vmm: enable software breakpoints for AMD CPUs

This patch adds support for software breakpoint vmexits on AMD SVM.
It implements the VM_CAP_BPT_EXIT used to enable software breakpoints.
When enabled, breakpoint vmexits are passed to userspace where they
are handled by the GDB stub.

Reviewed by:	jhb
Sponsored by:	Google, Inc. (GSoC 2022)
Differential Revision:	https://reviews.freebsd.org/D42295
This commit is contained in:
Bojan Novković 2023-12-07 14:46:31 -08:00 committed by John Baldwin
parent 78c1d174a1
commit 231eee17d2

View file

@ -1421,6 +1421,12 @@ svm_vmexit(struct svm_softc *svm_sc, struct svm_vcpu *vcpu,
break;
case IDT_BP:
vmexit->exitcode = VM_EXITCODE_BPT;
vmexit->u.bpt.inst_length = vmexit->inst_length;
vmexit->inst_length = 0;
reflect = 0;
break;
case IDT_OF:
case IDT_BR:
/*
@ -2333,6 +2339,9 @@ svm_setcap(void *vcpui, int type, int val)
if (val == 0)
error = EINVAL;
break;
case VM_CAP_BPT_EXIT:
svm_set_intercept(vcpu, VMCB_EXC_INTCPT, BIT(IDT_BP), val);
break;
case VM_CAP_IPI_EXIT:
vlapic = vm_lapic(vcpu->vcpu);
vlapic->ipi_exit = val;
@ -2366,6 +2375,9 @@ svm_getcap(void *vcpui, int type, int *retval)
case VM_CAP_UNRESTRICTED_GUEST:
*retval = 1; /* unrestricted guest is always enabled */
break;
case VM_CAP_BPT_EXIT:
*retval = svm_get_intercept(vcpu, VMCB_EXC_INTCPT, BIT(IDT_BP));
break;
case VM_CAP_IPI_EXIT:
vlapic = vm_lapic(vcpu->vcpu);
*retval = vlapic->ipi_exit;