lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 18 Jan 2018 09:36:16 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     KarimAllah Ahmed <karahmed@...zon.de>, kvm@...r.kernel.org
Cc:     Radim Krčmář <rkrcmar@...hat.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] kvm: Map PFN-type memory regions as writable (if
 possible)

On 17/01/2018 19:18, KarimAllah Ahmed wrote:
> For EPT-violations that are triggered by a read, the pages are also mapped with
> write permissions (if their memory region is also writable). That would avoid
> getting yet another fault on the same page when a write occurs.
> 
> This optimization only happens when you have a "struct page" backing the memory
> region. So also enable it for memory regions that do not have a "struct page".
> 
> Cc: Paolo Bonzini <pbonzini@...hat.com>
> Cc: Radim Krčmář <rkrcmar@...hat.com>
> Cc: kvm@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> Signed-off-by: KarimAllah Ahmed <karahmed@...zon.de>
> 
> ---
> v2:
> - Move setting writable to hva_to_pfn_remapped
> - Extend hva_to_pfn_remapped interface to accept writable as a parameter

Reviewed-by: Paolo Bonzini <pbonzini@...hat.com>

> ---
>  virt/kvm/kvm_main.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 97da45e..88702d5 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1438,7 +1438,8 @@ static bool vma_is_valid(struct vm_area_struct *vma, bool write_fault)
>  
>  static int hva_to_pfn_remapped(struct vm_area_struct *vma,
>  			       unsigned long addr, bool *async,
> -			       bool write_fault, kvm_pfn_t *p_pfn)
> +			       bool write_fault, bool *writable,
> +			       kvm_pfn_t *p_pfn)
>  {
>  	unsigned long pfn;
>  	int r;
> @@ -1464,6 +1465,8 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
>  
>  	}
>  
> +	if (writable)
> +		*writable = true;
>  
>  	/*
>  	 * Get a reference here because callers of *hva_to_pfn* and
> @@ -1529,7 +1532,7 @@ static kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
>  	if (vma == NULL)
>  		pfn = KVM_PFN_ERR_FAULT;
>  	else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
> -		r = hva_to_pfn_remapped(vma, addr, async, write_fault, &pfn);
> +		r = hva_to_pfn_remapped(vma, addr, async, write_fault, writable, &pfn);
>  		if (r == -EAGAIN)
>  			goto retry;
>  		if (r < 0)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ