HomeFreeBSD

vmm: implement single-stepping for AMD CPUs

Description

vmm: implement single-stepping for AMD CPUs

This patch implements single-stepping for AMD CPUs using the RFLAGS.TF
single-stepping mechanism. The GDB stub requests single-stepping
using the VM_CAP_RFLAGS_TF capability. Setting this capability will
set the RFLAGS.TF bit on the selected vCPU, activate DB exception
intercepts, and activate POPF/PUSH instruction intercepts. The
resulting DB exception is then caught by the IDT_DB vmexit handler and
bounced to userland where it is processed by the GDB stub. This patch
also makes sure that the value of the TF bit is correctly updated and
that it is not erroneously propagated into memory. Stepping over PUSHF
will cause the vm_handle_db function to correct the pushed RFLAGS
value and stepping over POPF will update the shadowed TF bit copy.

Reviewed by: jhb
Sponsored by: Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D42296

(cherry picked from commit e3b4fe645e50bfd06becb74e52ea958315024d5f)

Details

Provenance
bnovkovAuthored on Dec 7 2023, 11:00 PM
jhbCommitted on Jan 5 2024, 12:25 AM
Reviewer
jhb
Differential Revision
D42296: vmm: implement single-stepping for AMD CPUs
Parents
rG3613a2806667: vmm: enable software breakpoints for AMD CPUs
Branches
Unknown
Tags
Unknown