Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH v4 0/6] KVM: nVMX: Synthesize SHUTDOWN on RSM with bad state
@ 2026-07-28  0:43 Sean Christopherson
  2026-07-28  0:43 ` [PATCH v4 1/6] KVM: x86: Extract VMX's unhandleable emulation check to common x86 Sean Christopherson
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Sean Christopherson @ 2026-07-28  0:43 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, Hao Zhang

Synthesize SHUTDOWN if invalid guest state is detected a RSM, i.e. if SMRAM
is clobbered by L1 (or host userspace) while handling an SMI that occurred
while L2 was active.  This fixes yet another case of syzkaller tripping KVM's
sanity check that KVM doesn't cancel a pending nested VM-Enter.

Hao, can you provide your Signed-off-by for the selftest, assuming it looks
good to you?  Thanks!

v4:
 - Synthesize SHUTDOWN instead of trying to suppress the KVM_BUG_ON().
 - Add a selftest.

v3:
 - https://lore.kernel.org/all/al8M4gCwsWXS_jMs@192.168.1.215
 - Retain KVM_NESTED_RUN_PENDING_UNTRUSTED until after
   sync_vmcs02_to_vmcs12(), to avoid saving VMCS12 fields that are valid
   only after L2 has actually run.
 - Clear the untrusted pending state before restoring L1 state to avoid
   leaking nested_run_pending into L1 and blocking event injection.
 - Clarify the VMX pending-run BUG comment and update the changelog.
 - Tested with the syzkaller repro on the fixed kernel, no WARNING/KVM_BUG
   in the repro log

v2:
 - https://lore.kernel.org/all/al8M4gCwsWXS_jMs@192.168.1.215
 - Mark nested state restored by RSM from SMRAM as KVM_NESTED_RUN_PENDING_UNTRUSTED.
 - Keep the BUG check in __vmx_handle_exit(), but make it apply only to KVM_NESTED_RUN_PENDING.

v1: https://lore.kernel.org/all/al3Qbq-jUYE-_72N@192.168.1.215

Hao Zhang (1):
  KVM: selftests: Extend the invalid nVMX guest state test to cover RSM

Sean Christopherson (5):
  KVM: x86: Extract VMX's unhandleable emulation check to common x86
  KVM: nVMX: Synthesize SHUTDOWN on RSM if L2 requires emulation
  KVM: x86: Rework kvm_x86_ops.vcpu_pre_run() into
    .vcpu_needs_initialization()
  KVM: selftests: Use port 0x80 in invalid nVMX guest state test
  KVM: selftests: Refactor invalid nVMX state test to prepare for RSM
    testcase

 arch/x86/include/asm/kvm-x86-ops.h            |   3 +-
 arch/x86/include/asm/kvm_host.h               |   4 +-
 arch/x86/kvm/smm.c                            |   4 +
 arch/x86/kvm/svm/sev.c                        |   5 +
 arch/x86/kvm/svm/svm.c                        |  12 +-
 arch/x86/kvm/svm/svm.h                        |   1 +
 arch/x86/kvm/vmx/main.c                       |  21 +++-
 arch/x86/kvm/vmx/tdx.c                        |   9 +-
 arch/x86/kvm/vmx/vmx.c                        |  12 +-
 arch/x86/kvm/vmx/x86_ops.h                    |   4 +-
 arch/x86/kvm/x86.c                            |  10 +-
 .../kvm/x86/vmx_invalid_nested_guest_state.c  | 118 ++++++++++++++----
 12 files changed, 143 insertions(+), 60 deletions(-)


base-commit: 271255273d5ff348fe29d89fe4712b2f7f7907c3
-- 
2.55.0.229.g6434b31f56-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-07-28  3:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28  0:43 [PATCH v4 0/6] KVM: nVMX: Synthesize SHUTDOWN on RSM with bad state Sean Christopherson
2026-07-28  0:43 ` [PATCH v4 1/6] KVM: x86: Extract VMX's unhandleable emulation check to common x86 Sean Christopherson
2026-07-28  0:58   ` sashiko-bot
2026-07-28  1:01     ` Sean Christopherson
2026-07-28  0:43 ` [PATCH v4 2/6] KVM: nVMX: Synthesize SHUTDOWN on RSM if L2 requires emulation Sean Christopherson
2026-07-28  0:43 ` [PATCH v4 3/6] KVM: x86: Rework kvm_x86_ops.vcpu_pre_run() into .vcpu_needs_initialization() Sean Christopherson
2026-07-28  0:43 ` [PATCH v4 4/6] KVM: selftests: Use port 0x80 in invalid nVMX guest state test Sean Christopherson
2026-07-28  0:43 ` [PATCH v4 5/6] KVM: selftests: Refactor invalid nVMX state test to prepare for RSM testcase Sean Christopherson
2026-07-28  0:51   ` sashiko-bot
2026-07-28  0:43 ` [PATCH v4 6/6] KVM: selftests: Extend the invalid nVMX guest state test to cover RSM Sean Christopherson
2026-07-28  3:01   ` Hao Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox