* [PATCH] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
@ 2024-08-28 23:20 Sean Christopherson
2024-10-31 19:51 ` Sean Christopherson
0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2024-08-28 23:20 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
Wrap kvm_vcpu_exit_request()'s load of vcpu->mode with READ_ONCE() to
ensure the variable is re-loaded from memory, as there is no guarantee the
caller provides the necessary annotations to ensure KVM sees a fresh value,
e.g. the VM-Exit fastpath could theoretically reuse the pre-VM-Enter value.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/x86.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 70219e406987..d38fdb5f90dd 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2124,8 +2124,9 @@ EXPORT_SYMBOL_GPL(kvm_emulate_monitor);
static inline bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu)
{
xfer_to_guest_mode_prepare();
- return vcpu->mode == EXITING_GUEST_MODE || kvm_request_pending(vcpu) ||
- xfer_to_guest_mode_work_pending();
+
+ return READ_ONCE(vcpu->mode) == EXITING_GUEST_MODE ||
+ kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending();
}
/*
base-commit: 15e1c3d65975524c5c792fcd59f7d89f00402261
--
2.46.0.295.g3b9ea8a38a-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
2024-08-28 23:20 [PATCH] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request() Sean Christopherson
@ 2024-10-31 19:51 ` Sean Christopherson
2024-11-01 19:26 ` Sean Christopherson
0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2024-10-31 19:51 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
On Wed, 28 Aug 2024 16:20:13 -0700, Sean Christopherson wrote:
> Wrap kvm_vcpu_exit_request()'s load of vcpu->mode with READ_ONCE() to
> ensure the variable is re-loaded from memory, as there is no guarantee the
> caller provides the necessary annotations to ensure KVM sees a fresh value,
> e.g. the VM-Exit fastpath could theoretically reuse the pre-VM-Enter value.
Applied to kvm-x86 misc, thanks!
[1/1] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
https://github.com/kvm-x86/linux/commit/ba50bb4a9fb5
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
2024-10-31 19:51 ` Sean Christopherson
@ 2024-11-01 19:26 ` Sean Christopherson
0 siblings, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2024-11-01 19:26 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: kvm, linux-kernel
On Thu, Oct 31, 2024, Sean Christopherson wrote:
> On Wed, 28 Aug 2024 16:20:13 -0700, Sean Christopherson wrote:
> > Wrap kvm_vcpu_exit_request()'s load of vcpu->mode with READ_ONCE() to
> > ensure the variable is re-loaded from memory, as there is no guarantee the
> > caller provides the necessary annotations to ensure KVM sees a fresh value,
> > e.g. the VM-Exit fastpath could theoretically reuse the pre-VM-Enter value.
>
> Applied to kvm-x86 misc, thanks!
>
> [1/1] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
> https://github.com/kvm-x86/linux/commit/ba50bb4a9fb5
FYI, I rebased misc to v6.12-rc5, as patches in another series had already been
taken through the tip tree. New hash:
[1/1] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request()
https://github.com/kvm-x86/linux/commit/3ffe874ea3eb
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-01 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 23:20 [PATCH] KVM: x86: Ensure vcpu->mode is loaded from memory in kvm_vcpu_exit_request() Sean Christopherson
2024-10-31 19:51 ` Sean Christopherson
2024-11-01 19:26 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox