aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBojan Novković <bojan.novkovic@fer.hr>2023-12-07 22:46:31 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2023-12-07 23:10:56 +0000
commit231eee17d2905682014b71d1f01719003b13bd91 (patch)
treee1bba93d059bae23c0c482f6c4202ac8c9bbf3dc
parent78c1d174a1e13c6522bd4d663225fc9cbabc329d (diff)
downloadsrc-231eee17d2905682014b71d1f01719003b13bd91.tar.gz
src-231eee17d2905682014b71d1f01719003b13bd91.zip
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
-rw-r--r--sys/amd64/vmm/amd/svm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
index a502632f6ed6..ec0cde31aaad 100644
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -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;