linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brijesh Singh <brijesh.singh@amd.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: brijesh.singh@amd.com, pbonzini@redhat.com, joro@8bytes.org,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	x86@kernel.org, Thomas.Lendacky@amd.com
Subject: Re: [PATCH v2] KVM: x86: Avoid guest page table walk when gpa_available is set
Date: Tue, 8 Aug 2017 14:24:59 -0500	[thread overview]
Message-ID: <2aa4bae3-79ef-0988-0333-813af04382a4@amd.com> (raw)
In-Reply-To: <20170720074316.GA30718@potion>

Hi Radim,


On 07/20/2017 02:43 AM, Radim Krčmář wrote:
> 2017-07-19 08:35-0500, Brijesh Singh:
>> On 07/19/2017 06:19 AM, Radim Krčmář wrote:
>>> 2017-07-17 16:32-0500, Brijesh Singh:
>>>> Hi Paolo and Radim
>>>>
>>>> Any comments on this patch, I could not find it in 4.13-2 branch.
>>>>
>>>> Please let me know if you want to fix something, or want me to
>>>> refresh and resend the patch.
>>>
>>> Sorry, I tried it during the merge window, but it didn't pass tests on
>>> VMX and I got distracted by other bugs before looking into the cause.
>>>
>>> Can you reproduce the fail?
>>>
>>
>> No worries, thanks.
>>
>> I can try to reproduce it, are you running kvm-unittest or something different?
> 
> I noticed that a linux guest hung in early boot, but at least (io)apic
> kvm-unit-tests failed as well, IIRC.
> 
>> IIRC, VMX does not set the gpa_available flag hence I am wondering what did I miss
>> in the patch to trigger the failure. I will debug it and let you know.
> 
> It does now, in ept_violation and ept_misconfig,
> 

I am able to reproduce the issue on VMX, Sorry it took a bit longer to verify
it.

I was not aware that VMX is also making use of gpa_available flag hence I missed
updating the vmx.c to set the gpa_val. After applying the below small patch I am
able to boot the guest on Intel Xeon E5-2665.

Additionally, there was one issue in current patch pointed by Paolo [1]. If patch
was using vcpu->arch.gpa_val check as pointed by Paolo then on VMX we will silently
fallback to guest page table walk (even when gpa_available is set). I guess since I
have testing my code on SVM platform hence never caught the error. I will soon send
updated patch.

[1] http://marc.info/?l=kvm&m=150116338725964&w=2

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b5e0b02..9309fbb 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6309,6 +6309,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu)
                       ? PFERR_PRESENT_MASK : 0;
  
         vcpu->arch.gpa_available = true;
+       vcpu->arch.gpa_val = gpa;
         vcpu->arch.exit_qualification = exit_qualification;
  
         return kvm_mmu_page_fault(vcpu, gpa, error_code, NULL, 0);
@@ -6326,6 +6327,7 @@ static int handle_ept_misconfig(struct kvm_vcpu *vcpu)
         }
  
         ret = handle_mmio_page_fault(vcpu, gpa, true);
+       vcpu->arch.gpa_val = gpa;
         vcpu->arch.gpa_available = true;
         if (likely(ret == RET_MMIO_PF_EMULATE))
                 return x86_emulate_instruction(vcpu, gpa, 0, NULL, 0) ==

  reply	other threads:[~2017-08-08 19:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 15:12 [PATCH v2] KVM: x86: Avoid guest page table walk when gpa_available is set Brijesh Singh
2017-05-30  9:05 ` Joerg Roedel
2017-05-30 22:09   ` Brijesh Singh
2017-07-17 21:32 ` Brijesh Singh
2017-07-19 11:19   ` Radim Krčmář
2017-07-19 13:35     ` Brijesh Singh
2017-07-20  7:43       ` Radim Krčmář
2017-08-08 19:24         ` Brijesh Singh [this message]
2017-07-27 13:49 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2aa4bae3-79ef-0988-0333-813af04382a4@amd.com \
    --to=brijesh.singh@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).