The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=231eee17d2905682014b71d1f01719003b13bd91

commit 231eee17d2905682014b71d1f01719003b13bd91
Author:     Bojan Novković <bojan.novko...@fer.hr>
AuthorDate: 2023-12-07 22:46:31 +0000
Commit:     John Baldwin <j...@freebsd.org>
CommitDate: 2023-12-07 23:10:56 +0000

    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
---
 sys/amd64/vmm/amd/svm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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;

Reply via email to