freebsd-dev/sys/amd64/include
John Baldwin 65eefbe422 Save and restore guest debug registers.
Currently most of the debug registers are not saved and restored
during VM transitions allowing guest and host debug register values to
leak into the opposite context.  One result is that hardware
watchpoints do not work reliably within a guest under VT-x.

Due to differences in SVM and VT-x, slightly different approaches are
used.

For VT-x:

- Enable debug register save/restore for VM entry/exit in the VMCS for
  DR7 and MSR_DEBUGCTL.
- Explicitly save DR0-3,6 of the guest.
- Explicitly save DR0-3,6-7, MSR_DEBUGCTL, and the trap flag from
  %rflags for the host.  Note that because DR6 is "software" managed
  and not stored in the VMCS a kernel debugger which single steps
  through VM entry could corrupt the guest DR6 (since a single step
  trap taken after loading the guest DR6 could alter the DR6
  register).  To avoid this, explicitly disable single-stepping via
  the trace flag before loading the guest DR6.  A determined debugger
  could still defeat this by setting a breakpoint after the guest DR6
  was loaded and then single-stepping.

For SVM:
- Enable debug register caching in the VMCB for DR6/DR7.
- Explicitly save DR0-3 of the guest.
- Explicitly save DR0-3,6-7, and MSR_DEBUGCTL for the host.  Since SVM
  saves the guest DR6 in the VMCB, the race with single-stepping
  described for VT-x does not exist.

For both platforms, expose all of the guest DRx values via --get-drX
and --set-drX flags to bhyvectl.

Discussed with:	avg, grehan
Tested by:	avg (SVM), myself (VT-x)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D13229
2018-01-17 23:11:25 +00:00
..
pc sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
xen x86/xen: Consolidate xen-os.h in a single place 2015-10-21 10:04:35 +00:00
_align.h
_bus.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
_inttypes.h
_limits.h
_stdint.h
_types.h
acpica_machdep.h
apm_bios.h
asm.h Remove lint support from system headers and MD x86 headers. 2017-11-23 11:40:16 +00:00
asmacros.h PTI for amd64. 2018-01-17 11:44:21 +00:00
atomic.h Add atomic_load(9) and atomic_store(9) operations. 2017-12-19 09:59:20 +00:00
bus_dma.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
bus.h
clock.h
counter.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
cpu.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
cpufunc.h Add STAC and CLAC instructions wrappers. 2018-01-14 12:39:50 +00:00
cputypes.h Remove 'cpu' and 'cpu_class' on amd64. 2016-09-15 17:05:54 +00:00
db_machdep.h Fix printing of negative offsets (typically from frame pointers) again. 2017-03-26 18:46:35 +00:00
dump.h Factor out duplicated code from dumpsys() on each architecture into generic 2015-01-07 01:01:39 +00:00
efi.h Hide kernel stuff from userspace. 2017-10-02 08:37:43 +00:00
elf.h
endian.h
exec.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
fdt.h
float.h
floatingpoint.h spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
fpu.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
frame.h PTI for amd64. 2018-01-17 11:44:21 +00:00
gdb_machdep.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
ieeefp.h spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
in_cksum.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
intr_machdep.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
iodev.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
kdb.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
limits.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
md_var.h Move the hardware setup for fast syscalls into a common function. 2018-01-11 12:40:43 +00:00
memdev.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
metadata.h Move amd64 metadata.h to x86 and share with i386 2016-01-07 19:47:26 +00:00
minidump.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
mp_watchdog.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
nexusvar.h
npx.h
ofw_machdep.h
param.h spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
pcb.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
pci_cfgreg.h
pcpu.h PTI for amd64. 2018-01-17 11:44:21 +00:00
pmap.h PTI for amd64. 2018-01-17 11:44:21 +00:00
pmc_mdep.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
ppireg.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
proc.h Amd64 user_ldt_deref() is not used outside sys_machdep.c. Mark it as 2018-01-17 11:21:03 +00:00
profile.h Remove lint support from system headers and MD x86 headers. 2017-11-23 11:40:16 +00:00
psl.h
ptrace.h
pvclock.h Generalized parts of the XEN timer code into a generic pvclock 2015-02-04 08:26:43 +00:00
reg.h
reloc.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
resource.h
runq.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
segments.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
setjmp.h
sf_buf.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
sgx.h Add support for Intel Software Guard Extensions (Intel SGX). 2017-08-16 10:38:06 +00:00
sgxreg.h Add support for Intel Software Guard Extensions (Intel SGX). 2017-08-16 10:38:06 +00:00
sigframe.h
signal.h
smp.h PTI for amd64. 2018-01-17 11:44:21 +00:00
specialreg.h
stack.h Merge stack(9) implementations for i386 and amd64 under x86/. 2015-09-11 03:24:07 +00:00
stdarg.h
sysarch.h
timerreg.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
trap.h
tss.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
ucontext.h
varargs.h spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
vdso.h
vm.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
vmm_dev.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
vmm_instruction_emul.h sys/amd64: further adoption of SPDX licensing ID tags. 2017-11-27 15:03:07 +00:00
vmm.h Save and restore guest debug registers. 2018-01-17 23:11:25 +00:00
vmparam.h spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00