Skip to content

KVM: nVMX: Synthesize SHUTDOWN on RSM with bad state

Sean Christopherson kvm lkml 2 versions – Applied

Status from this message: Applied to kvm-x86 misc, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 1 replyApplied
  2. v46 patches 2 repliesSuperseded

Changes in v5 from the cover letter

- Fix goofs in patch 1. [Sashiko]
- Print out correct target L1 vs. L2. [Sashiko]

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/6KVM: x86: Extract VMX's unhandleable emulation check to common x86arch/x86/include/asm/kvm-x86-ops.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/vmx/main.c +3 more+21 -60 replies
2/6KVM: nVMX: Synthesize SHUTDOWN on RSM if L2 requires emulationarch/x86/kvm/smm.c+4 -00 replies
3/6KVM: x86: Rework kvm_x86_ops.vcpu_pre_run() into .vcpu_needs_initialization()arch/x86/include/asm/kvm-x86-ops.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/sev.c +7 more+21 -330 replies
4/6KVM: selftests: Use port 0x80 in invalid nVMX guest state testtools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c+3 -30 replies
5/6KVM: selftests: Refactor invalid nVMX state test to prepare for RSM testcasetools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c+42 -190 replies
6/6KVM: selftests: Extend the invalid nVMX guest state test to cover RSMtools/testing/selftests/kvm/x86/vmx_invalid_nested_guest_state.c+53 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/6] KVM: nVMX: Synthesize SHUTDOWN on RSM with bad state

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.

v5:
- Fix goofs in patch 1. [Sashiko]
- Print out correct target L1 vs. L2. [Sashiko]

v4:
- https://lore.kernel.org/all/[email protected]
- Synthesize SHUTDOWN instead of trying to suppress the KVM_BUG_ON().
- Add a selftest.

v3:
- https://lore.kernel.org/all/[email protected]
- 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/[email protected]
- 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/[email protected]

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: 3c7d7f908d574277a845423ec32250a8d8df44c8

Signature · 1 line
2.55.0.508.g3f0d502094-goog