Module Name: src Committed By: kamil Date: Sun Nov 27 14:49:21 UTC 2016
Modified Files: src/sys/arch/amd64/amd64: cpufunc.S src/sys/arch/i386/i386: i386func.S src/sys/arch/x86/include: cpufunc.h src/sys/arch/xen/x86: xenfunc.c Added Files: src/sys/arch/x86/include: dbregs.h Log Message: Add accessors for available x86 Debug Registers There are 8 Debug Registers on i386 (available at least since 80386) and 16 on AMD64. Currently DR4 and DR5 are reserved on both cpu-families and DR9-DR15 are still reserved on AMD64. Therefore add accessors for DR0-DR3, DR6-DR7 for all ports. Debug Registers x86: * DR0-DR3 Debug Address Registers * DR4-DR5 Reserved * DR6 Debug Status Register * DR7 Debug Control Register * DR8-DR15 Reserved Access the registers is available only from a kernel (ring 0) as there is needed top protected access. For this reason there is need to use special XEN functions to get and set the registers in the XEN3 kernels. XEN specific functions as defined in NetBSD: - HYPERVISOR_get_debugreg() - HYPERVISOR_set_debugreg() This code extends the existing rdr6() and ldr6() accessor for additional: - rdr0() & ldr0() - rdr1() & ldr1() - rdr2() & ldr2() - rdr3() & ldr3() - rdr7() & ldr7() Traditionally accessors for DR6 were passing vaddr_t argument, while it's appropriate type for DR0-DR3, DR6-DR7 should be using u_long, however it's not a big deal. The resulting functionality should be equivalent so stick to this convention and use the vaddr_t type for all DR accessors. There was already a function defined for rdr6() in XEN, but it had a nit on AMD64 as it was casting HYPERVISOR_get_debugreg() to u_int (32-bit on AMD64), truncating result. It still works for DR6, but for the sake of simplicity always return full 64-bit value. New accessors duplicate functionality of the dr0() function available on i386 within the KSTACK_CHECK_DR0 option. dr0() is a specialized layer with logic to set appropriate types of interrupts, now accessors are designed to pass verbatim values from user-land (with simple sanity checks in the kernel). At the moment there are no plans to make possible to coexist KSTACK_CHECK_DR0 with debug registers for user applications (debuggers). options KSTACK_CHECK_DR0 Detect kernel stack overflow using DR0 register. This option uses DR0 register exclusively so you can't use DR0 register for other purpose (e.g., hardware breakpoint) if you turn this on. The KSTACK_CHECK_DR0 functionality was designed for i386 and never ported to amd64. Code tested on i386 and amd64 with kernels: GENERIC, XEN3_DOMU, XEN3_DOM0. Sponsored by <The NetBSD Foundation> To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/i386/i386func.S cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/include/cpufunc.h cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/dbregs.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/xen/x86/xenfunc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.