Skip to content

KVM: x86: Improve #DB handling in the emulator

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. v3 Latest10 patches 11 repliesApplied

Changes in v3 from the cover letter

- Fix the GUEST_PENDING_DBG_EXCEPTIONS.BS consistency check issue by stuffing the VMCS during injection, not during emulation.
- Drop a prep that is no longer necessary.
- Massage a few shortlogs/changelogs.
- Fix the selftest that takes an IRQ in the STI-shadow after IRET.
- Fix an intermediate bug where kvm_queue_exception_e() was being used instead of kvm_queue_exception_p().

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/10KVM: VMX: Refresh GUEST_PENDING_DBG_EXCEPTIONS.BS on all injected #DBsarch/x86/kvm/vmx/vmx.c+18 -173 replies
2/10KVM: x86: Capture "struct x86_exception" in inject_emulated_exception()arch/x86/kvm/x86.c+6 -71 reply
3/10KVM: x86: Set guest DR6 by kvm_queue_exception_p() in instruction emulationarch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h arch/x86/kvm/x86.c+18 -121 reply
4/10KVM: x86: Honor KVM_GUESTDBG_USE_HW_BP when emulating MOV DR (in emulator)arch/x86/kvm/emulate.c arch/x86/kvm/kvm_emulate.h arch/x86/kvm/x86.c+35 -91 reply
5/10KVM: x86: Honor KVM_GUESTDBG_USE_HW_BP when checking for code breakpoints in emulationarch/x86/kvm/x86.c+10 -250 replies
6/10KVM: x86: Move KVM_GUESTDBG_SINGLESTEP handling into kvm_inject_emulated_db()arch/x86/kvm/x86.c+2 -121 reply
7/10KVM: x86: Drop kvm_vcpu_do_singlestep() now that it's been guttedarch/x86/kvm/x86.c+2 -81 reply
8/10KVM: selftests: Add all (known) EFLAGS bit definitionstools/testing/selftests/kvm/include/x86/processor.h tools/testing/selftests/kvm/lib/x86/processor.c tools/testing/selftests/kvm/lib/x86/vmx.c+20 -30 replies
9/10KVM: selftests: Verify guest debug DR7.GD checking during instruction emulationtools/testing/selftests/kvm/x86/debug_regs.c+22 -11 reply
10/10KVM: selftests: Verify VMX's GUEST_PENDING_DBG_EXCEPTIONS.BS Consistency Checktools/testing/selftests/kvm/x86/debug_regs.c+60 -41 reply

Reviews trailers per patch

5 of 10 patches have a Reviewed-by or Acked-by.

PatchHou WenlongYosry Ahmed
1/10R-b
2/10R-b
3/10R-b
4/10
5/10
6/10R-b
7/10R-b
8/10
9/10
10/10

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/10] KVM: x86: Improve #DB handling in the emulator

Hou's series of fixes and cleanups related to #DB handling in the emulator.

v3:
- Fix the GUEST_PENDING_DBG_EXCEPTIONS.BS consistency check issue by stuffing the VMCS during injection, not during emulation.
- Drop a prep that is no longer necessary.
- Massage a few shortlogs/changelogs.
- Fix the selftest that takes an IRQ in the STI-shadow after IRET.
- Fix an intermediate bug where kvm_queue_exception_e() was being used instead of kvm_queue_exception_p().

v2:
- https://lore.kernel.org/all/[email protected]
- cleanup in inject_emulated_exception().
- rename 'set_pending_dbg' callback as 'refresh_pending_dbg_exceptions'.
- fold refresh_pending_dbg_exceptions() call into kvm_vcpu_do_singlestep().
- Split the change to move up kvm_set_rflags() into a single patch.
- Move the #DB and IRQ handler registration after guest debug testcases.

v1: https://lore.kernel.org/all/[email protected]

Hou Wenlong (7):
KVM: x86: Capture "struct x86_exception" in
inject_emulated_exception()
KVM: x86: Set guest DR6 by kvm_queue_exception_p() in instruction
emulation
KVM: x86: Honor KVM_GUESTDBG_USE_HW_BP when emulating MOV DR (in
emulator)
KVM: x86: Honor KVM_GUESTDBG_USE_HW_BP when checking for code
breakpoints in emulation
KVM: x86: Move KVM_GUESTDBG_SINGLESTEP handling into
kvm_inject_emulated_db()
KVM: selftests: Verify guest debug DR7.GD checking during instruction
emulation
KVM: selftests: Verify VMX's GUEST_PENDING_DBG_EXCEPTIONS.BS
Consistency Check

Sean Christopherson (3):
KVM: VMX: Refresh GUEST_PENDING_DBG_EXCEPTIONS.BS on all injected #DBs
KVM: x86: Drop kvm_vcpu_do_singlestep() now that it's been gutted
KVM: selftests: Add all (known) EFLAGS bit definitions

 arch/x86/kvm/emulate.c                        |  14 +--
 arch/x86/kvm/kvm_emulate.h                    |   7 +-
 arch/x86/kvm/vmx/vmx.c                        |  35 +++---
 arch/x86/kvm/x86.c                            | 111 +++++++++---------
 .../selftests/kvm/include/x86/processor.h     |  19 ++-
 .../testing/selftests/kvm/lib/x86/processor.c |   2 +-
 tools/testing/selftests/kvm/lib/x86/vmx.c     |   2 +-
 tools/testing/selftests/kvm/x86/debug_regs.c  |  83 ++++++++++++-
 8 files changed, 184 insertions(+), 89 deletions(-)

base-commit: b7fbe9a1bf9ee6c967ef77d366ca58c35fcf1887

Signature · 1 line
2.54.0.563.g4f69b47b94-goog