History log of /src/sys/arch/i386/include/userret.h |
Revision | | Date | Author | Comments |
1.15 |
| 26-Jul-2018 |
maxv | Rework dbregs, to switch the registers during context switches, and not on each user->kernel transition via userret. Reloads of DR6/DR7 are expensive on both native and xen.
|
1.14 |
| 23-Feb-2017 |
kamil | branches: 1.14.12; 1.14.14; Introduce PT_GETDBREGS and PT_SETDBREGS in ptrace(2) on i386 and amd64
This interface is modeled after FreeBSD API with the usage.
This replaced previous watchpoint API. The previous one was introduced recently in NetBSD-current and remove its spurs without any backward-compatibility.
Design choices for Debug Register accessors: - exec() (TRAP_EXEC event) must remove debug registers from LWP - debug registers are only per-LWP, not per-process globally - debug registers must not be inherited after (v)forking a process - debug registers must not be inherited after forking a thread - a debugger is responsible to set global watchpoints/breakpoints with the debug registers, to achieve this PTRACE_LWP_CREATE/PTRACE_LWP_EXIT event monitoring function is designed to be used - debug register traps must generate SIGTRAP with si_code TRAP_DBREG - debugger is responsible to retrieve debug register state to distinguish the exact debug register trap (DR6 is Status Register on x86) - kernel must not remove debug register traps after triggering a trap event a debugger is responsible to detach this trap with appropriate PT_SETDBREGS call (DR7 is Control Register on x86) - debug registers must not be exposed in mcontext - userland must not be allowed to set a trap on the kernel
Implementation notes on i386 and amd64: - the initial state of debug register is retrieved on boot and this value is stored in a local copy (initdbregs), this value is used to initialize dbreg context after PT_GETDBREGS - struct dbregs is stored in pcb as a pointer and by default not initialized - reserved registers (DR4-DR5, DR9-DR15) are ignored
Further ideas: - restrict this interface with securelevel
Tested on real hardware i386 (Intel Pentium IV) and amd64 (Intel i7).
This commit enables 390 debug register ATF tests in kernel/arch/x86. All tests are passing.
This commit does not cover netbsd32 compat code. Currently other interface PT_GET_SIGINFO/PT_SET_SIGINFO is required in netbsd32 compat code in order to validate reliably PT_GETDBREGS/PT_SETDBREGS.
This implementation does not cover FreeBSD specific defines in their <x86/reg.h>: DBREG_DR7_LOCAL_ENABLE, DBREG_DR7_GLOBAL_ENABLE, DBREG_DR7_LEN_1 etc. These values tend to be reinvented by each tracer on its own. GNU Debugger (GDB) works with NetBSD debug registers after adding this patch:
--- gdb/amd64bsd-nat.c.orig 2016-02-10 03:19:39.000000000 +0000 +++ gdb/amd64bsd-nat.c @@ -167,6 +167,10 @@ amd64bsd_target (void)
#ifdef HAVE_PT_GETDBREGS
+#ifndef DBREG_DRX +#define DBREG_DRX(d,x) ((d)->dr[(x)]) +#endif + static unsigned long amd64bsd_dr_get (ptid_t ptid, int regnum) {
Another reason to stop introducing unpopular defines covering machine specific register macros is that these value varies across generations of the same CPU family.
GDB demo: (gdb) c Continuing.
Watchpoint 2: traceme
Old value = 0 New value = 16 main (argc=1, argv=0x7f7fff79fe30) at test.c:8 8 printf("traceme=%d\n", traceme);
(Currently the GDB interface is not reliable due to NetBSD support bugs)
Sponsored by <The NetBSD Foundation>
|
1.13 |
| 16-Jan-2017 |
kamil | Allow to mix single-step with hardware assisted watchpoints on i386
This case needs new handling in trap recognition.
Sponsored by <The NetBSD Foundation>
|
1.12 |
| 15-Dec-2016 |
kamil | branches: 1.12.2; Add support for hardware assisted watchpoints/breakpoints API in ptrace(2)
Add new ptrace(2) calls: - PT_COUNT_WATCHPOINTS - count the number of available hardware watchpoints - PT_READ_WATCHPOINT - read struct ptrace_watchpoint from the kernel state - PT_WRITE_WATCHPOINT - write new struct ptrace_watchpoint state, this includes enabling and disabling watchpoints
The ptrace_watchpoint structure contains MI and MD parts:
typedef struct ptrace_watchpoint { int pw_index; /* HW Watchpoint ID (count from 0) */ lwpid_t pw_lwpid; /* LWP described */ struct mdpw pw_md; /* MD fields */ } ptrace_watchpoint_t;
For example amd64 defines MD as follows: struct mdpw { void *md_address; int md_condition; int md_length; };
These calls are protected with the __HAVE_PTRACE_WATCHPOINTS guard.
Tested on amd64, initial support added for i386 and XEN.
Sponsored by <The NetBSD Foundation>
|
1.11 |
| 28-Apr-2008 |
martin | branches: 1.11.44; 1.11.64; 1.11.68; Remove clause 3 and 4 from TNF licenses
|
1.10 |
| 09-Feb-2007 |
ad | branches: 1.10.44; 1.10.46; 1.10.48; Merge newlock2 to head.
|
1.9 |
| 15-Apr-2006 |
simonb | branches: 1.9.8; Remove "register", ANSIfy.
|
1.8 |
| 16-Feb-2006 |
perry | branches: 1.8.2; 1.8.4; 1.8.6; Change "inline" back to "__inline" in .h files -- C99 is still too new, and some apps compile things in C89 mode. C89 keywords stay.
As per core@.
|
1.7 |
| 24-Dec-2005 |
perry | branches: 1.7.2; 1.7.4; 1.7.6; Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
|
1.6 |
| 31-Oct-2003 |
cl | branches: 1.6.16; Reduce code duplication by adding mi_userret() in sys/userret.h containing signal posting, kernel-exit handling and sa_upcall processing.
XXX the pc532, sparc, sparc64 and vax ports should have their XXX userret() code rearranged to use this.
|
1.5 |
| 27-Oct-2003 |
junyoung | Nuke __P().
|
1.4 |
| 07-Aug-2003 |
agc | Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
|
1.3 |
| 17-Jan-2003 |
thorpej | branches: 1.3.2; Merge the nathanw_sa branch.
|
1.2 |
| 10-Dec-2000 |
mycroft | branches: 1.2.2; 1.2.4; 1.2.6; Introduce PROC_PC(), which is used to get a process's user PC. If this is defined, call addupc_intr() directly from statclock() in the system time case, using the same P_OWEUPC path if the copyin/copyout fails. Use this in i386 to remove profiling code from the normal userret() path.
|
1.1 |
| 09-Dec-2000 |
jdolecek | put userret() into header file machine/userret.h and pull it where needed
|
1.2.6.6 |
| 26-Sep-2002 |
nathanw | Change "if (l->l_flag & L_SA_UPCALL)" to "while (l->l_flag & L_SA_UPCALL)" in userret() functions or equivalent, to permit delivery of multiple upcalls in a single kernel entry.
XXX It's getting crowded in here. Collapsing posting signals, upcalls, and XXX kernel-exit handling into one mechanism would be nice.
|
1.2.6.5 |
| 17-Dec-2001 |
nathanw | Call sa_upcall_userret(), not cpu_upcall().
|
1.2.6.4 |
| 17-Nov-2001 |
nathanw | Check and obey user-return exit hook (replaces test for P_WEXIT).
|
1.2.6.3 |
| 19-Jul-2001 |
nathanw | Check for P_WEXIT after taking signals, in case we were stopped in CURSIG().
|
1.2.6.2 |
| 09-Jul-2001 |
nathanw | Move upcall processing to the point of userret() rather than invocation time.
|
1.2.6.1 |
| 05-Mar-2001 |
nathanw | Initial commit of scheduler activations and lightweight process support.
|
1.2.4.2 |
| 10-Dec-2000 |
mycroft | Introduce PROC_PC(), which is used to get a process's user PC. If this is defined, call addupc_intr() directly from statclock() in the system time case, using the same P_OWEUPC path if the copyin/copyout fails. Use this in i386 to remove profiling code from the normal userret() path.
|
1.2.4.1 |
| 10-Dec-2000 |
mycroft | file userret.h was added on branch sommerfeld_i386mp_1 on 2000-12-10 19:29:32 +0000
|
1.2.2.2 |
| 13-Dec-2000 |
bouyer | Sync with HEAD (for UBC fixes).
|
1.2.2.1 |
| 10-Dec-2000 |
bouyer | file userret.h was added on branch thorpej_scsipi on 2000-12-13 15:49:31 +0000
|
1.3.2.3 |
| 21-Sep-2004 |
skrll | Fix the sync with head I botched.
|
1.3.2.2 |
| 18-Sep-2004 |
skrll | Sync with HEAD.
|
1.3.2.1 |
| 03-Aug-2004 |
skrll | Sync with HEAD
|
1.6.16.2 |
| 26-Feb-2007 |
yamt | sync with head.
|
1.6.16.1 |
| 21-Jun-2006 |
yamt | sync with head.
|
1.7.6.1 |
| 22-Apr-2006 |
simonb | Sync with head.
|
1.7.4.1 |
| 09-Sep-2006 |
rpaulo | sync with head
|
1.7.2.1 |
| 18-Feb-2006 |
yamt | sync with head.
|
1.8.6.1 |
| 24-May-2006 |
tron | Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
|
1.8.4.1 |
| 19-Apr-2006 |
elad | sync with head - hopefully this will work
|
1.8.2.1 |
| 24-May-2006 |
yamt | sync with head.
|
1.9.8.1 |
| 20-Oct-2006 |
ad | Do the priority adjustment in mi_userret().
|
1.10.48.1 |
| 16-May-2008 |
yamt | sync with head.
|
1.10.46.1 |
| 18-May-2008 |
yamt | sync with head.
|
1.10.44.1 |
| 02-Jun-2008 |
mjf | Sync with HEAD.
|
1.11.68.2 |
| 20-Mar-2017 |
pgoyette | Sync with HEAD
|
1.11.68.1 |
| 07-Jan-2017 |
pgoyette | Sync with HEAD. (Note that most of these changes are simply $NetBSD$ tag issues.)
|
1.11.64.2 |
| 28-Aug-2017 |
skrll | Sync with HEAD
|
1.11.64.1 |
| 05-Feb-2017 |
skrll | Sync with HEAD
|
1.11.44.1 |
| 03-Dec-2017 |
jdolecek | update from HEAD
|
1.12.2.1 |
| 21-Apr-2017 |
bouyer | Sync with HEAD
|
1.14.14.1 |
| 10-Jun-2019 |
christos | Sync with HEAD
|
1.14.12.1 |
| 28-Jul-2018 |
pgoyette | Sync with HEAD
|