Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@linux.alibaba.com>
To: David Matlack <dmatlack@google.com>, kvm@vger.kernel.org
Cc: seanjc@google.com, pbonzini@redhat.com, vkuznets@redhat.com
Subject: Re: VM_BUG_ON in vmx_prepare_switch_to_guest->__get_current_cr3_fast at kvm/queue
Date: Sat, 11 Dec 2021 09:04:58 +0800	[thread overview]
Message-ID: <bbde6da2-9441-53c1-6b7c-bb6551933a2e@linux.alibaba.com> (raw)
In-Reply-To: <b66710af-4f52-4097-9cba-27703c49f784@linux.alibaba.com>



On 2021/12/11 07:54, Lai Jiangshan wrote:
> 
> 
> On 2021/12/11 01:57, David Matlack wrote:
>> While testing some patches I ran into a VM_BUG_ON that I have been able to
>> reproduce at kvm/queue commit 45af1bb99b72 ("KVM: VMX: Clean up PI
>> pre/post-block WARNs").
>>
>> To repro run the kvm-unit-tests on a kernel built from kvm/queue with
>> CONFIG_DEBUG_VM=y. I was testing on an Intel Cascade Lake host and have not
>> tested in any other environments yet. The repro is not 100% reliable, although
>> it's fairly easy to trigger and always during a vmx* kvm-unit-tests
>>
>> Given the details of the crash, commit 15ad9762d69f ("KVM: VMX: Save HOST_CR3
>> in vmx_prepare_switch_to_guest()") and surrounding commits look most suspect.
> 
> Hello, is it producible if this commit is reverted?
> 
> Which test in kvm-unit-tests can trigger it?

Hello, commit 15ad9762d69f ("KVM: VMX: Save HOST_CR3
in vmx_prepare_switch_to_guest()") must be the culprit.

Is the test related to nested vmx?

Could you also apply the following patch and retest please.

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 95f3823b3a9d..c93849be73f1 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -251,6 +251,10 @@ static void vmx_sync_vmcs_host_state(struct vcpu_vmx *vmx,
  	dest->ds_sel = src->ds_sel;
  	dest->es_sel = src->es_sel;
  #endif
+	if (unlikely(dest->cr3 != src->cr3)) {
+		vmcs_writel(HOST_CR3, src->cr3);
+		dest->cr3 = src->cr3;
+	}
  }

  static void vmx_switch_vmcs(struct kvm_vcpu *vcpu, struct loaded_vmcs *vmcs)

  reply	other threads:[~2021-12-11  1:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 17:57 VM_BUG_ON in vmx_prepare_switch_to_guest->__get_current_cr3_fast at kvm/queue David Matlack
2021-12-10 23:54 ` Lai Jiangshan
2021-12-11  1:04   ` Lai Jiangshan [this message]
2021-12-11  0:11 ` Paolo Bonzini
2021-12-11  2:01   ` Paolo Bonzini
2021-12-11  3:14     ` Lai Jiangshan

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=bbde6da2-9441-53c1-6b7c-bb6551933a2e@linux.alibaba.com \
    --to=laijs@linux.alibaba.com \
    --cc=dmatlack@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    /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