* [PATCH] KVM: x86: Ignore -EBUSY when checking nested events from vcpu_block()
@ 2026-01-09 3:06 Sean Christopherson
2026-01-15 18:03 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2026-01-09 3:06 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Alessandro Ratti, syzbot+1522459a74d26b0ac33a
Ignore -EBUSY when checking nested events after exiting a blocking state
while L2 is active, as exiting to userspace will generate a spurious
userspace exit, usually with KVM_EXIT_UNKNOWN, and likely lead to the VM's
demise. Continuing with the wakeup isn't perfect either, as *something*
has gone sideways if a vCPU is awakened in L2 with an injected event (or
worse, a nested run pending), but continuing on gives the VM a decent
chance of surviving without any major side effects.
As explained in the Fixes commits, it _should_ be impossible for a vCPU to
be put into a blocking state with an already-injected event (exception,
IRQ, or NMI). Unfortunately, userspace can stuff MP_STATE and/or injected
events, and thus put the vCPU into what should be an impossible state.
Don't bother trying to preserve the WARN, e.g. with an anti-syzkaller
Kconfig, as WARNs can (hopefully) be added in paths where _KVM_ would be
violating x86 architecture, e.g. by WARNing if KVM attempts to inject an
exception or interrupt while the vCPU isn't running.
Cc: Alessandro Ratti <alessandro@0x65c.net>
Cc: stable@vger.kernel.org
Fixes: 26844fee6ade ("KVM: x86: never write to memory from kvm_vcpu_check_block()")
Fixes: 45405155d876 ("KVM: x86: WARN if a vCPU gets a valid wakeup that KVM can't yet inject")
Link: https://syzkaller.appspot.com/text?tag=ReproC&x=10d4261a580000
Reported-by: syzbot+1522459a74d26b0ac33a@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/671bc7a7.050a0220.455e8.022a.GAE@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/x86.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ff8812f3a129..4bf9be1e17a7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11596,8 +11596,7 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu)
if (is_guest_mode(vcpu)) {
int r = kvm_check_nested_events(vcpu);
- WARN_ON_ONCE(r == -EBUSY);
- if (r < 0)
+ if (r < 0 && r != -EBUSY)
return 0;
}
base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86: Ignore -EBUSY when checking nested events from vcpu_block()
2026-01-09 3:06 [PATCH] KVM: x86: Ignore -EBUSY when checking nested events from vcpu_block() Sean Christopherson
@ 2026-01-15 18:03 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2026-01-15 18:03 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini
Cc: kvm, linux-kernel, Alessandro Ratti, syzbot+1522459a74d26b0ac33a
On Thu, 08 Jan 2026 19:06:57 -0800, Sean Christopherson wrote:
> Ignore -EBUSY when checking nested events after exiting a blocking state
> while L2 is active, as exiting to userspace will generate a spurious
> userspace exit, usually with KVM_EXIT_UNKNOWN, and likely lead to the VM's
> demise. Continuing with the wakeup isn't perfect either, as *something*
> has gone sideways if a vCPU is awakened in L2 with an injected event (or
> worse, a nested run pending), but continuing on gives the VM a decent
> chance of surviving without any major side effects.
>
> [...]
Applied to kvm-x86 misc, thanks!
[1/1] KVM: x86: Ignore -EBUSY when checking nested events from vcpu_block()
https://github.com/kvm-x86/linux/commit/ead63640d4e7
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-15 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-09 3:06 [PATCH] KVM: x86: Ignore -EBUSY when checking nested events from vcpu_block() Sean Christopherson
2026-01-15 18:03 ` Sean Christopherson
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®