mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Chenyi Qiang <chenyi.qiang@intel.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>
Subject: Re: [RFC v2 2/2] KVM: VMX: Enable bus lock VM exit
Date: Wed, 2 Sep 2020 18:25:06 -0700	[thread overview]
Message-ID: <20200903012506.GM11695@sjchrist-ice> (raw)
In-Reply-To: <2e12df9d-4d56-d6c2-3470-9c990ab722c5@intel.com>

On Thu, Sep 03, 2020 at 08:52:41AM +0800, Xiaoyao Li wrote:
> On 9/3/2020 6:44 AM, Sean Christopherson wrote:
> > On Tue, Sep 01, 2020 at 10:43:12AM +0200, Vitaly Kuznetsov wrote:
> > > > +			vcpu->arch.bus_lock_detected = true;
> > > > +		} else {
> > > > +			vcpu->arch.bus_lock_detected = false;
> > > 
> > > This is a fast path so I'm wondering if we can move bus_lock_detected
> > > clearing somewhere else.
> > 
> > Why even snapshot vmx->exit_reason.bus_lock_detected?  I don't see any
> > reason why vcpu_enter_guest() needs to handle the exit to userspace, e.g.
> > it's just as easily handled in VMX code.
> 
> Because we want to handle the exit to userspace only in one place, i.e.,
> after kvm_x86_ops.handle_exit(vcpu, exit_fastpath). Otherwise, we would have
> to check vmx->exit_reason.bus_lock_detected in every other handler, at least
> in those can preempt the bus lock VM-exit theoretically.

That's not hard to do in vmx.c, e.g.

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0316b86bad43a..ea2fed7f21565 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -5677,7 +5677,7 @@ void dump_vmcs(void)
  * The guest has exited.  See if we can fix it or if we need userspace
  * assistance.
  */
-static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
+static int __vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
        u32 exit_reason = vmx->exit_reason;
@@ -5822,6 +5822,22 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
        return 0;
 }

+static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
+{
+       int ret = __vmx_handle_exit(vcpu, exit_fastpath);
+
+       if (vmx->exit_reason.bus_lock_detected) {
+               if (ret)
+                       vcpu->run->exit_reason = KVM_EXIT_BUS_LOCK;
+               else
+                       vcpu->run->flags |= KVM_RUN_BUS_LOCK;
+               return 0;
+       }
+
+       vcpu->run->flags &= ~KVM_RUN_BUS_LOCK;
+       return ret;
+}
+
 /*
  * Software based L1D cache flush which is used when microcode providing
  * the cache control MSR is not loaded.


      reply	other threads:[~2020-09-03  1:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17  1:44 [RFC v2 0/2] add bus lock VM exit support Chenyi Qiang
2020-08-17  1:44 ` [RFC v2 1/2] KVM: VMX: Convert vcpu_vmx.exit_reason to a union Chenyi Qiang
2020-08-17  1:44 ` [RFC v2 2/2] KVM: VMX: Enable bus lock VM exit Chenyi Qiang
2020-09-01  8:43   ` Vitaly Kuznetsov
2020-09-02  5:19     ` Chenyi Qiang
2020-09-02 22:44     ` Sean Christopherson
2020-09-03  0:52       ` Xiaoyao Li
2020-09-03  1:25         ` Sean Christopherson [this message]

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=20200903012506.GM11695@sjchrist-ice \
    --to=sean.j.christopherson@intel.com \
    --cc=chenyi.qiang@intel.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=xiaoyao.li@intel.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

all inboxes | Powered by JetHome®