From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932979AbcIENCs (ORCPT ); Mon, 5 Sep 2016 09:02:48 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35641 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932127AbcIENCp (ORCPT ); Mon, 5 Sep 2016 09:02:45 -0400 Subject: Re: [PATCH] KVM: nVMX: pass valid guest linear-address to the L1 To: Wanpeng Li References: <1473013367-12173-1-git-send-email-jan.dakinevich@gmail.com> Cc: kvm , Paolo Bonzini , Radim Krcmar , "linux-kernel@vger.kernel.org" , ynorov@caviumnetworks.com From: Jan Dakinevich Message-ID: <9db16fce-3813-2882-bec5-abd279a8a3a1@gmail.com> Date: Mon, 5 Sep 2016 16:02:41 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/2016 03:49 AM, Wanpeng Li wrote: > 2016-09-05 2:22 GMT+08:00 Jan Dakinevich : >> If EPT support is exposed to L1 hypervisor, guest linear-address field >> of VMCS should contain GVA of L2, the access to which caused EPT violation. >> >> Signed-off-by: Jan Dakinevich >> --- >> arch/x86/kvm/vmx.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index 5cede40..a4bb2bd 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -10500,6 +10500,9 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, >> vmcs12->guest_pdptr3 = vmcs_read64(GUEST_PDPTR3); >> } >> >> + if (nested_cpu_has_ept(vmcs12)) >> + vmcs12->guest_linear_address = vmcs_readl(GUEST_LINEAR_ADDRESS); >> + > > No, nested_ept_inject_page_fault() will set > vmcs12->guest_linear_address after L0 walks L1's EPT page table and > finds that the mapping is invalid if nested EPT is enabled. Acctually, nested_ept_inject_page_fault() doesn't do that, the routine sets only vmcs12->guest_physical_address, but vmcs12->guest_linear_address remains untouched. As result, after EPT fault from L2, vmcs_readl(GUEST_LINEAR_ADDRESS) in L1 always returns 0. > prepare_vmcs12() just copies the vmcs field that could have changed by > the L2 guest or the exit-information etc instead of all fields since > other fields are modified by L1 with VMWRITE, which already writes to > vmcs12 directly. Yes, and guest linear-address considered as a part of exit information, provided by hardware. > > Regards, > Wanpeng Li > -- Best regards Jan Dakinevich