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

(cherry picked from commit fefac543590db4e1461235b7c936f46026d0f318)

Details

Provenance
bnovkovAuthored on May 9 2023, 7:02 AM
corvinkCommitted on Aug 17 2023, 1:06 PM
Reviewer
corvink
Differential Revision
D39949: bhyve: Fix vCPU single-stepping on VMX
Parents
rG3152cbdd1657: bhyve: don't panic if e820 finds no available memory
Branches
Unknown
Tags
Unknown