Home | History | Annotate | only in /src/sys/compat/linux/common
History log of /src/sys/compat/linux/common
RevisionDateAuthorComments
 1.2 02-Nov-1999  erh undo confusion.
 1.1 01-Oct-1998  erh branches: 1.1.12; 1.1.14; 1.1.16;
New makefiles for includes, syscall gen.
 1.1.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.14.1 15-Nov-1999  fvdl Sync with -current
 1.1.12.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck, and commit Makefile which
I forgot in the batch of commits.
 1.18 08-Dec-2015  christos Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
 1.17 21-Mar-2008  ad branches: 1.17.6; 1.17.48; 1.17.68;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.16 20-Dec-2007  dsl branches: 1.16.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.15 19-Oct-2007  njoly branches: 1.15.4; 1.15.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.14 04-Mar-2007  christos branches: 1.14.14; 1.14.16; 1.14.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 09-Feb-2007  ad branches: 1.13.2;
Merge newlock2 to head.
 1.12 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.11 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 29-Jun-2003  fvdl branches: 1.9.2; 1.9.18;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.8 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.7 21-Mar-2003  dsl Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
 1.6 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.5 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.4 14-Jun-2001  thorpej branches: 1.4.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.3 18-Jan-2001  tv branches: 1.3.2; 1.3.4;
No-op commit to force update to a non-"-kk" revision.
 1.2 10-Jan-2001  fvdl branches: 1.2.2;
Correct copyright year.
 1.1 10-Jan-2001  fvdl Add some BLK* ioctl calls. Currently only the easy and useful ones
are implemented.
 1.2.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.2.2.1 10-Jan-2001  bouyer file linux_blkio.c was added on branch thorpej_scsipi on 2001-01-18 09:23:13 +0000
 1.3.4.2 30-Mar-2001  he Pull up revisions 1.1-1.3 (new, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.3.4.1 18-Jan-2001  he file linux_blkio.c was added on branch netbsd-1-5 on 2001-03-30 21:36:59 +0000
 1.3.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.18.7 24-Mar-2008  yamt sync with head.
 1.9.18.6 21-Jan-2008  yamt sync with head
 1.9.18.5 27-Oct-2007  yamt sync with head.
 1.9.18.4 03-Sep-2007  yamt sync with head.
 1.9.18.3 26-Feb-2007  yamt sync with head.
 1.9.18.2 30-Dec-2006  yamt sync with head.
 1.9.18.1 21-Jun-2006  yamt sync with head.
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.10.22.2 10-Dec-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.13.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.14.16.2 09-Jan-2008  matt sync with HEAD
 1.14.16.1 06-Nov-2007  matt sync with HEAD
 1.14.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.15.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.15.4.1 26-Dec-2007  ad Sync with head.
 1.16.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.68.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.48.1 03-Dec-2017  jdolecek update from HEAD
 1.17.6.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.17.6.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.2 18-Jan-2001  tv branches: 1.2.4;
No-op commit to force update to a non-"-kk" revision.
 1.1 10-Jan-2001  fvdl branches: 1.1.2;
Add some BLK* ioctl calls. Currently only the easy and useful ones
are implemented.
 1.1.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.1.2.1 10-Jan-2001  bouyer file linux_blkio.h was added on branch thorpej_scsipi on 2001-01-18 09:23:13 +0000
 1.2.4.2 30-Mar-2001  he Pull up revisions 1.1-1.2 (new, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.2.4.1 18-Jan-2001  he file linux_blkio.h was added on branch netbsd-1-5 on 2001-03-30 21:37:26 +0000
 1.57 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.56 28-Apr-2008  martin branches: 1.56.2;
Remove clause 3 and 4 from TNF licenses
 1.55 20-Dec-2007  dsl branches: 1.55.6; 1.55.8; 1.55.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.54 09-Feb-2007  ad branches: 1.54.20; 1.54.28; 1.54.32;
Merge newlock2 to head.
 1.53 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.52 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.51 18-Jan-2003  thorpej branches: 1.51.18; 1.51.48; 1.51.50;
Merge the nathanw_sa branch.
 1.50 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.49 04-Oct-1998  fvdl branches: 1.49.24; 1.49.26;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.48 03-Oct-1998  christos Attempt to fix the mess.
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.49.26.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.49.24.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.49.24.2 14-Nov-2001  nathanw Catch up to -current.
 1.49.24.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.51.50.2 10-Dec-2006  yamt sync with head.
 1.51.50.1 22-Oct-2006  yamt sync with head
 1.51.48.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.51.48.1 18-Nov-2006  ad Sync with head.
 1.51.18.3 21-Jan-2008  yamt sync with head
 1.51.18.2 26-Feb-2007  yamt sync with head.
 1.51.18.1 30-Dec-2006  yamt sync with head.
 1.54.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.54.28.1 26-Dec-2007  ad Sync with head.
 1.54.20.1 09-Jan-2008  matt sync with HEAD
 1.55.10.1 16-May-2008  yamt sync with head.
 1.55.8.1 18-May-2008  yamt sync with head.
 1.55.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.56.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.56.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.29 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.28 07-Sep-2021  riastradh branches: 1.28.10;
sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.27 28-Apr-2008  martin branches: 1.27.2; 1.27.80; 1.27.92;
Remove clause 3 and 4 from TNF licenses
 1.26 21-Mar-2008  ad branches: 1.26.2; 1.26.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.25 20-Dec-2007  dsl branches: 1.25.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.24 19-Oct-2007  njoly branches: 1.24.4; 1.24.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.23 30-Jun-2007  dsl branches: 1.23.6; 1.23.8; 1.23.12;
Use the new CDIOCREADSUBCHANNEL_BUF and CDIOREADTOCENTRIES_BUF ioctls to
avoid copying into the stackgap.
 1.22 04-Mar-2007  christos branches: 1.22.2; 1.22.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.21 09-Feb-2007  ad branches: 1.21.2;
Merge newlock2 to head.
 1.20 12-Jun-2006  christos branches: 1.20.6;
don't allocate a crapload of struct's on the stack. Use a couple of unions
and use malloc for them.
 1.19 11-Dec-2005  christos branches: 1.19.4; 1.19.8; 1.19.14;
merge ktrace-lwp.
 1.18 26-Feb-2005  perry branches: 1.18.4;
nuke trailing whitespace
 1.17 29-Jun-2003  fvdl branches: 1.17.2; 1.17.10; 1.17.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.16 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.15 21-Mar-2003  dsl Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
 1.14 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.13 22-Mar-2002  christos gc debugging printfs.
 1.12 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.11 15-Feb-2002  christos s/printf/uprintf/
 1.10 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.9 14-Jun-2001  thorpej branches: 1.9.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.8 03-Feb-2001  fvdl branches: 1.8.2;
Oops, remove debugging printf.
 1.7 03-Feb-2001  fvdl For the read subchannel ioctl, don't mix up the data and address formats,
and always set the track to 0, like Linux does.
 1.6 10-Dec-2000  fvdl Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.5 29-Oct-1999  mycroft branches: 1.5.6;
Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.
 1.4 03-Oct-1998  christos branches: 1.4.12; 1.4.14; 1.4.16;
Remove stray debugging printfs
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Moved compat/linux/linux_cdrom to common.
 1.1 15-Jan-1998  christos PR/4794: Urban Boquist: Linux cdrom ioctls are missing
 1.4.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.14.1 15-Nov-1999  fvdl Sync with -current
 1.4.12.3 11-Feb-2001  bouyer Sync with HEAD.
 1.4.12.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.6.1 30-Mar-2001  he Pull up revisions 1.6-1.8 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.8.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.8.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.9.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.9.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.10.1 29-Apr-2005  kent sync with -current
 1.17.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.17.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.18.4.6 24-Mar-2008  yamt sync with head.
 1.18.4.5 21-Jan-2008  yamt sync with head
 1.18.4.4 27-Oct-2007  yamt sync with head.
 1.18.4.3 03-Sep-2007  yamt sync with head.
 1.18.4.2 26-Feb-2007  yamt sync with head.
 1.18.4.1 21-Jun-2006  yamt sync with head.
 1.19.14.1 19-Jun-2006  chap Sync with head.
 1.19.8.1 26-Jun-2006  yamt sync with head.
 1.19.4.1 09-Sep-2006  rpaulo sync with head
 1.20.6.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.21.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.4.1 11-Jul-2007  mjf Sync with head.
 1.22.2.1 15-Jul-2007  ad Sync with head.
 1.23.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.23.8.2 09-Jan-2008  matt sync with HEAD
 1.23.8.1 06-Nov-2007  matt sync with HEAD
 1.23.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.24.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.24.4.1 26-Dec-2007  ad Sync with head.
 1.25.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.25.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.4.1 16-May-2008  yamt sync with head.
 1.26.2.1 18-May-2008  yamt sync with head.
 1.27.92.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.27.80.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.27.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.27.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.28.10.1 02-Aug-2025  perseant Sync with HEAD
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 11-Dec-2005  christos branches: 1.7.70; 1.7.72; 1.7.74;
merge ktrace-lwp.
 1.6 26-Feb-2005  perry nuke trailing whitespace
 1.5 10-Dec-2000  fvdl branches: 1.5.24; 1.5.32; 1.5.34;
Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.4 29-Oct-1999  mycroft branches: 1.4.6;
Emulate the Linux DVD_* ioctls(2). This gets us 90% of the way to running the
LiViD DVD player. (See forthcoming mail to current-users.)
XXX NOTE: We should do something to probe capabilities, rather than allowing
these ioctls on any device.
 1.3 03-Oct-1998  christos branches: 1.3.12; 1.3.14; 1.3.16;
Attempt to fix the mess.
 1.2 01-Oct-1998  erh Moved compat/linux/linux_cdrom to common.
 1.1 15-Jan-1998  christos PR/4794: Urban Boquist: Linux cdrom ioctls are missing
 1.3.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.14.1 15-Nov-1999  fvdl Sync with -current
 1.3.12.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.3.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.4.6.1 30-Mar-2001  he Pull up revision 1.5 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.5.34.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.32.1 29-Apr-2005  kent sync with -current
 1.5.24.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.74.1 16-May-2008  yamt sync with head.
 1.7.72.1 18-May-2008  yamt sync with head.
 1.7.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.12 11-Sep-2010  chs recent versions of linux (which we now claim to be) supply a BSD-style
d_type value in getdents() results, after the d_name field.
make our emulation do the same. fixes part of PR 43695.
 1.11 28-Apr-2008  martin branches: 1.11.20; 1.11.22;
Remove clause 3 and 4 from TNF licenses
 1.10 11-Dec-2005  christos branches: 1.10.70; 1.10.72; 1.10.74;
merge ktrace-lwp.
 1.9 26-Feb-2005  perry nuke trailing whitespace
 1.8 10-May-2002  tron branches: 1.8.10; 1.8.18; 1.8.20;
Add missing bracket arround macro argument reference.
 1.7 10-Apr-2002  christos implement getdents64; my full java tree builds now.
 1.6 04-Oct-1998  fvdl branches: 1.6.24; 1.6.26;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.5 03-Oct-1998  christos Attempt to fix the mess.
 1.4 01-Oct-1998  erh Moved from compat/linux/linux_dirent.h to common.
 1.3 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.2 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.6.26.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.24.2 20-Jun-2002  nathanw Catch up to -current.
 1.6.24.1 17-Apr-2002  nathanw Catch up to -current.
 1.8.20.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.18.1 29-Apr-2005  kent sync with -current
 1.8.10.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.74.2 09-Oct-2010  yamt sync with head
 1.10.74.1 16-May-2008  yamt sync with head.
 1.10.72.1 18-May-2008  yamt sync with head.
 1.10.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.22.1 05-Mar-2011  rmind sync with head
 1.11.20.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.20 20-May-2022  andvar s/auxillary/auxiliary/ in comments.
 1.19 26-Apr-2020  thorpej Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.18 02-Nov-2010  chs personality() now interprets its parameter as having
the base personality type in the low byte and
various flags in the upper bytes. for now just mask off
the flags to make sure the base type is one we accept.
store the current personality in the emuldata so that
we can return the expected value for PER_QUERY.
 1.17 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.16 26-Oct-2008  christos branches: 1.16.14; 1.16.16;
futex support fixes from FreeBSD via cube+pengo.
 1.15 28-Apr-2008  martin branches: 1.15.6;
Remove clause 3 and 4 from TNF licenses
 1.14 04-Mar-2007  christos branches: 1.14.36; 1.14.38; 1.14.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 05-Feb-2007  njoly branches: 1.13.2;
Add a new linux_emuldata_shared flag value LINUX_LES_USE_NPTL to allow
both NPTL and old linuxthreads behaviour depending on process needs.

Apply to exit_group(), getpid() and getppid() to share them between
compat linux32 (non NPTL) and compat linux (NPTL) on amd64.

ok by manu and christos
 1.12 23-Aug-2006  manu branches: 1.12.2; 1.12.6;
1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

The thread group leader must report the exit status, even if it exits
because of another thread calling exit_group(). We do that by storing the
exit status in struct linux_emuldata_shared, and the exit hook has the
duty of setting struct proc's p_xstat for the thread group leader.

2) For exit/fork/exec hooks, move the NPTL specific code to separate functions
that are shared between COMPAT_LINUX and COMPAT_LINUX32

3) Fix LINUX_CLONE_PARENT_SETTID semantics
 1.11 25-Jun-2006  manu - Complete exit_group() implementation. We now maintain a list of Linux
threads in a processes and kill them properly. The code is a bit too
complicated, but I could not find a simplier way of dealing with it

- Change getpid() and getppid() semantics to match what Linux does,
and implement gettid(). In the Linux kernel, threads are implemnted
as plain old processes. A thread group is just a set of processes,
with the parent called leader. Thread ID, which are returned by gettid(),
are just the PID of the plain old processes, and getpid() returns the
PID of the thread group leader.

- Remove struct linux32_emuldata. COMPAT_LINUX32 uses a lot of COMPAT_LINUX
code, where a struct linux_emuldata is assumed. By having distinct emuldata
structure with different sizes and layouts, we caused kernel memory
corruptions.

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.8; 1.10.16;
merge ktrace-lwp.
 1.9 05-Nov-2005  manu Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()
 1.8 22-Jun-2005  manu branches: 1.8.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.
 1.7 26-Feb-2005  perry nuke trailing whitespace
 1.6 08-Aug-2004  jdolecek branches: 1.6.4; 1.6.6;
linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads
 1.5 23-Jun-2003  erh branches: 1.5.2; 1.5.4;
Add copyright+license.
 1.4 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.3 15-Mar-2001  manu branches: 1.3.2;
Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.
 1.2 21-Nov-2000  jdolecek branches: 1.2.2;
comment out ps_siginfo from struct emuldata for now, add int debugreg[8]
update comment a bit
 1.1 08-Dec-1998  erh branches: 1.1.10;
At least make this compile. Add linux compat version of auxillary data eventually to be used to make the emulation work correctly.
 1.1.10.2 27-Mar-2001  bouyer Sync with HEAD.
 1.1.10.1 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.3.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.4.1 15-Aug-2004  tron Pull up revision 1.6 (requested by jdolecek in ticket #762):
linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size
this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads
 1.5.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 12-Aug-2004  skrll Sync with HEAD.
 1.6.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.4.1 29-Apr-2005  kent sync with -current
 1.8.2.4 03-Sep-2007  yamt sync with head.
 1.8.2.3 26-Feb-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.10.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.10.8.2 03-Sep-2006  yamt sync with head.
 1.10.8.1 26-Jun-2006  yamt sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.12.6.1 28-Mar-2007  jdc Pull up revision 1.13 (requested by njoly in ticket #523).

Add a new linux_emuldata_shared flag value LINUX_LES_USE_NPTL to allow
both NPTL and old linuxthreads behaviour depending on process needs.

Apply to exit_group(), getpid() and getppid() to share them between
compat linux32 (non NPTL) and compat linux (NPTL) on amd64.

ok by manu and christos
 1.12.2.1 09-Feb-2007  ad Sync with HEAD.
 1.13.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.40.3 11-Aug-2010  yamt sync with head.
 1.14.40.2 04-May-2009  yamt sync with head.
 1.14.40.1 16-May-2008  yamt sync with head.
 1.14.38.1 18-May-2008  yamt sync with head.
 1.14.36.2 17-Jan-2009  mjf Sync with HEAD.
 1.14.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.16.1 05-Mar-2011  rmind sync with head
 1.16.14.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.16.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.16 08-Mar-2020  mgorny PR standards/44921: Add errno consts for robust mutexes

Add the two missing errno.h constants: EOWNERDEAD and ENOTRECOVERABLE.
While technically they're used for robust mutexes which we do not
support at the moment, they are listed in POSIX and used by libc++.
While libc++ can be made to build without it, it just locally redefines
the values then, so we may as well define them globally.
 1.15 22-Dec-2013  njoly branches: 1.15.30;
CTASSERT that native to compat errno translation tables are kept in
sync with native errno list.

Remove extra entries (linux) which resulted in bad translated values,
and add missing ones (ibcs2, osf1 and svr4) which made some out of
bounds accesses.
 1.14 17-Dec-2013  njoly Cleanup compat linux errnos by adding generic errnos in a single file.
Use it for all arches except alpha and mips.
Add a few missing native to linux errno conversions.
 1.13 28-Apr-2008  martin branches: 1.13.34; 1.13.44; 1.13.50;
Remove clause 3 and 4 from TNF licenses
 1.12 13-Nov-2001  lukem branches: 1.12.114; 1.12.116; 1.12.118;
add RCSIDs (including regeneration of files as appropriate)
 1.11 11-Feb-2001  manu branches: 1.11.2; 1.11.4;
Moved the fix for negative errno returned to userland on the PowerPC to a
more machine independent fashion
 1.10 18-Jan-2001  jdolecek constify
 1.9 23-Oct-1998  erh branches: 1.9.12;
Change linux_error to native_to_linux_errno. Add some (unrelated) debugging printfs.
 1.8 23-Oct-1998  erh Moved from linux_error.c,v
 1.7 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.6 03-Oct-1998  christos Attempt to fix the mess.
 1.5 01-Oct-1998  erh Move compat/linux/linux_error.c to common.
 1.4 10-Feb-1998  kleink Map ENOMSG.
 1.3 06-Feb-1998  mikel update errno maps, we now have EIDRM
 1.2 22-Apr-1995  christos - added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.9.12.2 12-Mar-2001  bouyer Sync with HEAD.
 1.9.12.1 11-Feb-2001  bouyer Sync with HEAD.
 1.11.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.12.118.1 16-May-2008  yamt sync with head.
 1.12.116.1 18-May-2008  yamt sync with head.
 1.12.114.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.50.1 18-May-2014  rmind sync with head
 1.13.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.34.1 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.15.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.17 22-May-2022  andvar fix various small typos, mainly in comments.
 1.16 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.15 22-Nov-2014  njoly Do not define LINUX_EDEADLK more than once.
 1.14 17-Dec-2013  njoly Cleanup compat linux errnos by adding generic errnos in a single file.
Use it for all arches except alpha and mips.
Add a few missing native to linux errno conversions.
 1.13 28-Apr-2008  martin branches: 1.13.34; 1.13.44; 1.13.50;
Remove clause 3 and 4 from TNF licenses
 1.12 11-Dec-2005  christos branches: 1.12.70; 1.12.72; 1.12.74;
merge ktrace-lwp.
 1.11 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.10 19-Jun-2004  manu Fix a reversed errno issue for Linux binaries on mips. While we are there,
fix broken includes for alpha and m68k.
 1.9 17-Jan-2002  rjs branches: 1.9.16; 1.9.18;
Include arch/arm/linux_errno.h for arm build.
 1.8 19-Jan-2001  manu branches: 1.8.2; 1.8.4;
Added Linux errno mapping for powerpc
 1.7 18-Jan-2001  jdolecek constify
 1.6 24-Oct-1998  christos branches: 1.6.12;
Allow kdump to compile again.
 1.5 23-Oct-1998  erh Change linux_error to native_to_linux_errno. Add some (unrelated) debugging printfs.
 1.4 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Split compat/linux/linux_errno.h into i386 and common parts.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.6.12.1 11-Feb-2001  bouyer Sync with HEAD.
 1.8.4.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.8.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.9.18.1 22-Jun-2004  tron Pull up revision 1.10 (requested by manu in ticket #521):
Fix a reversed errno issue for Linux binaries on mips. While we are
there,
fix broken includes for alpha and m68k.
 1.9.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.16.1 03-Aug-2004  skrll Sync with HEAD
 1.12.74.1 16-May-2008  yamt sync with head.
 1.12.72.1 18-May-2008  yamt sync with head.
 1.12.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.50.1 18-May-2014  rmind sync with head
 1.13.44.2 03-Dec-2017  jdolecek update from HEAD
 1.13.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.34.1 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.1 17-Dec-2013  njoly branches: 1.1.4; 1.1.6; 1.1.10;
Cleanup compat linux errnos by adding generic errnos in a single file.
Use it for all arches except alpha and mips.
Add a few missing native to linux errno conversions.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 17-Dec-2013  tls file linux_errno_generic.h was added on branch tls-maxphys on 2014-08-20 00:03:32 +0000
 1.1.6.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.1.6.1 17-Dec-2013  yamt file linux_errno_generic.h was added on branch yamt-pagecache on 2014-05-22 11:40:16 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 17-Dec-2013  rmind file linux_errno_generic.h was added on branch rmind-smpnet on 2014-05-18 17:45:32 +0000
 1.8 23-Oct-1998  erh Moved to linux_errno.c,v
 1.7 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.6 03-Oct-1998  christos Attempt to fix the mess.
 1.5 01-Oct-1998  erh Move compat/linux/linux_error.c to common.
 1.4 10-Feb-1998  kleink Map ENOMSG.
 1.3 06-Feb-1998  mikel update errno maps, we now have EIDRM
 1.2 22-Apr-1995  christos - added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.124 03-May-2020  thorpej Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes
exist in different namespace depending on FUTEX_PRIVATE_FLAG. This appears
not to be the case in Linux, and some futex users will mix private and non-
private ops on the same futex object. Provide a convenience wrapper that
puts this logic in one place witn a comment explaining why.

While here, move the Linux futex wrapper out of its own file and plop
it in linux_misc.c, which is where it lives in the linux32 module.
 1.123 26-Apr-2020  thorpej Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.122 24-Apr-2020  thorpej Overhaul the way LWP IDs are allocated. Instead of each LWP having it's
own LWP ID space, LWP IDs came from the same number space as PIDs. The
lead LWP of a process gets the PID as its LID. If a multi-LWP process's
lead LWP exits, the PID persists for the process.

In addition to providing system-wide unique thread IDs, this also lets us
eliminate the per-process LWP radix tree, and some associated locks.

Remove the separate "global thread ID" map added previously; it is no longer
needed to provide this functionality.

Nudged in this direction by ad@ and chs@.
 1.121 15-Feb-2020  ad branches: 1.121.4;
PR kern/54922: 9.99.45@20200202 panic: diagnostic assertion linux ldconfig triggers vpp != NULL in exit1()->radixtree.c line 674

Create an lwp_renumber() from the code in emulexec() and use in
linux_e_proc_exec() and linux_e_proc_fork() too.
 1.120 10-Aug-2018  pgoyette branches: 1.120.6;
Allow syscall_establish() to install new syscalls when the existing
entry-point is either sys_nomodule or sys_nosys. Update the
makesyscalls.sh script to create a const array of bits to allow
syscall_disestablish() to properly restore the original entry-point.
Update all the initializers of struct emul to initialize the pointer
to the bit array struct emul.

XXX Regen of all files created by makesyscalls.sh will come soon,
XXX followed by a kernel version bump (since struct emul is being
XXX modified).

This commit should address PR kern/45781 and also removes the need
for the work-around for that PR in file

sys/arch/usermode/modules/syscallemu/syscallemu.c
 1.119 06-May-2018  kamil branches: 1.119.2;
Remove an element from struct emul: e_tracesig

e_tracesig used to be implemented for Darwin compat. Nowadays the Darwin
compatiblity layer is gone and there are no other users.

This functionality isn't used where it shall be used in the existing
codebase.

If we want to emulate debugging interfaces in compat layers we would need
to implement that from scratch anyway. We would need to be bug compatible
with other OSes too.

Proposed on tech-kern@.

Welcome to NetBSD 8.99.16!

Sponsored by <The NetBSD Foundation>
 1.118 09-Jan-2018  maya branches: 1.118.2;
remove struct emul's e_fault.

It used to be used by COMPAT_IRIX for the purpose of overriding
uvm_fault (only implemented in MIPS), now removed.

Ride 8.99.12 version bump.
 1.117 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.116 19-Feb-2012  rmind branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.115 18-Aug-2011  christos branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var
 1.114 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.113 25-Oct-2009  rmind branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).
 1.112 15-Mar-2009  cegger ansify function definitions
 1.111 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.110 17-Dec-2008  cegger branches: 1.110.2;
kill MALLOC and FREE macros.
 1.109 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.108 28-Oct-2008  jmcneill Only call release_futexes if LINUX_NPTL
 1.107 26-Oct-2008  christos branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.
 1.106 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.105 28-Apr-2008  martin branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses
 1.104 24-Apr-2008  ad branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.103 23-Apr-2008  ad Sprinkle locking.
 1.102 11-Apr-2008  njoly branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...
 1.101 08-Apr-2008  njoly Cleanup unneeded LINUX_NPTL ifdef/endif.
 1.100 08-Dec-2007  dsl branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.99 04-Dec-2007  dsl Remove all the __P
 1.98 16-Nov-2007  njoly branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.
 1.97 19-Oct-2007  njoly branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.96 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.95 22-Apr-2007  dsl branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.94 09-Mar-2007  ad branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.
 1.93 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.92 19-Feb-2007  cube Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.
 1.91 15-Feb-2007  ad branches: 1.91.2;
Fix Linux compat on amd64.
 1.90 09-Feb-2007  ad Merge newlock2 to head.
 1.89 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.88 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.87 29-Sep-2006  christos Coverity CID 2990: fix memory leak (from Arnaud Lacombe)
 1.86 02-Sep-2006  christos branches: 1.86.2; 1.86.4;
fix incomplete initializer
 1.85 23-Aug-2006  manu 1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

The thread group leader must report the exit status, even if it exits
because of another thread calling exit_group(). We do that by storing the
exit status in struct linux_emuldata_shared, and the exit hook has the
duty of setting struct proc's p_xstat for the thread group leader.

2) For exit/fork/exec hooks, move the NPTL specific code to separate functions
that are shared between COMPAT_LINUX and COMPAT_LINUX32

3) Fix LINUX_CLONE_PARENT_SETTID semantics
 1.84 25-Jun-2006  manu - Complete exit_group() implementation. We now maintain a list of Linux
threads in a processes and kill them properly. The code is a bit too
complicated, but I could not find a simplier way of dealing with it

- Change getpid() and getppid() semantics to match what Linux does,
and implement gettid(). In the Linux kernel, threads are implemnted
as plain old processes. A thread group is just a set of processes,
with the parent called leader. Thread ID, which are returned by gettid(),
are just the PID of the plain old processes, and getpid() returns the
PID of the thread group leader.

- Remove struct linux32_emuldata. COMPAT_LINUX32 uses a lot of COMPAT_LINUX
code, where a struct linux_emuldata is assumed. By having distinct emuldata
structure with different sizes and layouts, we caused kernel memory
corruptions.

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.
 1.83 11-Dec-2005  christos branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.
 1.82 23-Nov-2005  manu To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...
 1.81 05-Nov-2005  manu branches: 1.81.2;
Implement more of Linux futex(2)
 1.80 05-Nov-2005  manu Fix build when LINUX_NPTL is not defined
 1.79 05-Nov-2005  manu Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()
 1.78 04-Nov-2005  manu Implement Linux futex ang gettid
 1.77 22-Jun-2005  manu branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.
 1.76 02-Jun-2005  tsutsui Add a const.
 1.75 20-May-2005  fvdl Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.
 1.74 26-Mar-2005  christos s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!
 1.73 26-Mar-2005  fvdl Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
that will return the default VM map address. The default function
is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
macro. This gives emulations control over the default map address,
and allows things to be mapped at the right address (in 32bit range)
for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2

Tested on amd64, compile-tested on sparc64.
 1.72 08-Aug-2004  jdolecek branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug
 1.71 08-Aug-2004  jdolecek linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads
 1.70 20-Dec-2003  fvdl branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.
 1.69 20-Dec-2003  manu Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.
 1.68 05-Dec-2003  jdolecek back the sigfilter emulation hook change off
 1.67 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.66 03-Dec-2003  manu Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

if sigfilter returns 0, then no signal is sent by kpsignal2().

There is another place where signals can be generated: trapsignal. Since this
function is already an emulation hook, no call to the sigfilter hook was
introduced in trapsignal.

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)
 1.65 24-Aug-2003  chs add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

- pmap and trap-handler changes. these are all MD:
= alpha: we already track per-page execute permission with the (software)
PG_EXEC bit, so just have the trap handler pay attention to it.
= i386: use a new GDT segment for %cs for processes that have no
executable mappings above a certain threshold (currently the
bottom of the stack). track per-page execute permission with
the last unused PTE bit.
= powerpc/ibm4xx: just use the hardware exec bit.
= powerpc/oea: we already track per-page exec bits, but the hardware only
implements non-exec mappings at the segment level. so track the
number of executable mappings in each segment and turn on the no-exec
segment bit iff the count is 0. adjust the trap handler to deal.
= sparc (sun4m): fix our use of the hardware protection bits.
fix the trap handler to recognize text faults.
= sparc64: split the existing unified TSB into data and instruction TSBs,
and only load TTEs into the appropriate TSB(s) for the permissions.
fix the trap handler to check for execute permission.
= not yet implemented: amd64, hppa, sh5

- changes in all the emulations that put a signal trampoline on the stack.
instead, we now put the trampoline into a uvm_aobj and map that into
the process separately.

originally from openbsd, adapted for netbsd by me.
 1.64 29-Jun-2003  fvdl branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.63 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.62 01-Mar-2003  thorpej Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.
 1.61 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.60 01-Nov-2002  jdolecek set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL
 1.59 21-Sep-2002  manu - Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

- While we are there, explicitely set to NULL the uninitialized fields in
struct emul: e_fault and e_sysctl on most ports

- e_fault is used by the trap handler, for now only on mips. In order to avoid
intrusive modifications in UVM, the function pointed by e_fault does not
has exactly the same protoype as uvm_fault:
int uvm_fault __P((struct vm_map *, vaddr_t, vm_fault_t, vm_prot_t));
int e_fault __P((struct proc *, vaddr_t, vm_fault_t, vm_prot_t));

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
 1.58 02-Apr-2002  jdolecek rename sysctl_linux() to linux_sysctl() and hook it into emul_linux
 1.57 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.56 17-Jan-2002  bjh21 Fix typo in last commit.
 1.55 17-Jan-2002  bjh21 On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.
 1.54 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.53 18-Sep-2001  jdolecek Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).
 1.52 18-Jun-2001  christos branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.
 1.51 16-Jun-2001  manu Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?
 1.50 07-May-2001  manu Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.
 1.49 06-May-2001  manu Added two flags to emulation packages:

EMUL_BSD_ASYNCIO_PIPE notes that the emulated binaries expect the original
BSD pipe behavior for asynchronous I/O, which is to fire SIGIO on read() and
write(). OSes without this flag do not expect any SIGIO to be fired on
read() and write() for pipes, even when async I/O was requested. As far as
we know, the OSes that need EMUL_BSD_ASYNCIO_PIPE are NetBSD, OSF/1 and
Darwin.

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.
 1.48 24-Mar-2001  jdolecek Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.
 1.47 22-Mar-2001  itojun do not dereference p_vmspace, if it is not initialized yet (NULL).
 1.46 15-Mar-2001  manu Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.
 1.45 19-Jan-2001  manu branches: 1.45.2;
Added support for powerpc Linux compatibility
 1.44 11-Dec-2000  mycroft Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.
 1.43 09-Dec-2000  jdolecek always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()
 1.42 02-Dec-2000  jdolecek if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386
 1.41 01-Dec-2000  jdolecek if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha
 1.40 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.39 21-Nov-2000  jdolecek (de)allocate linux emuldata on fork/exec/exit as needed
 1.38 21-Nov-2000  jdolecek restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures
 1.37 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.36 26-Jun-2000  mrg remove redundant vm includes.
 1.35 09-Feb-1999  christos branches: 1.35.8;
const poisoning.
 1.34 07-Oct-1998  erh The siginfo include line is not needed here anymore.
 1.33 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.32 03-Oct-1998  christos Attempt to fix the mess.
 1.31 01-Oct-1998  erh Split compat/linux/linux_exec.c into common, elf and a.out parts.
 1.30 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.29 05-Sep-1998  christos Assign copyright to TNF.
 1.28 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.27 28-Jul-1998  thorpej Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.
 1.26 24-Jan-1998  mycroft Use linux_setregs().
 1.25 13-Oct-1996  christos branches: 1.25.14;
catch up with Jason's exec.h inclusion.
 1.24 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.23 07-Oct-1996  cgd include <sys/exec.h> rather than <machine/exec.h>
 1.22 05-Oct-1996  jtk update to compile; needs new enum name 'Elf_sht_progbits'
 1.21 03-Oct-1996  cgd kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.
 1.20 03-Oct-1996  thorpej Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.
 1.19 30-Sep-1996  christos Elf32_sht_progbits -> Elf_sht_progbits
 1.18 27-Sep-1996  cgd slightly clean up some of the changes made when ELF64 support went in
 1.17 26-Sep-1996  cgd adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.
 1.16 03-Sep-1996  mycroft Define execv() and execve() consistently across emulations.
Do path name translation.
 1.15 13-Jun-1996  christos Simplify and add comments.
 1.14 13-Jun-1996  christos - Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.
 1.13 05-Apr-1996  christos branches: 1.13.4;
Prototyping changes.
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 14-Aug-1995  mycroft Rearrange #includes.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 16-May-1995  mycroft Generate the new ps_strings format.
 1.4 22-Apr-1995  christos - added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.
 1.3 07-Apr-1995  fvdl Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.13.4.1 10-Dec-1996  mycroft From trunk:
Do execv() and execve() path name translation consistently across
emulations.
 1.25.14.1 29-Jan-1998  mellon Pull up 1.26 (mycroft)
 1.35.8.6 27-Mar-2001  bouyer Sync with HEAD.
 1.35.8.5 11-Feb-2001  bouyer Sync with HEAD.
 1.35.8.4 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.35.8.3 08-Dec-2000  bouyer Sync with HEAD.
 1.35.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.35.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.45.2.11 11-Nov-2002  nathanw Catch up to -current
 1.45.2.10 18-Oct-2002  nathanw Catch up to -current.
 1.45.2.9 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.45.2.8 17-Apr-2002  nathanw Catch up to -current.
 1.45.2.7 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.45.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.45.2.5 14-Nov-2001  nathanw Catch up to -current.
 1.45.2.4 21-Sep-2001  nathanw Catch up to -current.
 1.45.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.45.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.45.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.52.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.52.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.52.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.52.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.52.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.64.2.8 11-Dec-2005  christos Sync with head.
 1.64.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.64.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.64.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.64.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.64.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.64.2.2 03-Aug-2004  skrll Sync with HEAD
 1.64.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.70.2.2 15-Aug-2004  tron Pull up revision 1.72 (requested by jdolecek in ticket #762):
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug
 1.70.2.1 15-Aug-2004  tron Pull up revision 1.71 (requested by jdolecek in ticket #762):
linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size
this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads
 1.72.10.2 18-Sep-2005  tron Pull up following revision(s) (requested by fvdl in ticket #798):
sys/compat/linux/common/linux_exec.c: revision 1.74
sys/compat/hpux/hpux_exec.c: revision 1.47
s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!
 1.72.10.1 18-Sep-2005  tron Pull up following revision(s) (requested by fvdl in ticket #798):
sys/compat/sunos/sunos_exec.c: revision 1.47
sys/compat/pecoff/pecoff_emul.c: revision 1.11
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.45
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.12
sys/sys/proc.h: revision 1.198
sys/compat/mach/mach_exec.c: revision 1.56
sys/compat/freebsd/freebsd_exec.c: revision 1.27
sys/arch/sparc64/include/vmparam.h: revision 1.27
sys/kern/kern_resource.c: revision 1.91
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.88
sys/compat/osf1/osf1_exec.c: revision 1.39
sys/compat/svr4_32/svr4_32_resource.c: revision 1.5
sys/compat/ultrix/ultrix_misc.c: revision 1.99
sys/compat/svr4_32/svr4_32_exec.h: revision 1.9
sys/kern/exec_elf32.c: revision 1.103
sys/compat/aoutm68k/aoutm68k_exec.c: revision 1.19
sys/compat/sunos32/sunos32_exec.c: revision 1.20
sys/compat/hpux/hpux_exec.c: revision 1.46
sys/compat/darwin/darwin_exec.c: revision 1.40
sys/kern/sysv_shm.c: revision 1.83
sys/uvm/uvm_extern.h: revision 1.99
sys/uvm/uvm_mmap.c: revision 1.89
sys/kern/kern_exec.c: revision 1.195
sys/compat/netbsd32/netbsd32.h: revision 1.31
sys/arch/sparc64/sparc64/svr4_32_machdep.c: revision 1.20
sys/compat/svr4/svr4_exec.c: revision 1.56
sys/compat/irix/irix_exec.c: revision 1.41
sys/compat/ibcs2/ibcs2_exec.c: revision 1.63
sys/compat/svr4_32/svr4_32_exec.c: revision 1.16
sys/arch/amd64/include/vmparam.h: revision 1.8
sys/compat/linux/common/linux_exec.c: revision 1.73
Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
that will return the default VM map address. The default function
is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
macro. This gives emulations control over the default map address,
and allows things to be mapped at the right address (in 32bit range)
for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2
Tested on amd64, compile-tested on sparc64.
 1.72.6.1 26-Mar-2005  yamt sync with head.
 1.72.4.1 29-Apr-2005  kent sync with -current
 1.77.2.7 21-Jan-2008  yamt sync with head
 1.77.2.6 07-Dec-2007  yamt sync with head
 1.77.2.5 27-Oct-2007  yamt sync with head.
 1.77.2.4 03-Sep-2007  yamt sync with head.
 1.77.2.3 26-Feb-2007  yamt sync with head.
 1.77.2.2 30-Dec-2006  yamt sync with head.
 1.77.2.1 21-Jun-2006  yamt sync with head.
 1.81.2.1 29-Nov-2005  yamt sync with head.
 1.83.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.83.8.2 03-Sep-2006  yamt sync with head.
 1.83.8.1 26-Jun-2006  yamt sync with head.
 1.83.4.1 09-Sep-2006  rpaulo sync with head
 1.86.4.2 10-Dec-2006  yamt sync with head.
 1.86.4.1 22-Oct-2006  yamt sync with head
 1.86.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.86.2.1 18-Nov-2006  ad Sync with head.
 1.91.2.3 07-May-2007  yamt sync with head.
 1.91.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.91.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.94.4.1 11-Jul-2007  mjf Sync with head.
 1.94.2.2 23-Oct-2007  ad Sync with head.
 1.94.2.1 27-May-2007  ad Sync with head.
 1.95.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.95.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.95.8.2 09-Jan-2008  matt sync with HEAD
 1.95.8.1 06-Nov-2007  matt sync with HEAD
 1.95.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.95.6.2 21-Nov-2007  joerg Sync with HEAD.
 1.95.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.97.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.97.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.97.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.98.2.2 26-Dec-2007  ad Sync with head.
 1.98.2.1 08-Dec-2007  ad Sync with head.
 1.100.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.100.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.102.2.1 18-May-2008  yamt sync with head.
 1.104.2.4 11-Aug-2010  yamt sync with head.
 1.104.2.3 11-Mar-2010  yamt sync with head
 1.104.2.2 04-May-2009  yamt sync with head.
 1.104.2.1 16-May-2008  yamt sync with head.
 1.105.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.105.6.1 19-Oct-2008  haad Sync with HEAD.
 1.105.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.105.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.107.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.107.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.110.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.113.4.1 05-Mar-2011  rmind sync with head
 1.113.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.115.6.1 24-Feb-2012  mrg sync to -current.
 1.115.2.1 17-Apr-2012  yamt sync with head
 1.116.14.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.116.2.1 03-Dec-2017  jdolecek update from HEAD
 1.118.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.118.2.1 21-May-2018  pgoyette Sync with HEAD
 1.119.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.119.2.1 10-Jun-2019  christos Sync with HEAD
 1.120.6.1 29-Feb-2020  ad Sync with head.
 1.121.4.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.55 26-Nov-2021  ryo - LINUX_GO_RT0_SIGNATURE for compat_linux is no longer enabled by default.
it is now defined in each arch same as the other *_SIGNATURE definitions.
- add new LINUX32_GO_RT0_SIGNATURE for compat_linux32, and is defined in amd64 and aarch64.
 1.54 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.53 22-Aug-2018  msaitoh - Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.
 1.52 12-Feb-2017  chs branches: 1.52.12; 1.52.14;
es_arglen is now in units of bytes, update the emulations accordingly.
 1.51 21-Feb-2014  maxv branches: 1.51.6; 1.51.10; 1.51.14;
Increase LINUX32_ELF_AUX_ENTRIES to avoid overrun in linux32/. Also,
add comments and KASSERTs to make sure people don't forget to increase
XX_AUX_ENTRIES's when adding vectors.

Reported by martin@ (CV), with suggestions from chs@.

ok martin@ chs@
 1.50 09-Feb-2014  chs account for the 16 bytes of AT_RANDOM data in the stack setup. fixes PR 48518.
use cprng_strong32() instead of random(). add AT_RANDOM support for linux32.
 1.49 18-Nov-2013  chs implement AT_RANDOM.
 1.48 07-Jul-2010  chs branches: 1.48.8; 1.48.18; 1.48.22;
many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.47 10-Dec-2009  matt branches: 1.47.2; 1.47.4;
Change u_long to vaddr_t/vsize_t in exec code where appropriate (mostly
involves setregs and vmcmds). Should result in no code differences.
 1.46 15-Aug-2009  matt Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for you.
 1.45 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.44 25-Oct-2008  christos branches: 1.44.2;
Add preliminary tls support for i386. Does not work yet. From FreeBSD.
 1.43 28-Apr-2008  martin branches: 1.43.6;
Remove clause 3 and 4 from TNF licenses
 1.42 04-Dec-2007  dsl branches: 1.42.12; 1.42.14; 1.42.16;
Remove all the __P
 1.41 15-Feb-2007  ad branches: 1.41.18; 1.41.20; 1.41.26; 1.41.28;
Fix Linux compat on amd64.
 1.40 09-Feb-2007  ad Merge newlock2 to head.
 1.39 23-Aug-2006  manu branches: 1.39.2;
1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

The thread group leader must report the exit status, even if it exits
because of another thread calling exit_group(). We do that by storing the
exit status in struct linux_emuldata_shared, and the exit hook has the
duty of setting struct proc's p_xstat for the thread group leader.

2) For exit/fork/exec hooks, move the NPTL specific code to separate functions
that are shared between COMPAT_LINUX and COMPAT_LINUX32

3) Fix LINUX_CLONE_PARENT_SETTID semantics
 1.38 07-Aug-2006  manu Add a new signature test for linux probe function. We look for a .debuglink
section, which is specific to the Linux dynamic interpeter (yes, Linux
can execute it as a stand alone program)
 1.37 09-Feb-2006  manu branches: 1.37.2;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.36 11-Dec-2005  christos branches: 1.36.2; 1.36.4; 1.36.6;
merge ktrace-lwp.
 1.35 20-May-2005  fvdl branches: 1.35.2;
Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.
 1.34 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.33 26-Feb-2005  perry nuke trailing whitespace
 1.32 26-Mar-2004  drochner branches: 1.32.8; 1.32.10;
all ports define __HAVE_SIGINFO now, so remove the CPP conditionals
 1.31 25-Sep-2003  christos constify sendsig/trapsignal
 1.30 06-Sep-2003  christos SA_SIGINFO changes
 1.29 29-Jun-2003  fvdl branches: 1.29.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.28 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.27 09-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.26 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.25 21-Nov-2002  jdolecek back previous off; port can only supply LINUX_ELF_AUX_ENTRIES if it also
overrides the ELF copyargs function
 1.24 15-Nov-2002  wdk Fix LINUX_ELF_AUX_ENTRIES sociability issue with Mips based ports
 1.23 13-Nov-2002  jdolecek add generic linux compat ELF copyargs function

this gives:
* linux sysconf(_SC_CLK_TCK) gives correct value for linux binaries (hz)
even if hz != 100
* glibc gets proper information on real/effective uid and enables
secure mode for suid binaries

g/c LINUX_COPYARGS_FUNCTION, replaced by linux ELF copyargs function
g/c alpha-specific linux ELF copyargs function and linux ELF defines
 1.22 26-Aug-2002  christos Implement passing AT_{E,R}{U,G}ID in the elf aux vector, like solaris.
- pass struct proc to copyargs.
- eliminate svr4_copyargs, since it is the same as ours now.
 1.21 02-Apr-2002  jdolecek branches: 1.21.2;
rename sysctl_linux() to linux_sysctl() and hook it into emul_linux
 1.20 21-Mar-2002  christos Don't bitch if we don't have support for a particular arch. This makes it
easier to include this header from userland binaries [sysctl] on archs that
don't support compat-linux without incurring ifdef hell.
 1.19 20-Mar-2002  christos emulation specific sysctls. Also change the kernel date to nov 11 as requested
by bad.
 1.18 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.17 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.16 29-Jul-2001  christos branches: 1.16.2;
Adjust to the new copyargs() footprint.
 1.15 18-Jun-2001  christos branches: 1.15.2;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.
 1.14 19-Jan-2001  manu branches: 1.14.2;
Added Linux compatibility support for powerpc ports
 1.13 21-Nov-2000  jdolecek restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures
 1.12 15-Dec-1998  itohy branches: 1.12.8;
Added linux compat support on m68k ports.
 1.11 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.10 03-Oct-1998  christos Attempt to fix the mess.
 1.9 01-Oct-1998  erh Move compat/linux/linux_exec.h to common.
 1.8 24-Jan-1998  mycroft Prototype new functions.
 1.7 26-Sep-1996  cgd branches: 1.7.14;
adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.
 1.6 13-Jun-1996  christos - Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.
 1.5 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.2 07-Apr-1995  fvdl Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.7.14.1 29-Jan-1998  mellon Pull up 1.8 (mycroft)
 1.12.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.12.8.1 22-Nov-2000  bouyer Sync with HEAD.
 1.14.2.9 11-Dec-2002  thorpej Sync with HEAD.
 1.14.2.8 27-Aug-2002  nathanw Catch up to -current.
 1.14.2.7 17-Apr-2002  nathanw Catch up to -current.
 1.14.2.6 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.14.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.4 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.14.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.14.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.14.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.15.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.2.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.15.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 03-Aug-2001  lukem update to -current
 1.16.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.21.2.1 29-Aug-2002  gehenna catch up with -current.
 1.29.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.29.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.2 03-Aug-2004  skrll Sync with HEAD
 1.29.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.32.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.8.1 29-Apr-2005  kent sync with -current
 1.35.2.4 07-Dec-2007  yamt sync with head
 1.35.2.3 26-Feb-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.36.6.1 22-Apr-2006  simonb Sync with head.
 1.36.4.1 09-Sep-2006  rpaulo sync with head
 1.36.2.1 18-Feb-2006  yamt sync with head.
 1.37.2.2 03-Sep-2006  yamt sync with head.
 1.37.2.1 11-Aug-2006  yamt sync with head
 1.39.2.1 24-Oct-2006  ad - Redo LWP locking slightly and fix some races.
- Fix some locking botches.
- Make signal mask / stack per-proc for SA processes.
- Add _lwp_kill().
 1.41.28.1 08-Dec-2007  ad Sync with head.
 1.41.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.41.20.1 09-Jan-2008  matt sync with HEAD
 1.41.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.42.16.5 11-Aug-2010  yamt sync with head.
 1.42.16.4 11-Mar-2010  yamt sync with head
 1.42.16.3 19-Aug-2009  yamt sync with head.
 1.42.16.2 04-May-2009  yamt sync with head.
 1.42.16.1 16-May-2008  yamt sync with head.
 1.42.14.1 18-May-2008  yamt sync with head.
 1.42.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.42.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.43.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.44.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.4.1 05-Mar-2011  rmind sync with head
 1.47.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.48.22.1 18-May-2014  rmind sync with head
 1.48.18.2 03-Dec-2017  jdolecek update from HEAD
 1.48.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.8.1 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.51.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.51.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.51.6.1 28-Aug-2017  skrll Sync with HEAD
 1.52.14.1 10-Jun-2019  christos Sync with HEAD
 1.52.12.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.68 18-Oct-2015  maxv Make sure we have space for the aout header.
 1.67 09-Nov-2014  maxv branches: 1.67.2;
Do not uselessly include <sys/malloc.h>.
 1.66 15-Aug-2009  matt branches: 1.66.22; 1.66.38;
Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for you.
 1.65 28-Apr-2008  martin branches: 1.65.2;
Remove clause 3 and 4 from TNF licenses
 1.64 08-Dec-2007  dsl branches: 1.64.12; 1.64.14; 1.64.16;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.63 04-Dec-2007  dsl Remove all the __P
 1.62 19-Oct-2007  ad branches: 1.62.2; 1.62.4;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.61 09-Feb-2007  ad branches: 1.61.6; 1.61.18; 1.61.20; 1.61.24;
Merge newlock2 to head.
 1.60 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.59 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.58 11-Dec-2005  christos branches: 1.58.20; 1.58.22;
merge ktrace-lwp.
 1.57 26-Feb-2005  perry branches: 1.57.4;
nuke trailing whitespace
 1.56 30-Jan-2005  christos Don't try to map a 0 size bss.
 1.55 08-Aug-2003  christos branches: 1.55.8; 1.55.10;
- GC all the setup_stack functions
- add one for linux/i386
 1.54 29-Jun-2003  fvdl branches: 1.54.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.53 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.52 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.51 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.50 05-Oct-2002  chs count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.49 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.48 26-Aug-2002  christos Implement passing AT_{E,R}{U,G}ID in the elf aux vector, like solaris.
- pass struct proc to copyargs.
- eliminate svr4_copyargs, since it is the same as ours now.
 1.47 13-Nov-2001  lukem branches: 1.47.8; 1.47.10;
add RCSIDs (including regeneration of files as appropriate)
 1.46 30-Oct-2001  thorpej - Add a new vnode flag VEXECMAP, which indicates that a vnode has
executable mappings. Stop overloading VTEXT for this purpose (VTEXT
also has another meaning).
- Rename vn_marktext() to vn_markexec(), and use it when executable
mappings of a vnode are established.
- In places where we want to set VTEXT, set it in v_flag directly, rather
than making a function call to do this (it no longer makes sense to
use a function call, since we no longer overload VTEXT with VEXECMAP's
meaning).

VEXECMAP suggested by Chuq Silvers.
 1.45 29-Jul-2001  christos branches: 1.45.4;
Adjust to the new copyargs() footprint.
 1.44 01-Dec-2000  jdolecek branches: 1.44.2; 1.44.4;
put linux_sys_uselib() to separate file linux_uselib.c
 1.43 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.42 21-Nov-2000  jdolecek restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures
 1.41 13-Nov-2000  jdolecek change the type of *syscallnames[] array to 'const char * const foo[]'
 1.40 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.39 26-Jun-2000  mrg remove redundant vm includes.
 1.38 11-Apr-2000  chs add a new function vn_marktext() for exec code to let others know
that the vnode is now being used as process text.
 1.37 09-Feb-1999  christos branches: 1.37.4; 1.37.8;
const poisoning.
 1.36 23-Oct-1998  veego Include linux_errno.h to fix the recent error->errno losage.
 1.35 23-Oct-1998  erh Change linux_error to native_to_linux_errno. Add some (unrelated) debugging printfs.
 1.34 07-Oct-1998  erh The siginfo include line is not needed here anymore.
 1.33 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.32 03-Oct-1998  christos Attempt to fix the mess.
 1.31 01-Oct-1998  erh Split compat/linux/linux_exec.c into common, elf and a.out parts.
 1.30 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.29 05-Sep-1998  christos Assign copyright to TNF.
 1.28 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.27 28-Jul-1998  thorpej Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.
 1.26 24-Jan-1998  mycroft Use linux_setregs().
 1.25 13-Oct-1996  christos branches: 1.25.14;
catch up with Jason's exec.h inclusion.
 1.24 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.23 07-Oct-1996  cgd include <sys/exec.h> rather than <machine/exec.h>
 1.22 05-Oct-1996  jtk update to compile; needs new enum name 'Elf_sht_progbits'
 1.21 03-Oct-1996  cgd kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.
 1.20 03-Oct-1996  thorpej Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.
 1.19 30-Sep-1996  christos Elf32_sht_progbits -> Elf_sht_progbits
 1.18 27-Sep-1996  cgd slightly clean up some of the changes made when ELF64 support went in
 1.17 26-Sep-1996  cgd adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.
 1.16 03-Sep-1996  mycroft Define execv() and execve() consistently across emulations.
Do path name translation.
 1.15 13-Jun-1996  christos Simplify and add comments.
 1.14 13-Jun-1996  christos - Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.
 1.13 05-Apr-1996  christos branches: 1.13.4;
Prototyping changes.
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 14-Aug-1995  mycroft Rearrange #includes.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 16-May-1995  mycroft Generate the new ps_strings format.
 1.4 22-Apr-1995  christos - added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.
 1.3 07-Apr-1995  fvdl Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.13.4.1 10-Dec-1996  mycroft From trunk:
Do execv() and execve() path name translation consistently across
emulations.
 1.25.14.1 29-Jan-1998  mellon Pull up 1.26 (mycroft)
 1.37.8.3 08-Dec-2000  bouyer Sync with HEAD.
 1.37.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.37.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.37.4.1 04-Jul-1999  chs after setting VTEXT on a vnode, flush any UBC mappings
to try to prevent unnecessary VAC aliases.
 1.44.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.44.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.44.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.44.4.1 03-Aug-2001  lukem update to -current
 1.44.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.44.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.44.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.44.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.44.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.45.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.47.10.2 02-Oct-2003  tron Pull up revision 1.50 (requested by junyoung in ticket #1488):
count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.47.10.1 27-Sep-2003  tron Pull up revision 1.49 (requested by junyoung in ticket #1466):
remove trailing \n in panic(). approved perry.
 1.47.8.1 29-Aug-2002  gehenna catch up with -current.
 1.54.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.54.2.6 04-Feb-2005  skrll Sync with HEAD.
 1.54.2.5 04-Feb-2005  skrll Adapt to branch.
 1.54.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.54.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.54.2.2 03-Aug-2004  skrll Sync with HEAD
 1.54.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.55.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.55.10.1 12-Feb-2005  yamt sync with head.
 1.55.8.1 29-Apr-2005  kent sync with -current
 1.57.4.6 21-Jan-2008  yamt sync with head
 1.57.4.5 07-Dec-2007  yamt sync with head
 1.57.4.4 27-Oct-2007  yamt sync with head.
 1.57.4.3 26-Feb-2007  yamt sync with head.
 1.57.4.2 30-Dec-2006  yamt sync with head.
 1.57.4.1 21-Jun-2006  yamt sync with head.
 1.58.22.2 10-Dec-2006  yamt sync with head.
 1.58.22.1 22-Oct-2006  yamt sync with head
 1.58.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.58.20.1 18-Nov-2006  ad Sync with head.
 1.61.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.61.20.2 09-Jan-2008  matt sync with HEAD
 1.61.20.1 06-Nov-2007  matt sync with HEAD
 1.61.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.61.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.61.6.1 23-Oct-2007  ad Sync with head.
 1.62.4.2 26-Dec-2007  ad Sync with head.
 1.62.4.1 08-Dec-2007  ad Sync with head.
 1.62.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.62.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.64.16.2 19-Aug-2009  yamt sync with head.
 1.64.16.1 16-May-2008  yamt sync with head.
 1.64.14.1 18-May-2008  yamt sync with head.
 1.64.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.65.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.65.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.66.38.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.66.22.1 03-Dec-2017  jdolecek update from HEAD
 1.67.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.102 26-Nov-2021  ryo The internal architecture name of golang is "arm" or "arm64", which has
different naming conventions from netbsd's machine[] or machine_arch[]
("earmv7", "aarch64", etc.) and cannot be used as is.
Instead, use define LINUX_GO_RT0_SIGNATURE_ARCH{32,64}.
 1.101 26-Nov-2021  ryo - LINUX_GO_RT0_SIGNATURE for compat_linux is no longer enabled by default.
it is now defined in each arch same as the other *_SIGNATURE definitions.
- add new LINUX32_GO_RT0_SIGNATURE for compat_linux32, and is defined in amd64 and aarch64.
 1.100 12-Jan-2020  ad Tidy up the vnode locking around execve() on ELF images to acquire and
release the locks fewer times. Proposed on tech-kern a very long time go.
 1.99 01-Mar-2019  pgoyette branches: 1.99.6;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.98 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.97 15-Jul-2018  christos - fix constants and explain limit
- use machine32 instead of hard-coded x86 stuff
 1.96 09-Jul-2018  msaitoh Fix compile error.
 1.95 08-Jul-2018  christos Enable executing linux go binaries by using a special probe function for them.
 1.94 06-Feb-2017  uwe branches: 1.94.12; 1.94.14;
Use ELFOSABI_LINUX instead of a magic number.
 1.93 11-Jun-2015  matt branches: 1.93.2; 1.93.4;
Force *stackp to (uintptr_t) before possibly moving to a smaller pointer size.
 1.92 20-Mar-2015  maxv Zero-fill the ELF auxiliary vectors. Otherwise, on 64bit systems, the
padding between a_v and a_type contains kernel garbage, therefore
exposed to userland.

Original report by uebayasi@
 1.91 15-Apr-2014  maxv branches: 1.91.2; 1.91.4;
A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.

Spotted by several developers, patch from chs@/enami@
 1.90 23-Feb-2014  njoly branches: 1.90.2;
Fix wrong KASSERTs. Do not compare size vs. entries count.
 1.89 21-Feb-2014  maxv Increase LINUX32_ELF_AUX_ENTRIES to avoid overrun in linux32/. Also,
add comments and KASSERTs to make sure people don't forget to increase
XX_AUX_ENTRIES's when adding vectors.

Reported by martin@ (CV), with suggestions from chs@.

ok martin@ chs@
 1.88 09-Feb-2014  chs account for the 16 bytes of AT_RANDOM data in the stack setup. fixes PR 48518.
use cprng_strong32() instead of random(). add AT_RANDOM support for linux32.
 1.87 18-Nov-2013  chs implement AT_RANDOM.
 1.86 12-Feb-2012  matt branches: 1.86.2; 1.86.6; 1.86.8; 1.86.10; 1.86.16;
Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.85 03-Feb-2012  matt Add a hook for freeing an ep_emul_arg. Add a wrapper routine
(exec_free_emul_arg) to call the hook and then clear the ep_emul_arg
and ep_emul_arg_free members in the exec_package.
Change users/accessors to use these routines.
Approved by releng.
 1.84 11-Sep-2010  chs branches: 1.84.8; 1.84.12;
always supply an auxiliary vector for linux ELF processes.
static executables (such as newer versions of /sbin/ldconfig)
require this to work properly. since static executables
also don't have a PT_PHDR entry, use the same heuristic as
linux does to provide a value for AT_PHDR in this case.
 1.83 15-Mar-2009  cegger branches: 1.83.2; 1.83.4;
ansify function definitions
 1.82 20-Nov-2008  ad branches: 1.82.4;
PR port-amd64/39964 modules/compat_linux: missing symbols on amd64
 1.81 28-Apr-2008  martin branches: 1.81.2; 1.81.6; 1.81.8; 1.81.10; 1.81.16; 1.81.20;
Remove clause 3 and 4 from TNF licenses
 1.80 19-Oct-2007  ad branches: 1.80.16; 1.80.18; 1.80.20;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.79 22-Apr-2007  dsl branches: 1.79.6; 1.79.8; 1.79.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.78 04-Mar-2007  christos branches: 1.78.2; 1.78.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.77 09-Feb-2007  ad branches: 1.77.2;
Merge newlock2 to head.
 1.76 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.75 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.74 07-Aug-2006  manu branches: 1.74.4; 1.74.6;
Add a new signature test for linux probe function. We look for a .debuglink
section, which is specific to the Linux dynamic interpeter (yes, Linux
can execute it as a stand alone program)
 1.73 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.72 14-May-2006  elad integrate kauth.
 1.71 09-Feb-2006  manu branches: 1.71.2; 1.71.4; 1.71.6;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.70 11-Dec-2005  christos branches: 1.70.2; 1.70.4; 1.70.6;
merge ktrace-lwp.
 1.69 29-May-2005  christos branches: 1.69.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.68 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.67 26-Feb-2005  perry nuke trailing whitespace
 1.66 31-Oct-2003  drochner branches: 1.66.8; 1.66.10;
adapt for changes to kern/exec_elf32.c
 1.65 27-Oct-2003  chs uninitialized variables
 1.64 29-Jun-2003  fvdl branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.63 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.62 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.61 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.60 29-Nov-2002  jdolecek branches: 1.60.2;
Get the dynamic interpreter location using emul_find_interp(), so that
it checks both the alternative/emul tree, and the non-emul tree.
This makes it possible to run chrooted emulated binaries without need
to setup shadow /emul tree within the chroot hierarchy.
Only tested for COMPAT_LINUX, changes to other compat modules were
mechanical.
Fixes kern/19161 by Christian Groessler.
 1.59 13-Nov-2002  jdolecek add generic linux compat ELF copyargs function

this gives:
* linux sysconf(_SC_CLK_TCK) gives correct value for linux binaries (hz)
even if hz != 100
* glibc gets proper information on real/effective uid and enables
secure mode for suid binaries

g/c LINUX_COPYARGS_FUNCTION, replaced by linux ELF copyargs function
g/c alpha-specific linux ELF copyargs function and linux ELF defines
 1.58 22-Oct-2002  christos remove XXX should die comment from the define; otherwise traditional cpp
screws up the elf name formation.
 1.57 05-Sep-2002  christos check out EI_OSABI and EI_ABIVERSION for linux signatures. This is what
http://upx.sourceforge.net/ binaries are like.
 1.56 22-Mar-2002  christos gc debugging printfs.
 1.55 15-Feb-2002  christos s/printf/uprintf/
 1.54 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.53 30-Aug-2001  manu Changed the way signature tests are done. This makes possible to run
ld.so as an executable on the PowerPC (Linux's ldd does this), and it also
much clearer IMHO.
 1.52 14-Jul-2001  christos rename elf32_read_from to exec_read_from since it is used in many places
now.
 1.51 19-Jan-2001  manu branches: 1.51.2; 1.51.4;
Added a linux_atexit_signature to match Linux statically linked ELF binaries. It
searches for a __libc_atexit ELF section, which is specific to Linux
 1.50 15-Dec-2000  mycroft Tighten up the ELF signature checks, and actually look for the ABI tag added
in newer glibc versions.
 1.49 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.48 21-Nov-2000  jdolecek restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures
 1.47 17-Nov-2000  erh Make the linux compatibilty code work on the alpha. (horay!) (at last!)
Two main changes:
Create a linux_elf64_copyargs that uses the linux specific LinuxAuxInfo
structure. This is only used on the alpha. i386 and m68k use the
standard elf copyargs function.

Since linux's approach to binary compatibilty is to look as much
like osf1 as possible, add all the osf1 syscalls that we have
implemented to the linux syscall table. This includes get/setsysinfo,
ported from FreeBSD.

In order for linux compat to work you must have COMPAT_OSF1, COMPAT_43,
COMPAT_09, COMPAT_12 and COMPAT_13 on also.
 1.46 13-Nov-2000  jdolecek change the type of *syscallnames[] array to 'const char * const foo[]'
 1.45 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.44 26-Jun-2000  mrg remove redundant vm includes.
 1.43 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.42 30-Apr-1999  cgd branches: 1.42.2; 1.42.4; 1.42.6;
compute the value to be used for e_arglen via howmany(value, sizeof (char *)),
rather than just "value / sizeof (char *)". While in these cases the latter
works as well, the former's a better example for other uses to copy (since
it handles the non-integral multiple case correctly).
 1.41 09-Feb-1999  christos branches: 1.41.4;
const poisoning.
 1.40 05-Nov-1998  erh Make sure the interpreter string is long enough to check against.
 1.39 23-Oct-1998  veego Include linux_errno.h to fix the recent error->errno losage.
 1.38 23-Oct-1998  erh Change linux_error to native_to_linux_errno. Add some (unrelated) debugging printfs.
 1.37 07-Oct-1998  erh The siginfo include line is not needed here anymore.
 1.36 04-Oct-1998  christos unobfuscate: !strncmp() != 0 -> strncmp() == 0
 1.35 04-Oct-1998  fvdl Fix wrong strncmp test.
 1.34 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.33 03-Oct-1998  christos Remove stray debugging printfs
 1.32 03-Oct-1998  christos Attempt to fix the mess.
 1.31 01-Oct-1998  erh Split compat/linux/linux_exec.c into common, elf and a.out parts.
 1.30 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.29 05-Sep-1998  christos Assign copyright to TNF.
 1.28 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.27 28-Jul-1998  thorpej Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.
 1.26 24-Jan-1998  mycroft Use linux_setregs().
 1.25 13-Oct-1996  christos branches: 1.25.14;
catch up with Jason's exec.h inclusion.
 1.24 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.23 07-Oct-1996  cgd include <sys/exec.h> rather than <machine/exec.h>
 1.22 05-Oct-1996  jtk update to compile; needs new enum name 'Elf_sht_progbits'
 1.21 03-Oct-1996  cgd kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.
 1.20 03-Oct-1996  thorpej Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.
 1.19 30-Sep-1996  christos Elf32_sht_progbits -> Elf_sht_progbits
 1.18 27-Sep-1996  cgd slightly clean up some of the changes made when ELF64 support went in
 1.17 26-Sep-1996  cgd adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.
 1.16 03-Sep-1996  mycroft Define execv() and execve() consistently across emulations.
Do path name translation.
 1.15 13-Jun-1996  christos Simplify and add comments.
 1.14 13-Jun-1996  christos - Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.
 1.13 05-Apr-1996  christos branches: 1.13.4;
Prototyping changes.
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 14-Aug-1995  mycroft Rearrange #includes.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 16-May-1995  mycroft Generate the new ps_strings format.
 1.4 22-Apr-1995  christos - added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.
 1.3 07-Apr-1995  fvdl Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.13.4.1 10-Dec-1996  mycroft From trunk:
Do execv() and execve() path name translation consistently across
emulations.
 1.25.14.1 29-Jan-1998  mellon Pull up 1.26 (mycroft)
 1.41.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.42.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.42.4.1 15-Nov-1999  fvdl Sync with -current
 1.42.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.42.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.42.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.42.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.42.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.51.4.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.51.4.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.51.4.4 16-Mar-2002  jdolecek Catch up with -current.
 1.51.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.51.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.51.4.1 03-Aug-2001  lukem update to -current
 1.51.2.9 11-Dec-2002  thorpej Sync with HEAD.
 1.51.2.8 11-Nov-2002  nathanw Catch up to -current
 1.51.2.7 17-Sep-2002  nathanw Catch up to -current.
 1.51.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.51.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.51.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.51.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.51.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.51.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.60.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.64.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.64.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.64.2.5 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.64.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.64.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.64.2.2 03-Aug-2004  skrll Sync with HEAD
 1.64.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.66.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.66.8.1 29-Apr-2005  kent sync with -current
 1.69.2.5 27-Oct-2007  yamt sync with head.
 1.69.2.4 03-Sep-2007  yamt sync with head.
 1.69.2.3 26-Feb-2007  yamt sync with head.
 1.69.2.2 30-Dec-2006  yamt sync with head.
 1.69.2.1 21-Jun-2006  yamt sync with head.
 1.70.6.2 01-Jun-2006  kardel Sync with head.
 1.70.6.1 22-Apr-2006  simonb Sync with head.
 1.70.4.1 09-Sep-2006  rpaulo sync with head
 1.70.2.1 18-Feb-2006  yamt sync with head.
 1.71.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.71.4.2 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.71.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.71.2.2 11-Aug-2006  yamt sync with head
 1.71.2.1 24-May-2006  yamt sync with head.
 1.74.6.2 10-Dec-2006  yamt sync with head.
 1.74.6.1 22-Oct-2006  yamt sync with head
 1.74.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.74.4.1 18-Nov-2006  ad Sync with head.
 1.77.2.2 07-May-2007  yamt sync with head.
 1.77.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.78.4.1 11-Jul-2007  mjf Sync with head.
 1.78.2.2 23-Oct-2007  ad Sync with head.
 1.78.2.1 27-May-2007  ad Sync with head.
 1.79.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.79.8.1 06-Nov-2007  matt sync with HEAD
 1.79.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.80.20.3 09-Oct-2010  yamt sync with head
 1.80.20.2 04-May-2009  yamt sync with head.
 1.80.20.1 16-May-2008  yamt sync with head.
 1.80.18.1 18-May-2008  yamt sync with head.
 1.80.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.80.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.81.20.1 14-May-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1902):
src/sys/compat/linux/common/linux_exec_elf32.c 1.91 via patch

A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.

Spotted by several developers, patch from chs@/enami@
 1.81.16.1 14-May-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1902):
src/sys/compat/linux/common/linux_exec_elf32.c 1.91 via patch

A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.

Spotted by several developers, patch from chs@/enami@
 1.81.10.1 14-May-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1902):
src/sys/compat/linux/common/linux_exec_elf32.c 1.91 via patch

A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.

Spotted by several developers, patch from chs@/enami@
 1.81.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.81.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.81.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.81.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.81.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.82.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.83.4.1 05-Mar-2011  rmind sync with head
 1.83.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.84.12.1 18-Feb-2012  mrg merge to -current.
 1.84.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.84.8.1 17-Apr-2012  yamt sync with head
 1.86.16.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1051):
sys/compat/linux/common/linux_exec_elf32.c: revision 1.91 via patch
A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.
Spotted by several developers, patch from chs@/enami@
 1.86.10.1 18-May-2014  rmind sync with head
 1.86.8.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1051):
sys/compat/linux/common/linux_exec_elf32.c: revision 1.91 via patch
A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.
Spotted by several developers, patch from chs@/enami@
 1.86.6.2 03-Dec-2017  jdolecek update from HEAD
 1.86.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.86.2.1 21-Apr-2014  bouyer Pull up following revision(s) (requested by maxv in ticket #1051):
sys/compat/linux/common/linux_exec_elf32.c: revision 1.91 via patch
A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.
Spotted by several developers, patch from chs@/enami@
 1.90.2.1 10-Aug-2014  tls Rebase.
 1.91.4.3 28-Aug-2017  skrll Sync with HEAD
 1.91.4.2 22-Sep-2015  skrll Sync with HEAD
 1.91.4.1 06-Apr-2015  skrll Sync with HEAD
 1.91.2.1 29-Mar-2015  martin Pull up following revision(s) (requested by maxv in ticket #650):
sys/compat/netbsd32/netbsd32_exec_elf32.c: revision 1.39
sys/kern/exec_elf.c: revision 1.71
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.18
sys/compat/linux/common/linux_exec_elf32.c: revision 1.92
sys/compat/svr4_32/svr4_32_exec_elf32.c: revision 1.24
Zero-fill the ELF auxiliary vectors. Otherwise, on 64bit systems, the
padding between a_v and a_type contains kernel garbage, therefore
exposed to userland.
Original report by uebayasi@
 1.93.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.93.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.94.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.94.14.1 10-Jun-2019  christos Sync with HEAD
 1.94.12.8 25-Jan-2019  pgoyette Move the netbsd32_machine32_hook into the main kernel with most of
the other hooks.

Although this hook might better belong in compat/netbsd32/ code,
there are some machines without a netbsd32 module (for example, i386
and sgimips) which still have consumers/users of this hook. :(
 1.94.12.7 24-Jan-2019  pgoyette Move the definition around to avoid strange compiler error (something
about trying to set a section attribute on a local variable).
 1.94.12.6 24-Jan-2019  pgoyette revert previous, just define the hook here
 1.94.12.5 24-Jan-2019  pgoyette And include the definition
 1.94.12.4 24-Jan-2019  pgoyette Make sure we declare the hook variable
 1.94.12.3 24-Jan-2019  pgoyette Rework placement of the new netbsd32_machine32_hook
 1.94.12.2 24-Jan-2019  pgoyette Replace weak symbol definition for machine32 with a hook. Our in-kernel
linker doesn't handle weak symbols, so this prevented us from loading the
compat_linux32 module.

XXX There don't seem to be any other consumers of machine32 (nor does
XXX there seem to be any consumers of machine_arch32), even though it
XXX is defined for aarch64, arm32, and riscv).
 1.94.12.1 28-Jul-2018  pgoyette Sync with HEAD
 1.99.6.1 17-Jan-2020  ad Sync with head.
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 13-Nov-2001  lukem branches: 1.2.114; 1.2.116; 1.2.118;
add RCSIDs (including regeneration of files as appropriate)
 1.1 01-Oct-1998  erh branches: 1.1.24; 1.1.26;
Split compat/linux/linux_exec.c into common, elf and a.out parts.
 1.1.26.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.24.1 14-Nov-2001  nathanw Catch up to -current.
 1.2.118.1 16-May-2008  yamt sync with head.
 1.2.116.1 18-May-2008  yamt sync with head.
 1.2.114.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.2 17-May-2014  njoly branches: 1.2.2;
Fix fadvise64 syscalls to use 64bit offset types.
 1.1 30-May-2011  alnsn branches: 1.1.2; 1.1.6; 1.1.18; 1.1.22; 1.1.32;
Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.1.32.1 10-Aug-2014  tls Rebase.
 1.1.22.1 18-May-2014  rmind sync with head
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.1 30-May-2011  jruoho file linux_fadvise64.c was added on branch jruoho-x86intr on 2011-06-06 09:07:27 +0000
 1.1.2.2 31-May-2011  rmind sync with head
 1.1.2.1 30-May-2011  rmind file linux_fadvise64.c was added on branch rmind-uvmplock on 2011-05-31 03:04:30 +0000
 1.2.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.3 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.2 06-May-2014  njoly branches: 1.2.2;
Fix c&p error for the length argument in fadvise64_64.
 1.1 30-May-2011  alnsn branches: 1.1.2; 1.1.6; 1.1.8; 1.1.18; 1.1.22; 1.1.32;
Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.1.32.1 10-Aug-2014  tls Rebase.
 1.1.22.1 18-May-2014  rmind sync with head
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.8.1 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.1.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.6.1 30-May-2011  jruoho file linux_fadvise64_64.c was added on branch jruoho-x86intr on 2011-06-06 09:07:27 +0000
 1.1.2.2 31-May-2011  rmind sync with head
 1.1.2.1 30-May-2011  rmind file linux_fadvise64_64.c was added on branch rmind-uvmplock on 2011-05-31 03:04:30 +0000
 1.2.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.23 28-Sep-2024  christos Linux GSoC-2024: renameat2, clone3, sync_file_range, syncfs (Shivraj Jamgade)
 1.22 19-Aug-2023  christos branches: 1.22.6;
new inotify support GSoC 2023 (Theodore Preduta)
 1.21 10-Jul-2023  christos Add memfd_create(2) from GSoC 2023 by Theodore Preduta
 1.20 25-Nov-2021  ryo - Add compat_linux statx(2) syscall.
- The AT_EMPTY_PATH processing from the modification of
sys/compat/linux/common/linux_file64.c r1.63 has been separated, and made
common to linux_statat(), so that it can be used not only by
linux32_sys_fstatat64() but also by other *statat() variants.
 1.19 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.18 23-Aug-2019  maxv When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.
 1.17 01-Mar-2015  njoly branches: 1.17.10; 1.17.18; 1.17.22;
Add Linux specific fcntl(2) commands. Support F_DUPFD_CLOEXEC.
 1.16 01-Jun-2014  njoly branches: 1.16.2; 1.16.4; 1.16.10;
Cleanup pipe(2) flags, now that native handle them.
 1.15 24-Sep-2013  njoly branches: 1.15.2;
Add utimensat(2) for compat linux.
 1.14 28-Apr-2008  martin branches: 1.14.34; 1.14.44; 1.14.50;
Remove clause 3 and 4 from TNF licenses
 1.13 21-Mar-2008  ad branches: 1.13.2; 1.13.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.12 02-Feb-2008  dsl branches: 1.12.6;
Fix the linux32 emulations of fcntl() locking.
The 64bit linux emulation versions can't be used because the lock structure
alignment and field sizes all differ.
Since there need to be 4 different versions of the linux struct flock, and
amd64 kernel needs 3 of them compiled in, rather than replicating the same
code block twice more, move the body of the code into a few #defines
that can be expanded with the correct types in the linux[32]_sys_fcntl[64]()
functions.
Should fix problems running progams like skype running under linux32
emulation on amd64.
 1.11 11-Dec-2005  christos branches: 1.11.46; 1.11.52;
merge ktrace-lwp.
 1.10 03-May-2005  manu branches: 1.10.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.9 22-Mar-2002  christos branches: 1.9.10;
implement the locking calls for linux_file64.
 1.8 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.7 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.6 19-Jan-2001  manu branches: 1.6.2; 1.6.4; 1.6.6;
Added Linux compatibility support for powerpc ports
 1.5 15-Dec-1998  itohy branches: 1.5.8;
Added linux compat support on m68k ports.
 1.4 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Split linux_fcntl.h into i386 and common parts.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.5.8.1 11-Feb-2001  bouyer Sync with HEAD.
 1.6.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.6.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.6.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.6.2.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.9.10.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.2 24-Mar-2008  yamt sync with head.
 1.10.2.1 04-Feb-2008  yamt sync with head.
 1.11.52.1 18-Feb-2008  mjf Sync with HEAD.
 1.11.46.1 23-Mar-2008  matt sync with HEAD
 1.12.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.50.1 18-May-2014  rmind sync with head
 1.14.44.2 03-Dec-2017  jdolecek update from HEAD
 1.14.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.34.1 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.15.2.1 10-Aug-2014  tls Rebase.
 1.16.10.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.16.4.1 06-Apr-2015  skrll Sync with HEAD
 1.16.2.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.17.22.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.17.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17.10.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.22.6.1 02-Aug-2025  perseant Sync with HEAD
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 12-Feb-2008  he branches: 1.3.2; 1.3.8; 1.3.10; 1.3.12; 1.3.14;
Need to include <sys/fstypes.h> before <sys/vfs_syscalls.h> to get
fhandle_t defined, which is used in a function prototype in the latter.
 1.2 02-Feb-2008  dsl branches: 1.2.2;
Fix the linux32 emulations of fcntl() locking.
The 64bit linux emulation versions can't be used because the lock structure
alignment and field sizes all differ.
Since there need to be 4 different versions of the linux struct flock, and
amd64 kernel needs 3 of them compiled in, rather than replicating the same
code block twice more, move the body of the code into a few #defines
that can be expanded with the correct types in the linux[32]_sys_fcntl[64]()
functions.
Should fix problems running progams like skype running under linux32
emulation on amd64.
 1.1 02-Feb-2008  dsl Extract the fcntl64() suppoort from linux_file64.c into linux_fcntl64.c
Unravel some of the knots that caused linux_file64.c to be compiled twice
for an amd64 kernel (once for linux and once for linux32) with different
parts being skipped each time.
 1.2.2.3 27-Feb-2008  yamt sync with head.
 1.2.2.2 04-Feb-2008  yamt sync with head.
 1.2.2.1 02-Feb-2008  yamt file linux_fcntl64.c was added on branch yamt-lazymbuf on 2008-02-04 09:23:04 +0000
 1.3.14.1 16-May-2008  yamt sync with head.
 1.3.12.1 18-May-2008  yamt sync with head.
 1.3.10.2 23-Mar-2008  matt sync with HEAD
 1.3.10.1 12-Feb-2008  matt file linux_fcntl64.c was added on branch matt-armv6 on 2008-03-23 02:04:32 +0000
 1.3.8.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.3.2.1 12-Feb-2008  mjf file linux_fcntl64.c was added on branch mjf-devfs on 2008-02-18 21:05:26 +0000
 1.14 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.13 21-Mar-2008  ad branches: 1.13.6; 1.13.84; 1.13.96;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.12 20-Dec-2007  dsl branches: 1.12.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.11 19-Oct-2007  njoly branches: 1.11.4; 1.11.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.10 04-Mar-2007  christos branches: 1.10.14; 1.10.16; 1.10.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 09-Feb-2007  ad branches: 1.9.2;
Merge newlock2 to head.
 1.8 11-Dec-2005  christos branches: 1.8.20;
merge ktrace-lwp.
 1.7 29-Jun-2003  fvdl branches: 1.7.2; 1.7.18;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.6 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.5 21-Mar-2003  dsl Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
 1.4 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.3 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.2 14-Jun-2001  thorpej branches: 1.2.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.1 10-Dec-2000  fvdl branches: 1.1.2; 1.1.4; 1.1.6;
Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.1.6.2 30-Mar-2001  he Pull up revision 1.1 (new, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.1.6.1 10-Dec-2000  he file linux_fdio.c was added on branch netbsd-1-5 on 2001-03-30 21:39:58 +0000
 1.1.4.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.1 10-Dec-2000  bouyer file linux_fdio.c was added on branch thorpej_scsipi on 2000-12-13 15:49:49 +0000
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.18.6 24-Mar-2008  yamt sync with head.
 1.7.18.5 21-Jan-2008  yamt sync with head
 1.7.18.4 27-Oct-2007  yamt sync with head.
 1.7.18.3 03-Sep-2007  yamt sync with head.
 1.7.18.2 26-Feb-2007  yamt sync with head.
 1.7.18.1 21-Jun-2006  yamt sync with head.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.8.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.9.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.16.2 09-Jan-2008  matt sync with HEAD
 1.10.16.1 06-Nov-2007  matt sync with HEAD
 1.10.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.4.1 26-Dec-2007  ad Sync with head.
 1.12.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.96.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.13.84.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.13.6.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.13.6.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.4 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 11-Dec-2005  christos branches: 1.3.26;
merge ktrace-lwp.
 1.2 26-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 10-Dec-2000  fvdl branches: 1.1.2; 1.1.6; 1.1.28; 1.1.36; 1.1.38;
Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.1.38.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.36.1 29-Apr-2005  kent sync with -current
 1.1.28.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.6.2 30-Mar-2001  he Pull up revision 1.1 (new, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.1.6.1 10-Dec-2000  he file linux_fdio.h was added on branch netbsd-1-5 on 2001-03-30 21:39:59 +0000
 1.1.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.1 10-Dec-2000  bouyer file linux_fdio.h was added on branch thorpej_scsipi on 2000-12-13 15:49:49 +0000
 1.2.4.1 03-Sep-2007  yamt sync with head.
 1.3.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.133 01-Oct-2024  riastradh linux_sys_copy_file_range: Nix unused variable new_size.
 1.132 01-Oct-2024  riastradh linux_sys_copy_file_range: Avoid more UB arithmetic overflow.

Need to check the input offset too, not just the output offset.

No functional change in the non-UB case.
 1.131 01-Oct-2024  riastradh linux_sys_copy_file_range: Avoid UB arithmetic overflow.

No functional change intended in the non-UB case.
 1.130 01-Oct-2024  riastradh sys/compat/linux/common/linux_file.c: KNF

No functional change intended.
 1.129 01-Oct-2024  riastradh linux_sys_copy_file_range: Prune dead branch.

kmem_alloc(KM_SLEEP) can't fail.

No functional change intended.
 1.128 01-Oct-2024  riastradh sys/compat/linux/common/linux_file.c: Fix blank lines and comments.

No functional change intended.
 1.127 01-Oct-2024  riastradh sys/compat/linux/common/linux_file.c: KNF in function heads.

No functional change intended.
 1.126 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.125 28-Sep-2024  christos Linux GSoC-2024: renameat2, clone3, sync_file_range, syncfs (Shivraj Jamgade)
 1.124 29-Jun-2024  christos branches: 1.124.2;
From gsoc 2024: Implement faccessat2 and getcpu (Shivraz)
 1.123 10-Jul-2023  christos Add memfd_create(2) from GSoC 2023 by Theodore Preduta
 1.122 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.121 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.120 20-Sep-2021  thorpej Add preadv(2) and pwritev(2) system calls to COMPAT_LINUX and COMPAT_LINUX32.
 1.119 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.118 23-May-2020  ad branches: 1.118.2;
Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.117 09-Nov-2019  jdolecek add dummy implementation of linux fallocate() which just returns EOPNOTSUPP;
this is needed so that glibc falls back to emulation and apps behaving
properly, since EOPNOTSUPP is a documented and expected return code, but
ENOSYS is not

right now there are no filesystems in NetBSD tree supporting the fallocate
VOP, so no point trying to map this to a native call

supposed to help with problem reported in
https://mail-index.netbsd.org/tech-kern/2019/11/03/msg025641.html
 1.116 18-Jun-2019  kamil branches: 1.116.2;
Drop unused retval pointer from do_sys_mknod{,at}()

No functional change intended.
 1.115 01-Mar-2015  njoly branches: 1.115.10; 1.115.18;
Add Linux specific fcntl(2) commands. Support F_DUPFD_CLOEXEC.
 1.114 09-Nov-2014  maxv branches: 1.114.2;
Do not uselessly include <sys/malloc.h>.
 1.113 25-Jun-2014  njoly branches: 1.113.2;
Add support for more open flags that have a native equivalent
(O_NONBLOCK, O_DIRECT and O_NOFOLLOW).
Translate native EFTYPE error (missing on Linux) to expected ELOOP;
when opening symlinks with flag O_NOFOLLOW.
 1.112 01-Jun-2014  njoly Cleanup pipe(2) flags, now that native handle them.
 1.111 18-May-2014  njoly Simplify dup3 emulation to call dodup() directly instead of
sys_dup2()+fd_set_exclose(). While here, add some error conditions.
 1.110 06-May-2014  njoly linux_off_t -> off_t in pwrite() syscall args comment.
 1.109 04-May-2014  njoly Fix pread/pwrite syscalls which need a 64bit offset argument.
 1.108 08-Dec-2013  njoly branches: 1.108.2;
Sprinkle a few more linux_umode_t where appropriate.
Reduce diffs between archs.
 1.107 08-Dec-2013  njoly Add missing syscall argument fd in comment.
 1.106 18-Nov-2013  chs implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.105 24-Sep-2013  njoly Add utimensat(2) for compat linux.
 1.104 14-Oct-2011  hannken branches: 1.104.2; 1.104.12; 1.104.16;
Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock. Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
 1.103 14-Apr-2011  christos move dup3 to a more appropriate place because pipe is "special". Gotta love
linux.
 1.102 10-Apr-2011  christos We have O_CLOEXEC now
 1.101 19-Nov-2010  dholland branches: 1.101.2;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.100 21-Sep-2010  chs implement O_DIRECTORY as standardized in POSIX-2008,
for both native and linux emulations.
this fixes the rest of PR 43695.
 1.99 01-Jul-2010  rmind Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
 1.98 09-Aug-2009  haad branches: 1.98.2; 1.98.4;
Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions
can be called from kernel, too.

Change needed for zfs device node creation, until we have propoer devfs.

Oked by ad@.
 1.97 11-Jan-2009  christos merge christos-time_t
 1.96 28-Apr-2008  martin branches: 1.96.2; 1.96.8;
Remove clause 3 and 4 from TNF licenses
 1.95 24-Apr-2008  ad branches: 1.95.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.94 23-Apr-2008  ad - Use cdev_tty().
- Tweak locking.
 1.93 21-Mar-2008  ad branches: 1.93.2; 1.93.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.92 02-Feb-2008  dsl branches: 1.92.6;
Fix the linux32 emulations of fcntl() locking.
The 64bit linux emulation versions can't be used because the lock structure
alignment and field sizes all differ.
Since there need to be 4 different versions of the linux struct flock, and
amd64 kernel needs 3 of them compiled in, rather than replicating the same
code block twice more, move the body of the code into a few #defines
that can be expanded with the correct types in the linux[32]_sys_fcntl[64]()
functions.
Should fix problems running progams like skype running under linux32
emulation on amd64.
 1.91 15-Jan-2008  njoly compat linux (and linux32) uid16 functions cleanup and fixes.

- Move uid16 functions to their own file linux_uid16.c, included by
needed archs (arm, i386 and m68k).
- Add new MI types linux_{u,g}id16_t.
- Add macros to handle linux_uid16_t and uid_t conversions.
- Add linux_sys_getres{uid,gid}16 syscalls, to fix an overflow with
bad sizes given to copyout when linux_sys_getres{uid,gid} are used.
- Update arm syscall table to use more uid16 functions.
 1.90 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.89 08-Dec-2007  pooka branches: 1.89.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.88 08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.87 04-Dec-2007  dsl Remove all the __P
 1.86 26-Nov-2007  pooka branches: 1.86.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.85 16-Nov-2007  njoly Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.
 1.84 19-Oct-2007  njoly branches: 1.84.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.83 12-May-2007  dsl branches: 1.83.6; 1.83.8; 1.83.12;
Split the fcntl locking code out from its copyin/out.
Use to avoid all the stackgap stuff in compat code.
 1.82 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.81 10-Mar-2007  dsl branches: 1.81.2;
Update all the compat stuff to not use the 'stackgap' for processing
sys_stat() and friends, instead use do_sys_stat() and do_sys_fstat()
that write the answer into a kernel buffer (on stack) that can be
converted to the correct form and written the userspace.
I've test compiled a few kernels, and tested i386 netbsd1.6 ls.
Given I think I've fixed some bugs, it might be 50-50 with new ones.
 1.80 09-Mar-2007  ad branches: 1.80.2;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.
 1.79 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.78 17-Feb-2007  dsl Acquire proclist_lock across the calls to p_find() and pg_find().
 1.77 09-Feb-2007  ad branches: 1.77.2;
Merge newlock2 to head.
 1.76 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.75 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.74 25-Sep-2006  pavel Replace homegrown tests for FIFO (... & S_IFIFO) by S_ISFIFO. The old code
was "correct" by luck - we don't have any other file type whose S_IF* bits
in sys/stat.h overlap with S_IFIFO.

Originally discovered by Paul Stoeber in OpenBSD.
 1.73 23-Jul-2006  ad branches: 1.73.4; 1.73.6;
Use the LWP cached credentials where sane.
 1.72 14-May-2006  elad integrate kauth.
 1.71 11-Dec-2005  christos branches: 1.71.4; 1.71.6; 1.71.8; 1.71.10; 1.71.12;
merge ktrace-lwp.
 1.70 19-Aug-2005  christos 64 bit inode changes.
 1.69 29-May-2005  christos branches: 1.69.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.68 16-May-2005  fvdl Add *xattr functions (they all return EOPNOTSUPP).
 1.67 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.66 10-Mar-2005  christos Add nanosecond handling on the stat and stat64 code for the i386.
 1.65 26-Feb-2005  perry nuke trailing whitespace
 1.64 12-Dec-2004  abs branches: 1.64.2; 1.64.4;
Fix comments slighly
 1.63 13-Aug-2004  jdolecek on Linux, unlink() fails with EISDIR if the target is directory,
rather than EPERM; to emulate this properly, translate the error to EISDIR
if the target patch exists and points to a directory

this fixes the 'ant clean' problem reported by Marc Recht on current-users@
with SuSE 9.1 libraries
 1.62 09-Aug-2003  jdolecek branches: 1.62.2;
fix linux_sys_p{read|write}() to actually call correct syscall after
arg massage, i.e. sys_p{read|write} as appropriate; up to now, the functions
called sys_{read|write}() by mistake
 1.61 29-Jun-2003  fvdl branches: 1.61.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.60 29-Jun-2003  jdolecek properly FILE_USE/FILE_UNUSE descriptor in linux_sys_fcntl()
adresses PR kern/21628 by Wolfgang Solfrank
 1.59 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.58 19-Mar-2003  dsl Alternative pid/proc allocater, removes all searches associated with pid
lookup and allocation, and any dependency on NPROC or MAXUSERS.
NO_PID changed to -1 (and renamed NO_PGID) to remove artificial limit
on PID_MAX.
As discussed on tech-kern.
 1.57 27-Feb-2003  yamt make compat_linux struct file interlock friendly.
 1.56 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.55 17-Dec-2002  simonb Use the already-filled-in-but-not-used native syscall args in
linux_sys_mknod().
 1.54 11-Dec-2002  jdolecek linux_sys_mknod(): if creating device file (i.e. !fifo case), mask
the passed device number to only contain lower 16 bits; older glibc
appears to pass some junk in upper bits sometimes, resulting in incorrect
device entries being created

Problem initially analyzed by Thor Lancelot Simon.
 1.53 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.52 13-May-2002  simonb branches: 1.52.2; 1.52.4;
Remove an unreachable "break" after a return statement.
 1.51 10-Apr-2002  christos implement getdents64; my full java tree builds now.
 1.50 24-Mar-2002  jdolecek add explicit comment a FILE_USE() is not needed here
 1.49 24-Mar-2002  jdolecek Fix problem with assumption non-socket == vnode in F_{G,S}ETOWN different way
(revisions 1.47 & 1.48 effectively backed off):
* for all but vnodes, just fallback to sys_fcntl(); assumming
state of support for F_SETOWN/F_GETOWN and even hardcoding it here is
not right (e.g. rev. 1.47 had this incorrect for DTYPE_PIPE)
* fallback to sys_fcntl() also for vnodes which don't represent tty
* don't need to use FILE_{,UN}USE() here, the code won't block while
using the pointer
* add/fix some comments
 1.48 23-Mar-2002  christos correct placement for FILE_UNUSE [from Izumi Tsutsui]
 1.47 22-Mar-2002  christos - obey FILE_USE and FILE_UNUSE
- don't assume that non sockets point to vnodes.
 1.46 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.45 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.44 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.43 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.42 22-Sep-2001  manu Fixes for mips support
 1.41 04-Sep-2001  jdolecek branches: 1.41.2;
change LINUX_F_SETFL so that SIGIO handling for sockets
matches more closely
add support for NEW_PIPE to the SIGIO hack
 1.40 22-Jul-2001  wiz seperate -> separate
 1.39 16-Jun-2001  manu branches: 1.39.2;
Linux does not send a SIGIO to the write end of a socket,
neither it does send any SIGIO for pipes. If async I/O
was requested, we keep the SS_ASYNC in struct socket flag
set, but we clear SB_ASYNC flags on the sending buffer
(for socket), and on the sending and the receiving buffer
(for pipes).

Because we do not alter to SS_ASYNC in struct socket,
the Linux process keeps a consistent view of async I/O
status if it attemps to read the async flag (SS_ASYNC)

This async I/O problem does matters, since some Linux
a programs such as the JDK request async I/O on pipes,
but they fail if they happen to get a SIGIO to the write
end of the pipe.
 1.38 14-Jun-2001  thorpej Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.37 22-Jan-2001  jdolecek branches: 1.37.2;
use CHECK_ALT_SYMLINK() for lstat(2)
don't call stackgap_init() for pwrite(2) and pread(2), it's not necessary
 1.36 22-Jan-2001  jdolecek Use CHECK_ALT_SYMLINK() instead CHECK_ALT_EXISTS() where appropriate.
This addresses kern/11757.
 1.35 19-Jan-2001  manu Added support for powerpc Linux compatibility
 1.34 29-Dec-2000  fvdl Do alternate path checks for link(2).
 1.33 27-Dec-2000  fvdl Use CHECK_ALT_* for chown and lchown, missed in my previous commit.
Get *id16 calls right; most can be passed through directly, but
some need the 16->32 check for -1 values.
 1.32 21-Dec-2000  thorpej Only include the 16-bit chown/fchown/lchown stuff if on i386 or m68k.
This is a little ugly, but hey, so is Linux.
 1.31 18-Dec-2000  fvdl Add seperate entries for 16 bit uid/gid calls, so that border cases
like 0xffff can be handled better (not done yet).
 1.30 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.29 29-Aug-2000  sommerfeld Emulation stackgap sanity checks, based partly on fixes from
FreeBSD-SA00:42.

Change stackgap_alloc to bounds-check the allocation vs. the stack
gap, returning NULL if there isn't room for the allocation.

Change emul_find() to check for a NULL return from stackgap_alloc()
and convert that into ENAMETOOLONG.

Reorder various emulation syscalls so that all *_CHECK_ALT_{EXIST,CREAT}
calls (which turn into emul_find() under the covers come *after* small,
fixed-size stackgap_alloc() calls.

Clean up ibcs2 {get,set}groups.
 1.28 05-Dec-1999  tron branches: 1.28.4;
Add proper stub code to make emulation of Linux's pread(2) and pwrite(2)
work. Fixes PR kern/8945 by Dave Sainty.
 1.27 09-Feb-1999  christos branches: 1.27.2; 1.27.8; 1.27.14;
const poisoning.
 1.26 07-Oct-1998  erh The siginfo include line is not needed here anymore.
 1.25 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.24 03-Oct-1998  christos Attempt to fix the mess.
 1.23 01-Oct-1998  erh Split compat/linux/linux_file.c into common and multi-architechture parts.
 1.22 14-Feb-1998  kleink * Use sys___posix_{chown,fchown}() instead of sys_{chown,fchown}().
* Change reference from sys_posix_rename() to sys___posix_rename().
 1.21 20-Oct-1997  thorpej Fix the shared library versioning snafu caused by the recent changes
to the stat(2) family and msync(2). This uses a primitive function
versioning scheme.

This reverts the libc shared library major version from 13 to 12, and
adds a few new interfaces to bring us to libc version 12.20.

From Frank van der Linden <fvdl@NetBSD.ORG>.
 1.20 19-Oct-1997  mycroft Fix bogosity in mknod(2) translation.
 1.19 16-Oct-1997  christos check for st_nlink overflow
 1.18 05-Sep-1997  kleink Add missing preparation of F_GETLK parameters in linux_sys_fcntl(); fixes PR
port-i386/4083 from Matthias Scheler <tron@lyssa.owl.de>, but vastly cleaned
up as previously suggested by myself.
 1.17 27-Jun-1997  kleink branches: 1.17.4;
Use sys_posix_rename() instead of sys_rename() as it's the behaviour of the
native implementation.
 1.16 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.15 20-May-1996  fvdl Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.14 05-Apr-1996  christos Prototyping changes.
 1.13 08-Oct-1995  fvdl Work around calling the NetBSD fcntl(F_{G,S}ETOWN) for now; it is too
restrictive to implement the Linux equivalent (and perhaps too restrictive
overall).
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.9 27-Aug-1995  fvdl Add a hook for MD ioctl calls, plus a couple of more changes to make
svgalib binaries work on the i386
 1.8 14-Aug-1995  mycroft Rearrange #includes.
 1.7 24-Jul-1995  fvdl mkdir() has 2 arguments.. fixes PR 1248 (from Brad Spencer)
 1.6 03-Jul-1995  fvdl Fix totally bogus implementation of a few fcntl() calls. I think I'll go
live on a deserted island now..
 1.5 24-Jun-1995  christos Use compat_util.[ch].
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 04-Apr-1995  mycroft Fix conversion of `type' and `whence' values in struct flock.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.17.4.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.27.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.27.8.4 11-Feb-2001  bouyer Sync with HEAD.
 1.27.8.3 05-Jan-2001  bouyer Sync with HEAD
 1.27.8.2 08-Dec-2000  bouyer Sync with HEAD.
 1.27.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.27.2.1 09-Sep-2000  he Pull up revision 1.29 (requested by simonb):
More carefully check length of user-supplied data, in particular
make sure we don't overrun the available stack gap in stack gap
allocations.
 1.28.4.2 30-Mar-2001  he Pull up revision 1.34 (via patch, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.28.4.1 30-Aug-2000  sommerfeld Pull up:
syssrc/sys/compat/common/compat_util.c 1.16
syssrc/sys/compat/hpux/hpux_file.c 1.14
syssrc/sys/compat/ibcs2/ibcs2_misc.c 1.52
syssrc/sys/compat/ibcs2/ibcs2_stat.c 1.16
syssrc/sys/compat/linux/common/linux_file.c 1.29
syssrc/sys/compat/linux/common/linux_misc_notalpha.c 1.58
syssrc/sys/compat/svr4/svr4_stat.c 1.40
syssrc/sys/compat/svr4/svr4_stream.c 1.40,1.41

Approved by thorpej and jhawk.

Emulation stackgap sanity checks, based partly on fixes from
FreeBSD-SA00:42.

Change stackgap_alloc to bounds-check the allocation vs. the stack
gap, returning NULL if there isn't room for the allocation.

Change emul_find() to check for a NULL return from stackgap_alloc()
and convert that into ENAMETOOLONG.

Reorder various emulation syscalls so that all *_CHECK_ALT_{EXIST,CREAT}
calls (which turn into emul_find() under the covers come *after* small,
fixed-size stackgap_alloc() calls.

Clean up ibcs2 {get,set}groups.

Add range checks to svr4_stream.c
 1.37.2.14 20-Dec-2002  nathanw LWPify new mkfifo code.
 1.37.2.13 19-Dec-2002  thorpej Sync with HEAD.
 1.37.2.12 17-Sep-2002  nathanw Catch up to -current.
 1.37.2.11 20-Jun-2002  nathanw Catch up to -current.
 1.37.2.10 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.37.2.9 17-Apr-2002  nathanw Catch up to -current.
 1.37.2.8 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.37.2.7 28-Feb-2002  nathanw Catch up to -current.
 1.37.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.37.2.5 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.37.2.4 21-Sep-2001  nathanw Catch up to -current.
 1.37.2.3 24-Aug-2001  nathanw Catch up with -current.
 1.37.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.37.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.39.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.39.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.39.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.39.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.39.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.39.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.39.2.1 03-Aug-2001  lukem update to -current
 1.41.2.2 01-Oct-2001  fvdl Catch up with -current.
 1.41.2.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.52.4.1 01-May-2005  tron Pull up revision 1.62 via patch (requested by bad in ticket #5762):
fix linux_sys_p{read|write}() to actually call correct syscall after
arg massage, i.e. sys_p{read|write} as appropriate; up to now, the functions
called sys_{read|write}() by mistake
 1.52.2.1 16-May-2002  gehenna Replace the direct-access to devsw table with calling devsw API.
 1.61.2.9 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.61.2.8 01-Apr-2005  skrll Sync with HEAD.
 1.61.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.61.2.6 18-Dec-2004  skrll Sync with HEAD.
 1.61.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.61.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.61.2.3 25-Aug-2004  skrll Sync with HEAD.
 1.61.2.2 03-Aug-2004  skrll Sync with HEAD
 1.61.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.62.2.1 15-Aug-2004  tron Pull up revision 1.63 (requested by jdolecek in ticket #764):
on Linux, unlink() fails with EISDIR if the target is directory,
rather than EPERM; to emulate this properly, translate the error to EISDIR
if the target patch exists and points to a directory
this fixes the 'ant clean' problem reported by Marc Recht on current-users@
with SuSE 9.1 libraries
 1.64.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.64.2.1 29-Apr-2005  kent sync with -current
 1.69.2.9 24-Mar-2008  yamt sync with head.
 1.69.2.8 04-Feb-2008  yamt sync with head.
 1.69.2.7 21-Jan-2008  yamt sync with head
 1.69.2.6 07-Dec-2007  yamt sync with head
 1.69.2.5 27-Oct-2007  yamt sync with head.
 1.69.2.4 03-Sep-2007  yamt sync with head.
 1.69.2.3 26-Feb-2007  yamt sync with head.
 1.69.2.2 30-Dec-2006  yamt sync with head.
 1.69.2.1 21-Jun-2006  yamt sync with head.
 1.71.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.71.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.71.8.2 11-Aug-2006  yamt sync with head
 1.71.8.1 24-May-2006  yamt sync with head.
 1.71.6.1 01-Jun-2006  kardel Sync with head.
 1.71.4.1 09-Sep-2006  rpaulo sync with head
 1.73.6.2 10-Dec-2006  yamt sync with head.
 1.73.6.1 22-Oct-2006  yamt sync with head
 1.73.4.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.73.4.2 18-Nov-2006  ad Sync with head.
 1.73.4.1 17-Nov-2006  ad Checkpoint work in progress.
 1.77.2.4 17-May-2007  yamt sync with head.
 1.77.2.3 07-May-2007  yamt sync with head.
 1.77.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.77.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.80.2.2 27-May-2007  ad Sync with head.
 1.80.2.1 13-Mar-2007  ad Sync with head.
 1.81.2.1 11-Jul-2007  mjf Sync with head.
 1.83.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.83.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.83.8.3 23-Mar-2008  matt sync with HEAD
 1.83.8.2 09-Jan-2008  matt sync with HEAD
 1.83.8.1 06-Nov-2007  matt sync with HEAD
 1.83.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.83.6.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.83.6.2 21-Nov-2007  joerg Sync with HEAD.
 1.83.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.84.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.84.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.84.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.84.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.86.2.2 26-Dec-2007  ad Sync with head.
 1.86.2.1 08-Dec-2007  ad Sync with head.
 1.89.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.89.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.92.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.92.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.92.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.93.4.1 18-May-2008  yamt sync with head.
 1.93.2.2 01-Nov-2008  christos Sync with head.
 1.93.2.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.95.2.5 09-Oct-2010  yamt sync with head
 1.95.2.4 11-Aug-2010  yamt sync with head.
 1.95.2.3 19-Aug-2009  yamt sync with head.
 1.95.2.2 04-May-2009  yamt sync with head.
 1.95.2.1 16-May-2008  yamt sync with head.
 1.96.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.96.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.96.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.98.4.3 21-Apr-2011  rmind sync with head
 1.98.4.2 05-Mar-2011  rmind sync with head
 1.98.4.1 03-Jul-2010  rmind sync with head
 1.98.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.98.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.101.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.104.16.1 18-May-2014  rmind sync with head
 1.104.12.2 03-Dec-2017  jdolecek update from HEAD
 1.104.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.104.2.1 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.108.2.1 10-Aug-2014  tls Rebase.
 1.113.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.114.2.1 06-Apr-2015  skrll Sync with HEAD
 1.115.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.115.10.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.116.2.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.118.2.1 17-Dec-2020  thorpej Add suppport for Linux preadv(2) and pwritev(2). Same as native, except
for the silly way that the offset argument is passed in.
 1.124.2.1 02-Aug-2025  perseant Sync with HEAD
 1.68 29-Jul-2023  christos Add/fix statx, readahead, close_range. From GSoC 2023 by Theodore Preduta
 1.67 25-Nov-2021  ryo - Add compat_linux statx(2) syscall.
- The AT_EMPTY_PATH processing from the modification of
sys/compat/linux/common/linux_file64.c r1.63 has been separated, and made
common to linux_statat(), so that it can be used not only by
linux32_sys_fstatat64() but also by other *statat() variants.
 1.66 25-Nov-2021  ryo rename bsd_to_linux_stat() to bsd_to_linux_stat64() to avoid confusion.
There is a static function with the same name in linux/common/linux_file.c.

NFC.
 1.65 25-Nov-2021  ryo rename bsd_to_linux_stat() to bsd_to_linux_stat64() to avoid confusion.
There is a static function with the same name in linux/common/linux_file.c.

NFC.
 1.64 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.63 21-Sep-2021  rin linux_sys_fstatat64: Add support for AT_EMPTY_PATH flag.

This is required for rtld shipped with glibc 2.33.

Now, userland of Fedora 34 is working fine on NetBSD/amd64.
 1.62 23-Aug-2019  maxv Fix info leaks.
 1.61 23-Aug-2019  maxv Fix info leak.
 1.60 03-Sep-2018  riastradh branches: 1.60.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.59 28-Jul-2017  riastradh branches: 1.59.2; 1.59.4;
Fail, don't panic, on bad dirents from file system.

Controllable via puffs from userland.

From Ilja Van Sprundel.
 1.58 28-Jan-2017  christos branches: 1.58.6;
copy the terminating NUL (njoly)
 1.57 13-Jan-2017  christos branches: 1.57.2;
fix typo
 1.56 13-Jan-2017  christos convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
 1.55 27-Dec-2013  njoly branches: 1.55.4; 1.55.6; 1.55.8; 1.55.10; 1.55.14;
Add struct linux_stat64 definition for alpha, and enable syscalls that
use it.
 1.54 18-Nov-2013  chs implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.53 14-Oct-2011  hannken branches: 1.53.2; 1.53.8; 1.53.12; 1.53.14; 1.53.16; 1.53.22;
Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock. Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
 1.52 01-Sep-2011  njoly Make linux_sys_getdents64 fails with ENOTDIR instead of EINVAL, when fd
does not refer to a directory.
 1.51 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.50 03-Mar-2010  he branches: 1.50.2;
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.

This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.

Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.49 15-May-2009  pooka branches: 1.49.2;
pad -> PAD
 1.48 24-Jun-2008  ad branches: 1.48.6; 1.48.10; 1.48.14;
Replace references to getsock/getvnode.
 1.47 28-Apr-2008  martin branches: 1.47.2; 1.47.4;
Remove clause 3 and 4 from TNF licenses
 1.46 21-Mar-2008  ad branches: 1.46.2; 1.46.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.45 02-Feb-2008  dsl branches: 1.45.6;
Extract the fcntl64() suppoort from linux_file64.c into linux_fcntl64.c
Unravel some of the knots that caused linux_file64.c to be compiled twice
for an amd64 kernel (once for linux and once for linux32) with different
parts being skipped each time.
 1.44 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.43 08-Dec-2007  dsl branches: 1.43.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.42 04-Dec-2007  dsl Remove all the __P
 1.41 26-Nov-2007  pooka branches: 1.41.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.40 19-Oct-2007  njoly branches: 1.40.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.39 12-May-2007  dsl branches: 1.39.6; 1.39.8; 1.39.12;
Split the fcntl locking code out from its copyin/out.
Use to avoid all the stackgap stuff in compat code.
 1.38 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.37 10-Mar-2007  dsl branches: 1.37.2;
Update all the compat stuff to not use the 'stackgap' for processing
sys_stat() and friends, instead use do_sys_stat() and do_sys_fstat()
that write the answer into a kernel buffer (on stack) that can be
converted to the correct form and written the userspace.
I've test compiled a few kernels, and tested i386 netbsd1.6 ls.
Given I think I've fixed some bugs, it might be 50-50 with new ones.
 1.36 04-Mar-2007  christos branches: 1.36.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 09-Feb-2007  ad branches: 1.35.2;
Merge newlock2 to head.
 1.34 23-Jul-2006  ad branches: 1.34.4; 1.34.8;
Use the LWP cached credentials where sane.
 1.33 14-May-2006  elad integrate kauth.
 1.32 01-Mar-2006  yamt branches: 1.32.2; 1.32.4; 1.32.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.31 09-Feb-2006  manu Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.30 11-Dec-2005  christos branches: 1.30.2; 1.30.4; 1.30.6;
merge ktrace-lwp.
 1.29 19-Aug-2005  christos 64 bit inode changes.
 1.28 29-May-2005  christos branches: 1.28.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.27 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.26 19-Apr-2005  christos PR/29696: Joel Carnat: NetBSD freezes when accessing smbfs mounted FS with
firefox/linux due to compat getdents() call assumption that all filesystems
support cookies.
 1.25 10-Mar-2005  christos branches: 1.25.2;
Add nanosecond handling on the stat and stat64 code for the i386.
 1.24 26-Feb-2005  perry nuke trailing whitespace
 1.23 17-Sep-2004  skrll branches: 1.23.4; 1.23.6;
There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.22 10-Aug-2003  jdolecek add Linux compat arg wrapper for ftruncate64(), and change linux compat
truncate64() wrapper to translate args structure
NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
to do the argument translation

Problem found and patch supplied in PR kern/22360 by Ales Krenek

This is the last of syscalls with hidden 'pad' arg we didn't have
wrapper for; all the others (lseek, mmap, pwrite, pread) already had
wrapper before.
 1.21 29-Jun-2003  fvdl branches: 1.21.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.20 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.19 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.18 20-May-2002  jdolecek branches: 1.18.2;
linux_sys_getdents64(): remove the oldcall bug workaround cruft,
it's not needed for this call, and update comment accordingly
 1.17 20-May-2002  jdolecek linux_sys_getdents64(): make the d_off member point to next entry, rather
than current one; this is expected (even documented) behaviour of the
new system call
This fixes the endless loop when reading directories on NFS, though
applications won't see all directory entries due to different problem.
Fix by Matthias Scheler and Charles Hannum.
 1.16 19-May-2002  jdolecek On archs with broken linux struct stat64 st_ino, rename linux_stat64's
lst_ino to __lst_ino and lst_ino64 to lst_ino, and define
LINUX_STAT64_HAS_BROKEN_ST_INO. Only assign __lst_ino if this define
is present.

This fixes compile on powerpc archs, and hence port-powerpc/16893.
 1.15 13-May-2002  matt branches: 1.15.2;
Make COMPAT_LINUX compile again on Alpha. linux_getdents64 moved but
files.linux_alpha wasn't updated. common/linux_file64.c contains a lot
of syscalls which aren't on Linux/alpha so #ifdef them for alpha.
 1.14 13-May-2002  simonb Remove an unreachable "return error;".
 1.13 12-May-2002  jdolecek hook in remaining 64bit fs syscalls
make most of stuff in linux_file64.c available unconditionally,
with exception of fcntl64, which is not present on Linux m68k
 1.12 10-May-2002  tron Remove check for size of field "d_off" in Linux "dirent" structure because
this problem cannot happen with the 64Bit version of the getdents().
 1.11 10-May-2002  tron Move implementation of linux_sys_getdents64() to source file for
Linux 64bit filesystem calls.
 1.10 22-Mar-2002  christos gc debugging printfs.
 1.9 22-Mar-2002  christos implement the locking calls for linux_file64.
 1.8 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.7 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.6 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.5 14-Oct-2001  manu Fixed a minor problem so that it builds
 1.4 30-Sep-2001  manu Fixes my last commit: only mips really need fcntl64 to work now. i386 and
powerpc could use it later if needed. m68k and alpha should never need it.
 1.3 30-Sep-2001  manu Added initial support for fcntl64 system call (file locking is not
implemented)
 1.2 12-Dec-2000  jdolecek branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
add linux_sys_truncate64()
 1.1 12-Dec-2000  jdolecek add emulation of Linux truncate64(2), ftruncate64(2), *stat64(2)
 1.2.8.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.2.8.1 01-Oct-2001  fvdl Catch up with -current.
 1.2.6.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.10 20-Jun-2002  nathanw Catch up to -current.
 1.2.4.9 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.4.8 01-Apr-2002  nathanw Re-LWPify linux_sys_fcntl64().
 1.2.4.7 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.4.6 28-Feb-2002  nathanw Catch up to -current.
 1.2.4.5 06-Dec-2001  wdk struct proc -> struct lwp changes for COMPAT_LINUX support on Mips
processors.
 1.2.4.4 14-Nov-2001  nathanw Catch up to -current.
 1.2.4.3 22-Oct-2001  nathanw Catch up to -current.
 1.2.4.2 08-Oct-2001  nathanw Catch up to -current.
 1.2.4.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.2.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.2.2.1 12-Dec-2000  bouyer file linux_file64.c was added on branch thorpej_scsipi on 2000-12-13 15:49:49 +0000
 1.15.2.1 30-May-2002  gehenna Catch up with -current.
 1.18.2.2 14-Jun-2004  jmc Pullup patch (requested by skrll in ticket #1708)

Bring netbsd-1-6 inline with -current sources after the mistakes in ticket #1686
 1.18.2.1 11-May-2004  tron Pull up revision 1.22 via patch (requested by wennmach in ticket #1686):
add Linux compat arg wrapper for ftruncate64(), and change linux compat
truncate64() wrapper to translate args structure
NetBSD truncate() and ftrucate() have hidden 'pad' argument, so we have
to do the argument translation
Problem found and patch supplied in PR kern/22360 by Ales Krenek
This is the last of syscalls with hidden 'pad' arg we didn't have
wrapper for; all the others (lseek, mmap, pwrite, pread) already had
wrapper before.
 1.21.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.21.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.2 03-Aug-2004  skrll Sync with HEAD
 1.21.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.23.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.4.1 29-Apr-2005  kent sync with -current
 1.25.2.1 01-Oct-2005  tron Pull up following revision(s) (requested by christos in ticket #838):
sys/compat/svr4/svr4_misc.c: revision 1.112
sys/compat/ibcs2/ibcs2_misc.c: revision 1.74
sys/compat/linux/common/linux_misc.c: revision 1.136
sys/compat/irix/irix_dirent.c: revision 1.14
sys/compat/sunos/sunos_misc.c: revision 1.132
sys/compat/svr4_32/svr4_32_misc.c: revision 1.31
sys/compat/sunos32/sunos32_misc.c: revision 1.30
sys/compat/linux/common/linux_file64.c: revision 1.26
PR/29696: Joel Carnat: NetBSD freezes when accessing smbfs mounted FS with
firefox/linux due to compat getdents() call assumption that all filesystems
support cookies.
 1.28.2.9 24-Mar-2008  yamt sync with head.
 1.28.2.8 04-Feb-2008  yamt sync with head.
 1.28.2.7 21-Jan-2008  yamt sync with head
 1.28.2.6 07-Dec-2007  yamt sync with head
 1.28.2.5 27-Oct-2007  yamt sync with head.
 1.28.2.4 03-Sep-2007  yamt sync with head.
 1.28.2.3 26-Feb-2007  yamt sync with head.
 1.28.2.2 30-Dec-2006  yamt sync with head.
 1.28.2.1 21-Jun-2006  yamt sync with head.
 1.30.6.2 01-Jun-2006  kardel Sync with head.
 1.30.6.1 22-Apr-2006  simonb Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.30.2.2 18-Feb-2006  yamt sync with head.
 1.30.2.1 31-Dec-2005  yamt adapt some random parts of kernel to uio_vmspace.
 1.32.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.32.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.32.2.3 11-Aug-2006  yamt revert code which was mistakenly slipped in with 1.32.2.1.
 1.32.2.2 11-Aug-2006  yamt sync with head
 1.32.2.1 24-May-2006  yamt sync with head.
 1.34.8.1 12-Jun-2010  riz Pull up following revision(s) (requested by he in ticket #1387):
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/osf1/osf1_file.c: revision 1.38
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.34.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.35.2.3 17-May-2007  yamt sync with head.
 1.35.2.2 07-May-2007  yamt sync with head.
 1.35.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.2.2 27-May-2007  ad Sync with head.
 1.36.2.1 13-Mar-2007  ad Sync with head.
 1.37.2.1 11-Jul-2007  mjf Sync with head.
 1.39.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.39.8.3 23-Mar-2008  matt sync with HEAD
 1.39.8.2 09-Jan-2008  matt sync with HEAD
 1.39.8.1 06-Nov-2007  matt sync with HEAD
 1.39.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.39.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.39.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.40.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.40.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.40.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.41.2.2 26-Dec-2007  ad Sync with head.
 1.41.2.1 08-Dec-2007  ad Sync with head.
 1.43.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.45.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.45.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.45.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.46.4.5 11-Aug-2010  yamt sync with head.
 1.46.4.4 11-Mar-2010  yamt sync with head
 1.46.4.3 16-May-2009  yamt sync with head
 1.46.4.2 04-May-2009  yamt sync with head.
 1.46.4.1 16-May-2008  yamt sync with head.
 1.46.2.1 18-May-2008  yamt sync with head.
 1.47.4.1 27-Jun-2008  simonb Sync with head.
 1.47.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.47.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.47.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.48.14.1 21-Apr-2010  matt sync to netbsd-5
 1.48.10.1 23-Jul-2009  jym Sync with HEAD.
 1.48.6.1 17-Mar-2010  snj Pull up following revision(s) (requested by he in ticket #1323):
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.49.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.49.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.50.2.1 03-Jul-2010  rmind sync with head
 1.53.22.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.53.16.1 18-May-2014  rmind sync with head
 1.53.14.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.53.12.2 03-Dec-2017  jdolecek update from HEAD
 1.53.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.53.8.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.53.2.1 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.55.14.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.14.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.55.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.55.8.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.55.6.2 28-Aug-2017  skrll Sync with HEAD
 1.55.6.1 05-Feb-2017  skrll Sync with HEAD
 1.55.4.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.4.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.57.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.58.6.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.58.6.1 09-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #193):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.59.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.59.4.1 10-Jun-2019  christos Sync with HEAD
 1.59.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.60.4.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.41 03-May-2020  thorpej Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes
exist in different namespace depending on FUTEX_PRIVATE_FLAG. This appears
not to be the case in Linux, and some futex users will mix private and non-
private ops on the same futex object. Provide a convenience wrapper that
puts this logic in one place witn a comment explaining why.

While here, move the Linux futex wrapper out of its own file and plop
it in linux_misc.c, which is where it lives in the linux32 module.
 1.40 29-Apr-2020  thorpej Oops, fix a silly mistake in the Linux futex syscall stubs -- we also
copy in the timeout for FUTEX_WAIT_BITSET.
 1.39 26-Apr-2020  thorpej Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.38 14-Mar-2020  ad - Hide the details of SPCF_SHOULDYIELD and related behind a couple of small
functions: preempt_point() and preempt_needed().

- preempt(): if the LWP has exceeded its timeslice in kernel, strip it of
any priority boost gained earlier from blocking.
 1.37 10-Apr-2017  dholland branches: 1.37.14;
Return value pointers should be the last argument.
 1.36 09-Apr-2017  dholland speed limit 80
 1.35 15-Aug-2016  maxv branches: 1.35.2;
Uninitialized var, found by brainy; not tested, but obvious enough
 1.34 20-May-2016  chs branches: 1.34.2;
simplify and fix futex requeuing:
don't wake up all the threads being requeued to have them move themselves
from one list to another (thus defeating the purpose), just change the lists
directly in futex_wake().
 1.33 11-Feb-2014  maxv branches: 1.33.6;
Fix uninitialized variable. Harmless: it does not change the behavior
at all.

ok rmind@ christos@
 1.32 17-Oct-2013  christos remove unused variable
 1.31 18-Jul-2013  njoly Do not make FUTEX_WAIT wait indefinitely for an invalid timeout
(tv_nsec = -1).
 1.30 17-Apr-2013  christos branches: 1.30.4; 1.30.6;
handle timeouts like before.
 1.29 16-Apr-2013  christos Add some more futex gunk and explain why it does not work (yet).
Now skype aborts with a futex timeout, instead of a stack smash leading
to a SEGV.
 1.28 18-Nov-2011  christos branches: 1.28.10;
- add sigtimedwait support.
- merge the siginfo population code.
 1.27 14-Sep-2011  christos branches: 1.27.2;
Can't use RUN_ONCE here to initialize the futex_lock, otherwise we cannot
unload the module.
 1.26 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.25 01-Jul-2010  rmind Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
 1.24 14-Mar-2009  christos branches: 1.24.2; 1.24.4;
fix robust_list pointer mess!
 1.23 23-Feb-2009  rmind Switch Linux futex emulation to native ucas_int(), remove unecessary
futex-specific assembler routines.

Fixes PR/40490. Reviewed by <ad>.
 1.22 08-Jan-2009  njoly branches: 1.22.2;
Restore expected FUTEX_WAIT behaviour with NULL timeout argument,
which was broken in my recent timespec cleanup/fix.
 1.21 23-Nov-2008  mrg initialise a variable to avoid a GCC warning.
 1.20 19-Nov-2008  njoly futex(2) timeout argument cleanup/fix.
- Use `struct linux_timespec', converted to native structure.
- Ensure that provided values are correct.
- Replace timeval+tvtohz by tstohz.
 1.19 18-Nov-2008  njoly noisy printf.
 1.18 26-Oct-2008  jmcneill branches: 1.18.2; 1.18.4;
linux_sys_get_robust_list: copyout the entire struct, not the size of the
pointer to it.
 1.17 26-Oct-2008  christos futex support fixes from FreeBSD via cube+pengo.
 1.16 20-Jun-2008  njoly branches: 1.16.2;
Do not return 0 for unsupported/unknown futex operations, but ENOSYS
instead. From Roman Divacky in private email.
 1.15 20-Jun-2008  njoly Fix futex locking. Move all locking to linux_sys_futex function, and
KASSERT that futex_{get,put,sleep,wake} are now called with lock held.
 1.14 05-Jun-2008  njoly branches: 1.14.2;
Add missing cv_destroy in futex_sleep.
 1.13 30-Apr-2008  ad branches: 1.13.2;
Make various bits of debug code compile again.
 1.12 24-Apr-2008  ad branches: 1.12.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.11 23-Apr-2008  ad Fix locking.
 1.10 20-Dec-2007  dsl branches: 1.10.6; 1.10.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.9 04-Nov-2007  rmind branches: 1.9.4; 1.9.8;
- Replace lockmgr with mutex;
- Use condvars instead of tsleep/wakeup;
- Replace malloc with kmem;
- Use itimespecfix/tstohz;

Reviewed by <ad>.
 1.8 19-Oct-2007  njoly Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.7 24-Jul-2006  manu branches: 1.7.28; 1.7.30; 1.7.34;
typo
 1.6 09-Jul-2006  manu If the user process requests a non null timeout, make sure we do not turn
it into an infinite timeout because of a conversion
 1.5 23-Nov-2005  manu branches: 1.5.4; 1.5.8; 1.5.16; 1.5.18;
- Add Linux tkill and tgkill (partial emulation).
- Fix getrlimit on amd64
 1.4 09-Nov-2005  manu branches: 1.4.2; 1.4.4;
Prevent integer overflow in timout calculation.
changed DEBUG_LINUX to DEBUG_LINUX_FUTEX so that we have less debug
messages on the console
 1.3 08-Nov-2005  manu Correctly computes futex timeout.
 1.2 05-Nov-2005  manu Implement more of Linux futex(2)
 1.1 04-Nov-2005  manu Implement Linux futex ang gettid
 1.4.4.1 29-Nov-2005  yamt sync with head.
 1.4.2.3 11-Dec-2005  christos Sync with head.
 1.4.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.1 09-Nov-2005  skrll file linux_futex.c was added on branch ktrace-lwp on 2005-11-10 14:01:07 +0000
 1.5.18.6 21-Jan-2008  yamt sync with head
 1.5.18.5 15-Nov-2007  yamt sync with head.
 1.5.18.4 27-Oct-2007  yamt sync with head.
 1.5.18.3 30-Dec-2006  yamt sync with head.
 1.5.18.2 21-Jun-2006  yamt sync with head.
 1.5.18.1 23-Nov-2005  yamt file linux_futex.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:12 +0000
 1.5.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.8.1 11-Aug-2006  yamt sync with head
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.7.34.2 13-Nov-2007  bouyer Sync with HEAD
 1.7.34.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.30.2 09-Jan-2008  matt sync with HEAD
 1.7.30.1 06-Nov-2007  matt sync with HEAD
 1.7.28.2 04-Nov-2007  jmcneill Sync with HEAD.
 1.7.28.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.9.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.4.1 26-Dec-2007  ad Sync with head.
 1.10.8.2 17-Jun-2008  yamt sync with head.
 1.10.8.1 18-May-2008  yamt sync with head.
 1.10.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.10.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.10.6.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.10.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.2.3 11-Aug-2010  yamt sync with head.
 1.12.2.2 04-May-2009  yamt sync with head.
 1.12.2.1 16-May-2008  yamt sync with head.
 1.13.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.2.1 27-Jun-2008  simonb Sync with head.
 1.16.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.18.4.2 16-Mar-2009  snj Pull up following revision(s) (requested by adrianp in ticket #582):
sys/compat/linux/common/linux_futex.c: revision 1.24 via patch
fix robust_list pointer mess!
 1.18.4.1 26-Feb-2009  snj Pull up following revision(s) (requested by rmind in ticket #493):
sys/compat/linux/arch/amd64/files.linux_amd64: revision 1.4
sys/compat/linux/arch/amd64/linux_support.S: file removal
sys/compat/linux/common/linux_futex.c: revision 1.23
sys/compat/linux/arch/i386/linux_support.S: file removal
sys/compat/linux/arch/i386/files.linux_i386: revision 1.10
Switch Linux futex emulation to native ucas_int(), remove unecessary
futex-specific assembler routines.
Fixes PR/40490. Reviewed by <ad>.
 1.18.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.18.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.18.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.22.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.4.2 05-Mar-2011  rmind sync with head
 1.24.4.1 03-Jul-2010  rmind sync with head
 1.24.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.27.2.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.27.2.1 17-Apr-2012  yamt sync with head
 1.28.10.3 03-Dec-2017  jdolecek update from HEAD
 1.28.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.10.1 23-Jun-2013  tls resync from head
 1.30.6.1 23-Jul-2013  riastradh sync with HEAD
 1.30.4.2 18-May-2014  rmind sync with head
 1.30.4.1 28-Aug-2013  rmind sync with head
 1.33.6.3 28-Aug-2017  skrll Sync with HEAD
 1.33.6.2 05-Oct-2016  skrll Sync with HEAD
 1.33.6.1 29-May-2016  skrll Sync with HEAD
 1.34.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.35.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.37.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.9 26-Apr-2020  thorpej Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.8 10-Apr-2017  dholland Return value pointers should be the last argument.
 1.7 16-Apr-2013  christos branches: 1.7.12; 1.7.16; 1.7.20;
Add some more futex gunk and explain why it does not work (yet).
Now skype aborts with a futex timeout, instead of a stack smash leading
to a SEGV.
 1.6 11-Jan-2013  christos add the futex PI commands (not implemented yet)
PI = Priotity Inheritance
 1.5 14-Sep-2011  christos branches: 1.5.2; 1.5.12;
Can't use RUN_ONCE here to initialize the futex_lock, otherwise we cannot
unload the module.
 1.4 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.3 26-Oct-2008  christos branches: 1.3.14; 1.3.16;
futex support fixes from FreeBSD via cube+pengo.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.72; 1.2.76; 1.2.82;
merge ktrace-lwp.
 1.1 04-Nov-2005  manu branches: 1.1.2;
Implement Linux futex ang gettid
 1.1.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.1 04-Nov-2005  skrll file linux_futex.h was added on branch ktrace-lwp on 2005-11-10 14:01:07 +0000
 1.2.82.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.76.2 11-Aug-2010  yamt sync with head.
 1.2.76.1 04-May-2009  yamt sync with head.
 1.2.72.1 17-Jan-2009  mjf Sync with HEAD.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file linux_futex.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:12 +0000
 1.3.16.1 05-Mar-2011  rmind sync with head
 1.3.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.5.12.3 03-Dec-2017  jdolecek update from HEAD
 1.5.12.2 23-Jun-2013  tls resync from head
 1.5.12.1 25-Feb-2013  tls resync with head
 1.5.2.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.5.2.1 23-Jan-2013  yamt sync with head
 1.7.20.1 21-Apr-2017  bouyer Sync with HEAD
 1.7.16.1 26-Apr-2017  pgoyette Sync with HEAD
 1.7.12.1 28-Aug-2017  skrll Sync with HEAD
 1.19 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.18 03-Feb-2019  mrg branches: 1.18.4;
- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.17 08-Dec-2015  christos branches: 1.17.10; 1.17.18;
Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
 1.16 21-Mar-2008  ad branches: 1.16.6; 1.16.48; 1.16.68;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.15 20-Dec-2007  dsl branches: 1.15.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.14 19-Oct-2007  njoly branches: 1.14.4; 1.14.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.13 01-Jul-2007  dsl branches: 1.13.6; 1.13.8; 1.13.12;
Fix LINUX_HDIO_GET_IDENTITY so that it returns the entire 512 byte buffer.
Rely on the code in dev/ata/wd.c doing a relay for the short read needed
for LINUX_HDIO_OBSOLETE_IDENTITY.
 1.12 04-Mar-2007  christos branches: 1.12.2; 1.12.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 09-Feb-2007  ad branches: 1.11.2;
Merge newlock2 to head.
 1.10 11-Dec-2005  christos branches: 1.10.20;
merge ktrace-lwp.
 1.9 28-Feb-2005  soren branches: 1.9.4;
Remove duplicate statement.
 1.8 29-Jun-2003  fvdl branches: 1.8.2; 1.8.10; 1.8.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.7 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.6 21-Mar-2003  dsl Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
 1.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.3 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.2 14-Jun-2001  thorpej branches: 1.2.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.1 10-Dec-2000  fvdl branches: 1.1.2; 1.1.4; 1.1.6;
Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.1.6.2 30-Mar-2001  he Pull up revision 1.1 (new, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.1.6.1 10-Dec-2000  he file linux_hdio.c was added on branch netbsd-1-5 on 2001-03-30 21:39:59 +0000
 1.1.4.6 08-Jul-2002  nathanw Revert a change (looked like a typo fix!) for the LINUX_HDIO_GETGEO
ioctl.
 1.1.4.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 24-Aug-2001  nathanw A few files and lwp/proc conversions I missed in the last big update.
GENERIC runs again.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.1 10-Dec-2000  bouyer file linux_hdio.c was added on branch thorpej_scsipi on 2000-12-13 15:49:49 +0000
 1.2.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.10.1 29-Apr-2005  kent sync with -current
 1.8.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.9.4.6 24-Mar-2008  yamt sync with head.
 1.9.4.5 21-Jan-2008  yamt sync with head
 1.9.4.4 27-Oct-2007  yamt sync with head.
 1.9.4.3 03-Sep-2007  yamt sync with head.
 1.9.4.2 26-Feb-2007  yamt sync with head.
 1.9.4.1 21-Jun-2006  yamt sync with head.
 1.10.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.11.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.4.1 11-Jul-2007  mjf Sync with head.
 1.12.2.1 15-Jul-2007  ad Sync with head.
 1.13.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.8.2 09-Jan-2008  matt sync with HEAD
 1.13.8.1 06-Nov-2007  matt sync with HEAD
 1.13.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.4.1 26-Dec-2007  ad Sync with head.
 1.15.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.68.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.16.48.1 03-Dec-2017  jdolecek update from HEAD
 1.16.6.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.16.6.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.17.18.1 10-Jun-2019  christos Sync with HEAD
 1.17.10.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.18.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.1 10-Dec-2000  fvdl branches: 1.1.2; 1.1.6;
Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.1.6.2 30-Mar-2001  he Pull up revision 1.1 (new, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.1.6.1 10-Dec-2000  he file linux_hdio.h was added on branch netbsd-1-5 on 2001-03-30 21:39:59 +0000
 1.1.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.1 10-Dec-2000  bouyer file linux_hdio.h was added on branch thorpej_scsipi on 2000-12-13 15:49:50 +0000
 1.8 27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.7 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.6 09-Feb-2024  andvar branches: 1.6.2;
fix spelling mistakes, mainly in comments and log messages.
 1.5 24-Aug-2023  christos fix a locking bug (Theodore Preduta)
 1.4 23-Aug-2023  christos put variable length structure at the end, so that clang does not complain.
 1.3 22-Aug-2023  christos aarch64 does not have sys_inotify_init()...
 1.2 20-Aug-2023  christos fix locking: eliminate using mutex_owned() (Theodore Preduta)
 1.1 19-Aug-2023  christos new inotify support GSoC 2023 (Theodore Preduta)
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 19-Aug-2023  christos new inotify support GSoC 2023 (Theodore Preduta)
 1.60 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.59 19-Sep-2021  thorpej branches: 1.59.10;
Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.58 23-Mar-2014  dholland branches: 1.58.10; 1.58.20; 1.58.42;
typos in comments
 1.57 19-Sep-2012  bouyer branches: 1.57.2;
Add a pass-through ioctl for mfi(4), allowing userland to send raw commands
to the controller. This is compatible with the linux and FreeBSD
implementations.
Add the needed conversion for mfi ioctls in COMPAT_LINUX
Allocate a character major number, and create /dev/mfi0 by default
on amd64 and i386.
This allows (along with a hand-created /emul/linux/proc/devices file)
to run the MegaCLI linux binary provided by LSI.
 1.56 14-Oct-2011  hannken branches: 1.56.2; 1.56.8; 1.56.12;
Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock. Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
 1.55 19-Jul-2008  jmcneill ioctl compatibility for v4l2 and drm
 1.54 28-Apr-2008  martin branches: 1.54.2; 1.54.4; 1.54.6;
Remove clause 3 and 4 from TNF licenses
 1.53 21-Mar-2008  ad branches: 1.53.2; 1.53.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.52 20-Dec-2007  dsl branches: 1.52.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.51 08-Dec-2007  dsl branches: 1.51.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.50 26-Nov-2007  pooka branches: 1.50.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.49 19-Oct-2007  njoly branches: 1.49.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.48 16-Jun-2007  dsl branches: 1.48.6; 1.48.8; 1.48.12;
Delete stuff in comment about use of stackgap.
 1.47 04-Mar-2007  christos branches: 1.47.2; 1.47.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.46 09-Feb-2007  ad branches: 1.46.2;
Merge newlock2 to head.
 1.45 23-Jul-2006  ad branches: 1.45.4;
Use the LWP cached credentials where sane.
 1.44 14-May-2006  elad integrate kauth.
 1.43 11-Dec-2005  christos branches: 1.43.4; 1.43.6; 1.43.8; 1.43.10; 1.43.12;
merge ktrace-lwp.
 1.42 28-Feb-2005  soren branches: 1.42.4;
Emulate basic mtio ioctls.
 1.41 26-Feb-2005  perry nuke trailing whitespace
 1.40 03-Feb-2005  christos Add linux scsi-generic to work for simple cases. Allows gendalia's change
to limp along. From soren with fixes from me.
 1.39 03-Jun-2004  yamt branches: 1.39.4; 1.39.6;
linux_sys_ioctl: map EPASSTHROUGH to EINVAL as sys_ioctl does.
otherwise, linux_syscall() returns garbage, at least on i386.
(it returns native_to_linux_errno[EPASSTHROUGH] where EPASSTHROUGH == -4.)

i choose EINVAL rather than ENOTTY, because linux's pipe returns it
and i think that it's a common case.
 1.38 29-Jun-2003  fvdl branches: 1.38.2; 1.38.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.37 29-Jun-2003  enami Redo previous; struct proc *p is necessary if NSEQUENCER is non zero.
 1.36 28-Jun-2003  bouyer Kill unused variable.
 1.35 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.34 23-Jun-2003  christos PR/21936: Todd Vierling: ioctl 'r' misinterpreted
 1.33 20-Jun-2003  christos PR/21936: Todd Vierling: compat/linux: ioctl 'r' misinterpreted
 1.32 27-Feb-2003  yamt make compat_linux struct file interlock friendly.
 1.31 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.30 22-Oct-2002  simonb Don't call cdevsw_lookup() with an uninitialised variable in
linux_sys_ioctl().
 1.29 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.28 13-Nov-2001  lukem branches: 1.28.8; 1.28.10;
add RCSIDs (including regeneration of files as appropriate)
 1.27 14-Jun-2001  thorpej branches: 1.27.2; 1.27.4;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.26 30-May-2001  mrg use _KERNEL_OPT.
 1.25 10-Jan-2001  fvdl branches: 1.25.2;
Declare linux_ioctl_blkio and call it from the main routine.
 1.24 10-Dec-2000  fvdl Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.23 29-Nov-2000  jdolecek LKMify
 1.22 15-Dec-1998  augustss branches: 1.22.8; 1.22.18;
Slight code rearrangement and more defensive tests for the sequencer device.
 1.21 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.20 03-Oct-1998  christos Attempt to fix the mess.
 1.19 01-Oct-1998  erh Move compat/linux/linux_ioctl.c to common.
 1.18 07-Aug-1998  augustss Add MIDI support. The MIDI devices can be accessed as ``raw'' through
the /dev/rmidiN devices, or with a sequencer interface via /dev/music.
So far the only supported MIDI device is the MPU401 port on SoundBlaster
(and only on SB on isapnp, since we do not have locators with multiple
values yet).
 1.17 15-Jan-1998  christos PR/4794: Urban Boquist: Linux cdrom ioctls are missing
 1.16 04-Apr-1997  augustss * Move the Linux audio emulation into its own directory and rename it
OSS (aka VoxWare) audio emulation.
* Use the OSS audio emulation for Linux and FreeBSD.
* Add mixer emulation to the OSS emulator.
 1.15 19-Mar-1997  mycroft Emulate the SOUND_PCM_WRITE_CHANNELS ioctl. From PR 3356, by Lennart
Augustsson. Also add hooks for mixer ioctls.
 1.14 05-Apr-1996  christos Prototyping changes.
 1.13 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.12 27-Feb-1996  mycroft Map SIOCGIFFLAGS and SIOCGIFADDR (et al).
 1.11 27-Feb-1996  mycroft Use OSIOCGIFCONF in previous.
 1.10 27-Feb-1996  mycroft Map SIOCGIFCONF.
 1.9 16-Nov-1995  thorpej Fix transposed copyin() args, from Niklas Hallqvist <niklas@appli.se>.
 1.8 07-Oct-1995  mycroft branches: 1.8.2;
Prefix names of system call implementation functions with `sys_'.
 1.7 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.6 27-Aug-1995  fvdl Add a hook for MD ioctl calls, plus a couple of more changes to make
svgalib binaries work on the i386
 1.5 16-Aug-1995  mycroft Convert 230400 baud.
 1.4 14-Aug-1995  mycroft Rearrange #includes.
 1.3 24-Jun-1995  christos Use compat_util.[ch].
 1.2 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.8.2.1 16-Nov-1995  thorpej Update from trunk; fix transposed copyin() args.
 1.22.18.1 30-Mar-2001  he Pull up revisions 1.24-1.25 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.22.8.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.22.8.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.22.8.1 08-Dec-2000  bouyer Sync with HEAD.
 1.25.2.6 11-Nov-2002  nathanw Catch up to -current
 1.25.2.5 17-Sep-2002  nathanw Catch up to -current.
 1.25.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.25.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.25.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.25.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.27.4.1 07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.27.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.27.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.28.10.1 17-Aug-2003  tron Pull up revision 1.33 (requested by tv in ticket #1421):
PR/21936: Todd Vierling: compat/linux: ioctl 'r' misinterpreted
 1.28.8.1 16-May-2002  gehenna Replace the direct-access to devsw table with calling devsw API.
 1.38.4.1 08-Oct-2004  jmc Pullup rev 1.39 (requested by manu in ticket #904)

linux_sys_ioctl: map EPASSTHROUGH to EINVAL as sys_ioctl does.
otherwise, linux_syscall() returns garbage, at least on i386.
 1.38.2.9 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.38.2.8 04-Feb-2005  skrll Sync with HEAD.
 1.38.2.7 21-Nov-2004  skrll Adapt to branch. Alpha kernels now compile.
 1.38.2.6 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.38.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.38.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.38.2.3 03-Aug-2004  skrll Sync with HEAD
 1.38.2.2 19-Aug-2003  skrll Fix patch botch. Closes PR 22043.
 1.38.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.39.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.39.6.1 12-Feb-2005  yamt sync with head.
 1.39.4.1 29-Apr-2005  kent sync with -current
 1.42.4.8 24-Mar-2008  yamt sync with head.
 1.42.4.7 21-Jan-2008  yamt sync with head
 1.42.4.6 07-Dec-2007  yamt sync with head
 1.42.4.5 27-Oct-2007  yamt sync with head.
 1.42.4.4 03-Sep-2007  yamt sync with head.
 1.42.4.3 26-Feb-2007  yamt sync with head.
 1.42.4.2 30-Dec-2006  yamt sync with head.
 1.42.4.1 21-Jun-2006  yamt sync with head.
 1.43.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.43.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.43.8.2 11-Aug-2006  yamt sync with head
 1.43.8.1 24-May-2006  yamt sync with head.
 1.43.6.1 01-Jun-2006  kardel Sync with head.
 1.43.4.1 09-Sep-2006  rpaulo sync with head
 1.45.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.46.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.47.4.1 11-Jul-2007  mjf Sync with head.
 1.47.2.1 15-Jul-2007  ad Sync with head.
 1.48.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.48.8.2 09-Jan-2008  matt sync with HEAD
 1.48.8.1 06-Nov-2007  matt sync with HEAD
 1.48.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.48.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.48.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.49.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.49.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.50.2.1 26-Dec-2007  ad Sync with head.
 1.51.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.52.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.52.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.52.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.53.4.2 04-May-2009  yamt sync with head.
 1.53.4.1 16-May-2008  yamt sync with head.
 1.53.2.1 18-May-2008  yamt sync with head.
 1.54.6.1 19-Oct-2008  haad Sync with HEAD.
 1.54.4.1 28-Jul-2008  simonb Sync with head.
 1.54.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.54.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.54.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.56.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.56.8.1 24-Oct-2012  riz Pull up following revision(s) (requested by bouyer in ticket #629):
sys/compat/linux/common/linux_ioctl.c: revision 1.57
sys/dev/ic/mfi.c: revision 1.47
sys/conf/majors: revision 1.62
etc/etc.i386/MAKEDEV.conf: revision 1.24
sys/dev/ic/mfivar.h: revision 1.20
etc/MAKEDEV.tmpl: revision 1.159
sys/dev/ic/mfiio.h: revision 1.1
etc/etc.amd64/MAKEDEV.conf: revision 1.19
sys/dev/ic/mfireg.h: revision 1.8
Add a pass-through ioctl for mfi(4), allowing userland to send raw commands
to the controller. This is compatible with the linux and FreeBSD
implementations.
Add the needed conversion for mfi ioctls in COMPAT_LINUX
Allocate a character major number, and create /dev/mfi0 by default
on amd64 and i386.
This allows (along with a hand-created /emul/linux/proc/devices file)
to run the MegaCLI linux binary provided by LSI.
 1.56.2.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.56.2.1 30-Oct-2012  yamt sync with head
 1.57.2.1 18-May-2014  rmind sync with head
 1.58.42.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.58.20.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.58.10.2 21-Jul-2016  pgoyette simplify for readability
 1.58.10.1 20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.59.10.1 02-Aug-2025  perseant Sync with HEAD
 1.30 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.29 23-Sep-2021  ryo branches: 1.29.10;
add support COMPAT_LINUX for aarch64
 1.28 19-Sep-2021  thorpej Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.27 08-Jun-2013  stacktic branches: 1.27.46;
Typo
 1.26 28-Apr-2008  martin branches: 1.26.34; 1.26.44;
Remove clause 3 and 4 from TNF licenses
 1.25 20-Dec-2007  dsl branches: 1.25.6; 1.25.8; 1.25.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.24 04-Dec-2007  dsl branches: 1.24.4;
Remove all the __P
 1.23 11-Dec-2005  christos branches: 1.23.44; 1.23.46; 1.23.52; 1.23.56;
merge ktrace-lwp.
 1.22 03-May-2005  manu branches: 1.22.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.21 28-Feb-2005  soren Emulate basic mtio ioctls.
 1.20 26-Feb-2005  perry nuke trailing whitespace
 1.19 03-Feb-2005  christos Add linux scsi-generic to work for simple cases. Allows gendalia's change
to limp along. From soren with fixes from me.
 1.18 29-Jun-2003  fvdl branches: 1.18.2; 1.18.10; 1.18.12;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.17 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.16 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.15 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.14 19-Jan-2001  manu branches: 1.14.2; 1.14.4; 1.14.6;
Added Linux compatibility support for powerpc ports
 1.13 10-Jan-2001  fvdl Declare linux_ioctl_blkio and call it from the main routine.
 1.12 10-Dec-2000  fvdl The gist of the Linux _IOX definitions was the same for all platforms;
move it to the MI linux_ioctl.h and only leave the MD bits in the MD
header files.

Add defintions for linux_ioctl_hdio and linux_ioctl_fdio.
 1.11 15-Dec-1998  itohy branches: 1.11.8; 1.11.18;
Added linux compat support on m68k ports.
 1.10 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.9 03-Oct-1998  christos Attempt to fix the mess.
 1.8 01-Oct-1998  erh Split compat/linux/linux_ioctl.h into i386 and common parts.
 1.7 15-Jan-1998  christos PR/4794: Urban Boquist: Linux cdrom ioctls are missing
 1.6 04-Apr-1997  augustss * Move the Linux audio emulation into its own directory and rename it
OSS (aka VoxWare) audio emulation.
* Use the OSS audio emulation for Linux and FreeBSD.
* Add mixer emulation to the OSS emulator.
 1.5 19-Mar-1997  mycroft Emulate the SOUND_PCM_WRITE_CHANNELS ioctl. From PR 3356, by Lennart
Augustsson. Also add hooks for mixer ioctls.
 1.4 05-Apr-1996  christos Prototyping changes.
 1.3 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.2 16-Aug-1995  mycroft Convert 230400 baud.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.11.18.1 30-Mar-2001  he Pull up revisions 1.12-1.13 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.11.8.3 11-Feb-2001  bouyer Sync with HEAD.
 1.11.8.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.11.8.1 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.14.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.14.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.14.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.14.2.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.18.12.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.12.1 12-Feb-2005  yamt sync with head.
 1.18.10.1 29-Apr-2005  kent sync with -current
 1.18.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.18.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.22.2.3 21-Jan-2008  yamt sync with head
 1.22.2.2 07-Dec-2007  yamt sync with head
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.23.56.2 26-Dec-2007  ad Sync with head.
 1.23.56.1 08-Dec-2007  ad Sync with head.
 1.23.52.2 27-Dec-2007  mjf Sync with HEAD.
 1.23.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.23.46.1 09-Jan-2008  matt sync with HEAD
 1.23.44.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.25.10.1 16-May-2008  yamt sync with head.
 1.25.8.1 18-May-2008  yamt sync with head.
 1.25.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.26.44.1 23-Jun-2013  tls resync from head
 1.26.34.1 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.27.46.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.29.10.1 02-Aug-2025  perseant Sync with HEAD
 1.58 27-Jun-2025  andvar Fix various typos, mainly in comments.
 1.57 23-Aug-2019  maxv branches: 1.57.32;
Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.

Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.
 1.56 21-Feb-2019  mrg branches: 1.56.4;
for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.

besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.


while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.


XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.
 1.55 28-May-2011  alnsn branches: 1.55.30; 1.55.34; 1.55.42; 1.55.48; 1.55.56;
Fix typo in a comment.
 1.54 16-Nov-2009  joerg branches: 1.54.4; 1.54.6;
Make sure to never leak padding space before copyout or copyin
uninitialized fields by explicitly using memset in the conversion
routines.
 1.53 23-Apr-2009  njoly Add IPC_64 support for all semctl(2)/msgctl(2). Needed, at least on
i386 for Linux 2.6 emulation.
 1.52 18-Feb-2009  njoly Add IPC_64 support for all shmctl(2) commands, not only for STAT/SET.
This make it work on i386 under 2.6 emulation.
 1.51 21-May-2008  njoly branches: 1.51.6; 1.51.12;
Add IPC_64 support to msgctl, needed for amd64.
 1.50 28-Apr-2008  martin branches: 1.50.2;
Remove clause 3 and 4 from TNF licenses
 1.49 24-Apr-2008  njoly branches: 1.49.2;
Add IPC_64 support for semctl IPC_STAT/IPC_SET.
 1.48 21-Apr-2008  njoly Add LINUX_IPC_64 support for LINUX_IPC_SET in shmctl. Required, at
least, for amd64 which use LINUX_IPC_FORCE64.
 1.47 21-Apr-2008  njoly Rename LINUX_SHMCTL_FORCEIPC64 define to LINUX_IPC_FORCE64.
 1.46 16-Apr-2008  njoly branches: 1.46.2;
Remove an obsolete comment about SHM_LOCK/SHM_UNLOCK being no-op.
 1.45 15-Apr-2008  njoly Remove unneeded amd64 ifdef/endif.
 1.44 28-Jan-2008  njoly branches: 1.44.6;
Make shmctl + {IPC,SHM}_STAT work an amd64, by forcing use of IPC_64.
Following the Linux kernel behaviour.
 1.43 28-Jan-2008  njoly shmctl fixes.

- SHM_STAT take an index as input, and return the corresponding shmid.
- IPC_INFO and SHM_INFO returns the highest used index.
- SHM_INFO expected the total used pages (not bytes) in shm_tot field
of struct shm_info.
 1.42 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.41 08-Dec-2007  dsl branches: 1.41.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.40 17-Jun-2007  dsl branches: 1.40.6; 1.40.8; 1.40.14; 1.40.16;
Do the sysv ipc calls without the stackgap.
 1.39 04-Mar-2007  christos branches: 1.39.2; 1.39.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.38 09-Feb-2007  ad branches: 1.38.2;
Merge newlock2 to head.
 1.37 13-Sep-2006  manu Jumbo COMPAT_LINUX/COMPAT_LINUX32 bugfix, with the help of Nicolas Joly
- Fix shmat return value on amd64: it uses no black magic with retval[0]
- Fix integer overflows in sysinfo
- Implement sysinfo, mmap2, sched_getparam, sched_getscheduler, mremap,
and madvise in COMPAT_LINUX32
- Fix improper types used in setgroups16/getgroups16
- Implement mmap2 for COMPAT_LINUX32
- Ifdef debug messages by DEBUG_LINUX
 1.36 24-Aug-2006  manu branches: 1.36.2;
The return value for Linux shmat on amd64 does not suffer the same horrible
hack as on i386.
 1.35 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.34 09-Feb-2006  dogcow branches: 1.34.2;
make linux emulation compile on i386 again.
 1.33 09-Feb-2006  manu Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.32 10-Nov-2005  christos branches: 1.32.4; 1.32.6; 1.32.8;
More ipc support for linux; makes oracle work. From chuq and
jlrodriguez at terra dot es
 1.31 26-Feb-2005  perry branches: 1.31.4;
nuke trailing whitespace
 1.30 28-Sep-2004  jdolecek branches: 1.30.4; 1.30.6;
add flag for shmget(2) to specify that later shmat(2) for the shared memory
segment should succeed even if the segment would be marked removed; use this
to implement the Linux-compatible semantics of shmat(2)

this fixes the old Linux VMware3 graphics problem with local display,
and possibly other local Linux X clients using MIT-SHM
 1.29 28-Sep-2004  jdolecek fold shmat1() back into sys_shmat(), the change in rev 1.64 is not sufficient
for Linux-compatible shmat() behaviour - shmat() for the removed shared memory
segment must work from all callers, the shared memory id could be passed e.g.
to native X server via MIT-SHM

temporarily remove the functionality, the Linux-compatible semantics
will be reimplemented differently
 1.28 18-Jan-2003  thorpej branches: 1.28.2; 1.28.4;
Merge the nathanw_sa branch.
 1.27 03-Apr-2002  fvdl Use shmat1(), and tell it to find removed segments.
 1.26 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.25 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.24 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.23 30-May-2001  mrg branches: 1.23.2;
use _KERNEL_OPT.
 1.22 01-Dec-2000  jdolecek branches: 1.22.2;
make LKM safe
 1.21 25-Aug-1999  thorpej branches: 1.21.2;
Update for new msgctl()/semctl()/shmctl() calls.
 1.20 27-May-1999  tron Add support for SETALL and GETALL to the Linux emulation of semctl()
and improve handling of SETVAL. Patches supplied by YAMAMOTO Jiro in
PR kern/7621.
 1.19 03-Jan-1999  erh branches: 1.19.4;
Undo previous: Put back opt_sysv.h
 1.18 03-Jan-1999  erh Moved opt include to header file.
 1.17 19-Oct-1998  tron Defopt SYSVMSG, SYSVSEM and SYSVSHM.
 1.16 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.15 03-Oct-1998  christos Attempt to fix the mess.
 1.14 01-Oct-1998  erh Split compat/linux/linux_ipc.c into common and multi-architechture parts. The IPC multiplexer and associated functions are now in linux_ipccall.c
 1.13 22-Jan-1998  mycroft Clean this up a bit.
 1.12 08-May-1997  kleink Fixed copyin() argument botch in shmctl() IPC_STAT handling.
 1.11 15-Nov-1996  fvdl Avoid compiler warnings when none of the SYSV* options is defined.
 1.10 05-Apr-1996  christos Prototyping changes.
 1.9 08-Oct-1995  fvdl Avoid unnecessary copyin() of shmid_ds struct for shmctl(IPC_RMID)
 1.8 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.7 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.6 15-Aug-1995  fvdl Implement the rest of the sysv ipc calls ({sem,msg}*())
 1.5 14-Aug-1995  mycroft Rearrange #includes.
 1.4 24-Jun-1995  christos Use compat_util.[ch].
 1.3 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.2 08-Mar-1995  fvdl Add missing structure conversion for IPC_RMID.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.19.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.21.2.1 08-Dec-2000  bouyer Sync with HEAD.
 1.22.2.8 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.22.2.7 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.22.2.6 17-Apr-2002  nathanw Catch up to -current.
 1.22.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.22.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.22.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.22.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.22.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.23.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.28.4.1 04-Oct-2004  jmc Pullup rev 1.29 (requested by jdolecek in ticket #884)

Fix linux handling of SysV-style shared memory. Fixed Linux VMware display
problems.
 1.28.2.3 11-Dec-2005  christos Sync with head.
 1.28.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.28.2.1 19-Oct-2004  skrll Sync with HEAD
 1.30.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.30.4.1 29-Apr-2005  kent sync with -current
 1.31.4.6 04-Feb-2008  yamt sync with head.
 1.31.4.5 21-Jan-2008  yamt sync with head
 1.31.4.4 03-Sep-2007  yamt sync with head.
 1.31.4.3 26-Feb-2007  yamt sync with head.
 1.31.4.2 30-Dec-2006  yamt sync with head.
 1.31.4.1 21-Jun-2006  yamt sync with head.
 1.32.8.1 22-Apr-2006  simonb Sync with head.
 1.32.6.1 09-Sep-2006  rpaulo sync with head
 1.32.4.1 18-Feb-2006  yamt sync with head.
 1.34.2.3 14-Sep-2006  yamt sync with head.
 1.34.2.2 03-Sep-2006  yamt sync with head.
 1.34.2.1 11-Aug-2006  yamt sync with head
 1.36.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.36.2.1 18-Nov-2006  ad Sync with head.
 1.38.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.39.4.1 11-Jul-2007  mjf Sync with head.
 1.39.2.1 15-Jul-2007  ad Sync with head.
 1.40.16.1 26-Dec-2007  ad Sync with head.
 1.40.14.1 18-Feb-2008  mjf Sync with HEAD.
 1.40.8.2 23-Mar-2008  matt sync with HEAD
 1.40.8.1 09-Jan-2008  matt sync with HEAD
 1.40.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.41.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.44.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.46.2.2 04-Jun-2008  yamt sync with head
 1.46.2.1 18-May-2008  yamt sync with head.
 1.49.2.3 11-Mar-2010  yamt sync with head
 1.49.2.2 04-May-2009  yamt sync with head.
 1.49.2.1 16-May-2008  yamt sync with head.
 1.50.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.50.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.50.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.51.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.51.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.51.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.54.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.54.4.1 31-May-2011  rmind sync with head
 1.55.56.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.55.56.1 10-Jun-2019  christos Sync with HEAD
 1.55.48.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.48.1 23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1195):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.55.42.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.42.1 23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.55.34.1 23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.55.30.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.55.30.1 23-Feb-2019  martin Pull up following revision(s) (requested by mrg in ticket #1679):
sys/compat/sys/ipc.h: revision 1.6
sys/compat/sys/ipc.h: revision 1.7
sys/compat/sys/shm.h: revision 1.8
sys/kern/sysv_shm.c: revision 1.133
sys/compat/sys/sem.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.38
sys/kern/sysv_sem.c: revision 1.96
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.28
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.29
sys/compat/linux32/common/linux32_ipccall.c: revision 1.12
sys/kern/sysv_msg.c: revision 1.73
sys/compat/sys/msg.h: revision 1.6

for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.
besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.

while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.

XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.

fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)

include libkern.h or strings.h. should fix i386 build issues.
 1.56.4.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.57.32.1 02-Aug-2025  perseant Sync with HEAD
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 04-Dec-2007  dsl branches: 1.8.12; 1.8.14; 1.8.16;
Remove all the __P
 1.7 10-Nov-2005  christos branches: 1.7.46; 1.7.48; 1.7.54; 1.7.58;
More ipc support for linux; makes oracle work. From chuq and
jlrodriguez at terra dot es
 1.6 30-May-2001  mrg branches: 1.6.22; 1.6.38;
use _KERNEL_OPT.
 1.5 03-Jan-1999  erh branches: 1.5.20;
Grab the sysv options.
 1.4 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Move IPC headers to common. The msg, sem and shm files, in addition to other common structures and to avoid creating several more machine dependent header files, include the syscall arguments for several system calls which don't exist on all architechtures.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.5.20.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.38.2 07-Dec-2007  yamt sync with head
 1.6.38.1 21-Jun-2006  yamt sync with head.
 1.6.22.1 11-Dec-2005  christos Sync with head.
 1.7.58.1 08-Dec-2007  ad Sync with head.
 1.7.54.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.48.1 09-Jan-2008  matt sync with HEAD
 1.7.46.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.16.1 16-May-2008  yamt sync with head.
 1.8.14.1 18-May-2008  yamt sync with head.
 1.8.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.34 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.33 27-Dec-2013  njoly Rename ipcall/socketcall specific defines to avoid conflict with
syscalls definitions. No functional changes.
 1.32 18-Aug-2009  drochner branches: 1.32.12; 1.32.22; 1.32.26;
remove some "inline" from functions which are defined in a .c file
but used elsewhere -- gcc-4.4.1 doesn't like it and I doubt it
had any effect
 1.31 28-Apr-2008  martin branches: 1.31.2;
Remove clause 3 and 4 from TNF licenses
 1.30 20-Dec-2007  dsl branches: 1.30.6; 1.30.8; 1.30.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.29 08-Dec-2007  dsl branches: 1.29.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.28 04-Mar-2007  christos branches: 1.28.14; 1.28.16; 1.28.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.27 09-Feb-2007  ad branches: 1.27.2;
Merge newlock2 to head.
 1.26 11-Dec-2005  christos branches: 1.26.20;
merge ktrace-lwp.
 1.25 26-Feb-2005  perry branches: 1.25.4;
nuke trailing whitespace
 1.24 28-Sep-2004  jdolecek branches: 1.24.4; 1.24.6;
add flag for shmget(2) to specify that later shmat(2) for the shared memory
segment should succeed even if the segment would be marked removed; use this
to implement the Linux-compatible semantics of shmat(2)

this fixes the old Linux VMware3 graphics problem with local display,
and possibly other local Linux X clients using MIT-SHM
 1.23 18-Jan-2003  thorpej branches: 1.23.2; 1.23.4;
Merge the nathanw_sa branch.
 1.22 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.21 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.20 30-May-2001  mrg branches: 1.20.2;
use _KERNEL_OPT.
 1.19 10-Jan-1999  tron branches: 1.19.20;
Revert last changes:
Because "linux_ipccall.h" cannot be included before "sys/shm.h" and
"sys/shm.h" needs to be included after "opt_sysv.h" include "opt_sysv.h"
in "linux_ipccall.c" again.
 1.18 03-Jan-1999  erh Moved sysv opt include to header file.
 1.17 22-Nov-1998  drochner include missing SYSV option header - PR kern/6479 by Urban Boquist
 1.16 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.15 03-Oct-1998  christos Attempt to fix the mess.
 1.14 01-Oct-1998  erh Split compat/linux/linux_ipc.c into common and multi-architechture parts. The IPC multiplexer and associated functions are now in linux_ipccall.c
 1.13 22-Jan-1998  mycroft Clean this up a bit.
 1.12 08-May-1997  kleink Fixed copyin() argument botch in shmctl() IPC_STAT handling.
 1.11 15-Nov-1996  fvdl Avoid compiler warnings when none of the SYSV* options is defined.
 1.10 05-Apr-1996  christos Prototyping changes.
 1.9 08-Oct-1995  fvdl Avoid unnecessary copyin() of shmid_ds struct for shmctl(IPC_RMID)
 1.8 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.7 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.6 15-Aug-1995  fvdl Implement the rest of the sysv ipc calls ({sem,msg}*())
 1.5 14-Aug-1995  mycroft Rearrange #includes.
 1.4 24-Jun-1995  christos Use compat_util.[ch].
 1.3 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.2 08-Mar-1995  fvdl Add missing structure conversion for IPC_RMID.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.19.20.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.19.20.4 08-Jan-2002  nathanw Catch up to -current.
 1.19.20.3 14-Nov-2001  nathanw Catch up to -current.
 1.19.20.2 21-Jun-2001  nathanw Catch up to -current.
 1.19.20.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.20.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.23.4.1 04-Oct-2004  jmc Pullup rev 1.24 (requested by jdolecek in ticket #884)

Fix linux handling of SysV-style shared memory. Fixed Linux VMware display
problems.
 1.23.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.23.2.1 19-Oct-2004  skrll Sync with HEAD
 1.24.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.24.4.1 29-Apr-2005  kent sync with -current
 1.25.4.3 21-Jan-2008  yamt sync with head
 1.25.4.2 03-Sep-2007  yamt sync with head.
 1.25.4.1 26-Feb-2007  yamt sync with head.
 1.26.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.27.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.28.24.1 26-Dec-2007  ad Sync with head.
 1.28.16.1 09-Jan-2008  matt sync with HEAD
 1.28.14.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.29.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.10.2 19-Aug-2009  yamt sync with head.
 1.30.10.1 16-May-2008  yamt sync with head.
 1.30.8.1 18-May-2008  yamt sync with head.
 1.30.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.31.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.31.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.32.26.1 18-May-2014  rmind sync with head
 1.32.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.12.1 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.17 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.16 27-Dec-2013  njoly Rename ipcall/socketcall specific defines to avoid conflict with
syscalls definitions. No functional changes.
 1.15 18-Aug-2009  drochner branches: 1.15.12; 1.15.22; 1.15.26;
remove some "inline" from functions which are defined in a .c file
but used elsewhere -- gcc-4.4.1 doesn't like it and I doubt it
had any effect
 1.14 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.13 20-Dec-2007  dsl branches: 1.13.6; 1.13.8; 1.13.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.12 04-Dec-2007  dsl branches: 1.12.4;
Remove all the __P
 1.11 16-Feb-2006  perry branches: 1.11.38; 1.11.40; 1.11.46; 1.11.50;
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.10 11-Dec-2005  christos branches: 1.10.2; 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 03-May-2005  manu branches: 1.9.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.8 18-Jan-2003  thorpej branches: 1.8.2;
Merge the nathanw_sa branch.
 1.7 10-Jan-1999  tron branches: 1.7.20;
Revert last changes:
Because "linux_ipccall.h" cannot be included before "sys/shm.h" and
"sys/shm.h" needs to be included after "opt_sysv.h" include "opt_sysv.h"
in "linux_ipccall.c" again.
 1.6 03-Jan-1999  erh Grab the sysv options.
 1.5 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.4 03-Oct-1998  christos Attempt to fix the mess.
 1.3 01-Oct-1998  erh Move linux/compat/linux_ipccall.h to multiarch. Defines for the IPC multiplexerand associated functions.
 1.2 15-Aug-1995  fvdl Implement the rest of the sysv ipc calls ({sem,msg}*())
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.7.20.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.8.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.3 21-Jan-2008  yamt sync with head
 1.9.2.2 07-Dec-2007  yamt sync with head
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.1 18-Feb-2006  yamt sync with head.
 1.11.50.2 26-Dec-2007  ad Sync with head.
 1.11.50.1 08-Dec-2007  ad Sync with head.
 1.11.46.2 27-Dec-2007  mjf Sync with HEAD.
 1.11.46.1 08-Dec-2007  mjf Sync with HEAD.
 1.11.40.1 09-Jan-2008  matt sync with HEAD
 1.11.38.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.12.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.13.10.2 19-Aug-2009  yamt sync with head.
 1.13.10.1 16-May-2008  yamt sync with head.
 1.13.8.1 18-May-2008  yamt sync with head.
 1.13.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.26.1 18-May-2014  rmind sync with head
 1.15.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.12.1 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.10 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.9 12-May-2024  christos branches: 1.9.2;
PR/58240: Ricardo Branco: Add missing limits
 1.8 02-Dec-2021  ryo add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32
 1.7 28-Feb-2015  njoly When converting limits from linux32 (int32_t) to native (uint64_t),
cast it to unsigned first to avoid bad side effect for negative
values.
 1.6 22-Sep-2012  joerg branches: 1.6.14;
LINUX_RLIM_INFINITY doesn't fit into the value range for linux32, so
introduce a variant with correct value.
 1.5 29-Mar-2009  mrg branches: 1.5.12; 1.5.22;
- add new RLIMIT_AS (aka RLIMIT_VMEM) resource that limits the total
address space available to processes. this limit exists in most other
modern unix variants, and like most of them, our defaults are unlimited.
remove the old mmap / rlimit.datasize hack.

- adds the VMCMD_STACK flag to all the stack-creation vmcmd callers.
it is currently unused, but was added a few years ago.

- add a pair of new process size values to kinfo_proc2{}. one is the
total size of the process memory map, and the other is the total size
adjusted for unused stack space (since most processes have a lot of
this...)

- patch sh, and csh to notice RLIMIT_AS. (in some cases, the alias
RLIMIT_VMEM was already present and used if availble.)

- patch ps, top and systat to notice the new k_vm_vsize member of
kinfo_proc2{}.

- update irix, svr4, svr4_32, linux and osf1 emulations to support
this information. (freebsd could be done, but that it's best left
as part of the full-update of compat/freebsd.)


this addresses PR 7897. it also gives correct memory usage values,
which have never been entirely correct (since mmap), and have been
very incorrect since jemalloc() was enabled.

tested on i386 and sparc64, build tested on several other platforms.

thanks to many folks for feedback and testing but most espcially
chuq and yamt for critical suggestions that lead to this patch not
having a special ugliness i wasn't happy with anyway :-)
 1.4 15-Mar-2009  cegger ansify function definitions
 1.3 28-Apr-2008  martin branches: 1.3.8; 1.3.10; 1.3.14;
Remove clause 3 and 4 from TNF licenses
 1.2 04-Dec-2007  dsl branches: 1.2.12; 1.2.14; 1.2.16;
Remove all the __P
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.46; 1.1.48; 1.1.54; 1.1.58;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.1.58.1 08-Dec-2007  ad Sync with head.
 1.1.54.1 08-Dec-2007  mjf Sync with HEAD.
 1.1.48.1 09-Jan-2008  matt sync with HEAD
 1.1.46.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux_limit.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.3 07-Dec-2007  yamt sync with head
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux_limit.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:12 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux_limit.h was added on branch simonb-timecounters on 2006-04-22 11:38:13 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux_limit.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.16.2 04-May-2009  yamt sync with head.
 1.2.16.1 16-May-2008  yamt sync with head.
 1.2.14.1 18-May-2008  yamt sync with head.
 1.2.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.10.1 01-Apr-2009  snj Pull up following revision(s) (requested by mrg in ticket #622):
bin/csh/csh.1: revision 1.46
bin/csh/func.c: revision 1.37
bin/ps/print.c: revision 1.111
bin/ps/ps.c: revision 1.74
bin/sh/miscbltin.c: revision 1.38
bin/sh/sh.1: revision 1.92 via patch
external/bsd/top/dist/machine/m_netbsd.c: revision 1.7
lib/libkvm/kvm_proc.c: revision 1.82
sys/arch/mips/mips/cpu_exec.c: revision 1.55
sys/compat/darwin/darwin_exec.c: revision 1.57
sys/compat/ibcs2/ibcs2_exec.c: revision 1.73
sys/compat/irix/irix_resource.c: revision 1.15
sys/compat/linux/arch/amd64/linux_exec_machdep.c: revision 1.16
sys/compat/linux/arch/i386/linux_exec_machdep.c: revision 1.12
sys/compat/linux/common/linux_limit.h: revision 1.5
sys/compat/osf1/osf1_resource.c: revision 1.14
sys/compat/svr4/svr4_resource.c: revision 1.18
sys/compat/svr4_32/svr4_32_resource.c: revision 1.17
sys/kern/exec_subr.c: revision 1.62
sys/kern/init_sysctl.c: revision 1.160
sys/kern/kern_exec.c: revision 1.288
sys/kern/kern_resource.c: revision 1.151
sys/sys/param.h: patch
sys/sys/resource.h: revision 1.31
sys/sys/sysctl.h: revision 1.184
sys/uvm/uvm_extern.h: revision 1.153
sys/uvm/uvm_glue.c: revision 1.136
sys/uvm/uvm_mmap.c: revision 1.128
usr.bin/systat/ps.c: revision 1.32
- - add new RLIMIT_AS (aka RLIMIT_VMEM) resource that limits the total
address space available to processes. this limit exists in most other
modern unix variants, and like most of them, our defaults are unlimited.
remove the old mmap / rlimit.datasize hack.
- - adds the VMCMD_STACK flag to all the stack-creation vmcmd callers.
it is currently unused, but was added a few years ago.
- - add a pair of new process size values to kinfo_proc2{}. one is the
total size of the process memory map, and the other is the total size
adjusted for unused stack space (since most processes have a lot of
this...)
- - patch sh, and csh to notice RLIMIT_AS. (in some cases, the alias
RLIMIT_VMEM was already present and used if availble.)
- - patch ps, top and systat to notice the new k_vm_vsize member of
kinfo_proc2{}.
- - update irix, svr4, svr4_32, linux and osf1 emulations to support
this information. (freebsd could be done, but that it's best left
as part of the full-update of compat/freebsd.)
this addresses PR 7897. it also gives correct memory usage values,
which have never been entirely correct (since mmap), and have been
very incorrect since jemalloc() was enabled.
tested on i386 and sparc64, build tested on several other platforms.
thanks to many folks for feedback and testing but most espcially
chuq and yamt for critical suggestions that lead to this patch not
having a special ugliness i wasn't happy with anyway :-)
 1.3.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.22.2 03-Dec-2017  jdolecek update from HEAD
 1.5.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.12.1 30-Oct-2012  yamt sync with head
 1.6.14.1 06-Apr-2015  skrll Sync with HEAD
 1.9.2.1 02-Aug-2025  perseant Sync with HEAD
 1.35 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.34 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.33 18-Jun-2008  tsutsui branches: 1.33.40; 1.33.58;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.32 28-Apr-2008  martin branches: 1.32.2; 1.32.4;
Remove clause 3 and 4 from TNF licenses
 1.31 20-Dec-2007  dsl branches: 1.31.6; 1.31.8; 1.31.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.30 08-Dec-2007  dsl branches: 1.30.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.29 04-Mar-2007  christos branches: 1.29.14; 1.29.16; 1.29.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 09-Feb-2007  ad branches: 1.28.2;
Merge newlock2 to head.
 1.27 18-Jan-2003  thorpej branches: 1.27.18; 1.27.48;
Merge the nathanw_sa branch.
 1.26 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.25 04-Oct-1998  fvdl branches: 1.25.24; 1.25.26;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.24 03-Oct-1998  christos Attempt to fix the mess.
 1.23 01-Oct-1998  erh Split compat/linux/linux_file.c into common and multi-architechture parts.
 1.22 14-Feb-1998  kleink * Use sys___posix_{chown,fchown}() instead of sys_{chown,fchown}().
* Change reference from sys_posix_rename() to sys___posix_rename().
 1.21 20-Oct-1997  thorpej Fix the shared library versioning snafu caused by the recent changes
to the stat(2) family and msync(2). This uses a primitive function
versioning scheme.

This reverts the libc shared library major version from 13 to 12, and
adds a few new interfaces to bring us to libc version 12.20.

From Frank van der Linden <fvdl@NetBSD.ORG>.
 1.20 19-Oct-1997  mycroft Fix bogosity in mknod(2) translation.
 1.19 16-Oct-1997  christos check for st_nlink overflow
 1.18 05-Sep-1997  kleink Add missing preparation of F_GETLK parameters in linux_sys_fcntl(); fixes PR
port-i386/4083 from Matthias Scheler <tron@lyssa.owl.de>, but vastly cleaned
up as previously suggested by myself.
 1.17 27-Jun-1997  kleink branches: 1.17.4;
Use sys_posix_rename() instead of sys_rename() as it's the behaviour of the
native implementation.
 1.16 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.15 20-May-1996  fvdl Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.14 05-Apr-1996  christos Prototyping changes.
 1.13 08-Oct-1995  fvdl Work around calling the NetBSD fcntl(F_{G,S}ETOWN) for now; it is too
restrictive to implement the Linux equivalent (and perhaps too restrictive
overall).
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.9 27-Aug-1995  fvdl Add a hook for MD ioctl calls, plus a couple of more changes to make
svgalib binaries work on the i386
 1.8 14-Aug-1995  mycroft Rearrange #includes.
 1.7 24-Jul-1995  fvdl mkdir() has 2 arguments.. fixes PR 1248 (from Brad Spencer)
 1.6 03-Jul-1995  fvdl Fix totally bogus implementation of a few fcntl() calls. I think I'll go
live on a deserted island now..
 1.5 24-Jun-1995  christos Use compat_util.[ch].
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 04-Apr-1995  mycroft Fix conversion of `type' and `whence' values in struct flock.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.17.4.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.26.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.25.24.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.25.24.2 14-Nov-2001  nathanw Catch up to -current.
 1.25.24.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.27.48.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.27.18.3 21-Jan-2008  yamt sync with head
 1.27.18.2 03-Sep-2007  yamt sync with head.
 1.27.18.1 26-Feb-2007  yamt sync with head.
 1.28.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.24.1 26-Dec-2007  ad Sync with head.
 1.29.16.1 09-Jan-2008  matt sync with HEAD
 1.29.14.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.30.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.31.10.2 04-May-2009  yamt sync with head.
 1.31.10.1 16-May-2008  yamt sync with head.
 1.31.8.1 18-May-2008  yamt sync with head.
 1.31.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.31.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.4.1 18-Jun-2008  simonb Sync with head.
 1.32.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.32.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.32.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.33.58.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.33.40.1 03-Dec-2017  jdolecek update from HEAD
 1.20 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.19 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.18 28-Apr-2008  martin branches: 1.18.20; 1.18.22;
Remove clause 3 and 4 from TNF licenses
 1.17 04-Dec-2007  dsl branches: 1.17.12; 1.17.14; 1.17.16;
Remove all the __P
 1.16 10-May-2007  christos branches: 1.16.6; 1.16.8; 1.16.14; 1.16.16;
- linux uname -m on x86 returns i{3,4,5,6}86 make it so.
- delete the machine sysctl that never worked, and gc linux_machine.
 1.15 23-Aug-2006  manu branches: 1.15.8; 1.15.12; 1.15.14;
1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

The thread group leader must report the exit status, even if it exits
because of another thread calling exit_group(). We do that by storing the
exit status in struct linux_emuldata_shared, and the exit hook has the
duty of setting struct proc's p_xstat for the thread group leader.

2) For exit/fork/exec hooks, move the NPTL specific code to separate functions
that are shared between COMPAT_LINUX and COMPAT_LINUX32

3) Fix LINUX_CLONE_PARENT_SETTID semantics
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.8;
merge ktrace-lwp.
 1.13 05-Nov-2005  manu Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()
 1.12 03-May-2005  manu branches: 1.12.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.11 26-Mar-2004  drochner all ports define __HAVE_SIGINFO now, so remove the CPP conditionals
 1.10 26-Sep-2003  simonb Fix "constify sendsig/trapsignal" fallout for non-siginfo'd archs. Test
compiled on most architectures.
 1.9 25-Sep-2003  christos constify sendsig/trapsignal
 1.8 06-Sep-2003  christos SA_SIGINFO changes
 1.7 04-Jul-2002  thorpej branches: 1.7.6;
Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.6 15-Feb-2002  christos branches: 1.6.8;
- add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.5 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.4 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.3 19-Jan-2001  manu branches: 1.3.2; 1.3.4; 1.3.6;
Added Linux compatibility support for powerpc ports
 1.2 15-Dec-1998  itohy branches: 1.2.8;
Added linux compat support on m68k ports.
 1.1 03-Oct-1998  christos Forgot those two.
 1.2.8.1 11-Feb-2001  bouyer Sync with HEAD.
 1.3.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.3.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.6.8.1 15-Jul-2002  gehenna catch up with -current.
 1.7.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.12.2.4 07-Dec-2007  yamt sync with head
 1.12.2.3 03-Sep-2007  yamt sync with head.
 1.12.2.2 30-Dec-2006  yamt sync with head.
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.14.8.1 03-Sep-2006  yamt sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.14.1 11-Jul-2007  mjf Sync with head.
 1.15.12.1 27-May-2007  ad Sync with head.
 1.15.8.1 17-May-2007  yamt sync with head.
 1.16.16.1 08-Dec-2007  ad Sync with head.
 1.16.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.8.1 09-Jan-2008  matt sync with HEAD
 1.16.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.17.16.2 11-Aug-2010  yamt sync with head.
 1.17.16.1 16-May-2008  yamt sync with head.
 1.17.14.1 18-May-2008  yamt sync with head.
 1.17.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.22.1 05-Mar-2011  rmind sync with head
 1.18.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.267 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.266 29-Sep-2024  christos move clone3 to linux_sched.c and make it compile (need to fix XXX comments)
 1.265 28-Sep-2024  christos Linux GSoC-2024: renameat2, clone3, sync_file_range, syncfs (Shivraj Jamgade)
 1.264 29-Jun-2024  christos branches: 1.264.2;
From gsoc 2024: Implement faccessat2 and getcpu (Shivraz)
 1.263 10-Feb-2024  andvar Fix various typos in comments, log messages and documentation.
 1.262 18-Aug-2023  christos Add linux waitid(2) from GSoC 2023 (Theodore Preduta)
 1.261 30-Jul-2023  christos Add EPOLL_CLOEXEC (Theodore Preduta)
 1.260 29-Jul-2023  christos Add/fix statx, readahead, close_range. From GSoC 2023 by Theodore Preduta
 1.259 29-Jul-2023  rin compat/linux: aarch64 does not have epoll_create(2) nor epoll_wait(2)

Note that for Linux, new architectures like arm64 use MI system call
table in include/uapi/asm-generic/unistd.h, instead of MD syscall.tbl.

XXX
Too many ifdef's like this. We should be smarter...
 1.258 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.257 10-Jul-2023  christos Add memfd_create(2) from GSoC 2023 by Theodore Preduta
 1.256 02-Dec-2021  ryo add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32
 1.255 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.254 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.253 20-Sep-2021  thorpej Add the eventfd system calls to COMPAT_LINUX and COMPAT_LINUX32.
 1.252 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.251 11-Jun-2020  ad branches: 1.251.2;
Counter tweaks:

- Don't need to count anonpages+filepages any more; clean+unknown+dirty for
each kind of page can be summed to get the totals.

- Track the number of free pages with a counter so that it's one less thing
for the allocator to do, which opens up further options there.

- Remove cpu_count_sync_one(). It has no users and doesn't save a whole lot.
For the cheap option, give cpu_count_sync() a boolean parameter indicating
that a cached value is okay, and rate limit the updates for cached values
to hz.
 1.250 11-Jun-2020  ad uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched. It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
 1.249 03-May-2020  thorpej Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes
exist in different namespace depending on FUTEX_PRIVATE_FLAG. This appears
not to be the case in Linux, and some futex users will mix private and non-
private ops on the same futex object. Provide a convenience wrapper that
puts this logic in one place witn a comment explaining why.

While here, move the Linux futex wrapper out of its own file and plop
it in linux_misc.c, which is where it lives in the linux32 module.
 1.248 19-Apr-2020  thorpej - Only increment nprocs when we're creating a new process, not just
when allocating a PID.
- Per above, proc_free_pid() no longer decrements nprocs. It's now done
in proc_free() right after proc_free_pid().
- Ensure nprocs is accessed using atomics everywhere.
 1.247 31-Dec-2019  ad branches: 1.247.6;
Rename uvm_free() -> uvm_availmem().
 1.246 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.245 20-Sep-2019  kamil Avoid signed integer overflow when convering linux timeval to timespec

Linux accepts garbage as timeout and attempts to set it to something
meaningful. Instead of checking for valid ranges of usec, just convert
the type safely, regardless of what is inside it.
 1.244 24-Aug-2019  maxv I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.
 1.243 23-Aug-2019  maxv Fix info leaks in sysinfo().
 1.242 23-Aug-2019  maxv Fix info leaks.
 1.241 23-Aug-2019  maxv Fix info leaks.
 1.240 03-Sep-2018  riastradh branches: 1.240.4;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.239 28-Jul-2017  riastradh branches: 1.239.2; 1.239.4;
Fail, don't panic, on bad dirents from file system.

Controllable via puffs from userland.

From Ilja Van Sprundel.
 1.238 06-May-2017  joerg branches: 1.238.2;
Extend the mmap(2) interface to allow requesting protections for later
use with mprotect(2), but without enabling them immediately.

Extend the mremap(2) interface to allow duplicating mappings, i.e.
create a second range of virtual addresses references the same physical
pages. Duplicated mappings can have different effective protections.

Adjust PAX mprotect logic to disallow effective protections of W&X, but
allow one mapping W and another X protections. This obsoletes using
temporary files for purposes like JIT.

Adjust PAX logic for mmap(2) and mprotect(2) to fail if W&X is requested
and not silently drop the X protection.

Improve test cases to ensure correct operation of the changed
interfaces.
 1.237 28-Jan-2017  christos branches: 1.237.4;
copy the terminating NUL (njoly)
 1.236 13-Jan-2017  christos branches: 1.236.2;
no namlen on linux
 1.235 13-Jan-2017  christos convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
 1.234 02-Jan-2017  manu Add pselect6 Linux system call.
This lets Matlab R2016A run on NetBSD/amd64
 1.233 10-Nov-2016  christos GC WOPTSCHECKED
 1.232 31-Aug-2016  njoly Teach wait4 about WCONTINUED.
 1.231 14-Mar-2015  njoly branches: 1.231.2;
Support Linux MAP_LOCKED mmap flag.
 1.230 22-Nov-2014  njoly branches: 1.230.2;
Fix ppoll signature (int ->u_int)
 1.229 29-May-2014  njoly branches: 1.229.2; 1.229.4; 1.229.8;
For utimes(2), use compat_50_sys_utimes() instead of local version.
 1.228 18-Nov-2013  chs branches: 1.228.2;
implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.227 10-Nov-2013  slp On linux_sys_getdents, insert d_type at the end of each record.
Fixes PR kern/47806.
 1.226 24-Sep-2013  njoly Add utimensat(2) for compat linux.
 1.225 15-Sep-2013  njoly Make alpha use linux_sys_utimes() just like other archs.
 1.224 11-Aug-2013  pooka Allow to build in envs without USRSTACK (namely, rump kernels on powerpc).
TODO: all of the m*() calls are by definition incompatible with rump
kernels; including them is no great damage, but they're not useful either.
 1.223 15-Apr-2013  christos branches: 1.223.4;
alpha uses standard utimes.
 1.222 09-Apr-2013  pooka Fix COMPAT_LINUX32.
 1.221 08-Apr-2013  pooka support utimes on non-alpha linux platforms
 1.220 19-Sep-2012  pooka emulate ppoll which is essentially our pollts
 1.219 14-Oct-2011  hannken branches: 1.219.2; 1.219.8; 1.219.12; 1.219.14; 1.219.16;
Change the vnode locking protocol of VOP_GETATTR() to request at least
a shared lock. Make all calls outside of file systems respect it.

The calls from file systems need review.

No objections from tech-kern.
 1.218 02-Nov-2010  chs personality() now interprets its parameter as having
the base personality type in the low byte and
various flags in the upper bytes. for now just mask off
the flags to make sure the base type is one we accept.
store the current personality in the emuldata so that
we can return the expected value for PER_QUERY.
 1.217 11-Sep-2010  chs recent versions of linux (which we now claim to be) supply a BSD-style
d_type value in getdents() results, after the d_name field.
make our emulation do the same. fixes part of PR 43695.
 1.216 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.215 24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.214 03-Mar-2010  he branches: 1.214.2;
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.

This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.

Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.213 05-Dec-2009  pooka branches: 1.213.2;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.
 1.212 24-Nov-2009  njoly Update personality(2) to match Linux definition where the argument is an
unsigned long.
 1.211 11-Nov-2009  rmind - selcommon/pollcommon: drop redundant l argument.
- Use cached curlwp->l_fd, instead of p->p_fd.
- Inline selscan/pollscan.
 1.210 04-Nov-2009  rmind do_sys_wait(): fix previous by checking for ru != NULL. Noticed by
Onno van der Linden. Also, remove redundant arguments (seems that
was_zombie was not used since rev 1.177 ?).
 1.209 22-Jul-2009  njoly Make compat linux/linux32 getdents(2) fail with ENOTDIR instead of
EINVAL when file descriptor does not refer to a directory.
 1.208 15-May-2009  pooka pad -> PAD
 1.207 29-Mar-2009  christos Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
 1.206 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.205 19-Jan-2009  njoly branches: 1.205.2;
Small personality(2) update.
- Allow querying current personality.
- Use symbolic names instead of magic values.
 1.204 17-Jan-2009  njoly Convert linux/linux32 wait(4) to use a compat50 rusage structure.
 1.203 11-Jan-2009  christos merge christos-time_t
 1.202 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.201 24-Jun-2008  ad branches: 1.201.2; 1.201.4; 1.201.6; 1.201.10;
Replace references to getsock/getvnode.
 1.200 24-Jun-2008  gmcgarry ioctl commands are defined unsigned long, so cast cmd to unsigned long before comparison.
 1.199 28-May-2008  njoly branches: 1.199.2;
Add LINUX_TMPFS_SUPER_MAGIC, and map it to our tmpfs.
This makes sem_open/sem_unlink (POSIX named semaphores) work under
NPTL emulation.
 1.198 28-Apr-2008  martin branches: 1.198.2;
Remove clause 3 and 4 from TNF licenses
 1.197 24-Apr-2008  ad branches: 1.197.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.196 23-Apr-2008  ad Fix locking.
 1.195 04-Apr-2008  njoly branches: 1.195.2;
Cleanup. Kill linux_sys_msync and use sys___msync13 instead.
No functional changes expected.
 1.194 21-Mar-2008  ad branches: 1.194.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.193 15-Jan-2008  njoly branches: 1.193.6;
compat linux (and linux32) uid16 functions cleanup and fixes.

- Move uid16 functions to their own file linux_uid16.c, included by
needed archs (arm, i386 and m68k).
- Add new MI types linux_{u,g}id16_t.
- Add macros to handle linux_uid16_t and uid_t conversions.
- Add linux_sys_getres{uid,gid}16 syscalls, to fix an overflow with
bad sizes given to copyout when linux_sys_getres{uid,gid} are used.
- Update arm syscall table to use more uid16 functions.
 1.192 24-Dec-2007  njoly Kill unneeded linux_sys_getpgid and use native sys_getpgid instead.
 1.191 21-Dec-2007  njoly - Fix setfsuid to return uid on success.
- Replace getfsuid, which never existed on Linux, by correct setfsgid
syscall.

ok by christos and dsl.
 1.190 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.189 08-Dec-2007  dsl branches: 1.189.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.188 04-Dec-2007  dsl Remove all the __P
 1.187 26-Nov-2007  pooka branches: 1.187.2;
Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start. In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
 1.186 08-Nov-2007  njoly Replace strncpy with strlcpy in compat linux and linux32 uname,
old_uname and oldold_uname syscalls to ensure that all *utsname fields
are always NUL terminated.
 1.185 07-Nov-2007  njoly Remove remaining 64-bit compat linux syscalls linux_sys_xxx() (except
for ones without arguments), and replace them by their 32-bit
equivalent linux32_sys_xxxx().
 1.184 19-Oct-2007  njoly branches: 1.184.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.183 17-Jul-2007  joerg branches: 1.183.6; 1.183.8; 1.183.12;
Add native mremap system call based on the UVM implementation for
Linux compat. Add code to enforce alignment of the new location.
Special thanks to wizd for helping with the man page.
 1.182 04-Jul-2007  dsl It seems that min(16,16) isn't a compile time constant.
So don't bother limiting the local arrays to NGROUPS, just use 16.
 1.181 30-Jun-2007  dsl Match updates to kauth_cred_set/getgroups.
 1.180 23-Jun-2007  dsl Simplify code to get/set 16bit group lists.
Cloned from ibcs2 copy (maybe I should have worked out somewhere to put this
as common code...)
 1.179 23-Jun-2007  dsl These now need sys/prot.h
 1.178 04-Jun-2007  dsl Fix select() without a timeout parameter.
 1.177 02-Jun-2007  dsl Call selcommon() directly instead of using the stackgap...
 1.176 12-May-2007  dsl There is no need to use the stackgap for get/setrlimit.
 1.175 10-May-2007  christos - linux uname -m on x86 returns i{3,4,5,6}86 make it so.
- delete the machine sysctl that never worked, and gc linux_machine.
 1.174 08-May-2007  dsl Remember to copy the rusage to the users buffer.
 1.173 07-May-2007  dsl Split sys_wait4() so that compat code can fiddle with the returned 'status'
and 'rusage' without having to copy data to/from stackgap buffers.
The old split (find_stopped_child) could be removed.
amd64 seems to run netbsd32, linux and linux32 emulations. sparc64 compiles.
 1.172 30-Apr-2007  dsl Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.171 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.170 11-Apr-2007  njoly - Add compat amd64 linux32 statfs support, adapted from PR/35956.
- Move bsd_to_linux_statfs() function to its own file to be shared
between both linux compats.

ok by manu.
 1.169 23-Mar-2007  mrg implement emul.linux.kern.machine, which can be set to "i686", like
some applications seem to want.
 1.168 14-Mar-2007  njoly branches: 1.168.2;
Fix compat linux statfs/fstatfs syscalls on amd64.
- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.

ok by manu
 1.167 04-Mar-2007  christos branches: 1.167.2; 1.167.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.166 09-Feb-2007  ad branches: 1.166.2;
Merge newlock2 to head.
 1.165 16-Nov-2006  christos branches: 1.165.2;
__unused removal on arguments; approved by core.
 1.164 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.163 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.162 13-Sep-2006  manu branches: 1.162.2;
Jumbo COMPAT_LINUX/COMPAT_LINUX32 bugfix, with the help of Nicolas Joly
- Fix shmat return value on amd64: it uses no black magic with retval[0]
- Fix integer overflows in sysinfo
- Implement sysinfo, mmap2, sched_getparam, sched_getscheduler, mremap,
and madvise in COMPAT_LINUX32
- Fix improper types used in setgroups16/getgroups16
- Implement mmap2 for COMPAT_LINUX32
- Ifdef debug messages by DEBUG_LINUX
 1.161 01-Sep-2006  matt branches: 1.161.2;
When calling PTRACE from an LKM, use sysent[SYS_ptrace].sy_call in case
the sys_ptrace symbol isn't present.
 1.160 30-Aug-2006  he Allow this to build as an LKM by testing for _KERNEL_OPT before
including opt_ptrace.h.
 1.159 30-Aug-2006  matt Update to deal with options PTRACE
 1.158 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.157 13-Jun-2006  christos change 20 to NZERO; pointed out by mrg.
 1.156 10-Jun-2006  christos PR/33671: Nicolas Joly: Add a getpriority syscall to account for the fact
that the linux getpriority is off by 20.
 1.155 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.154 14-May-2006  elad branches: 1.154.2;
integrate kauth.
 1.153 10-May-2006  yamt don't allocate struct statvfs on stack as it's too large.
while i'm here, remove some unnecessary casts.
 1.152 17-Mar-2006  erh Fix Coverity issues 2321 and 2320. Make sure to free allocated memory.
 1.151 01-Mar-2006  yamt branches: 1.151.2; 1.151.4; 1.151.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.150 09-Feb-2006  manu Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.149 31-Jan-2006  yamt branches: 1.149.2; 1.149.4;
linux_sys_mremap: validate flags.
 1.148 21-Jan-2006  yamt implement compat_linux mremap.
 1.147 11-Dec-2005  christos branches: 1.147.2;
merge ktrace-lwp.
 1.146 30-Nov-2005  rpaulo Remove the debugging printf left in linux_sys_getrlimit().
 1.145 23-Nov-2005  manu Remove a debug printf
 1.144 23-Nov-2005  manu - Add Linux tkill and tgkill (partial emulation).
- Fix getrlimit on amd64
 1.143 07-Nov-2005  manu branches: 1.143.2;
Include linux_machdep.h so that LINUX_UNAME_ARCH ges defined (fixes
uname emulation)
 1.142 04-Nov-2005  manu Fix machine name returned by uname on Linux
 1.141 30-Oct-2005  chs add support for the linux PROT_GROWS{DOWN,UP} mprotect() flags.
fixes PR 30008.
 1.140 10-Sep-2005  jmmv branches: 1.140.2;
Initial addition of tmpfs, an efficient memory file-system. This project
was developed as part of Google's Summer of Code 2005 program. This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*. Therefore, it is disabled by
default in all kernels. However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).
 1.139 02-Jun-2005  drochner branches: 1.139.2;
more cast-qual fallout
 1.138 29-May-2005  christos - sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.137 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.136 19-Apr-2005  christos PR/29696: Joel Carnat: NetBSD freezes when accessing smbfs mounted FS with
firefox/linux due to compat getdents() call assumption that all filesystems
support cookies.
 1.135 26-Feb-2005  perry branches: 1.135.2;
nuke trailing whitespace
 1.134 13-Nov-2004  christos branches: 1.134.4; 1.134.6;
Add ptyfs magic number and entry.
 1.133 07-Oct-2004  erh PR kern/27184: Have linux_sys_waitpid() call linux_sys_wait4() so the
supported options can't get out of sync. This add support for the
linux __WCLONE and __WALL options (NetBSD version: WALTSIG and WALLSIG)
Add a diagnostic check to see if the one unhandled option (__WNOTHREAD) is
specified.
This should prevent linux processes from losing their children and creating
tons of zombie processes.
 1.132 20-Sep-2004  jdolecek implement support for Linux statfs64() syscall - 64bit variant of statfs()
 1.131 19-Sep-2004  jdolecek Adjust struct statfs content to flag that the newer Linux kernel do
provide f_frsize. It cannot be actually used to GNU C statvfs() bug
in f_frsize != f_bsize case, so just keep pretending we don't support it.
Update comments and explain the situation in detail there.
 1.130 17-Sep-2004  skrll There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.129 13-Sep-2004  jdolecek bsd_to_linux_statfs():
- filesystem size is expressed in number of fragments, not blocks;
this fixes computed filesystem sizes for Linux df(1) and other Linux
binaries using statfs(2) for filesystems, which use different value
for frament and block, such as FFS
- use FS f_namemax instead of always using MAXNAMLEN
 1.128 29-Aug-2004  jdolecek handle mmap() request with MAP_GROWSDOWN flag (request for stack-like
grow-down auto extend segment) by allocating segment sized at
current stack size limit, and offsetting requested/returned address
as required

due to how normal virtual memory management work, allocating the
full sized stack memory segment up-front actually requires exactly same
amount of VA space and physical memory as the Linux 'grow' scheme and the
'grow' scheme is quite a lot more difficult to use in applications correctly,
so it's not very apparent why Linux introduced this feature at all

this fixes Thomas Klausner's Heroes3 crash, and might also
fix PR 26687 by Jan Schaumann
 1.127 08-Aug-2004  jdolecek linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads
 1.126 01-Aug-2004  jdolecek Linux returns ENOMEM (not EFAULT) if the address specified in mprotect()
is not part of process address space

this fixes Linux libgcc_s's stack executability setup
 1.125 21-Apr-2004  christos fix more statvfs1 fallout
 1.124 21-Apr-2004  christos s/statvfs/statvfs1/
 1.123 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.122 04-Dec-2003  atatat branches: 1.122.2;
Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.121 29-Jun-2003  fvdl branches: 1.121.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.120 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.119 23-Jun-2003  christos PR/21948: Todd Vierling: Implement MAP_TRYFIXED for linux emulation.
 1.118 23-Jun-2003  christos PR/21937: Todd Vierling: Proper support for mmap2
 1.117 05-Mar-2003  dsl Use do_setresuid() to implement linux_sys_setresuid()
 1.116 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.115 16-Dec-2002  christos branches: 1.115.2;
Don't allow non-page-aligned offsets! So dumb. From Jason Ish, thanks.
 1.114 25-Nov-2002  thorpej Add ULL to a 64-bit integer constant.
 1.113 13-Nov-2002  jdolecek we now export information about CLK_TCK via ELF aux args, no need to
hardcode '100' for times(2) anymore; use 'hz' instead
 1.112 13-Nov-2002  jdolecek linux_sys_times(): if tms is NULL, just return the number of ticks since
boot, don't error out; this matches what Linux does

Fixes problem reported in kern/19027
 1.111 23-Sep-2002  simonb Put storage class first in "static const" declaration.
 1.110 20-Jun-2002  enami Don't copy from destination to destination.
 1.109 10-May-2002  tron branches: 1.109.2; 1.109.4;
Fix off by one error in check for size of field "d_off" in Linux
"dirent" structure.
 1.108 10-May-2002  tron Move implementation of linux_sys_getdents64() to source file for
Linux 64bit filesystem calls.
 1.107 10-Apr-2002  christos implement getdents64; my full java tree builds now.
 1.106 03-Apr-2002  fvdl Allocate the right size for the native gid_t array in setgroups16.
 1.105 31-Mar-2002  christos make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.104 22-Mar-2002  christos gc debugging printfs.
 1.103 22-Mar-2002  christos nuke mmap2, cleanup mmap, add mprotect
 1.102 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.101 20-Feb-2002  christos proper statfs emulation...
 1.100 18-Feb-2002  christos Resolve alpha compile issues:
- bug with order in args in mask conversion md code.
- flags can be both int and long on the alpha. kludge around that, by not
passing pointers to the conversion function.
- something is wrong with the toolchain look at the void * cast in copyout().
- sa_restorer is in a different place on the aplha. Deal with that, by not
initializing it as before. XXX: this should be changed in the MD signal
definition.
 1.99 18-Feb-2002  jdolecek Back off previous partially - make linux_release[] back 2.0.38
and linux_version[] "#0 Sun Apr 1 11:11:11 MET 2000";". Add a BIG
WARNING MESSAGE so that people won't break things changing this.
 1.98 17-Feb-2002  rafal There is no linux_sys_ugetrlimit on mips, so don't try building it (XXX: adds
icky ifdefs)
 1.97 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.96 09-Dec-2001  chs replace "vnode" and "vtext" with "file" and "exec" in uvmexp field names.
 1.95 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.94 08-Sep-2001  manu Removed a hack to make PowerPC mmap work. This could have side effects on
alpha and i386. It has been tested and works on i386.
 1.93 18-Jul-2001  thorpej branches: 1.93.2;
Add support for the __WALL wait4(2) flag.
 1.92 04-Jun-2001  manu branches: 1.92.2;
Fixes by Chuck Silvers to make ptrace PEEKTEXT more 64 bit friendy
 1.91 03-Jun-2001  manu added a double cast to build on alpha
 1.90 02-Jun-2001  jdolecek Slighly improve the PTRACE_CONT comment
 1.89 27-May-2001  manu Fixed the return value of ptrace for PEEKTEXT and PEEKDATA: return value must
be a pointer to data, which holds the result. Linux's glibc undo this odd
operation to bring the standard ptrace behavior to userland.
 1.88 20-May-2001  manu Added powerpc status in a comment
 1.87 30-Mar-2001  jdolecek Implement linux_sys_nosys() and use it instead of sys_nosys() for
unimplemented syscalls. Difference is that linux_sys_nosys() doesn't
post SIGSYS to the process. Linux doesn't do that and thus glibc (and
probably other Linux code) doesn't deal with SIGSYS, even through it
generally contains fallback code for ENOSYS case.

This also addresses port-i386/12503, though the issue was already discussed
earlier.
 1.86 16-Mar-2001  manu Removed an unused oldbrk variable in linux_sys_brk()
 1.85 15-Mar-2001  manu Made linux_sys_brk() cleaner (no functionnality change)
 1.84 15-Mar-2001  manu Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.
 1.83 05-Jan-2001  fvdl branches: 1.83.2;
Set Linux version to 2.0.38 for now, until the clone + "real time signal"
problems are fixed.
 1.82 29-Dec-2000  fvdl Hardcode what the linux uname() calls return (Linux 2.2.5 is the current
value). A few major applications check for this (like VMware), and
there is no other way to trick them. Needs a more generic solution
eventually.
 1.81 27-Dec-2000  fvdl Use CHECK_ALT_* for chown and lchown, missed in my previous commit.
Get *id16 calls right; most can be passed through directly, but
some need the 16->32 check for -1 values.
 1.80 22-Dec-2000  jdolecek split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.79 21-Dec-2000  thorpej Only include the 16-bit uid/gid stuff if on i386 or m68k. This is a
little ugly, but hey, so is Linux.
 1.78 18-Dec-2000  fvdl Add seperate entries for 16 bit uid/gid calls, so that border cases
like 0xffff can be handled better (not done yet).
 1.77 13-Dec-2000  augustss Implement sysinfo.
 1.76 02-Dec-2000  jdolecek add emulation of linux swapoff(2)
 1.75 01-Dec-2000  jdolecek implement linux_sys_setdomainname()/linux_sys_swapon(), using code
from compat_09_sys_setdomainname()/compat_12_sys_swapon().
 1.74 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.73 01-Nov-2000  jdolecek Linux LINUX_PTRACE_SINGLESTEP operation should have same
semantics as NetBSD's PT_STEP, so support it on archs which have it
under Linux, ptrace(PTRACE_CONT, pid, 0, 0) is used to continue the
traced process where it left off; adjust addr to (caddr_t) 1 so that
the NetBSD syscall code DTRT
some sligh const poisoning
 1.72 07-Sep-2000  fvdl In the case of MAP_ANON, Linux mmap ignores the fd argument completely.
So, always pass -1 to the native syscall in that case, to avoid
errors if a Linux app doesn't specify -1 as the fd (which some do).
 1.71 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.70 26-Jun-2000  mrg remove redundant vm includes.
 1.69 30-Mar-2000  augustss branches: 1.69.4;
Kill register declarations.
 1.68 28-Mar-2000  simonb Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
 1.67 18-Mar-2000  erh Add linux_sys_reboot.
 1.66 18-Mar-2000  erh Adjust linux_sys_ptrace_args to reflect inconsistencies across ports. Temporarily ifndef alpha around getfsuid since Linux/alpha doesn't seem to have it.
 1.65 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.64 17-Feb-2000  abs Update patch from Witold Wnuk in PR 9335 to solve potential security
issue noted by tls.
 1.63 03-Feb-2000  abs Add Linux fsuid system calls - from Witold J. Wnuk in PR kern/9335
 1.62 16-Dec-1999  tron Move MI parts of ptrace(2) emulation to "linux_misc.c".
 1.61 05-Oct-1999  tron branches: 1.61.2; 1.61.8;
After linux_sys_clone() has been moved to "linux_sched.c" we don't need
to include "linux_sched.h" any more.
 1.60 04-Oct-1999  tron Add emulation for scheduler related syscalls. Although they are dummies
even under Linux the posix thread library for "glibc2" requires them.
 1.59 15-Jul-1999  thorpej A few things to make the Linux clone(2) emulation work a bit better:
- When the exit signal is specified to be 0, don't just assume they
meant SIGCHLD. In the Linux world, this appears to mean "don't deliver
an exit signal at all".
- Simplify P_EXITSIG(); don't check against initproc here, just change
the exit signal to SIGCHLD if reparenting to initproc.

A very simple clone(2) test program now works, and the MpegTV package
starts, but doesn't run properly yet (I believe there is a separate
bug which keeps it from working properly).
 1.58 17-May-1999  thorpej Oops, completely forgot to translate the exit signal in clone(2).
 1.57 14-May-1999  thorpej Emulate the Linux {get,set}resuid(2) system calls.
 1.56 13-May-1999  thorpej Emulate the Linux clone(2) system call.
 1.55 13-May-1999  thorpej Fully emulate the Linux wait4(2) system call, including the __WCLONE
flag (which is equivalent to our new WALTSIG).
 1.54 05-May-1999  thorpej Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
 1.53 09-Feb-1999  christos branches: 1.53.2; 1.53.4;
const poisoning.
 1.52 16-Dec-1998  christos more defensive signal conversion, and fix a malloc sizeof(int) to sizeof(int *).
 1.51 04-Oct-1998  fvdl Fix pointer fuckup that made getdents() stop working.
 1.50 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.49 03-Oct-1998  christos Attempt to fix the mess.
 1.48 01-Oct-1998  perry Add braces to shut up egcs
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.53.4.2 02-Aug-1999  thorpej Update from trunk.
 1.53.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.53.2.1 15-Aug-2000  he Pull up revision 1.63 (requested by abs):
Enable basic versions of Linux fsuid calls.
 1.61.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.61.2.6 21-Apr-2001  bouyer Sync with HEAD
 1.61.2.5 27-Mar-2001  bouyer Sync with HEAD.
 1.61.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.61.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.61.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.61.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.69.4.3 01-May-2001  he Pull up revision 1.87 (via patch, requested by jdolecek):
Make it possible to use a different function for unimplemented
syscalls than sys_nosys(), so that the Linux emulation can avoid
posting SIGSYS and instead just return ENOSYS.
 1.69.4.2 30-Mar-2001  he Pull up revisions 1.82-1.83 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.69.4.1 11-Sep-2000  fvdl Pull up revision 1.72:
In the case of MAP_ANON, Linux mmap ignores the fd argument completely.
So, always pass -1 to the native syscall in that case, to avoid
errors if a Linux app doesn't specify -1 as the fd (which some do).

approved by thorpej
 1.83.2.21 19-Dec-2002  thorpej Sync with HEAD.
 1.83.2.20 11-Dec-2002  thorpej Sync with HEAD.
 1.83.2.19 18-Oct-2002  nathanw Catch up to -current.
 1.83.2.18 01-Aug-2002  nathanw Catch up to -current.
 1.83.2.17 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.83.2.16 08-Jul-2002  nathanw Whitespace.
 1.83.2.15 20-Jun-2002  nathanw Catch up to -current.
 1.83.2.14 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.83.2.13 17-Apr-2002  nathanw LWPify.
 1.83.2.12 17-Apr-2002  nathanw Catch up to -current.
 1.83.2.11 01-Apr-2002  nathanw LWPify linux_sys_mprotect().
 1.83.2.10 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.83.2.9 28-Feb-2002  nathanw LWPify linux_{set/get}rlimit(); move and LWPify linux_sysctl().
 1.83.2.8 28-Feb-2002  nathanw Catch up to -current.
 1.83.2.7 08-Jan-2002  nathanw Catch up to -current.
 1.83.2.6 14-Nov-2001  nathanw Catch up to -current.
 1.83.2.5 21-Sep-2001  nathanw Catch up to -current.
 1.83.2.4 24-Aug-2001  nathanw Catch up with -current.
 1.83.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.83.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.83.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.92.2.7 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.92.2.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.92.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.92.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.92.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.92.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.92.2.1 03-Aug-2001  lukem update to -current
 1.93.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.109.4.5 26-Oct-2003  jmc Pullup rev 1.119 (ticket #1428)

Implement MAP_TRYFIXED for linux emulation.
 1.109.4.4 22-Oct-2003  jmc Pullup rev 1.118 (via patch) (requested by tv in ticket #1427)

Proper support for mmap2
 1.109.4.3 22-Oct-2003  jmc Pullup rev 115 (requested by tv in ticket #1426)

Don't allow non-page-aligned offsets.
 1.109.4.2 12-Dec-2002  he Pull up revision 1.112 (requested by jdolecek in ticket #987):
Correct linux_sys_times(): if tms is NULL, just return the
number of ticks since boot instead of returning error; this
matches what Linux does. Fixes PR#19027.
 1.109.4.1 21-Jun-2002  lukem Pull up revision 1.110 (requested by enami in ticket #331):
Don't copy from destination to destination.

[Fixes setrlimit in linux emulation]
 1.109.2.1 15-Jul-2002  gehenna catch up with -current.
 1.115.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.121.2.12 11-Dec-2005  christos Sync with head.
 1.121.2.11 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.121.2.10 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.121.2.9 14-Nov-2004  skrll Sync with HEAD.
 1.121.2.8 19-Oct-2004  skrll Sync with HEAD
 1.121.2.7 24-Sep-2004  skrll Sync with HEAD.
 1.121.2.6 21-Sep-2004  skrll Fix the sync with head I botched.
 1.121.2.5 18-Sep-2004  skrll Sync with HEAD.
 1.121.2.4 03-Sep-2004  skrll Sync with HEAD
 1.121.2.3 12-Aug-2004  skrll Sync with HEAD.
 1.121.2.2 03-Aug-2004  skrll Sync with HEAD
 1.121.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.122.2.4 12-Nov-2004  jmc Pullup rev 1.133 (requested by christos in ticket #950)

Prevent linux processes from losing their children and creating
tons of zombie processes.
 1.122.2.3 05-Sep-2004  tron Pull up revision 1.128 (requested by jdolecek in ticket #810):
handle mmap() request with MAP_GROWSDOWN flag (request for stack-like
grow-down auto extend segment) by allocating segment sized at
current stack size limit, and offsetting requested/returned address
as required
due to how normal virtual memory management work, allocating the
full sized stack memory segment up-front actually requires exactly same
amount of VA space and physical memory as the Linux 'grow' scheme and the
'grow' scheme is quite a lot more difficult to use in applications correctly,
so it's not very apparent why Linux introduced this feature at all
this fixes Thomas Klausner's Heroes3 crash, and might also
fix PR 26687 by Jan Schaumann
 1.122.2.2 15-Aug-2004  tron Pull up revision 1.127 (requested by jdolecek in ticket #762):
linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size
this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads
 1.122.2.1 11-Aug-2004  jmc Pullup rev 1.126 (requested by jdolecek in ticket #740)

Linux returns ENOMEM (not EFAULT) if the address specified in mprotect()
is not part of process address space.
 1.134.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.134.4.1 29-Apr-2005  kent sync with -current
 1.135.2.2 01-Nov-2005  tron Pull up following revision(s) (requested by chs in ticket #924):
sys/compat/linux/common/linux_misc.c: revision 1.141
sys/compat/linux/common/linux_mmap.h: revision 1.17
add support for the linux PROT_GROWS{DOWN,UP} mprotect() flags.
fixes PR 30008.
 1.135.2.1 01-Oct-2005  tron Pull up following revision(s) (requested by christos in ticket #838):
sys/compat/svr4/svr4_misc.c: revision 1.112
sys/compat/ibcs2/ibcs2_misc.c: revision 1.74
sys/compat/linux/common/linux_misc.c: revision 1.136
sys/compat/irix/irix_dirent.c: revision 1.14
sys/compat/sunos/sunos_misc.c: revision 1.132
sys/compat/svr4_32/svr4_32_misc.c: revision 1.31
sys/compat/sunos32/sunos32_misc.c: revision 1.30
sys/compat/linux/common/linux_file64.c: revision 1.26
PR/29696: Joel Carnat: NetBSD freezes when accessing smbfs mounted FS with
firefox/linux due to compat getdents() call assumption that all filesystems
support cookies.
 1.139.2.9 24-Mar-2008  yamt sync with head.
 1.139.2.8 21-Jan-2008  yamt sync with head
 1.139.2.7 07-Dec-2007  yamt sync with head
 1.139.2.6 15-Nov-2007  yamt sync with head.
 1.139.2.5 27-Oct-2007  yamt sync with head.
 1.139.2.4 03-Sep-2007  yamt sync with head.
 1.139.2.3 26-Feb-2007  yamt sync with head.
 1.139.2.2 30-Dec-2006  yamt sync with head.
 1.139.2.1 21-Jun-2006  yamt sync with head.
 1.140.2.1 02-Nov-2005  yamt sync with head.
 1.143.2.1 29-Nov-2005  yamt sync with head.
 1.147.2.3 18-Feb-2006  yamt sync with head.
 1.147.2.2 01-Feb-2006  yamt sync with head.
 1.147.2.1 31-Dec-2005  yamt adapt some random parts of kernel to uio_vmspace.
 1.149.4.3 01-Jun-2006  kardel Sync with head.
 1.149.4.2 22-Apr-2006  simonb Sync with head.
 1.149.4.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.149.2.1 09-Sep-2006  rpaulo sync with head
 1.151.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.151.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.151.4.6 11-May-2006  elad sync with head
 1.151.4.5 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.151.4.4 19-Apr-2006  elad sync with head.
 1.151.4.3 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.151.4.2 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.151.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.151.2.6 14-Sep-2006  yamt sync with head.
 1.151.2.5 03-Sep-2006  yamt sync with head.
 1.151.2.4 11-Aug-2006  yamt sync with head
 1.151.2.3 26-Jun-2006  yamt sync with head.
 1.151.2.2 24-May-2006  yamt sync with head.
 1.151.2.1 01-Apr-2006  yamt sync with head.
 1.154.2.1 19-Jun-2006  chap Sync with head.
 1.161.2.4 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.161.2.3 29-Dec-2006  ad Checkpoint work in progress.
 1.161.2.2 18-Nov-2006  ad Sync with head.
 1.161.2.1 24-Oct-2006  ad - Redo LWP locking slightly and fix some races.
- Fix some locking botches.
- Make signal mask / stack per-proc for SA processes.
- Add _lwp_kill().
 1.162.2.2 10-Dec-2006  yamt sync with head.
 1.162.2.1 22-Oct-2006  yamt sync with head
 1.165.2.3 12-Jun-2010  riz Pull up following revision(s) (requested by he in ticket #1387):
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/osf1/osf1_file.c: revision 1.38
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.165.2.2 20-Apr-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #582):
sys/compat/linux32/common/linux32_types.h: revision 1.4 via patch
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.14 via patch
sys/compat/linux/common/linux_statfs.h: revision 1.1 via patch
sys/compat/linux/common/linux_misc.c: revision 1.170 via patch
sys/compat/linux32/common/linux32_misc.c: revision 1.5 via patch
sys/compat/linux32/files.linux32: revision 1.4 via patch
- Add compat amd64 linux32 statfs support, adapted from PR/35956.
- Move bsd_to_linux_statfs() function to its own file to be shared
between both linux compats.
 1.165.2.1 20-Apr-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #581):
sys/compat/linux/common/linux_misc.c: revision 1.168
sys/compat/linux/arch/amd64/syscalls.master: revision 1.18
sys/compat/linux/common/linux_types.h: revision 1.25
sys/compat/linux/arch/amd64/linux_machdep.h: revision 1.6
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.87
Fix compat linux statfs/fstatfs syscalls on amd64.
- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.
 1.166.2.5 17-May-2007  yamt sync with head.
 1.166.2.4 07-May-2007  yamt sync with head.
 1.166.2.3 15-Apr-2007  yamt sync with head.
 1.166.2.2 24-Mar-2007  yamt sync with head.
 1.166.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.167.4.1 11-Jul-2007  mjf Sync with head.
 1.167.2.5 20-Aug-2007  ad Sync with HEAD.
 1.167.2.4 15-Jul-2007  ad Sync with head.
 1.167.2.3 09-Jun-2007  ad Sync with head.
 1.167.2.2 27-May-2007  ad Sync with head.
 1.167.2.1 10-Apr-2007  ad Sync with head.
 1.168.2.1 29-Mar-2007  reinoud Pullup to -current
 1.183.12.2 13-Nov-2007  bouyer Sync with HEAD
 1.183.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.183.8.4 23-Mar-2008  matt sync with HEAD
 1.183.8.3 09-Jan-2008  matt sync with HEAD
 1.183.8.2 08-Nov-2007  matt sync with -HEAD
 1.183.8.1 06-Nov-2007  matt sync with HEAD
 1.183.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.183.6.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.183.6.2 11-Nov-2007  joerg Sync with HEAD.
 1.183.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.184.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.184.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.184.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.184.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.187.2.2 26-Dec-2007  ad Sync with head.
 1.187.2.1 08-Dec-2007  ad Sync with head.
 1.189.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.189.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.193.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.193.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.193.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.193.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.194.2.3 20-Nov-2008  christos merge with head.
 1.194.2.2 01-Nov-2008  christos Sync with head.
 1.194.2.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.195.2.2 04-Jun-2008  yamt sync with head
 1.195.2.1 18-May-2008  yamt sync with head.
 1.197.2.7 09-Oct-2010  yamt sync with head
 1.197.2.6 11-Aug-2010  yamt sync with head.
 1.197.2.5 11-Mar-2010  yamt sync with head
 1.197.2.4 19-Aug-2009  yamt sync with head.
 1.197.2.3 16-May-2009  yamt sync with head
 1.197.2.2 04-May-2009  yamt sync with head.
 1.197.2.1 16-May-2008  yamt sync with head.
 1.198.2.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.198.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.198.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.198.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.199.2.1 27-Jun-2008  simonb Sync with head.
 1.201.10.1 21-Apr-2010  matt sync to netbsd-5
 1.201.6.1 17-Mar-2010  snj Pull up following revision(s) (requested by he in ticket #1323):
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.201.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.201.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.201.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.201.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.205.2.2 23-Jul-2009  jym Sync with HEAD.
 1.205.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.213.2.4 06-Nov-2010  uebayasi Sync with HEAD.
 1.213.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.213.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.213.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.214.2.2 05-Mar-2011  rmind sync with head
 1.214.2.1 03-Jul-2010  rmind sync with head
 1.219.16.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.219.14.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.219.12.4 03-Dec-2017  jdolecek update from HEAD
 1.219.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.219.12.2 23-Jun-2013  tls resync from head
 1.219.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.219.8.2 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.219.8.1 14-Dec-2013  bouyer Pull up following revision(s) (requested by hauke in ticket #993):
sys/compat/linux/common/linux_misc.c: revision 1.227
On linux_sys_getdents, insert d_type at the end of each record.
Fixes PR kern/47806.
 1.219.2.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.219.2.1 30-Oct-2012  yamt sync with head
 1.223.4.2 18-May-2014  rmind sync with head
 1.223.4.1 28-Aug-2013  rmind sync with head
 1.228.2.1 10-Aug-2014  tls Rebase.
 1.229.8.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.229.8.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.229.4.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.229.2.3 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.229.2.2 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.229.2.1 17-Apr-2017  snj Pull up following revision(s) (requested by manu in ticket #1354):
sys/compat/linux/arch/alpha/syscalls.master: revision 1.92 via patch
sys/compat/linux/arch/amd64/syscalls.master: revision 1.58 via patch
sys/compat/linux/arch/arm/syscalls.master: revision 1.65 via patch
sys/compat/linux/arch/i386/syscalls.master: revision 1.122 via patch
sys/compat/linux/arch/m68k/syscalls.master: revision 1.91 via patch
sys/compat/linux/arch/mips/syscalls.master: revision 1.61 via patch
sys/compat/linux/arch/powerpc/syscalls.master: revision 1.70 via patch
sys/compat/linux/common/linux_misc.c: revision 1.234
sys/compat/linux/common/linux_signal.h: revision 1.31
Add pselect6 Linux system call.
This lets Matlab R2016A run on NetBSD/amd64
 1.230.2.5 28-Aug-2017  skrll Sync with HEAD
 1.230.2.4 05-Feb-2017  skrll Sync with HEAD
 1.230.2.3 05-Dec-2016  skrll Sync with HEAD
 1.230.2.2 05-Oct-2016  skrll Sync with HEAD
 1.230.2.1 06-Apr-2015  skrll Sync with HEAD
 1.231.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.231.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.236.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.237.4.1 11-May-2017  pgoyette Sync with HEAD
 1.238.2.3 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.238.2.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.238.2.1 09-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #193):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.239.4.4 21-Apr-2020  martin Sync with HEAD
 1.239.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.239.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.239.4.1 10-Jun-2019  christos Sync with HEAD
 1.239.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.240.4.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.240.4.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.247.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.251.2.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.264.2.1 02-Aug-2025  perseant Sync with HEAD
 1.34 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.33 29-Jun-2024  christos branches: 1.33.2;
From gsoc 2024: Implement faccessat2 and getcpu (Shivraz)
 1.32 12-May-2024  christos Add forward decl for procfs include.
 1.31 12-May-2024  christos fix whitespace
 1.30 12-May-2024  christos PR/58240: Ricardo Branco: Add missing limits
 1.29 18-Aug-2023  christos Add linux waitid(2) from GSoC 2023 (Theodore Preduta)
 1.28 29-Jul-2023  rin Add comment on packed attribution for struct linux_epoll_event on amd64.
NFC.
 1.27 28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.26 03-May-2020  thorpej Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes
exist in different namespace depending on FUTEX_PRIVATE_FLAG. This appears
not to be the case in Linux, and some futex users will mix private and non-
private ops on the same futex object. Provide a convenience wrapper that
puts this logic in one place witn a comment explaining why.

While here, move the Linux futex wrapper out of its own file and plop
it in linux_misc.c, which is where it lives in the linux32 module.
 1.25 31-Aug-2016  njoly Teach wait4 about WCONTINUED.
 1.24 18-Nov-2013  chs branches: 1.24.6;
implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.23 22-Sep-2012  joerg branches: 1.23.2;
LINUX_RLIM_INFINITY doesn't fit into the value range for linux32, so
introduce a variant with correct value.
 1.22 13-Sep-2012  pooka Rename structure members to make the code compile in environments
where "linux" is #defined.
 1.21 30-May-2011  alnsn branches: 1.21.4; 1.21.14;
Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.20 02-Nov-2010  chs branches: 1.20.2;
personality() now interprets its parameter as having
the base personality type in the low byte and
various flags in the upper bytes. for now just mask off
the flags to make sure the base type is one we accept.
store the current personality in the emuldata so that
we can return the expected value for PER_QUERY.
 1.19 19-Jan-2009  njoly branches: 1.19.4; 1.19.6;
Small personality(2) update.
- Allow querying current personality.
- Use symbolic names instead of magic values.
 1.18 11-Jan-2009  christos merge christos-time_t
 1.17 28-May-2008  njoly branches: 1.17.6;
Add LINUX_TMPFS_SUPER_MAGIC, and map it to our tmpfs.
This makes sem_open/sem_unlink (POSIX named semaphores) work under
NPTL emulation.
 1.16 28-Apr-2008  martin branches: 1.16.2;
Remove clause 3 and 4 from TNF licenses
 1.15 04-Dec-2007  dsl branches: 1.15.12; 1.15.14; 1.15.16; 1.15.18;
Remove all the __P
 1.14 07-May-2007  dsl branches: 1.14.6; 1.14.8; 1.14.14; 1.14.16;
Split sys_wait4() so that compat code can fiddle with the returned 'status'
and 'rusage' without having to copy data to/from stackgap buffers.
The old split (find_stopped_child) could be removed.
amd64 seems to run netbsd32, linux and linux32 emulations. sparc64 compiles.
 1.13 11-Dec-2005  christos branches: 1.13.26; 1.13.30; 1.13.32;
merge ktrace-lwp.
 1.12 03-May-2005  manu branches: 1.12.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.11 13-Nov-2004  christos Add ptyfs magic number and entry.
 1.10 07-Oct-2004  erh PR kern/27184: Have linux_sys_waitpid() call linux_sys_wait4() so the
supported options can't get out of sync. This add support for the
linux __WCLONE and __WALL options (NetBSD version: WALTSIG and WALLSIG)
Add a diagnostic check to see if the one unhandled option (__WNOTHREAD) is
specified.
This should prevent linux processes from losing their children and creating
tons of zombie processes.
 1.9 20-Sep-2004  jdolecek implement support for Linux statfs64() syscall - 64bit variant of statfs()
 1.8 18-Jan-2003  thorpej branches: 1.8.2; 1.8.4;
Merge the nathanw_sa branch.
 1.7 20-Feb-2002  christos proper statfs emulation...
 1.6 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.5 18-Jul-2001  thorpej Add support for the __WALL wait4(2) flag.
 1.4 13-Dec-2000  augustss branches: 1.4.2; 1.4.4;
Implement sysinfo.
 1.3 13-May-1999  thorpej branches: 1.3.2;
Define the flags used by the Linux wait4() system call.
 1.2 03-Oct-1998  christos branches: 1.2.8;
Attempt to fix the mess.
 1.1 01-Oct-1998  erh Add a couple function prototypes from linux_misc.c.
 1.2.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.4.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.1 03-Aug-2001  lukem update to -current
 1.4.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.4.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.8.4.1 12-Nov-2004  jmc Pullup rev 1.10 (requested by christos in ticket #950)

Prevent linux processes from losing their children and creating
tons of zombie processes.
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.3 14-Nov-2004  skrll Sync with HEAD.
 1.8.2.2 19-Oct-2004  skrll Sync with HEAD
 1.8.2.1 24-Sep-2004  skrll Sync with HEAD.
 1.12.2.2 07-Dec-2007  yamt sync with head
 1.12.2.1 03-Sep-2007  yamt sync with head.
 1.13.32.1 11-Jul-2007  mjf Sync with head.
 1.13.30.1 27-May-2007  ad Sync with head.
 1.13.26.1 17-May-2007  yamt sync with head.
 1.14.16.1 08-Dec-2007  ad Sync with head.
 1.14.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.14.8.1 09-Jan-2008  matt sync with HEAD
 1.14.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.15.18.2 04-May-2009  yamt sync with head.
 1.15.18.1 16-May-2008  yamt sync with head.
 1.15.16.2 04-Jun-2008  yamt sync with head
 1.15.16.1 18-May-2008  yamt sync with head.
 1.15.14.2 01-Nov-2008  christos Sync with head.
 1.15.14.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.15.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.15.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.6.2 03-Mar-2009  skrll Sync with HEAD.
 1.17.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.6.2 31-May-2011  rmind sync with head
 1.19.6.1 05-Mar-2011  rmind sync with head
 1.19.4.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.20.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.14.3 03-Dec-2017  jdolecek update from HEAD
 1.21.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.4.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.21.4.1 30-Oct-2012  yamt sync with head
 1.23.2.1 18-May-2014  rmind sync with head
 1.24.6.1 05-Oct-2016  skrll Sync with HEAD
 1.33.2.1 02-Aug-2025  perseant Sync with HEAD
 1.115 22-May-2022  andvar fix various small typos, mainly in comments.
 1.114 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.113 23-Sep-2021  christos remove stray char.
 1.112 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.111 04-Dec-2020  thorpej Rewrite linux_sys_alarm() to use dogetitimer() / dosetitimer(), rather
than fiddling with process timers directly.
 1.110 29-Nov-2018  maxv branches: 1.110.12;
Improve my kern_time.c::rev1.192, systematically clear the buffers we get
from 'ptimer_pool' to prevent more leaks.
 1.109 09-Nov-2014  maxv branches: 1.109.12; 1.109.18; 1.109.20;
Do not uselessly include <sys/malloc.h>.
 1.108 02-Nov-2010  chs branches: 1.108.18; 1.108.34;
implement the following syscalls for linux32:
truncate64
ftruncate64
profil
ioperm
iopl
setdomainname
modify_ldt
statfs64
fstatfs64

note that iopl(), ioperm() and modify_ldt() just call
the respective 64-bit handlers, which don't do anything yet.
 1.107 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.106 02-Jun-2009  njoly branches: 1.106.2; 1.106.4;
Make nice(2) return EPERM on error, not EACCES (from sys_setpriority).
 1.105 29-Dec-2008  njoly branches: 1.105.2;
Fix stime(2) inverted copyin arguments.
 1.104 03-Oct-2008  njoly branches: 1.104.2;
Compat linux/linux32 nice(2) fix. The syscall argument is an increment
to be added to the current nice value, not an absolute value to be
set.
 1.103 15-Jul-2008  christos Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
 1.102 28-Apr-2008  martin branches: 1.102.2; 1.102.4; 1.102.6;
Remove clause 3 and 4 from TNF licenses
 1.101 21-Apr-2008  ad branches: 1.101.2;
timer fixes for PR 37093:

- Fix serious concurrency problems, making the code MT and MP safe in
the process.
- Don't allocate memory or inspect process state from hardclock().
 1.100 26-Dec-2007  njoly branches: 1.100.6; 1.100.8;
Fix readdir syscall retval to return 1 (instead of getdents number of
byte read) on success.
 1.99 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.98 08-Dec-2007  dsl branches: 1.98.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.97 25-Nov-2007  elad branches: 1.97.2;
Refactor time modification checks and place them in the secmodel code.

okay christos@
 1.96 07-Nov-2007  njoly Remove remaining 64-bit compat linux syscalls linux_sys_xxx() (except
for ones without arguments), and replace them by their 32-bit
equivalent linux32_sys_xxxx().
 1.95 19-Oct-2007  njoly branches: 1.95.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.94 09-Jul-2007  ad branches: 1.94.6; 1.94.8; 1.94.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.93 23-Jun-2007  dsl These now need sys/prot.h
 1.92 12-May-2007  dsl Change the compat sys_[fl]utime code to not use the stackgap.
 1.91 30-Apr-2007  dsl Include extra header (vfs_syscalls.h).
 1.90 30-Apr-2007  dsl Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.89 23-Apr-2007  christos avoid zerodivide.
 1.88 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.87 14-Mar-2007  njoly Fix compat linux statfs/fstatfs syscalls on amd64.
- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.

ok by manu
 1.86 04-Mar-2007  christos branches: 1.86.2; 1.86.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.85 09-Feb-2007  ad branches: 1.85.2;
Merge newlock2 to head.
 1.84 16-Nov-2006  christos branches: 1.84.2;
__unused removal on arguments; approved by core.
 1.83 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.82 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.81 23-Jul-2006  ad branches: 1.81.4; 1.81.6;
Use the LWP cached credentials where sane.
 1.80 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.79 14-May-2006  elad branches: 1.79.2;
integrate kauth.
 1.78 10-May-2006  yamt don't allocate struct statvfs on stack as it's too large.
while i'm here, remove some unnecessary casts.
 1.77 09-Feb-2006  manu branches: 1.77.2; 1.77.4; 1.77.6;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.76 11-Dec-2005  christos branches: 1.76.2; 1.76.4; 1.76.6;
merge ktrace-lwp.
 1.75 05-Dec-2005  christos - make settime take timespec.
- avoid wrapping of time in settime.
- pass struct proc down so that we can log a detailed message.
 1.74 03-May-2005  manu branches: 1.74.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.73 26-Feb-2005  perry nuke trailing whitespace
 1.72 07-Oct-2004  erh branches: 1.72.4; 1.72.6;
PR kern/27184: Have linux_sys_waitpid() call linux_sys_wait4() so the
supported options can't get out of sync. This add support for the
linux __WCLONE and __WALL options (NetBSD version: WALTSIG and WALLSIG)
Add a diagnostic check to see if the one unhandled option (__WNOTHREAD) is
specified.
This should prevent linux processes from losing their children and creating
tons of zombie processes.
 1.71 24-Sep-2004  he Since the implementation of bsd_to_linux_statfs64() is conditional,
also make the forward declaration conditional. Fixes compile
problem for m68k ports.
 1.70 20-Sep-2004  jdolecek implement support for Linux statfs64() syscall - 64bit variant of statfs()
 1.69 29-Jun-2003  fvdl branches: 1.69.2; 1.69.4;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.68 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.67 05-Mar-2003  dsl Reimplement linux_sys_setresgid() in terms of do_setresgid()
 1.66 23-Feb-2003  enami Remember the allocated ptimer object so that it won't leak.
 1.65 19-Feb-2003  jdolecek update emul alarm syscalls to recent timer changes

problem encountered by Luke Mewburn for linux emul, problem spot
found by Enami Tsugutomo
 1.64 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.63 03-Apr-2002  tron branches: 1.63.6;
Fix a cut and paste error in the emulation of getresgid(2): it returned
the effective user id as effective group id.
 1.62 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.61 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.60 22-Dec-2000  jdolecek branches: 1.60.2; 1.60.4;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.59 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.58 29-Aug-2000  sommerfeld Emulation stackgap sanity checks, based partly on fixes from
FreeBSD-SA00:42.

Change stackgap_alloc to bounds-check the allocation vs. the stack
gap, returning NULL if there isn't room for the allocation.

Change emul_find() to check for a NULL return from stackgap_alloc()
and convert that into ENAMETOOLONG.

Reorder various emulation syscalls so that all *_CHECK_ALT_{EXIST,CREAT}
calls (which turn into emul_find() under the covers come *after* small,
fixed-size stackgap_alloc() calls.

Clean up ibcs2 {get,set}groups.
 1.57 07-Aug-2000  itohy Add #include <sys/proc.h>, since this file touches members of struct proc.
 1.56 13-Jul-2000  thorpej Add a comment about the hzto() return value.
 1.55 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.54 26-Jun-2000  mrg remove redundant vm includes
 1.53 23-Mar-2000  thorpej branches: 1.53.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.52 16-Aug-1999  tron branches: 1.52.2;
Add emulation for Linux stime(2) required for MuPAD's X11 interface.
 1.51 14-May-1999  thorpej Emulate the Linux {get,set}resgid(2) system calls.
 1.50 09-Feb-1999  christos branches: 1.50.2; 1.50.4;
const poisoning.
 1.49 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.48 03-Oct-1998  christos Attempt to fix the mess.
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.50.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.50.2.1 09-Sep-2000  he Pull up revision 1.58 (requested by simonb):
More carefully check length of user-supplied data, in particular
make sure we don't overrun the available stack gap in stack gap
allocations.
 1.52.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.52.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.52.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.53.4.2 30-Aug-2000  sommerfeld Pull up:
syssrc/sys/compat/common/compat_util.c 1.16
syssrc/sys/compat/hpux/hpux_file.c 1.14
syssrc/sys/compat/ibcs2/ibcs2_misc.c 1.52
syssrc/sys/compat/ibcs2/ibcs2_stat.c 1.16
syssrc/sys/compat/linux/common/linux_file.c 1.29
syssrc/sys/compat/linux/common/linux_misc_notalpha.c 1.58
syssrc/sys/compat/svr4/svr4_stat.c 1.40
syssrc/sys/compat/svr4/svr4_stream.c 1.40,1.41

Approved by thorpej and jhawk.

Emulation stackgap sanity checks, based partly on fixes from
FreeBSD-SA00:42.

Change stackgap_alloc to bounds-check the allocation vs. the stack
gap, returning NULL if there isn't room for the allocation.

Change emul_find() to check for a NULL return from stackgap_alloc()
and convert that into ENAMETOOLONG.

Reorder various emulation syscalls so that all *_CHECK_ALT_{EXIST,CREAT}
calls (which turn into emul_find() under the covers come *after* small,
fixed-size stackgap_alloc() calls.

Clean up ibcs2 {get,set}groups.

Add range checks to svr4_stream.c
 1.53.4.1 13-Jul-2000  thorpej Pull up rev. 1.56:
Add a comment about the hzto() return value.
 1.60.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.60.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.60.2.9 05-Oct-2002  gmcgarry Rework for new struct ptimers.
 1.60.2.8 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.60.2.7 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.60.2.6 17-Apr-2002  nathanw Catch up to -current.
 1.60.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.60.2.4 06-Dec-2001  wdk #include <sys/lwp.h> for Mips architectures.
 1.60.2.3 17-Nov-2001  nathanw Reimplement linux_sys_alarm() in terms of the new timers.
 1.60.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.60.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.63.6.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.69.4.1 12-Nov-2004  jmc Pullup rev 1.72 (requested by christos in ticket #950)

Prevent linux processes from losing their children and creating
tons of zombie processes.
 1.69.2.8 11-Dec-2005  christos Sync with head.
 1.69.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.69.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.69.2.5 19-Oct-2004  skrll Sync with HEAD
 1.69.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.69.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.69.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.69.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.72.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.72.4.1 29-Apr-2005  kent sync with -current
 1.74.2.8 21-Jan-2008  yamt sync with head
 1.74.2.7 07-Dec-2007  yamt sync with head
 1.74.2.6 15-Nov-2007  yamt sync with head.
 1.74.2.5 27-Oct-2007  yamt sync with head.
 1.74.2.4 03-Sep-2007  yamt sync with head.
 1.74.2.3 26-Feb-2007  yamt sync with head.
 1.74.2.2 30-Dec-2006  yamt sync with head.
 1.74.2.1 21-Jun-2006  yamt sync with head.
 1.76.6.3 01-Jun-2006  kardel Sync with head.
 1.76.6.2 22-Apr-2006  simonb Sync with head.
 1.76.6.1 04-Feb-2006  simonb Adapt for timecounters: mostly use get*time() and use "time_second"
instead of "time.tv_sec".
 1.76.4.1 09-Sep-2006  rpaulo sync with head
 1.76.2.1 18-Feb-2006  yamt sync with head.
 1.77.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.77.4.4 11-May-2006  elad sync with head
 1.77.4.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.77.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.77.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.77.2.3 11-Aug-2006  yamt sync with head
 1.77.2.2 26-Jun-2006  yamt sync with head.
 1.77.2.1 24-May-2006  yamt sync with head.
 1.79.2.1 19-Jun-2006  chap Sync with head.
 1.81.6.2 10-Dec-2006  yamt sync with head.
 1.81.6.1 22-Oct-2006  yamt sync with head
 1.81.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.81.4.1 18-Nov-2006  ad Sync with head.
 1.84.2.2 07-Oct-2007  pavel Pull up following revision(s) (requested by hauke in ticket #919):
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.89
avoid zerodivide.
 1.84.2.1 20-Apr-2007  bouyer branches: 1.84.2.1.2;
Pull up following revision(s) (requested by njoly in ticket #581):
sys/compat/linux/common/linux_misc.c: revision 1.168
sys/compat/linux/arch/amd64/syscalls.master: revision 1.18
sys/compat/linux/common/linux_types.h: revision 1.25
sys/compat/linux/arch/amd64/linux_machdep.h: revision 1.6
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.87
Fix compat linux statfs/fstatfs syscalls on amd64.
- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.
 1.84.2.1.2.1 29-Oct-2007  wrstuden Catch up with 4.0 RC3
 1.85.2.4 17-May-2007  yamt sync with head.
 1.85.2.3 07-May-2007  yamt sync with head.
 1.85.2.2 24-Mar-2007  yamt sync with head.
 1.85.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.86.4.1 11-Jul-2007  mjf Sync with head.
 1.86.2.4 15-Jul-2007  ad Sync with head.
 1.86.2.3 01-Jul-2007  ad Adapt to callout API change.
 1.86.2.2 27-May-2007  ad Sync with head.
 1.86.2.1 10-Apr-2007  ad Sync with head.
 1.94.12.2 13-Nov-2007  bouyer Sync with HEAD
 1.94.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.94.8.3 09-Jan-2008  matt sync with HEAD
 1.94.8.2 08-Nov-2007  matt sync with -HEAD
 1.94.8.1 06-Nov-2007  matt sync with HEAD
 1.94.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.94.6.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.94.6.2 11-Nov-2007  joerg Sync with HEAD.
 1.94.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.95.2.4 18-Feb-2008  mjf Sync with HEAD.
 1.95.2.3 27-Dec-2007  mjf Sync with HEAD.
 1.95.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.95.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.97.2.1 26-Dec-2007  ad Sync with head.
 1.98.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.100.8.1 18-May-2008  yamt sync with head.
 1.100.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.100.6.3 05-Oct-2008  mjf Sync with HEAD.
 1.100.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.100.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.101.2.4 11-Aug-2010  yamt sync with head.
 1.101.2.3 20-Jun-2009  yamt sync with head
 1.101.2.2 04-May-2009  yamt sync with head.
 1.101.2.1 16-May-2008  yamt sync with head.
 1.102.6.1 19-Oct-2008  haad Sync with HEAD.
 1.102.4.1 18-Jul-2008  simonb Sync with head.
 1.102.2.4 10-Oct-2008  skrll Sync with HEAD.
 1.102.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.102.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.102.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.104.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.105.2.1 23-Jul-2009  jym Sync with HEAD.
 1.106.4.1 05-Mar-2011  rmind sync with head
 1.106.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.106.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.108.34.2 14-Dec-2018  martin Additionally pull up following revision(s) (requested by maxv in ticket #1660):

sys/compat/linux/common/linux_misc_notalpha.c: revision 1.110
sys/kern/kern_time.c: revision 1.193

Improve my kern_time.c::rev1.192, systematically clear the buffers we get
from 'ptimer_pool' to prevent more leaks.
 1.108.34.1 17-Jan-2015  martin branches: 1.108.34.1.2; 1.108.34.1.6;
Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.108.34.1.6.1 14-Dec-2018  martin Additionally pull up following revision(s) (requested by maxv in ticket #1660):

sys/compat/linux/common/linux_misc_notalpha.c: revision 1.110
sys/kern/kern_time.c: revision 1.193

Improve my kern_time.c::rev1.192, systematically clear the buffers we get
from 'ptimer_pool' to prevent more leaks.
 1.108.34.1.2.1 14-Dec-2018  martin Additionally pull up following revision(s) (requested by maxv in ticket #1660):

sys/compat/linux/common/linux_misc_notalpha.c: revision 1.110
sys/kern/kern_time.c: revision 1.193

Improve my kern_time.c::rev1.192, systematically clear the buffers we get
from 'ptimer_pool' to prevent more leaks.
 1.108.18.1 03-Dec-2017  jdolecek update from HEAD
 1.109.20.1 10-Jun-2019  christos Sync with HEAD
 1.109.18.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.109.12.1 30-Nov-2018  martin Additionally pull up following revision(s) (requested by maxv in ticket #1110):

sys/compat/linux/common/linux_misc_notalpha.c: revision 1.110
sys/kern/kern_time.c: revision 1.193

Improve my kern_time.c::rev1.192, systematically clear the buffers we get
from 'ptimer_pool' to prevent more leaks.
 1.110.12.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.22 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.21 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.20 20-Dec-2007  dsl branches: 1.20.6; 1.20.8; 1.20.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.19 04-Dec-2007  dsl branches: 1.19.4;
Remove all the __P
 1.18 11-Dec-2005  christos branches: 1.18.44; 1.18.46; 1.18.52; 1.18.56;
merge ktrace-lwp.
 1.17 30-Oct-2005  chs add support for the linux PROT_GROWS{DOWN,UP} mprotect() flags.
fixes PR 30008.
 1.16 03-May-2005  manu branches: 1.16.2; 1.16.4;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.15 23-Jun-2003  christos branches: 1.15.2; 1.15.16;
PR/21937: Todd Vierling: Proper support for mmap2
 1.14 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.13 22-Mar-2002  christos branches: 1.13.4;
nuke mmap2, cleanup mmap, add mprotect
 1.12 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.11 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.10 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.9 08-Sep-2001  manu Removed a hack to make PowerPC mmap work. This could have side effects on
alpha and i386. It has been tested and works on i386.
 1.8 19-Jan-2001  manu branches: 1.8.2; 1.8.4; 1.8.6;
Cosmetic fix to move powerpc from "guesses" to "know values"
 1.7 10-Apr-2000  chs sparc -> __sparc__
 1.6 15-Dec-1998  itohy branches: 1.6.8;
Added linux compat support on m68k ports.
 1.5 07-Oct-1998  erh Move linux_sys_mmap declarations to linux_mmap.h Make sure oldmmap.c includes oldmmap.h.
 1.4 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Split compat/linux/linux_mmap.h into i386 and common parts.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.6.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.6.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.8.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.8.4.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.4.4 16-Mar-2002  jdolecek Catch up with -current.
 1.8.4.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.8.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.3 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.8.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.8.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.13.4.1 22-Oct-2003  jmc Pullup rev 1.15 (via patch) (requested by tv in ticket #1427)

Proper support for mmap2
 1.15.16.1 01-Nov-2005  tron Pull up following revision(s) (requested by chs in ticket #924):
sys/compat/linux/common/linux_misc.c: revision 1.141
sys/compat/linux/common/linux_mmap.h: revision 1.17
add support for the linux PROT_GROWS{DOWN,UP} mprotect() flags.
fixes PR 30008.
 1.15.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.4.1 02-Nov-2005  yamt sync with head.
 1.16.2.3 21-Jan-2008  yamt sync with head
 1.16.2.2 07-Dec-2007  yamt sync with head
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.18.56.2 26-Dec-2007  ad Sync with head.
 1.18.56.1 08-Dec-2007  ad Sync with head.
 1.18.52.2 27-Dec-2007  mjf Sync with HEAD.
 1.18.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.18.46.1 09-Jan-2008  matt sync with HEAD
 1.18.44.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.19.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.20.10.1 16-May-2008  yamt sync with head.
 1.20.8.1 18-May-2008  yamt sync with head.
 1.20.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.17 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.16 01-Jul-2024  christos Add linux POSIX message queue support (Ricardo Branco)
 1.15 19-Aug-2023  christos branches: 1.15.6;
new inotify support GSoC 2023 (Theodore Preduta)
 1.14 26-Apr-2020  thorpej Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.13 21-Mar-2020  pgoyette Deal with having to teardown sysctl entries in multiple sub-trees.

(This used to work, but I broke it recently.)
 1.12 16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.11 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.10 10-Dec-2017  kre branches: 1.10.2; 1.10.4;

Finally (hopefully) return completely to the state where compat_linux is
enabled by default.

While here make it possible to enable this if already enabled, or disable
if already disabled, without error. Some minor KNF.
 1.9 08-Dec-2017  kre Finish the previous change - as well as setting the default for these
compat modules back to enabled, stop forcing it to switch back to
disabled any time the module is init'd (which is truly barbaric behaviour.)
 1.8 01-Dec-2017  joerg Unbreak Linux emulation by default. While not loading it automatically
is somewhat sensible, breaking functionality of GENERIC is not and has
been objected to on a regular base.
 1.7 29-Sep-2017  maxv Remove compat_linux from the autoload list, and add a sysctl to enable or
disable it - which defaults to disabled. The following command is now
required to use linux binaries:

sysctl -w emul.linux.enabled=1

After a discussion on tech-kern@. All the other ideas to reduce the attack
surface have drawbacks, and this sysctl seems to be the best option.
 1.6 03-Dec-2015  pgoyette Merge the compat_sysv module into the sysv_ipc module - it should
never have been a separate module in the first place (my bad).

Adjust dependencies as appropriate.
 1.5 10-Oct-2015  pgoyette Add an additional dependency on compat_sysv
 1.4 07-Mar-2014  christos branches: 1.4.4; 1.4.6;
c99 initializers for struct execsw
 1.3 19-Sep-2013  christos exec modules need to be of the exec kind
 1.2 14-Sep-2011  christos branches: 1.2.2; 1.2.12; 1.2.16;
Can't use RUN_ONCE here to initialize the futex_lock, otherwise we cannot
unload the module.
 1.1 19-Nov-2008  ad branches: 1.1.4; 1.1.6; 1.1.8; 1.1.12;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.1.12.2 04-May-2009  yamt sync with head.
 1.1.12.1 19-Nov-2008  yamt file linux_mod.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:22 +0000
 1.1.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.1 19-Nov-2008  skrll file linux_mod.c was added on branch nick-hppapmap on 2009-01-19 13:17:31 +0000
 1.1.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.1 19-Nov-2008  mjf file linux_mod.c was added on branch mjf-devfs2 on 2009-01-17 13:28:44 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 19-Nov-2008  haad file linux_mod.c was added on branch haad-dm on 2008-12-13 01:13:56 +0000
 1.2.16.1 18-May-2014  rmind sync with head
 1.2.12.2 03-Dec-2017  jdolecek update from HEAD
 1.2.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.2.1 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.4.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.4.4.2 17-Nov-2015  riz Revert ticket #1020, per pgoyette in ticket #1041.
 1.4.4.1 08-Nov-2015  riz Pull up following revision(s) (requested by pgoyette in ticket #1020):
sys/compat/netbsd32/netbsd32_mod.c: revision 1.6
sys/compat/netbsd32/netbsd32_mod.c: revision 1.7
sys/compat/netbsd32/netbsd32_mod.c: revision 1.8
sys/compat/netbsd32/netbsd32_mod.c: revision 1.9
sys/compat/linux/common/linux_mod.c: revision 1.5
Add an additional dependency on compat_sysv
Add another dependency for nfsserver
And yet another dependency, this time on mq
Ooops, spell the module name in full. "mqueue" vs "mq"
we need compat_sysv now.
 1.10.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.4.1 10-Jun-2019  christos Sync with HEAD
 1.10.2.4 24-Jan-2019  pgoyette Reduce the list of required modules to what is really needed
 1.10.2.3 18-Oct-2018  pgoyette Add a few more references to the (currently always but not forever)
built-in compat_util module
 1.10.2.2 19-Sep-2018  pgoyette Remove leading coma from list of required modules. It doesn't seem
to cause any real problems, but it makes modstat output look weird.
 1.10.2.1 12-Sep-2018  pgoyette Adjust module requirements to reflect the new more granular modules
 1.15.6.1 02-Aug-2025  perseant Sync with HEAD
 1.2 17-May-2025  andvar branches: 1.2.4;
Fix RCS ID in few more files.
 1.1 01-Jul-2024  christos Add linux POSIX message queue support (Ricardo Branco)
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 17-May-2025  perseant file linux_mqueue.c was added on branch perseant-exfatfs on 2025-08-02 05:56:26 +0000
 1.2 17-May-2025  andvar branches: 1.2.4;
Fix RCS ID in few more files.
 1.1 01-Jul-2024  christos Add linux POSIX message queue support (Ricardo Branco)
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 17-May-2025  perseant file linux_mqueue.h was added on branch perseant-exfatfs on 2025-08-02 05:56:26 +0000
 1.14 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.13 18-Nov-2009  njoly branches: 1.13.100;
Make compat linux/linux32 msgrcv_msgarg type member of type
long/netbsd32_long to match linux definition.
 1.12 09-Dec-2008  njoly Add some padding members to linux_msqid64_ds for 32-bit archs. This
fix msgctl(2) IPC_STAT|IPC_64 calls, at least, on i386.
 1.11 21-May-2008  njoly branches: 1.11.4; 1.11.6;
Add IPC_64 support to msgctl, needed for amd64.
 1.10 28-Apr-2008  martin branches: 1.10.2;
Remove clause 3 and 4 from TNF licenses
 1.9 20-Dec-2007  dsl branches: 1.9.6; 1.9.8; 1.9.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.8 04-Dec-2007  dsl branches: 1.8.4;
Remove all the __P
 1.7 09-Feb-2006  manu branches: 1.7.38; 1.7.40; 1.7.46; 1.7.50;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.6 18-Jan-2003  thorpej branches: 1.6.18; 1.6.30; 1.6.32; 1.6.34;
Merge the nathanw_sa branch.
 1.5 04-Oct-1998  fvdl branches: 1.5.24;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.4 03-Oct-1998  christos Attempt to fix the mess.
 1.3 01-Oct-1998  erh Move IPC headers to common. The msg, sem and shm files, in addition to other common structures and to avoid creating several more machine dependent header files, include the syscall arguments for several system calls which don't exist on all architechtures.
 1.2 15-Aug-1995  fvdl Implement the rest of the sysv ipc calls ({sem,msg}*())
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.5.24.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.6.34.1 22-Apr-2006  simonb Sync with head.
 1.6.32.1 09-Sep-2006  rpaulo sync with head
 1.6.30.1 18-Feb-2006  yamt sync with head.
 1.6.18.3 21-Jan-2008  yamt sync with head
 1.6.18.2 07-Dec-2007  yamt sync with head
 1.6.18.1 21-Jun-2006  yamt sync with head.
 1.7.50.2 26-Dec-2007  ad Sync with head.
 1.7.50.1 08-Dec-2007  ad Sync with head.
 1.7.46.2 27-Dec-2007  mjf Sync with HEAD.
 1.7.46.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.40.1 09-Jan-2008  matt sync with HEAD
 1.7.38.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.10.3 11-Mar-2010  yamt sync with head
 1.9.10.2 04-May-2009  yamt sync with head.
 1.9.10.1 16-May-2008  yamt sync with head.
 1.9.8.2 04-Jun-2008  yamt sync with head
 1.9.8.1 18-May-2008  yamt sync with head.
 1.9.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.9.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.100.1 02-Aug-2025  perseant Sync with HEAD
 1.9 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.8 07-Sep-2021  riastradh branches: 1.8.10;
sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.7 21-Mar-2008  ad branches: 1.7.6; 1.7.84; 1.7.96;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.6 20-Dec-2007  dsl branches: 1.6.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.5 19-Oct-2007  njoly branches: 1.5.4; 1.5.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.4 04-Mar-2007  christos branches: 1.4.14; 1.4.16; 1.4.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 09-Feb-2007  ad branches: 1.3.2;
Merge newlock2 to head.
 1.2 11-Dec-2005  christos branches: 1.2.20;
merge ktrace-lwp.
 1.1 28-Feb-2005  soren branches: 1.1.2; 1.1.6; 1.1.8; 1.1.10;
Emulate basic mtio ioctls.
 1.1.10.6 24-Mar-2008  yamt sync with head.
 1.1.10.5 21-Jan-2008  yamt sync with head
 1.1.10.4 27-Oct-2007  yamt sync with head.
 1.1.10.3 03-Sep-2007  yamt sync with head.
 1.1.10.2 26-Feb-2007  yamt sync with head.
 1.1.10.1 21-Jun-2006  yamt sync with head.
 1.1.8.2 29-Apr-2005  kent sync with -current
 1.1.8.1 28-Feb-2005  kent file linux_mtio.c was added on branch kent-audio2 on 2005-04-29 11:28:40 +0000
 1.1.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 28-Feb-2005  yamt file linux_mtio.c was added on branch yamt-km on 2005-03-19 08:33:37 +0000
 1.1.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.1 28-Feb-2005  skrll file linux_mtio.c was added on branch ktrace-lwp on 2005-03-04 16:40:03 +0000
 1.2.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.3.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.4.16.2 09-Jan-2008  matt sync with HEAD
 1.4.16.1 06-Nov-2007  matt sync with HEAD
 1.4.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.5.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.4.1 26-Dec-2007  ad Sync with head.
 1.6.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.7.96.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.7.84.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.7.6.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.7.6.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.8.10.1 02-Aug-2025  perseant Sync with HEAD
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 28-Feb-2005  soren branches: 1.1.2; 1.1.6; 1.1.8;
Emulate basic mtio ioctls.
 1.1.8.2 29-Apr-2005  kent sync with -current
 1.1.8.1 28-Feb-2005  kent file linux_mtio.h was added on branch kent-audio2 on 2005-04-29 11:28:40 +0000
 1.1.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.6.1 28-Feb-2005  yamt file linux_mtio.h was added on branch yamt-km on 2005-03-19 08:33:37 +0000
 1.1.2.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.1 28-Feb-2005  skrll file linux_mtio.h was added on branch ktrace-lwp on 2005-03-04 16:40:03 +0000
 1.74 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.73 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.72 18-Aug-2009  christos more debugging for mmap
 1.71 03-Dec-2008  ad PR port-amd64/40091 compat_linux32 module loading = panic due to missing syms
 1.70 18-Jun-2008  tsutsui branches: 1.70.2; 1.70.4;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.69 28-Apr-2008  martin branches: 1.69.2; 1.69.4;
Remove clause 3 and 4 from TNF licenses
 1.68 20-Dec-2007  dsl branches: 1.68.6; 1.68.8; 1.68.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.67 08-Dec-2007  dsl branches: 1.67.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.66 09-Feb-2007  ad branches: 1.66.18; 1.66.20; 1.66.28;
Merge newlock2 to head.
 1.65 09-Feb-2006  manu branches: 1.65.14;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.64 11-Dec-2005  christos branches: 1.64.2; 1.64.4; 1.64.6;
merge ktrace-lwp.
 1.63 24-Aug-2004  jdolecek branches: 1.63.12;
fix debug printf - lm_addr is not pointer anumore
 1.62 22-Aug-2004  jdolecek make struct linux_oldmmap members explicitly unsigned (with exception
of lm_fd, which can be -1), rename lm_pos to lm_offset, g/c some unneeded casts

no functional change
 1.61 18-Jan-2003  thorpej branches: 1.61.2;
Merge the nathanw_sa branch.
 1.60 17-Dec-2002  tron Include "uvm/uvm_param.h" to get definition of PAGE_MASK required for
last change.
 1.59 16-Dec-2002  christos Don't allow non-page-aligned offsets! So dumb. From Jason Ish, thanks.
 1.58 29-Mar-2002  christos branches: 1.58.4;
- #undef DPRINTF for files that are included from other files.
- more debugging for socketcalls
- fix sa_len if AF_INET; somehow we get passed 28 instead of 16?
 1.57 22-Mar-2002  christos gc debugging printfs.
 1.56 15-Feb-2002  christos s/printf/uprintf/
 1.55 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.54 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.53 29-Dec-2000  fvdl branches: 1.53.2; 1.53.4;
Avoid sign extension problem in offset.
 1.52 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.51 26-Jun-2000  mrg remove redundant vm includes.
 1.50 07-Oct-1998  erh branches: 1.50.12; 1.50.22;
Move linux_sys_mmap declarations to linux_mmap.h Make sure oldmmap.c includes oldmmap.h.
 1.49 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.48 03-Oct-1998  christos Attempt to fix the mess.
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.50.22.1 30-Mar-2001  he Pull up revision 1.53 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.50.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.50.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.53.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.53.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.53.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.53.2.7 19-Dec-2002  thorpej Sync with HEAD.
 1.53.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.53.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.53.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.53.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.53.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.53.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.58.4.2 22-Oct-2003  jmc Pullup rev 1.60 (requested by tv in ticket #1426)

Don't allow non-page-aligned offsets.
 1.58.4.1 22-Oct-2003  jmc Pullup rev 1.59 (requested by tv in ticket #1426)

Don't allow non-page-aligned offsets.
 1.61.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.61.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.61.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.63.12.3 21-Jan-2008  yamt sync with head
 1.63.12.2 26-Feb-2007  yamt sync with head.
 1.63.12.1 21-Jun-2006  yamt sync with head.
 1.64.6.1 22-Apr-2006  simonb Sync with head.
 1.64.4.1 09-Sep-2006  rpaulo sync with head
 1.64.2.1 18-Feb-2006  yamt sync with head.
 1.65.14.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.66.28.1 26-Dec-2007  ad Sync with head.
 1.66.20.1 09-Jan-2008  matt sync with HEAD
 1.66.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.67.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.68.10.3 19-Aug-2009  yamt sync with head.
 1.68.10.2 04-May-2009  yamt sync with head.
 1.68.10.1 16-May-2008  yamt sync with head.
 1.68.8.1 18-May-2008  yamt sync with head.
 1.68.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.68.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.68.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.69.4.1 18-Jun-2008  simonb Sync with head.
 1.69.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.69.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.69.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.70.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.70.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 11-Dec-2005  christos branches: 1.4.70; 1.4.72; 1.4.74;
merge ktrace-lwp.
 1.3 22-Aug-2004  jdolecek make struct linux_oldmmap members explicitly unsigned (with exception
of lm_fd, which can be -1), rename lm_pos to lm_offset, g/c some unneeded casts

no functional change
 1.2 07-Oct-1998  erh branches: 1.2.46;
Move linux_sys_mmap declarations to linux_mmap.h Make sure oldmmap.c includes oldmmap.h.
 1.1 01-Oct-1998  erh Define structures needed for these functions.
 1.2.46.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.46.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.46.1 25-Aug-2004  skrll Sync with HEAD.
 1.4.74.1 16-May-2008  yamt sync with head.
 1.4.72.1 18-May-2008  yamt sync with head.
 1.4.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.68 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.67 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.66 28-Apr-2008  martin branches: 1.66.2; 1.66.80; 1.66.92;
Remove clause 3 and 4 from TNF licenses
 1.65 20-Dec-2007  dsl branches: 1.65.6; 1.65.8; 1.65.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.64 08-Nov-2007  njoly branches: 1.64.2; 1.64.6;
Replace strncpy with strlcpy in compat linux and linux32 uname,
old_uname and oldold_uname syscalls to ensure that all *utsname fields
are always NUL terminated.
 1.63 10-May-2007  christos branches: 1.63.6; 1.63.8; 1.63.12; 1.63.14;
- linux uname -m on x86 returns i{3,4,5,6}86 make it so.
- delete the machine sysctl that never worked, and gc linux_machine.
 1.62 23-Mar-2007  mrg implement emul.linux.kern.machine, which can be set to "i686", like
some applications seem to want.
 1.61 09-Feb-2007  ad branches: 1.61.2; 1.61.6; 1.61.8; 1.61.10;
Merge newlock2 to head.
 1.60 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.59 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.58 19-Jan-2003  thorpej branches: 1.58.18; 1.58.48; 1.58.50;
Merge the nathanw_sa branch.
 1.57 18-Jan-2003  jdolecek LWPify
 1.56 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.55 29-Dec-2000  fvdl branches: 1.55.2; 1.55.4;
Hardcode what the linux uname() calls return (Linux 2.2.5 is the current
value). A few major applications check for this (like VMware), and
there is no other way to trick them. Needs a more generic solution
eventually.
 1.54 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.53 26-Jun-2000  mrg remove redundant vm includes.
 1.52 28-Mar-2000  simonb branches: 1.52.4;
Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
 1.51 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.50 04-Oct-1998  fvdl branches: 1.50.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.49 03-Oct-1998  christos Attempt to fix the mess.
 1.48 01-Oct-1998  perry shut up egcs complaints by adding braces
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.50.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.50.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.52.4.1 30-Mar-2001  he Pull up revision 1.55 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.55.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.55.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.55.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.55.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.58.50.2 10-Dec-2006  yamt sync with head.
 1.58.50.1 22-Oct-2006  yamt sync with head
 1.58.48.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.58.48.1 18-Nov-2006  ad Sync with head.
 1.58.18.5 21-Jan-2008  yamt sync with head
 1.58.18.4 15-Nov-2007  yamt sync with head.
 1.58.18.3 03-Sep-2007  yamt sync with head.
 1.58.18.2 26-Feb-2007  yamt sync with head.
 1.58.18.1 30-Dec-2006  yamt sync with head.
 1.61.10.1 29-Mar-2007  reinoud Pullup to -current
 1.61.8.1 11-Jul-2007  mjf Sync with head.
 1.61.6.2 27-May-2007  ad Sync with head.
 1.61.6.1 10-Apr-2007  ad Sync with head.
 1.61.2.2 17-May-2007  yamt sync with head.
 1.61.2.1 24-Mar-2007  yamt sync with head.
 1.63.14.2 27-Dec-2007  mjf Sync with HEAD.
 1.63.14.1 19-Nov-2007  mjf Sync with HEAD.
 1.63.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.63.8.1 09-Jan-2008  matt sync with HEAD
 1.63.6.1 11-Nov-2007  joerg Sync with HEAD.
 1.64.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.64.2.1 26-Dec-2007  ad Sync with head.
 1.65.10.1 16-May-2008  yamt sync with head.
 1.65.8.1 18-May-2008  yamt sync with head.
 1.65.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.66.92.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.66.80.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.66.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.66.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.3 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 01-Oct-1998  erh branches: 1.1.144; 1.1.146; 1.1.148;
Define structures needed for these functions.
 1.1.148.1 16-May-2008  yamt sync with head.
 1.1.146.1 18-May-2008  yamt sync with head.
 1.1.144.1 02-Jun-2008  mjf Sync with HEAD.
 1.59 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.58 18-Jun-2008  tsutsui Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.57 28-Apr-2008  martin branches: 1.57.2; 1.57.4;
Remove clause 3 and 4 from TNF licenses
 1.56 20-Dec-2007  dsl branches: 1.56.6; 1.56.8; 1.56.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.55 08-Dec-2007  dsl branches: 1.55.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.54 09-Feb-2007  ad branches: 1.54.18; 1.54.20; 1.54.28;
Merge newlock2 to head.
 1.53 18-Jan-2003  thorpej branches: 1.53.18; 1.53.48;
Merge the nathanw_sa branch.
 1.52 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.51 29-Jun-2000  mrg branches: 1.51.2; 1.51.4;
remove include of <vm/vm.h>
 1.50 26-Jun-2000  mrg remove redundant vm includes.
 1.49 04-Oct-1998  fvdl branches: 1.49.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.48 03-Oct-1998  christos Attempt to fix the mess.
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.49.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.51.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.51.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.51.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.51.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.53.48.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.53.18.2 21-Jan-2008  yamt sync with head
 1.53.18.1 26-Feb-2007  yamt sync with head.
 1.54.28.1 26-Dec-2007  ad Sync with head.
 1.54.20.1 09-Jan-2008  matt sync with HEAD
 1.54.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.55.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.56.10.2 04-May-2009  yamt sync with head.
 1.56.10.1 16-May-2008  yamt sync with head.
 1.56.8.1 18-May-2008  yamt sync with head.
 1.56.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.56.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.57.4.1 18-Jun-2008  simonb Sync with head.
 1.57.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.57.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.57.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.4 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.3 11-Jan-2009  christos merge christos-time_t
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 01-Oct-1998  erh branches: 1.1.144; 1.1.146; 1.1.148; 1.1.150;
Define structures needed for these functions.
 1.1.150.2 04-May-2009  yamt sync with head.
 1.1.150.1 16-May-2008  yamt sync with head.
 1.1.148.1 18-May-2008  yamt sync with head.
 1.1.146.2 01-Nov-2008  christos Sync with head.
 1.1.146.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.1.144.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.144.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.68 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.67 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.66 28-Apr-2008  martin branches: 1.66.2; 1.66.80; 1.66.92;
Remove clause 3 and 4 from TNF licenses
 1.65 20-Dec-2007  dsl branches: 1.65.6; 1.65.8; 1.65.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.64 08-Nov-2007  njoly branches: 1.64.2; 1.64.6;
Replace strncpy with strlcpy in compat linux and linux32 uname,
old_uname and oldold_uname syscalls to ensure that all *utsname fields
are always NUL terminated.
 1.63 10-May-2007  christos branches: 1.63.6; 1.63.8; 1.63.12; 1.63.14;
- linux uname -m on x86 returns i{3,4,5,6}86 make it so.
- delete the machine sysctl that never worked, and gc linux_machine.
 1.62 23-Mar-2007  mrg implement emul.linux.kern.machine, which can be set to "i686", like
some applications seem to want.
 1.61 09-Feb-2007  ad branches: 1.61.2; 1.61.6; 1.61.8; 1.61.10;
Merge newlock2 to head.
 1.60 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.59 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.58 18-Jan-2003  thorpej branches: 1.58.18; 1.58.48; 1.58.50;
Merge the nathanw_sa branch.
 1.57 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.56 29-Dec-2000  fvdl branches: 1.56.2; 1.56.4;
Hardcode what the linux uname() calls return (Linux 2.2.5 is the current
value). A few major applications check for this (like VMware), and
there is no other way to trick them. Needs a more generic solution
eventually.
 1.55 29-Jun-2000  mrg remove include of <vm/vm.h>
 1.54 26-Jun-2000  mrg remove redundant vm includes.
 1.53 28-Mar-2000  simonb branches: 1.53.4;
Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
 1.52 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.51 07-Oct-1998  erh branches: 1.51.12;
This needs its defines.
 1.50 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.49 03-Oct-1998  christos Attempt to fix the mess.
 1.48 01-Oct-1998  perry shut up egcs complaints about braces
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.51.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.51.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.53.4.1 30-Mar-2001  he Pull up revision 1.56 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.56.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.56.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.56.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.56.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.58.50.2 10-Dec-2006  yamt sync with head.
 1.58.50.1 22-Oct-2006  yamt sync with head
 1.58.48.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.58.48.1 18-Nov-2006  ad Sync with head.
 1.58.18.5 21-Jan-2008  yamt sync with head
 1.58.18.4 15-Nov-2007  yamt sync with head.
 1.58.18.3 03-Sep-2007  yamt sync with head.
 1.58.18.2 26-Feb-2007  yamt sync with head.
 1.58.18.1 30-Dec-2006  yamt sync with head.
 1.61.10.1 29-Mar-2007  reinoud Pullup to -current
 1.61.8.1 11-Jul-2007  mjf Sync with head.
 1.61.6.2 27-May-2007  ad Sync with head.
 1.61.6.1 10-Apr-2007  ad Sync with head.
 1.61.2.2 17-May-2007  yamt sync with head.
 1.61.2.1 24-Mar-2007  yamt sync with head.
 1.63.14.2 27-Dec-2007  mjf Sync with HEAD.
 1.63.14.1 19-Nov-2007  mjf Sync with HEAD.
 1.63.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.63.8.1 09-Jan-2008  matt sync with HEAD
 1.63.6.1 11-Nov-2007  joerg Sync with HEAD.
 1.64.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.64.2.1 26-Dec-2007  ad Sync with head.
 1.65.10.1 16-May-2008  yamt sync with head.
 1.65.8.1 18-May-2008  yamt sync with head.
 1.65.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.66.92.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.66.80.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.66.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.66.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.9 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 04-Oct-1998  fvdl branches: 1.7.144; 1.7.146; 1.7.148;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.6 01-Oct-1998  erh Split linux_types.h into i386, common and multi-architechture parts.
 1.5 20-May-1996  fvdl Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.4 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.3 14-Aug-1995  mycroft Move signal types into signal.h.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.7.148.1 16-May-2008  yamt sync with head.
 1.7.146.1 18-May-2008  yamt sync with head.
 1.7.144.1 02-Jun-2008  mjf Sync with HEAD.
 1.69 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.68 26-Dec-2017  kamil Refactor pipe1() and correct a bug in sys_pipe2() (SYS_pipe2)

sys_pipe2() returns two integers (values), the 2nd one is a copy of the 2nd
file descriptor that lands in fildes[2]. This is a side effect of reusing
the code for sys_pipe() (SYS_pipe) and not cleaning it up.

The first returned value is (on success) 0.

Introduced a small refactoring in pipe1() that it does not operate over
retval[], but on an array int[2]. A user sets retval[] for pipe() when
desired and needed.

This refactoring touches compat code: netbsd32, linux, linux32.

Before the changes on NetBSD/amd64:

$ ktruss -i ./a.out
[...]
15131 1 a.out pipe2(0x7f7fff2e62b8, 0) = 0, 4
[...]

After the changes:

$ ktruss -i ./a.out
[...]
782 1 a.out pipe2(0x7f7fff97e850, 0) = 0
[...]

There should not be a visible change for current users.

Sponsored by <The NetBSD Foundation>
 1.67 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.66 01-Jun-2014  njoly branches: 1.66.2;
Cleanup pipe(2) flags, now that native handle them.
 1.65 14-Apr-2011  christos branches: 1.65.14; 1.65.28;
move dup3 to a more appropriate place because pipe is "special". Gotta love
linux.
 1.64 10-Apr-2011  christos - implement dup3 and pipe2
- eliminate amd64 ifdef
 1.63 18-Jun-2008  tsutsui branches: 1.63.18; 1.63.24;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.62 28-Apr-2008  martin branches: 1.62.2; 1.62.4;
Remove clause 3 and 4 from TNF licenses
 1.61 20-Dec-2007  dsl branches: 1.61.6; 1.61.8; 1.61.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.60 08-Dec-2007  dsl branches: 1.60.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.59 19-Oct-2007  njoly branches: 1.59.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.58 09-Feb-2007  ad branches: 1.58.18; 1.58.20; 1.58.24;
Merge newlock2 to head.
 1.57 11-Dec-2005  christos branches: 1.57.20;
merge ktrace-lwp.
 1.56 05-Nov-2005  manu Fix a messed up patch
 1.55 04-Nov-2005  manu register_t is not an int on amd64
 1.54 31-Oct-2005  manu Fix pipe linux emulation on amd64
 1.53 18-Jan-2003  thorpej branches: 1.53.2; 1.53.18; 1.53.20;
Merge the nathanw_sa branch.
 1.52 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.51 29-Jun-2000  mrg branches: 1.51.2; 1.51.4;
remove include of <vm/vm.h>
 1.50 26-Jun-2000  mrg remove redundant vm includes.
 1.49 04-Oct-1998  fvdl branches: 1.49.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.48 03-Oct-1998  christos Attempt to fix the mess.
 1.47 01-Oct-1998  erh Wheeee!: 8-way split of compat/linux/linux_misc.c into common code and multi-architechture functions.
 1.46 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.45 08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.44 18-Aug-1998  thorpej Add some braces to make egcs happy.
 1.43 07-Jul-1998  thorpej Oops, fix typo, pointed out by Urban Boquist <boquist@cs.chalmers.se>.
 1.42 02-Jul-1998  thorpej Implement the shrinking and no-change bits of the Linux mremap(2) system
call, provided by Urban Boquist <boquist@cs.chalmers.se> in PR #5693.

Add a comment about how one might implement the growing bit of mremap(2).
 1.41 24-Mar-1998  mycroft Fix typo in utime().
 1.40 03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.39 01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38 20-Feb-1998  mycroft Linux's getsid(2) does in fact return a pid, not a pointer.
 1.37 14-Feb-1998  thorpej Add a comment clearly describing that Linux's getsid(2) differs from
the XPG4.2 definition in that it returns the kernel virtual address
of the session structure, rather than the process group ID of the
session leader.
 1.36 21-Oct-1997  fvdl branches: 1.36.2;
msync -> __msync13
 1.35 10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.34 10-Oct-1997  mycroft Emulate mremap(2) by returning ENOMEM for now. This should be sufficient for
realloc(3) and other uses. From Matthias Scheler in PR 3920.
 1.33 10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.32 04-Aug-1997  bouyer Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.31 27-Jul-1997  augustss branches: 1.31.2;
Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.30 07-Apr-1997  augustss Add Linux nice() syscall.
 1.29 10-Aug-1996  mycroft sys/dir.h -> sys/dirent.h
 1.28 23-Jun-1996  mycroft Catch up with setre[ug]id() changes.
 1.27 20-May-1996  fvdl branches: 1.27.4;
Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.26 04-Apr-1996  christos - Prototyping changes
- Fix bug that gcc -Wall found in linux_sys_getpgid()
 1.25 03-Apr-1996  mycroft Add explicit return types.
 1.24 18-Dec-1995  fvdl msync, readv and writev were recently added to the Linux kernel; add them
to the emulation as well.
 1.23 09-Dec-1995  mycroft We don't need a private version of fork() here any more.
 1.22 09-Oct-1995  mycroft Use cookies for directory offset, mostly from Greg Hudson.
 1.21 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.20 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.19 13-Sep-1995  fvdl Update offset elsewhere in linux_getdents(); still emulate a bug in
Linux, but avoid endless loops.
 1.18 07-Sep-1995  fvdl Fix some bugs & typing problems.
 1.17 23-Aug-1995  fvdl Emulate some syscalls that appear in Linux 1.3: a select() with normal args,
getdents() and flock().
 1.16 21-Aug-1995  fvdl Check for status NULL argument in wait4 and waitpid. From PR #1392
by Thomas EberHardt.
 1.15 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.14 16-Aug-1995  mycroft If updating the timeval would make it negative, zero it instead.
 1.13 16-Aug-1995  mycroft Allow bogus timevals, per Linux.
 1.12 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.11 14-Aug-1995  mycroft Rearrange #includes.
 1.10 13-Aug-1995  mycroft Linux doesn't allow select(2) to be restarted.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 11-Jun-1995  fvdl Linux select() returns the amount of time left before a timeout would have
occured in the timeval structure. Emulate this behavior. Reported by
Theo de Raadt.
 1.6 11-Jun-1995  fvdl * Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib
 1.5 10-Jun-1995  mycroft Rename the dirent fields to match Linux. Make sure the requested buffer
is no larger than MAXBSIZE.
 1.4 22-Mar-1995  mycroft Emulate the return value of times() better.
 1.3 21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.27.4.2 10-Dec-1996  mycroft From trunk:
sys/dir.h -> sys/dirent.h
 1.27.4.1 10-Dec-1996  mycroft From trunk:
Implement setre[ug]id() for real.
 1.31.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.36.2.1 08-May-1998  mycroft Pull up 1.41, per request of mycroft.
 1.49.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.51.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.51.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.51.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.51.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.53.20.1 02-Nov-2005  yamt sync with head.
 1.53.18.4 21-Jan-2008  yamt sync with head
 1.53.18.3 27-Oct-2007  yamt sync with head.
 1.53.18.2 26-Feb-2007  yamt sync with head.
 1.53.18.1 21-Jun-2006  yamt sync with head.
 1.53.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.57.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.58.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.58.20.2 09-Jan-2008  matt sync with HEAD
 1.58.20.1 06-Nov-2007  matt sync with HEAD
 1.58.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.58.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.59.4.1 26-Dec-2007  ad Sync with head.
 1.60.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.61.10.2 04-May-2009  yamt sync with head.
 1.61.10.1 16-May-2008  yamt sync with head.
 1.61.8.1 18-May-2008  yamt sync with head.
 1.61.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.61.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.62.4.1 18-Jun-2008  simonb Sync with head.
 1.62.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.62.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.62.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.63.24.1 06-Jun-2011  jruoho Sync with HEAD.
 1.63.18.1 21-Apr-2011  rmind sync with head
 1.65.28.1 10-Aug-2014  tls Rebase.
 1.65.14.2 03-Dec-2017  jdolecek update from HEAD
 1.65.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.66.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.5 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.4 09-Feb-2024  andvar branches: 1.4.2;
fix spelling mistakes, mainly in comments and log messages.
 1.3 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.2 11-Dec-2005  christos branches: 1.2.20; 1.2.22;
merge ktrace-lwp.
 1.1 03-May-2005  manu branches: 1.1.2; 1.1.8;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.1.8.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.8.1 03-May-2005  skrll file linux_prctl.h was added on branch ktrace-lwp on 2005-11-10 14:01:07 +0000
 1.1.2.1 30-Dec-2006  yamt sync with head.
 1.2.22.1 10-Dec-2006  yamt sync with head.
 1.2.20.1 12-Jan-2007  ad Sync with head.
 1.4.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 20-Dec-2007  dsl branches: 1.11.6; 1.11.8; 1.11.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.10 04-Dec-2007  dsl branches: 1.10.4;
Remove all the __P
 1.9 11-Dec-2005  christos branches: 1.9.44; 1.9.46; 1.9.52; 1.9.56;
merge ktrace-lwp.
 1.8 26-Feb-2005  perry branches: 1.8.4;
nuke trailing whitespace
 1.7 18-Jan-2003  thorpej branches: 1.7.2; 1.7.10; 1.7.12;
Merge the nathanw_sa branch.
 1.6 27-Jan-2002  bjh21 Add support for PTRACE_GETREGS and PTRACE_SETREGS in ARMLinux emulation.
 1.5 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.4 22-May-2001  manu branches: 1.4.2; 1.4.4;
Enable PowerPC Linux ptrace() emulation
 1.3 01-Nov-2000  jdolecek branches: 1.3.2; 1.3.4;
move definition of LINUX_PTRACE_{SET|GET}(FP)REGS flags to
sys/compat/linux/common/linux_ptrace.h, they seem to be actually MI
 1.2 16-Dec-1999  tron branches: 1.2.2;
Move MI parts of ptrace(2) emulation to "linux_misc.c".
 1.1 11-Dec-1999  tron Architecture independent definitions for Linux's ptrace(2) system call.
 1.2.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.4.4 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.3 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.3.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.3.4.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.3.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.3.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.2.1 01-Nov-2000  bouyer file linux_ptrace.h was added on branch thorpej_scsipi on 2000-11-20 18:08:25 +0000
 1.4.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.4.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.10.1 29-Apr-2005  kent sync with -current
 1.7.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.8.4.2 21-Jan-2008  yamt sync with head
 1.8.4.1 07-Dec-2007  yamt sync with head
 1.9.56.2 26-Dec-2007  ad Sync with head.
 1.9.56.1 08-Dec-2007  ad Sync with head.
 1.9.52.2 27-Dec-2007  mjf Sync with HEAD.
 1.9.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.46.1 09-Jan-2008  matt sync with HEAD
 1.9.44.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.10.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.10.1 16-May-2008  yamt sync with head.
 1.11.8.1 18-May-2008  yamt sync with head.
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 18-Mar-2000  erh branches: 1.1.6; 1.1.128; 1.1.130; 1.1.132;
Add defines for linux_sys_reboot.
 1.1.132.1 16-May-2008  yamt sync with head.
 1.1.130.1 18-May-2008  yamt sync with head.
 1.1.128.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.1.6.1 18-Mar-2000  bouyer file linux_reboot.h was added on branch thorpej_scsipi on 2000-11-20 18:08:25 +0000
 1.85 19-Sep-2025  kre cl_args.stack_size is uint64_t (all architectures), on ILP32 (void *)
is 32 bits, as is (intptr_t). 32 bits added to 64 bits --> 64 bits,
which gcc complains about converting to a pointer. Add yet another cast.

Should fix ILP32 builds (eg: i386)
 1.84 19-Sep-2025  christos PR/59608: csaba mate: fix stack address and ignore sysvsem flag. makes the
latest jvm work again.
 1.83 03-Oct-2024  hannken branches: 1.83.2;
Fix fallout from DPRINTF conversion.

Kernels ALL/i386 and ALL/amd64 compile again.
 1.82 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.81 30-Sep-2024  kre Supply a missing cast, which fixes the i386 (other 32 bit too probably)
builds.

Note I used uintptr_t rather than intptr_t which other similar
lines nearby use - the int being converted to a ptr is uint64_t
so using unsigned seemed safer to me. Feel free to change it.

Not sure if the code will work though - linux's clone3() is
being emulated via its clone() sys call - I know nothing about
linux sys calls, but my impression of these two is that in
clone() the "stack" arg points at the logical stack start
(usually the highest addr in the stack segment - though there
are some systems with upward growing stacks) whereas for
clone3() it looks to me as if the stack arg is always intended
to be the lowest addr in the stack segment (with a new size
field added to compute the top). Simply copying that arg to the
clone() arg of the same name might not work. (I am surmising).
I'd expect the code to need to vary based upon in which direction
the architecture's stack grows. Maybe.
 1.80 29-Sep-2024  christos move clone3 to linux_sched.c and make it compile (need to fix XXX comments)
 1.79 07-Sep-2021  riastradh branches: 1.79.10;
sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.78 23-May-2020  ad Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.77 14-May-2020  rin Fix previous; specify lwpid for curlpw in the case of pid == 0.

For linux_sys_sched_setaffinity, pid == 0 means the current thread.
On the other hand, for our native sys_sched_setaffinity, lid == 0
means all lwp's that belong to the process.
 1.76 29-Apr-2020  thorpej Fix proc / lwp lookup processing in linux_sys_sched_getaffinity()
and linux_sys_sched_setaffinity(). They were incorrect even before
the LWP ID changes, but those changes exposed the latent bugs.
 1.75 24-Apr-2020  thorpej Overhaul the way LWP IDs are allocated. Instead of each LWP having it's
own LWP ID space, LWP IDs came from the same number space as PIDs. The
lead LWP of a process gets the PID as its LID. If a multi-LWP process's
lead LWP exits, the PID persists for the process.

In addition to providing system-wide unique thread IDs, this also lets us
eliminate the per-process LWP radix tree, and some associated locks.

Remove the separate "global thread ID" map added previously; it is no longer
needed to provide this functionality.

Nudged in this direction by ad@ and chs@.
 1.74 19-Apr-2020  thorpej - Only increment nprocs when we're creating a new process, not just
when allocating a PID.
- Per above, proc_free_pid() no longer decrements nprocs. It's now done
in proc_free() right after proc_free_pid().
- Ensure nprocs is accessed using atomics everywhere.
 1.73 23-Nov-2019  ad branches: 1.73.6;
Minor scheduler cleanup:

- Adapt to cpu_need_resched() changes. Avoid lost & duplicate IPIs and ASTs.
sched_resched_cpu() and sched_resched_lwp() contain the logic for this.
- Changes for LSIDL to make the locking scheme match the intended design.
- Reduce lock contention and false sharing further.
- Numerous small bugfixes, including some corrections for SCHED_FIFO/RT.
- Use setrunnable() in more places, and merge cut & pasted code.
 1.72 03-Oct-2019  kamil Switch kevent udata from intptr_t void*

Synchromize the struct field format with other BSDs and Darwin.

No ABI change between older and newer struct form on the ports.

The change will require no changes to most C users during the transition
period as the header keeps a caller cast.

Discussed with core@ and there were no objections for this move.
 1.71 16-Apr-2018  kamil branches: 1.71.2; 1.71.6;
Remove the rnewprocp argument from fork1(9)

It's now unused and it can cause use-after-free scenarios as noted by
<Mateusz Guzik>.

Reference: http://mail-index.netbsd.org/tech-kern/2017/09/08/msg022267.html

Sponsored by <The NetBSD Foundation>
 1.70 15-Apr-2018  kamil Remove unused variable p from linux_sys_clone()

After refactoring by <chs> in 2010 (r. 1.63) the p variable is no longer
used.

As noted by <Mateusz Guzik> its usage is also unsafe and might cause
use-after-free scenarios.

No functional change intended.

Reference: http://mail-index.netbsd.org/tech-kern/2017/09/08/msg022267.html

Sponsored by <The NetBSD Foundation>
 1.69 21-Apr-2017  christos branches: 1.69.4; 1.69.10;
- Propagate the signal mask from the ucontext_t to the newly created thread
as specified by _lwp_create(2)
- Reset the signal stack for threads created with _lwp_create(2)
 1.68 03-Jul-2015  christos branches: 1.68.2; 1.68.4;
PR/50021: Rin Okuyama: Fix linux affinity syscalls
XXX: pullup-7
 1.67 09-Nov-2014  maxv branches: 1.67.2;
Do not uselessly include <sys/malloc.h>.
 1.66 23-Jan-2014  njoly branches: 1.66.4;
Fix inverted pid/lid arguments in do_sched_{get,set}param calls.
 1.65 18-Aug-2011  christos branches: 1.65.2; 1.65.12; 1.65.16;
Better debugging.
 1.64 05-Jun-2011  dsl Delete some splurious commas and very unexpected trailing space
 1.63 07-Jul-2010  chs branches: 1.63.2; 1.63.6;
many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.62 01-Jul-2010  rmind Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
 1.61 03-Sep-2009  njoly branches: 1.61.2; 1.61.4;
Use correct sched_setscheduler syscall 3rd argument type.
 1.60 23-Jun-2009  njoly sched_getaffinity(2) update:
- dynamically calculate the cpu mask size,
- return it upon success,
- fix generated cpu mask.
 1.59 18-Jun-2009  njoly In linux_sys_sched_getaffinity(), do not leak memory on error.
 1.58 25-Oct-2008  christos branches: 1.58.4; 1.58.8; 1.58.10;
Add preliminary tls support for i386. Does not work yet. From FreeBSD.
 1.57 07-May-2008  njoly branches: 1.57.2; 1.57.6;
Restore sched_native2linux() KASSERTs, i accidentally disabled in a
previous commit.
 1.56 05-May-2008  jmcneill Wrap debug printfs in #ifdef DEBUG_LINUX (hi njoly!)
 1.55 01-May-2008  njoly Add SCHED_FIFO/SCHED_RR support to sched_get_priority_{min,max}.
 1.54 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.53 24-Apr-2008  ad branches: 1.53.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.52 23-Apr-2008  ad Tweak previous.
 1.51 23-Apr-2008  ad Fix locking.
 1.50 29-Feb-2008  elad branches: 1.50.2;
In linux_sys_sched_getparam(), get the native policy too, so that we have
a better chance at properly converting the priority.

Noted by & okay yamt@.
 1.49 28-Feb-2008  elad Factor out the guts of get/setparam so it can be used from the compat code.

Make the FreeBSD and Linux compat code convert the parameters to their
native representation and call the native routines.

Remove KAUTH_PROCESS_SCHEDULER_GET/SET.

Update documentation and examples.

XXX: For now, only the Linux compat code does the priority conversion
XXX: right.

Linux priority conversion code from yamt@, thanks!

Okay yamt@.
 1.48 16-Feb-2008  elad branches: 1.48.2; 1.48.6;
Fold KAUTH_REQ_PROCESS_SCHEDULER_* to KAUTH_PROCESS_SCHEDULER_*. In other
words, don't pass an action and a request, and just use a single action to
indicate what is the operation in question.

This is the first step in fixing PR/37986, which calls for policy/priority
checking in the secmodel code. Right now we're lacking room for another
parameter required to make a decision, and this change makes room for such.
 1.47 23-Jan-2008  elad Tons of process scope changes.

- Add a KAUTH_PROCESS_SCHEDULER action, to handle scheduler related
requests, and add specific requests for set/get scheduler policy and
set/get scheduler parameters.

- Add a KAUTH_PROCESS_KEVENT_FILTER action, to handle kevent(2) related
requests.

- Add a KAUTH_DEVICE_TTY_STI action to handle requests to TIOCSTI.

- Add requests for the KAUTH_PROCESS_CANSEE action, indicating what
process information is being looked at (entry itself, args, env,
open files).

- Add requests for the KAUTH_PROCESS_RLIMIT action indicating set/get.

- Add requests for the KAUTH_PROCESS_CORENAME action indicating set/get.

- Make bsd44 secmodel code handle the newly added rqeuests appropriately.

All of the above make it possible to issue finer-grained kauth(9) calls in
many places, removing some KAUTH_GENERIC_ISSUSER requests.

- Remove the "CAN" from KAUTH_PROCESS_CAN{KTRACE,PROCFS,PTRACE,SIGNAL}.

Discussed with christos@ and yamt@.
 1.46 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.45 08-Dec-2007  dsl branches: 1.45.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.44 19-Oct-2007  njoly branches: 1.44.2; 1.44.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.43 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.42 15-Feb-2007  ad branches: 1.42.6; 1.42.18; 1.42.20; 1.42.24;
Count the number of CPUs at boot and stash in 'ncpu'. Eventually should
have each CPU register at attach, so we can figure out the topology for
the scheduler.
 1.41 09-Feb-2007  ad Acquire proclist_mutex before sending signals.
 1.40 09-Feb-2007  ad Merge newlock2 to head.
 1.39 05-Feb-2007  njoly Add a new linux_emuldata_shared flag value LINUX_LES_USE_NPTL to allow
both NPTL and old linuxthreads behaviour depending on process needs.

Apply to exit_group(), getpid() and getppid() to share them between
compat linux32 (non NPTL) and compat linux (NPTL) on amd64.

ok by manu and christos
 1.38 05-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.37 16-Nov-2006  christos branches: 1.37.2;
__unused removal on arguments; approved by core.
 1.36 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.35 23-Aug-2006  dogcow branches: 1.35.2; 1.35.4;
move #ifdef up a few lines to prevent unused variable warning/error
 1.34 23-Aug-2006  manu 1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

The thread group leader must report the exit status, even if it exits
because of another thread calling exit_group(). We do that by storing the
exit status in struct linux_emuldata_shared, and the exit hook has the
duty of setting struct proc's p_xstat for the thread group leader.

2) For exit/fork/exec hooks, move the NPTL specific code to separate functions
that are shared between COMPAT_LINUX and COMPAT_LINUX32

3) Fix LINUX_CLONE_PARENT_SETTID semantics
 1.33 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.32 26-Jun-2006  manu Do not implement exit_group() the right way on platforms that do not
define LINUX_NPTL yet, that cause firefox-bin to fail.
 1.31 25-Jun-2006  manu - Complete exit_group() implementation. We now maintain a list of Linux
threads in a processes and kill them properly. The code is a bit too
complicated, but I could not find a simplier way of dealing with it

- Change getpid() and getppid() semantics to match what Linux does,
and implement gettid(). In the Linux kernel, threads are implemnted
as plain old processes. A thread group is just a set of processes,
with the parent called leader. Thread ID, which are returned by gettid(),
are just the PID of the plain old processes, and getpid() returns the
PID of the thread group leader.

- Remove struct linux32_emuldata. COMPAT_LINUX32 uses a lot of COMPAT_LINUX
code, where a struct linux_emuldata is assumed. By having distinct emuldata
structure with different sizes and layouts, we caused kernel memory
corruptions.

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.
 1.30 14-May-2006  elad branches: 1.30.4;
integrate kauth.
 1.29 29-Nov-2005  jdolecek branches: 1.29.4; 1.29.6; 1.29.8; 1.29.10; 1.29.12;
undo linux_sys_exit_group() change _again_ - please do not commit known
broken code
 1.28 29-Nov-2005  manu Threads should not send a signal on exit.
 1.27 23-Nov-2005  manu - Add Linux tkill and tgkill (partial emulation).
- Fix getrlimit on amd64
 1.26 11-Nov-2005  jdolecek branches: 1.26.2;
undo the linux_sys_exit_group() change for now - complete CLONE_THREAD support
is necessary for this to work properly
 1.25 09-Nov-2005  manu Fix build problem
 1.24 09-Nov-2005  manu Improve Linux exit_group emulation by sending a SIGKILL to all other
processes in the group instead of letting them live. It would be better
to properly terminate them.
 1.23 05-Nov-2005  manu ifdef out sched_{get|set}affinity for ports that don't use it yet. That
should fix build.
 1.22 05-Nov-2005  manu Implement Linux sched_{set|get}affinity
 1.21 05-Nov-2005  manu Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()
 1.20 04-Nov-2005  manu Implement Linux futex ang gettid
 1.19 22-Jun-2005  manu branches: 1.19.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.
 1.18 10-Sep-2004  wiz Fix typo in comment.
 1.17 09-Sep-2004  tron Next attempt to fix the RCS Id. *sigh*
 1.16 09-Sep-2004  tron Fix RCS Id lossage caused by last commit.
 1.15 09-Sep-2004  tron Finish linux_sys_exit_group() with a (never reached) "return" statement so
that GCC will actually compile this.
 1.14 08-Sep-2004  jdolecek implement basic exit_group(2), which just terminates calling thread;
apparently not many apps use thread groups yet, at least not with default
SuSE 9.1 libraries, so this is enough for now
 1.13 08-Sep-2004  jdolecek do more strict flag checking in clone(2) (matches what Linux does)
 1.12 18-Jan-2003  thorpej branches: 1.12.2;
Merge the nathanw_sa branch.
 1.11 22-Dec-2002  gmcgarry Use yield() for voluntary context switches.
 1.10 31-Mar-2002  christos branches: 1.10.6;
make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.9 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.8 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.7 25-Aug-2000  thorpej branches: 1.7.2; 1.7.4;
Make need_resched() take a "struct cpu_info *" argument. This
causes gives a primitive form of processor affinity. Its use in
roundrobin() still needs some work.
 1.6 28-May-2000  thorpej Rather than starting init and creating kthreads by forking and then
doing a cpu_set_kpc(), just pass the entry point and argument all
the way down the fork path starting with fork1(). In order to
avoid special-casing the normal fork in every cpu_fork(), MI code
passes down child_return() and the child process pointer explicitly.

This fixes a race condition on multiprocessor systems; a CPU could
grab the newly created processes (which has been placed on a run queue)
before cpu_set_kpc() would be performed.
 1.5 30-Mar-2000  augustss branches: 1.5.2;
Kill register declarations.
 1.4 04-Dec-1999  tron Allow signal numbers upto 63 in clone(2) emulation.
 1.3 21-Oct-1999  itohy Add #include <machine/cpu.h> for need_resched() macro.
 1.2 11-Oct-1999  thorpej branches: 1.2.2; 1.2.4;
Fix typos in the license notice.
 1.1 04-Oct-1999  tron branches: 1.1.2;
Add emulation for scheduler related syscalls. Although they are dummies
even under Linux the posix thread library for "glibc2" requires them.
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.7.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.7 29-Dec-2002  thorpej Sync with HEAD.
 1.7.2.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.7.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.7.2.4 17-Apr-2002  nathanw Catch up to -current.
 1.7.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.7.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.7.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.10.6.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.12.2.4 11-Dec-2005  christos Sync with head.
 1.12.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.2.2 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.1 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.8 17-Mar-2008  yamt sync with head.
 1.19.2.7 27-Feb-2008  yamt sync with head.
 1.19.2.6 04-Feb-2008  yamt sync with head.
 1.19.2.5 21-Jan-2008  yamt sync with head
 1.19.2.4 27-Oct-2007  yamt sync with head.
 1.19.2.3 26-Feb-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.26.2.1 29-Nov-2005  yamt sync with head.
 1.29.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.29.10.2 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.29.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.29.8.4 03-Sep-2006  yamt sync with head.
 1.29.8.3 11-Aug-2006  yamt sync with head
 1.29.8.2 26-Jun-2006  yamt sync with head.
 1.29.8.1 24-May-2006  yamt sync with head.
 1.29.6.1 01-Jun-2006  kardel Sync with head.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.30.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.35.4.2 10-Dec-2006  yamt sync with head.
 1.35.4.1 22-Oct-2006  yamt sync with head
 1.35.2.4 09-Feb-2007  ad Sync with HEAD.
 1.35.2.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.35.2.2 12-Jan-2007  ad Sync with head.
 1.35.2.1 18-Nov-2006  ad Sync with head.
 1.37.2.2 21-Jun-2009  bouyer Pull up following revision(s) (requested by njoly in ticket #1328):
sys/compat/linux/common/linux_sched.c: revision 1.59
In linux_sys_sched_getaffinity(), do not leak memory on error.
 1.37.2.1 28-Mar-2007  jdc branches: 1.37.2.1.6;
Pull up revision 1.39 (requested by njoly in ticket #523).

Add a new linux_emuldata_shared flag value LINUX_LES_USE_NPTL to allow
both NPTL and old linuxthreads behaviour depending on process needs.

Apply to exit_group(), getpid() and getppid() to share them between
compat linux32 (non NPTL) and compat linux (NPTL) on amd64.

ok by manu and christos
 1.37.2.1.6.1 21-Jun-2009  bouyer Pull up following revision(s) (requested by njoly in ticket #1328):
sys/compat/linux/common/linux_sched.c: revision 1.59
In linux_sys_sched_getaffinity(), do not leak memory on error.
 1.42.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.42.20.3 23-Mar-2008  matt sync with HEAD
 1.42.20.2 09-Jan-2008  matt sync with HEAD
 1.42.20.1 06-Nov-2007  matt sync with HEAD
 1.42.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.42.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.42.6.1 23-Oct-2007  ad Sync with head.
 1.44.4.1 26-Dec-2007  ad Sync with head.
 1.44.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.45.4.2 23-Jan-2008  bouyer Sync with HEAD.
 1.45.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.48.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.48.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.48.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.48.2.1 24-Mar-2008  keiichi sync with head.
 1.50.2.1 18-May-2008  yamt sync with head.
 1.53.2.5 11-Aug-2010  yamt sync with head.
 1.53.2.4 16-Sep-2009  yamt sync with head
 1.53.2.3 18-Jul-2009  yamt sync with head.
 1.53.2.2 04-May-2009  yamt sync with head.
 1.53.2.1 16-May-2008  yamt sync with head.
 1.57.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.57.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.57.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.58.10.1 19-Jun-2009  snj branches: 1.58.10.1.2;
Pull up following revision(s) (requested by njoly in ticket #822):
sys/compat/linux/common/linux_sched.c: revision 1.59
In linux_sys_sched_getaffinity(), do not leak memory on error.
 1.58.10.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.58.8.1 23-Jul-2009  jym Sync with HEAD.
 1.58.4.1 19-Jun-2009  snj Pull up following revision(s) (requested by njoly in ticket #822):
sys/compat/linux/common/linux_sched.c: revision 1.59
In linux_sys_sched_getaffinity(), do not leak memory on error.
 1.61.4.3 12-Jun-2011  rmind sync with head
 1.61.4.2 05-Mar-2011  rmind sync with head
 1.61.4.1 03-Jul-2010  rmind sync with head
 1.61.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.63.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.63.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.65.16.1 18-May-2014  rmind sync with head
 1.65.12.2 03-Dec-2017  jdolecek update from HEAD
 1.65.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.65.2.1 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.66.4.2 31-Dec-2016  snj Pull up following revision(s) (requested by rin in ticket #1343):
sys/compat/linux/common/linux_sched.c: revision 1.68
PR/50021: Rin Okuyama: Fix linux affinity syscalls
 1.66.4.1 17-Jan-2015  martin branches: 1.66.4.1.4;
Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.66.4.1.4.1 18-Jan-2017  skrll Sync with netbsd-5
 1.67.2.2 28-Aug-2017  skrll Sync with HEAD
 1.67.2.1 22-Sep-2015  skrll Sync with HEAD
 1.68.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.68.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.69.10.2 22-Apr-2018  pgoyette Sync with HEAD
 1.69.10.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.69.4.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.71.6.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.71.2.2 21-Apr-2020  martin Sync with HEAD
 1.71.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.73.6.2 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.73.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.79.10.1 02-Aug-2025  perseant Sync with HEAD
 1.83.2.1 09-Oct-2025  martin Pull up following revision(s) (requested by christos in ticket #49):

sys/compat/linux/common/linux_sched.h: revision 1.12
sys/compat/linux/common/linux_sched.c: revision 1.84
sys/compat/linux/common/linux_sched.c: revision 1.85

PR/59608: csaba mate: fix stack address and ignore sysvsem flag. makes
the
latest jvm work again.

cl_args.stack_size is uint64_t (all architectures), on ILP32 (void *)
is 32 bits, as is (intptr_t). 32 bits added to 64 bits --> 64 bits,
which gcc complains about converting to a pointer. Add yet another
cast.

Should fix ILP32 builds (eg: i386)
 1.12 19-Sep-2025  christos PR/59608: csaba mate: fix stack address and ignore sysvsem flag. makes the
latest jvm work again.
 1.11 28-Sep-2024  christos branches: 1.11.2;
Linux GSoC-2024: renameat2, clone3, sync_file_range, syncfs (Shivraj Jamgade)
 1.10 19-Sep-2021  thorpej branches: 1.10.10;
Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.9 19-Sep-2021  thorpej Add the POSIX timer syscalls (timer_create(), timer_settime(), timer_gettime(),
timer_getoverrun(), and timer_delete()) to COMPAT_LINUX and COMPAT_LINUX32.
 1.8 18-Nov-2011  christos branches: 1.8.64;
- add sigtimedwait support.
- merge the siginfo population code.
 1.7 28-Apr-2008  martin branches: 1.7.34;
Remove clause 3 and 4 from TNF licenses
 1.6 17-Apr-2008  njoly branches: 1.6.2; 1.6.4;
Add compat linux32 sys_clock_{getres,gettime,settime} syscalls.
 1.5 11-Dec-2005  christos branches: 1.5.70;
merge ktrace-lwp.
 1.4 16-May-2005  fvdl Implement clock_* POSIX functions.
 1.3 05-Sep-2004  jdolecek add some newer clone flags
 1.2 04-Oct-1999  tron branches: 1.2.36;
Add emulation for scheduler related syscalls. Although they are dummies
even under Linux the posix thread library for "glibc2" requires them.
 1.1 12-May-1999  thorpej branches: 1.1.2;
Add scheduling-related definitions. Currently we have the flags passed
to the __clone(2) system call.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.36.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.36.2 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.1 18-Sep-2004  skrll Sync with HEAD.
 1.5.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.4.1 16-May-2008  yamt sync with head.
 1.6.2.1 18-May-2008  yamt sync with head.
 1.7.34.1 17-Apr-2012  yamt sync with head
 1.8.64.2 17-Dec-2020  thorpej Re-factor the code that maps the clockid_t in timer_create() and
the flags in timerfd_settime() into separate functions.
 1.8.64.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.10.10.1 02-Aug-2025  perseant Sync with HEAD
 1.11.2.1 09-Oct-2025  martin Pull up following revision(s) (requested by christos in ticket #49):

sys/compat/linux/common/linux_sched.h: revision 1.12
sys/compat/linux/common/linux_sched.c: revision 1.84
sys/compat/linux/common/linux_sched.c: revision 1.85

PR/59608: csaba mate: fix stack address and ignore sysvsem flag. makes
the
latest jvm work again.

cl_args.stack_size is uint64_t (all architectures), on ILP32 (void *)
is 32 bits, as is (intptr_t). 32 bits added to 64 bits --> 64 bits,
which gcc complains about converting to a pointer. Add yet another
cast.

Should fix ILP32 builds (eg: i386)
 1.11 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 24-Apr-2008  njoly branches: 1.9.2;
Add IPC_64 support for semctl IPC_STAT/IPC_SET.
 1.8 20-Dec-2007  dsl branches: 1.8.6; 1.8.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.7 04-Dec-2007  dsl branches: 1.7.4;
Remove all the __P
 1.6 09-Feb-2006  manu branches: 1.6.38; 1.6.40; 1.6.46; 1.6.50;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.5 18-Jan-2003  thorpej branches: 1.5.18; 1.5.30; 1.5.32; 1.5.34;
Merge the nathanw_sa branch.
 1.4 04-Oct-1998  fvdl branches: 1.4.24;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Move IPC headers to common. The msg, sem and shm files, in addition to other common structures and to avoid creating several more machine dependent header files, include the syscall arguments for several system calls which don't exist on all architechtures.
 1.1 15-Aug-1995  fvdl Implement the rest of the sysv ipc calls ({sem,msg}*())
 1.4.24.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.5.34.1 22-Apr-2006  simonb Sync with head.
 1.5.32.1 09-Sep-2006  rpaulo sync with head
 1.5.30.1 18-Feb-2006  yamt sync with head.
 1.5.18.3 21-Jan-2008  yamt sync with head
 1.5.18.2 07-Dec-2007  yamt sync with head
 1.5.18.1 21-Jun-2006  yamt sync with head.
 1.6.50.2 26-Dec-2007  ad Sync with head.
 1.6.50.1 08-Dec-2007  ad Sync with head.
 1.6.46.2 27-Dec-2007  mjf Sync with HEAD.
 1.6.46.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.40.1 09-Jan-2008  matt sync with HEAD
 1.6.38.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.7.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.8.1 18-May-2008  yamt sync with head.
 1.8.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.2.1 16-May-2008  yamt sync with head.
 1.14 21-Nov-2017  maxv This should be "linux_sg_version", not "version".
 1.13 21-Mar-2008  ad branches: 1.13.6; 1.13.48; 1.13.84;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.12 20-Dec-2007  dsl branches: 1.12.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.11 19-Oct-2007  njoly branches: 1.11.4; 1.11.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.10 04-Mar-2007  christos branches: 1.10.14; 1.10.16; 1.10.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 09-Feb-2007  ad branches: 1.9.2;
Merge newlock2 to head.
 1.8 13-Sep-2006  christos Avoid empty body in if
 1.7 11-Dec-2005  christos branches: 1.7.8; 1.7.20;
merge ktrace-lwp.
 1.6 04-Nov-2005  chs make this compile on m68k by including sys/device.h explicitly.
on other platforms it's apparently included implicitly, probably through cpu.h.
 1.5 26-Feb-2005  perry branches: 1.5.2; 1.5.4; 1.5.6;
nuke trailing whitespace
 1.4 13-Feb-2005  soren SG_GET_VERSION_NUM returns an int. Also make the version number patchable.
 1.3 13-Feb-2005  christos Don't zero out the linux request; we still need values from it.
Limit the sense len to the linux input buffer.
 1.2 13-Feb-2005  christos We were zeroing out the wrong struct.
 1.1 03-Feb-2005  christos branches: 1.1.2; 1.1.4;
Add linux scsi-generic to work for simple cases. Allows gendalia's change
to limp along. From soren with fixes from me.
 1.1.4.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.4.2 12-Feb-2005  yamt sync with head.
 1.1.4.1 03-Feb-2005  yamt file linux_sg.c was added on branch yamt-km on 2005-02-12 18:17:41 +0000
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.3 15-Feb-2005  skrll Sync with HEAD.
 1.1.2.2 04-Feb-2005  skrll Sync with HEAD.
 1.1.2.1 03-Feb-2005  skrll file linux_sg.c was added on branch ktrace-lwp on 2005-02-04 11:45:08 +0000
 1.5.6.7 24-Mar-2008  yamt sync with head.
 1.5.6.6 21-Jan-2008  yamt sync with head
 1.5.6.5 27-Oct-2007  yamt sync with head.
 1.5.6.4 03-Sep-2007  yamt sync with head.
 1.5.6.3 26-Feb-2007  yamt sync with head.
 1.5.6.2 30-Dec-2006  yamt sync with head.
 1.5.6.1 21-Jun-2006  yamt sync with head.
 1.5.4.2 29-Apr-2005  kent sync with -current
 1.5.4.1 26-Feb-2005  kent file linux_sg.c was added on branch kent-audio2 on 2005-04-29 11:28:40 +0000
 1.5.2.1 11-Oct-2006  ghen Pull up following revision(s) (requested by tsutsui in ticket #1526):
sys/compat/linux/common/linux_sg.c: revision 1.6
make this compile on m68k by including sys/device.h explicitly.
on other platforms it's apparently included implicitly, probably through cpu.h.
 1.7.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.7.20.1 18-Nov-2006  ad Sync with head.
 1.7.8.1 14-Sep-2006  yamt sync with head.
 1.9.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.16.2 09-Jan-2008  matt sync with HEAD
 1.10.16.1 06-Nov-2007  matt sync with HEAD
 1.10.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.11.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.4.1 26-Dec-2007  ad Sync with head.
 1.12.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.84.1 30-Nov-2017  martin Pull up following revision(s) (requested by maxv in ticket #400):
sys/compat/linux/common/linux_sg.c: revision 1.14
This should be "linux_sg_version", not "version".
 1.13.48.1 03-Dec-2017  jdolecek update from HEAD
 1.13.6.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.13.6.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 26-Feb-2005  perry branches: 1.2.4;
nuke trailing whitespace
 1.1 03-Feb-2005  christos branches: 1.1.2; 1.1.4;
Add linux scsi-generic to work for simple cases. Allows gendalia's change
to limp along. From soren with fixes from me.
 1.1.4.3 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.1.4.2 12-Feb-2005  yamt sync with head.
 1.1.4.1 03-Feb-2005  yamt file linux_sg.h was added on branch yamt-km on 2005-02-12 18:17:41 +0000
 1.1.2.3 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.2.2 04-Feb-2005  skrll Sync with HEAD.
 1.1.2.1 03-Feb-2005  skrll file linux_sg.h was added on branch ktrace-lwp on 2005-02-04 11:45:08 +0000
 1.2.4.2 29-Apr-2005  kent sync with -current
 1.2.4.1 26-Feb-2005  kent file linux_sg.h was added on branch kent-audio2 on 2005-04-29 11:28:40 +0000
 1.12 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 28-Jan-2008  njoly branches: 1.11.6; 1.11.8; 1.11.10;
Update struct linux_shmid64_ds for 64bits archs.
- shm_segsz should be of type size_t, not int.
- Disable padding fields used on 32bits archs.
 1.10 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.9 04-Dec-2007  dsl branches: 1.9.4;
Remove all the __P
 1.8 09-Feb-2006  manu branches: 1.8.38; 1.8.40; 1.8.46; 1.8.50;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.7 10-Nov-2005  christos branches: 1.7.4; 1.7.6; 1.7.8;
More ipc support for linux; makes oracle work. From chuq and
jlrodriguez at terra dot es
 1.6 28-Sep-2004  jdolecek branches: 1.6.12;
add flag for shmget(2) to specify that later shmat(2) for the shared memory
segment should succeed even if the segment would be marked removed; use this
to implement the Linux-compatible semantics of shmat(2)

this fixes the old Linux VMware3 graphics problem with local display,
and possibly other local Linux X clients using MIT-SHM
 1.5 18-Jan-2003  thorpej branches: 1.5.2; 1.5.4;
Merge the nathanw_sa branch.
 1.4 04-Oct-1998  fvdl branches: 1.4.24;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Move IPC headers to common. The msg, sem and shm files, in addition to other common structures and to avoid creating several more machine dependent header files, include the syscall arguments for several system calls which don't exist on all architechtures.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.4.24.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.5.4.1 04-Oct-2004  jmc Pullup rev 1.6 (requested by jdolecek in ticket #884)

Fix linux handling of SysV-style shared memory. Fixed Linux VMware display
problems.
 1.5.2.2 11-Dec-2005  christos Sync with head.
 1.5.2.1 19-Oct-2004  skrll Sync with HEAD
 1.6.12.4 04-Feb-2008  yamt sync with head.
 1.6.12.3 21-Jan-2008  yamt sync with head
 1.6.12.2 07-Dec-2007  yamt sync with head
 1.6.12.1 21-Jun-2006  yamt sync with head.
 1.7.8.1 22-Apr-2006  simonb Sync with head.
 1.7.6.1 09-Sep-2006  rpaulo sync with head
 1.7.4.1 18-Feb-2006  yamt sync with head.
 1.8.50.2 26-Dec-2007  ad Sync with head.
 1.8.50.1 08-Dec-2007  ad Sync with head.
 1.8.46.3 18-Feb-2008  mjf Sync with HEAD.
 1.8.46.2 27-Dec-2007  mjf Sync with HEAD.
 1.8.46.1 08-Dec-2007  mjf Sync with HEAD.
 1.8.40.2 23-Mar-2008  matt sync with HEAD
 1.8.40.1 09-Jan-2008  matt sync with HEAD
 1.8.38.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.9.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.10.1 16-May-2008  yamt sync with head.
 1.11.8.1 18-May-2008  yamt sync with head.
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.41 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.40 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.39 02-Jun-2009  njoly Add the mask value returned by siggetmask.
 1.38 28-Apr-2008  martin branches: 1.38.2; 1.38.14;
Remove clause 3 and 4 from TNF licenses
 1.37 24-Apr-2008  ad branches: 1.37.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.36 20-Dec-2007  dsl branches: 1.36.6; 1.36.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.35 08-Dec-2007  dsl branches: 1.35.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.34 19-Oct-2007  njoly branches: 1.34.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.33 09-Feb-2007  ad branches: 1.33.18; 1.33.20; 1.33.24;
Merge newlock2 to head.
 1.32 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.31 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.30 11-Dec-2005  christos branches: 1.30.20; 1.30.22;
merge ktrace-lwp.
 1.29 03-May-2005  manu branches: 1.29.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.28 26-Feb-2005  perry nuke trailing whitespace
 1.27 18-Jan-2003  thorpej branches: 1.27.2; 1.27.10; 1.27.12;
Merge the nathanw_sa branch.
 1.26 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.25 31-Mar-2002  christos branches: 1.25.2;
make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.24 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.23 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.22 30-Mar-2000  augustss branches: 1.22.6; 1.22.8;
Kill register declarations.
 1.21 04-Dec-1999  tron Fix typo in last commit.
 1.20 04-Dec-1999  tron Adapt to renamed system call argument.
 1.19 04-Dec-1999  tron Add bound checks in emulation of signal(2) and return SIG_ERR on failure.
This fixes a part of PR kern/8904 by Dave Sainty.
 1.18 07-Oct-1998  erh branches: 1.18.12; 1.18.18;
Fix typos.
 1.17 07-Oct-1998  erh sigprocmask (non-rt version) doesn't exist on alpha. Add it here.
 1.16 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.15 03-Oct-1998  christos Attempt to fix the mess.
 1.14 01-Oct-1998  erh Split compat/linux/linux_signal.c into i386, common and multi-architecture parts.
 1.13 29-Sep-1998  tv Bracket stray printf()s by #ifdef DEBUG.
 1.12 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.11 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.10 04-Apr-1996  christos - Add missing prototypes
- Fix bugs with reversed arguments that prototyping discovered
 1.9 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.8 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.7 14-Aug-1995  mycroft Move signal types into signal.h.
 1.6 13-Aug-1995  mycroft Convert SA_NOMASK and SA_ONESHOT.
Clean up this code a bit.
 1.5 24-Jun-1995  christos Use compat_util.[ch].
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 10-Mar-1995  fvdl Add the Linux pause() system call. Fix the arguments to sigsuspend().
 1.2 08-Mar-1995  fvdl Fix typo in comment.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.18.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.22.8.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.22.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.22.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.22.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.22.6.8 01-Aug-2002  nathanw Catch up to -current.
 1.22.6.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.22.6.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.22.6.5 17-Apr-2002  nathanw Catch up to -current.
 1.22.6.4 28-Feb-2002  nathanw Catch up to -current.
 1.22.6.3 06-Dec-2001  wdk #include <sys/lwp.h> for Mips architectures.
 1.22.6.2 14-Nov-2001  nathanw Catch up to -current.
 1.22.6.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.25.2.1 15-Jul-2002  gehenna catch up with -current.
 1.27.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.27.10.1 29-Apr-2005  kent sync with -current
 1.27.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.27.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.29.2.4 21-Jan-2008  yamt sync with head
 1.29.2.3 27-Oct-2007  yamt sync with head.
 1.29.2.2 26-Feb-2007  yamt sync with head.
 1.29.2.1 30-Dec-2006  yamt sync with head.
 1.30.22.2 10-Dec-2006  yamt sync with head.
 1.30.22.1 22-Oct-2006  yamt sync with head
 1.30.20.4 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.30.20.3 19-Jan-2007  ad Fix Linux compatability for i386, others to follow later.
 1.30.20.2 18-Nov-2006  ad Sync with head.
 1.30.20.1 24-Oct-2006  ad - Redo LWP locking slightly and fix some races.
- Fix some locking botches.
- Make signal mask / stack per-proc for SA processes.
- Add _lwp_kill().
 1.33.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.33.20.2 09-Jan-2008  matt sync with HEAD
 1.33.20.1 06-Nov-2007  matt sync with HEAD
 1.33.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.33.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.34.4.1 26-Dec-2007  ad Sync with head.
 1.35.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.36.8.1 18-May-2008  yamt sync with head.
 1.36.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.37.2.2 20-Jun-2009  yamt sync with head
 1.37.2.1 16-May-2008  yamt sync with head.
 1.38.14.1 23-Jul-2009  jym Sync with HEAD.
 1.38.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.38.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.36 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.35 07-Jan-2018  christos Ignore signal 64 for now (go uses it)
XXX: pullup-8
 1.34 17-Oct-2008  njoly g/c amd64 ifndef/endif.
 1.33 28-Apr-2008  martin branches: 1.33.2; 1.33.6;
Remove clause 3 and 4 from TNF licenses
 1.32 20-Dec-2007  dsl branches: 1.32.6; 1.32.8; 1.32.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.31 19-Oct-2007  njoly branches: 1.31.4; 1.31.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.30 09-Feb-2007  ad branches: 1.30.18; 1.30.20; 1.30.24;
Merge newlock2 to head.
 1.29 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.28 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.27 11-Dec-2005  christos branches: 1.27.20; 1.27.22;
merge ktrace-lwp.
 1.26 03-May-2005  manu branches: 1.26.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.25 18-Jan-2003  thorpej branches: 1.25.2;
Merge the nathanw_sa branch.
 1.24 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.23 31-Mar-2002  christos branches: 1.23.2;
make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.22 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.21 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.20 09-Aug-2000  tv branches: 1.20.2; 1.20.4;
Pretend to do something useful (just fill in oldsigaction with SIG_IGN and
zeroes) if the mapped signal number comes up zero. Previously, sigaction1()
would return an error, confusing some linux apps trying to set handlers for
"all" signals.
 1.19 30-Mar-2000  augustss Kill register declarations.
 1.18 04-Dec-1999  tron Add bound checks in emulation of sigaction(2). This fixes a part of
PR kern/8904 by Dave Sainty.
 1.17 07-Oct-1998  erh branches: 1.17.12; 1.17.18;
This is used on the alpha. It is called osf_sigaction under linux because of the format of the sigaction structure but it acts the same.
 1.16 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.15 03-Oct-1998  christos Attempt to fix the mess.
 1.14 01-Oct-1998  erh Split compat/linux/linux_signal.c into i386, common and multi-architecture parts.
 1.13 29-Sep-1998  tv Bracket stray printf()s by #ifdef DEBUG.
 1.12 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.11 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.10 04-Apr-1996  christos - Add missing prototypes
- Fix bugs with reversed arguments that prototyping discovered
 1.9 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.8 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.7 14-Aug-1995  mycroft Move signal types into signal.h.
 1.6 13-Aug-1995  mycroft Convert SA_NOMASK and SA_ONESHOT.
Clean up this code a bit.
 1.5 24-Jun-1995  christos Use compat_util.[ch].
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 10-Mar-1995  fvdl Add the Linux pause() system call. Fix the arguments to sigsuspend().
 1.2 08-Mar-1995  fvdl Fix typo in comment.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.17.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.17.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.20.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.20.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.20.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.2.8 01-Aug-2002  nathanw Catch up to -current.
 1.20.2.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.20.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.20.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.20.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.20.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.20.2.2 30-Aug-2001  nathanw #include <sys/lwp.h>
 1.20.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.23.2.1 15-Jul-2002  gehenna catch up with -current.
 1.25.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.4 21-Jan-2008  yamt sync with head
 1.26.2.3 27-Oct-2007  yamt sync with head.
 1.26.2.2 26-Feb-2007  yamt sync with head.
 1.26.2.1 30-Dec-2006  yamt sync with head.
 1.27.22.2 10-Dec-2006  yamt sync with head.
 1.27.22.1 22-Oct-2006  yamt sync with head
 1.27.20.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.27.20.2 18-Nov-2006  ad Sync with head.
 1.27.20.1 24-Oct-2006  ad - Redo LWP locking slightly and fix some races.
- Fix some locking botches.
- Make signal mask / stack per-proc for SA processes.
- Add _lwp_kill().
 1.30.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.30.20.2 09-Jan-2008  matt sync with HEAD
 1.30.20.1 06-Nov-2007  matt sync with HEAD
 1.30.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.31.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.31.4.1 26-Dec-2007  ad Sync with head.
 1.32.10.2 04-May-2009  yamt sync with head.
 1.32.10.1 16-May-2008  yamt sync with head.
 1.32.8.1 18-May-2008  yamt sync with head.
 1.32.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.32.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.6.1 19-Oct-2008  haad Sync with HEAD.
 1.33.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.33.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.3 19-Sep-2021  thorpej - LINUX_SIGEV_PAD is incorrect for 64-bit systems, because sigval_t
contains a pointer. Correct this.
- Add routines to convert from Linux to native sigevent_t.
 1.2 28-Apr-2008  martin branches: 1.2.100;
Remove clause 3 and 4 from TNF licenses
 1.1 16-May-2005  fvdl branches: 1.1.8; 1.1.80; 1.1.82; 1.1.84;
Add Linux sigevent definitions.
 1.1.84.1 16-May-2008  yamt sync with head.
 1.1.82.1 18-May-2008  yamt sync with head.
 1.1.80.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.8.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.8.1 16-May-2005  skrll file linux_sigevent.h was added on branch ktrace-lwp on 2005-11-10 14:01:07 +0000
 1.2.100.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.17 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.16 18-Nov-2011  martin Provide linux_siginfo_t for all archs, to unbreak kdump build.
 1.15 18-Nov-2011  christos - add sigtimedwait support.
- merge the siginfo population code.
 1.14 23-Nov-2008  njoly branches: 1.14.16;
Move si_code definitions from MD to MI linux_siginfo.h, all archs
(except mips for 3 values) are identical.
While here, remove unused/unneeded LINUX__SI_CODE macro. Only the
lower 16-bits are used for userland si_code.
 1.13 21-Oct-2008  njoly branches: 1.13.2;
Remove LINUX_SI_xxx from MI siginfo.h, that should not have been
committed. Rather add them to amd64 MD header.
Fix compilation failures on non x86 archs.
 1.12 19-Oct-2008  njoly Add native to linux siginfo si_code translation, mostly for negative
values. Adjust amd64 and i386 accordingly, not sure about aother archs
i can't test.
 1.11 28-Apr-2008  martin branches: 1.11.6;
Remove clause 3 and 4 from TNF licenses
 1.10 11-Dec-2005  christos branches: 1.10.70; 1.10.72; 1.10.74;
merge ktrace-lwp.
 1.9 24-Jun-2005  manu More accurate SIGCHLD code and status for siginfo
 1.8 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.7 05-Sep-2002  christos branches: 1.7.6;
remove XXX:
 1.6 03-Apr-2002  christos don't bail out if we don't have an arch/siginfo.h because we are being used
from userland.
 1.5 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.4 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.3 19-Jan-2001  manu branches: 1.3.2; 1.3.4; 1.3.6;
Added Linux compatibility support for powerpc ports
 1.2 15-Dec-1998  itohy branches: 1.2.8;
Added linux compat support on m68k ports.
 1.1 03-Oct-1998  christos Forgot those two.
 1.2.8.1 11-Feb-2001  bouyer Sync with HEAD.
 1.3.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.4 17-Sep-2002  nathanw Catch up to -current.
 1.3.2.3 17-Apr-2002  nathanw Catch up to -current.
 1.3.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.7.6.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.74.2 04-May-2009  yamt sync with head.
 1.10.74.1 16-May-2008  yamt sync with head.
 1.10.72.1 18-May-2008  yamt sync with head.
 1.10.70.2 17-Jan-2009  mjf Sync with HEAD.
 1.10.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.6.1 19-Oct-2008  haad Sync with HEAD.
 1.13.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.16.1 17-Apr-2012  yamt sync with head
 1.90 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.89 18-Aug-2023  christos branches: 1.89.6;
Add linux waitid(2) from GSoC 2023 (Theodore Preduta)
 1.88 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.87 27-Oct-2021  thorpej Use __SIGTRAMP_SIGCODE_VERSION rather than hard-coding 0.
 1.86 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.85 19-Sep-2021  thorpej - LINUX_SIGEV_PAD is incorrect for 64-bit systems, because sigval_t
contains a pointer. Correct this.
- Add routines to convert from Linux to native sigevent_t.
 1.84 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.83 23-May-2020  ad branches: 1.83.2;
Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.82 29-Apr-2020  thorpej Fix proc lookup by distinguishing between the "tgid" and "tid" cases.
 1.81 23-Aug-2019  maxv Fix info leaks in sigaltstack.
 1.80 07-Jan-2018  christos branches: 1.80.4; 1.80.8;
Ignore signal 64 for now (go uses it)
XXX: pullup-8
 1.79 20-Feb-2017  rin branches: 1.79.6;
KNF; no binary changes
 1.78 20-Feb-2017  rin CID 980928: fix NULL pointer dereferece
 1.77 14-Nov-2015  christos branches: 1.77.2; 1.77.4;
PR/50428: Rin Okuyama: support SA_RESTORER flag for rt_sigaction(2) in the
ports that support it.
 1.76 09-Nov-2014  maxv branches: 1.76.2;
Do not uselessly include <sys/malloc.h>.
 1.75 18-Nov-2011  christos branches: 1.75.10; 1.75.26;
remove one more kassert
 1.74 18-Nov-2011  christos remove incorrect assertions (the len passed is the size of the bsd structure
not the linux one)
 1.73 18-Nov-2011  christos - add sigtimedwait support.
- merge the siginfo population code.
 1.72 30-Jun-2011  wiz branches: 1.72.2;
dependant -> dependent
 1.71 07-Jul-2010  chs many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.70 01-Jul-2010  rmind Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
 1.69 08-Jun-2009  njoly branches: 1.69.2; 1.69.4;
Small rt_queueinfo(2) update, to require a linux_siginfo structure.
While here, cleanup ifdef out argument types.
 1.68 29-May-2009  njoly Add native to linux siginfo si_status translation, used on i386 and
amd64.
 1.67 18-Feb-2009  njoly Do not protect native_to_linux_si_code() under LINUX_NPTL anymore, now
that linux si_code definitions are MI.
 1.66 21-Oct-2008  njoly branches: 1.66.2; 1.66.8;
Do not use native_to_linux_si_code() outside LINUX_NPTL; until i
figure a better way to handle it.
 1.65 21-Oct-2008  njoly tkill/tgkill syscalls cleanup.

- Make both syscalls set si_code to SI_LWP (which will be converted to
Linux SI_TKILL value). Fix thread some cancellation under NPTL
emulation.
- Merge code in a new linux_do_tkill() function that will do its own
job, instead of calling linux_sys_kill().
- Do only alter single tasks, by rejecting non positive tid/tgid
values.
 1.64 19-Oct-2008  njoly Add native to linux siginfo si_code translation, mostly for negative
values. Adjust amd64 and i386 accordingly, not sure about aother archs
i can't test.
 1.63 30-Jul-2008  njoly Fix linux_sigismember/linux_sigaddset to work on amd64 (and other
64bits archs), by ensuring that bit shifts are done on correct type.
 1.62 28-Apr-2008  martin branches: 1.62.2; 1.62.4; 1.62.6;
Remove clause 3 and 4 from TNF licenses
 1.61 24-Apr-2008  ad branches: 1.61.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.60 24-Apr-2008  ad Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
be sent from a hardware interrupt handler. Signal activity must be
deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.59 23-Apr-2008  ad Tweak locking.
 1.58 20-Dec-2007  dsl branches: 1.58.6; 1.58.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.57 08-Dec-2007  dsl branches: 1.57.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.56 04-Dec-2007  dsl Remove all the __P
 1.55 19-Oct-2007  njoly branches: 1.55.2; 1.55.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.54 04-Mar-2007  christos branches: 1.54.14; 1.54.16; 1.54.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.53 09-Feb-2007  ad branches: 1.53.2;
Merge newlock2 to head.
 1.52 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.51 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.50 13-Sep-2006  christos branches: 1.50.2;
avoid empty if body.
 1.49 23-Nov-2005  manu branches: 1.49.8; 1.49.20;
- Add Linux tkill and tgkill (partial emulation).
- Fix getrlimit on amd64
 1.48 19-Sep-2005  christos branches: 1.48.6;
MINSIGSTKSZ on linux is different depending on the platform and usually
smaller than ours.
 1.47 20-May-2005  mrg branches: 1.47.2;
tramp and vers are used unconditionally, make them visible everywhere.
 1.46 19-May-2005  manu Add support for Linux SA_RESTORER on amd64.
 1.45 16-May-2005  fvdl Include linux_sigevent.h (to be used later).
 1.44 09-May-2005  jmc #endif for LINUX_SS_ONSTACK needs to go after linux_sys_sigaltstack or builds
break on platforms that don't define it (alpha, sparc)
 1.43 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.42 26-Feb-2005  perry nuke trailing whitespace
 1.41 03-Jul-2003  christos branches: 1.41.8; 1.41.10;
make the converter of sigaltstack public.
 1.40 18-Jan-2003  thorpej branches: 1.40.2;
Merge the nathanw_sa branch.
 1.39 26-Nov-2002  christos rename: s/sa_/<compat>sa/g
 1.38 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.37 31-Mar-2002  christos branches: 1.37.2;
make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.36 22-Mar-2002  christos gc debugging printfs.
 1.35 19-Mar-2002  christos - Now that RT-signals fit, fix the array to deliver them. [i386 only].
- jdk-1.4 works perfectly now. :-)
 1.34 18-Feb-2002  christos Resolve alpha compile issues:
- bug with order in args in mask conversion md code.
- flags can be both int and long on the alpha. kludge around that, by not
passing pointers to the conversion function.
- something is wrong with the toolchain look at the void * cast in copyout().
- sa_restorer is in a different place on the aplha. Deal with that, by not
initializing it as before. XXX: this should be changed in the MD signal
definition.
 1.33 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.32 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.31 18-Jan-2001  jdolecek branches: 1.31.2; 1.31.4;
constify
 1.30 23-Aug-2000  christos add support for sigaltstack(2) needed for jvm-1.3 support.
XXX: Only on i386, don't have access to other linuxes...
 1.29 09-Aug-2000  tv Pretend to do something useful (just fill in oldsigaction with SIG_IGN and
zeroes) if the mapped signal number comes up zero. Previously, sigaction1()
would return an error, confusing some linux apps trying to set handlers for
"all" signals.
 1.28 28-Jul-2000  tron Adoid excessive use of "return" in "excessive()".
 1.27 28-Jul-2000  tron Use "NULL" and not "0" for null pointers.
 1.26 30-Mar-2000  augustss branches: 1.26.4;
Kill register declarations.
 1.25 04-Dec-1999  tron Add bound checks in emulation of kill(2). This fixes the last part of
PR kern/8904 by Dave Sainty.
 1.24 04-Oct-1999  fvdl branches: 1.24.2; 1.24.8;
Handle the newer, larger sigset_t Linux now uses.
 1.23 30-Sep-1999  tron NetBSD's signal number 11 is SIGSYS nog SIGSEGV.
 1.22 08-Sep-1999  jdolecek Use DEBUG_LINUX exclusively. Fixes PR#7684.
 1.21 19-Dec-1998  drochner get "opt_compat_xxx.h" includes out of <sys/signal.h>
 1.20 15-Dec-1998  itohy Added linux compat support on m68k ports.
 1.19 07-Oct-1998  erh Fix typos.
 1.18 07-Oct-1998  erh Fix types. Kill old declarations.
 1.17 07-Oct-1998  erh sigprocmask (non-rt) version doesn't exist on alpha. rename it to sigprocmask1 for use in linux_sys_sigprocmask and linux_sys_rt_sigprocmask.
 1.16 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.15 03-Oct-1998  christos Attempt to fix the mess.
 1.14 01-Oct-1998  erh Split compat/linux/linux_signal.c into i386, common and multi-architecture parts.
 1.13 29-Sep-1998  tv Bracket stray printf()s by #ifdef DEBUG.
 1.12 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.11 09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.10 04-Apr-1996  christos - Add missing prototypes
- Fix bugs with reversed arguments that prototyping discovered
 1.9 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.8 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.7 14-Aug-1995  mycroft Move signal types into signal.h.
 1.6 13-Aug-1995  mycroft Convert SA_NOMASK and SA_ONESHOT.
Clean up this code a bit.
 1.5 24-Jun-1995  christos Use compat_util.[ch].
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 10-Mar-1995  fvdl Add the Linux pause() system call. Fix the arguments to sigsuspend().
 1.2 08-Mar-1995  fvdl Fix typo in comment.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.24.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.24.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.24.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.26.4.1 30-Mar-2001  he Pull up revision 1.29 (via patch, requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.31.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.31.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.31.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.31.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.31.2.9 11-Dec-2002  thorpej Sync with HEAD.
 1.31.2.8 01-Aug-2002  nathanw Catch up to -current.
 1.31.2.7 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.31.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.31.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.31.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.31.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.31.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.31.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.37.2.1 15-Jul-2002  gehenna catch up with -current.
 1.40.2.6 11-Dec-2005  christos Sync with head.
 1.40.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.40.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.40.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.40.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.40.2.1 03-Aug-2004  skrll Sync with HEAD
 1.41.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.41.8.1 29-Apr-2005  kent sync with -current
 1.47.2.7 21-Jan-2008  yamt sync with head
 1.47.2.6 07-Dec-2007  yamt sync with head
 1.47.2.5 27-Oct-2007  yamt sync with head.
 1.47.2.4 03-Sep-2007  yamt sync with head.
 1.47.2.3 26-Feb-2007  yamt sync with head.
 1.47.2.2 30-Dec-2006  yamt sync with head.
 1.47.2.1 21-Jun-2006  yamt sync with head.
 1.48.6.1 29-Nov-2005  yamt sync with head.
 1.49.20.4 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.49.20.3 19-Jan-2007  ad Fix Linux compatability for i386, others to follow later.
 1.49.20.2 18-Nov-2006  ad Sync with head.
 1.49.20.1 24-Oct-2006  ad - Redo LWP locking slightly and fix some races.
- Fix some locking botches.
- Make signal mask / stack per-proc for SA processes.
- Add _lwp_kill().
 1.49.8.1 14-Sep-2006  yamt sync with head.
 1.50.2.2 10-Dec-2006  yamt sync with head.
 1.50.2.1 22-Oct-2006  yamt sync with head
 1.53.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.54.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.54.16.2 09-Jan-2008  matt sync with HEAD
 1.54.16.1 06-Nov-2007  matt sync with HEAD
 1.54.14.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.54.14.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.55.4.2 26-Dec-2007  ad Sync with head.
 1.55.4.1 08-Dec-2007  ad Sync with head.
 1.55.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.55.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.57.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.58.8.1 18-May-2008  yamt sync with head.
 1.58.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.58.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.58.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.61.2.4 11-Aug-2010  yamt sync with head.
 1.61.2.3 20-Jun-2009  yamt sync with head
 1.61.2.2 04-May-2009  yamt sync with head.
 1.61.2.1 16-May-2008  yamt sync with head.
 1.62.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.62.6.1 19-Oct-2008  haad Sync with HEAD.
 1.62.4.1 31-Jul-2008  simonb Sync with head.
 1.62.2.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.62.2.3 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.62.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.62.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.66.8.2 23-Jul-2009  jym Sync with HEAD.
 1.66.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.66.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.69.4.2 05-Mar-2011  rmind sync with head
 1.69.4.1 03-Jul-2010  rmind sync with head
 1.69.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.72.2.1 17-Apr-2012  yamt sync with head
 1.75.26.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.75.26.1 17-Jan-2015  martin branches: 1.75.26.1.6;
Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.75.26.1.6.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.75.10.1 03-Dec-2017  jdolecek update from HEAD
 1.76.2.2 28-Aug-2017  skrll Sync with HEAD
 1.76.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.77.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.77.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.79.6.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.79.6.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.80.8.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.80.8.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.80.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.83.2.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.89.6.1 02-Aug-2025  perseant Sync with HEAD
 1.34 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.33 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.32 02-Jan-2017  martin Provide a dummy linux_sigset_t for all architectures that do not have
any machdep one. This make kdump compile again.
 1.31 02-Jan-2017  manu Add pselect6 Linux system call.
This lets Matlab R2016A run on NetBSD/amd64
 1.30 29-May-2009  njoly branches: 1.30.22; 1.30.38; 1.30.40; 1.30.44;
Add native to linux siginfo si_status translation, used on i386 and
amd64.
 1.29 19-Oct-2008  njoly branches: 1.29.8;
Add native to linux siginfo si_code translation, mostly for negative
values. Adjust amd64 and i386 accordingly, not sure about aother archs
i can't test.
 1.28 28-Apr-2008  martin branches: 1.28.6;
Remove clause 3 and 4 from TNF licenses
 1.27 04-Dec-2007  dsl branches: 1.27.12; 1.27.14; 1.27.16;
Remove all the __P
 1.26 09-Feb-2007  ad branches: 1.26.18; 1.26.20; 1.26.26; 1.26.28;
Merge newlock2 to head.
 1.25 11-Dec-2005  christos branches: 1.25.20;
merge ktrace-lwp.
 1.24 19-Jun-2005  christos branches: 1.24.2;
remove duplicate declaration.
 1.23 02-Jun-2005  drochner more cast-qual fallout
 1.22 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.21 08-Aug-2003  christos Conditionally declare function that is not used all the time.
 1.20 04-Jul-2003  enami Actually move the prototype of native_to_linux_sigaltstack here.
 1.19 02-Apr-2002  christos branches: 1.19.10;
Don't blow up if we don't have a machine dependend linux_signal.h.
kdump includes linux_signo.c
 1.18 31-Mar-2002  christos make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.17 18-Feb-2002  christos Resolve alpha compile issues:
- bug with order in args in mask conversion md code.
- flags can be both int and long on the alpha. kludge around that, by not
passing pointers to the conversion function.
- something is wrong with the toolchain look at the void * cast in copyout().
- sa_restorer is in a different place on the aplha. Deal with that, by not
initializing it as before. XXX: this should be changed in the MD signal
definition.
 1.16 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.15 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.14 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.13 19-Jan-2001  manu branches: 1.13.2; 1.13.4; 1.13.6;
Added Linux compatibility support for powerpc ports
 1.12 18-Jan-2001  jdolecek constify
 1.11 15-Dec-1998  itohy branches: 1.11.8;
Added linux compat support on m68k ports.
 1.10 07-Oct-1998  erh Fix types. Kill old declarations.
 1.9 07-Oct-1998  erh Add prototype for linux_sigprocmask1().
 1.8 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.7 03-Oct-1998  christos Attempt to fix the mess.
 1.6 01-Oct-1998  erh Split compat/linux/linux_signal.h into i386 and common parts.
 1.5 11-Sep-1998  mycroft Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.4 27-Aug-1995  fvdl Add a hook for MD ioctl calls, plus a couple of more changes to make
svgalib binaries work on the i386
 1.3 14-Aug-1995  mycroft Export bsd_to_linux_sig[], and use it.
 1.2 14-Aug-1995  mycroft Move signal types into signal.h.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.11.8.1 11-Feb-2001  bouyer Sync with HEAD.
 1.13.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.13.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.13.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.13.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.3 17-Apr-2002  nathanw Catch up to -current.
 1.13.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.13.2.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.19.10.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.10.1 03-Aug-2004  skrll Sync with HEAD
 1.24.2.2 07-Dec-2007  yamt sync with head
 1.24.2.1 26-Feb-2007  yamt sync with head.
 1.25.20.1 24-Oct-2006  ad - Redo LWP locking slightly and fix some races.
- Fix some locking botches.
- Make signal mask / stack per-proc for SA processes.
- Add _lwp_kill().
 1.26.28.1 08-Dec-2007  ad Sync with head.
 1.26.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.26.20.1 09-Jan-2008  matt sync with HEAD
 1.26.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.27.16.3 20-Jun-2009  yamt sync with head
 1.27.16.2 04-May-2009  yamt sync with head.
 1.27.16.1 16-May-2008  yamt sync with head.
 1.27.14.1 18-May-2008  yamt sync with head.
 1.27.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.27.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.6.1 19-Oct-2008  haad Sync with HEAD.
 1.29.8.1 23-Jul-2009  jym Sync with HEAD.
 1.30.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.30.40.1 05-Feb-2017  skrll Sync with HEAD
 1.30.38.2 19-Apr-2017  snj Fix fallout from ticket #1354 by applying:
sys/compat/linux/common/linux_signal.h: revision 1.32
Provide a dummy linux_sigset_t for all architectures that do not have
any machdep one. This make kdump compile again.
 1.30.38.1 17-Apr-2017  snj Pull up following revision(s) (requested by manu in ticket #1354):
sys/compat/linux/arch/alpha/syscalls.master: revision 1.92 via patch
sys/compat/linux/arch/amd64/syscalls.master: revision 1.58 via patch
sys/compat/linux/arch/arm/syscalls.master: revision 1.65 via patch
sys/compat/linux/arch/i386/syscalls.master: revision 1.122 via patch
sys/compat/linux/arch/m68k/syscalls.master: revision 1.91 via patch
sys/compat/linux/arch/mips/syscalls.master: revision 1.61 via patch
sys/compat/linux/arch/powerpc/syscalls.master: revision 1.70 via patch
sys/compat/linux/common/linux_misc.c: revision 1.234
sys/compat/linux/common/linux_signal.h: revision 1.31
Add pselect6 Linux system call.
This lets Matlab R2016A run on NetBSD/amd64
 1.30.22.1 03-Dec-2017  jdolecek update from HEAD
 1.7 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.70; 1.5.72; 1.5.74;
merge ktrace-lwp.
 1.4 19-May-2005  manu Add support for Linux SA_RESTORER on amd64.
 1.3 03-Apr-2002  christos branches: 1.3.2; 1.3.8; 1.3.14;
make this compile on archs that don't define linux signals.
 1.2 31-Mar-2002  christos bring the reverse signal mapping array into linux_signo.c
 1.1 31-Mar-2002  christos make signal array handling uniform, and put signal arrays in a separate
file. This is simular to errno array handling.
 1.3.14.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.1 03-Apr-2002  jdolecek file linux_signo.c was added on branch kqueue on 2002-06-23 17:44:27 +0000
 1.3.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.3.2.1 03-Apr-2002  nathanw file linux_signo.c was added on branch nathanw_sa on 2002-04-17 00:05:12 +0000
 1.5.74.1 16-May-2008  yamt sync with head.
 1.5.72.1 18-May-2008  yamt sync with head.
 1.5.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.158 28-Jun-2025  christos PR/59486: csaba mate: Ignore IP_MULTICAST_ALL, since we don't have it.
Also, add -3 to return ENOPROTOOPT, more options and consistently whitespace
after define (the majority had define<space> so make them all the samr)
 1.157 27-Jun-2025  christos PR/59486: csaba mate: Ignore IP_MULTICAST_ALL, since we don't have it.
 1.156 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.155 24-Dec-2022  andvar branches: 1.155.6;
s/reqest/request/, s/requst/request/ and s/reuqest/request/ in comments.
 1.154 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.153 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.152 03-Nov-2020  christos PR/55780: Bernd Sieker: setsockopt in Linux emulation misses some options
 1.151 24-Oct-2020  mgorny branches: 1.151.2;
Fix compat with Linux programs that use longer namelen for sockets

Linux is less strict than NetBSD and permits namelen to be larger
than valid struct sockaddr_in*. If this is the case, truncate the value
to the correct size, so that NetBSD networking does not return an error.

Reviewed by kamil
 1.150 16-Jul-2020  msaitoh Don't accept negative value.

Reported-by: syzbot+e71a77402d6668f1868d@syzkaller.appspotmail.com
 1.149 08-Sep-2019  maxv Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.148 24-Aug-2019  maxv Fix memory leak.
 1.147 24-Aug-2019  maxv Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().
 1.146 24-Aug-2019  maxv Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?
 1.145 18-Apr-2019  christos branches: 1.145.4;
Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.144 04-Feb-2019  mrg - avoid uninitialised memory usage
 1.143 14-Nov-2018  hannken Apply the recent fixes to {send,recv}mmsg() to their compat variants.
 1.142 10-May-2018  ozaki-r branches: 1.142.2;
Fix pserialize enter/exit pairs in linux_getifconf and linux32_getifconf

Tested by using a small linux program that uses ioctl(SIOCGIFCONF).
Probably fix PR kern/53259 as well.
 1.141 03-May-2018  christos Fix COMPAT_NETBSD32 cmsg handling:

1. alignment was wrong for > 1 message
2. macros were doing incorrect pointer comparisons, fortunately ending
the iteration early after the fists cmsg instead of crashing.
3. don't output 32 bit ktrace records for cmsg. 32 bit programs running
under emulation on 64 bit systems should produce 64 bit ktrace records
so that the native ktrace can handle the records; remove extra arguments
that are now not needed (the 32 bit msghdr).
4. output the correct type for cmsg trace records.
5. output all the cmsg records in traces instead of just the first one.

Welcome to 8.99.15 because of the argument removal.

XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR
macros...
 1.140 16-Mar-2018  christos PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.
 1.139 22-Nov-2017  ozaki-r branches: 1.139.2;
Fix and make consistent of usages of psz/psref in ifconf variants
 1.138 14-Mar-2017  ozaki-r branches: 1.138.6;
Use if_acquire and if_release instead of using psref API directly

- Provide if_release for consistency to if_acquire
- Use if_acquire and if_release for ifp iterations
- Make ifnet_psref_class static
 1.137 03-Feb-2017  christos add sendmmsg and recvmmsg
 1.136 03-Feb-2017  christos handle accept4 for i386
 1.135 03-Feb-2017  martin Do not compile accept4 on i386, there is no such syscall in Linux.
 1.134 02-Feb-2017  christos implement accept4
 1.133 13-Sep-2016  martin branches: 1.133.2;
Make the ktrace record written by do_sys_sendmsg/do_sys_recvmsg overridable
by the caller. Use this in compat_netbsd32 to log the 32bit version, so
the 32bit userland kdump is happy.
 1.132 01-Aug-2016  ozaki-r Apply pserialize and psref to struct ifaddr and its variants

This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
 1.131 07-Jul-2016  ozaki-r branches: 1.131.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.130 05-Jul-2016  ozaki-r Fix psref isn't released in a case of IFADDR_EMPTY
 1.129 16-Jun-2016  ozaki-r Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND
 1.128 15-Jun-2016  ozaki-r Protect if_byindex by pserialize
 1.127 12-May-2016  ozaki-r Protect ifnet list with psz and psref

The change ensures that ifnet objects in the ifnet list aren't freed during
list iterations by using pserialize(9) and psref(9).

Note that the change adds a pslist(9) for ifnet but doesn't remove the
original ifnet list (ifnet_list) to avoid breaking kvm(3) users. We
shouldn't use the original list in the kernel anymore.
 1.126 24-Jul-2015  maxv Unused inits (harmless).

Found by Brainy.
 1.125 24-May-2015  rtr convert remaining linux_get_sa() users to use linux_get_sa_sb() and
pass the pointer to the sockaddr in msghdr.msg_name, while removing
the MSG_NAMEMBUF flag.

now that the original linux_get_sa() is unused remove it and to make
function names consistent again rename linux_get_sa_sb() to linux_get_sa().
 1.124 02-May-2015  rtr make connect syscall use sockaddr_big and modify pr_{send,connect}
nam parameter type from buf * to sockaddr *.

final commit for parameter type changes to protocol user requests

* bump kernel version to 7.99.15 for parameter type changes to pr_{send,connect}
 1.123 03-Apr-2015  rtr * change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@
 1.122 26-Nov-2014  ozaki-r branches: 1.122.2;
Tweak ifconf variants

The tweaks make the code intention clear and make further changes easy.

No functional change.
 1.121 21-Nov-2014  ozaki-r Tweak linux_getifhwaddr

No functional change.
 1.120 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.119 23-May-2014  njoly branches: 1.119.2;
Add a funtion that translate socket type value from Linux to NetBSD.
Use it for socket and socketpair syscalls.
 1.118 17-May-2014  rmind Replace open-coded access (and boundary checking) of ifindex2ifnet with
if_byindex() function.
 1.117 27-Jan-2014  njoly branches: 1.117.2;
Add basic IPV6 level socket options support (IPV6_V6ONLY).
 1.116 27-Jan-2014  njoly Add SO_SNDLOWAT, SO_RCVLOWAT and SO_ACCEPTCONN support for socket
options.
 1.115 11-Jan-2013  christos branches: 1.115.2;
Use copyin/copyout and linux-specific ifreq structures (they are the same
as the netbsd ones, but this disconnects them)
 1.114 20-Jun-2012  christos branches: 1.114.2;
print proper ktruser names depending on the emulation.
 1.113 15-Mar-2012  bouyer Do not read past end of array. Found by gcc -03
 1.112 20-Jan-2012  joerg Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.111 20-Dec-2011  christos - Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).
 1.110 17-Jul-2011  christos branches: 1.110.2; 1.110.6;
fail early on socket domain+type combinations we don't support
 1.109 30-Jun-2011  wiz dependant -> dependent
 1.108 02-Nov-2010  chs update linux_sys_socket() to understand the flags that are now
included in the "type" parameter. in linux_sys_sendmsg(),
if we see an SCM_CREDENTIALS control message, just drop it
instead of giving an error. the linux and native versions of
the cred-passing operation are very different and some apps
(eg. linux pulseaudio library talking to a native server)
will work without the control data.
 1.107 28-Nov-2009  dsl branches: 1.107.2; 1.107.4;
Add LINUX_SIOCGIFMTU and LINUX_IP_HDRINCL support.
Fixes part of PR/31358
The other parts are rather too intrusive to be fixed as in the PR.
 1.106 13-Nov-2009  joerg Return the result of copyout. Reminded by Niolas Joly.
 1.105 13-Nov-2009  joerg Provide SIOCGIFNAME.
 1.104 17-Jun-2009  njoly Add a new linux_msghdr structure, as its size differs on 64bit archs.
Do the needed conversions in sendmsg/recvmsg syscalls, and adjust
their definitions accordingly.
 1.103 16-Jun-2009  njoly Add LINUX_CMSG_{SPACE,LEN} macros. Use then when calculating the
msg_controllen size, when converting the control message buffer from
native (previous version was missing the linux_cmsghdr size).
 1.102 16-Jun-2009  njoly For linux cmsg header copyout, use the linux structure size, not the
native one.
 1.101 16-Jun-2009  njoly Make compat linux sendmsg/recvmsg output msghdr and control messages
buffers with ktrace(1), just like the native functions.
 1.100 11-Jun-2009  njoly In sendmsg(2), do copy the msghdr structure before trying to use it.
 1.99 19-Nov-2008  ad branches: 1.99.4;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.98 06-Aug-2008  plunky branches: 1.98.2; 1.98.4; 1.98.6;
Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
 1.97 03-Jul-2008  njoly branches: 1.97.2;
Fix SIOCGIFCONF ioctl for 64bit platforms. Add a new linux_ifreq
structure and linux_getifconf function (cleaned up version from
compat_ifconf).

While here, update linux_getifhwaddr to use the new structure.

Ok by christos.
 1.96 24-Jun-2008  ad Replace references to getsock/getvnode.
 1.95 11-Jun-2008  njoly In linux_sys_sendto, do not unconditionnally set MSG_NAMEMBUF to
msg_flags; add it only if a target adress was provided and needs to be
converted.
 1.94 09-Jun-2008  njoly branches: 1.94.2;
Do set mbuf in all cases, even for salen value of 0; otherwise this
will make a panic later when trying to free memory from a random
adress.

XXX Need to revisit it later to avoid mbuf allocation in this case.
 1.93 29-Apr-2008  njoly branches: 1.93.2;
In linux_get_sa(), make salen parameter unsigned.
Avoid kernel DIAGNOSTIC 0 bytes uvm mapping assertion, for negative
values.
 1.92 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.91 24-Apr-2008  ad branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
 1.90 23-Apr-2008  ad Fix locking.
 1.89 26-Mar-2008  ad branches: 1.89.2;
- Remove uneeded splsoftnet().
- Use fd_getsock().
 1.88 23-Mar-2008  ad linux_get_sa: fix botched fd handling.
 1.87 21-Mar-2008  ad Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.86 06-Feb-2008  ad branches: 1.86.6;
Don't lock the socket to set/clear FNONBLOCK. Just set it atomically.
 1.85 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.84 08-Dec-2007  dsl branches: 1.84.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.83 05-Dec-2007  dyoung Use IFADDR_EMPTY().
 1.82 05-Dec-2007  dyoung Don't open-code queue(3) macros (x = ifnet.tqh_first; y =
x.if_list.tqe_next). Instead, use the macros themselves.

Use IFNET_FOREACH() and IFADDR_FOREACH().
 1.81 04-Dec-2007  dsl Remove all the __P
 1.80 19-Oct-2007  njoly branches: 1.80.2; 1.80.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.79 29-Aug-2007  dyoung branches: 1.79.4;
Constify: LLADDR() -> CLLADDR().
 1.78 26-Aug-2007  dyoung branches: 1.78.2;
Use satosdl().
 1.77 15-Aug-2007  ad Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.76 01-Jul-2007  dsl branches: 1.76.2; 1.76.6;
Fix long-term breakage in the definition of 'control' data for linux.
cmsg->cmsg_len is 'size_t' not 'socklen_t' - so it is 8 bytes on 64bit
platforms instead of 4. There is also never padding after the header.
Redo linux sendmsg() so that it stands a chance of getting it right.
Redo linux recvmsg() so that it process control data directly from the mbuf
list. Allowing it to hack the data without using the stackgap.
 1.75 06-Jun-2007  rjs Wrap ktrace calls with #ifdef KTRACE.
 1.74 02-Jun-2007  yamt wrap #include "opt_ktrace.h" by #ifdef _KERNEL_OPT.
 1.73 01-Jun-2007  dsl Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.
 1.72 29-May-2007  christos Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
 1.71 04-Mar-2007  christos branches: 1.71.2; 1.71.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.70 11-Feb-2007  mlelstv branches: 1.70.2;
Make setsockopt return compatible error codes for AF_UNIX sockets.
 1.69 09-Feb-2007  ad Merge newlock2 to head.
 1.68 16-Nov-2006  christos branches: 1.68.2;
__unused removal on arguments; approved by core.
 1.67 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.66 02-Sep-2006  christos branches: 1.66.2; 1.66.4;
comment out impossible code
 1.65 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.64 27-Jun-2006  pavel Use the new socket call for Linux and SVR4, because those systems (at
least Linux 2.4.31, Irix 6.5.20 and Solaris 10) use EAFNOSUPPORT.

Only the Linux emulation has been tested.

XXX somebody should audit the other emulations...
 1.63 26-Jun-2006  mrg version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
 1.62 14-May-2006  elad branches: 1.62.4;
integrate kauth.
 1.61 12-May-2006  mrg use socklen_t when talking to the NetBSD side of things
 1.60 27-Mar-2006  dyoung Use __arraycount().
 1.59 09-Feb-2006  manu branches: 1.59.2; 1.59.4; 1.59.6;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.58 11-Dec-2005  christos branches: 1.58.2; 1.58.4; 1.58.6;
merge ktrace-lwp.
 1.57 24-Sep-2005  christos factor out some of the osockaddr, omsghdr code.
 1.56 03-May-2005  manu branches: 1.56.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.55 26-Feb-2005  perry nuke trailing whitespace
 1.54 24-Feb-2005  martin Fix number of elements calculation when converting socket options.
Fixes bugs 4 and 5 reported by Ted Unangst on tech-kern.
 1.53 12-Sep-2004  jdolecek branches: 1.53.4; 1.53.6;
if passed sockaddr has family AF_UNSPEC, use socket family of the socket
the sockaddr is used for

this fixes bind() problem in Linux version of Theocracy, testing
by Thomas Klausner
 1.52 05-Sep-2004  jdolecek linux_sa_get: g/c curproc use, we get the process as one of arguments
 1.51 29-Aug-2004  jdolecek in debug log, data dump is more useful unsigned
 1.50 25-Oct-2003  christos branches: 1.50.2;
Fix uninitialized variable warnings
 1.49 27-Jul-2003  jdolecek More complete sendmsg(2) and recvmsg(2) emulation:
* translate MSG_* flags
* rewrite CMSG level/type to appropriate NetBSD value on input, and to Linux
value on output
* handle different CMSG_DATA alignment for some archs

This fixes SCM_RIGHTS passing. Other SCM_* types are not supported -
the set is different on NetBSD and Linux. SCM_TIMESTAMP doesn't seem
to be actually implemented in Linux 2.5.15, so it's not supported
for Linux binaries either (for now).

PR: 21577 by Todd Vierling
 1.48 27-Jul-2003  mrg add a cast appease gcc3.3
 1.47 23-Jul-2003  christos make credentials work on the i386 by passing the original msg structure.
(from Todd Vierling)
 1.46 29-Jun-2003  fvdl branches: 1.46.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.45 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.44 21-Mar-2003  dsl Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
 1.43 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.42 29-Nov-2002  fvdl branches: 1.42.2;
Patch that actually works for previous, from Jaromir Dolecek.
 1.41 29-Nov-2002  itojun setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) for AF_INET6 sockets,
to meet with the default behavior of linux.
review: fvdl/christos
XXX interactions with net.inet6.ip6.v6only?
 1.40 28-Nov-2002  itojun minor KNF (indent)
 1.39 12-May-2002  jschauma branches: 1.39.4;
Linux does not implement SO_REUSEPORT, but allows reuse of a
host:port pair through SO_REUSEADDR even if the address is not a
multicast-address. Effectively, this means that we should use
SO_REUSEPORT when SO_REUSEADDR is set (from the linux process)
to allow Linux applications to not exit with EADDRINUSE.

(Previously erraneously applied to 1.5 branch; approved for
proper location by thorpej)
 1.38 08-Apr-2002  christos PR/16236: Joachim Koenig-Baltes: Linux emulation connect requires IPV6.
Apparently the sockaddr len fix was only compiled when IPV6 was enabled.
 1.37 29-Mar-2002  christos - #undef DPRINTF for files that are included from other files.
- more debugging for socketcalls
- fix sa_len if AF_INET; somehow we get passed 28 instead of 16?
 1.36 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.35 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.34 08-Sep-2001  fvdl Allow the old-style sockaddr_in6 for v6 addresses for which the
scope id is irrelevant. Makes netscape6 for Linux work again,
which uses v4-mapped addresses to connect to v4 sites.
 1.33 04-Jul-2001  jdolecek branches: 1.33.2; 1.33.4;
remove no longer used variable
make 'osa' arg of linux_sa_get() const
 1.32 04-Jul-2001  jdolecek Do address family (AF_*) number translation for socket system calls which
pass socket address in our or out. This makes Linux programs using IPv6
working under emulation. This addresses kern/13279 by Jun-ichiro itojun Hagino.

Change sendmsg()/recvmsg() to expect the control information
to be passed the standard way (not 4.3BSD one, imlied by compat_43 code
or MSG_COMPAT). Linux uses different (arguably broken) CMSG_ALIGN() on some
architectures unfortunately, that would need to be handled eventually.

Also provide some other trivial stubs (like linux_sys_send()) to avoid
unneeded dependance on uipc_syscalls_43.c.
 1.31 25-Jun-2001  jdolecek linux_getifhwaddr(): use strncmp() to find out if if_name starts with 'eth',
it's more readable that way
 1.30 14-Jun-2001  thorpej Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.29 29-Mar-2001  fvdl Don't do the ioctl call for the get hw addr case, all the work has
been done already.
 1.28 05-Feb-2001  chs branches: 1.28.2;
expose the definitions of MIN() and MAX() in sys/param.h to the kernel
and use those in favor of a dozen copies scattered around the source tree.
 1.27 29-Dec-2000  fvdl Allow the EJUSTRETURN hack for PTIOCLINUX-passed through ioctl calls.
 1.26 22-Dec-2000  fvdl Don't do the syscall with modified ioctl command if we've successfully
done a 'passthrough' ioctl.
 1.25 18-Dec-2000  fvdl Pass SIOC* calls that are done on devices (not sockets) through
without trying to interpret done, as is done on Linux. The device
will get them as PTIOCLINUX, with command and arg in the structure
passed in.
 1.24 03-May-2000  thorpej branches: 1.24.4;
Remove junk after #undef.
 1.23 30-Mar-2000  augustss Kill register declarations.
 1.22 12-Jan-2000  jdolecek Improve emulation of SIOCGIFHWADDR ioctl:
* when finding an interface, try the real name first before faking eth*
* Linux kernel returns ENODEV if the request goes to unknown interface,
so do the same here

This change makes Linux ICA client work.

Patch sent by Zdenek Salvet <salvet@ics.muni.cz> in kern/9169.
 1.21 17-Jul-1999  jtk branches: 1.21.2;
implement emulation of SIOCGIFHWADDR, PR 7997
 1.20 05-May-1999  thorpej Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
 1.19 25-Mar-1999  sommerfe branches: 1.19.2; 1.19.4;
commit fix to PR7072: emulate linux non-blocking connect behavior more correctly
 1.18 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.17 03-Oct-1998  christos Attempt to fix the mess.
 1.16 01-Oct-1998  erh Split linux/compat/linux_socket.c into common and multi-architechture parts. linux_socketcall.c contains the socketcall multiplexer.
 1.15 22-Dec-1996  fvdl Make this compile again, including Politically Correct const handling.
 1.14 05-Apr-1996  christos Prototyping changes.
 1.13 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 14-Aug-1995  mycroft Rearrange #includes.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 28-May-1995  mycroft Need netinet/tcp.h.
 1.6 28-May-1995  mycroft Convert TCP socket options.
 1.5 28-May-1995  mycroft Fill in `name' argument to getsockopt() correctly.
 1.4 28-May-1995  mycroft Fix typo.
 1.3 28-May-1995  mycroft Convert IP socket options.
 1.2 28-May-1995  mycroft Get rid of damned `static's.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.19.4.2 02-Aug-1999  thorpej Update from trunk.
 1.19.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.19.2.1 15-Jan-2000  he Pull up revision 1.21 (via patch, requested by joda):
Implement the SIOCGIFHWADDR Linux ioctl, allowing installation
of Matlab (after convincing the install script it is running on
a supported platform).
 1.21.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.21.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.21.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.21.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.24.4.4 12-May-2002  jschauma Undo my own bad - change did not belong into 1.5 branch. Sorry.
 1.24.4.3 11-May-2002  jschauma Linux does not implement SO_REUSEPORT, but allows reuse of a
host:port pair through SO_REUSEADDR even if the address is not a
multicast-address. Effectively, this means that we should use
SO_REUSEPORT when SO_REUSEADDR is set (from the linux process)
to allow Linux applications to not exit with EADDRINUSE.
 1.24.4.2 30-Mar-2001  he Pull up revision 1.29 (requested by fvdl):
Fix the SIOCGETHWADDR socket ioctl call; earlier it always returned
an error.
 1.24.4.1 30-Mar-2001  he Pull up revisions 1.25-1.26 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.28.2.14 11-Dec-2002  thorpej Sync with HEAD.
 1.28.2.13 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.28.2.12 24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.28.2.11 20-Jun-2002  nathanw Catch up to -current.
 1.28.2.10 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.28.2.9 17-Apr-2002  nathanw Catch up to -current.
 1.28.2.8 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.28.2.7 14-Nov-2001  nathanw Catch up to -current.
 1.28.2.6 21-Sep-2001  nathanw Catch up to -current.
 1.28.2.5 24-Aug-2001  nathanw A few files and lwp/proc conversions I missed in the last big update.
GENERIC runs again.
 1.28.2.4 24-Aug-2001  nathanw Catch up with -current.
 1.28.2.3 21-Jun-2001  nathanw Catch up to -current.
 1.28.2.2 09-Apr-2001  nathanw Catch up with -current.
 1.28.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.33.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.33.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.33.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.33.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.39.4.3 22-Oct-2003  jmc Pullup revs 1.41-1.42 (requested by tv in ticket #1429)

setsockopt(IPPROTO_IPV6, IPV6_V6ONLY, 0) for AF_INET6 sockets,
to meet with the default behavior of linux.
 1.39.4.2 22-Oct-2003  jmc Pullup rev 1.49 (via patch) (requested by tv in ticket #1425)

More complete sendmsg(2) and recvmsg(2) emulation:
* translate MSG_* flags
* rewrite CMSG level/type to appropriate NetBSD value on input,
and to Linux value on output
* handle different CMSG_DATA alignment for some archs

This fixes SCM_RIGHTS passing. Other SCM_* types are not supported -
the set is different on NetBSD and Linux. SCM_TIMESTAMP doesn't seem
to be actually implemented in Linux 2.5.15, so it's not supported
for Linux binaries either (for now).
 1.39.4.1 22-Oct-2003  jmc Pullup rev 1.46 (requested by tv in ticket #1425)

make credentials work on the i386 by passing the original msg structure.
 1.42.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.46.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.46.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.46.2.6 21-Sep-2004  skrll Adapt to branch.
 1.46.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.46.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.46.2.3 03-Sep-2004  skrll Sync with HEAD
 1.46.2.2 03-Aug-2004  skrll Sync with HEAD
 1.46.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.50.2.1 20-Sep-2004  tron Pull up revision 1.53 (requested by jdolecek in ticket #844):
if passed sockaddr has family AF_UNSPEC, use socket family of the socket
the sockaddr is used for
this fixes bind() problem in Linux version of Theocracy, testing
by Thomas Klausner
 1.53.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.53.4.1 29-Apr-2005  kent sync with -current
 1.56.2.9 24-Mar-2008  yamt sync with head.
 1.56.2.8 11-Feb-2008  yamt sync with head.
 1.56.2.7 21-Jan-2008  yamt sync with head
 1.56.2.6 07-Dec-2007  yamt sync with head
 1.56.2.5 27-Oct-2007  yamt sync with head.
 1.56.2.4 03-Sep-2007  yamt sync with head.
 1.56.2.3 26-Feb-2007  yamt sync with head.
 1.56.2.2 30-Dec-2006  yamt sync with head.
 1.56.2.1 21-Jun-2006  yamt sync with head.
 1.58.6.2 01-Jun-2006  kardel Sync with head.
 1.58.6.1 22-Apr-2006  simonb Sync with head.
 1.58.4.1 09-Sep-2006  rpaulo sync with head
 1.58.2.1 18-Feb-2006  yamt sync with head.
 1.59.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.59.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.59.4.3 06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.59.4.2 19-Apr-2006  elad sync with head.
 1.59.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.59.2.4 03-Sep-2006  yamt sync with head.
 1.59.2.3 11-Aug-2006  yamt sync with head
 1.59.2.2 24-May-2006  yamt sync with head.
 1.59.2.1 01-Apr-2006  yamt sync with head.
 1.62.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.66.4.2 10-Dec-2006  yamt sync with head.
 1.66.4.1 22-Oct-2006  yamt sync with head
 1.66.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.66.2.1 18-Nov-2006  ad Sync with head.
 1.68.2.1 21-Feb-2007  tron Pull up following revision(s) (requested by mlelstv in ticket #447):
sys/compat/linux/common/linux_socket.c: revision 1.70
Make setsockopt return compatible error codes for AF_UNIX sockets.
 1.70.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.71.4.1 11-Jul-2007  mjf Sync with head.
 1.71.2.4 09-Oct-2007  ad Sync with head.
 1.71.2.3 20-Aug-2007  ad Sync with HEAD.
 1.71.2.2 15-Jul-2007  ad Sync with head.
 1.71.2.1 09-Jun-2007  ad Sync with head.
 1.76.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.76.6.3 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.76.6.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.76.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.76.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.78.2.3 23-Mar-2008  matt sync with HEAD
 1.78.2.2 09-Jan-2008  matt sync with HEAD
 1.78.2.1 06-Nov-2007  matt sync with HEAD
 1.79.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.80.4.2 26-Dec-2007  ad Sync with head.
 1.80.4.1 08-Dec-2007  ad Sync with head.
 1.80.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.80.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.80.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.84.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.86.6.5 17-Jan-2009  mjf Sync with HEAD.
 1.86.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.86.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.86.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.86.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.89.2.2 17-Jun-2008  yamt sync with head.
 1.89.2.1 18-May-2008  yamt sync with head.
 1.91.2.4 11-Mar-2010  yamt sync with head
 1.91.2.3 20-Jun-2009  yamt sync with head
 1.91.2.2 04-May-2009  yamt sync with head.
 1.91.2.1 16-May-2008  yamt sync with head.
 1.93.2.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.93.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.93.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.93.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.94.2.3 03-Jul-2008  simonb Sync with head.
 1.94.2.2 27-Jun-2008  simonb Sync with head.
 1.94.2.1 18-Jun-2008  simonb Sync with head.
 1.97.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.97.2.1 19-Oct-2008  haad Sync with HEAD.
 1.98.6.1 17-Jun-2009  bouyer branches: 1.98.6.1.2;
Pull up following revision(s) (requested by njoly in ticket #806):
sys/compat/linux/common/linux_socket.c: revision 1.100
In sendmsg(2), do copy the msghdr structure before trying to use it.
 1.98.6.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.98.4.2 28-Nov-2009  bouyer Pull up following revision(s) (requested by joerg in ticket #1147):
sys/compat/linux32/common/linux32_socket.c: revision 1.11, 1.12
sys/compat/linux/common/linux_socket.c: revision 1.105, 1.106
sys/compat/linux/common/linux_sockio.h: revision 1.17
sys/compat/linux32/common/linux32_sockio.h: revision 1.3
Provide SIOCGIFNAME.
Return the result of copyout. Reminded by Niolas Joly.
 1.98.4.1 17-Jun-2009  bouyer Pull up following revision(s) (requested by njoly in ticket #806):
sys/compat/linux/common/linux_socket.c: revision 1.100
In sendmsg(2), do copy the msghdr structure before trying to use it.
 1.98.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.99.4.1 23-Jul-2009  jym Sync with HEAD.
 1.107.4.1 05-Mar-2011  rmind sync with head
 1.107.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.110.6.2 05-Apr-2012  mrg sync to latest -current.
 1.110.6.1 18-Feb-2012  mrg merge to -current.
 1.110.2.4 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.110.2.3 23-Jan-2013  yamt sync with head
 1.110.2.2 30-Oct-2012  yamt sync with head
 1.110.2.1 17-Apr-2012  yamt sync with head
 1.114.2.3 03-Dec-2017  jdolecek update from HEAD
 1.114.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.114.2.1 25-Feb-2013  tls resync with head
 1.115.2.2 18-May-2014  rmind sync with head
 1.115.2.1 17-Jul-2013  rmind Checkpoint work in progress:
- Move PCB structures under __INPCB_PRIVATE, adjust most of the callers
and thus make IPv4 PCB structures mostly opaque. Any volunteers for
merging in6pcb with inpcb (see rpaulo-netinet-merge-pcb branch)?
- Move various global vars to the modules where they belong, make them static.
- Some preliminary work for IPv4 PCB locking scheme.
- Make raw IP code mostly MP-safe. Simplify some of it.
- Rework "fast" IP forwarding (ipflow) code to be mostly MP-safe. It should
run from a software interrupt, rather than hard.
- Rework tun(4) pseudo interface to be MP-safe.
- Work towards making some other interfaces more strict.
 1.117.2.1 10-Aug-2014  tls Rebase.
 1.119.2.3 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.119.2.2 19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.119.2.1 17-Jan-2015  martin branches: 1.119.2.1.2; 1.119.2.1.6;
Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.119.2.1.6.2 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.119.2.1.6.1 19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.119.2.1.2.1 19-Apr-2019  martin Pull up following revision(s) via patch (requested by christos in ticket #1689):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.122.2.8 28-Aug-2017  skrll Sync with HEAD
 1.122.2.7 05-Feb-2017  skrll Sync with HEAD
 1.122.2.6 05-Oct-2016  skrll Sync with HEAD
 1.122.2.5 09-Jul-2016  skrll Sync with HEAD
 1.122.2.4 29-May-2016  skrll Sync with HEAD
 1.122.2.3 22-Sep-2015  skrll Sync with HEAD
 1.122.2.2 06-Jun-2015  skrll Sync with HEAD
 1.122.2.1 06-Apr-2015  skrll Sync with HEAD
 1.131.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.131.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.133.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.138.6.7 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.138.6.6 17-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1576):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

Don't accept negative value.
 1.138.6.5 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.138.6.4 19-Apr-2019  martin Pull up following revision(s) (requested by christos in ticket #1233):

sys/compat/linux/common/linux_socket.c: revision 1.145
sys/net/if.c: revision 1.449
sys/compat/linux32/common/linux32_socket.c: revision 1.30
sys/compat/common/uipc_syscalls_40.c: revision 1.19

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks!

-

Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stack
disclosure. From Andy Nguyen, many thanks! This is the compat code part
pointed out by ozaki-r@
 1.138.6.3 08-Dec-2018  martin Apply patch, requested by tsutsui in ticket #1132:

Different solution for the fix in

sys/compat/linux/common/linux_socket.c rev 1.140

The solution in -current could not be directly used as it required a kernel
version bump and broke the ABI. Work around it differently here.

Fixes linux emulation of sendto(2), PR 53103.
 1.138.6.2 12-May-2018  martin Pull up following revision(s) (requested by ozaki-r in ticket #818):

sys/compat/linux/common/linux_socket.c: revision 1.142
sys/compat/linux32/common/linux32_socket.c: revision 1.29

Fix pserialize enter/exit pairs in linux_getifconf and linux32_getifconf

Tested by using a small linux program that uses ioctl(SIOCGIFCONF).
Probably fix PR kern/53259 as well.
 1.138.6.1 30-Nov-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #407):
sys/compat/linux32/common/linux32_socket.c: revision 1.28
sys/net/if.c: revision 1.400
sys/netipsec/key.c: revision 1.243
sys/compat/linux/common/linux_socket.c: revision 1.139
sys/netinet/ip_carp.c: revision 1.93
sys/netinet6/in6.c: revision 1.252
sys/netinet6/in6.c: revision 1.253
sys/netinet6/in6.c: revision 1.254
sys/net/if_spppsubr.c: revision 1.173
sys/net/if_spppsubr.c: revision 1.174
sys/compat/common/uipc_syscalls_40.c: revision 1.14
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Fix usage of FOREACH macro
key_sad.lock is held there so SAVLIST_WRITER_FOREACH is enough.
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref
Protect IFADDR_READER_FOREACH and obtained ifa with psz/psref (more)
Fix and make consistent of usages of psz/psref in ifconf variants
Remove unnecessary goto because there is no cleanup code to share (NFC)
Tweak a condition; we don't need to care ifacount to be negative
Fix a race condition of in6_ifinit
in6_ifinit checks the number of IPv6 addresses on a given interface and
if it's zero (i.e., an IPv6 address being assigned to the interface
is the first one), call if_addr_init. However, the actual assignment of
the address (ifa_insert) is out of in6_ifinit. The check and the
assignment must be done atomically.
Fix it by holding in6_ifaddr_lock during in6_ifinit and ifa_insert.
And also add missing pserialize to IFADDR_READER_FOREACH.
 1.139.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.139.2.2 21-May-2018  pgoyette Sync with HEAD
 1.139.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.142.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.142.2.1 10-Jun-2019  christos Sync with HEAD
 1.145.4.4 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.145.4.3 08-Nov-2020  martin Pull up following revision(s) (requested by kamil in ticket #1127):

sys/compat/linux/common/linux_socket.c: revision 1.151

Fix compat with Linux programs that use longer namelen for sockets

Linux is less strict than NetBSD and permits namelen to be larger
than valid struct sockaddr_in*. If this is the case, truncate the value
to the correct size, so that NetBSD networking does not return an error.

Reviewed by kamil
 1.145.4.2 17-Jul-2020  martin Pull up following revision(s) (requested by msaitoh in ticket #1018):

sys/net/if.c: revision 1.479
sys/compat/common/uipc_syscalls_40.c: revision 1.23
sys/compat/linux/common/linux_socket.c: revision 1.150
sys/compat/linux32/common/linux32_socket.c: revision 1.31

Don't accept negative value.
 1.145.4.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.151.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.155.6.1 02-Aug-2025  perseant Sync with HEAD
 1.27 28-Jun-2025  christos PR/59486: csaba mate: Ignore IP_MULTICAST_ALL, since we don't have it.
Also, add -3 to return ENOPROTOOPT, more options and consistently whitespace
after define (the majority had define<space> so make them all the samr)
 1.26 27-Jun-2025  christos PR/59486: csaba mate: Ignore IP_MULTICAST_ALL, since we don't have it.
 1.25 23-Sep-2021  ryo branches: 1.25.10;
add support COMPAT_LINUX for aarch64
 1.24 24-Aug-2019  maxv Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?
 1.23 03-Feb-2017  christos branches: 1.23.6; 1.23.14; 1.23.18;
add sendmmsg and recvmmsg
 1.22 27-Jan-2014  njoly branches: 1.22.4; 1.22.6; 1.22.10; 1.22.14; 1.22.16;
Add basic IPV6 level socket options support (IPV6_V6ONLY).
 1.21 30-Jun-2011  wiz branches: 1.21.2; 1.21.12; 1.21.16;
dependant -> dependent
 1.20 02-Nov-2010  chs update linux_sys_socket() to understand the flags that are now
included in the "type" parameter. in linux_sys_sendmsg(),
if we see an SCM_CREDENTIALS control message, just drop it
instead of giving an error. the linux and native versions of
the cred-passing operation are very different and some apps
(eg. linux pulseaudio library talking to a native server)
will work without the control data.
 1.19 28-Nov-2009  dsl branches: 1.19.2; 1.19.4;
Add LINUX_SIOCGIFMTU and LINUX_IP_HDRINCL support.
Fixes part of PR/31358
The other parts are rather too intrusive to be fixed as in the PR.
 1.18 17-Jun-2009  njoly Add a new linux_msghdr structure, as its size differs on 64bit archs.
Do the needed conversions in sendmsg/recvmsg syscalls, and adjust
their definitions accordingly.
 1.17 16-Jun-2009  njoly Add LINUX_CMSG_{SPACE,LEN} macros. Use then when calculating the
msg_controllen size, when converting the control message buffer from
native (previous version was missing the linux_cmsghdr size).
 1.16 28-Apr-2008  martin branches: 1.16.14;
Remove clause 3 and 4 from TNF licenses
 1.15 01-Jul-2007  dsl branches: 1.15.28; 1.15.30; 1.15.32;
Fix long-term breakage in the definition of 'control' data for linux.
cmsg->cmsg_len is 'size_t' not 'socklen_t' - so it is 8 bytes on 64bit
platforms instead of 4. There is also never padding after the header.
Redo linux sendmsg() so that it stands a chance of getting it right.
Redo linux recvmsg() so that it process control data directly from the mbuf
list. Allowing it to hack the data without using the stackgap.
 1.14 04-Mar-2007  christos branches: 1.14.2; 1.14.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 11-Dec-2005  christos branches: 1.13.26;
merge ktrace-lwp.
 1.12 03-May-2005  manu branches: 1.12.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.11 27-Jul-2003  jdolecek More complete sendmsg(2) and recvmsg(2) emulation:
* translate MSG_* flags
* rewrite CMSG level/type to appropriate NetBSD value on input, and to Linux
value on output
* handle different CMSG_DATA alignment for some archs

This fixes SCM_RIGHTS passing. Other SCM_* types are not supported -
the set is different on NetBSD and Linux. SCM_TIMESTAMP doesn't seem
to be actually implemented in Linux 2.5.15, so it's not supported
for Linux binaries either (for now).

PR: 21577 by Todd Vierling
 1.10 14-Jan-2002  bjh21 branches: 1.10.10; 1.10.16;
Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.9 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.8 19-Jan-2001  manu branches: 1.8.2; 1.8.4; 1.8.6;
Added Linux compatibility support for powerpc ports
 1.7 15-Dec-1998  itohy branches: 1.7.8;
Added linux compat support on m68k ports.
 1.6 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.5 03-Oct-1998  christos Attempt to fix the mess.
 1.4 01-Oct-1998  erh Split linux_socket.h into i386 and common parts.
 1.3 28-May-1995  mycroft Convert TCP socket options.
 1.2 28-May-1995  mycroft Convert IP socket options.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.7.8.1 11-Feb-2001  bouyer Sync with HEAD.
 1.8.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.8.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.8.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.10.16.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.16.1 03-Aug-2004  skrll Sync with HEAD
 1.10.10.1 22-Oct-2003  jmc Pullup rev 1.11 (requested by tv in ticket #1425)

More complete sendmsg(2) and recvmsg(2) emulation:
* translate MSG_* flags
* rewrite CMSG level/type to appropriate NetBSD value on input,
and to Linux value on output
* handle different CMSG_DATA alignment for some archs

This fixes SCM_RIGHTS passing. Other SCM_* types are not supported -
the set is different on NetBSD and Linux. SCM_TIMESTAMP doesn't seem
to be actually implemented in Linux 2.5.15, so it's not supported
for Linux binaries either (for now).
 1.12.2.1 03-Sep-2007  yamt sync with head.
 1.13.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.4.1 11-Jul-2007  mjf Sync with head.
 1.14.2.1 15-Jul-2007  ad Sync with head.
 1.15.32.3 11-Mar-2010  yamt sync with head
 1.15.32.2 20-Jun-2009  yamt sync with head
 1.15.32.1 16-May-2008  yamt sync with head.
 1.15.30.1 18-May-2008  yamt sync with head.
 1.15.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.14.1 23-Jul-2009  jym Sync with HEAD.
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.19.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.21.16.1 18-May-2014  rmind sync with head
 1.21.12.2 03-Dec-2017  jdolecek update from HEAD
 1.21.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 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.22.16.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.22.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.22.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.22.6.1 05-Feb-2017  skrll Sync with HEAD
 1.22.4.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.23.18.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.23.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.23.6.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.25.10.1 02-Aug-2025  perseant Sync with HEAD
 1.1 25-Jan-2014  njoly branches: 1.1.4; 1.1.6; 1.1.10;
Update linux socket socket options (SO_*). Add common version to its
own file (linux_socket_generic.h); use it for all but alpha and mips.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 25-Jan-2014  tls file linux_socket_generic.h was added on branch tls-maxphys on 2014-08-20 00:03:32 +0000
 1.1.6.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.1.6.1 25-Jan-2014  yamt file linux_socket_generic.h was added on branch yamt-pagecache on 2014-05-22 11:40:17 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 25-Jan-2014  rmind file linux_socket_generic.h was added on branch rmind-smpnet on 2014-05-18 17:45:32 +0000
 1.49 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.48 09-Feb-2017  christos use proper arg functions, remove bogus ones.
 1.47 03-Feb-2017  christos add sendmmsg and recvmmsg
 1.46 03-Feb-2017  christos handle accept4 for i386
 1.45 09-Nov-2014  maxv branches: 1.45.2; 1.45.4; 1.45.6;
Do not uselessly include <sys/malloc.h>.
 1.44 21-Jun-2014  maxv branches: 1.44.2;
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.

With the help of njoly@
 1.43 27-Dec-2013  njoly branches: 1.43.2;
Rename ipcall/socketcall specific defines to avoid conflict with
syscalls definitions. No functional changes.
 1.42 22-Jun-2012  martin branches: 1.42.2; 1.42.4;
From the "parse errors that you just do not see as a human" department:
build fix.
 1.41 21-Jun-2012  christos fix token pasting.
 1.40 20-Jun-2012  christos print proper ktruser names depending on the emulation.
 1.39 03-Jul-2008  njoly branches: 1.39.6; 1.39.20; 1.39.30; 1.39.36; 1.39.40; 1.39.42; 1.39.44;
Fix SIOCGIFCONF ioctl for 64bit platforms. Add a new linux_ifreq
structure and linux_getifconf function (cleaned up version from
compat_ifconf).

While here, update linux_getifhwaddr to use the new structure.

Ok by christos.
 1.38 28-Apr-2008  martin branches: 1.38.2; 1.38.4;
Remove clause 3 and 4 from TNF licenses
 1.37 20-Dec-2007  dsl branches: 1.37.6; 1.37.8; 1.37.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.36 08-Dec-2007  dsl branches: 1.36.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.35 15-Aug-2007  ad branches: 1.35.2; 1.35.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.34 02-Jun-2007  yamt branches: 1.34.2; 1.34.6;
wrap #include "opt_ktrace.h" by #ifdef _KERNEL_OPT.
 1.33 01-Jun-2007  dsl (Ab)use a KTR_USER trace entry for the linux socket command and arguments.
 1.32 04-Mar-2007  christos branches: 1.32.2; 1.32.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.31 09-Feb-2007  ad branches: 1.31.2;
Merge newlock2 to head.
 1.30 11-Dec-2005  christos branches: 1.30.20;
merge ktrace-lwp.
 1.29 29-May-2005  christos branches: 1.29.2;
- sprinkle const.
- add XXXUNCONST to the emul_find() pbuf argument free'ing. XXX: this needs
an api change.
- avoid variable shadowing.
 1.28 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.27 05-Sep-2004  jdolecek improve the (#ifdef DEBUG_LINUX) socketcall argument dump code:
- print the socketcall type
- special case socket(2) call, it's also the only one with first argument
not being a socket descriptor
- only dump the relevant part of linux_socketcall_dummy_args, instead
of always the whole structure
 1.26 29-Aug-2004  jdolecek dump socketcall data #ifdef DEBUG_LINUX
 1.25 18-Jan-2003  thorpej branches: 1.25.2;
Merge the nathanw_sa branch.
 1.24 29-Mar-2002  christos - #undef DPRINTF for files that are included from other files.
- more debugging for socketcalls
- fix sa_len if AF_INET; somehow we get passed 28 instead of 16?
 1.23 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.22 22-Jul-2001  jdolecek make linux_socketcall_argsize[] static const
 1.21 04-Jul-2001  jdolecek branches: 1.21.2;
Do address family (AF_*) number translation for socket system calls which
pass socket address in our or out. This makes Linux programs using IPv6
working under emulation. This addresses kern/13279 by Jun-ichiro itojun Hagino.

Change sendmsg()/recvmsg() to expect the control information
to be passed the standard way (not 4.3BSD one, imlied by compat_43 code
or MSG_COMPAT). Linux uses different (arguably broken) CMSG_ALIGN() on some
architectures unfortunately, that would need to be handled eventually.

Also provide some other trivial stubs (like linux_sys_send()) to avoid
unneeded dependance on uipc_syscalls_43.c.
 1.20 22-Jun-2001  jdolecek linux_sys_socketcall(): refuse negative 'what' values
 1.19 25-Mar-1999  sommerfe branches: 1.19.20;
commit fix to PR7072: emulate linux non-blocking connect behavior more correctly
 1.18 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.17 03-Oct-1998  christos Attempt to fix the mess.
 1.16 01-Oct-1998  erh Split linux/compat/linux_socket.c into common and multi-architechture parts. linux_socketcall.c contains the socketcall multiplexer.
 1.15 22-Dec-1996  fvdl Make this compile again, including Politically Correct const handling.
 1.14 05-Apr-1996  christos Prototyping changes.
 1.13 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.12 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.11 19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.10 14-Aug-1995  mycroft Rearrange #includes.
 1.9 24-Jun-1995  christos Use compat_util.[ch].
 1.8 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.7 28-May-1995  mycroft Need netinet/tcp.h.
 1.6 28-May-1995  mycroft Convert TCP socket options.
 1.5 28-May-1995  mycroft Fill in `name' argument to getsockopt() correctly.
 1.4 28-May-1995  mycroft Fix typo.
 1.3 28-May-1995  mycroft Convert IP socket options.
 1.2 28-May-1995  mycroft Get rid of damned `static's.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.19.20.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.19.20.4 17-Apr-2002  nathanw Catch up to -current.
 1.19.20.3 14-Nov-2001  nathanw Catch up to -current.
 1.19.20.2 24-Aug-2001  nathanw Catch up with -current.
 1.19.20.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.21.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.21.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.2.1 03-Aug-2001  lukem update to -current
 1.25.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.1 03-Sep-2004  skrll Sync with HEAD
 1.29.2.3 21-Jan-2008  yamt sync with head
 1.29.2.2 03-Sep-2007  yamt sync with head.
 1.29.2.1 26-Feb-2007  yamt sync with head.
 1.30.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.31.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.32.4.1 11-Jul-2007  mjf Sync with head.
 1.32.2.2 20-Aug-2007  ad Sync with HEAD.
 1.32.2.1 09-Jun-2007  ad Sync with head.
 1.34.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.34.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.34.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.35.10.1 26-Dec-2007  ad Sync with head.
 1.35.2.1 09-Jan-2008  matt sync with HEAD
 1.36.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.37.10.2 04-May-2009  yamt sync with head.
 1.37.10.1 16-May-2008  yamt sync with head.
 1.37.8.1 18-May-2008  yamt sync with head.
 1.37.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.37.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.38.4.1 03-Jul-2008  simonb Sync with head.
 1.38.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.38.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.38.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.39.44.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1104):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@
 1.39.42.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1916):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@
 1.39.40.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1104):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@
 1.39.36.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1104):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@
 1.39.30.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.39.30.1 30-Oct-2012  yamt sync with head
 1.39.20.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1916):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@
 1.39.6.1 08-Aug-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1916):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@
 1.42.4.1 18-May-2014  rmind sync with head
 1.42.2.2 03-Dec-2017  jdolecek update from HEAD
 1.42.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.2.1 10-Aug-2014  tls Rebase.
 1.44.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.45.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.45.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.45.2.2 28-Aug-2017  skrll Sync with HEAD
 1.45.2.1 05-Feb-2017  skrll Sync with HEAD
 1.22 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.21 09-Feb-2017  christos use proper arg functions, remove bogus ones.
 1.20 03-Feb-2017  christos New versions of linux on arm and others have both socketcall and separate
syscalls...
 1.19 03-Feb-2017  christos add sendmmsg and recvmmsg
 1.18 03-Feb-2017  christos handle accept4 for i386
 1.17 27-Dec-2013  njoly branches: 1.17.6; 1.17.10; 1.17.14;
Rename ipcall/socketcall specific defines to avoid conflict with
syscalls definitions. No functional changes.
 1.16 17-Jun-2009  njoly branches: 1.16.12; 1.16.22; 1.16.26;
Add a new linux_msghdr structure, as its size differs on 64bit archs.
Do the needed conversions in sendmsg/recvmsg syscalls, and adjust
their definitions accordingly.
 1.15 28-Apr-2008  martin branches: 1.15.14;
Remove clause 3 and 4 from TNF licenses
 1.14 20-Dec-2007  dsl branches: 1.14.6; 1.14.8; 1.14.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.13 04-Dec-2007  dsl branches: 1.13.4;
Remove all the __P
 1.12 04-Mar-2007  christos branches: 1.12.14; 1.12.16; 1.12.22; 1.12.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 09-Feb-2006  manu branches: 1.11.20;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.10 11-Dec-2005  christos branches: 1.10.2; 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 03-May-2005  manu branches: 1.9.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.8 26-Feb-2005  perry nuke trailing whitespace
 1.7 18-Jan-2003  thorpej branches: 1.7.2; 1.7.10; 1.7.12;
Merge the nathanw_sa branch.
 1.6 04-Jul-2001  jdolecek Do address family (AF_*) number translation for socket system calls which
pass socket address in our or out. This makes Linux programs using IPv6
working under emulation. This addresses kern/13279 by Jun-ichiro itojun Hagino.

Change sendmsg()/recvmsg() to expect the control information
to be passed the standard way (not 4.3BSD one, imlied by compat_43 code
or MSG_COMPAT). Linux uses different (arguably broken) CMSG_ALIGN() on some
architectures unfortunately, that would need to be handled eventually.

Also provide some other trivial stubs (like linux_sys_send()) to avoid
unneeded dependance on uipc_syscalls_43.c.
 1.5 25-Mar-1999  sommerfe branches: 1.5.20;
commit fix to PR7072: emulate linux non-blocking connect behavior more correctly
 1.4 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.3 03-Oct-1998  christos Attempt to fix the mess.
 1.2 01-Oct-1998  erh Move compat/linux/linux_socketcall.h to multiarch. Defines for the socketcall multiplexer.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.5.20.2 24-Aug-2001  nathanw Catch up with -current.
 1.5.20.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.7.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.10.1 29-Apr-2005  kent sync with -current
 1.7.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.2.4 21-Jan-2008  yamt sync with head
 1.9.2.3 07-Dec-2007  yamt sync with head
 1.9.2.2 03-Sep-2007  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.1 18-Feb-2006  yamt sync with head.
 1.11.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.24.2 26-Dec-2007  ad Sync with head.
 1.12.24.1 08-Dec-2007  ad Sync with head.
 1.12.22.2 27-Dec-2007  mjf Sync with HEAD.
 1.12.22.1 08-Dec-2007  mjf Sync with HEAD.
 1.12.16.1 09-Jan-2008  matt sync with HEAD
 1.12.14.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.13.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.10.2 20-Jun-2009  yamt sync with head
 1.14.10.1 16-May-2008  yamt sync with head.
 1.14.8.1 18-May-2008  yamt sync with head.
 1.14.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.14.1 23-Jul-2009  jym Sync with HEAD.
 1.16.26.1 18-May-2014  rmind sync with head
 1.16.22.2 03-Dec-2017  jdolecek update from HEAD
 1.16.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.12.1 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.17.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.17.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.17.6.2 28-Aug-2017  skrll Sync with HEAD
 1.17.6.1 05-Feb-2017  skrll Sync with HEAD
 1.20 01-Oct-2024  riastradh sys/compat/linux/common: Nix trailing whitespace, and one blank line.

No functional change intended.
 1.19 11-Jan-2013  christos branches: 1.19.74;
Use copyin/copyout and linux-specific ifreq structures (they are the same
as the netbsd ones, but this disconnects them)
 1.18 28-Nov-2009  dsl branches: 1.18.12; 1.18.22;
Add LINUX_SIOCGIFMTU and LINUX_IP_HDRINCL support.
Fixes part of PR/31358
The other parts are rather too intrusive to be fixed as in the PR.
 1.17 13-Nov-2009  joerg Provide SIOCGIFNAME.
 1.16 03-Jul-2008  njoly branches: 1.16.6; 1.16.14;
Fix SIOCGIFCONF ioctl for 64bit platforms. Add a new linux_ifreq
structure and linux_getifconf function (cleaned up version from
compat_ifconf).

While here, update linux_getifhwaddr to use the new structure.

Ok by christos.
 1.15 28-Apr-2008  martin branches: 1.15.2; 1.15.4;
Remove clause 3 and 4 from TNF licenses
 1.14 22-Dec-2000  fvdl branches: 1.14.122; 1.14.124; 1.14.126;
Add SIOCGIFBR and SIOCSIFBR (more for reference than anything, currently).
 1.13 21-Dec-2000  fvdl Fix yet another typo.
 1.12 19-Dec-2000  fvdl Fix another pasto.
 1.11 18-Dec-2000  fvdl Fix pasto in previous.
 1.10 18-Dec-2000  fvdl Define LINUX_SIOCDEVPRIVATE (currently not emulated for sockets).
 1.9 17-Jul-1999  jtk branches: 1.9.2; 1.9.12;
add LINUX_SIOCGIFHWADDR
 1.8 04-Oct-1998  fvdl branches: 1.8.6; 1.8.8;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.7 03-Oct-1998  christos Attempt to fix the mess.
 1.6 01-Oct-1998  erh Move compat/linux/linux_sockio.h to common.
 1.5 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.4 27-Feb-1996  mycroft Map SIOCGIFFLAGS and SIOCGIFADDR (et al).
 1.3 27-Feb-1996  mycroft Map SIOCGIFCONF.
 1.2 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.8.8.1 02-Aug-1999  thorpej Update from trunk.
 1.8.6.1 15-Jan-2000  he Pull up revision 1.9 (requested by joda):
Implement the SIOCGIFHWADDR Linux ioctl, allowing installation
of Matlab (after convincing the install script it is running on
a supported platform).
 1.9.12.1 30-Mar-2001  he Pull up revisions 1.10-1.14 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.9.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.14.126.3 11-Mar-2010  yamt sync with head
 1.14.126.2 04-May-2009  yamt sync with head.
 1.14.126.1 16-May-2008  yamt sync with head.
 1.14.124.1 18-May-2008  yamt sync with head.
 1.14.122.2 28-Sep-2008  mjf Sync with HEAD.
 1.14.122.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.4.1 03-Jul-2008  simonb Sync with head.
 1.15.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.16.14.1 21-Apr-2010  matt sync to netbsd-5
 1.16.6.1 28-Nov-2009  bouyer Pull up following revision(s) (requested by joerg in ticket #1147):
sys/compat/linux32/common/linux32_socket.c: revision 1.11, 1.12
sys/compat/linux/common/linux_socket.c: revision 1.105, 1.106
sys/compat/linux/common/linux_sockio.h: revision 1.17
sys/compat/linux32/common/linux32_sockio.h: revision 1.3
Provide SIOCGIFNAME.
Return the result of copyout. Reminded by Niolas Joly.
 1.18.22.1 25-Feb-2013  tls resync with head
 1.18.12.1 23-Jan-2013  yamt sync with head
 1.19.74.1 02-Aug-2025  perseant Sync with HEAD
 1.7 23-Aug-2019  maxv Fix info leaks.
 1.6 13-Sep-2012  pooka branches: 1.6.12; 1.6.24; 1.6.30; 1.6.38; 1.6.42;
Rename structure members to make the code compile in environments
where "linux" is #defined.
 1.5 02-Nov-2010  chs branches: 1.5.8; 1.5.18;
implement the following syscalls for linux32:
truncate64
ftruncate64
profil
ioperm
iopl
setdomainname
modify_ldt
statfs64
fstatfs64

note that iopl(), ioperm() and modify_ldt() just call
the respective 64-bit handlers, which don't do anything yet.
 1.4 15-Mar-2009  cegger branches: 1.4.2; 1.4.4;
ansify function definitions
 1.3 28-Apr-2008  martin branches: 1.3.8; 1.3.14;
Remove clause 3 and 4 from TNF licenses
 1.2 04-Dec-2007  dsl branches: 1.2.12; 1.2.14; 1.2.16;
Remove all the __P
 1.1 11-Apr-2007  njoly branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.16; 1.1.18; 1.1.20; 1.1.26; 1.1.28;
- Add compat amd64 linux32 statfs support, adapted from PR/35956.
- Move bsd_to_linux_statfs() function to its own file to be shared
between both linux compats.

ok by manu.
 1.1.28.1 08-Dec-2007  ad Sync with head.
 1.1.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.1.20.3 07-Dec-2007  yamt sync with head
 1.1.20.2 03-Sep-2007  yamt sync with head.
 1.1.20.1 11-Apr-2007  yamt file linux_statfs.h was added on branch yamt-lazymbuf on 2007-09-03 14:32:26 +0000
 1.1.18.1 09-Jan-2008  matt sync with HEAD
 1.1.16.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.1.10.2 11-Jul-2007  mjf Sync with head.
 1.1.10.1 11-Apr-2007  mjf file linux_statfs.h was added on branch mjf-ufs-trans on 2007-07-11 20:04:20 +0000
 1.1.8.2 09-Jun-2007  ad Sync with head.
 1.1.8.1 11-Apr-2007  ad file linux_statfs.h was added on branch vmlocking on 2007-06-09 21:37:08 +0000
 1.1.6.2 20-Apr-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #582):
sys/compat/linux32/common/linux32_types.h: revision 1.4 via patch
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.14 via patch
sys/compat/linux/common/linux_statfs.h: revision 1.1 via patch
sys/compat/linux/common/linux_misc.c: revision 1.170 via patch
sys/compat/linux32/common/linux32_misc.c: revision 1.5 via patch
sys/compat/linux32/files.linux32: revision 1.4 via patch
- Add compat amd64 linux32 statfs support, adapted from PR/35956.
- Move bsd_to_linux_statfs() function to its own file to be shared
between both linux compats.
 1.1.6.1 11-Apr-2007  bouyer file linux_statfs.h was added on branch netbsd-4 on 2007-04-20 20:26:04 +0000
 1.1.4.2 15-Apr-2007  yamt sync with head.
 1.1.4.1 11-Apr-2007  yamt file linux_statfs.h was added on branch yamt-idlelwp on 2007-04-15 16:03:14 +0000
 1.2.16.2 04-May-2009  yamt sync with head.
 1.2.16.1 16-May-2008  yamt sync with head.
 1.2.14.1 18-May-2008  yamt sync with head.
 1.2.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.4.4.1 05-Mar-2011  rmind sync with head
 1.4.2.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.5.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.8.1 30-Oct-2012  yamt sync with head
 1.6.42.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.6.38.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.30.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.6.24.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.6.12.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.48 10-Jul-2023  christos Add memfd_create(2) from GSoC 2023 by Theodore Preduta
 1.47 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.46 21-Mar-2020  pgoyette Deal with having to teardown sysctl entries in multiple sub-trees.

(This used to work, but I broke it recently.)
 1.45 16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.44 29-Sep-2017  maxv branches: 1.44.4;
Remove compat_linux from the autoload list, and add a sysctl to enable or
disable it - which defaults to disabled. The following command is now
required to use linux binaries:

sysctl -w emul.linux.enabled=1

After a discussion on tech-kern@. All the other ideas to reduce the attack
surface have drawbacks, and this sysctl seems to be the best option.
 1.43 16-May-2014  martin Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.42 25-Feb-2014  pooka branches: 1.42.2;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.41 18-Nov-2013  chs claim to be linux 3.11.6 (opensuse 13.1).
 1.40 07-Jul-2010  chs branches: 1.40.8; 1.40.18; 1.40.22;
many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.
 1.39 05-Jan-2009  njoly branches: 1.39.4; 1.39.6;
Make sysctl(2) fails with ENOTDIR (instead of EINVAL) for invalid mib
vector length.
 1.38 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.37 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.36 18-Jun-2008  tsutsui branches: 1.36.2; 1.36.4;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.35 28-Apr-2008  martin branches: 1.35.2; 1.35.4;
Remove clause 3 and 4 from TNF licenses
 1.34 07-Jan-2008  ad branches: 1.34.6; 1.34.8; 1.34.10;
Patch up sysctl locking:

- Lock processes, credentials, filehead etc correctly.
- Acquire a read hold on sysctl_treelock if only doing a query.
- Don't wire down the output buffer. It doesn't work correctly and the code
regularly does long term sleeps with it held - it's not worth it.
- Don't hold locks other than sysctl_lock while doing copyout().
- Drop sysctl_lock while doing copyout / allocating memory in a few places.
- Don't take kernel_lock for sysctl.
- Fix a number of bugs spotted along the way
 1.33 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.32 19-Oct-2007  njoly branches: 1.32.2; 1.32.4; 1.32.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.31 15-Aug-2007  ad branches: 1.31.2; 1.31.6;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.30 10-May-2007  christos branches: 1.30.2; 1.30.6;
- linux uname -m on x86 returns i{3,4,5,6}86 make it so.
- delete the machine sysctl that never worked, and gc linux_machine.
 1.29 10-May-2007  christos move the #if 0 down a few lines so linux_machine gets initialized. Pointed
out by Joachim K�nig
 1.28 06-May-2007  christos Remove change that obviously was not tested (since it uses LINUX_KERN_VERSION
again, producing EEXIST). There is no machine sysctl in linux that corresponds
to this (at least on my i386 suse box)
 1.27 23-Apr-2007  manu Linux's uname should return x86_64 as machine_arch
 1.26 23-Mar-2007  mrg implement emul.linux.kern.machine, which can be set to "i686", like
some applications seem to want.
 1.25 09-Feb-2007  ad branches: 1.25.2; 1.25.6; 1.25.8; 1.25.10;
Merge newlock2 to head.
 1.24 16-Nov-2006  christos branches: 1.24.2;
__unused removal on arguments; approved by core.
 1.23 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.22 24-Sep-2006  dbj use _KERNEL_OPT instead of _LKM to check whether to include "opt_ktrace.h"
 1.21 24-Sep-2006  dogcow opt_ktrace.h doesn't exist when building LKMs.
 1.20 23-Sep-2006  manu Add sysctl tracing to emulations.
While we are there, fix a bug in FreeBSD sysctl emulation: use copyin for
moving data to the kernel
 1.19 08-Mar-2006  jonathan branches: 1.19.10; 1.19.12;
Rework Linux sysctl()-emulation, so that on amd64, we return the same
Linux kernel-version as on i386 and ppc (currently 2.4.18), and a date
in Feb 2002.

On all other NetBSD platforms we return a Linux-kernel version of
2.0.38 and a date sometime in 2000, which (AFAIK) predates the
existence of amd64, and therefore predates Linux support for amd64.

To me, it makes much more sense to return the same Linux-kernel-version
and date for both 32-bit x86 and 64-bit x86.

Empirically (and not least), this change also allows SuSE 10 amd64
binaries to run under our Linux amd64 binary emulation (both static
and dynamic-linked, given suitable setup) , which they didn't when we
reported a Linux/x86_64 kernel version of 2.0.38.
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.6; 1.18.8; 1.18.10;
merge ktrace-lwp.
 1.17 20-Jun-2005  atatat branches: 1.17.2;
Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.16 25-May-2004  atatat Sysctl descriptions under emul subtree.
 1.15 20-May-2004  atatat Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.14 27-Apr-2004  atatat Be consistent about using sysc_init_field()
 1.13 24-Mar-2004  atatat branches: 1.13.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.12 09-Mar-2004  atatat Remove useless comment about stuff that never happened.
 1.11 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.10 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.9 29-Jun-2003  fvdl branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.8 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.7 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.6 25-Nov-2002  schmonz Report ourselves as Linux 2.4.18 on powerpc, too.
 1.5 04-Apr-2002  tron Set default kernel version of Linux emulation to 2.4.18 on the i386 port.
It has been successfully tested using SuSE 7.3 libraries and binaries with
many applications.
 1.4 02-Apr-2002  jdolecek rename sysctl_linux() to linux_sysctl() and hook it into emul_linux
 1.3 20-Mar-2002  christos emulation specific sysctls. Also change the kernel date to nov 11 as requested
by bad.
 1.2 20-Feb-2002  christos branches: 1.2.2; 1.2.8;
allow writing of kernel.version, kernel.osrelease, kernel.ostype... I might
revert that l8r if I come up with something better.
 1.1 15-Feb-2002  christos s/printf/uprintf/
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1 20-Feb-2002  jdolecek file linux_sysctl.c was added on branch kqueue on 2002-03-16 16:00:39 +0000
 1.2.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.2.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.2.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.3 28-Feb-2002  nathanw LWPify linux_{set/get}rlimit(); move and LWPify linux_sysctl().
 1.2.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.1 20-Feb-2002  nathanw file linux_sysctl.c was added on branch nathanw_sa on 2002-02-28 04:12:57 +0000
 1.9.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.2 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.13.2.3 26-May-2004  he Pull up revision 1.16 (requested by atatat in ticket #387):
Add sysctl descriptions under emul subtree.
 1.13.2.2 23-May-2004  tron Pull up revision 1.15 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.13.2.1 29-Apr-2004  jmc Pullup rev 1.14 (requested by atatat in ticket #206)

Be consistent about using sysc_init_field()
 1.17.2.6 21-Jan-2008  yamt sync with head
 1.17.2.5 27-Oct-2007  yamt sync with head.
 1.17.2.4 03-Sep-2007  yamt sync with head.
 1.17.2.3 26-Feb-2007  yamt sync with head.
 1.17.2.2 30-Dec-2006  yamt sync with head.
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.18.10.1 19-Apr-2006  elad sync with head.
 1.18.8.1 13-Mar-2006  yamt sync with head.
 1.18.6.1 22-Apr-2006  simonb Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.19.12.2 10-Dec-2006  yamt sync with head.
 1.19.12.1 22-Oct-2006  yamt sync with head
 1.19.10.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.19.10.1 18-Nov-2006  ad Sync with head.
 1.24.2.1 29-Apr-2007  bouyer Pull up following revision(s) (requested by manu in ticket #596):
sys/compat/linux/arch/amd64/linux_machdep.h: revision 1.8
sys/compat/linux/common/linux_sysctl.c: revision 1.27
Linux's uname should return x86_64 as machine_arch
 1.25.10.1 29-Mar-2007  reinoud Pullup to -current
 1.25.8.1 11-Jul-2007  mjf Sync with head.
 1.25.6.3 20-Aug-2007  ad Sync with HEAD.
 1.25.6.2 27-May-2007  ad Sync with head.
 1.25.6.1 10-Apr-2007  ad Sync with head.
 1.25.2.3 17-May-2007  yamt sync with head.
 1.25.2.2 07-May-2007  yamt sync with head.
 1.25.2.1 24-Mar-2007  yamt sync with head.
 1.30.6.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.30.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.30.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.31.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.31.2.2 09-Jan-2008  matt sync with HEAD
 1.31.2.1 06-Nov-2007  matt sync with HEAD
 1.32.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.32.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.32.4.1 26-Dec-2007  ad Sync with head.
 1.32.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.34.10.3 11-Aug-2010  yamt sync with head.
 1.34.10.2 04-May-2009  yamt sync with head.
 1.34.10.1 16-May-2008  yamt sync with head.
 1.34.8.1 18-May-2008  yamt sync with head.
 1.34.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.34.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.34.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.35.4.1 18-Jun-2008  simonb Sync with head.
 1.35.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.35.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.35.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.36.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.36.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.39.6.1 05-Mar-2011  rmind sync with head
 1.39.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.40.22.1 18-May-2014  rmind sync with head
 1.40.18.2 03-Dec-2017  jdolecek update from HEAD
 1.40.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.8.1 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.42.2.1 10-Aug-2014  tls Rebase.
 1.44.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8 21-Mar-2020  pgoyette Deal with having to teardown sysctl entries in multiple sub-trees.

(This used to work, but I broke it recently.)
 1.7 16-Mar-2020  pgoyette Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself. These are not changed.
 1.6 29-Sep-2017  maxv branches: 1.6.4;
Remove compat_linux from the autoload list, and add a sysctl to enable or
disable it - which defaults to disabled. The following command is now
required to use linux binaries:

sysctl -w emul.linux.enabled=1

After a discussion on tech-kern@. All the other ideas to reduce the attack
surface have drawbacks, and this sysctl seems to be the best option.
 1.5 19-Nov-2008  ad branches: 1.5.26;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.4 28-Apr-2008  martin branches: 1.4.6; 1.4.8;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.70; 1.3.72; 1.3.74;
merge ktrace-lwp.
 1.2 20-May-2004  atatat Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.1 15-Feb-2002  christos branches: 1.1.2; 1.1.8; 1.1.20; 1.1.22;
s/printf/uprintf/
 1.1.22.1 23-May-2004  tron Pull up revision 1.2 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.1.20.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.20.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.20.1 03-Aug-2004  skrll Sync with HEAD
 1.1.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.8.1 15-Feb-2002  jdolecek file linux_sysctl.h was added on branch kqueue on 2002-03-16 16:00:39 +0000
 1.1.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.1 15-Feb-2002  nathanw file linux_sysctl.h was added on branch nathanw_sa on 2002-02-28 04:12:57 +0000
 1.3.74.2 04-May-2009  yamt sync with head.
 1.3.74.1 16-May-2008  yamt sync with head.
 1.3.72.1 18-May-2008  yamt sync with head.
 1.3.70.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.70.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.5.26.1 03-Dec-2017  jdolecek update from HEAD
 1.6.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.39 23-Nov-2021  pho Make LINUX_FIOCLEX and LINUX_FIONCLEX work

These ioctls were declared in linux_termios.h but were not actually
handled.
 1.38 23-Aug-2019  maxv Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.
 1.37 27-Dec-2013  njoly branches: 1.37.4; 1.37.16; 1.37.22; 1.37.30; 1.37.34;
Add easy parts (TCOOFF/TCOON) of the TCXONC linux termios ioctl.
 1.36 04-Jul-2008  matthias branches: 1.36.30; 1.36.40; 1.36.46;
make LINUX_TCSBRK work. The code is mostly copied from
sys/compat/ibcs2/ibcs2_ioctl.c.
 1.35 28-Apr-2008  martin branches: 1.35.2; 1.35.4;
Remove clause 3 and 4 from TNF licenses
 1.34 21-Mar-2008  ad branches: 1.34.2; 1.34.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.33 20-Dec-2007  dsl branches: 1.33.6;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.32 19-Oct-2007  njoly branches: 1.32.4; 1.32.8;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.31 13-May-2007  dsl branches: 1.31.6; 1.31.8; 1.31.12;
This is deja vu - I fixed this earlier....
No need to use stackgap for ioctl to get PTM name, directly call file's
ioctl function with kernel buffer.
 1.30 14-Mar-2007  manu Add ptmx fakedevice hack for amd64
Fix a bug in ioctl handling
 1.29 04-Mar-2007  christos branches: 1.29.2; 1.29.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 09-Feb-2007  ad branches: 1.28.2;
Merge newlock2 to head.
 1.27 25-Nov-2006  elad branches: 1.27.2;
Part of PR/33280: Christian Ehrhardt: The call to FILE_USE should be
immediatly before the FREAD | FWRITE test not after it or FILE_UNUSE will
be called after the jump to out without a corresponding FILE_USE.
 1.26 22-Sep-2006  christos Pretend to implement TIOCSPTLCK. Although failing is harmless, there is no
point in doing so.
 1.25 15-Feb-2006  manu branches: 1.25.14; 1.25.16;
- Move the BSD to Linux and Linux to BSD termio/termios conversion functions
to a header where they can be shared between COMPAT_LINUX and COMPAT_LINUX32
- Add termios ioctl emulation to COMPAT_LINUX32
- Add the getcwd system call to COMPAT_LINUX32/amd64

That makes Linux's bash working with COMPAT_LINUX32.
 1.24 11-Dec-2005  christos branches: 1.24.2; 1.24.4; 1.24.6;
merge ktrace-lwp.
 1.23 24-Oct-2005  christos PR/31905: Wolfgang Stukenbrock: Termios ioctls TIOCMBIC and TIOCMBIS missing
in linux emulation code
 1.22 26-Feb-2005  perry branches: 1.22.2; 1.22.4; 1.22.6;
nuke trailing whitespace
 1.21 13-Nov-2004  christos branches: 1.21.4; 1.21.6;
Add LINUX_TIOCGPTN for ptyfs pty emulation.
 1.20 29-Jun-2003  fvdl branches: 1.20.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.19 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.18 21-Mar-2003  dsl Change 'data' argument to fo_ioctl and fo_fcntl from 'caddr_t' to 'void *'.
Avoids a lot of casting and removes the need for some line breaks.
Removed a load of (caddr_t) casts from calls to copyin/copyout as well.
(approved by christos - he has a plan to remove caddr_t...)
 1.17 27-Feb-2003  yamt make compat_linux struct file interlock friendly.
 1.16 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.15 19-Dec-2001  augustss Add some missing ioctl()s. From Tommy Bohlin in PR kern/14414.
 1.14 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.13 14-Jun-2001  thorpej branches: 1.13.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.12 22-May-2001  manu When c_ospeed in termio is null, NetBSD hangup the terminal. Since Linux
does not do this, we fake null c_ospeed values by -1 in the kernel, so
that NetBSD does not hangup.
 1.11 21-Feb-2001  jdolecek branches: 1.11.2;
make some more constant arrays 'const'
 1.10 05-Feb-2001  itojun make it compile on alpha. cast pointer to u_long, not int
 1.9 03-Feb-2001  ross Emulate LINUX_TCFLSH with our TIOCFLUSH. Do some CSE.
 1.8 10-Dec-2000  fvdl Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.7 30-Mar-2000  augustss branches: 1.7.4;
Kill register declarations.
 1.6 04-Oct-1998  fvdl branches: 1.6.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.5 03-Oct-1998  christos Attempt to fix the mess.
 1.4 01-Oct-1998  erh Moved from compat/linux/linux_termios.c to common.
 1.3 05-Apr-1996  christos Prototyping changes.
 1.2 03-Apr-1996  mycroft Add explicit return types.
 1.1 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.6.12.4 12-Mar-2001  bouyer Sync with HEAD.
 1.6.12.3 11-Feb-2001  bouyer Sync with HEAD.
 1.6.12.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.6.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.7.4.1 30-Mar-2001  he Pull up revision 1.8 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.11.2.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.11.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.11.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.11.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.13.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.20.2.5 21-Nov-2004  skrll This was somehow missed in the sync to HEAD.
 1.20.2.4 14-Nov-2004  skrll Sync with HEAD.
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.21.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.4.1 29-Apr-2005  kent sync with -current
 1.22.6.1 26-Oct-2005  yamt sync with head
 1.22.4.7 24-Mar-2008  yamt sync with head.
 1.22.4.6 21-Jan-2008  yamt sync with head
 1.22.4.5 27-Oct-2007  yamt sync with head.
 1.22.4.4 03-Sep-2007  yamt sync with head.
 1.22.4.3 26-Feb-2007  yamt sync with head.
 1.22.4.2 30-Dec-2006  yamt sync with head.
 1.22.4.1 21-Jun-2006  yamt sync with head.
 1.22.2.1 11-Jan-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1627):
sys/compat/linux/common/linux_termios.c: revision 1.23
PR/31905: Wolfgang Stukenbrock: Termios ioctls TIOCMBIC and TIOCMBIS missing
in linux emulation code
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.24.2.1 18-Feb-2006  yamt sync with head.
 1.25.16.2 10-Dec-2006  yamt sync with head.
 1.25.16.1 22-Oct-2006  yamt sync with head
 1.25.14.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.25.14.2 12-Jan-2007  ad Sync with head.
 1.25.14.1 18-Nov-2006  ad Sync with head.
 1.27.2.1 13-May-2007  pavel Pull up following revision(s) (requested by manu in ticket #637):
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.21
sys/compat/linux/arch/amd64/linux_machdep.h: revision 1.7
sys/compat/linux/common/linux_termios.c: revision 1.30
Add ptmx fakedevice hack for amd64
Fix a bug in ioctl handling
 1.28.2.3 17-May-2007  yamt sync with head.
 1.28.2.2 24-Mar-2007  yamt sync with head.
 1.28.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.4.1 11-Jul-2007  mjf Sync with head.
 1.29.2.2 27-May-2007  ad Sync with head.
 1.29.2.1 10-Apr-2007  ad Sync with head.
 1.31.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.31.8.2 09-Jan-2008  matt sync with HEAD
 1.31.8.1 06-Nov-2007  matt sync with HEAD
 1.31.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.32.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.32.4.1 26-Dec-2007  ad Sync with head.
 1.33.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.33.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.33.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.34.4.2 04-May-2009  yamt sync with head.
 1.34.4.1 16-May-2008  yamt sync with head.
 1.34.2.1 18-May-2008  yamt sync with head.
 1.35.4.1 18-Jul-2008  simonb Sync with head.
 1.35.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.35.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.35.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.36.46.1 18-May-2014  rmind sync with head
 1.36.40.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.30.1 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.37.34.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.37.30.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.22.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.37.16.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.37.4.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.23 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.22 23-Aug-2019  maxv Fix info leaks.
 1.21 25-Sep-2011  chs branches: 1.21.28; 1.21.40; 1.21.46; 1.21.54; 1.21.58;
linux_termio c_cc array should be indexed by LINUX_OLD_V* rather than LINUX_V*.
fixes array overrun on alpha noticed by gcc 4.5.
 1.20 04-Jul-2011  mrg avoid array bounds violation on netbsd/mips when dealing with termio
structures. (did linux/mips ever support termio?).

the effect of this is that termio linux apps won't have VEOF support.
i can't tell what it should be since that code isn't in linux going
back quite some years.
 1.19 15-Mar-2009  cegger ansify function definitions
 1.18 28-Jun-2008  chris branches: 1.18.4; 1.18.10;
Fix warnings about type conversions by using linux_speed_t type on
linux_speeds[] rather than speed_t.

On Arm (and others) linux uses unsigned long, however, NetBSD uses
unsigned int.
 1.17 28-Apr-2008  martin branches: 1.17.2; 1.17.4;
Remove clause 3 and 4 from TNF licenses
 1.16 04-Dec-2007  dsl branches: 1.16.12; 1.16.14; 1.16.16;
Remove all the __P
 1.15 15-Feb-2006  manu branches: 1.15.38; 1.15.40; 1.15.46; 1.15.50;
- Move the BSD to Linux and Linux to BSD termio/termios conversion functions
to a header where they can be shared between COMPAT_LINUX and COMPAT_LINUX32
- Add termios ioctl emulation to COMPAT_LINUX32
- Add the getcwd system call to COMPAT_LINUX32/amd64

That makes Linux's bash working with COMPAT_LINUX32.
 1.14 11-Dec-2005  christos branches: 1.14.2; 1.14.4; 1.14.6;
merge ktrace-lwp.
 1.13 03-May-2005  manu branches: 1.13.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.12 26-Feb-2005  perry nuke trailing whitespace
 1.11 14-Jan-2002  bjh21 branches: 1.11.16; 1.11.24; 1.11.26;
Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.10 22-Sep-2001  manu Enable Mips Linux emulation in header files
 1.9 26-Aug-2001  manu branches: 1.9.2;
Moved LINUX_NCCS from MI file to MD file, because the value is different
on MIPS and sparc machines.
 1.8 20-Jan-2001  manu branches: 1.8.2; 1.8.4;
Moved architecure dependent part of struct linux_termio to architecture
dependent header files.
 1.7 19-Jan-2001  manu Added Linux compatibility support for powerpc ports
 1.6 10-Dec-2000  fvdl Add some ioctls for harddisk, floppy disk and console handling.
Implement a few extra cdrom ioctl calls.
Make sure to correctly use FILE_USE and FILE_UNUSE.
 1.5 15-Dec-1998  itohy branches: 1.5.8; 1.5.18;
Added linux compat support on m68k ports.
 1.4 03-Oct-1998  christos Attempt to fix the mess.
 1.3 01-Oct-1998  erh Split compat/linux/linux_termios.h into i386 and common parts.
 1.2 05-Jan-1998  perry RCSID Police.
 1.1 08-Mar-1996  mycroft Separate ioctl emulation by group. Add (minimal) audio emulation.
 1.5.18.1 30-Mar-2001  he Pull up revision 1.6 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.5.8.2 11-Feb-2001  bouyer Sync with HEAD.
 1.5.8.1 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.8.4.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.8.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.2 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.8.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.9.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.11.26.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.24.1 29-Apr-2005  kent sync with -current
 1.11.16.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.16.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.2 07-Dec-2007  yamt sync with head
 1.13.2.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 18-Feb-2006  yamt sync with head.
 1.15.50.1 08-Dec-2007  ad Sync with head.
 1.15.46.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.40.1 09-Jan-2008  matt sync with HEAD
 1.15.38.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.16.2 04-May-2009  yamt sync with head.
 1.16.16.1 16-May-2008  yamt sync with head.
 1.16.14.1 18-May-2008  yamt sync with head.
 1.16.12.2 29-Jun-2008  mjf Sync with HEAD.
 1.16.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.4.1 03-Jul-2008  simonb Sync with head.
 1.17.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.18.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.21.58.1 13-Sep-2019  martin Pull up following revision(s) (requested by maxv in ticket #194):

sys/compat/linux/common/linux_socket.c: revision 1.146
sys/compat/linux/common/linux_socket.c: revision 1.147
sys/compat/linux/common/linux_socket.c: revision 1.148
sys/compat/linux/common/linux_socket.c: revision 1.149
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.59
sys/compat/linux32/common/linux32_sysinfo.c: revision 1.8
sys/kern/sysv_shm.c: revision 1.138
sys/compat/linux/common/linux_file64.c: revision 1.61
sys/compat/linux/common/linux_file64.c: revision 1.62
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.58
sys/compat/linux32/common/linux32_dirent.c: revision 1.20
sys/compat/linux32/common/linux32_utsname.c: revision 1.10
sys/compat/linux/common/linux_termios.h: revision 1.22
sys/compat/linux32/common/linux32_termios.c: revision 1.15
sys/compat/linux32/common/linux32_misc.c: revision 1.27
sys/compat/linux32/common/linux32_ioctl.c: revision 1.14
sys/compat/linux/common/linux_statfs.h: revision 1.7
sys/compat/linux/common/linux_ipc.c: revision 1.57
sys/compat/linux/common/linux_fcntl.h: revision 1.18
sys/compat/linux/common/linux_socket.h: revision 1.24
sys/sys/shm.h: revision 1.54
sys/compat/ossaudio/ossaudio.c: revision 1.75
sys/compat/linux32/common/linux32_signal.c: revision 1.20
sys/miscfs/procfs/procfs_linux.c: revision 1.75
sys/compat/linux/common/linux_signal.c: revision 1.81
sys/compat/linux/common/linux_termios.c: revision 1.38
sys/compat/linux/common/linux_misc.c: revision 1.241
sys/compat/linux/common/linux_misc.c: revision 1.242
sys/compat/linux/common/linux_misc.c: revision 1.243
sys/compat/linux/common/linux_misc.c: revision 1.244

Fix info leaks.

Fix stupid bugs in linux_sys_shmctl(): the index could be out of bound
(page fault) and there was no proper locking.
Maybe we should just remove LINUX_SHM_STAT, like compat_linux32.

Remove printf.

When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.

Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.

Fix error handling, returns an errno, not -1.

Put the printf under DEBUG_LINUX.


Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.

Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?

Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().

Fix memory leak.

I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.

Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.
 1.21.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.21.46.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.21.40.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.21.28.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

sys/compat/common/kern_sig_43.c 1.36
sys/compat/linux/arch/amd64/linux_machdep.c 1.59
sys/compat/linux/common/linux_fcntl.h 1.18
sys/compat/linux/common/linux_file64.c 1.62
sys/compat/linux/common/linux_ipc.c 1.57
sys/compat/linux/common/linux_misc.c 1.243
sys/compat/linux/common/linux_signal.c 1.81
sys/compat/linux/common/linux_socket.c 1.149 (patch)
sys/compat/linux/common/linux_socket.h 1.24
sys/compat/linux/common/linux_statfs.h 1.7
sys/compat/linux/common/linux_termios.c 1.38
sys/compat/linux/common/linux_termios.h 1.22
sys/compat/linux32/common/linux32_dirent.c 1.20
sys/compat/linux32/common/linux32_ioctl.c 1.14
sys/compat/linux32/common/linux32_misc.c 1.27
sys/compat/linux32/common/linux32_signal.c 1.20
sys/compat/linux32/common/linux32_sysinfo.c 1.8
sys/compat/linux32/common/linux32_termios.c 1.15
sys/compat/linux32/common/linux32_utsname.c 1.10
sys/compat/netbsd32/netbsd32_compat_20.c 1.39
sys/compat/netbsd32/netbsd32_compat_43.c 1.59
sys/compat/netbsd32/netbsd32_compat_50.c 1.44
sys/compat/ossaudio/ossaudio.c 1.75
sys/kern/sysv_shm.c 1.138
sys/miscfs/procfs/procfs_linux.c 1.75 (patch)
sys/sys/shm.h 1.54 (patch)

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.42 19-Sep-2021  thorpej Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.41 19-Sep-2021  thorpej Add the POSIX timer syscalls (timer_create(), timer_settime(), timer_gettime(),
timer_getoverrun(), and timer_delete()) to COMPAT_LINUX and COMPAT_LINUX32.
 1.40 07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.39 29-Jul-2017  riastradh branches: 1.39.8; 1.39.16;
Put suser check in the right function: settimeofday, not gettimeofday.

While here, remove wrong comment.

Noted by kre@.
 1.38 29-Jul-2017  riastradh Only let the superuser set the compat_linux timezone.

Not really keen to invent a new kauth cookie for this useless purpose.

From Ilja Van Sprundel.
 1.37 13-Jan-2014  njoly branches: 1.37.4; 1.37.6; 1.37.8; 1.37.16; 1.37.22;
Cleanup, and reduce diffs between arches. Make alpha use
linux_sys_{get,set}timeofday like others.
 1.36 02-Oct-2012  christos branches: 1.36.2;
kernel portion of clock_nanosleep()
 1.35 18-Nov-2011  christos branches: 1.35.6; 1.35.10; 1.35.12; 1.35.14;
- add sigtimedwait support.
- merge the siginfo population code.
 1.34 12-Jul-2010  njoly branches: 1.34.8;
Add CLOCK_MONOTONIC support for compat linux/linux32
clock_nanosleep(2).
 1.33 08-Apr-2010  njoly Do not use 0 for pointers, but NULL.
 1.32 08-Apr-2010  njoly Add a new clock_gettime1() function that holds most of the
clock_gettime syscall code (except for the copyout). Adjust all
corresponding syscalls to make use of it.
 1.31 03-Apr-2010  njoly Move most clock_getres syscall code, except for coypout call, to a new
clock_getres1() function which can be used by emulations. Adjust all
clock_getres syscalls to now make of use it.
 1.30 29-Mar-2010  njoly Convert linux/linux32/netbsd32 clock_settime syscalls, to use the
common clock_settime1() function.
 1.29 21-Jul-2009  njoly branches: 1.29.2; 1.29.4;
Do reject unknown/invalid linux clockid.
 1.28 11-Jan-2009  christos branches: 1.28.2;
merge christos-time_t
 1.27 19-Nov-2008  njoly futex(2) timeout argument cleanup/fix.
- Use `struct linux_timespec', converted to native structure.
- Ensure that provided values are correct.
- Replace timeval+tvtohz by tstohz.
 1.26 12-Nov-2008  njoly Fix nanosleep(2) on 64-bit archs. Do not call native nanosleep
syscall, but rather a modified version the will take care of `struct
timespec' conversions.
 1.25 18-Jun-2008  tsutsui branches: 1.25.2; 1.25.4; 1.25.6;
Include <sys/sched.h> before <sys/syscallargs.h> for cpuset_t.
 1.24 28-Apr-2008  martin branches: 1.24.2; 1.24.4;
Remove clause 3 and 4 from TNF licenses
 1.23 17-Apr-2008  njoly branches: 1.23.2; 1.23.4;
Add compat linux32 sys_clock_{getres,gettime,settime} syscalls.
 1.22 20-Dec-2007  dsl branches: 1.22.6; 1.22.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.21 08-Dec-2007  dsl branches: 1.21.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.20 25-Nov-2007  elad branches: 1.20.2;
Refactor time modification checks and place them in the secmodel code.

okay christos@
 1.19 19-Oct-2007  njoly branches: 1.19.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.18 13-May-2007  dsl branches: 1.18.6; 1.18.8; 1.18.12;
Stop using the stackgap for time functions.
 1.17 12-May-2007  dsl Fix comment and indent.
 1.16 04-Mar-2007  christos branches: 1.16.2; 1.16.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.15 09-Feb-2007  ad branches: 1.15.2;
Merge newlock2 to head.
 1.14 14-May-2006  christos branches: 1.14.8;
XXX: GCC uninitialized
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.12;
merge ktrace-lwp.
 1.12 05-Nov-2005  manu Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()
 1.11 16-May-2005  fvdl branches: 1.11.2;
Implement clock_* POSIX functions.
 1.10 03-May-2005  manu First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.9 26-Feb-2005  perry nuke trailing whitespace
 1.8 18-Jan-2003  thorpej branches: 1.8.2; 1.8.10; 1.8.12;
Merge the nathanw_sa branch.
 1.7 17-Jan-2002  rjs Add arm to #endif comment.
 1.6 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.5 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.4 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.3 22-Sep-2001  manu Fixes for mips support
 1.2 15-May-2001  manu branches: 1.2.2; 1.2.4; 1.2.6;
This file is not used on alpha, and it causes some warning that break the
build. Added an ifdef to ignore the file content for alpha (not tested)
 1.1 13-May-2001  manu Improved the accuracy of gettimeofday/settimeofday: Linux stores a srtuct
timezone in the kernel. We now keep track of it for emulated processes.
Tested for powerpc and i386. Untested on m68k, but it should be ok
Alpha has a particular implementation (osf1_sys_gettimeofday), and it has
therefore not been touched.
 1.2.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.2.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.2.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.7 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.5 08-Jan-2002  nathanw Catch up to -current.
 1.2.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.3 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.2.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.2.2.1 15-May-2001  nathanw file linux_time.c was added on branch nathanw_sa on 2001-06-21 19:59:57 +0000
 1.8.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.10.1 29-Apr-2005  kent sync with -current
 1.8.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.6 21-Jan-2008  yamt sync with head
 1.11.2.5 07-Dec-2007  yamt sync with head
 1.11.2.4 27-Oct-2007  yamt sync with head.
 1.11.2.3 03-Sep-2007  yamt sync with head.
 1.11.2.2 26-Feb-2007  yamt sync with head.
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.13.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.13.8.1 24-May-2006  yamt sync with head.
 1.13.6.1 01-Jun-2006  kardel Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.8.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.2.2 17-May-2007  yamt sync with head.
 1.15.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.4.1 11-Jul-2007  mjf Sync with head.
 1.16.2.1 27-May-2007  ad Sync with head.
 1.18.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.18.8.2 09-Jan-2008  matt sync with HEAD
 1.18.8.1 06-Nov-2007  matt sync with HEAD
 1.18.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.18.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.18.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.19.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.19.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 26-Dec-2007  ad Sync with head.
 1.21.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.22.8.3 20-Nov-2008  christos merge with head.
 1.22.8.2 01-Nov-2008  christos Sync with head.
 1.22.8.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.22.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.22.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.22.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.4.4 11-Aug-2010  yamt sync with head.
 1.23.4.3 19-Aug-2009  yamt sync with head.
 1.23.4.2 04-May-2009  yamt sync with head.
 1.23.4.1 16-May-2008  yamt sync with head.
 1.23.2.1 18-May-2008  yamt sync with head.
 1.24.4.1 18-Jun-2008  simonb Sync with head.
 1.24.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.24.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.24.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.25.6.1 20-Nov-2008  snj Pull up following revision(s) (requested by njoly in ticket #81):
sys/compat/linux/arch/mips/syscalls.master: revision 1.30
sys/compat/linux/arch/m68k/syscalls.master: revision 1.63
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.39
sys/compat/linux/arch/alpha/syscalls.master: revision 1.63
sys/compat/linux/arch/powerpc/syscalls.master: revision 1.38
sys/compat/linux32/common/linux32_time.c: revision 1.22
sys/compat/linux/arch/amd64/syscalls.master: revision 1.25
sys/compat/linux/arch/i386/syscalls.master: revision 1.94
sys/compat/linux/arch/arm/syscalls.master: revision 1.36
sys/compat/linux/common/linux_time.c: revision 1.26
Fix nanosleep(2) on 64-bit archs. Do not call native nanosleep
syscall, but rather a modified version the will take care of `struct
timespec' conversions.
 1.25.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.25.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.28.2.1 23-Jul-2009  jym Sync with HEAD.
 1.29.4.2 05-Mar-2011  rmind sync with head
 1.29.4.1 30-May-2010  rmind sync with head
 1.29.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.29.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.8.3 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.34.8.2 30-Oct-2012  yamt sync with head
 1.34.8.1 17-Apr-2012  yamt sync with head
 1.35.14.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1489):
sys/compat/linux/common/linux_time.c: 1.38-1.39 via patch
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
--
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.35.12.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1489):
sys/compat/linux/common/linux_time.c: 1.38-1.39 via patch
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
--
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.35.10.3 03-Dec-2017  jdolecek update from HEAD
 1.35.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.10.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.35.6.1 19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1489):
sys/compat/linux/common/linux_time.c: 1.38-1.39 via patch
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
--
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.36.2.1 18-May-2014  rmind sync with head
 1.37.22.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.37.22.1 08-Aug-2017  martin Pull up following revision(s) (requested by spz in ticket #188):
sys/compat/linux/common/linux_time.c: revision 1.38
sys/compat/linux/common/linux_time.c: revision 1.39
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.37.16.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1486):
sys/compat/linux/common/linux_time.c: revision 1.38-1.39 via patch
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
--
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.37.8.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1486):
sys/compat/linux/common/linux_time.c: revision 1.38-1.39 via patch
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
--
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.37.6.1 28-Aug-2017  skrll Sync with HEAD
 1.37.4.1 12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1486):
sys/compat/linux/common/linux_time.c: revision 1.38-1.39 via patch
Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.
From Ilja Van Sprundel.
--
Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.
Noted by kre@.
 1.39.16.2 17-Dec-2020  thorpej Re-factor the code that maps the clockid_t in timer_create() and
the flags in timerfd_settime() into separate functions.
 1.39.16.1 15-Dec-2020  thorpej Add Linux eventfd, timerfd, and POSIX timer calls.
 1.39.8.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.34 01-Jul-2024  christos Add linux POSIX message queue support (Ricardo Branco)
 1.33 25-Nov-2021  ryo branches: 1.33.10;
- Add compat_linux statx(2) syscall.
- The AT_EMPTY_PATH processing from the modification of
sys/compat/linux/common/linux_file64.c r1.63 has been separated, and made
common to linux_statat(), so that it can be used not only by
linux32_sys_fstatat64() but also by other *statat() variants.
 1.32 23-Sep-2021  ryo add support COMPAT_LINUX for aarch64
 1.31 18-Nov-2013  chs implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.30 11-Jan-2009  christos branches: 1.30.14; 1.30.24; 1.30.28;
merge christos-time_t
 1.29 05-Jan-2009  njoly Restore struct sysctl padding member name, which was damaged during
__unused removal on arguments.
 1.28 28-Apr-2008  martin branches: 1.28.8;
Remove clause 3 and 4 from TNF licenses
 1.27 15-Jan-2008  njoly branches: 1.27.6; 1.27.8; 1.27.10; 1.27.12;
compat linux (and linux32) uid16 functions cleanup and fixes.

- Move uid16 functions to their own file linux_uid16.c, included by
needed archs (arm, i386 and m68k).
- Add new MI types linux_{u,g}id16_t.
- Add macros to handle linux_uid16_t and uid_t conversions.
- Add linux_sys_getres{uid,gid}16 syscalls, to fix an overflow with
bad sizes given to copyout when linux_sys_getres{uid,gid} are used.
- Update arm syscall table to use more uid16 functions.
 1.26 23-Mar-2007  mrg branches: 1.26.10; 1.26.16; 1.26.22;
implement emul.linux.kern.machine, which can be set to "i686", like
some applications seem to want.
 1.25 14-Mar-2007  njoly branches: 1.25.2;
Fix compat linux statfs/fstatfs syscalls on amd64.
- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.

ok by manu
 1.24 16-Nov-2006  christos branches: 1.24.2; 1.24.4; 1.24.8; 1.24.10;
__unused removal on arguments; approved by core.
 1.23 11-Dec-2005  christos branches: 1.23.20; 1.23.22;
merge ktrace-lwp.
 1.22 03-May-2005  manu branches: 1.22.2;
First work on COMPAT_LINUX/amd64
Process startup and dynamiclinking work, but processes hang due to
Linux arch_prctl(2) not being really supported yet.
 1.21 26-Feb-2005  perry nuke trailing whitespace
 1.20 20-Sep-2004  jdolecek branches: 1.20.4; 1.20.6;
move definition of linux_fsid_t to common/linux_types.h - it's identical
across all Linux archs
 1.19 20-Sep-2004  jdolecek implement support for Linux statfs64() syscall - 64bit variant of statfs()
 1.18 20-Sep-2004  christos Add a linux_fsid_t typedef for the ports that don't have architecture dependent
linux_types.h. Fixes sparc build.
 1.17 19-Sep-2004  jdolecek Adjust struct statfs content to flag that the newer Linux kernel do
provide f_frsize. It cannot be actually used to GNU C statvfs() bug
in f_frsize != f_bsize case, so just keep pretending we don't support it.
Update comments and explain the situation in detail there.
 1.16 19-Sep-2004  jdolecek move definition of struct linux_stafs to common/linux_types.h, and use
explicit size types - the structure definition is actually identical
on currently support COMPAT_LINUX archs, so no point to have 6 copies of it
in the tree
 1.15 10-Oct-2002  thorpej branches: 1.15.6;
Avoid collision with __unused in sys/cdefs.h.
 1.14 03-Apr-2002  christos provide missing types for arch's that don't have specific linux_types.h
 1.13 15-Feb-2002  christos - add a real linux_sys___sysctl because the mib numbers are different.
implement only the kernel version getting entries.
- make the signal conversion functions consistent; dest is arg 1.
- make linux_fakedev deal with block and char devices differently.
- add linux_sys_ugetrlimit, and flesh out the regular get/setrlimit so
that they work properly.
- add linux_mmap2 [untested].
- bump kernel to 2.4.18, and make the date be valentine's day :-)
- linux_sys_*stat64 family was totally busted. Fix it.

tested only on i386.

Status:
gdb, telnet, work
jdk-1.4.0 extractor works, jdk still coredumps.

christos
 1.12 14-Jan-2002  bjh21 Crude first cut at ARMLinux binary compatibility. Successfully runs
"/emul/linux/bin/echo hello, world", dynamically linked.
 1.11 19-Jan-2001  manu branches: 1.11.2; 1.11.4;
Added Linux compatibility support for powerpc ports
 1.10 29-Dec-2000  fvdl Hardcode what the linux uname() calls return (Linux 2.2.5 is the current
value). A few major applications check for this (like VMware), and
there is no other way to trick them. Needs a more generic solution
eventually.
 1.9 07-Oct-1998  erh branches: 1.9.12; 1.9.22;
Kill the linux_old*.h includes (which are only used in the corresponding linux_old*.c). Add linux_siginfo.h.
 1.8 04-Oct-1998  fvdl Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.7 03-Oct-1998  christos Attempt to fix the mess.
 1.6 01-Oct-1998  erh Split linux_types.h into i386, common and multi-architechture parts.
 1.5 20-May-1996  fvdl Update list of Linux syscalls and implement the ones that are likely to be
used and doable.
 1.4 21-Aug-1995  mycroft Implement the old and older uname(2) calls.
 1.3 14-Aug-1995  mycroft Move signal types into signal.h.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.9.22.1 30-Mar-2001  he Pull up revision 1.10 (requested by fvdl):
Add some required Linux emulation bits to support the Linux
version of VMware.
 1.9.12.2 11-Feb-2001  bouyer Sync with HEAD.
 1.9.12.1 05-Jan-2001  bouyer Sync with HEAD
 1.11.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.11.4.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.11.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.11.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.11.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.15.6.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.6.2 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.6.1 24-Sep-2004  skrll Sync with HEAD.
 1.20.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.20.4.1 29-Apr-2005  kent sync with -current
 1.22.2.3 21-Jan-2008  yamt sync with head
 1.22.2.2 03-Sep-2007  yamt sync with head.
 1.22.2.1 30-Dec-2006  yamt sync with head.
 1.23.22.1 10-Dec-2006  yamt sync with head.
 1.23.20.1 18-Nov-2006  ad Sync with head.
 1.24.10.1 11-Jul-2007  mjf Sync with head.
 1.24.8.1 10-Apr-2007  ad Sync with head.
 1.24.4.1 24-Mar-2007  yamt sync with head.
 1.24.2.1 20-Apr-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #581):
sys/compat/linux/common/linux_misc.c: revision 1.168
sys/compat/linux/arch/amd64/syscalls.master: revision 1.18
sys/compat/linux/common/linux_types.h: revision 1.25
sys/compat/linux/arch/amd64/linux_machdep.h: revision 1.6
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.87
Fix compat linux statfs/fstatfs syscalls on amd64.
- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.
 1.25.2.1 29-Mar-2007  reinoud Pullup to -current
 1.26.22.1 19-Jan-2008  bouyer Sync with HEAD
 1.26.16.1 18-Feb-2008  mjf Sync with HEAD.
 1.26.10.1 23-Mar-2008  matt sync with HEAD
 1.27.12.2 04-May-2009  yamt sync with head.
 1.27.12.1 16-May-2008  yamt sync with head.
 1.27.10.1 18-May-2008  yamt sync with head.
 1.27.8.4 10-Jan-2009  christos merge diffs
 1.27.8.3 30-Dec-2008  christos it is suseconds_t we want
 1.27.8.2 01-Nov-2008  christos Sync with head.
 1.27.8.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.27.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.27.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.30.28.1 18-May-2014  rmind sync with head
 1.30.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.14.1 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.33.10.1 02-Aug-2025  perseant Sync with HEAD
 1.4 20-May-2014  njoly Fix signed vs. unsigned comparison in getgroups16() syscall. Negative
gisetsize values now fail with EINVAL as expected.
 1.3 20-May-2008  njoly branches: 1.3.42; 1.3.58;
Fix linux_sys_getres{uid,gid}16 arguments type in comment.
 1.2 28-Apr-2008  martin branches: 1.2.2;
Remove clause 3 and 4 from TNF licenses
 1.1 15-Jan-2008  njoly branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12; 1.1.14; 1.1.16; 1.1.18;
compat linux (and linux32) uid16 functions cleanup and fixes.

- Move uid16 functions to their own file linux_uid16.c, included by
needed archs (arm, i386 and m68k).
- Add new MI types linux_{u,g}id16_t.
- Add macros to handle linux_uid16_t and uid_t conversions.
- Add linux_sys_getres{uid,gid}16 syscalls, to fix an overflow with
bad sizes given to copyout when linux_sys_getres{uid,gid} are used.
- Update arm syscall table to use more uid16 functions.
 1.1.18.2 04-May-2009  yamt sync with head.
 1.1.18.1 16-May-2008  yamt sync with head.
 1.1.16.2 04-Jun-2008  yamt sync with head
 1.1.16.1 18-May-2008  yamt sync with head.
 1.1.14.2 23-Mar-2008  matt sync with HEAD
 1.1.14.1 15-Jan-2008  matt file linux_uid16.c was added on branch matt-armv6 on 2008-03-23 02:04:33 +0000
 1.1.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.6.1 15-Jan-2008  mjf file linux_uid16.c was added on branch mjf-devfs on 2008-02-18 21:05:27 +0000
 1.1.4.2 21-Jan-2008  yamt sync with head
 1.1.4.1 15-Jan-2008  yamt file linux_uid16.c was added on branch yamt-lazymbuf on 2008-01-21 09:41:31 +0000
 1.1.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 15-Jan-2008  bouyer file linux_uid16.c was added on branch bouyer-xeni386 on 2008-01-19 12:14:58 +0000
 1.2.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.3.58.1 10-Aug-2014  tls Rebase.
 1.3.42.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.32 30-Oct-2014  maxv Reject non-regular files.

Patch from njoly@.
 1.31 19-Oct-2014  maxv Resource leak.

Found by my code scanner.

Tested by njoly@; ok njoly@ rmind@ on tech-kern@.
 1.30 28-Aug-2009  dholland branches: 1.30.22; 1.30.38;
Another one that needs <sys/exec_aout.h>.
 1.29 15-Aug-2009  matt Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for you.
 1.28 29-Jun-2009  dholland Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.27 28-Apr-2008  martin branches: 1.27.2; 1.27.14;
Remove clause 3 and 4 from TNF licenses
 1.26 20-Dec-2007  dsl branches: 1.26.6; 1.26.8; 1.26.10;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.25 08-Dec-2007  pooka branches: 1.25.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.24 19-Oct-2007  njoly branches: 1.24.4;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.
 1.23 19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.22 30-Apr-2007  dsl branches: 1.22.6; 1.22.8; 1.22.12;
Remove some unused calls to stackgap_init()
 1.21 22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.20 04-Mar-2007  christos branches: 1.20.2; 1.20.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 09-Feb-2007  ad branches: 1.19.2;
Merge newlock2 to head.
 1.18 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.17 12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16 23-Jul-2006  ad branches: 1.16.4; 1.16.6;
Use the LWP cached credentials where sane.
 1.15 14-May-2006  elad integrate kauth.
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
merge ktrace-lwp.
 1.13 17-Sep-2004  skrll branches: 1.13.12;
There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.12 29-Jun-2003  fvdl branches: 1.12.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.11 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.10 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 06-Jan-2003  wiz writable, not writeable.
 1.7 05-Oct-2002  chs count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.6 16-Mar-2002  christos branches: 1.6.6;
make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.5 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.4 30-Oct-2001  thorpej - Add a new vnode flag VEXECMAP, which indicates that a vnode has
executable mappings. Stop overloading VTEXT for this purpose (VTEXT
also has another meaning).
- Rename vn_marktext() to vn_markexec(), and use it when executable
mappings of a vnode are established.
- In places where we want to set VTEXT, set it in v_flag directly, rather
than making a function call to do this (it no longer makes sense to
use a function call, since we no longer overload VTEXT with VEXECMAP's
meaning).

VEXECMAP suggested by Chuq Silvers.
 1.3 22-Jul-2001  wiz branches: 1.3.4;
seperate -> separate
 1.2 12-Dec-2000  jdolecek branches: 1.2.2; 1.2.4;
define EXEC_AOUT (if not defined) before including linux_syscallargs.h,
to get linux_sys_uselib() prototype
 1.1 01-Dec-2000  jdolecek branches: 1.1.2;
put linux_sys_uselib() to separate file linux_uselib.c
 1.1.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.1.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.1.2.1 01-Dec-2000  bouyer file linux_uselib.c was added on branch thorpej_scsipi on 2000-12-08 09:08:31 +0000
 1.2.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.1 03-Aug-2001  lukem update to -current
 1.2.2.7 07-Jan-2003  thorpej Sync with HEAD.
 1.2.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.2.2.1 05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.3.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.6.6.1 02-Oct-2003  tron Pull up revision 1.7 (requested by junyoung in ticket #1488):
count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.13.12.6 21-Jan-2008  yamt sync with head
 1.13.12.5 27-Oct-2007  yamt sync with head.
 1.13.12.4 03-Sep-2007  yamt sync with head.
 1.13.12.3 26-Feb-2007  yamt sync with head.
 1.13.12.2 30-Dec-2006  yamt sync with head.
 1.13.12.1 21-Jun-2006  yamt sync with head.
 1.14.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.14.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.14.8.2 11-Aug-2006  yamt sync with head
 1.14.8.1 24-May-2006  yamt sync with head.
 1.14.6.1 01-Jun-2006  kardel Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.16.6.2 10-Dec-2006  yamt sync with head.
 1.16.6.1 22-Oct-2006  yamt sync with head
 1.16.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.16.4.1 18-Nov-2006  ad Sync with head.
 1.19.2.2 07-May-2007  yamt sync with head.
 1.19.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.4.1 11-Jul-2007  mjf Sync with head.
 1.20.2.2 23-Oct-2007  ad Sync with head.
 1.20.2.1 27-May-2007  ad Sync with head.
 1.22.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.8.2 09-Jan-2008  matt sync with HEAD
 1.22.8.1 06-Nov-2007  matt sync with HEAD
 1.22.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.22.6.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.24.4.1 26-Dec-2007  ad Sync with head.
 1.25.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.26.10.4 16-Sep-2009  yamt sync with head
 1.26.10.3 19-Aug-2009  yamt sync with head.
 1.26.10.2 18-Jul-2009  yamt sync with head.
 1.26.10.1 16-May-2008  yamt sync with head.
 1.26.8.1 18-May-2008  yamt sync with head.
 1.26.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.14.1 23-Jul-2009  jym Sync with HEAD.
 1.27.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.27.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.30.38.2 17-Jan-2015  martin Pull up following revision(s) (requested by maxv in ticket #427):
sys/compat/svr4/svr4_schedctl.c: revision 1.8
sys/netinet/tcp_timer.c: revision 1.88
sys/miscfs/genfs/layer_vfsops.c: revision 1.45
sys/compat/svr4/svr4_ioctl.c: revision 1.37
sys/ufs/chfs/chfs_vfsops.c: revision 1.14
sys/miscfs/fdesc/fdesc_vfsops.c: revision 1.91
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.30
sys/compat/common/kern_time_50.c: revision 1.28
sys/netinet6/ip6_forward.c: revision 1.74
sys/miscfs/umapfs/umap_vnops.c: revision 1.57
sys/compat/svr4/svr4_fcntl.c: revision 1.74
distrib/sets/lists/comp/mi: revision 1.1931
sys/netinet6/udp6_output.c: revision 1.46
sys/fs/puffs/puffs_compat.c: revision 1.3
sys/fs/udf/udf_rename.c: revision 1.11
sys/compat/svr4/svr4_filio.c: revision 1.24
sys/fs/udf/udf_rename.c: revision 1.12
sys/netinet/tcp_usrreq.c: revision 1.202
sys/miscfs/umapfs/umap_subr.c: revision 1.29
sys/compat/linux/common/linux_fadvise64.c: revision 1.3
sys/netinet/if_atm.c: revision 1.34
sys/miscfs/procfs/procfs_subr.c: revision 1.106
sys/miscfs/genfs/layer_subr.c: revision 1.37
sys/netinet/tcp_sack.c: revision 1.30
sys/compat/freebsd/freebsd_misc.c: revision 1.33
sys/compat/freebsd/freebsd_file.c: revision 1.33
sys/ufs/chfs/chfs_vnode.c: revision 1.12
sys/compat/svr4/svr4_ttold.c: revision 1.34
sys/compat/linux/common/linux_file.c: revision 1.114
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.43
sys/compat/linux/common/linux_signal.c: revision 1.76
sys/compat/common/compat_util.c: revision 1.46
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.18
sys/compat/svr4/svr4_sockio.c: revision 1.36
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.32
sys/compat/svr4/svr4_signal.c: revision 1.66
sys/kern/kern_exec.c: revision 1.410
sys/fs/puffs/puffs_vfsops.c: revision 1.115
sys/compat/svr4/svr4_exec_elf64.c: revision 1.15
sys/compat/linux/arch/i386/linux_machdep.c: revision 1.159
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.50
sys/compat/linux32/common/linux32_misc.c: revision 1.24
sys/netinet/in_pcb.c: revision 1.153
sys/sys/malloc.h: revision 1.116
sys/compat/common/if_43.c: revision 1.9
share/man/man9/Makefile: revision 1.380
sys/netinet/tcp_vtw.c: revision 1.12
sys/miscfs/umapfs/umap_vfsops.c: revision 1.95
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.186
sys/compat/common/uipc_syscalls_43.c: revision 1.46
sys/ufs/ext2fs/ext2fs_vnops.c: revision 1.115
sys/fs/puffs/puffs_msgif.c: revision 1.97
sys/compat/svr4/svr4_ipc.c: revision 1.27
sys/compat/linux/common/linux_exec.c: revision 1.117
sys/ufs/ext2fs/ext2fs_readwrite.c: revision 1.66
sys/netinet/tcp_output.c: revision 1.179
sys/compat/svr4/svr4_termios.c: revision 1.28
sys/fs/udf/udf_strat_bootstrap.c: revision 1.4
sys/fs/puffs/puffs_subr.c: revision 1.67
sys/fs/puffs/puffs_node.c: revision 1.36
sys/miscfs/overlay/overlay_vnops.c: revision 1.21
sys/fs/cd9660/cd9660_node.c: revision 1.34
sys/netinet/raw_ip.c: revision 1.146
sys/sys/mallocvar.h: revision 1.13
sys/miscfs/overlay/overlay_vfsops.c: revision 1.63
share/man/man9/malloc.9: revision 1.50
sys/netinet6/dest6.c: revision 1.18
sys/compat/linux/common/linux_uselib.c: revision 1.33
sys/compat/linux/common/linux_socket.c: revision 1.120
share/man/man9/malloc.9: revision 1.51
sys/netinet/tcp_subr.c: revision 1.257
sys/compat/linux/common/linux_socketcall.c: revision 1.45
sys/compat/linux/common/linux_fadvise64_64.c: revision 1.3
sys/compat/freebsd/freebsd_ipc.c: revision 1.17
sys/compat/linux/common/linux_misc_notalpha.c: revision 1.109
sys/compat/linux/arch/alpha/linux_pipe.c: revision 1.17
sys/netinet6/in6_pcb.c: revision 1.132
sys/netinet6/in6_ifattach.c: revision 1.94
sys/compat/svr4/svr4_exec_elf32.c: revision 1.15
sys/miscfs/nullfs/null_vfsops.c: revision 1.90
sys/fs/cd9660/cd9660_util.c: revision 1.12
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.48
sys/compat/freebsd/freebsd_exec_elf32.c: revision 1.20
sys/miscfs/procfs/procfs_vfsops.c: revision 1.94
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.28
sys/compat/linux/common/linux_sched.c: revision 1.67
sys/compat/linux/common/linux_exec_aout.c: revision 1.67
sys/compat/linux/common/linux_pipe.c: revision 1.67
sys/compat/linux/common/linux_llseek.c: revision 1.34
sys/compat/linux/arch/mips/linux_ptrace.c: revision 1.10
Do not uselessly include <sys/malloc.h>.
Cleanup:
- remove struct kmembuckets (dead)
- correctly deadify MALLOC_XX
- remove MALLOC_DEFINE_LIMIT and MALLOC_JUSTDEFINE_LIMIT (dead)
- remove malloc_roundup(), malloc_type_setlimit(), MALLOC_DEFINE_LIMIT()
and MALLOC_JUSTDEFINE_LIMIT() from man 9 malloc
New sentence, new line. Bump date for previous.
Obsolete malloc_roundup(9), malloc_type_setlimit(9) and MALLOC_DEFINE_LIMIT(9)
man pages.
 1.30.38.1 29-Dec-2014  martin Pull up following revision(s) (requested by maxv in ticket #353):
sys/ufs/chfs/chfs_vfsops.c: revision 1.12
sys/compat/common/vfs_syscalls_30.c: revision 1.35
sys/compat/linux/common/linux_uselib.c: revision 1.31
sys/compat/linux/common/linux_uselib.c: revision 1.32
Resource leak.
Memory leaks.
Reject non-regular files.
 1.30.22.1 03-Dec-2017  jdolecek update from HEAD
 1.11 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10 01-Dec-2000  jdolecek branches: 1.10.122; 1.10.124; 1.10.126;
add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.9 04-Oct-1998  fvdl branches: 1.9.12;
Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.
 1.8 03-Oct-1998  christos Attempt to fix the mess.
 1.7 01-Oct-1998  erh Move compat/linux/linux_util.h to common.
 1.6 05-Sep-1998  christos Assign copyright to TNF.
 1.5 24-Jun-1995  christos Use compat_util.[ch].
 1.4 22-Jun-1995  fvdl * Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)
 1.3 07-Apr-1995  fvdl Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.
 1.2 05-Mar-1995  fvdl Added a few more system calls.
More consistent alternate root file semantics throughout.
 1.1 28-Feb-1995  fvdl Added Linux compat code.
 1.9.12.1 08-Dec-2000  bouyer Sync with HEAD.
 1.10.126.1 16-May-2008  yamt sync with head.
 1.10.124.1 18-May-2008  yamt sync with head.
 1.10.122.1 02-Jun-2008  mjf Sync with HEAD.

RSS XML Feed