]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Cleanups related to debug exceptions on x86.
authorjhb <jhb@FreeBSD.org>
Tue, 22 May 2018 00:45:00 +0000 (00:45 +0000)
committerjhb <jhb@FreeBSD.org>
Tue, 22 May 2018 00:45:00 +0000 (00:45 +0000)
commit31acfe0f07a27191c91f2a0b0aaaa0c28bc3b059
tree8b62b7069e4e689839a3617f8e9ef65b70b29d9a
parentde0d361fd5faca89d7106018bd4714074afe2ae6
Cleanups related to debug exceptions on x86.

- Add constants for fields in DR6 and the reserved fields in DR7.  Use
  these constants instead of magic numbers in most places that use DR6
  and DR7.
- Refer to T_TRCTRAP as "debug exception" rather than a "trace trap"
  as it is not just for trace exceptions.
- Always read DR6 for debug exceptions and only clear TF in the flags
  register for user exceptions where DR6.BS is set.
- Clear DR6 before returning from a debug exception handler as
  recommended by the SDM dating all the way back to the 386.  This
  allows debuggers to determine the cause of each exception.  For
  kernel traps, clear DR6 in the T_TRCTRAP case and pass DR6 by value
  to other parts of the handler (namely, user_dbreg_trap()).  For user
  traps, wait until after trapsignal to clear DR6 so that userland
  debuggers can read DR6 via PT_GETDBREGS while the thread is stopped
  in trapsignal().

Reviewed by: kib, rgrimes
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D15189
sys/amd64/amd64/machdep.c
sys/amd64/amd64/trap.c
sys/amd64/include/db_machdep.h
sys/amd64/vmm/amd/svm.c
sys/amd64/vmm/intel/vmx.c
sys/i386/i386/machdep.c
sys/i386/i386/trap.c
sys/i386/include/db_machdep.h
sys/x86/include/reg.h
sys/x86/include/x86_var.h