From: Hao Xiang <hao.xiang@linux.alibaba.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, pbonzini@redhat.com,
seanjc@google.com, shannon.zhao@linux.alibaba.com,
Hao Xiang <hao.xiang@linux.alibaba.com>
Subject: [PATCH] KVM: VMX: Remove redundant handling of bus lock vmexit
Date: Mon, 27 Sep 2021 13:53:22 +0800 [thread overview]
Message-ID: <1632722002-25003-1-git-send-email-hao.xiang@linux.alibaba.com> (raw)
exit_reason.bus_lock_detected may or may not be set when exit reason is
EXIT_REASON_BUS_LOCK. It is non-deterministic hardware behavior. Dealing
with KVM_RUN_X86_BUS_LOCK in handle_bus_lock_vmexit could be redundant
when exit_reason.basic is EXIT_REASON_BUS_LOCK.
We can remove redundant handling of bus lock vmexit. Set
exit_reason.bus_lock_detected (bit 26) unconditionally, and deal with
KVM_RUN_X86_BUS_LOCK only in vmx_handle_exit.
Signed-off-by: Hao Xiang <hao.xiang@linux.alibaba.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/vmx/vmx.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0c2c0d5..f993c38 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -5561,9 +5561,13 @@ static int handle_encls(struct kvm_vcpu *vcpu)
static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
{
- vcpu->run->exit_reason = KVM_EXIT_X86_BUS_LOCK;
- vcpu->run->flags |= KVM_RUN_X86_BUS_LOCK;
- return 0;
+ struct vcpu_vmx *vmx = to_vmx(vcpu);
+
+ /* The dedicated flag (bit 26 of exit reason in vmcs field) may or may
+ * not be set by hardware.
+ */
+ vmx->exit_reason.bus_lock_detected = true;
+ return 1;
}
/*
@@ -6050,9 +6054,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
int ret = __vmx_handle_exit(vcpu, exit_fastpath);
/*
- * Even when current exit reason is handled by KVM internally, we
- * still need to exit to user space when bus lock detected to inform
- * that there is a bus lock in guest.
+ * Exit to user space when bus lock detected to inform that there is
+ * a bus lock in guest.
*/
if (to_vmx(vcpu)->exit_reason.bus_lock_detected) {
if (ret > 0)
--
1.8.3.1
reply other threads:[~2021-09-27 5:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1632722002-25003-1-git-send-email-hao.xiang@linux.alibaba.com \
--to=hao.xiang@linux.alibaba.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shannon.zhao@linux.alibaba.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®