Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1709319

Re: [PATCH v3] KVM: MMU: Fix guest stuck during boot due to read/write emulation against GVA

From David Hildenbrand <david@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3] KVM: MMU: Fix guest stuck during boot due to read/write emulation against GVA
Date 2017-08-11 09:00 +0200
Message-ID <udc5k-bt-11@gated-at.bofh.it> (permalink)
References <udbVE-7y-23@gated-at.bofh.it>
Organization Red Hat GmbH

Show all headers | View raw


On 11.08.2017 08:46, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> Commit c016004494b0 (KVM: x86: Avoid guest page table walk when gpa_available 
> is set) avoids the page table walk when cr2 has already contained a valid GPA. 
> However, that is not the truth if ept == 0 and shadow page table is used. In 
> this scenario cr2 can just contains a valid GVA. The commit results in guest 
> stuck during boot due to read/write emulation against GVA instead of GPA of 
> the guest.
> 
> This patch fixes it by setting the gpa_available flag under direct mode.  
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: David Hildenbrand <david@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
>  arch/x86/kvm/mmu.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 849312d..4780348 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -3791,8 +3791,11 @@ int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code,
>  
>  		if (need_unprotect && kvm_event_needs_reinjection(vcpu))
>  			kvm_mmu_unprotect_page_virt(vcpu, fault_address);
> -		vcpu->arch.gpa_available = true;
> -		vcpu->arch.gpa_val = fault_address;
> +		/* With shadow page tables, cr2 could contain a GVA, not a GPA */
> +		if (vcpu->arch.mmu.direct_map) {
> +			vcpu->arch.gpa_available = true;
> +			vcpu->arch.gpa_val = fault_address;
> +		}
>  		r = kvm_mmu_page_fault(vcpu, fault_address, error_code, insn,
>  				insn_len);
>  		break;
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3] KVM: MMU: Fix guest stuck during boot due to read/write emulation against GVA Wanpeng Li <kernellwp@gmail.com> - 2017-08-11 08:50 +0200
  Re: [PATCH v3] KVM: MMU: Fix guest stuck during boot due to  read/write emulation against GVA David Hildenbrand <david@redhat.com> - 2017-08-11 09:00 +0200
  Re: [PATCH v3] KVM: MMU: Fix guest stuck during boot due to  read/write emulation against GVA Paolo Bonzini <pbonzini@redhat.com> - 2017-08-11 17:10 +0200

csiph-web