Skip to content

KVM: x86: Fix emulation of (some) L2 instructions

Sean Christopherson kvm lkml 1 version Applied

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

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest11 patches 1 replyApplied

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/11KVM: nVMX: Check PAUSE_EXITING, not BUS_LOCK_DETECTION, on PAUSE emulationarch/x86/kvm/vmx/vmx.c+1 -10 replies
2/11KVM: nSVM: Pass next RIP, not current RIP, for nested VM-Exit on emulationarch/x86/kvm/emulate.c+1 -10 replies
3/11KVM: nVMX: Allow emulating RDPID on behalf of L2arch/x86/kvm/vmx/vmx.c+7 -60 replies
4/11KVM: nVMX: Emulate HLT in L2 if it's not interceptedarch/x86/kvm/vmx/vmx.c+5 -00 replies
5/11KVM: nVMX: Consolidate missing X86EMUL_INTERCEPTED logic in L2 emulationarch/x86/kvm/vmx/vmx.c+7 -110 replies
6/11KVM: x86: Plumb the src/dst operand types through to .check_intercept()arch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h+4 -00 replies
7/11KVM: x86: Plumb the emulator's starting RIP into nested intercept checksarch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h+2 -00 replies
8/11KVM: x86: Add a #define for the architectural max instruction lengtharch/x86/kvm/kvm_emulate.h arch/x86/kvm/trace.h arch/x86/kvm/vmx/nested.c+11 -90 replies
9/11KVM: nVMX: Allow the caller to provide instruction length on nested VM-Exitarch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/nested.h+27 -70 replies
10/11KVM: nVMX: Synthesize nested VM-Exit for supported emulation interceptsarch/x86/kvm/vmx/vmx.c+56 -140 replies
11/11KVM: selftests: Add a nested (forced) emulation intercept test for x86tools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/x86/nested_emulation_test.c+147 -00 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH v2 00/11] KVM: x86: Fix emulation of (some) L2 instructions

Fix a variety of bugs related to emulating instructions on behalf of L2, and (finally) add support for synthesizing nested VM-Exit to L1 when L1 wants to intercept an instruction (KVM currently injects a #UD into L2).

There's no real motivation behind this series. I spotted the PAUSE_EXITING vs. BUS_LOCK_DETECTION goof when sorting out a report/question about HLT emulation in L2 doing weird things, and then stupidly thought "how hard can it be to generate a VM-Exit?". Turns out, not that hard, but definitely a bit harder than I was anticipating due to the annoying RIP vs. next RIP flaw.

Given that VMX has literally never done the right thing, and SVM was quite broken since the beginning, I doubt anyone cares about this, but we have the code, so why not...

Sean Christopherson (11):
KVM: nVMX: Check PAUSE_EXITING, not BUS_LOCK_DETECTION, on PAUSE
emulation
KVM: nSVM: Pass next RIP, not current RIP, for nested VM-Exit on
emulation
KVM: nVMX: Allow emulating RDPID on behalf of L2
KVM: nVMX: Emulate HLT in L2 if it's not intercepted
KVM: nVMX: Consolidate missing X86EMUL_INTERCEPTED logic in L2
emulation
KVM: x86: Plumb the src/dst operand types through to
.check_intercept()
KVM: x86: Plumb the emulator's starting RIP into nested intercept
checks
KVM: x86: Add a #define for the architectural max instruction length
KVM: nVMX: Allow the caller to provide instruction length on nested
VM-Exit
KVM: nVMX: Synthesize nested VM-Exit for supported emulation
intercepts
KVM: selftests: Add a nested (forced) emulation intercept test for x86

 arch/x86/kvm/emulate.c                        |   5 +-
 arch/x86/kvm/kvm_emulate.h                    |   7 +-
 arch/x86/kvm/trace.h                          |  14 +-
 arch/x86/kvm/vmx/nested.c                     |  14 +-
 arch/x86/kvm/vmx/nested.h                     |  22 ++-
 arch/x86/kvm/vmx/vmx.c                        | 102 ++++++++----
 tools/testing/selftests/kvm/Makefile.kvm      |   1 +
 .../selftests/kvm/x86/nested_emulation_test.c | 146 ++++++++++++++++++
 8 files changed, 265 insertions(+), 46 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86/nested_emulation_test.c

base-commit: eb723766b1030a23c38adf2348b7c3d1409d11f0

Signature · 1 line
2.48.1.362.g079036d154-goog