aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/include
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2019-12-13 19:21:58 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2019-12-13 19:21:58 +0000
commitcbd03a9df2c897e592d9cdd7fbd0b715bdf28602 (patch)
tree751ef3f24a5723a2fd497701e8b2d20cd3566f56 /sys/amd64/include
parent34ad5ac2428d75bd37d9446ebce64be3ca08a999 (diff)
downloadsrc-cbd03a9df2c897e592d9cdd7fbd0b715bdf28602.tar.gz
src-cbd03a9df2c897e592d9cdd7fbd0b715bdf28602.zip
Support software breakpoints in the debug server on Intel CPUs.
- Allow the userland hypervisor to intercept breakpoint exceptions (BP#) in the guest. A new capability (VM_CAP_BPT_EXIT) is used to enable this feature. These exceptions are reported to userland via a new VM_EXITCODE_BPT that includes the length of the original breakpoint instruction. If userland wishes to pass the exception through to the guest, it must be explicitly re-injected via vm_inject_exception(). - Export VMCS_ENTRY_INST_LENGTH as a VM_REG_GUEST_ENTRY_INST_LENGTH pseudo-register. Injecting a BP# on Intel requires setting this to the length of the breakpoint instruction. AMD SVM currently ignores writes to this register (but reports success) and fails to read it. - Rework the per-vCPU state tracked by the debug server. Rather than a single 'stepping_vcpu' global, add a structure for each vCPU that tracks state about that vCPU ('stepping', 'stepped', and 'hit_swbreak'). A global 'stopped_vcpu' tracks which vCPU is currently reporting an event. Event handlers for MTRAP and breakpoint exits loop until the associated event is reported to the debugger. Breakpoint events are discarded if the breakpoint is not present when a vCPU resumes in the breakpoint handler to retry submitting the breakpoint event. - Maintain a linked-list of active breakpoints in response to the GDB 'Z0' and 'z0' packets. Reviewed by: markj (earlier version) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D20309
Notes
Notes: svn path=/head/; revision=355724
Diffstat (limited to 'sys/amd64/include')
-rw-r--r--sys/amd64/include/vmm.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h
index 798d70b4d5c0..5b291dda265e 100644
--- a/sys/amd64/include/vmm.h
+++ b/sys/amd64/include/vmm.h
@@ -95,6 +95,7 @@ enum vm_reg_name {
VM_REG_GUEST_DR2,
VM_REG_GUEST_DR3,
VM_REG_GUEST_DR6,
+ VM_REG_GUEST_ENTRY_INST_LENGTH,
VM_REG_LAST
};
@@ -455,6 +456,7 @@ enum vm_cap_type {
VM_CAP_PAUSE_EXIT,
VM_CAP_UNRESTRICTED_GUEST,
VM_CAP_ENABLE_INVPCID,
+ VM_CAP_BPT_EXIT,
VM_CAP_MAX
};
@@ -580,6 +582,7 @@ enum vm_exitcode {
VM_EXITCODE_REQIDLE,
VM_EXITCODE_DEBUG,
VM_EXITCODE_VMINSN,
+ VM_EXITCODE_BPT,
VM_EXITCODE_MAX
};
@@ -667,6 +670,9 @@ struct vm_exit {
uint64_t exitinfo2;
} svm;
struct {
+ int inst_length;
+ } bpt;
+ struct {
uint32_t code; /* ecx value */
uint64_t wval;
} msr;