HomeFreeBSD

bhyve: fix vCPU single-stepping on VMX

Description

bhyve: fix vCPU single-stepping on VMX

This patch fixes virtual machine single stepping on VMX hosts.

Currently, when using bhyve's gdb stub, each attempt at single-stepping
a vCPU lands in a timer interrupt. The current single-stepping mechanism
uses the Monitor Trap Flag feature to cause VMEXIT after a single
instruction is executed. Unfortunately, the SDM states that MTF causes
VMEXITs for the next instruction that gets executed, which is often not
what the person using the debugger expects. [1]

This patch adds a new VM capability that masks interrupts on a vCPU by
blocking interrupt injection and modifies the gdb stub to use the newly
added capability while single-stepping a vCPU.

[1] Intel SDM 26.5.2 Vol. 3C

Reviewed by: corvink, jbh
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39949

Details

Provenance
bnovkovAuthored on May 9 2023, 7:02 AM
corvinkCommitted on May 9 2023, 8:04 AM
Reviewer
corvink
Differential Revision
D39949: bhyve: Fix vCPU single-stepping on VMX
Parents
rGb0cf48305f7f: em(4): update sysctl list, mention iflib(4)
Branches
Unknown
Tags
Unknown