Home | History | Annotate | Download | only in include
History log of /src/sys/arch/amd64/include/proc.h
RevisionDateAuthorComments
 1.25  13-Jun-2020  ad Print a rate limited warning if the TSC timecounter goes backwards from the
viewpoint of any single LWP.
 1.24  13-Jan-2020  ad Remove now unused mdlwp fields md_gc_pmap and md_gc_ptp.
 1.23  12-Oct-2019  maxv branches: 1.23.2;
Rewrite the FPU code on x86. This greatly simplifies the logic and removes
the dependency on IPL_HIGH. NVMM is updated accordingly. Posted on
port-amd64 a week ago.

Bump the kernel version to 9.99.16.
 1.22  25-Feb-2017  kamil branches: 1.22.14;
Garbage collect unneeded inclusion of <x86/dbregs.h> in <machine/proc.h>

This is left over after introduction of Debug Register accessors.
This interface replaced older watchpoint API.

Sponsored by <The NetBSD Foundation>
 1.21  23-Feb-2017  kamil 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.20  15-Dec-2016  kamil branches: 1.20.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.19  20-Feb-2014  dsl branches: 1.19.6; 1.19.10;
Move the amd64 and i386 pcb to the bottom of the uarea, and move the
kernel stack to the top.
Change the pcb layouts so that fpu save area is at the end and is
64byte aligned ready for xsave (saving the ymm registers).
Welcome to 6.99.32
 1.18  15-Feb-2014  dsl Remove all references to MDL_USEDFPU and deferred fpu initialisation.
The cost of zeroing the save area on exec is minimal.
This stops the FP registers of a random process being used the first
time an lwp uses the fpu.
sendsig_siginfo() and get_mcontext() now unconditionally copy the FP
registers.
I'll remove the double-copy for signal handlers soon.
get_mcontext() might have been leaking kernel memory to userspace - and
may still do so if i386_use_fxsave is false (short copies).
 1.17  01-Dec-2013  christos revert fpu/pcu changes until we figure out what's wrong; they cause random
freezes
 1.16  23-Oct-2013  drochner Use the MI "pcu" framework for bookkeeping of npx/fpu states on x86.
This reduces the amount of MD code enormously, and makes it easier
to implement support for newer CPU features which require more fpu
state, or for fpu usage by the kernel.
For access to FPU state across CPUs, an xcall kthread is used now
rather than a dedicated IPI.
No user visible changes intended.
 1.15  15-Jul-2012  dsl branches: 1.15.2; 1.15.4;
Rename MDP_IRET to MDL_IRET since it is an lwp flag, not a proc one.
Add an MDL_COMPAT32 flag to the lwp's md_flags, set it for 32bit lwps
and use it to force 'return to user' with iret (as is done when
MDL_IRET is set).
Split the iret/sysret code paths much later.
Remove all the replicated code for 32bit system calls - which was only
needed so that iret was always used.
frameasm.h for XEN contains '#define swapgs', while XEN probable never
needs swapgs, this is likely to be confusing.
Add a SWAPGS which is a nop on XEN and swapgs otherwise.
(I've not yet checked all the swapgs in files that include frameasm.h)
Simple x86 programs still work.
Hijack 6.99.9 kernel bump (needed for compat32 modules)
 1.14  08-Jul-2012  dsl The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.13  14-Jan-2011  rmind branches: 1.13.8;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.12  14-Mar-2009  dsl branches: 1.12.4;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.11  26-Oct-2008  mrg branches: 1.11.2; 1.11.8;
put the contents of these header files around #ifdef __x86_64__, and
#include the <i386/foo.h> in the #else clause, making these files
largely bit-size independant.
 1.10  05-Jun-2008  ad branches: 1.10.4;
pmap_remove_all() for x86. Also, always defer freeing ptps to pmap_update().
There may be a better way to do this, but for now this is simple and avoids
potential bugs.

Proposed on tech-kern and discussed with chs@.
 1.9  08-Jan-2008  yamt branches: 1.9.6; 1.9.8; 1.9.10; 1.9.12;
change the layout in u-area and reduce UPAGES.
 1.8  05-Jan-2008  yamt - make amd64 use per-cpu tss.
- fix iopl syscall for amd64+xen.
 1.7  16-Nov-2007  skrll branches: 1.7.6;
s/proc/lwp/ in comment
 1.6  09-Feb-2007  ad branches: 1.6.6; 1.6.22; 1.6.24; 1.6.28; 1.6.30;
Merge newlock2 to head.
 1.5  24-Dec-2005  perry branches: 1.5.20;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.4  11-Dec-2005  christos merge ktrace-lwp.
 1.3  20-Aug-2003  fvdl branches: 1.3.16;
Pass pointers to frames from assembly, do not use the 'frame on stack
as argument passed by value' trick, as gcc 3.3.x makes (valid) assumptions
about the stack that will not be true. Costs 2 instructions per trap/syscall
on i386, 4 per interrupt for MP. One instruction per trap/syscall on amd64,
2 per interrupt for MP. I expect gcc 3.3.1 to make up for this by better
optimization (it'd better..)

While here, make amd64 compile again by using subr_mbr_disk.c
 1.2  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.1  26-Apr-2003  fvdl branches: 1.1.2;
Rename the x86_64 port to amd64, as this is the actual name used for
the processor family now. x86_64 is kept as the MACHINE_ARCH value,
since it's already widely used (by e.g. the toolchain, etc), and
by other operating systems.
 1.1.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1  03-Aug-2004  skrll Sync with HEAD
 1.3.16.4  21-Jan-2008  yamt sync with head
 1.3.16.3  07-Dec-2007  yamt sync with head
 1.3.16.2  26-Feb-2007  yamt sync with head.
 1.3.16.1  21-Jun-2006  yamt sync with head.
 1.5.20.1  20-Oct-2006  ad Make ASTs per-LWP.
 1.6.30.2  18-Feb-2008  mjf Sync with HEAD.
 1.6.30.1  19-Nov-2007  mjf Sync with HEAD.
 1.6.28.1  18-Nov-2007  bouyer Sync with HEAD
 1.6.24.1  09-Jan-2008  matt sync with HEAD
 1.6.22.1  21-Nov-2007  joerg Sync with HEAD.
 1.6.6.1  03-Dec-2007  ad Sync with HEAD.
 1.7.6.1  08-Jan-2008  bouyer Sync with HEAD
 1.9.12.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.9.10.1  04-May-2009  yamt sync with head.
 1.9.8.1  17-Jun-2008  yamt sync with head.
 1.9.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.9.6.1  29-Jun-2008  mjf Sync with HEAD.
 1.10.4.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.8.3  28-Mar-2011  jym Sync with HEAD. TODO before merge:
- shortcut for suspend code in sysmon, when powerd(8) is not running.
Borrow ``xs_watch'' thread context?
- bug hunting in xbd + xennet resume. Rings are currently thrashed upon
resume, so current implementation force flush them on suspend. It's not
really needed.
 1.11.8.2  01-Nov-2009  jym Sync with HEAD.
 1.11.8.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.2.1  28-Apr-2009  skrll Sync with HEAD.
 1.12.4.1  05-Mar-2011  rmind sync with head
 1.13.8.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.8.1  30-Oct-2012  yamt sync with head
 1.15.4.1  18-May-2014  rmind sync with head
 1.15.2.2  03-Dec-2017  jdolecek update from HEAD
 1.15.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.10.2  20-Mar-2017  pgoyette Sync with HEAD
 1.19.10.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.19.6.2  28-Aug-2017  skrll Sync with HEAD
 1.19.6.1  05-Feb-2017  skrll Sync with HEAD
 1.20.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.22.14.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22.14.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.23.2.1  17-Jan-2020  ad Sync with head.

RSS XML Feed