lkml.org 
[lkml]   [2018]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] kvm: Map PFN-type memory regions as writable (if possible)
From
Date
On 17/01/2018 18:26, 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@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>
> ---
> virt/kvm/kvm_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 97da45e..0efb089 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1534,6 +1534,8 @@ static kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
> goto retry;
> if (r < 0)
> pfn = KVM_PFN_ERR_FAULT;
> + if (writable)
> + *writable = true;
> } else {
> if (async && vma_is_valid(vma, write_fault))
> *async = true;
>

Looks good, but it should be in hva_to_pfn_remapped.

Paolo

\
 
 \ /
  Last update: 2018-01-18 00:21    [W:0.067 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site