From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hao Xiang <hao.xiang@linux.alibaba.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sasha Levin <sashal@kernel.org>,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, kvm@vger.kernel.org
Subject: [PATCH MANUALSEL 5.14 3/5] KVM: VMX: Remove redundant handling of bus lock vmexit
Date: Mon, 25 Oct 2021 16:38:25 -0400 [thread overview]
Message-ID: <20211025203828.1404503-3-sashal@kernel.org> (raw)
In-Reply-To: <20211025203828.1404503-1-sashal@kernel.org>
From: Hao Xiang <hao.xiang@linux.alibaba.com>
[ Upstream commit d61863c66f9b443192997613cd6aeca3f65cc313 ]
Hardware may or may not set exit_reason.bus_lock_detected on BUS_LOCK
VM-Exits. 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. Unconditionally Set
exit_reason.bus_lock_detected in handle_bus_lock_vmexit(), and deal with
KVM_RUN_X86_BUS_LOCK only in vmx_handle_exit().
Signed-off-by: Hao Xiang <hao.xiang@linux.alibaba.com>
Message-Id: <1634299161-30101-1-git-send-email-hao.xiang@linux.alibaba.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 55de1eb135f9..87150b3c9c5f 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -5551,9 +5551,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;
+ /*
+ * Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK
+ * VM-Exits. Unconditionally set the flag here and leave the handling to
+ * vmx_handle_exit().
+ */
+ to_vmx(vcpu)->exit_reason.bus_lock_detected = true;
+ return 1;
}
/*
@@ -6039,9 +6043,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)
--
2.33.0
next prev parent reply other threads:[~2021-10-25 20:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 20:38 [PATCH MANUALSEL 5.14 1/5] KVM: X86: fix lazy allocation of rmaps Sasha Levin
2021-10-25 20:38 ` [PATCH MANUALSEL 5.14 2/5] KVM: x86: WARN if APIC HW/SW disable static keys are non-zero on unload Sasha Levin
2021-10-26 16:15 ` Paolo Bonzini
2021-10-25 20:38 ` Sasha Levin [this message]
2021-10-26 16:15 ` [PATCH MANUALSEL 5.14 3/5] KVM: VMX: Remove redundant handling of bus lock vmexit Paolo Bonzini
2021-10-25 20:38 ` [PATCH MANUALSEL 5.14 4/5] KVM: SEV-ES: Set guest_state_protected after VMSA update Sasha Levin
2021-10-26 16:16 ` Paolo Bonzini
2021-10-25 20:38 ` [PATCH MANUALSEL 5.14 5/5] KVM: MMU: Reset mmu->pkru_mask to avoid stale data Sasha Levin
2021-10-26 16:17 ` Paolo Bonzini
2021-10-26 16:14 ` [PATCH MANUALSEL 5.14 1/5] KVM: X86: fix lazy allocation of rmaps Paolo Bonzini
2021-10-26 17:32 ` Sasha Levin
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=20211025203828.1404503-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hao.xiang@linux.alibaba.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
--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