Home | History | Annotate | only in /src/sys/compat/linux32
History log of /src/sys/compat/linux32
RevisionDateAuthorComments
 1.1 16-Jan-2017  christos branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18;
Descend
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 16-Jan-2017  jdolecek file Makefile was added on branch tls-maxphys on 2017-12-03 11:36:55 +0000
 1.1.8.2 21-Apr-2017  bouyer Sync with HEAD
 1.1.8.1 16-Jan-2017  bouyer file Makefile was added on branch bouyer-socketcan on 2017-04-21 16:53:42 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 16-Jan-2017  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-03-20 06:57:25 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 16-Jan-2017  skrll file Makefile was added on branch nick-nhusb on 2017-02-05 13:40:25 +0000
 1.4 16-Jan-2017  christos Descend
 1.3 14-Jan-2014  christos branches: 1.3.6; 1.3.10; 1.3.14;
use new bsd.syscall.mk
 1.2 23-Mar-2007  njoly branches: 1.2.70; 1.2.80; 1.2.86;
Fix generated file names from makesyscalls.sh (s/linux/linux32/).
From Edgar Fu� in PR/35956.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.26; 1.1.28; 1.1.32; 1.1.34; 1.1.36;
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.36.1 29-Mar-2007  reinoud Pullup to -current
 1.1.34.1 11-Jul-2007  mjf Sync with head.
 1.1.32.1 10-Apr-2007  ad Sync with head.
 1.1.28.1 24-Mar-2007  yamt sync with head.
 1.1.26.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #543):
sys/compat/linux32/Makefile.inc: revision 1.2
Fix generated file names from makesyscalls.sh (s/linux/linux32/).
From Edgar Fu� in PR/35956.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file Makefile.inc was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.3 03-Sep-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 Makefile.inc was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file Makefile.inc was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file Makefile.inc was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.86.1 18-May-2014  rmind sync with head
 1.2.80.2 03-Dec-2017  jdolecek update from HEAD
 1.2.80.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.70.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.3.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.3.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3.6.1 05-Feb-2017  skrll Sync with HEAD
 1.7 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.6 17-Nov-2014  uebayasi branches: 1.6.18; 1.6.20;
Define compat modules (but without dependencies yet).
 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 11-Apr-2007  njoly branches: 1.4.30; 1.4.34; 1.4.40; 1.4.44;
- 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.3 13-Sep-2006  manu branches: 1.3.4; 1.3.6; 1.3.10; 1.3.12;
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.2 15-Feb-2006  manu branches: 1.2.2; 1.2.4; 1.2.10; 1.2.16; 1.2.20; 1.2.22;
- 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.1 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.2.22.2 09-Sep-2006  rpaulo sync with head
 1.2.22.1 15-Feb-2006  rpaulo file files.linux32 was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.2.20.1 18-Nov-2006  ad Sync with head.
 1.2.16.4 03-Sep-2007  yamt sync with head.
 1.2.16.3 30-Dec-2006  yamt sync with head.
 1.2.16.2 21-Jun-2006  yamt sync with head.
 1.2.16.1 15-Feb-2006  yamt file files.linux32 was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.2.10.2 22-Apr-2006  simonb Sync with head.
 1.2.10.1 15-Feb-2006  simonb file files.linux32 was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.2.4.1 14-Sep-2006  yamt sync with head.
 1.2.2.2 18-Feb-2006  yamt sync with head.
 1.2.2.1 15-Feb-2006  yamt file files.linux32 was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.3.12.1 11-Jul-2007  mjf Sync with head.
 1.3.10.1 27-May-2007  ad Sync with head.
 1.3.6.1 15-Apr-2007  yamt sync with head.
 1.3.4.1 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.4.44.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.40.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.34.1 04-May-2009  yamt sync with head.
 1.4.30.1 17-Jan-2009  mjf Sync with HEAD.
 1.5.26.1 03-Dec-2017  jdolecek update from HEAD
 1.6.20.1 10-Jun-2019  christos Sync with HEAD
 1.6.18.1 12-Mar-2018  pgoyette Update dependencies for modules when they are built-in. Now we don't
(or at least, shouldn't) need reminders in the GENERIC config files
about which module options require other options.

Update branch status doc accordingly.
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_syscall.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_syscall.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_syscall.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_syscall.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_syscallargs.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_syscallargs.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_syscallargs.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_syscallargs.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_syscalls.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_syscalls.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_syscalls.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_syscalls.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 07-Mar-2015  christos branches: 1.1.2; 1.1.18;
centralize arguments functions
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 07-Mar-2015  jdolecek file linux32_systrace_args.c was added on branch tls-maxphys on 2017-12-03 11:36:55 +0000
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 07-Mar-2015  skrll file linux32_systrace_args.c was added on branch nick-nhusb on 2015-04-06 15:18:06 +0000
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 16-Jan-2017  christos branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18;
descend and regen
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 16-Jan-2017  jdolecek file Makefile was added on branch tls-maxphys on 2017-12-03 11:36:55 +0000
 1.1.8.2 21-Apr-2017  bouyer Sync with HEAD
 1.1.8.1 16-Jan-2017  bouyer file Makefile was added on branch bouyer-socketcan on 2017-04-21 16:53:42 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 16-Jan-2017  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-03-20 06:57:25 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 16-Jan-2017  skrll file Makefile was added on branch nick-nhusb on 2017-02-05 13:40:25 +0000
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.2 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.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.2 09-Apr-2023  riastradh compat_linux32: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.2 03-Dec-2021  ryo Fixed a bug in sigreturn that sigmask was not restored.
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.2 07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 02-Dec-2021  ryo regen
 1.2 27-Nov-2021  ryo regen
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 02-Dec-2021  ryo regen
 1.2 27-Nov-2021  ryo regen
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 02-Dec-2021  ryo regen
 1.2 27-Nov-2021  ryo regen
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 02-Dec-2021  ryo regen
 1.2 27-Nov-2021  ryo regen
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 02-Dec-2021  ryo regen
 1.2 27-Nov-2021  ryo regen
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 02-Dec-2021  ryo add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32
 1.2 27-Nov-2021  ryo Add pselect6(2) system call to COMPAT_LINUX32
 1.1 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.2 04-May-2014  njoly Remove now unneeded bsd.kinc.mk.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.112; 1.1.122; 1.1.128; 1.1.138;
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.138.1 10-Aug-2014  tls Rebase.
 1.1.128.1 18-May-2014  rmind sync with head
 1.1.122.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.112.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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file Makefile was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file Makefile was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file Makefile was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file Makefile was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.3 20-May-2008  njoly Add compat linux32 ipc(2) syscall support, for shared memory and
semaphores.
 1.2 15-Jan-2008  njoly branches: 1.2.6; 1.2.8; 1.2.10; 1.2.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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.48; 1.1.54; 1.1.62;
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.62.1 19-Jan-2008  bouyer Sync with HEAD
 1.1.54.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.48.1 23-Mar-2008  matt sync with HEAD
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file files.linux32_amd64 was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.3 21-Jan-2008  yamt sync with head
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file files.linux32_amd64 was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file files.linux32_amd64 was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file files.linux32_amd64 was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.2.10.1 04-May-2009  yamt sync with head.
 1.2.8.1 04-Jun-2008  yamt sync with head
 1.2.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_errno.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_errno.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_errno.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_errno.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.10 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.9 25-Nov-2021  ryo Extra arguments for AT_HWCAP and AT_PLATFORM are now passed when executing linux32 binaries.

AT_SYSINFO (vsyscall) feature seems to be broken, so leave it commented out.
 1.8 25-Nov-2021  ryo The default name of the `exec_setup_stack' function for linux32 should be `linux32_exec_setup_stack',
and it should be defined in each arch.
declaration of linux32_exec_setup_stack() in linux32/amd64 has been removed because it does not exist.

NFC.
 1.7 26-Apr-2017  christos catch up with unit fixes for es_arglen; consistently use bytes.
 1.6 21-Feb-2014  maxv branches: 1.6.6; 1.6.20;
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.5 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.4 07-Jul-2010  chs branches: 1.4.8; 1.4.18; 1.4.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.3 18-Apr-2010  jym This patch fixes the NX regression issue observed on amd64 kernels, where
per-page execution right was disabled (therefore leading to the inability
of the kernel to detect fraudulent use of memory mappings marked as not
being executable).

- replace cpu_feature and ci_feature_flags variables by cpu_feature and
ci_feat_val arrays. This makes it cleaner and brings kernel code closer
to the design of cpuctl(8). A warning will be raised for each CPU that
does not expose the same features as the Boot Processor (BP).

- the blacklist of CPU features is now a macro defined in the
specialreg.h header, instead of hardcoding it inside MD initialization
code; fix comments.

- replace checks against CPUID_TSC with the cpu_hascounter() function.

- clean up the code in init_x86_64(), as cpu_feature variables are set
inside cpu_probe().

- use cpu_init_msrs() for i386. It will be eventually used later for NX
feature under i386 PAE kernels.

- remove code that checks for CPUID_NOX in amd64 mptramp.S, this is already
performed by cpu_hatch() through cpu_init_msrs().

- remove cpu_signature and feature_flags members from struct mpbios_proc
(they were never used).

This patch was tested with i386 MONOLITHIC, XEN3PAE_DOM0 and XEN3_DOM0 under
a native i386 host, and amd64 GENERIC, XEN3_DOM0 via QEMU virtual machines.

XXX Should kernel rev be bumped?

XXX A similar patch should be pulled-up for NetBSD-5, hopefully tomorrow.
 1.2 07-Aug-2006  manu branches: 1.2.6; 1.2.60; 1.2.82; 1.2.84;
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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16;
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.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_exec.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_exec.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 11-Aug-2006  yamt sync with head
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_exec.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.84.2 05-Mar-2011  rmind sync with head
 1.2.84.1 30-May-2010  rmind sync with head
 1.2.82.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.82.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.60.1 11-Aug-2010  yamt sync with head.
 1.2.6.2 09-Sep-2006  rpaulo sync with head
 1.2.6.1 07-Aug-2006  rpaulo file linux32_exec.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.4.22.1 18-May-2014  rmind sync with head
 1.4.18.2 03-Dec-2017  jdolecek update from HEAD
 1.4.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.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.6.20.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.6.6.1 28-Aug-2017  skrll Sync with HEAD
 1.1 25-Nov-2021  ryo - Use LINUX32_F_xxx instead of LINUX_F_xxx for compat_linux32.
aarch64 and arm have different values.
- Compile linux32_sys_fadvise64() only if the syscall is required.
 1.1 15-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
- 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.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 15-Feb-2006  rpaulo file linux32_ioctl.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 15-Feb-2006  yamt file linux32_ioctl.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 15-Feb-2006  simonb file linux32_ioctl.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 15-Feb-2006  yamt file linux32_ioctl.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.48 20-Jun-2023  riastradh linux32_rt_sendsig: Memset zero before copyout.

Not sure if there's any padding here, but it's a pretty big
structure, fairly likely, so let's be rather safe than sorry.

XXX pullup-8
XXX pullup-9
XXX pullup-10
 1.47 01-Nov-2021  thorpej branches: 1.47.4;
Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.46 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.45 19-May-2019  maxv branches: 1.45.2;
Rename

fpu_save_area_clear -> fpu_clear
fpu_save_area_reset -> fpu_sigreset

Clearer, and reduces a future diff. No real functional change.
 1.44 24-Mar-2019  maxv Disable preemption when setting PCB_COMPAT32, to prevent a context switch
before cpu_fsgs_reload() finishes, otherwise we write garbage in the GDT.
On NetBSD-current it is harmless, however in NetBSD-8 it might cause
panics, because NetBSD-8 uses the old SegRegs model and under this model
we reload %fs and %gs during switches.
 1.43 21-Oct-2017  maxv branches: 1.43.4;
Include opt_user_ldt.h when needed.
 1.42 19-Oct-2017  maxv Always mask the 16 bits of the segregs in the trapframe. We don't zero-
extend the uint64_t's when building it, so we're leaking 48 bits of kernel
stack to userland.

Having said that, it appears that I unintentionally fixed most of this
issue in locore.S::rev1.127 - by building the frame with interrupts
disabled, we are implicitly guaranteeing that the structure doesn't get
overwritten by the kernel. Which means, we are leaking to userland data
that comes from userland anyway.

(still other places with this issue, but I'll fix them differently)
 1.41 15-Oct-2017  maxv Use two separate functions: cpu_segregs32_zero and cpu_segregs64_zero. The
way segment registers work on amd64 will diverge between 32bit and 64bit
LWPs.
 1.40 15-Oct-2017  maxv Make sure the 32bit LWPs don't have MDL_IRET set. That's not a problem
right now, but will be in the future.
 1.39 02-Sep-2017  maxv Fix a subtle ring0 escalation vulnerability in amd64, and implement a
mitigation against similar bugs.

The operations on segment registers can generate a page fault if there is
an issue when touching the in-memory gdt. Theoretically, it is never
supposed to happen, since the gdt is mapped correctly. However, in the
kernel we allow the gdt to be resized, and to do that, we allocate the
maximum amount of va needed by it, but only kenter a few pages until we
need more. Moreover, to avoid reloading the gdt each time we grow it, the
'size' field of gdtr is set to the maximum value. All of this means that
if a mov or iretq is done with a segment register whose index hits a page
that has not been kentered, a page fault is sent.

Such a page fault, if received in kernel mode, does not trigger a swapgs
on amd64; in other words, the kernel would be re-entered with the userland
tls.

And there just happens to be a place in compat_linux32 where the index of
%cs is controlled by userland, making it easy to trigger the page fault
and get kernel privileges.

The mitigation simply consists in abandoning the gdt_grow mechanism and
allocating/kentering the maximum size right away, in such a way that no
page fault can be triggered because of segment registers.
 1.38 05-Feb-2017  maxv branches: 1.38.6;
Remove #if 0 on USER_LDT.
 1.37 02-Sep-2016  maxv branches: 1.37.2;
Fix argument (does not compile anyway).
 1.36 19-Feb-2014  dsl branches: 1.36.4; 1.36.6; 1.36.8; 1.36.10; 1.36.14;
Explicitly include x86/fpu.h instead of relying in x86/frame.h including it.
 1.35 15-Feb-2014  dsl Remove all references to MDL_USEDFPU and deferred fpu initialisation.
The cost of zeroing the save area on exec is minimal.
This stops the FP registers of a random process being used the first
time an lwp uses the fpu.
sendsig_siginfo() and get_mcontext() now unconditionally copy the FP
registers.
I'll remove the double-copy for signal handlers soon.
get_mcontext() might have been leaking kernel memory to userspace - and
may still do so if i386_use_fxsave is false (short copies).
 1.34 07-Feb-2014  dsl Convert the amd64 build to use x86/cpu_extended_state.h so that the fpu
definitions match those of i386.
Mostly just structure and field renames, in addition:
1) process_xmm_to_s87() and process_s87_to_xmm() moved into
x86/convert_xmm_s87.c so they can be used by amd64's netbsd32 code.
2) The linux signal code simplified to use a structure copy for ths fxsave
data - it matches the hardware definition and won't change.
 1.33 01-Dec-2013  christos revert fpu/pcu changes until we figure out what's wrong; they cause random
freezes
 1.32 23-Oct-2013  drochner Use the MI "pcu" framework for bookkeeping of npx/fpu states on x86.
This reduces the amount of MD code enormously, and makes it easier
to implement support for newer CPU features which require more fpu
state, or for fpu usage by the kernel.
For access to FPU state across CPUs, an xcall kthread is used now
rather than a dedicated IPI.
No user visible changes intended.
 1.31 15-Jul-2012  dsl branches: 1.31.2; 1.31.4;
Rename MDP_IRET to MDL_IRET since it is an lwp flag, not a proc one.
Add an MDL_COMPAT32 flag to the lwp's md_flags, set it for 32bit lwps
and use it to force 'return to user' with iret (as is done when
MDL_IRET is set).
Split the iret/sysret code paths much later.
Remove all the replicated code for 32bit system calls - which was only
needed so that iret was always used.
frameasm.h for XEN contains '#define swapgs', while XEN probable never
needs swapgs, this is likely to be confusing.
Add a SWAPGS which is a nop on XEN and swapgs otherwise.
(I've not yet checked all the swapgs in files that include frameasm.h)
Simple x86 programs still work.
Hijack 6.99.9 kernel bump (needed for compat32 modules)
 1.30 08-Jul-2012  dsl The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.29 04-Mar-2011  joerg branches: 1.29.4; 1.29.10; 1.29.14; 1.29.16;
Refactor ps_strings access. Based on PK_32, write either the normal
version or the 32bit compat layout in execve1. Introduce a new function
copyin_psstrings for reading it back from userland and converting it to
the native layout. Refactor procfs to share most of the code with the
kern.proc_args sysctl handler.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.28 07-Feb-2011  chs move macros for validating fs/gs to segments.h and use them
in the linux32 code as well.
 1.27 02-Nov-2010  chs branches: 1.27.2; 1.27.4;
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.26 12-Jul-2010  christos fix debugging build.
 1.25 07-Jul-2010  jmmv Add missing includes to bring the linux_semun type needed by
linux_syscallargs.h.
 1.24 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.23 23-Nov-2009  rmind branches: 1.23.2; 1.23.4;
Use lwp_getpcb() in compat code, clean from struct user.
 1.22 29-May-2009  njoly Add native to linux siginfo si_status translation, used on i386 and
amd64.
 1.21 15-Mar-2009  cegger ansify function definitions
 1.20 19-Oct-2008  njoly branches: 1.20.2; 1.20.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.19 09-Oct-2008  njoly Fix linux32 siginfo si_signo value. Do not convert ksi_signo twice.
 1.18 18-Sep-2008  christos Define a PSL_CLEARSIG macro for the psl flags to be cleared on signal delivery
and use it everywhere.
 1.17 24-Apr-2008  ad branches: 1.17.2; 1.17.4; 1.17.8;
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.16 20-Dec-2007  dsl branches: 1.16.6; 1.16.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.15 08-Dec-2007  dsl branches: 1.15.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.14 04-Dec-2007  dsl Remove all the __P
 1.13 24-Nov-2007  christos branches: 1.13.2;
- move the save context before the signal reset (Arto Huusko)
- set the sigcontext cr2
 1.12 19-Oct-2007  ad branches: 1.12.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.11 21-May-2007  christos branches: 1.11.6; 1.11.8; 1.11.12;
rename si_sigval -> si_value to match POSIX RTS.
 1.10 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.9 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.8 05-Mar-2007  christos branches: 1.8.2; 1.8.4; 1.8.6;
fix caddr_t lossage
 1.7 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.6 17-Feb-2007  pavel Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
 1.5 15-Feb-2007  ad branches: 1.5.2;
Fix COMPAT_LINUX32.
 1.4 09-Feb-2007  ad Merge newlock2 to head.
 1.3 22-Nov-2006  christos adjust_limits takes p, not l again
 1.2 21-Nov-2006  christos From Nicolas Joly:

> It seems that 32bits programs, running under compat_netbsd32, using
> setrlimit force all other programs to have their maximum data size
> fixed at 3GB, where native 64bits apps used 8GB previously.

I tracked this one to the `netbsd32_adjust_limits()' function (called
when creating a new process under compat_netbsd32), where data and
stack limits are set without checking for shared `p_limit' structure
(p_limit->p_refcnt > 1). This explain the side effect where processes
have their limits changed when a compat_netbsd32 (or compat_linux32)
program is run.

The fix is to use `dosetrlimit()' to ensure the needed copy-on-write
behaviour for shared structure.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22; 1.1.24;
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.24.1 10-Dec-2006  yamt sync with head.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_machdep.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.20.3 06-Feb-2007  ad More compat changes.

XXX compat_irix, compat_mach and compat_darwin need work.
 1.1.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.20.1 12-Jan-2007  ad Sync with head.
 1.1.16.8 21-Jan-2008  yamt sync with head
 1.1.16.7 07-Dec-2007  yamt sync with head
 1.1.16.6 27-Oct-2007  yamt sync with head.
 1.1.16.5 03-Sep-2007  yamt sync with head.
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_machdep.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_machdep.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_machdep.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.5.2.3 24-Mar-2007  yamt sync with head.
 1.5.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.5.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.8.6.2 29-Mar-2007  reinoud Pullup to -current
 1.8.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.8.4.1 11-Jul-2007  mjf Sync with head.
 1.8.2.3 23-Oct-2007  ad Sync with head.
 1.8.2.2 27-May-2007  ad Sync with head.
 1.8.2.1 10-Apr-2007  ad Sync with head.
 1.11.12.1 25-Oct-2007  bouyer Sync with HEAD.
 1.11.8.2 09-Jan-2008  matt sync with HEAD
 1.11.8.1 06-Nov-2007  matt sync with HEAD
 1.11.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.11.6.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.11.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.12.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.12.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.2.2 26-Dec-2007  ad Sync with head.
 1.13.2.1 08-Dec-2007  ad Sync with head.
 1.15.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.16.8.1 18-May-2008  yamt sync with head.
 1.16.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.16.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.16.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.8.1 19-Oct-2008  haad Sync with HEAD.
 1.17.4.4 10-Oct-2008  skrll Sync with HEAD.
 1.17.4.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.17.4.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.4.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.2.4 11-Aug-2010  yamt sync with head.
 1.17.2.3 11-Mar-2010  yamt sync with head
 1.17.2.2 20-Jun-2009  yamt sync with head
 1.17.2.1 04-May-2009  yamt sync with head.
 1.20.8.2 23-Jul-2009  jym Sync with HEAD.
 1.20.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.23.4.1 05-Mar-2011  rmind sync with head
 1.23.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.23.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.27.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.27.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.16.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #1502):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.29.14.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #1502):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.29.10.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #1502):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.29.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.29.4.1 30-Oct-2012  yamt sync with head
 1.31.4.1 18-May-2014  rmind sync with head
 1.31.2.2 03-Dec-2017  jdolecek update from HEAD
 1.31.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.14.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #1507):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.36.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.36.8.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #1507):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.36.6.2 28-Aug-2017  skrll Sync with HEAD
 1.36.6.1 05-Oct-2016  skrll Sync with HEAD
 1.36.4.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #1507):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.37.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.38.6.4 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1841):

sys/compat/sunos32/sunos32_misc.c: revision 1.86
sys/compat/ossaudio/ossaudio.c: revision 1.85
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.48

compat_sunos32: Memset zero before copyout.

Unclear if this can leak anything but let's be on the safe side.

compat_ossaudio: Zero-initialize idat before copyout.
Unclear if there are any paths to the copyout without initialization,
but let's play it safe to keep the auditing effort low.

linux32_rt_sendsig: Memset zero before copyout.
Not sure if there's any padding here, but it's a pretty big
structure, fairly likely, so let's be rather safe than sorry.
 1.38.6.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.38.6.2 05-Apr-2019  martin Pull up following revision(s) (requested by maxv):

sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.120
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.57
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.44
sys/arch/amd64/amd64/machdep.c: revision 1.328
sys/arch/amd64/amd64/machdep.c: revision 1.329

Fix a tiny race in setregs and linux_setregs. Between the moment we set
pcb_flags to zero, and the moment cpu_segregs64_zero resets pcb_gs, we may
be preempted.

If this happens, and if the calling LWP was a 32bit thread, when switching
back to that LWP, the context switcher sees that PCB_COMPAT32 is not set in
pcb_flags and tries to perform a 64bit context switch; but pcb_gs contains
a 32bit GDT descriptor, and not a 64bit GS.base value. The wrmsr therefore
faults because the value is non-canonical, and this fault is fatal.

Rearrange the code so that the update of pcb_flags and pcb_gs/pcb_fs is non
interruptible. This fixes the problem, tested with a reproducer (which
therefore doesn't work anymore).

Likely fixes PR/53993.

Disable preemption when setting PCB_COMPAT32, to prevent a context switch
before cpu_fsgs_reload() finishes, otherwise we write garbage in the GDT.

On NetBSD-current it is harmless, however in NetBSD-8 it might cause
panics, because NetBSD-8 uses the old SegRegs model and under this model
we reload %fs and %gs during switches.
 1.38.6.1 09-Sep-2017  snj Pull up following revision(s) (requested by maxv in ticket #270):
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39
Fix a ring0 escalation vulnerability in compat_linux32 where the
index of %cs is controlled by userland, making it easy to trigger
the page fault and get kernel privileges.
 1.43.4.1 10-Jun-2019  christos Sync with HEAD
 1.45.2.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1650):

sys/compat/sunos32/sunos32_misc.c: revision 1.86
sys/compat/ossaudio/ossaudio.c: revision 1.85
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.48

compat_sunos32: Memset zero before copyout.

Unclear if this can leak anything but let's be on the safe side.

compat_ossaudio: Zero-initialize idat before copyout.
Unclear if there are any paths to the copyout without initialization,
but let's play it safe to keep the auditing effort low.

linux32_rt_sendsig: Memset zero before copyout.
Not sure if there's any padding here, but it's a pretty big
structure, fairly likely, so let's be rather safe than sorry.
 1.45.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.47.4.1 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #204):

sys/compat/sunos32/sunos32_misc.c: revision 1.86
sys/compat/ossaudio/ossaudio.c: revision 1.85
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.48

compat_sunos32: Memset zero before copyout.

Unclear if this can leak anything but let's be on the safe side.

compat_ossaudio: Zero-initialize idat before copyout.
Unclear if there are any paths to the copyout without initialization,
but let's play it safe to keep the auditing effort low.

linux32_rt_sendsig: Memset zero before copyout.
Not sure if there's any padding here, but it's a pretty big
structure, fairly likely, so let's be rather safe than sorry.
 1.2 04-Dec-2007  dsl 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 linux32_machdep.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 linux32_machdep.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_machdep.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_machdep.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.7 18-Nov-2013  chs implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.6 19-Nov-2008  ad branches: 1.6.16; 1.6.26; 1.6.30;
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.5 02-Feb-2008  dsl branches: 1.5.6; 1.5.10; 1.5.12; 1.5.16; 1.5.18;
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.4 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.3 19-Jul-2007  dsl branches: 1.3.6; 1.3.12; 1.3.18; 1.3.22;
include sys/cdefs.h
 1.2 09-Feb-2007  ad branches: 1.2.6; 1.2.14;
Merge newlock2 to head.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_missing.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.16.6 04-Feb-2008  yamt sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 26-Feb-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 linux32_missing.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_missing.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_missing.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.2.6.1 20-Aug-2007  ad Sync with HEAD.
 1.3.22.2 19-Jul-2007  dsl include sys/cdefs.h
 1.3.22.1 19-Jul-2007  dsl file linux32_missing.c was added on branch matt-mips64 on 2007-07-19 22:17:24 +0000
 1.3.18.1 19-Jan-2008  bouyer Sync with HEAD
 1.3.12.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.6.1 23-Mar-2008  matt sync with HEAD
 1.5.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.5.12.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.5.12.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.5.10.1 04-May-2009  yamt sync with head.
 1.5.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.6.30.1 18-May-2014  rmind sync with head
 1.6.26.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.16.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.9 08-Jun-2009  njoly Fix defines against multiple inclusion protection (s/I386/AMD64).
 1.8 16-Apr-2008  njoly branches: 1.8.4; 1.8.18;
Kill a few other unused linux syscall arguments/prototypes
definitions.
 1.7 15-Apr-2008  njoly Remove syscall prototypes forgotten in previous commit.
 1.6 15-Apr-2008  njoly Remove unused linux_sys_setresgid16_args/linux_sys_setresuid16_args
definitions.
 1.5 15-Jan-2008  njoly branches: 1.5.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.4 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.3 04-Mar-2007  christos branches: 1.3.16; 1.3.22; 1.3.24; 1.3.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 13-Sep-2006  manu branches: 1.2.6;
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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_missing.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.20.1 18-Nov-2006  ad Sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_missing.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_missing.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_missing.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.6.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.28.2 19-Jan-2008  bouyer Sync with HEAD
 1.3.28.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.24.1 26-Dec-2007  ad Sync with head.
 1.3.22.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.16.2 23-Mar-2008  matt sync with HEAD
 1.3.16.1 09-Jan-2008  matt sync with HEAD
 1.5.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.18.1 23-Jul-2009  jym Sync with HEAD.
 1.8.4.1 20-Jun-2009  yamt sync with head
 1.2 19-Sep-2021  thorpej Add routines to convert from linux32 to native sigevent_t.
 1.1 18-Nov-2011  christos branches: 1.1.8; 1.1.66;
add sigtimedwait support
 1.1.66.1 17-Dec-2020  thorpej Add sigevent mapping for Linux-32 compat.
 1.1.8.2 17-Apr-2012  yamt sync with head
 1.1.8.1 18-Nov-2011  yamt file linux32_siginfo.h was added on branch yamt-pagecache on 2012-04-17 00:07:18 +0000
 1.4 08-Mar-2015  christos fix inconsistent names
 1.3 18-Nov-2011  christos branches: 1.3.10; 1.3.28;
add sigtimedwait support
 1.2 08-Jun-2009  njoly branches: 1.2.12;
Fix defines against multiple inclusion protection (s/I386/AMD64).
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.76; 1.1.92;
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.92.1 23-Jul-2009  jym Sync with HEAD.
 1.1.76.1 20-Jun-2009  yamt sync with head
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_signal.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_signal.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_signal.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_signal.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.12.1 17-Apr-2012  yamt sync with head
 1.3.28.1 06-Apr-2015  skrll Sync with HEAD
 1.3.10.1 03-Dec-2017  jdolecek update from HEAD
 1.87 02-Dec-2021  ryo regen
 1.86 27-Nov-2021  ryo regen
 1.85 20-Sep-2021  thorpej Regen for preadv(2) / pwritev(2).
 1.84 20-Sep-2021  thorpej Regen for eventfd.
 1.83 19-Sep-2021  thorpej Regen for timerfd.
 1.82 19-Sep-2021  thorpej Regen for POSIX timer syscalls.
 1.81 26-Apr-2020  thorpej branches: 1.81.2;
Regen for native futex calls.
 1.80 09-Nov-2019  jdolecek regen
 1.79 10-Aug-2018  pgoyette Regen
 1.78 10-May-2017  riastradh branches: 1.78.8; 1.78.10;
regen
 1.77 16-Jan-2017  christos branches: 1.77.4;
descend and regen
 1.76 13-Jan-2017  christos branches: 1.76.2;
regen
 1.75 08-Mar-2015  christos branches: 1.75.2;
regen
 1.74 07-Mar-2015  christos regen
 1.73 22-Nov-2014  njoly branches: 1.73.2;
Regen for ppoll(2)
 1.72 29-May-2014  njoly Regen for utimes(2).
 1.71 04-May-2014  njoly Regen for pread/pwrite 64bit offset argument.
 1.70 18-Nov-2013  christos branches: 1.70.2;
Regen
 1.69 18-Nov-2013  chs regen
 1.68 07-Nov-2013  njoly Regen for dup/dup2/dup3 argument types fix.
 1.67 13-Jul-2012  christos branches: 1.67.2; 1.67.4;
regen
 1.66 10-May-2012  christos regen
 1.65 18-Nov-2011  christos branches: 1.65.4; 1.65.6;
regen
 1.64 18-Nov-2011  christos add sigtimedwait support
 1.63 30-May-2011  alnsn branches: 1.63.4;
Regenerate files to pick up correct RCS Ids. Suggested by Chris Badura.
 1.62 30-May-2011  alnsn Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.61 10-Apr-2011  christos Regen: XXX: produces errors because of rump changes!
 1.60 02-Nov-2010  chs branches: 1.60.2;
regen
 1.59 07-Jul-2010  chs regen
 1.58 24-Nov-2009  njoly branches: 1.58.2; 1.58.4;
Regen for personality(2) update.
 1.57 08-Jun-2009  njoly Regen for rt_queueinfo addition.
 1.56 05-Jun-2009  njoly Regen for fstatfs.
 1.55 04-Jun-2009  njoly Regen for stat/lstat/fstat syscalls.
 1.54 02-Jun-2009  njoly Regen for siggetmask/sigsetmask.
 1.53 30-Jan-2009  njoly branches: 1.53.2;
Regen for mincore(2).
 1.52 20-Jan-2009  njoly Regen for personality(2) addition.
 1.51 17-Jan-2009  njoly Regen for wait4 update.
 1.50 16-Jan-2009  njoly Regen for compat 50 update.
 1.49 13-Jan-2009  pooka Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.48 11-Jan-2009  christos merge christos-time_t
 1.47 12-Dec-2008  njoly branches: 1.47.2;
Regen for clock_nanosleep.
 1.46 06-Dec-2008  njoly Regen for netbsd32_caddr_t removal.
 1.45 05-Dec-2008  njoly Regen for getres{uid,gid} syscalls.
 1.44 01-Dec-2008  njoly Regen for sched_get_priority_{min,max}.
 1.43 19-Nov-2008  ad Regen.
 1.42 12-Nov-2008  njoly Regen for nanosleep(2) fix.
 1.41 06-Oct-2008  njoly branches: 1.41.2; 1.41.4;
Regen.
 1.40 22-Sep-2008  njoly Regen after cleanup.
 1.39 24-Jul-2008  njoly Regen for rt_sigpending.
 1.38 16-Jun-2008  christos branches: 1.38.2;
regen
 1.37 20-May-2008  njoly branches: 1.37.2;
Regen for ipc(2) syscall support.
 1.36 17-Apr-2008  njoly branches: 1.36.2; 1.36.4; 1.36.6;
Regen for sys_clock_{getres,gettime,settime} syscalls.
 1.35 04-Apr-2008  njoly Regen for msync(2) support.
 1.34 20-Feb-2008  njoly branches: 1.34.6;
Regen for mlock/munlock syscalls
 1.33 17-Feb-2008  njoly Regen for pread/pwrite fixes.
 1.32 04-Feb-2008  dsl Regen for merging fcntl() and fcntl64().
 1.31 02-Feb-2008  dsl Regen for pread and pwrite
 1.30 15-Jan-2008  njoly Regen.
 1.29 07-Jan-2008  njoly Regen.
 1.28 26-Dec-2007  njoly Regen for readdir syscall.
 1.27 24-Dec-2007  njoly Regen for old_uname syscall.
 1.26 24-Dec-2007  njoly Regen for getpgid.
 1.25 21-Dec-2007  njoly Regen for getfsuid/setfsgid syscall exchange.
 1.24 20-Dec-2007  dsl regen
 1.23 16-Nov-2007  njoly branches: 1.23.2; 1.23.6;
Regen.
 1.22 11-Nov-2007  christos regen
 1.21 07-Nov-2007  njoly Regen for 64-bit linux syscalls removal.
 1.20 31-Oct-2007  dsl branches: 1.20.2;
regen
 1.19 31-Oct-2007  njoly Regen for syscalls cleanup.
 1.18 27-Oct-2007  njoly Regen for chown additions.
 1.17 20-Apr-2007  njoly branches: 1.17.6; 1.17.8; 1.17.12;
Regen (ftruncate fix).
 1.16 11-Apr-2007  njoly Regen (statfs support).
 1.15 05-Mar-2007  christos branches: 1.15.2; 1.15.4;
fix caddr_t lossage.
 1.14 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 16-Feb-2007  njoly branches: 1.13.2;
Regen.
 1.12 08-Feb-2007  njoly Regen (aliases cleanup).
 1.11 07-Feb-2007  njoly Regen (poll argument fix).
 1.10 13-Sep-2006  manu branches: 1.10.4;
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.9 06-Sep-2006  manu branches: 1.9.2; 1.9.4;
Implement Linux's fdatasync, patch from Nicolas Joly
 1.8 06-Sep-2006  manu Fix linux32_sys_setres{uid|gid}: -1 does not means the same thing on i386
and amd64...
 1.7 05-Sep-2006  manu typo
 1.6 01-Sep-2006  matt Regen.
 1.5 25-Jun-2006  manu Regen
 1.4 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.3 15-Feb-2006  manu branches: 1.3.2; 1.3.4; 1.3.10; 1.3.14; 1.3.16;
Add getcwd (for real this time), fix dup and dup2
 1.2 15-Feb-2006  manu - 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.1 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.3.16.12 27-Feb-2008  yamt sync with head.
 1.3.16.11 11-Feb-2008  yamt sync with head.
 1.3.16.10 04-Feb-2008  yamt sync with head.
 1.3.16.9 21-Jan-2008  yamt sync with head
 1.3.16.8 07-Dec-2007  yamt sync with head
 1.3.16.7 15-Nov-2007  yamt sync with head.
 1.3.16.6 27-Oct-2007  yamt sync with head.
 1.3.16.5 03-Sep-2007  yamt sync with head.
 1.3.16.4 26-Feb-2007  yamt sync with head.
 1.3.16.3 30-Dec-2006  yamt sync with head.
 1.3.16.2 21-Jun-2006  yamt sync with head.
 1.3.16.1 15-Feb-2006  yamt file linux32_syscall.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.3.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.10.2 22-Apr-2006  simonb Sync with head.
 1.3.10.1 15-Feb-2006  simonb file linux32_syscall.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.3.4.2 14-Sep-2006  yamt sync with head.
 1.3.4.1 26-Jun-2006  yamt sync with head.
 1.3.2.2 18-Feb-2006  yamt sync with head.
 1.3.2.1 15-Feb-2006  yamt file linux32_syscall.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.9.4.2 09-Sep-2006  rpaulo sync with head
 1.9.4.1 06-Sep-2006  rpaulo file linux32_syscall.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.9.2.2 09-Feb-2007  ad Sync with HEAD.
 1.9.2.1 18-Nov-2006  ad Sync with head.
 1.10.4.2 20-Apr-2007  bouyer regen for ticket #582
 1.10.4.1 02-Apr-2007  bouyer Regen for ticket #544
 1.13.2.3 07-May-2007  yamt sync with head.
 1.13.2.2 15-Apr-2007  yamt sync with head.
 1.13.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 27-May-2007  ad Sync with head.
 1.17.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.17.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.17.8.4 23-Mar-2008  matt sync with HEAD
 1.17.8.3 09-Jan-2008  matt sync with HEAD
 1.17.8.2 08-Nov-2007  matt sync with -HEAD
 1.17.8.1 06-Nov-2007  matt sync with HEAD
 1.17.6.6 21-Nov-2007  joerg Sync with HEAD.
 1.17.6.5 14-Nov-2007  joerg Sync with HEAD.
 1.17.6.4 11-Nov-2007  joerg Sync with HEAD.
 1.17.6.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.17.6.2 31-Oct-2007  joerg Sync with HEAD.
 1.17.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.20.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.20.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.23.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.23.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.23.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.2.1 26-Dec-2007  ad Sync with head.
 1.34.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.34.6.3 28-Sep-2008  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.36.6.3 10-Oct-2008  skrll Sync with HEAD.
 1.36.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.36.4.4 11-Aug-2010  yamt sync with head.
 1.36.4.3 11-Mar-2010  yamt sync with head
 1.36.4.2 20-Jun-2009  yamt sync with head
 1.36.4.1 04-May-2009  yamt sync with head.
 1.36.2.2 17-Jun-2008  yamt sync with head.
 1.36.2.1 04-Jun-2008  yamt sync with head
 1.37.2.2 28-Jul-2008  simonb Sync with head.
 1.37.2.1 18-Jun-2008  simonb Sync with head.
 1.38.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.38.2.1 19-Oct-2008  haad Sync with HEAD.
 1.41.4.2 18-Mar-2015  snj regen for ticket 1149
 1.41.4.1 20-Nov-2008  snj Regen for ticket 81.
 1.41.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.41.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.2.2 04-Jan-2009  christos use compat_50 syscalls where appropriate.
 1.47.2.1 12-Dec-2008  christos file linux32_syscall.h was added on branch christos-time_t on 2009-01-04 01:58:39 +0000
 1.53.2.1 23-Jul-2009  jym Sync with HEAD.
 1.58.4.3 31-May-2011  rmind sync with head
 1.58.4.2 21-Apr-2011  rmind sync with head
 1.58.4.1 05-Mar-2011  rmind sync with head
 1.58.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.58.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.63.4.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.63.4.3 30-Oct-2012  yamt sync with head
 1.63.4.2 23-May-2012  yamt sync with head.
 1.63.4.1 17-Apr-2012  yamt sync with head
 1.65.6.2 20-Jul-2012  riz Pull up following revision(s) (requested by christos in ticket #424):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.67
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.62
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.67
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.67
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.67
add xattr stubs
regen
 1.65.6.1 19-May-2012  riz Pull up following revision(s) (requested by christos in ticket #263):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.66
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.61
sys/compat/linux32/common/linux32_signal.c: revision 1.16
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.66
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.66
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.66
regen
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.65.4.1 02-Jun-2012  mrg sync to latest -current.
 1.67.4.1 18-May-2014  rmind sync with head
 1.67.2.2 03-Dec-2017  jdolecek update from HEAD
 1.67.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.70.2.1 10-Aug-2014  tls Rebase.
 1.73.2.1 06-Apr-2015  skrll Sync with HEAD
 1.75.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.76.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.77.4.1 11-May-2017  pgoyette Sync with HEAD
 1.78.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.78.10.1 10-Jun-2019  christos Sync with HEAD
 1.78.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.81.2.3 03-Jan-2021  thorpej Regen for preadv(2) and pwritev(2).
 1.81.2.2 17-Dec-2020  thorpej Regen for POSIX timers and timerfd.
 1.81.2.1 16-Dec-2020  thorpej Regen for eventfd.
 1.87 02-Dec-2021  ryo regen
 1.86 27-Nov-2021  ryo regen
 1.85 20-Sep-2021  thorpej Regen for preadv(2) / pwritev(2).
 1.84 20-Sep-2021  thorpej Regen for eventfd.
 1.83 19-Sep-2021  thorpej Regen for timerfd.
 1.82 19-Sep-2021  thorpej Regen for POSIX timer syscalls.
 1.81 26-Apr-2020  thorpej branches: 1.81.2;
Regen for native futex calls.
 1.80 09-Nov-2019  jdolecek regen
 1.79 10-Aug-2018  pgoyette Regen
 1.78 10-May-2017  riastradh branches: 1.78.8; 1.78.10;
regen
 1.77 16-Jan-2017  christos branches: 1.77.4;
descend and regen
 1.76 13-Jan-2017  christos branches: 1.76.2;
regen
 1.75 08-Mar-2015  christos branches: 1.75.2;
regen
 1.74 07-Mar-2015  christos regen
 1.73 22-Nov-2014  njoly branches: 1.73.2;
Regen for ppoll(2)
 1.72 29-May-2014  njoly Regen for utimes(2).
 1.71 04-May-2014  njoly Regen for pread/pwrite 64bit offset argument.
 1.70 18-Nov-2013  christos branches: 1.70.2;
Regen
 1.69 18-Nov-2013  chs regen
 1.68 07-Nov-2013  njoly Regen for dup/dup2/dup3 argument types fix.
 1.67 13-Jul-2012  christos branches: 1.67.2; 1.67.4;
regen
 1.66 10-May-2012  christos regen
 1.65 18-Nov-2011  christos branches: 1.65.4; 1.65.6;
regen
 1.64 18-Nov-2011  christos add sigtimedwait support
 1.63 30-May-2011  alnsn branches: 1.63.4;
Regenerate files to pick up correct RCS Ids. Suggested by Chris Badura.
 1.62 30-May-2011  alnsn Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.61 10-Apr-2011  christos Regen: XXX: produces errors because of rump changes!
 1.60 02-Nov-2010  chs branches: 1.60.2;
regen
 1.59 07-Jul-2010  chs regen
 1.58 24-Nov-2009  njoly branches: 1.58.2; 1.58.4;
Regen for personality(2) update.
 1.57 08-Jun-2009  njoly Regen for rt_queueinfo addition.
 1.56 05-Jun-2009  njoly Regen for fstatfs.
 1.55 04-Jun-2009  njoly Regen for stat/lstat/fstat syscalls.
 1.54 02-Jun-2009  njoly Regen for siggetmask/sigsetmask.
 1.53 30-Jan-2009  njoly branches: 1.53.2;
Regen for mincore(2).
 1.52 20-Jan-2009  njoly Regen for personality(2) addition.
 1.51 17-Jan-2009  njoly Regen for wait4 update.
 1.50 16-Jan-2009  njoly Regen for compat 50 update.
 1.49 13-Jan-2009  pooka Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.48 11-Jan-2009  christos merge christos-time_t
 1.47 12-Dec-2008  njoly branches: 1.47.2;
Regen for clock_nanosleep.
 1.46 06-Dec-2008  njoly Regen for netbsd32_caddr_t removal.
 1.45 05-Dec-2008  njoly Regen for getres{uid,gid} syscalls.
 1.44 01-Dec-2008  njoly Regen for sched_get_priority_{min,max}.
 1.43 19-Nov-2008  ad Regen.
 1.42 12-Nov-2008  njoly Regen for nanosleep(2) fix.
 1.41 06-Oct-2008  njoly branches: 1.41.2; 1.41.4;
Regen.
 1.40 22-Sep-2008  njoly Regen after cleanup.
 1.39 24-Jul-2008  njoly Regen for rt_sigpending.
 1.38 16-Jun-2008  christos branches: 1.38.2;
regen
 1.37 20-May-2008  njoly branches: 1.37.2;
Regen for ipc(2) syscall support.
 1.36 17-Apr-2008  njoly branches: 1.36.2; 1.36.4; 1.36.6;
Regen for sys_clock_{getres,gettime,settime} syscalls.
 1.35 04-Apr-2008  njoly Regen for msync(2) support.
 1.34 20-Feb-2008  njoly branches: 1.34.6;
Regen for mlock/munlock syscalls
 1.33 17-Feb-2008  njoly Regen for pread/pwrite fixes.
 1.32 04-Feb-2008  dsl Regen for merging fcntl() and fcntl64().
 1.31 02-Feb-2008  dsl Regen for pread and pwrite
 1.30 15-Jan-2008  njoly Regen.
 1.29 07-Jan-2008  njoly Regen.
 1.28 26-Dec-2007  njoly Regen for readdir syscall.
 1.27 24-Dec-2007  njoly Regen for old_uname syscall.
 1.26 24-Dec-2007  njoly Regen for getpgid.
 1.25 21-Dec-2007  njoly Regen for getfsuid/setfsgid syscall exchange.
 1.24 20-Dec-2007  dsl regen
 1.23 16-Nov-2007  njoly branches: 1.23.2; 1.23.6;
Regen.
 1.22 11-Nov-2007  christos regen
 1.21 07-Nov-2007  njoly Regen for 64-bit linux syscalls removal.
 1.20 31-Oct-2007  dsl branches: 1.20.2;
regen
 1.19 31-Oct-2007  njoly Regen for syscalls cleanup.
 1.18 27-Oct-2007  njoly Regen for chown additions.
 1.17 20-Apr-2007  njoly branches: 1.17.6; 1.17.8; 1.17.12;
Regen (ftruncate fix).
 1.16 11-Apr-2007  njoly Regen (statfs support).
 1.15 05-Mar-2007  christos branches: 1.15.2; 1.15.4;
fix caddr_t lossage.
 1.14 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.13 16-Feb-2007  njoly branches: 1.13.2;
Regen.
 1.12 08-Feb-2007  njoly Regen (aliases cleanup).
 1.11 07-Feb-2007  njoly Regen (poll argument fix).
 1.10 13-Sep-2006  manu branches: 1.10.4;
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.9 06-Sep-2006  manu branches: 1.9.2; 1.9.4;
Implement Linux's fdatasync, patch from Nicolas Joly
 1.8 06-Sep-2006  manu Fix linux32_sys_setres{uid|gid}: -1 does not means the same thing on i386
and amd64...
 1.7 05-Sep-2006  manu typo
 1.6 01-Sep-2006  matt Regen.
 1.5 25-Jun-2006  manu Regen
 1.4 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.3 15-Feb-2006  manu branches: 1.3.2; 1.3.4; 1.3.10; 1.3.14; 1.3.16;
Add getcwd (for real this time), fix dup and dup2
 1.2 15-Feb-2006  manu - 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.1 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.3.16.12 27-Feb-2008  yamt sync with head.
 1.3.16.11 11-Feb-2008  yamt sync with head.
 1.3.16.10 04-Feb-2008  yamt sync with head.
 1.3.16.9 21-Jan-2008  yamt sync with head
 1.3.16.8 07-Dec-2007  yamt sync with head
 1.3.16.7 15-Nov-2007  yamt sync with head.
 1.3.16.6 27-Oct-2007  yamt sync with head.
 1.3.16.5 03-Sep-2007  yamt sync with head.
 1.3.16.4 26-Feb-2007  yamt sync with head.
 1.3.16.3 30-Dec-2006  yamt sync with head.
 1.3.16.2 21-Jun-2006  yamt sync with head.
 1.3.16.1 15-Feb-2006  yamt file linux32_syscallargs.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.3.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.10.2 22-Apr-2006  simonb Sync with head.
 1.3.10.1 15-Feb-2006  simonb file linux32_syscallargs.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.3.4.2 14-Sep-2006  yamt sync with head.
 1.3.4.1 26-Jun-2006  yamt sync with head.
 1.3.2.2 18-Feb-2006  yamt sync with head.
 1.3.2.1 15-Feb-2006  yamt file linux32_syscallargs.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.9.4.2 09-Sep-2006  rpaulo sync with head
 1.9.4.1 06-Sep-2006  rpaulo file linux32_syscallargs.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.9.2.2 09-Feb-2007  ad Sync with HEAD.
 1.9.2.1 18-Nov-2006  ad Sync with head.
 1.10.4.2 20-Apr-2007  bouyer regen for ticket #582
 1.10.4.1 02-Apr-2007  bouyer Regen for ticket #544
 1.13.2.3 07-May-2007  yamt sync with head.
 1.13.2.2 15-Apr-2007  yamt sync with head.
 1.13.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 27-May-2007  ad Sync with head.
 1.17.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.17.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.17.8.4 23-Mar-2008  matt sync with HEAD
 1.17.8.3 09-Jan-2008  matt sync with HEAD
 1.17.8.2 08-Nov-2007  matt sync with -HEAD
 1.17.8.1 06-Nov-2007  matt sync with HEAD
 1.17.6.6 21-Nov-2007  joerg Sync with HEAD.
 1.17.6.5 14-Nov-2007  joerg Sync with HEAD.
 1.17.6.4 11-Nov-2007  joerg Sync with HEAD.
 1.17.6.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.17.6.2 31-Oct-2007  joerg Sync with HEAD.
 1.17.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.20.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.20.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.23.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.23.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.23.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.2.1 26-Dec-2007  ad Sync with head.
 1.34.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.34.6.3 28-Sep-2008  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.36.6.3 10-Oct-2008  skrll Sync with HEAD.
 1.36.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.36.4.4 11-Aug-2010  yamt sync with head.
 1.36.4.3 11-Mar-2010  yamt sync with head
 1.36.4.2 20-Jun-2009  yamt sync with head
 1.36.4.1 04-May-2009  yamt sync with head.
 1.36.2.2 17-Jun-2008  yamt sync with head.
 1.36.2.1 04-Jun-2008  yamt sync with head
 1.37.2.2 28-Jul-2008  simonb Sync with head.
 1.37.2.1 18-Jun-2008  simonb Sync with head.
 1.38.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.38.2.1 19-Oct-2008  haad Sync with HEAD.
 1.41.4.2 18-Mar-2015  snj regen for ticket 1149
 1.41.4.1 20-Nov-2008  snj Regen for ticket 81.
 1.41.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.41.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.2.2 04-Jan-2009  christos use compat_50 syscalls where appropriate.
 1.47.2.1 12-Dec-2008  christos file linux32_syscallargs.h was added on branch christos-time_t on 2009-01-04 01:58:39 +0000
 1.53.2.1 23-Jul-2009  jym Sync with HEAD.
 1.58.4.3 31-May-2011  rmind sync with head
 1.58.4.2 21-Apr-2011  rmind sync with head
 1.58.4.1 05-Mar-2011  rmind sync with head
 1.58.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.58.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.63.4.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.63.4.3 30-Oct-2012  yamt sync with head
 1.63.4.2 23-May-2012  yamt sync with head.
 1.63.4.1 17-Apr-2012  yamt sync with head
 1.65.6.2 20-Jul-2012  riz Pull up following revision(s) (requested by christos in ticket #424):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.67
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.62
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.67
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.67
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.67
add xattr stubs
regen
 1.65.6.1 19-May-2012  riz Pull up following revision(s) (requested by christos in ticket #263):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.66
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.61
sys/compat/linux32/common/linux32_signal.c: revision 1.16
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.66
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.66
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.66
regen
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.65.4.1 02-Jun-2012  mrg sync to latest -current.
 1.67.4.1 18-May-2014  rmind sync with head
 1.67.2.2 03-Dec-2017  jdolecek update from HEAD
 1.67.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.70.2.1 10-Aug-2014  tls Rebase.
 1.73.2.2 28-Aug-2017  skrll Sync with HEAD
 1.73.2.1 06-Apr-2015  skrll Sync with HEAD
 1.75.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.76.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.77.4.1 11-May-2017  pgoyette Sync with HEAD
 1.78.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.78.10.1 10-Jun-2019  christos Sync with HEAD
 1.78.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.81.2.3 03-Jan-2021  thorpej Regen for preadv(2) and pwritev(2).
 1.81.2.2 17-Dec-2020  thorpej Regen for POSIX timers and timerfd.
 1.81.2.1 16-Dec-2020  thorpej Regen for eventfd.
 1.87 02-Dec-2021  ryo regen
 1.86 27-Nov-2021  ryo regen
 1.85 20-Sep-2021  thorpej Regen for preadv(2) / pwritev(2).
 1.84 20-Sep-2021  thorpej Regen for eventfd.
 1.83 19-Sep-2021  thorpej Regen for timerfd.
 1.82 19-Sep-2021  thorpej Regen for POSIX timer syscalls.
 1.81 26-Apr-2020  thorpej branches: 1.81.2;
Regen for native futex calls.
 1.80 09-Nov-2019  jdolecek regen
 1.79 10-Aug-2018  pgoyette Regen
 1.78 10-May-2017  riastradh branches: 1.78.8; 1.78.10;
regen
 1.77 16-Jan-2017  christos branches: 1.77.4;
descend and regen
 1.76 13-Jan-2017  christos branches: 1.76.2;
regen
 1.75 08-Mar-2015  christos branches: 1.75.2;
regen
 1.74 07-Mar-2015  christos regen
 1.73 22-Nov-2014  njoly branches: 1.73.2;
Regen for ppoll(2)
 1.72 29-May-2014  njoly Regen for utimes(2).
 1.71 04-May-2014  njoly Regen for pread/pwrite 64bit offset argument.
 1.70 18-Nov-2013  christos branches: 1.70.2;
Regen
 1.69 18-Nov-2013  chs regen
 1.68 07-Nov-2013  njoly Regen for dup/dup2/dup3 argument types fix.
 1.67 13-Jul-2012  christos branches: 1.67.2; 1.67.4;
regen
 1.66 10-May-2012  christos regen
 1.65 18-Nov-2011  christos branches: 1.65.4; 1.65.6;
regen
 1.64 18-Nov-2011  christos add sigtimedwait support
 1.63 30-May-2011  alnsn branches: 1.63.4;
Regenerate files to pick up correct RCS Ids. Suggested by Chris Badura.
 1.62 30-May-2011  alnsn Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.61 10-Apr-2011  christos Regen: XXX: produces errors because of rump changes!
 1.60 02-Nov-2010  chs branches: 1.60.2;
regen
 1.59 07-Jul-2010  chs regen
 1.58 24-Nov-2009  njoly branches: 1.58.2; 1.58.4;
Regen for personality(2) update.
 1.57 08-Jun-2009  njoly Regen for rt_queueinfo addition.
 1.56 05-Jun-2009  njoly Regen for fstatfs.
 1.55 04-Jun-2009  njoly Regen for stat/lstat/fstat syscalls.
 1.54 02-Jun-2009  njoly Regen for siggetmask/sigsetmask.
 1.53 30-Jan-2009  njoly branches: 1.53.2;
Regen for mincore(2).
 1.52 20-Jan-2009  njoly Regen for personality(2) addition.
 1.51 17-Jan-2009  njoly Regen for wait4 update.
 1.50 16-Jan-2009  njoly Regen for compat 50 update.
 1.49 13-Jan-2009  pooka Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.48 11-Jan-2009  christos merge christos-time_t
 1.47 12-Dec-2008  njoly branches: 1.47.2;
Regen for clock_nanosleep.
 1.46 06-Dec-2008  njoly Regen for netbsd32_caddr_t removal.
 1.45 05-Dec-2008  njoly Regen for getres{uid,gid} syscalls.
 1.44 01-Dec-2008  njoly Regen for sched_get_priority_{min,max}.
 1.43 19-Nov-2008  ad Regen.
 1.42 12-Nov-2008  njoly Regen for nanosleep(2) fix.
 1.41 06-Oct-2008  njoly branches: 1.41.2; 1.41.4;
Regen.
 1.40 22-Sep-2008  njoly Regen after cleanup.
 1.39 24-Jul-2008  njoly Regen for rt_sigpending.
 1.38 16-Jun-2008  christos branches: 1.38.2;
regen
 1.37 20-May-2008  njoly branches: 1.37.2;
Regen for ipc(2) syscall support.
 1.36 17-Apr-2008  njoly branches: 1.36.2; 1.36.4; 1.36.6;
Regen for sys_clock_{getres,gettime,settime} syscalls.
 1.35 04-Apr-2008  njoly Regen for msync(2) support.
 1.34 20-Feb-2008  njoly branches: 1.34.6;
Regen for mlock/munlock syscalls
 1.33 17-Feb-2008  njoly Regen for pread/pwrite fixes.
 1.32 04-Feb-2008  dsl Regen for merging fcntl() and fcntl64().
 1.31 02-Feb-2008  dsl Regen for pread and pwrite
 1.30 15-Jan-2008  njoly Regen.
 1.29 07-Jan-2008  njoly Regen.
 1.28 26-Dec-2007  njoly Regen for readdir syscall.
 1.27 24-Dec-2007  njoly Regen for old_uname syscall.
 1.26 24-Dec-2007  njoly Regen for getpgid.
 1.25 21-Dec-2007  njoly Regen for getfsuid/setfsgid syscall exchange.
 1.24 20-Dec-2007  dsl regen
 1.23 16-Nov-2007  njoly branches: 1.23.2; 1.23.6;
Regen.
 1.22 11-Nov-2007  christos regen
 1.21 07-Nov-2007  njoly Regen for 64-bit linux syscalls removal.
 1.20 31-Oct-2007  dsl branches: 1.20.2;
regen
 1.19 31-Oct-2007  njoly Regen for syscalls cleanup.
 1.18 27-Oct-2007  njoly Regen for chown additions.
 1.17 20-Apr-2007  njoly branches: 1.17.6; 1.17.8; 1.17.12;
Regen (ftruncate fix).
 1.16 11-Apr-2007  njoly Regen (statfs support).
 1.15 05-Mar-2007  christos branches: 1.15.2; 1.15.4;
fix caddr_t lossage.
 1.14 16-Feb-2007  njoly branches: 1.14.2;
Regen.
 1.13 09-Feb-2007  ad Merge newlock2 to head.
 1.12 08-Feb-2007  njoly Regen (aliases cleanup).
 1.11 07-Feb-2007  njoly Regen (poll argument fix).
 1.10 13-Sep-2006  manu branches: 1.10.4;
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.9 06-Sep-2006  manu branches: 1.9.2; 1.9.4;
Implement Linux's fdatasync, patch from Nicolas Joly
 1.8 06-Sep-2006  manu Fix linux32_sys_setres{uid|gid}: -1 does not means the same thing on i386
and amd64...
 1.7 05-Sep-2006  manu typo
 1.6 01-Sep-2006  matt Regen.
 1.5 25-Jun-2006  manu Regen
 1.4 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.3 15-Feb-2006  manu branches: 1.3.2; 1.3.4; 1.3.10; 1.3.14; 1.3.16;
Add getcwd (for real this time), fix dup and dup2
 1.2 15-Feb-2006  manu - 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.1 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.3.16.12 27-Feb-2008  yamt sync with head.
 1.3.16.11 11-Feb-2008  yamt sync with head.
 1.3.16.10 04-Feb-2008  yamt sync with head.
 1.3.16.9 21-Jan-2008  yamt sync with head
 1.3.16.8 07-Dec-2007  yamt sync with head
 1.3.16.7 15-Nov-2007  yamt sync with head.
 1.3.16.6 27-Oct-2007  yamt sync with head.
 1.3.16.5 03-Sep-2007  yamt sync with head.
 1.3.16.4 26-Feb-2007  yamt sync with head.
 1.3.16.3 30-Dec-2006  yamt sync with head.
 1.3.16.2 21-Jun-2006  yamt sync with head.
 1.3.16.1 15-Feb-2006  yamt file linux32_syscalls.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.3.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.10.2 22-Apr-2006  simonb Sync with head.
 1.3.10.1 15-Feb-2006  simonb file linux32_syscalls.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.3.4.2 14-Sep-2006  yamt sync with head.
 1.3.4.1 26-Jun-2006  yamt sync with head.
 1.3.2.2 18-Feb-2006  yamt sync with head.
 1.3.2.1 15-Feb-2006  yamt file linux32_syscalls.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.9.4.2 09-Sep-2006  rpaulo sync with head
 1.9.4.1 06-Sep-2006  rpaulo file linux32_syscalls.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.9.2.3 09-Feb-2007  ad Sync with HEAD.
 1.9.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.9.2.1 18-Nov-2006  ad Sync with head.
 1.10.4.2 20-Apr-2007  bouyer regen for ticket #582
 1.10.4.1 02-Apr-2007  bouyer Regen for ticket #544
 1.14.2.3 07-May-2007  yamt sync with head.
 1.14.2.2 15-Apr-2007  yamt sync with head.
 1.14.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 27-May-2007  ad Sync with head.
 1.17.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.17.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.17.8.4 23-Mar-2008  matt sync with HEAD
 1.17.8.3 09-Jan-2008  matt sync with HEAD
 1.17.8.2 08-Nov-2007  matt sync with -HEAD
 1.17.8.1 06-Nov-2007  matt sync with HEAD
 1.17.6.6 21-Nov-2007  joerg Sync with HEAD.
 1.17.6.5 14-Nov-2007  joerg Sync with HEAD.
 1.17.6.4 11-Nov-2007  joerg Sync with HEAD.
 1.17.6.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.17.6.2 31-Oct-2007  joerg Sync with HEAD.
 1.17.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.20.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.20.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.23.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.23.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.23.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.2.1 26-Dec-2007  ad Sync with head.
 1.34.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.34.6.3 28-Sep-2008  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.36.6.3 10-Oct-2008  skrll Sync with HEAD.
 1.36.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.36.4.4 11-Aug-2010  yamt sync with head.
 1.36.4.3 11-Mar-2010  yamt sync with head
 1.36.4.2 20-Jun-2009  yamt sync with head
 1.36.4.1 04-May-2009  yamt sync with head.
 1.36.2.2 17-Jun-2008  yamt sync with head.
 1.36.2.1 04-Jun-2008  yamt sync with head
 1.37.2.2 28-Jul-2008  simonb Sync with head.
 1.37.2.1 18-Jun-2008  simonb Sync with head.
 1.38.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.38.2.1 19-Oct-2008  haad Sync with HEAD.
 1.41.4.2 18-Mar-2015  snj regen for ticket 1149
 1.41.4.1 20-Nov-2008  snj Regen for ticket 81.
 1.41.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.41.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.2.2 04-Jan-2009  christos use compat_50 syscalls where appropriate.
 1.47.2.1 12-Dec-2008  christos file linux32_syscalls.c was added on branch christos-time_t on 2009-01-04 01:58:39 +0000
 1.53.2.1 23-Jul-2009  jym Sync with HEAD.
 1.58.4.3 31-May-2011  rmind sync with head
 1.58.4.2 21-Apr-2011  rmind sync with head
 1.58.4.1 05-Mar-2011  rmind sync with head
 1.58.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.58.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.63.4.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.63.4.3 30-Oct-2012  yamt sync with head
 1.63.4.2 23-May-2012  yamt sync with head.
 1.63.4.1 17-Apr-2012  yamt sync with head
 1.65.6.2 20-Jul-2012  riz Pull up following revision(s) (requested by christos in ticket #424):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.67
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.62
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.67
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.67
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.67
add xattr stubs
regen
 1.65.6.1 19-May-2012  riz Pull up following revision(s) (requested by christos in ticket #263):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.66
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.61
sys/compat/linux32/common/linux32_signal.c: revision 1.16
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.66
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.66
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.66
regen
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.65.4.1 02-Jun-2012  mrg sync to latest -current.
 1.67.4.1 18-May-2014  rmind sync with head
 1.67.2.2 03-Dec-2017  jdolecek update from HEAD
 1.67.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.70.2.1 10-Aug-2014  tls Rebase.
 1.73.2.2 05-Feb-2017  skrll Sync with HEAD
 1.73.2.1 06-Apr-2015  skrll Sync with HEAD
 1.75.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.76.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.77.4.1 11-May-2017  pgoyette Sync with HEAD
 1.78.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.78.10.1 10-Jun-2019  christos Sync with HEAD
 1.78.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.81.2.3 03-Jan-2021  thorpej Regen for preadv(2) and pwritev(2).
 1.81.2.2 17-Dec-2020  thorpej Regen for POSIX timers and timerfd.
 1.81.2.1 16-Dec-2020  thorpej Regen for eventfd.
 1.87 02-Dec-2021  ryo regen
 1.86 27-Nov-2021  ryo regen
 1.85 20-Sep-2021  thorpej Regen for preadv(2) / pwritev(2).
 1.84 20-Sep-2021  thorpej Regen for eventfd.
 1.83 19-Sep-2021  thorpej Regen for timerfd.
 1.82 19-Sep-2021  thorpej Regen for POSIX timer syscalls.
 1.81 26-Apr-2020  thorpej branches: 1.81.2;
Regen for native futex calls.
 1.80 09-Nov-2019  jdolecek regen
 1.79 10-Aug-2018  pgoyette Regen
 1.78 10-May-2017  riastradh branches: 1.78.8; 1.78.10;
regen
 1.77 16-Jan-2017  christos branches: 1.77.4;
descend and regen
 1.76 13-Jan-2017  christos branches: 1.76.2;
regen
 1.75 08-Mar-2015  christos branches: 1.75.2;
regen
 1.74 07-Mar-2015  christos regen
 1.73 22-Nov-2014  njoly branches: 1.73.2;
Regen for ppoll(2)
 1.72 29-May-2014  njoly Regen for utimes(2).
 1.71 04-May-2014  njoly Regen for pread/pwrite 64bit offset argument.
 1.70 18-Nov-2013  christos branches: 1.70.2;
Regen
 1.69 18-Nov-2013  chs regen
 1.68 07-Nov-2013  njoly Regen for dup/dup2/dup3 argument types fix.
 1.67 13-Jul-2012  christos branches: 1.67.2; 1.67.4;
regen
 1.66 10-May-2012  christos regen
 1.65 18-Nov-2011  christos branches: 1.65.4; 1.65.6;
regen
 1.64 18-Nov-2011  christos add sigtimedwait support
 1.63 30-May-2011  alnsn branches: 1.63.4;
Regenerate files to pick up correct RCS Ids. Suggested by Chris Badura.
 1.62 30-May-2011  alnsn Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.61 10-Apr-2011  christos Regen: XXX: produces errors because of rump changes!
 1.60 02-Nov-2010  chs branches: 1.60.2;
regen
 1.59 07-Jul-2010  chs regen
 1.58 24-Nov-2009  njoly branches: 1.58.2; 1.58.4;
Regen for personality(2) update.
 1.57 08-Jun-2009  njoly Regen for rt_queueinfo addition.
 1.56 05-Jun-2009  njoly Regen for fstatfs.
 1.55 04-Jun-2009  njoly Regen for stat/lstat/fstat syscalls.
 1.54 02-Jun-2009  njoly Regen for siggetmask/sigsetmask.
 1.53 30-Jan-2009  njoly branches: 1.53.2;
Regen for mincore(2).
 1.52 20-Jan-2009  njoly Regen for personality(2) addition.
 1.51 17-Jan-2009  njoly Regen for wait4 update.
 1.50 16-Jan-2009  njoly Regen for compat 50 update.
 1.49 13-Jan-2009  pooka Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.48 11-Jan-2009  christos merge christos-time_t
 1.47 12-Dec-2008  njoly branches: 1.47.2;
Regen for clock_nanosleep.
 1.46 06-Dec-2008  njoly Regen for netbsd32_caddr_t removal.
 1.45 05-Dec-2008  njoly Regen for getres{uid,gid} syscalls.
 1.44 01-Dec-2008  njoly Regen for sched_get_priority_{min,max}.
 1.43 19-Nov-2008  ad Regen.
 1.42 12-Nov-2008  njoly Regen for nanosleep(2) fix.
 1.41 06-Oct-2008  njoly branches: 1.41.2; 1.41.4;
Regen.
 1.40 22-Sep-2008  njoly Regen after cleanup.
 1.39 24-Jul-2008  njoly Regen for rt_sigpending.
 1.38 16-Jun-2008  christos branches: 1.38.2;
regen
 1.37 20-May-2008  njoly branches: 1.37.2;
Regen for ipc(2) syscall support.
 1.36 17-Apr-2008  njoly branches: 1.36.2; 1.36.4; 1.36.6;
Regen for sys_clock_{getres,gettime,settime} syscalls.
 1.35 04-Apr-2008  njoly Regen for msync(2) support.
 1.34 20-Feb-2008  njoly branches: 1.34.6;
Regen for mlock/munlock syscalls
 1.33 17-Feb-2008  njoly Regen for pread/pwrite fixes.
 1.32 04-Feb-2008  dsl Regen for merging fcntl() and fcntl64().
 1.31 02-Feb-2008  dsl Regen for pread and pwrite
 1.30 15-Jan-2008  njoly Regen.
 1.29 07-Jan-2008  njoly Regen.
 1.28 26-Dec-2007  njoly Regen for readdir syscall.
 1.27 24-Dec-2007  njoly Regen for old_uname syscall.
 1.26 24-Dec-2007  njoly Regen for getpgid.
 1.25 21-Dec-2007  njoly Regen for getfsuid/setfsgid syscall exchange.
 1.24 20-Dec-2007  dsl regen
 1.23 16-Nov-2007  njoly branches: 1.23.2; 1.23.6;
Regen.
 1.22 11-Nov-2007  christos regen
 1.21 07-Nov-2007  njoly Regen for 64-bit linux syscalls removal.
 1.20 31-Oct-2007  dsl branches: 1.20.2;
regen
 1.19 31-Oct-2007  njoly Regen for syscalls cleanup.
 1.18 27-Oct-2007  njoly Regen for chown additions.
 1.17 20-Apr-2007  njoly branches: 1.17.6; 1.17.8; 1.17.12;
Regen (ftruncate fix).
 1.16 11-Apr-2007  njoly Regen (statfs support).
 1.15 05-Mar-2007  christos branches: 1.15.2; 1.15.4;
fix caddr_t lossage.
 1.14 16-Feb-2007  njoly branches: 1.14.2;
Regen.
 1.13 09-Feb-2007  ad Merge newlock2 to head.
 1.12 08-Feb-2007  njoly Regen (aliases cleanup).
 1.11 07-Feb-2007  njoly Regen (poll argument fix).
 1.10 13-Sep-2006  manu branches: 1.10.4;
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.9 06-Sep-2006  manu branches: 1.9.2; 1.9.4;
Implement Linux's fdatasync, patch from Nicolas Joly
 1.8 06-Sep-2006  manu Fix linux32_sys_setres{uid|gid}: -1 does not means the same thing on i386
and amd64...
 1.7 05-Sep-2006  manu typo
 1.6 01-Sep-2006  matt Regen.
 1.5 25-Jun-2006  manu Regen
 1.4 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.3 15-Feb-2006  manu branches: 1.3.2; 1.3.4; 1.3.10; 1.3.14; 1.3.16;
Add getcwd (for real this time), fix dup and dup2
 1.2 15-Feb-2006  manu - 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.1 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.3.16.12 27-Feb-2008  yamt sync with head.
 1.3.16.11 11-Feb-2008  yamt sync with head.
 1.3.16.10 04-Feb-2008  yamt sync with head.
 1.3.16.9 21-Jan-2008  yamt sync with head
 1.3.16.8 07-Dec-2007  yamt sync with head
 1.3.16.7 15-Nov-2007  yamt sync with head.
 1.3.16.6 27-Oct-2007  yamt sync with head.
 1.3.16.5 03-Sep-2007  yamt sync with head.
 1.3.16.4 26-Feb-2007  yamt sync with head.
 1.3.16.3 30-Dec-2006  yamt sync with head.
 1.3.16.2 21-Jun-2006  yamt sync with head.
 1.3.16.1 15-Feb-2006  yamt file linux32_sysent.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.3.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.3.10.2 22-Apr-2006  simonb Sync with head.
 1.3.10.1 15-Feb-2006  simonb file linux32_sysent.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.3.4.2 14-Sep-2006  yamt sync with head.
 1.3.4.1 26-Jun-2006  yamt sync with head.
 1.3.2.2 18-Feb-2006  yamt sync with head.
 1.3.2.1 15-Feb-2006  yamt file linux32_sysent.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.9.4.2 09-Sep-2006  rpaulo sync with head
 1.9.4.1 06-Sep-2006  rpaulo file linux32_sysent.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.9.2.3 09-Feb-2007  ad Sync with HEAD.
 1.9.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.9.2.1 18-Nov-2006  ad Sync with head.
 1.10.4.2 20-Apr-2007  bouyer regen for ticket #582
 1.10.4.1 02-Apr-2007  bouyer Regen for ticket #544
 1.14.2.3 07-May-2007  yamt sync with head.
 1.14.2.2 15-Apr-2007  yamt sync with head.
 1.14.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 27-May-2007  ad Sync with head.
 1.17.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.17.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.17.8.4 23-Mar-2008  matt sync with HEAD
 1.17.8.3 09-Jan-2008  matt sync with HEAD
 1.17.8.2 08-Nov-2007  matt sync with -HEAD
 1.17.8.1 06-Nov-2007  matt sync with HEAD
 1.17.6.6 21-Nov-2007  joerg Sync with HEAD.
 1.17.6.5 14-Nov-2007  joerg Sync with HEAD.
 1.17.6.4 11-Nov-2007  joerg Sync with HEAD.
 1.17.6.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.17.6.2 31-Oct-2007  joerg Sync with HEAD.
 1.17.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.20.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.20.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.20.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.23.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.23.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.23.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.2.1 26-Dec-2007  ad Sync with head.
 1.34.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.34.6.3 28-Sep-2008  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.36.6.3 10-Oct-2008  skrll Sync with HEAD.
 1.36.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.36.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.36.4.4 11-Aug-2010  yamt sync with head.
 1.36.4.3 11-Mar-2010  yamt sync with head
 1.36.4.2 20-Jun-2009  yamt sync with head
 1.36.4.1 04-May-2009  yamt sync with head.
 1.36.2.2 17-Jun-2008  yamt sync with head.
 1.36.2.1 04-Jun-2008  yamt sync with head
 1.37.2.2 28-Jul-2008  simonb Sync with head.
 1.37.2.1 18-Jun-2008  simonb Sync with head.
 1.38.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.38.2.1 19-Oct-2008  haad Sync with HEAD.
 1.41.4.2 18-Mar-2015  snj regen for ticket 1149
 1.41.4.1 20-Nov-2008  snj Regen for ticket 81.
 1.41.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.41.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.2.2 04-Jan-2009  christos use compat_50 syscalls where appropriate.
 1.47.2.1 12-Dec-2008  christos file linux32_sysent.c was added on branch christos-time_t on 2009-01-04 01:58:39 +0000
 1.53.2.1 23-Jul-2009  jym Sync with HEAD.
 1.58.4.3 31-May-2011  rmind sync with head
 1.58.4.2 21-Apr-2011  rmind sync with head
 1.58.4.1 05-Mar-2011  rmind sync with head
 1.58.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.58.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.63.4.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.63.4.3 30-Oct-2012  yamt sync with head
 1.63.4.2 23-May-2012  yamt sync with head.
 1.63.4.1 17-Apr-2012  yamt sync with head
 1.65.6.2 20-Jul-2012  riz Pull up following revision(s) (requested by christos in ticket #424):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.67
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.62
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.67
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.67
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.67
add xattr stubs
regen
 1.65.6.1 19-May-2012  riz Pull up following revision(s) (requested by christos in ticket #263):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.66
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.61
sys/compat/linux32/common/linux32_signal.c: revision 1.16
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.66
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.66
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.66
regen
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.65.4.1 02-Jun-2012  mrg sync to latest -current.
 1.67.4.1 18-May-2014  rmind sync with head
 1.67.2.2 03-Dec-2017  jdolecek update from HEAD
 1.67.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.70.2.1 10-Aug-2014  tls Rebase.
 1.73.2.2 05-Feb-2017  skrll Sync with HEAD
 1.73.2.1 06-Apr-2015  skrll Sync with HEAD
 1.75.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.76.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.77.4.1 11-May-2017  pgoyette Sync with HEAD
 1.78.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.78.10.1 10-Jun-2019  christos Sync with HEAD
 1.78.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.81.2.3 03-Jan-2021  thorpej Regen for preadv(2) and pwritev(2).
 1.81.2.2 17-Dec-2020  thorpej Regen for POSIX timers and timerfd.
 1.81.2.1 16-Dec-2020  thorpej Regen for eventfd.
 1.14 02-Dec-2021  ryo regen
 1.13 27-Nov-2021  ryo regen
 1.12 20-Sep-2021  thorpej Regen for preadv(2) / pwritev(2).
 1.11 20-Sep-2021  thorpej Regen for eventfd.
 1.10 19-Sep-2021  thorpej Regen for timerfd.
 1.9 19-Sep-2021  thorpej Regen for POSIX timer syscalls.
 1.8 26-Apr-2020  thorpej branches: 1.8.2;
Regen for native futex calls.
 1.7 09-Nov-2019  jdolecek regen
 1.6 10-Aug-2018  pgoyette Regen
 1.5 10-May-2017  riastradh branches: 1.5.8; 1.5.10; 1.5.12;
regen
 1.4 16-Jan-2017  christos branches: 1.4.4;
descend and regen
 1.3 13-Jan-2017  christos branches: 1.3.2;
regen
 1.2 08-Mar-2015  christos branches: 1.2.2; 1.2.4;
regen
 1.1 07-Mar-2015  christos regen
 1.2.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.3 05-Feb-2017  skrll Sync with HEAD
 1.2.2.2 06-Apr-2015  skrll Sync with HEAD
 1.2.2.1 08-Mar-2015  skrll file linux32_systrace_args.c was added on branch nick-nhusb on 2015-04-06 15:18:06 +0000
 1.3.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.4.1 11-May-2017  pgoyette Sync with HEAD
 1.5.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.12.1 10-Jun-2019  christos Sync with HEAD
 1.5.10.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.5.8.2 03-Dec-2017  jdolecek update from HEAD
 1.5.8.1 10-May-2017  jdolecek file linux32_systrace_args.c was added on branch tls-maxphys on 2017-12-03 11:36:55 +0000
 1.8.2.3 03-Jan-2021  thorpej Regen for preadv(2) and pwritev(2).
 1.8.2.2 17-Dec-2020  thorpej Regen for POSIX timers and timerfd.
 1.8.2.1 16-Dec-2020  thorpej Regen for eventfd.
 1.2 26-Mar-2007  njoly Sync with recent compat linux termios changes.
 1.1 15-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.28; 1.1.32; 1.1.34; 1.1.36;
- 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.1.36.1 29-Mar-2007  reinoud Pullup to -current
 1.1.34.1 11-Jul-2007  mjf Sync with head.
 1.1.32.1 10-Apr-2007  ad Sync with head.
 1.1.28.1 15-Apr-2007  yamt sync with head.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 15-Feb-2006  rpaulo file linux32_termios.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.3 03-Sep-2007  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 15-Feb-2006  yamt file linux32_termios.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 15-Feb-2006  simonb file linux32_termios.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 15-Feb-2006  yamt file linux32_termios.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.7 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.6 08-Jun-2009  njoly branches: 1.6.2; 1.6.4;
Fix defines against multiple inclusion protection (s/I386/AMD64).
 1.5 04-Sep-2008  njoly branches: 1.5.8;
Make linux32 getdents(2) do its own job instead of calling the
corresponding compat linux function, where struct dirent members types
differs.
 1.4 25-Dec-2007  perry branches: 1.4.6; 1.4.10; 1.4.12; 1.4.16;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.3 05-Apr-2007  njoly branches: 1.3.10; 1.3.16; 1.3.18; 1.3.22;
Enable stat/stat64 nsec time support, for amd64 compat linux/linux32.
 1.2 13-Sep-2006  manu branches: 1.2.6; 1.2.10; 1.2.12;
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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_types.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.20.1 18-Nov-2006  ad Sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_types.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_types.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_types.h was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.2.12.1 11-Jul-2007  mjf Sync with head.
 1.2.10.1 10-Apr-2007  ad Sync with head.
 1.2.6.1 15-Apr-2007  yamt sync with head.
 1.3.22.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.18.1 26-Dec-2007  ad Sync with head.
 1.3.16.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.10.1 09-Jan-2008  matt sync with HEAD
 1.4.16.1 19-Oct-2008  haad Sync with HEAD.
 1.4.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.4.10.3 11-Aug-2010  yamt sync with head.
 1.4.10.2 20-Jun-2009  yamt sync with head
 1.4.10.1 04-May-2009  yamt sync with head.
 1.4.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.5.8.1 23-Jul-2009  jym Sync with HEAD.
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.6.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.2 07-Mar-2015  christos Add systrace output file
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.122; 1.1.142;
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.142.1 06-Apr-2015  skrll Sync with HEAD
 1.1.122.1 03-Dec-2017  jdolecek update from HEAD
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file syscalls.conf was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file syscalls.conf was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file syscalls.conf was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file syscalls.conf was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.77 02-Dec-2021  ryo add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32
 1.76 27-Nov-2021  ryo Add pselect6(2) system call to COMPAT_LINUX32
 1.75 20-Sep-2021  thorpej Add preadv(2) and pwritev(2) system calls to COMPAT_LINUX and COMPAT_LINUX32.
 1.74 20-Sep-2021  thorpej Add the eventfd system calls to COMPAT_LINUX and COMPAT_LINUX32.
 1.73 19-Sep-2021  thorpej Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.72 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.71 26-Apr-2020  thorpej branches: 1.71.2;
Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.70 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.69 08-Mar-2015  christos branches: 1.69.18;
fix inconsistent names
 1.68 22-Nov-2014  njoly branches: 1.68.2;
Add ppoll(2) for compat linux32.
 1.67 29-May-2014  njoly Add utimes(2) support.
 1.66 04-May-2014  njoly Fix pread/pwrite syscalls which need a 64bit offset argument.
 1.65 18-Nov-2013  christos branches: 1.65.2;
Fix extended attribute syscalls to use the proper types and call their netbsd32
counterparts for now.
 1.64 18-Nov-2013  chs implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.63 07-Nov-2013  njoly Fix dup/dup2/dup3 argument types (u_int -> int).
 1.62 13-Jul-2012  christos branches: 1.62.2; 1.62.4;
add xattr stubs
 1.61 10-May-2012  christos Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.60 18-Nov-2011  christos branches: 1.60.4; 1.60.6;
add sigtimedwait support
 1.59 30-May-2011  alnsn branches: 1.59.4;
Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.58 10-Apr-2011  christos add pipe2 and dup3
 1.57 02-Nov-2010  chs branches: 1.57.2;
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.56 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.55 24-Nov-2009  njoly branches: 1.55.2; 1.55.4;
Update personality(2) to match Linux definition where the argument is an
unsigned long.
 1.54 08-Jun-2009  njoly Add rt_queueinfo(2) support.
 1.53 05-Jun-2009  njoly Add fstatfs syscall.
 1.52 04-Jun-2009  njoly Add stat/lstat/fstat syscalls.
 1.51 02-Jun-2009  njoly Add siggetmask/sigsetmask syscalls.
 1.50 30-Jan-2009  njoly branches: 1.50.2;
Add mincore syscall.
 1.49 20-Jan-2009  njoly Add basic support for linux32 personality(2) syscall.
 1.48 17-Jan-2009  njoly Convert linux/linux32 wait(4) to use a compat50 rusage structure.
 1.47 16-Jan-2009  njoly Update some syscalls that now needs compat50 timeval structure.
 1.46 13-Jan-2009  pooka Convert the syscalls.master to a format from which it is easier
to parse and generate the compat name and basename (e.g. __stat50
and stat). Use this to autogenerate __RENAME()'s to the rump_syscalls
header so that they can be called e.g. rump_sys_socket() instead
of rump_sys___socket30().
 1.45 11-Jan-2009  christos merge christos-time_t
 1.44 12-Dec-2008  njoly branches: 1.44.2;
Add clock_nanosleep syscall.
 1.43 06-Dec-2008  njoly Cleanup; kill netbsd32_caddr_t use.
 1.42 05-Dec-2008  njoly Add getres{uid,gid} syscalls.
 1.41 01-Dec-2008  njoly Add sched_get_priority_{min,max} syscalls.
 1.40 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.39 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.38 06-Oct-2008  njoly branches: 1.38.2; 1.38.4;
Cleanup. Reduce diffs against netbsd32 syscalls.master.
- Remove const keyword for pointer types.
- Update some argument types.
 1.37 22-Sep-2008  njoly Kill a few linux32 syscalls identical to netbsd32 ones.
No functional changes expected.
 1.36 24-Jul-2008  njoly Add rt_sigpending syscall.
 1.35 16-Jun-2008  christos branches: 1.35.2;
an attempt at ptrace32
 1.34 20-May-2008  njoly branches: 1.34.2;
Add compat linux32 ipc(2) syscall support, for shared memory and
semaphores.
 1.33 17-Apr-2008  njoly branches: 1.33.2; 1.33.4; 1.33.6;
Add compat linux32 sys_clock_{getres,gettime,settime} syscalls.
 1.32 04-Apr-2008  njoly Add msync(2) syscall.
 1.31 20-Feb-2008  njoly branches: 1.31.6;
Add mlock/munlock syscalls
 1.30 17-Feb-2008  njoly pread/pwrite fixes: use SCARG_P32 to access pointers, and update
syscalls definitions.
 1.29 04-Feb-2008  dsl Use the same function to implement linux32_sys_fcntl() and linux_sys_fcntl64().
A rather excessive amount of 'appending 64' to names seems to have happened
when linux won support for files > 4G.
technically the linux32_sys_fcntl() function should error the 64bit file
locking requests - but life is too short.
 1.28 02-Feb-2008  dsl Impletemt pread() and pwrite().
 1.27 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.26 07-Jan-2008  njoly Remove wrong linux32_sys_mmap2_args define.
 1.25 26-Dec-2007  njoly Add readdir syscall.
 1.24 24-Dec-2007  njoly Add old_uname syscall.
 1.23 24-Dec-2007  njoly Add getpgid syscall.
 1.22 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.21 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.20 16-Nov-2007  njoly branches: 1.20.2; 1.20.6;
Update, for linux_sys_readlink() removal.
 1.19 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.18 31-Oct-2007  dsl branches: 1.18.2;
This file must use the netbsd32_xxx() system calls, not the sys_xxx() ones.
The latter actually function (due to luck) for calls with one argument,
but will fail badly if more than one is required.
Noticed as an error in the ktrace outut by Nicolas Joly, reported on
tech-kern.
 1.17 31-Oct-2007  njoly compat linux32 syscalls cleanup.

With stackgap and CHECK_ALT_xxx removal, some linux32 and netbsd32
syscalls are now identical.
To avoid code duplication, remove the linux32 definition and use the
netbsd32 one (no functional change).
 1.16 27-Oct-2007  njoly Add missing chown's syscalls family members.
This makes chown(1)/chgrp(1) works under compat linux32.

Problem reported and fix tested by Arto Huusko. Thanks.
 1.15 20-Apr-2007  njoly branches: 1.15.6; 1.15.8; 1.15.12;
Fix ftruncate syscall. Do not use compat_43_sys_ftruncate, but
compat_43_netbsd32_oftruncate instead.
 1.14 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.13 05-Mar-2007  christos branches: 1.13.2; 1.13.4;
fix caddr_t lossage.
 1.12 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 16-Feb-2007  njoly branches: 1.11.2;
Add support for a few syscalls:
setfsuid16/getfsuid16
setfsuid/getfsuid
sched_yield

ok by manu
 1.10 09-Feb-2007  ad Merge newlock2 to head.
 1.9 08-Feb-2007  njoly Remove some aliases, for syscalls that use their netbsd32 equivalent.
This makes the ktrace output more consistent.

ok by manu.
 1.8 07-Feb-2007  njoly Use netbsd32_pollfdp_t instead of wrong `struct pollfd *'.

ok by manu.
 1.7 13-Sep-2006  manu branches: 1.7.4;
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.6 06-Sep-2006  manu branches: 1.6.2; 1.6.4;
Implement Linux's fdatasync, patch from Nicolas Joly
 1.5 06-Sep-2006  manu Fix linux32_sys_setres{uid|gid}: -1 does not means the same thing on i386
and amd64...
 1.4 05-Sep-2006  manu typo
 1.3 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.2 15-Feb-2006  manu branches: 1.2.2; 1.2.4; 1.2.10; 1.2.14; 1.2.16;
Add getcwd (for real this time), fix dup and dup2
 1.1 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.2.16.12 27-Feb-2008  yamt sync with head.
 1.2.16.11 11-Feb-2008  yamt sync with head.
 1.2.16.10 04-Feb-2008  yamt sync with head.
 1.2.16.9 21-Jan-2008  yamt sync with head
 1.2.16.8 07-Dec-2007  yamt sync with head
 1.2.16.7 15-Nov-2007  yamt sync with head.
 1.2.16.6 27-Oct-2007  yamt sync with head.
 1.2.16.5 03-Sep-2007  yamt sync with head.
 1.2.16.4 26-Feb-2007  yamt sync with head.
 1.2.16.3 30-Dec-2006  yamt sync with head.
 1.2.16.2 21-Jun-2006  yamt sync with head.
 1.2.16.1 15-Feb-2006  yamt file syscalls.master was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.2.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.2.10.2 22-Apr-2006  simonb Sync with head.
 1.2.10.1 15-Feb-2006  simonb file syscalls.master was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.2.4.2 14-Sep-2006  yamt sync with head.
 1.2.4.1 26-Jun-2006  yamt sync with head.
 1.2.2.2 18-Feb-2006  yamt sync with head.
 1.2.2.1 15-Feb-2006  yamt file syscalls.master was added on branch yamt-uio_vmspace on 2006-02-18 15:38:59 +0000
 1.6.4.2 09-Sep-2006  rpaulo sync with head
 1.6.4.1 06-Sep-2006  rpaulo file syscalls.master was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:45:52 +0000
 1.6.2.3 09-Feb-2007  ad Sync with HEAD.
 1.6.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.6.2.1 18-Nov-2006  ad Sync with head.
 1.7.4.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.7.4.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #544):
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.11
Add support for a few syscalls:
setfsuid16/getfsuid16
setfsuid/getfsuid
sched_yield
ok by manu
 1.11.2.2 07-May-2007  yamt sync with head.
 1.11.2.1 15-Apr-2007  yamt sync with head.
 1.13.4.1 11-Jul-2007  mjf Sync with head.
 1.13.2.1 27-May-2007  ad Sync with head.
 1.15.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.15.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.15.8.4 23-Mar-2008  matt sync with HEAD
 1.15.8.3 09-Jan-2008  matt sync with HEAD
 1.15.8.2 08-Nov-2007  matt sync with -HEAD
 1.15.8.1 06-Nov-2007  matt sync with HEAD
 1.15.6.5 21-Nov-2007  joerg Sync with HEAD.
 1.15.6.4 11-Nov-2007  joerg Sync with HEAD.
 1.15.6.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.15.6.2 31-Oct-2007  joerg Sync with HEAD.
 1.15.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.18.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.18.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.18.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.20.6.3 19-Jan-2008  bouyer Sync with HEAD
 1.20.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.20.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.20.2.1 26-Dec-2007  ad Sync with head.
 1.31.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.31.6.3 28-Sep-2008  mjf 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.33.6.5 10-Oct-2008  skrll Sync with HEAD.
 1.33.6.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.6.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.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.33.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.33.4.4 11-Aug-2010  yamt sync with head.
 1.33.4.3 11-Mar-2010  yamt sync with head
 1.33.4.2 20-Jun-2009  yamt sync with head
 1.33.4.1 04-May-2009  yamt sync with head.
 1.33.2.2 17-Jun-2008  yamt sync with head.
 1.33.2.1 04-Jun-2008  yamt sync with head
 1.34.2.2 28-Jul-2008  simonb Sync with head.
 1.34.2.1 18-Jun-2008  simonb Sync with head.
 1.35.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.35.2.1 19-Oct-2008  haad Sync with HEAD.
 1.38.4.2 18-Mar-2015  snj Pull up following revision(s) (requested by joerg in ticket #1149):
sys/compat/linux32/arch/amd64/syscalls.master: revisions 1.52, 1.53 via patch
sys/compat/linux32/common/linux32_misc.c: revision 1.17 via patch
sys/compat/linux32/common/linux32_stat.c: revision 1.14-1.16 via patch
Fix inverted lst_ino/__lst_ino assignment in linux32_from_stat().
--
Cleanup (no functional changes).
Kill some unneeded variables and return stattement.
Rename linux32_from_stat() to better bsd_to_linux32_stat64().
Fix some types.
Add stat/lstat/fstat syscalls.
--
Add fstatfs syscall.
 1.38.4.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.38.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.38.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.44.2.2 04-Jan-2009  christos use compat_50 syscalls where appropriate.
 1.44.2.1 12-Dec-2008  christos file syscalls.master was added on branch christos-time_t on 2009-01-04 01:58:39 +0000
 1.50.2.1 23-Jul-2009  jym Sync with HEAD.
 1.55.4.3 31-May-2011  rmind sync with head
 1.55.4.2 21-Apr-2011  rmind sync with head
 1.55.4.1 05-Mar-2011  rmind sync with head
 1.55.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.55.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.57.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.59.4.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.59.4.3 30-Oct-2012  yamt sync with head
 1.59.4.2 23-May-2012  yamt sync with head.
 1.59.4.1 17-Apr-2012  yamt sync with head
 1.60.6.2 20-Jul-2012  riz Pull up following revision(s) (requested by christos in ticket #424):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.67
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.62
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.67
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.67
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.67
add xattr stubs
regen
 1.60.6.1 19-May-2012  riz Pull up following revision(s) (requested by christos in ticket #263):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.66
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.61
sys/compat/linux32/common/linux32_signal.c: revision 1.16
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.66
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.66
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.66
regen
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.60.4.1 02-Jun-2012  mrg sync to latest -current.
 1.62.4.1 18-May-2014  rmind sync with head
 1.62.2.2 03-Dec-2017  jdolecek update from HEAD
 1.62.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.65.2.1 10-Aug-2014  tls Rebase.
 1.68.2.1 06-Apr-2015  skrll Sync with HEAD
 1.69.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.71.2.3 03-Jan-2021  thorpej Add preadv(2) and pwritev(2).
 1.71.2.2 17-Dec-2020  thorpej Add POSIX timer and timerfd support to COMPAT_LINUX32.
 1.71.2.1 16-Dec-2020  thorpej Add eventfd glue to COMPAT_LINUX32.
 1.20 23-Aug-2019  maxv Fix info leaks.
 1.19 03-Sep-2018  riastradh branches: 1.19.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.18 28-Jul-2017  riastradh branches: 1.18.2; 1.18.4;
Fail, don't panic, on bad dirents from file system.

Controllable via puffs from userland.

From Ilja Van Sprundel.
 1.17 28-Jan-2017  christos branches: 1.17.6;
avoid the shadow
 1.16 28-Jan-2017  christos we have space for one more.
 1.15 28-Jan-2017  christos fix size computation
 1.14 13-Jan-2017  christos branches: 1.14.2;
convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
 1.13 14-Oct-2011  hannken branches: 1.13.8; 1.13.12; 1.13.14; 1.13.22; 1.13.28; 1.13.30; 1.13.32; 1.13.34; 1.13.38;
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.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 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.10 03-Mar-2010  he branches: 1.10.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.9 22-Jul-2009  njoly branches: 1.9.2;
Make compat linux/linux32 getdents(2) fail with ENOTDIR instead of
EINVAL when file descriptor does not refer to a directory.
 1.8 29-Dec-2008  njoly branches: 1.8.2;
s/syscallcarg/syscallarg/ in comments.
 1.7 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.6 04-Sep-2008  njoly branches: 1.6.2; 1.6.4; 1.6.8;
Make linux32 getdents(2) do its own job instead of calling the
corresponding compat linux function, where struct dirent members types
differs.
 1.5 26-Dec-2007  njoly branches: 1.5.6; 1.5.10; 1.5.12; 1.5.16;
Add readdir syscall.
 1.4 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.3 08-Dec-2007  dsl branches: 1.3.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.2 09-Feb-2007  ad branches: 1.2.18; 1.2.20; 1.2.26; 1.2.28;
Merge newlock2 to head.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_dirent.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.16.4 21-Jan-2008  yamt sync with head
 1.1.16.3 26-Feb-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 linux32_dirent.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_dirent.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_dirent.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.28.1 26-Dec-2007  ad Sync with head.
 1.2.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.20.1 09-Jan-2008  matt sync with HEAD
 1.2.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.5.16.1 19-Oct-2008  haad Sync with HEAD.
 1.5.12.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.12.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.5.12.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.5.10.5 09-Oct-2010  yamt sync with head
 1.5.10.4 11-Aug-2010  yamt sync with head.
 1.5.10.3 11-Mar-2010  yamt sync with head
 1.5.10.2 19-Aug-2009  yamt sync with head.
 1.5.10.1 04-May-2009  yamt sync with head.
 1.5.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.5.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.8.1 21-Apr-2010  matt sync to netbsd-5
 1.6.4.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.6.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.2.1 23-Jul-2009  jym Sync with HEAD.
 1.9.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.9.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.10.2.2 05-Mar-2011  rmind sync with head
 1.10.2.1 03-Jul-2010  rmind sync with head
 1.13.38.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.13.38.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.13.34.1 20-Mar-2017  pgoyette Sync with HEAD
 1.13.32.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.13.30.2 28-Aug-2017  skrll Sync with HEAD
 1.13.30.1 05-Feb-2017  skrll Sync with HEAD
 1.13.28.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.13.28.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.13.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.13.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.13.12.1 03-Dec-2017  jdolecek update from HEAD
 1.13.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.14.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.17.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.17.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.18.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.4.1 10-Jun-2019  christos Sync with HEAD
 1.18.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.19.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.2 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.14; 1.1.16;
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.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_emuldata.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_emuldata.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 26-Jun-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_emuldata.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_errno.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_errno.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_errno.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_errno.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.24 10-Aug-2018  pgoyette 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.23 06-May-2018  kamil branches: 1.23.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.22 09-Jan-2018  maya branches: 1.22.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.21 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.20 07-Jul-2010  chs branches: 1.20.8; 1.20.12;
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.19 25-Oct-2009  rmind branches: 1.19.2; 1.19.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).
 1.18 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.17 17-Dec-2008  cegger branches: 1.17.2;
kill MALLOC and FREE macros.
 1.16 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.15 15-Oct-2008  wrstuden branches: 1.15.2;
Merge wrstuden-revivesa into HEAD.
 1.14 05-Sep-2008  tron Compile NetBSD/amd64 kernels with "-Wextra". Patches contributed by
Juan RP in PR port-amd64/39266.
 1.13 28-Apr-2008  martin branches: 1.13.2; 1.13.6;
Remove clause 3 and 4 from TNF licenses
 1.12 26-Apr-2008  njoly branches: 1.12.2;
Remove a duplicate mutex_enter call in linux32_e_proc_init().
Fix a kernel panic for processes created with FORK_SHAREVM.
 1.11 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.10 23-Apr-2008  ad Catch up with linux.
 1.9 08-Dec-2007  dsl branches: 1.9.12; 1.9.14;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.8 04-Dec-2007  dsl Remove all the __P
 1.7 19-Oct-2007  ad branches: 1.7.2; 1.7.4;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.6 05-Mar-2007  christos branches: 1.6.2; 1.6.14; 1.6.16; 1.6.20;
more caddr_t lossage.
 1.5 15-Feb-2007  ad branches: 1.5.2;
Fix COMPAT_LINUX32.
 1.4 09-Feb-2007  ad Merge newlock2 to head.
 1.3 23-Aug-2006  manu branches: 1.3.2; 1.3.4;
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.2 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.14; 1.1.16;
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.16.8 21-Jan-2008  yamt sync with head
 1.1.16.7 07-Dec-2007  yamt sync with head
 1.1.16.6 27-Oct-2007  yamt sync with head.
 1.1.16.5 03-Sep-2007  yamt sync with head.
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_exec.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_exec.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.2 03-Sep-2006  yamt sync with head.
 1.1.4.1 26-Jun-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_exec.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.4.2 09-Sep-2006  rpaulo sync with head
 1.3.4.1 23-Aug-2006  rpaulo file linux32_exec.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.3.2.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.5.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.20.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.16.2 09-Jan-2008  matt sync with HEAD
 1.6.16.1 06-Nov-2007  matt sync with HEAD
 1.6.14.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.6.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.6.2.1 23-Oct-2007  ad Sync with head.
 1.7.4.2 26-Dec-2007  ad Sync with head.
 1.7.4.1 08-Dec-2007  ad Sync with head.
 1.7.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.7.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.14.1 18-May-2008  yamt sync with head.
 1.9.12.3 17-Jan-2009  mjf Sync with HEAD.
 1.9.12.2 28-Sep-2008  mjf Sync with HEAD.
 1.9.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.2.4 11-Aug-2010  yamt sync with head.
 1.12.2.3 11-Mar-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.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.6.1 19-Oct-2008  haad Sync with HEAD.
 1.13.2.4 24-Sep-2008  skrll Some build fixes.
 1.13.2.3 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.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.13.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.15.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.15.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.19.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.20.12.1 24-Feb-2012  mrg sync to -current.
 1.20.8.1 17-Apr-2012  yamt sync with head
 1.22.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.22.2.1 21-May-2018  pgoyette Sync with HEAD
 1.23.2.1 10-Jun-2019  christos Sync with HEAD
 1.9 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.8 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.7 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.6 10-Dec-2009  matt branches: 1.6.2; 1.6.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.5 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.4 04-Dec-2007  dsl branches: 1.4.12; 1.4.16; 1.4.22; 1.4.24;
Remove all the __P
 1.3 23-Aug-2006  manu branches: 1.3.4; 1.3.28; 1.3.30; 1.3.36; 1.3.40;
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.2 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16;
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.16.4 07-Dec-2007  yamt sync with head
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_exec.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_exec.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.2 03-Sep-2006  yamt sync with head.
 1.1.4.1 11-Aug-2006  yamt sync with head
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_exec.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.40.1 08-Dec-2007  ad Sync with head.
 1.3.36.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.30.1 09-Jan-2008  matt sync with HEAD
 1.3.28.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.4.2 09-Sep-2006  rpaulo sync with head
 1.3.4.1 23-Aug-2006  rpaulo file linux32_exec.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.4.24.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.22.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.16.3 11-Aug-2010  yamt sync with head.
 1.4.16.2 11-Mar-2010  yamt sync with head
 1.4.16.1 04-May-2009  yamt sync with head.
 1.4.12.1 17-Jan-2009  mjf Sync with HEAD.
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.6.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.23 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.22 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.21 25-Nov-2021  ryo Extra arguments for AT_HWCAP and AT_PLATFORM are now passed when executing linux32 binaries.

AT_SYSINFO (vsyscall) feature seems to be broken, so leave it commented out.
 1.20 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.19 06-Aug-2016  maxv branches: 1.19.8; 1.19.20;
The way the kernel tries to prevent a userland process from allocating page
zero is hugely flawed. It is easy to demonstrate that one can trick UVM
into chosing a NULL hint after the user_va0_disable check from uvm_map.
Such a bypass allows kernel NULL pointer dereferences to be exploitable on
architectures with a shared userland<->kernel VA, like amd64.

Fix this by increasing the limit of the vm space made available for
userland processes. This way, UVM will never chose a NULL hint, since it
would be outside of the vm space.

The user_va0_disable sysctl still controls this feature.
 1.18 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.17 23-Feb-2014  njoly branches: 1.17.4; 1.17.6;
Use Aux32Info not AuxInfo. Noticed by Maxime Villard.
 1.16 23-Feb-2014  njoly Fix wrong KASSERTs. Do not compare size vs. entries count.
 1.15 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.14 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.13 03-Feb-2012  matt branches: 1.13.6; 1.13.10;
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.12 11-Sep-2010  chs branches: 1.12.8; 1.12.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.11 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.10 18-Apr-2010  jym This patch fixes the NX regression issue observed on amd64 kernels, where
per-page execution right was disabled (therefore leading to the inability
of the kernel to detect fraudulent use of memory mappings marked as not
being executable).

- replace cpu_feature and ci_feature_flags variables by cpu_feature and
ci_feat_val arrays. This makes it cleaner and brings kernel code closer
to the design of cpuctl(8). A warning will be raised for each CPU that
does not expose the same features as the Boot Processor (BP).

- the blacklist of CPU features is now a macro defined in the
specialreg.h header, instead of hardcoding it inside MD initialization
code; fix comments.

- replace checks against CPUID_TSC with the cpu_hascounter() function.

- clean up the code in init_x86_64(), as cpu_feature variables are set
inside cpu_probe().

- use cpu_init_msrs() for i386. It will be eventually used later for NX
feature under i386 PAE kernels.

- remove code that checks for CPUID_NOX in amd64 mptramp.S, this is already
performed by cpu_hatch() through cpu_init_msrs().

- remove cpu_signature and feature_flags members from struct mpbios_proc
(they were never used).

This patch was tested with i386 MONOLITHIC, XEN3PAE_DOM0 and XEN3_DOM0 under
a native i386 host, and amd64 GENERIC, XEN3_DOM0 via QEMU virtual machines.

XXX Should kernel rev be bumped?

XXX A similar patch should be pulled-up for NetBSD-5, hopefully tomorrow.
 1.9 15-Mar-2009  cegger branches: 1.9.2; 1.9.4;
ansify function definitions
 1.8 28-Apr-2008  martin branches: 1.8.8; 1.8.14;
Remove clause 3 and 4 from TNF licenses
 1.7 22-Apr-2007  dsl branches: 1.7.28; 1.7.30; 1.7.32;
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.6 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.5 07-Aug-2006  manu branches: 1.5.6; 1.5.12; 1.5.16; 1.5.18; 1.5.20;
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.4 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.3 13-Jun-2006  skd branches: 1.3.4;
include kauth.h
workaround a gcc4 warning.
 1.2 14-May-2006  elad branches: 1.2.2;
integrate kauth.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
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.10.3 01-Jun-2006  kardel Sync with head.
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_exec_elf32.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.8.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.6.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.1.4.3 11-Aug-2006  yamt sync with head
 1.1.4.2 26-Jun-2006  yamt sync with head.
 1.1.4.1 24-May-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_exec_elf32.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.2.1 19-Jun-2006  chap Sync with head.
 1.3.4.4 03-Sep-2007  yamt sync with head.
 1.3.4.3 30-Dec-2006  yamt sync with head.
 1.3.4.2 21-Jun-2006  yamt sync with head.
 1.3.4.1 13-Jun-2006  yamt file linux32_exec_elf32.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.5.20.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.5.18.1 11-Jul-2007  mjf Sync with head.
 1.5.16.2 27-May-2007  ad Sync with head.
 1.5.16.1 10-Apr-2007  ad Sync with head.
 1.5.12.2 07-May-2007  yamt sync with head.
 1.5.12.1 24-Mar-2007  yamt sync with head.
 1.5.6.2 09-Sep-2006  rpaulo sync with head
 1.5.6.1 07-Aug-2006  rpaulo file linux32_exec_elf32.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.7.32.4 09-Oct-2010  yamt sync with head
 1.7.32.3 11-Aug-2010  yamt sync with head.
 1.7.32.2 04-May-2009  yamt sync with head.
 1.7.32.1 16-May-2008  yamt sync with head.
 1.7.30.1 18-May-2008  yamt sync with head.
 1.7.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.4.2 05-Mar-2011  rmind sync with head
 1.9.4.1 30-May-2010  rmind sync with head
 1.9.2.3 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.9.2.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.9.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.12.12.1 18-Feb-2012  mrg merge to -current.
 1.12.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.12.8.1 17-Apr-2012  yamt sync with head
 1.13.10.1 18-May-2014  rmind sync with head
 1.13.6.2 03-Dec-2017  jdolecek update from HEAD
 1.13.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.2 05-Oct-2016  skrll Sync with HEAD
 1.17.6.1 06-Apr-2015  skrll Sync with HEAD
 1.17.4.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.19.20.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.19.8.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.11 25-Nov-2021  ryo - Use LINUX32_F_xxx instead of LINUX_F_xxx for compat_linux32.
aarch64 and arm have different values.
- Compile linux32_sys_fadvise64() only if the syscall is required.
 1.10 17-May-2014  njoly Fix fadvise64 syscalls. Unlike our, linux fadvise syscall do not
return error code; call do_posix_fadvise().
 1.9 30-May-2011  alnsn branches: 1.9.14; 1.9.18; 1.9.28;
Add fadvise64 and fadvise64_64 syscalls to compat_linux and compat_linux32.
 1.8 29-Dec-2008  njoly branches: 1.8.6; 1.8.8;
s/syscallcarg/syscallarg/ in comments.
 1.7 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.6 04-Feb-2008  dsl branches: 1.6.6; 1.6.10; 1.6.12; 1.6.16; 1.6.18;
Use the same function to implement linux32_sys_fcntl() and linux_sys_fcntl64().
A rather excessive amount of 'appending 64' to names seems to have happened
when linux won support for files > 4G.
technically the linux32_sys_fcntl() function should error the 64bit file
locking requests - but life is too short.
 1.5 02-Feb-2008  dsl 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.4 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.3 08-Dec-2007  dsl branches: 1.3.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.2 09-Feb-2007  ad branches: 1.2.18; 1.2.20; 1.2.26; 1.2.28;
Merge newlock2 to head.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_fcntl.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.16.6 11-Feb-2008  yamt sync with head.
 1.1.16.5 04-Feb-2008  yamt sync with head.
 1.1.16.4 21-Jan-2008  yamt sync with head
 1.1.16.3 26-Feb-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 linux32_fcntl.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_fcntl.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_fcntl.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.28.1 26-Dec-2007  ad Sync with head.
 1.2.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.20.2 23-Mar-2008  matt sync with HEAD
 1.2.20.1 09-Jan-2008  matt sync with HEAD
 1.2.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.12.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.6.12.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.6.10.1 04-May-2009  yamt sync with head.
 1.6.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.8.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.6.1 31-May-2011  rmind sync with head
 1.9.28.1 10-Aug-2014  tls Rebase.
 1.9.18.1 18-May-2014  rmind sync with head
 1.9.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1 25-Nov-2021  ryo - Use LINUX32_F_xxx instead of LINUX_F_xxx for compat_linux32.
aarch64 and arm have different values.
- Compile linux32_sys_fadvise64() only if the syscall is required.
 1.15 19-Sep-2021  thorpej Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.14 23-Aug-2019  maxv branches: 1.14.8;
Put the printf under DEBUG_LINUX.
 1.13 18-Aug-2009  christos branches: 1.13.38; 1.13.50; 1.13.56; 1.13.64; 1.13.68;
add the video ioctls so that the 32 bit skype works with video
more commits to come
 1.12 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.11 19-Jun-2008  christos branches: 1.11.2; 1.11.4;
an attempt at linux32_ioctl_socket().
 1.10 22-Jan-2008  jmcneill branches: 1.10.6; 1.10.10; 1.10.12; 1.10.14;
Add ossaudio support for COMPAT_LINUX32, with help from mrg. With this
change, audio now works on amd64 with native firefox, nspluginwrapper, and
the 32-bit linux flash binaries.
 1.9 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.8 08-Dec-2007  dsl branches: 1.8.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.7 18-Mar-2007  dsl branches: 1.7.8; 1.7.10; 1.7.16; 1.7.18;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.6 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.5 04-Mar-2007  christos branches: 1.5.2; 1.5.4; 1.5.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 13-Sep-2006  manu branches: 1.4.4; 1.4.6; 1.4.10;
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.3 25-Aug-2006  manu branches: 1.3.2; 1.3.4;
Add support for socket ioctl.
 1.2 15-Feb-2006  manu branches: 1.2.2; 1.2.4; 1.2.10; 1.2.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.1 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.2.16.6 04-Feb-2008  yamt sync with head.
 1.2.16.5 21-Jan-2008  yamt sync with head
 1.2.16.4 03-Sep-2007  yamt sync with head.
 1.2.16.3 30-Dec-2006  yamt sync with head.
 1.2.16.2 21-Jun-2006  yamt sync with head.
 1.2.16.1 15-Feb-2006  yamt file linux32_ioctl.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.2.10.2 22-Apr-2006  simonb Sync with head.
 1.2.10.1 15-Feb-2006  simonb file linux32_ioctl.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.2.4.2 14-Sep-2006  yamt sync with head.
 1.2.4.1 03-Sep-2006  yamt sync with head.
 1.2.2.2 18-Feb-2006  yamt sync with head.
 1.2.2.1 15-Feb-2006  yamt file linux32_ioctl.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.4.2 09-Sep-2006  rpaulo sync with head
 1.3.4.1 25-Aug-2006  rpaulo file linux32_ioctl.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.3.2.1 18-Nov-2006  ad Sync with head.
 1.4.10.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.4.6.2 24-Mar-2007  yamt sync with head.
 1.4.6.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.4.1 20-Aug-2008  bouyer Pull up following revision(s) (requested by jmcneill in ticket #1051):
sys/compat/linux32/common/linux32_ioctl.c: revision 1.10 via patch
sys/compat/ossaudio/ossaudiovar.h: revision 1.14
Add ossaudio support for COMPAT_LINUX32, with help from mrg. With this
change, audio now works on amd64 with native firefox, nspluginwrapper, and
the 32-bit linux flash binaries.
 1.5.6.2 29-Mar-2007  reinoud Pullup to -current
 1.5.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.5.4.1 11-Jul-2007  mjf Sync with head.
 1.5.2.1 10-Apr-2007  ad Sync with head.
 1.7.18.1 26-Dec-2007  ad Sync with head.
 1.7.16.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.10.2 23-Mar-2008  matt sync with HEAD
 1.7.10.1 09-Jan-2008  matt sync with HEAD
 1.7.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.4.2 23-Jan-2008  bouyer Sync with HEAD.
 1.8.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.10.14.1 27-Jun-2008  simonb Sync with head.
 1.10.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.10.2 19-Aug-2009  yamt sync with head.
 1.10.10.1 04-May-2009  yamt sync with head.
 1.10.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.10.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.11.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.68.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.13.64.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.56.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.13.50.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.13.38.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.14.8.1 03-Jan-2021  thorpej Handle timerfd ioctls.
 1.6 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.5 19-Jun-2008  christos an attempt at linux32_ioctl_socket().
 1.4 28-Apr-2008  martin branches: 1.4.2; 1.4.4;
Remove clause 3 and 4 from TNF licenses
 1.3 20-Dec-2007  dsl branches: 1.3.6; 1.3.8; 1.3.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.2 04-Dec-2007  dsl branches: 1.2.4;
Remove all the __P
 1.1 15-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;
- 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.1.58.2 26-Dec-2007  ad Sync with head.
 1.1.58.1 08-Dec-2007  ad Sync with head.
 1.1.54.2 27-Dec-2007  mjf 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 15-Feb-2006  rpaulo file linux32_ioctl.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.16.4 21-Jan-2008  yamt sync with head
 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 15-Feb-2006  yamt file linux32_ioctl.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 15-Feb-2006  simonb file linux32_ioctl.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 15-Feb-2006  yamt file linux32_ioctl.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.10.2 04-May-2009  yamt sync with head.
 1.3.10.1 16-May-2008  yamt sync with head.
 1.3.8.1 18-May-2008  yamt sync with head.
 1.3.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.3.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.4.1 27-Jun-2008  simonb Sync with head.
 1.4.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4 20-Nov-2009  njoly Make linux32_msqid_ds l_msg_[src]time members use the right type,
linux32_time_t.
 1.3 16-Nov-2009  joerg Follow up commit to fix breakage that somehow passed by the compiler.
 1.2 16-Nov-2009  joerg Add SYSVMSG support for linux32.
 1.1 20-May-2008  njoly branches: 1.1.2; 1.1.4; 1.1.8; 1.1.22;
Add compat linux32 ipc(2) syscall support, for shared memory and
semaphores.
 1.1.22.3 11-Mar-2010  yamt sync with head
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 20-May-2008  yamt file linux32_ipc.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:23 +0000
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 20-May-2008  wrstuden file linux32_ipc.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2 04-Jun-2008  yamt sync with head
 1.1.4.1 20-May-2008  yamt file linux32_ipc.h was added on branch yamt-pf42 on 2008-06-04 02:05:04 +0000
 1.1.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1 20-May-2008  mjf file linux32_ipc.h was added on branch mjf-devfs2 on 2008-06-02 13:23:04 +0000
 1.12 21-Feb-2019  mrg 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.11 29-May-2010  dholland branches: 1.11.34; 1.11.38; 1.11.46; 1.11.52; 1.11.60;
Fix build without sysvipc configured, from Wolfgang Stukenbrock in PR 43376,
adjusted for current.
 1.10 05-Jan-2010  mbalmer branches: 1.10.2; 1.10.4;
Remove extra semicolon.
 1.9 18-Nov-2009  njoly Make compat linux/linux32 msgrcv_msgarg type member of type
long/netbsd32_long to match linux definition.
 1.8 18-Nov-2009  njoly Make linux32 msgsnd/msgrcv use the netbsd32 syscalls instead of native
ones, to ensure that msgbuf mtype member will be of the right type.
 1.7 18-Nov-2009  njoly Kill noisy debug printf.
 1.6 16-Nov-2009  joerg Follow up commit to fix breakage that somehow passed by the compiler.
 1.5 16-Nov-2009  joerg Add SYSVMSG support for linux32.
 1.4 27-Apr-2009  njoly branches: 1.4.2;
Add IPC_64 support to all semctl(2) commands, following corresponding
compat linux change.
 1.3 18-Feb-2009  njoly Add IPC_64 support for all shmctl(2) commands, and reduce diffs with
compat linux version.
 1.2 17-Sep-2008  scw branches: 1.2.2; 1.2.8;
In linux32_shmat() don't try to copyout a 64-bit pointer where userspace
is expecting a 32-bit result.

Fixes nspluginwrapper on amd64.
 1.1 20-May-2008  njoly branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
Add compat linux32 ipc(2) syscall support, for shared memory and
semaphores.
 1.1.10.1 19-Oct-2008  haad Sync with HEAD.
 1.1.8.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 20-May-2008  wrstuden file linux32_ipccall.c was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2 04-Jun-2008  yamt sync with head
 1.1.4.1 20-May-2008  yamt file linux32_ipccall.c was added on branch yamt-pf42 on 2008-06-04 02:05:04 +0000
 1.1.2.3 28-Sep-2008  mjf Sync with HEAD.
 1.1.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1 20-May-2008  mjf file linux32_ipccall.c was added on branch mjf-devfs2 on 2008-06-02 13:23:04 +0000
 1.2.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.4.2.4 11-Aug-2010  yamt sync with head.
 1.4.2.3 11-Mar-2010  yamt sync with head
 1.4.2.2 04-May-2009  yamt sync with head.
 1.4.2.1 27-Apr-2009  yamt file linux32_ipccall.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:23 +0000
 1.10.4.1 30-May-2010  rmind sync with head
 1.10.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.60.1 10-Jun-2019  christos Sync with HEAD
 1.11.52.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.11.46.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.11.38.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.11.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.4 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.3 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.2 04-Dec-2007  dsl branches: 1.2.16; 1.2.36; 1.2.38;
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 linux32_machdep.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +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 linux32_machdep.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_machdep.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_machdep.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.38.1 05-Mar-2011  rmind sync with head
 1.2.36.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.16.1 11-Aug-2010  yamt sync with head.
 1.34 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.33 20-Sep-2021  thorpej Add preadv(2) and pwritev(2) system calls to COMPAT_LINUX and COMPAT_LINUX32.
 1.32 20-Sep-2021  thorpej Add the eventfd system calls to COMPAT_LINUX and COMPAT_LINUX32.
 1.31 19-Sep-2021  thorpej Remove redundant linux32_to_native_timespec() prototype.
 1.30 03-May-2020  thorpej branches: 1.30.2;
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.29 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.28 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.27 23-Aug-2019  maxv Hum, don't forget the 'pid' argument, otherwise we're not gonna go very
far.
 1.26 10-Apr-2017  dholland branches: 1.26.6; 1.26.14; 1.26.18;
Return value pointers should be the last argument.
 1.25 22-Nov-2014  njoly branches: 1.25.2; 1.25.4; 1.25.6;
Add ppoll(2) for compat linux32.
 1.24 09-Nov-2014  maxv Do not uselessly include <sys/malloc.h>.
 1.23 18-Nov-2013  chs branches: 1.23.4;
implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.22 18-Nov-2011  christos branches: 1.22.10; 1.22.14;
add sigtimedwait support
 1.21 02-Nov-2010  chs branches: 1.21.8;
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.20 02-Nov-2010  chs 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.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 24-Nov-2009  njoly branches: 1.18.2; 1.18.4;
Update personality(2) to match Linux definition where the argument is an
unsigned long.
 1.17 05-Jun-2009  njoly Add fstatfs syscall.
 1.16 20-Jan-2009  njoly branches: 1.16.2;
Add basic support for linux32 personality(2) syscall.
 1.15 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.14 12-Nov-2008  njoly Add missing sys/syscall.h include for SYS_ptrace definition.
 1.13 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.12 18-Jun-2008  njoly branches: 1.12.2; 1.12.4; 1.12.6;
linux32_sys_ptrace() fixes.
- Add opt_ptrace.h include to activate syscall.
- Convert to use sys_ptrace() instead of netbsd32_ptrace().
- Do not use arch specific call for now.
 1.11 16-Jun-2008  christos an attempt at ptrace32
 1.10 28-Apr-2008  martin branches: 1.10.2; 1.10.4;
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 08-Dec-2007  dsl branches: 1.8.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.7 30-Apr-2007  dsl branches: 1.7.2; 1.7.8; 1.7.10; 1.7.18;
Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.6 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.5 11-Apr-2007  njoly branches: 1.5.4;
- 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.4 13-Sep-2006  manu branches: 1.4.4; 1.4.8;
This file was not used anymore
 1.3 23-Jul-2006  ad branches: 1.3.4; 1.3.6;
Use the LWP cached credentials where sane.
 1.2 14-May-2006  elad branches: 1.2.6;
integrate kauth.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
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.10.3 01-Jun-2006  kardel Sync with head.
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_misc.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.8.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.6.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.1.6.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.1.4.3 14-Sep-2006  yamt sync with head.
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 24-May-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_misc.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.6.5 21-Jan-2008  yamt sync with head
 1.2.6.4 03-Sep-2007  yamt sync with head.
 1.2.6.3 30-Dec-2006  yamt sync with head.
 1.2.6.2 21-Jun-2006  yamt sync with head.
 1.2.6.1 14-May-2006  yamt file linux32_misc.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.3.6.2 09-Sep-2006  rpaulo sync with head
 1.3.6.1 23-Jul-2006  rpaulo file linux32_misc.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.3.4.1 18-Nov-2006  ad Sync with head.
 1.4.8.1 09-Jun-2007  ad Sync with head.
 1.4.4.2 07-May-2007  yamt sync with head.
 1.4.4.1 15-Apr-2007  yamt sync with head.
 1.5.4.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.5.4.1 11-Apr-2007  bouyer file linux32_misc.c was added on branch netbsd-4 on 2007-04-20 20:26:03 +0000
 1.7.18.1 26-Dec-2007  ad Sync with head.
 1.7.10.1 09-Jan-2008  matt sync with HEAD
 1.7.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.7.2.2 11-Jul-2007  mjf Sync with head.
 1.7.2.1 30-Apr-2007  mjf file linux32_misc.c was added on branch mjf-ufs-trans on 2007-07-11 20:04:23 +0000
 1.8.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.10.5 11-Aug-2010  yamt sync with head.
 1.9.10.4 11-Mar-2010  yamt sync with head
 1.9.10.3 20-Jun-2009  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 17-Jun-2008  yamt sync with head.
 1.9.8.1 18-May-2008  yamt sync with head.
 1.9.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.9.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.9.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.4.2 27-Jun-2008  simonb Sync with head.
 1.10.4.1 18-Jun-2008  simonb Sync with head.
 1.10.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.6.1 18-Mar-2015  snj Pull up following revision(s) (requested by joerg in ticket #1149):
sys/compat/linux32/arch/amd64/syscalls.master: revisions 1.52, 1.53 via patch
sys/compat/linux32/common/linux32_misc.c: revision 1.17 via patch
sys/compat/linux32/common/linux32_stat.c: revision 1.14-1.16 via patch
Fix inverted lst_ino/__lst_ino assignment in linux32_from_stat().
--
Cleanup (no functional changes).
Kill some unneeded variables and return stattement.
Rename linux32_from_stat() to better bsd_to_linux32_stat64().
Fix some types.
Add stat/lstat/fstat syscalls.
--
Add fstatfs syscall.
 1.12.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.12.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.2.1 23-Jul-2009  jym Sync with HEAD.
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.18.2.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.18.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.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.21.8.1 17-Apr-2012  yamt sync with head
 1.22.14.1 18-May-2014  rmind sync with head
 1.22.10.2 03-Dec-2017  jdolecek update from HEAD
 1.22.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.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.23.4.1 17-Jan-2015  martin branches: 1.23.4.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.23.4.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.25.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.25.4.1 26-Apr-2017  pgoyette Sync with HEAD
 1.25.2.1 28-Aug-2017  skrll Sync with HEAD
 1.26.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.26.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.26.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.30.2.3 03-Jan-2021  thorpej Add preadv(2) and pwritev(2).
 1.30.2.2 17-Dec-2020  thorpej Remove a redundant prototype.
 1.30.2.1 16-Dec-2020  thorpej Add eventfd glue to COMPAT_LINUX32.
 1.8 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.7 27-Mar-2008  njoly branches: 1.7.4; 1.7.6; 1.7.10; 1.7.12;
Be sure to not include linux_mmap.h before linux_syscallargs.h.
Otherwise wrong syscallarg macro may used for linux_sys_mmap_args
definition.
This makes mmap2 works again (at least to launch oo2 binary).
 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 08-Dec-2007  dsl branches: 1.5.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.4 31-Oct-2007  njoly branches: 1.4.4;
Remove extra return
 1.3 09-Feb-2007  ad branches: 1.3.18; 1.3.20; 1.3.24;
Merge newlock2 to head.
 1.2 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_mman.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.20.1 18-Nov-2006  ad Sync with head.
 1.1.16.6 21-Jan-2008  yamt sync with head
 1.1.16.5 15-Nov-2007  yamt sync with head.
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_mman.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_mman.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_mman.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.3.20.2 09-Jan-2008  matt sync with HEAD
 1.3.20.1 06-Nov-2007  matt sync with HEAD
 1.3.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.18.1 31-Oct-2007  joerg Sync with HEAD.
 1.4.4.1 26-Dec-2007  ad Sync with head.
 1.5.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.6.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.7.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 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.7.4.1 04-May-2009  yamt sync with head.
 1.15 25-Nov-2021  ryo The default name of the `exec_setup_stack' function for linux32 should be `linux32_exec_setup_stack',
and it should be defined in each arch.
declaration of linux32_exec_setup_stack() in linux32/amd64 has been removed because it does not exist.

NFC.
 1.14 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.13 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.12 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.11 10-Dec-2017  kre branches: 1.11.2; 1.11.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.10 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.9 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.8 29-Sep-2017  maxv Remove compat_linux32 from the autoload list and add a enable/disable
sysctl, like compat_linux.
 1.7 03-Dec-2015  pgoyette Update dependencies - compat_linux32 requires compat_netbsd32_sysvipc
 1.6 22-Jul-2014  maxv branches: 1.6.4;
1) On 64bit systems, don't add the 32bit execsw[] to the global exec array.
exec_elf32 works on 32bit systems only, and will crash 32bit binaries on
64bit systems.
2) Now that exec_elf32 is dormant, we can give the native ELF loaders the
highest priority.

Binaries will load faster now (system boot, compilation, etc.).

With the help of njloy@. Discussed a bit on tech-kern@, no disagreement.
 1.5 07-Mar-2014  christos branches: 1.5.2;
c99 initializers for struct execsw
 1.4 19-Sep-2013  christos exec modules need to be of the exec kind
 1.3 07-Jul-2010  chs branches: 1.3.8; 1.3.18; 1.3.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.2 03-Dec-2008  ad branches: 1.2.4; 1.2.6; 1.2.8; 1.2.12; 1.2.14; 1.2.16;
PR port-amd64/40091 compat_linux32 module loading = panic due to missing syms
 1.1 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.2.16.1 05-Mar-2011  rmind sync with head
 1.2.14.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.2.12.3 11-Aug-2010  yamt sync with head.
 1.2.12.2 04-May-2009  yamt sync with head.
 1.2.12.1 03-Dec-2008  yamt file linux32_mod.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:23 +0000
 1.2.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.8.1 03-Dec-2008  skrll file linux32_mod.c was added on branch nick-hppapmap on 2009-01-19 13:17:32 +0000
 1.2.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.6.1 03-Dec-2008  mjf file linux32_mod.c was added on branch mjf-devfs2 on 2009-01-17 13:28:45 +0000
 1.2.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.4.1 03-Dec-2008  haad file linux32_mod.c was added on branch haad-dm on 2008-12-13 01:13:57 +0000
 1.3.22.1 18-May-2014  rmind sync with head
 1.3.18.2 03-Dec-2017  jdolecek update from HEAD
 1.3.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.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.5.2.1 10-Aug-2014  tls Rebase.
 1.6.4.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.11.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.4.1 10-Jun-2019  christos Sync with HEAD
 1.11.2.5 24-Jan-2019  pgoyette Restore the MD-vs-REQ requirements structure, just in case
 1.11.2.4 24-Jan-2019  pgoyette Clean up and reorganize the requirements for compat_linux32 module
 1.11.2.3 12-Sep-2018  pgoyette Typo - missing trailing quote
 1.11.2.2 12-Sep-2018  pgoyette Adjust module requirements to reflect the new more granular modules
 1.11.2.1 11-Mar-2018  pgoyette Update module dependencies
 1.13 02-Dec-2021  ryo add prlimit64(2) syscall to COMPAT_LINUX and COMPAT_LINUX32
 1.12 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.11 22-Sep-2012  joerg branches: 1.11.30; 1.11.42;
LINUX_RLIM_INFINITY doesn't fit into the value range for linux32, so
introduce a variant with correct value.
 1.10 19-Nov-2008  ad branches: 1.10.16; 1.10.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.9 22-Sep-2008  njoly branches: 1.9.2;
Kill a few linux32 syscalls identical to netbsd32 ones.
No functional changes expected.
 1.8 20-Dec-2007  dsl branches: 1.8.6; 1.8.10; 1.8.12; 1.8.16;
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 08-Dec-2007  dsl branches: 1.7.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.6 12-May-2007  dsl branches: 1.6.6; 1.6.8; 1.6.16;
There is no need to use the stackgap for get/setrlimit.
 1.5 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.4 04-Mar-2007  christos branches: 1.4.2; 1.4.4; 1.4.6;
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 25-Jun-2006  manu branches: 1.2.4; 1.2.6;
- 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.14; 1.1.16;
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.16.6 21-Jan-2008  yamt sync with head
 1.1.16.5 03-Sep-2007  yamt sync with head.
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_resource.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.14.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_resource.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 26-Jun-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_resource.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.6.2 09-Sep-2006  rpaulo sync with head
 1.2.6.1 25-Jun-2006  rpaulo file linux32_resource.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.2.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.3.2.3 17-May-2007  yamt sync with head.
 1.3.2.2 24-Mar-2007  yamt sync with head.
 1.3.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.6.1 29-Mar-2007  reinoud Pullup to -current
 1.4.4.1 11-Jul-2007  mjf Sync with head.
 1.4.2.2 27-May-2007  ad Sync with head.
 1.4.2.1 10-Apr-2007  ad Sync with head.
 1.6.16.1 26-Dec-2007  ad Sync with head.
 1.6.8.1 09-Jan-2008  matt sync with HEAD
 1.6.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.7.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.8.16.1 19-Oct-2008  haad Sync with HEAD.
 1.8.12.3 10-Oct-2008  skrll Sync with HEAD.
 1.8.12.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.8.12.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 04-May-2009  yamt sync with head.
 1.8.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.8.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.9.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.26.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.10.16.1 30-Oct-2012  yamt sync with head
 1.11.42.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.11.30.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.9 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.8 01-Dec-2008  njoly branches: 1.8.6; 1.8.8;
Add sched_get_priority_{min,max} syscalls.
 1.7 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.6 20-Dec-2007  dsl branches: 1.6.6; 1.6.10; 1.6.12; 1.6.16; 1.6.18;
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 08-Dec-2007  dsl branches: 1.5.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.4 07-Nov-2007  njoly branches: 1.4.2;
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.3 09-Feb-2007  ad branches: 1.3.18; 1.3.20; 1.3.24; 1.3.26;
Merge newlock2 to head.
 1.2 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_sched.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.20.1 18-Nov-2006  ad Sync with head.
 1.1.16.6 21-Jan-2008  yamt sync with head
 1.1.16.5 15-Nov-2007  yamt sync with head.
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_sched.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_sched.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_sched.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.26.2 27-Dec-2007  mjf Sync with HEAD.
 1.3.26.1 19-Nov-2007  mjf Sync with HEAD.
 1.3.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.3.20.2 09-Jan-2008  matt sync with HEAD
 1.3.20.1 08-Nov-2007  matt sync with -HEAD
 1.3.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.18.1 11-Nov-2007  joerg Sync with HEAD.
 1.4.2.1 26-Dec-2007  ad Sync with head.
 1.5.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.12.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.6.12.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.6.10.2 11-Aug-2010  yamt sync with head.
 1.6.10.1 04-May-2009  yamt sync with head.
 1.6.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.8.8.1 05-Mar-2011  rmind sync with head
 1.8.6.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.3 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.2 19-Sep-2021  thorpej G/C some unused (and unnecessary) definitions.
 1.1 18-Nov-2011  christos branches: 1.1.8; 1.1.66;
add sigtimedwait support
 1.1.66.1 17-Dec-2020  thorpej Add POSIX timer and timerfd support to COMPAT_LINUX32.
 1.1.8.2 17-Apr-2012  yamt sync with head
 1.1.8.1 18-Nov-2011  yamt file linux32_sched.h was added on branch yamt-pagecache on 2012-04-17 00:07:19 +0000
 1.1 20-May-2008  njoly branches: 1.1.2; 1.1.4; 1.1.8; 1.1.22;
Add compat linux32 ipc(2) syscall support, for shared memory and
semaphores.
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 20-May-2008  yamt file linux32_sem.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:23 +0000
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 20-May-2008  wrstuden file linux32_sem.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2 04-Jun-2008  yamt sync with head
 1.1.4.1 20-May-2008  yamt file linux32_sem.h was added on branch yamt-pf42 on 2008-06-04 02:05:05 +0000
 1.1.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1 20-May-2008  mjf file linux32_sem.h was added on branch mjf-devfs2 on 2008-06-02 13:23:04 +0000
 1.1 20-May-2008  njoly branches: 1.1.2; 1.1.4; 1.1.8; 1.1.22;
Add compat linux32 ipc(2) syscall support, for shared memory and
semaphores.
 1.1.22.2 04-May-2009  yamt sync with head.
 1.1.22.1 20-May-2008  yamt file linux32_shm.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:23 +0000
 1.1.8.2 23-Jun-2008  wrstuden Add files to branch that were added on -current.

After this, all that's left of update is to merge some changes
that had conflicts.
 1.1.8.1 20-May-2008  wrstuden file linux32_shm.h was added on branch wrstuden-revivesa on 2008-06-23 05:02:13 +0000
 1.1.4.2 04-Jun-2008  yamt sync with head
 1.1.4.1 20-May-2008  yamt file linux32_shm.h was added on branch yamt-pf42 on 2008-06-04 02:05:05 +0000
 1.1.2.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.2.1 20-May-2008  mjf file linux32_shm.h was added on branch mjf-devfs2 on 2008-06-02 13:23:04 +0000
 1.2 19-Sep-2021  thorpej Add routines to convert from linux32 to native sigevent_t.
 1.1 17-Dec-2020  thorpej branches: 1.1.2;
file linux32_sigevent.h was initially added on branch thorpej-futex.
 1.1.2.1 17-Dec-2020  thorpej Add sigevent mapping for Linux-32 compat.
 1.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 18-Nov-2011  christos branches: 1.1.8; 1.1.66;
add sigtimedwait support
 1.1.66.1 17-Dec-2020  thorpej Add sigevent mapping for Linux-32 compat.
 1.1.8.2 17-Apr-2012  yamt sync with head
 1.1.8.1 18-Nov-2011  yamt file linux32_siginfo.h was added on branch yamt-pagecache on 2012-04-17 00:07:19 +0000
 1.24 26-Nov-2021  christos Remove #error, fixes the build. I don't understand why this would not work
on big endian. We use this construct to convert pointers everywhere else.
 1.23 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.22 19-Sep-2021  thorpej Add routines to convert from linux32 to native sigevent_t.
 1.21 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.20 23-Aug-2019  maxv branches: 1.20.8;
Fix info leaks in sigaltstack.
 1.19 07-Jan-2018  christos branches: 1.19.4; 1.19.8;
ignore signal 64 for now (go uses it)
XXX: pullup-8
 1.18 08-Mar-2015  christos branches: 1.18.10;
fix inconsistent names
 1.17 18-Nov-2013  chs branches: 1.17.4; 1.17.6; 1.17.12;
implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.16 10-May-2012  christos branches: 1.16.2; 1.16.4;
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.15 18-Nov-2011  christos branches: 1.15.4; 1.15.6;
remove incorrect assertions (the len passed is the size of the bsd structure
not the linux one)
 1.14 18-Nov-2011  christos add sigtimedwait support
 1.13 08-Jun-2009  njoly branches: 1.13.12;
Add rt_queueinfo(2) support.
 1.12 02-Jun-2009  njoly Add siggetmask/sigsetmask syscalls.
 1.11 18-Mar-2009  cegger bzero -> memset
 1.10 20-Jan-2009  christos branches: 1.10.2;
add some debugging.
 1.9 24-Jul-2008  njoly branches: 1.9.2;
Add rt_sigpending syscall.
 1.8 24-Apr-2008  ad branches: 1.8.2; 1.8.4; 1.8.6; 1.8.8;
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.7 20-Dec-2007  dsl branches: 1.7.6; 1.7.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.6 11-Dec-2007  lukem use __KERNEL_RCSID()
 1.5 08-Dec-2007  dsl branches: 1.5.2; 1.5.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.4 18-Mar-2007  dsl branches: 1.4.8; 1.4.10; 1.4.18;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.3 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.2 15-Feb-2007  ad branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10;
Fix COMPAT_LINUX32.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_signal.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 26-Feb-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 linux32_signal.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_signal.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_signal.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.10.2 29-Mar-2007  reinoud Pullup to -current
 1.2.10.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.2.8.1 11-Jul-2007  mjf Sync with head.
 1.2.6.1 10-Apr-2007  ad Sync with head.
 1.2.2.1 24-Mar-2007  yamt sync with head.
 1.4.18.1 26-Dec-2007  ad Sync with head.
 1.4.10.1 09-Jan-2008  matt sync with HEAD
 1.4.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.5.4.2 02-Jan-2008  bouyer Sync with HEAD
 1.5.4.1 13-Dec-2007  bouyer Sync with HEAD
 1.5.2.1 13-Dec-2007  yamt sync with head.
 1.7.8.1 18-May-2008  yamt sync with head.
 1.7.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.7.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.8.1 19-Oct-2008  haad Sync with HEAD.
 1.8.6.1 28-Jul-2008  simonb Sync with head.
 1.8.4.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.2.2 20-Jun-2009  yamt sync with head
 1.8.2.1 04-May-2009  yamt sync with head.
 1.9.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.9.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.10.2.2 23-Jul-2009  jym Sync with HEAD.
 1.10.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.12.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.13.12.2 23-May-2012  yamt sync with head.
 1.13.12.1 17-Apr-2012  yamt sync with head
 1.15.6.1 19-May-2012  riz Pull up following revision(s) (requested by christos in ticket #263):
sys/compat/linux32/arch/amd64/linux32_syscallargs.h: revision 1.66
sys/compat/linux32/arch/amd64/syscalls.master: revision 1.61
sys/compat/linux32/common/linux32_signal.c: revision 1.16
sys/compat/linux32/arch/amd64/linux32_syscall.h: revision 1.66
sys/compat/linux32/arch/amd64/linux32_sysent.c: revision 1.66
sys/compat/linux32/arch/amd64/linux32_syscalls.c: revision 1.66
regen
Fix rt_sigtimedwait():
It is wishful thinking that:
1. declaring a 32 bit syscall with 64 bit pointers
2. passing a struct with 32 bit pointers to a 64 bit function
is going to work.
 1.15.4.1 02-Jun-2012  mrg sync to latest -current.
 1.16.4.1 18-May-2014  rmind sync with head
 1.16.2.2 03-Dec-2017  jdolecek update from HEAD
 1.16.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.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.17.6.1 06-Apr-2015  skrll Sync with HEAD
 1.17.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.18.10.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.18.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.19.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.19.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.19.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.20.8.1 17-Dec-2020  thorpej Add sigevent mapping for Linux-32 compat.
 1.6 27-Nov-2021  ryo Add pselect6(2) system call to COMPAT_LINUX32
 1.5 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.4 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.3 18-Nov-2011  christos add sigtimedwait support
 1.2 04-Dec-2007  dsl branches: 1.2.50;
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 linux32_signal.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +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 linux32_signal.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_signal.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_signal.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.50.1 17-Apr-2012  yamt sync with head
 1.32 24-Dec-2022  andvar s/reqest/request/, s/requst/request/ and s/reuqest/request/ in comments.
 1.31 16-Jul-2020  msaitoh Don't accept negative value.

Reported-by: syzbot+e71a77402d6668f1868d@syzkaller.appspotmail.com
 1.30 18-Apr-2019  christos branches: 1.30.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.29 10-May-2018  ozaki-r branches: 1.29.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.28 22-Nov-2017  ozaki-r branches: 1.28.2;
Fix and make consistent of usages of psz/psref in ifconf variants
 1.27 14-Mar-2017  ozaki-r branches: 1.27.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.26 01-Aug-2016  ozaki-r branches: 1.26.2;
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.25 07-Jul-2016  ozaki-r branches: 1.25.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.24 05-Jul-2016  ozaki-r Fix psref isn't released in a case of IFADDR_EMPTY
 1.23 16-Jun-2016  ozaki-r Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND
 1.22 15-Jun-2016  ozaki-r Protect if_byindex by pserialize
 1.21 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.20 24-Jul-2015  maxv Unused inits (harmless).

Found by Brainy.
 1.19 26-Nov-2014  ozaki-r branches: 1.19.2;
Tweak ifconf variants

The tweaks make the code intention clear and make further changes easy.

No functional change.
 1.18 17-May-2014  rmind branches: 1.18.2; 1.18.4; 1.18.8;
Replace open-coded access (and boundary checking) of ifindex2ifnet with
if_byindex() function.
 1.17 11-Jan-2013  christos branches: 1.17.2; 1.17.10;
Use copyin/copyout and linux-specific ifreq structures (they are the same
as the netbsd ones, but this disconnects them)
 1.16 15-Mar-2012  bouyer branches: 1.16.2;
Do not read past end of array. Found by gcc -03
 1.15 12-Dec-2009  njoly branches: 1.15.12; 1.15.16;
Add missing semicolons after NETBSD32TOx_UAP macro calls.
 1.14 10-Dec-2009  njoly Add SIOCGIFMTU support.
 1.13 10-Dec-2009  njoly Do not give native requests to netbsd32_ioctl(), use the compat
netbsd32 equivalent instead.
 1.12 13-Nov-2009  joerg Return the result of copyout. Reminded by Niolas Joly.
 1.11 13-Nov-2009  joerg Provide SIOCGIFNAME.
 1.10 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.9 23-Jul-2008  njoly branches: 1.9.2; 1.9.4; 1.9.8;
Add linux32_getifconf, following recent linux_getifconf addition.
 1.8 27-Jun-2008  njoly branches: 1.8.2;
Add SIOCGIFHWADDR support.
Tested by Cem Kayali.
 1.7 24-Jun-2008  njoly Fix SIOCGIFCONF ioctl under compat linux32.
 1.6 19-Jun-2008  christos an attempt at linux32_ioctl_socket().
 1.5 20-Dec-2007  dsl branches: 1.5.6; 1.5.10; 1.5.12; 1.5.14;
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.4 08-Dec-2007  dsl branches: 1.4.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.3 09-Feb-2007  ad branches: 1.3.18; 1.3.20; 1.3.28;
Merge newlock2 to head.
 1.2 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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_socket.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.20.1 18-Nov-2006  ad Sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_socket.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_socket.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_socket.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.28.1 26-Dec-2007  ad Sync with head.
 1.3.20.1 09-Jan-2008  matt sync with HEAD
 1.3.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.4.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.14.2 28-Jul-2008  simonb Sync with head.
 1.5.14.1 27-Jun-2008  simonb Sync with head.
 1.5.12.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.12.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.5.12.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.5.10.2 11-Mar-2010  yamt sync with head
 1.5.10.1 04-May-2009  yamt sync with head.
 1.5.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.5.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.5.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.8.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.8.2.1 19-Oct-2008  haad Sync with HEAD.
 1.9.8.1 21-Apr-2010  matt sync to netbsd-5
 1.9.4.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.9.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.16.1 05-Apr-2012  mrg sync to latest -current.
 1.15.12.2 23-Jan-2013  yamt sync with head
 1.15.12.1 17-Apr-2012  yamt sync with head
 1.16.2.3 03-Dec-2017  jdolecek update from HEAD
 1.16.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.1 25-Feb-2013  tls resync with head
 1.17.10.1 10-Aug-2014  tls Rebase.
 1.17.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.18.8.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.18.4.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.18.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.19.2.5 28-Aug-2017  skrll Sync with HEAD
 1.19.2.4 05-Oct-2016  skrll Sync with HEAD
 1.19.2.3 09-Jul-2016  skrll Sync with HEAD
 1.19.2.2 29-May-2016  skrll Sync with HEAD
 1.19.2.1 22-Sep-2015  skrll Sync with HEAD
 1.25.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.25.2.1 06-Aug-2016  pgoyette Sync with HEAD
 1.26.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.27.6.4 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.27.6.3 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.27.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.27.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.28.2.1 21-May-2018  pgoyette Sync with HEAD
 1.29.2.1 10-Jun-2019  christos Sync with HEAD
 1.30.4.1 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.9 21-Jun-2014  maxv 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.8 10-May-2012  christos branches: 1.8.2; 1.8.12;
prefix message with linux32
 1.7 19-Nov-2008  ad branches: 1.7.16; 1.7.20; 1.7.22; 1.7.26; 1.7.28;
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.6 20-Dec-2007  dsl branches: 1.6.6; 1.6.10; 1.6.16; 1.6.18; 1.6.20; 1.6.26; 1.6.30;
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 08-Dec-2007  dsl branches: 1.5.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.4 15-Aug-2007  ad branches: 1.4.2; 1.4.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.3 01-Jun-2007  dsl branches: 1.3.2; 1.3.6;
(Ab)use a KTR_USER trace entry for the linux socket command and arguments.
 1.2 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.28; 1.1.32; 1.1.34; 1.1.36;
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.36.1 29-Mar-2007  reinoud Pullup to -current
 1.1.34.1 11-Jul-2007  mjf Sync with head.
 1.1.32.3 20-Aug-2007  ad Sync with HEAD.
 1.1.32.2 09-Jun-2007  ad Sync with head.
 1.1.32.1 10-Apr-2007  ad Sync with head.
 1.1.28.1 24-Mar-2007  yamt sync with head.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_socketcall.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.16.4 21-Jan-2008  yamt sync with head
 1.1.16.3 03-Sep-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 linux32_socketcall.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_socketcall.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_socketcall.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.3.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.3.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.4.10.1 26-Dec-2007  ad Sync with head.
 1.4.2.1 09-Jan-2008  matt sync with HEAD
 1.5.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.30.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.6.26.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.6.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.6.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.10.1 04-May-2009  yamt sync with head.
 1.6.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.28.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.7.26.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.7.22.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.7.20.1 02-Jun-2012  mrg sync to latest -current.
 1.7.16.1 23-May-2012  yamt sync with head.
 1.8.12.1 10-Aug-2014  tls Rebase.
 1.8.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3 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.2 04-Dec-2007  dsl branches: 1.2.4;
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.2 26-Dec-2007  ad Sync with head.
 1.1.58.1 08-Dec-2007  ad Sync with head.
 1.1.54.2 27-Dec-2007  mjf 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 linux32_socketcall.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.16.4 21-Jan-2008  yamt sync with head
 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 linux32_socketcall.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_socketcall.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_socketcall.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.4 11-Jan-2013  christos Use copyin/copyout and linux-specific ifreq structures (they are the same
as the netbsd ones, but this disconnects them)
 1.3 13-Nov-2009  joerg branches: 1.3.12; 1.3.22;
Provide SIOCGIFNAME.
 1.2 23-Jul-2008  njoly branches: 1.2.2; 1.2.6; 1.2.14; 1.2.16;
Add linux32_getifconf, following recent linux_getifconf addition.
 1.1 27-Jun-2008  njoly branches: 1.1.2; 1.1.4; 1.1.6;
Add SIOCGIFHWADDR support.
Tested by Cem Kayali.
 1.1.6.1 19-Oct-2008  haad Sync with HEAD.
 1.1.4.3 28-Sep-2008  mjf Sync with HEAD.
 1.1.4.2 29-Jun-2008  mjf Sync with HEAD.
 1.1.4.1 27-Jun-2008  mjf file linux32_sockio.h was added on branch mjf-devfs2 on 2008-06-29 09:33:03 +0000
 1.1.2.3 28-Jul-2008  simonb Sync with head.
 1.1.2.2 27-Jun-2008  simonb Sync with head.
 1.1.2.1 27-Jun-2008  simonb file linux32_sockio.h was added on branch simonb-wapbl on 2008-06-27 15:11:19 +0000
 1.2.16.1 21-Apr-2010  matt sync to netbsd-5
 1.2.14.3 11-Mar-2010  yamt sync with head
 1.2.14.2 04-May-2009  yamt sync with head.
 1.2.14.1 23-Jul-2008  yamt file linux32_sockio.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:23 +0000
 1.2.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.2.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.2.1 23-Jul-2008  wrstuden file linux32_sockio.h was added on branch wrstuden-revivesa on 2008-09-18 04:36:45 +0000
 1.3.22.1 25-Feb-2013  tls resync with head
 1.3.12.1 23-Jan-2013  yamt sync with head
 1.18 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.17 18-Nov-2013  chs implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.16 04-Jun-2009  njoly branches: 1.16.12; 1.16.22; 1.16.26;
Add stat/lstat/fstat syscalls.
 1.15 03-Jun-2009  njoly Cleanup (no functional changes).
Kill some unneeded variables and return stattement.
Rename linux32_from_stat() to better bsd_to_linux32_stat64().
Fix some types.
 1.14 03-Jun-2009  njoly Fix inverted lst_ino/__lst_ino assignment in linux32_from_stat().
 1.13 18-Mar-2009  cegger bzero -> memset
 1.12 19-Nov-2008  ad branches: 1.12.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.11 21-Mar-2008  ad branches: 1.11.4; 1.11.6; 1.11.10; 1.11.12; 1.11.14;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.10 20-Dec-2007  dsl branches: 1.10.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.9 08-Dec-2007  dsl branches: 1.9.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.8 22-Apr-2007  dsl branches: 1.8.6; 1.8.8; 1.8.16;
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.7 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.6 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.5 11-Mar-2007  dsl branches: 1.5.2; 1.5.4;
Fix amd64 build for compat sys_stat() changes.
This file isn't included in amd64:GENERIC
 1.4 10-Mar-2007  dsl 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.3 04-Mar-2007  christos branches: 1.3.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 09-Feb-2007  ad branches: 1.2.2;
Merge newlock2 to head.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_stat.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.1.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.16.6 24-Mar-2008  yamt sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 26-Feb-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 linux32_stat.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_stat.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_stat.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.2.3 07-May-2007  yamt sync with head.
 1.2.2.2 24-Mar-2007  yamt sync with head.
 1.2.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.2.3 27-May-2007  ad Sync with head.
 1.3.2.2 10-Apr-2007  ad Sync with head.
 1.3.2.1 13-Mar-2007  ad Sync with head.
 1.5.4.2 29-Mar-2007  reinoud Pullup to -current
 1.5.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.5.2.1 11-Jul-2007  mjf Sync with head.
 1.8.16.1 26-Dec-2007  ad Sync with head.
 1.8.8.1 09-Jan-2008  matt sync with HEAD
 1.8.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.9.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.10.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.10.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.11.14.1 18-Mar-2015  snj Pull up following revision(s) (requested by joerg in ticket #1149):
sys/compat/linux32/arch/amd64/syscalls.master: revisions 1.52, 1.53 via patch
sys/compat/linux32/common/linux32_misc.c: revision 1.17 via patch
sys/compat/linux32/common/linux32_stat.c: revision 1.14-1.16 via patch
Fix inverted lst_ino/__lst_ino assignment in linux32_from_stat().
--
Cleanup (no functional changes).
Kill some unneeded variables and return stattement.
Rename linux32_from_stat() to better bsd_to_linux32_stat64().
Fix some types.
Add stat/lstat/fstat syscalls.
--
Add fstatfs syscall.
 1.11.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.11.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.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.11.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.11.4.2 20-Jun-2009  yamt sync with head
 1.11.4.1 04-May-2009  yamt sync with head.
 1.12.4.2 23-Jul-2009  jym Sync with HEAD.
 1.12.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.26.1 18-May-2014  rmind sync with 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.19 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.18 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.17 29-Sep-2017  maxv branches: 1.17.4;
Remove compat_linux32 from the autoload list and add a enable/disable
sysctl, like compat_linux.
 1.16 16-May-2014  martin Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.15 25-Feb-2014  pooka branches: 1.15.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.14 18-Nov-2013  chs claim to be linux 3.11.6 (opensuse 13.1).
 1.13 07-Jul-2010  chs branches: 1.13.8; 1.13.18; 1.13.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.12 05-Jan-2009  njoly branches: 1.12.4; 1.12.6;
Make sysctl(2) fails with ENOTDIR (instead of EINVAL) for invalid mib
vector length.
 1.11 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.10 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.9 07-Jan-2008  ad branches: 1.9.6; 1.9.10; 1.9.12; 1.9.16; 1.9.18;
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.8 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.7 08-Dec-2007  dsl branches: 1.7.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.6 15-Aug-2007  ad branches: 1.6.2; 1.6.8; 1.6.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.5 18-Mar-2007  dsl branches: 1.5.4; 1.5.8;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.4 09-Feb-2007  ad branches: 1.4.2; 1.4.6; 1.4.8; 1.4.10;
Merge newlock2 to head.
 1.3 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.2 05-Sep-2006  manu branches: 1.2.2; 1.2.4; 1.2.6;
Fix linux32_sys_sysctl, it was horribly broken.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16;
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.16.6 21-Jan-2008  yamt sync with head
 1.1.16.5 03-Sep-2007  yamt sync with head.
 1.1.16.4 26-Feb-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_sysctl.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_sysctl.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_sysctl.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.6.1 22-Oct-2006  yamt sync with head
 1.2.4.2 09-Sep-2006  rpaulo sync with head
 1.2.4.1 05-Sep-2006  rpaulo file linux32_sysctl.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:03 +0000
 1.2.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.2.2.1 18-Nov-2006  ad Sync with head.
 1.4.10.1 29-Mar-2007  reinoud Pullup to -current
 1.4.8.1 11-Jul-2007  mjf Sync with head.
 1.4.6.2 20-Aug-2007  ad Sync with HEAD.
 1.4.6.1 10-Apr-2007  ad Sync with head.
 1.4.2.1 24-Mar-2007  yamt sync with head.
 1.5.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.5.8.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.5.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.6.10.1 26-Dec-2007  ad Sync with head.
 1.6.8.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.2.1 09-Jan-2008  matt sync with HEAD
 1.7.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.7.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.9.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.9.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.9.12.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.9.12.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.10.2 11-Aug-2010  yamt sync with head.
 1.9.10.1 04-May-2009  yamt sync with head.
 1.9.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.12.6.1 05-Mar-2011  rmind sync with head
 1.12.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.22.1 18-May-2014  rmind sync with head
 1.13.18.2 03-Dec-2017  jdolecek update from HEAD
 1.13.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.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.15.2.1 10-Aug-2014  tls Rebase.
 1.17.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6 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.5 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.4 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.3 29-Sep-2017  maxv branches: 1.3.2; 1.3.4;
Remove compat_linux32 from the autoload list and add a enable/disable
sysctl, like compat_linux.
 1.2 19-Nov-2008  ad branches: 1.2.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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22; 1.1.72; 1.1.76; 1.1.82; 1.1.86;
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.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.82.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.76.1 04-May-2009  yamt sync with head.
 1.1.72.1 17-Jan-2009  mjf Sync with HEAD.
 1.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_sysctl.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_sysctl.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_sysctl.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_sysctl.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.26.1 03-Dec-2017  jdolecek update from HEAD
 1.3.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.4.1 10-Jun-2019  christos Sync with HEAD
 1.3.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.14 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.13 11-Jun-2020  ad 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.12 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.11 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.10 31-Dec-2019  ad branches: 1.10.6;
Rename uvm_free() -> uvm_availmem().
 1.9 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.8 23-Aug-2019  maxv Fix info leaks in sysinfo().
 1.7 19-Nov-2008  ad branches: 1.7.42; 1.7.54; 1.7.60; 1.7.68; 1.7.72;
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.6 20-Dec-2007  dsl branches: 1.6.6; 1.6.10; 1.6.12; 1.6.16; 1.6.18;
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 08-Dec-2007  dsl branches: 1.5.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.4 21-Jul-2007  xtraeme branches: 1.4.4; 1.4.6; 1.4.14; 1.4.16;
<sys/proc.h> is needed to get nprocs... fixes the build on amd64.
 1.3 18-Mar-2007  dsl branches: 1.3.4;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.2 09-Feb-2007  ad branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10;
Merge newlock2 to head.
 1.1 13-Sep-2006  manu branches: 1.1.2; 1.1.6; 1.1.10;
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.1.10.5 21-Jan-2008  yamt sync with head
 1.1.10.4 03-Sep-2007  yamt sync with head.
 1.1.10.3 26-Feb-2007  yamt sync with head.
 1.1.10.2 30-Dec-2006  yamt sync with head.
 1.1.10.1 13-Sep-2006  yamt file linux32_sysinfo.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:42 +0000
 1.1.6.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.6.2 18-Nov-2006  ad Sync with head.
 1.1.6.1 13-Sep-2006  ad file linux32_sysinfo.c was added on branch newlock2 on 2006-11-18 21:39:11 +0000
 1.1.2.2 14-Sep-2006  yamt sync with head.
 1.1.2.1 13-Sep-2006  yamt file linux32_sysinfo.c was added on branch yamt-pdpolicy on 2006-09-14 12:31:23 +0000
 1.2.10.1 29-Mar-2007  reinoud Pullup to -current
 1.2.8.1 11-Jul-2007  mjf Sync with head.
 1.2.6.2 15-Jul-2007  xtraeme sys/proc.h is required for nprocs, ok ad@.
 1.2.6.1 10-Apr-2007  ad Sync with head.
 1.2.2.1 24-Mar-2007  yamt sync with head.
 1.3.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.4.16.2 21-Jul-2007  xtraeme <sys/proc.h> is needed to get nprocs... fixes the build on amd64.
 1.4.16.1 21-Jul-2007  xtraeme file linux32_sysinfo.c was added on branch matt-mips64 on 2007-07-21 23:39:47 +0000
 1.4.14.1 26-Dec-2007  ad Sync with head.
 1.4.6.1 09-Jan-2008  matt sync with HEAD
 1.4.4.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.5.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.12.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.6.12.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.6.10.1 04-May-2009  yamt sync with head.
 1.6.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.72.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.7.68.3 21-Apr-2020  martin Sync with HEAD
 1.7.68.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.68.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.60.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.7.54.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.7.42.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.10.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.16 26-Nov-2021  ryo The changes on compat/linux/common/linux_termios.c should also
be applied to compat/linux32/common/linux_termios.c, and reduce diff.

- remove duplicate fd_putfile(). This will be done after "goto out;".
- catch up from compat/linux/common/linux_termios.c r1.26 TIOCSPTLCK
- catch up from compat/linux/common/linux_termios.c r1.37 (TCOOFF/TCOON) of the TCXONC
- catch up from compat/linux/common/linux_termios.c r1.39 FIOCLEX and FIONCLEX
 1.15 23-Aug-2019  maxv Add a default case, don't call sys_ioctl() with an uninitialized 'com'
argument.
 1.14 19-Nov-2008  ad branches: 1.14.42; 1.14.54; 1.14.60; 1.14.68; 1.14.72;
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.13 04-Jul-2008  matthias branches: 1.13.2; 1.13.4;
make LINUX_TCSBRK work. The code is mostly copied from
sys/compat/ibcs2/ibcs2_ioctl.c.
 1.12 28-Apr-2008  martin branches: 1.12.2; 1.12.4;
Remove clause 3 and 4 from TNF licenses
 1.11 22-Mar-2008  bjs branches: 1.11.2; 1.11.4;
fdputfile -> fd_putfile
 1.10 21-Mar-2008  ad Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.9 20-Dec-2007  dsl branches: 1.9.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.8 13-May-2007  dsl branches: 1.8.8; 1.8.16; 1.8.20;
This code is already set for directly calling a files ioctl fn with a
kernel buffer - so why not use it when getting the slave pty number.
 1.7 26-Mar-2007  njoly Sync with recent compat linux termios changes.
 1.6 19-Mar-2007  njoly Fix TIOCGPTN ioctl.
Do not use sysioctl() directly, but netbsd32_ioctl() instead.
 1.5 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.4 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.3 04-Mar-2007  christos branches: 1.3.2; 1.3.4; 1.3.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.2 25-Aug-2006  manu branches: 1.2.4; 1.2.10;
netbsd32_sys_ioctl was called with improper syscall argument structure, this
caused any X11 program to fail because FIONREAD ioctl always returned an
error.
 1.1 15-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.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.1.16.6 24-Mar-2008  yamt sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 15-Feb-2006  yamt file linux32_termios.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 15-Feb-2006  simonb file linux32_termios.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 03-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 15-Feb-2006  yamt file linux32_termios.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.10.4 17-May-2007  yamt sync with head.
 1.2.10.3 15-Apr-2007  yamt sync with head.
 1.2.10.2 24-Mar-2007  yamt sync with head.
 1.2.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.2.4.2 09-Sep-2006  rpaulo sync with head
 1.2.4.1 25-Aug-2006  rpaulo file linux32_termios.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.3.6.2 29-Mar-2007  reinoud Pullup to -current
 1.3.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.3.4.1 11-Jul-2007  mjf Sync with head.
 1.3.2.2 27-May-2007  ad Sync with head.
 1.3.2.1 10-Apr-2007  ad Sync with head.
 1.8.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.16.1 26-Dec-2007  ad Sync with head.
 1.8.8.1 09-Jan-2008  matt sync with HEAD
 1.9.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.9.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.9.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.11.4.2 04-May-2009  yamt sync with head.
 1.11.4.1 16-May-2008  yamt sync with head.
 1.11.2.1 18-May-2008  yamt sync with head.
 1.12.4.1 18-Jul-2008  simonb Sync with head.
 1.12.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.13.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.14.72.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.14.68.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.60.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.14.54.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.14.42.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.2 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.1 15-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.22;
- 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.1.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 15-Feb-2006  rpaulo file linux32_termios.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 15-Feb-2006  yamt file linux32_termios.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 15-Feb-2006  simonb file linux32_termios.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 15-Feb-2006  yamt file linux32_termios.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.40 19-Sep-2021  thorpej Add the timerfd syscalls to COMPAT_LINUX and COMPAT_LINUX32.
 1.39 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.38 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.37 02-Oct-2012  christos branches: 1.37.30; 1.37.42; 1.37.50;
kernel portion of clock_nanosleep()
 1.36 18-Nov-2011  christos branches: 1.36.10;
add sigtimedwait support
 1.35 12-Jul-2010  njoly branches: 1.35.8;
Add CLOCK_MONOTONIC support for compat linux/linux32
clock_nanosleep(2).
 1.34 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.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;
Kill unreachable return statement.
 1.28 16-Jan-2009  njoly branches: 1.28.2;
Update some syscalls that now needs compat50 timeval structure.
 1.27 29-Dec-2008  njoly Fix stime(2) inverted copyin arguments.
 1.26 29-Dec-2008  njoly s/syscallcarg/syscallarg/ in comments.
 1.25 12-Dec-2008  njoly Add clock_nanosleep syscall.
 1.24 08-Dec-2008  njoly Remove unused timeval_to_clock_t function, superseeded by CONVTCK
macro.
 1.23 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.22 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.21 08-Sep-2008  christos branches: 1.21.2; 1.21.4;
make this compile again.
 1.20 08-Sep-2008  christos fix broken linux32_sys_times, copied from linux_sys_times.
 1.19 24-Apr-2008  ad branches: 1.19.2; 1.19.4; 1.19.8;
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.18 17-Apr-2008  njoly branches: 1.18.2;
Add compat linux32 sys_clock_{getres,gettime,settime} syscalls.
 1.17 27-Mar-2008  ad Make rusage collection per-LWP and collate in the appropriate places.
cloned threads need a little bit more work but the locking needs to
be fixed first.
 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 08-Dec-2007  dsl branches: 1.15.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.14 25-Nov-2007  elad branches: 1.14.2;
Refactor time modification checks and place them in the secmodel code.

okay christos@
 1.13 12-May-2007  dsl branches: 1.13.6; 1.13.8; 1.13.14;
Get rusage directly, not via 64bit linux call and stackgap.
 1.12 12-May-2007  dsl Change the compat sys_[fl]utime code to not use the stackgap.
 1.11 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.10 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.9 16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.8 04-Mar-2007  christos branches: 1.8.2; 1.8.4; 1.8.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 09-Feb-2007  ad branches: 1.7.2;
Merge newlock2 to head.
 1.6 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.5 23-Jul-2006  ad branches: 1.5.4; 1.5.6; 1.5.8;
Use the LWP cached credentials where sane.
 1.4 13-Jun-2006  skd branches: 1.4.4;
include kauth.h
workaround a gcc4 warning.
 1.3 14-May-2006  elad branches: 1.3.2;
integrate kauth.
 1.2 24-Feb-2006  manu branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Fix compat_linux32 time(2) emulation
 1.1 09-Feb-2006  manu branches: 1.1.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.1.2.3 01-Mar-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_time.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.8.3 01-Jun-2006  kardel Sync with head.
 1.2.8.2 22-Apr-2006  simonb Sync with head.
 1.2.8.1 24-Feb-2006  simonb file linux32_time.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.2.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.2.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.2.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.2.2.3 11-Aug-2006  yamt sync with head
 1.2.2.2 26-Jun-2006  yamt sync with head.
 1.2.2.1 24-May-2006  yamt sync with head.
 1.3.2.1 19-Jun-2006  chap Sync with head.
 1.4.4.7 21-Jan-2008  yamt sync with head
 1.4.4.6 07-Dec-2007  yamt sync with head
 1.4.4.5 03-Sep-2007  yamt sync with head.
 1.4.4.4 26-Feb-2007  yamt sync with head.
 1.4.4.3 30-Dec-2006  yamt sync with head.
 1.4.4.2 21-Jun-2006  yamt sync with head.
 1.4.4.1 13-Jun-2006  yamt file linux32_time.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.5.8.1 10-Dec-2006  yamt sync with head.
 1.5.6.2 09-Sep-2006  rpaulo sync with head
 1.5.6.1 23-Jul-2006  rpaulo file linux32_time.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.5.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.5.4.1 18-Nov-2006  ad Sync with head.
 1.7.2.4 17-May-2007  yamt sync with head.
 1.7.2.3 07-May-2007  yamt sync with head.
 1.7.2.2 24-Mar-2007  yamt sync with head.
 1.7.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.6.2 29-Mar-2007  reinoud Pullup to -current
 1.8.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.8.4.1 11-Jul-2007  mjf Sync with head.
 1.8.2.2 27-May-2007  ad Sync with head.
 1.8.2.1 10-Apr-2007  ad Sync with head.
 1.13.14.2 27-Dec-2007  mjf Sync with HEAD.
 1.13.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.8.1 09-Jan-2008  matt sync with HEAD
 1.13.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.13.6.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.14.2.1 26-Dec-2007  ad Sync with head.
 1.15.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.16.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.16.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.16.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.16.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.18.2.1 18-May-2008  yamt sync with head.
 1.19.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.19.8.1 19-Oct-2008  haad Sync with HEAD.
 1.19.4.3 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.19.4.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.19.4.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.19.2.3 11-Aug-2010  yamt sync with head.
 1.19.2.2 19-Aug-2009  yamt sync with head.
 1.19.2.1 04-May-2009  yamt sync with head.
 1.21.4.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.21.2.1 19-Jan-2009  skrll Sync with HEAD.
 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.35.8.2 30-Oct-2012  yamt sync with head
 1.35.8.1 17-Apr-2012  yamt sync with head
 1.36.10.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.50.1 17-Dec-2020  thorpej Add POSIX timer and timerfd support to COMPAT_LINUX32.
 1.37.42.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.37.30.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 27-Nov-2021  ryo Add pselect6(2) system call to COMPAT_LINUX32
 1.17 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.16 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.15 18-Nov-2011  christos add sigtimedwait support
 1.14 02-Nov-2010  chs branches: 1.14.8;
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.13 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.12 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.11 16-Jan-2009  njoly branches: 1.11.4; 1.11.6;
Update some syscalls that now needs compat50 timeval structure.
 1.10 05-Jan-2009  njoly Restore struct sysctl padding member name, which was damaged during
__unused removal on arguments.
 1.9 05-Dec-2008  njoly Add getres{uid,gid} syscalls.
 1.8 04-Sep-2008  njoly branches: 1.8.2;
Make linux32 getdents(2) do its own job instead of calling the
corresponding compat linux function, where struct dirent members types
differs.
 1.7 17-Apr-2008  njoly branches: 1.7.4; 1.7.6; 1.7.10;
Add compat linux32 sys_clock_{getres,gettime,settime} syscalls.
 1.6 15-Jan-2008  njoly branches: 1.6.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.5 24-Dec-2007  njoly Add old_uname syscall.
 1.4 11-Apr-2007  njoly branches: 1.4.10; 1.4.16; 1.4.18; 1.4.22;
- 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.3 16-Nov-2006  christos branches: 1.3.2; 1.3.4; 1.3.8; 1.3.10;
__unused removal on arguments; approved by core.
 1.2 13-Sep-2006  manu branches: 1.2.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.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_types.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.1.20.1 18-Nov-2006  ad Sync with head.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 30-Dec-2006  yamt sync with head.
 1.1.16.2 21-Jun-2006  yamt sync with head.
 1.1.16.1 09-Feb-2006  yamt file linux32_types.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_types.h was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.1 14-Sep-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_types.h was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.2.1 10-Dec-2006  yamt sync with head.
 1.3.10.1 11-Jul-2007  mjf Sync with head.
 1.3.8.1 27-May-2007  ad Sync with head.
 1.3.4.1 15-Apr-2007  yamt sync with head.
 1.3.2.1 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.4.22.2 19-Jan-2008  bouyer Sync with HEAD
 1.4.22.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.18.1 26-Dec-2007  ad Sync with head.
 1.4.16.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.10.2 23-Mar-2008  matt sync with HEAD
 1.4.10.1 09-Jan-2008  matt sync with HEAD
 1.6.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.6.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.6.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.7.10.1 19-Oct-2008  haad Sync with HEAD.
 1.7.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.7.4.3 09-Oct-2010  yamt sync with head
 1.7.4.2 11-Aug-2010  yamt sync with head.
 1.7.4.1 04-May-2009  yamt sync with head.
 1.8.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.6.1 05-Mar-2011  rmind sync with head
 1.11.4.3 06-Nov-2010  uebayasi Sync with HEAD.
 1.11.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.8.1 17-Apr-2012  yamt sync with head
 1.2 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.1 15-Jan-2008  njoly branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12; 1.1.14; 1.1.18; 1.1.24; 1.1.26;
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.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.24.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.18.1 04-May-2009  yamt sync with head.
 1.1.14.2 23-Mar-2008  matt sync with HEAD
 1.1.14.1 15-Jan-2008  matt file linux32_uid16.c was added on branch matt-armv6 on 2008-03-23 02:04:33 +0000
 1.1.12.1 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.6.1 15-Jan-2008  mjf file linux32_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 linux32_uid16.c was added on branch yamt-lazymbuf on 2008-01-21 09:41:37 +0000
 1.1.2.2 19-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 15-Jan-2008  bouyer file linux32_uid16.c was added on branch bouyer-xeni386 on 2008-01-19 12:15:00 +0000
 1.44 27-Nov-2021  ryo Add pselect6(2) system call to COMPAT_LINUX32
 1.43 25-Nov-2021  ryo add support COMPAT_LINUX32 for aarch64
 1.42 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.41 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.40 26-Dec-2017  kamil branches: 1.40.4;
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.39 01-Jun-2014  njoly Cleanup pipe(2) flags, now that native handle them.
 1.38 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.37 04-May-2014  njoly Fix pread/pwrite syscalls which need a 64bit offset argument.
 1.36 18-Nov-2013  chs branches: 1.36.2;
implement the *at() syscalls.
bring the unimplemented syscall list up to date.
 1.35 10-Apr-2011  christos branches: 1.35.4; 1.35.14; 1.35.18;
implement pipe2 and dup3
 1.34 11-Nov-2009  rmind branches: 1.34.4; 1.34.6;
- selcommon/pollcommon: drop redundant l argument.
- Use cached curlwp->l_fd, instead of p->p_fd.
- Inline selscan/pollscan.
 1.33 02-Jun-2009  njoly Make nice(2) return EPERM on error, not EACCES (from sys_setpriority).
 1.32 29-Mar-2009  christos Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
 1.31 15-Mar-2009  cegger ansify function definitions
 1.30 16-Jan-2009  njoly branches: 1.30.2;
Update some syscalls that now needs compat50 timeval structure.
 1.29 29-Dec-2008  njoly s/syscallcarg/syscallarg/ in comments.
 1.28 06-Dec-2008  njoly Cleanup; kill netbsd32_caddr_t use.
 1.27 06-Dec-2008  njoly Small setres{uid,gid} cleanup; there is no need to use a specific
handling for -1 uid values.
 1.26 05-Dec-2008  njoly Add getres{uid,gid} syscalls.
 1.25 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.24 03-Oct-2008  njoly branches: 1.24.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.23 22-Sep-2008  njoly Kill a few linux32 syscalls identical to netbsd32 ones.
No functional changes expected.
 1.22 15-Apr-2008  njoly branches: 1.22.4; 1.22.6; 1.22.10;
Make linux32_sys_nice call sys_setpriority directly instead of
netbsd32_setpriority.
 1.21 17-Feb-2008  njoly branches: 1.21.6;
pread/pwrite fixes: use SCARG_P32 to access pointers, and update
syscalls definitions.
 1.20 02-Feb-2008  dsl Impletemt pread() and pwrite().
 1.19 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.18 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.17 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.16 15-Dec-2007  njoly s/netbsd32_void */netbsd32_caddr_t/
 1.15 08-Dec-2007  dsl branches: 1.15.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.14 16-Nov-2007  njoly branches: 1.14.2;
Update, for linux_sys_readlink() removal.
 1.13 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.12 31-Oct-2007  njoly branches: 1.12.2;
compat linux32 syscalls cleanup.

With stackgap and CHECK_ALT_xxx removal, some linux32 and netbsd32
syscalls are now identical.
To avoid code duplication, remove the linux32 definition and use the
netbsd32 one (no functional change).
 1.11 27-Oct-2007  njoly Add missing chown's syscalls family members.
This makes chown(1)/chgrp(1) works under compat linux32.

Problem reported and fix tested by Arto Huusko. Thanks.
 1.10 16-Jun-2007  dsl branches: 1.10.6; 1.10.8; 1.10.12;
Remove a spare 'timeval' structure - makes this version of this function
match some of the other copies lurking in the world of compat.
 1.9 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.8 02-Apr-2007  njoly Fix select() behaviour with NULL timeout, to blocks indefinitely
instead of returning immediately.
Reported by Edgar Fu� on port-amd64@.
 1.7 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.6 04-Mar-2007  christos branches: 1.6.2; 1.6.4; 1.6.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 09-Feb-2007  ad branches: 1.5.2;
Merge newlock2 to head.
 1.4 13-Sep-2006  manu branches: 1.4.4;
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.3 06-Sep-2006  manu branches: 1.3.2; 1.3.4;
Fix linux32_sys_setres{uid|gid}: -1 does not means the same thing on i386
and amd64...
 1.2 13-Jun-2006  skd branches: 1.2.4;
include kauth.h
workaround a gcc4 warning.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.4; 1.1.10; 1.1.12;
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.12.1 19-Jun-2006  chap Sync with head.
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_unistd.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.4.2 14-Sep-2006  yamt sync with head.
 1.1.4.1 26-Jun-2006  yamt sync with head.
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_unistd.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.4.11 27-Feb-2008  yamt sync with head.
 1.2.4.10 04-Feb-2008  yamt sync with head.
 1.2.4.9 21-Jan-2008  yamt sync with head
 1.2.4.8 07-Dec-2007  yamt sync with head
 1.2.4.7 15-Nov-2007  yamt sync with head.
 1.2.4.6 27-Oct-2007  yamt sync with head.
 1.2.4.5 03-Sep-2007  yamt sync with head.
 1.2.4.4 26-Feb-2007  yamt sync with head.
 1.2.4.3 30-Dec-2006  yamt sync with head.
 1.2.4.2 21-Jun-2006  yamt sync with head.
 1.2.4.1 13-Jun-2006  yamt file linux32_unistd.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.3.4.2 09-Sep-2006  rpaulo sync with head
 1.3.4.1 06-Sep-2006  rpaulo file linux32_unistd.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.3.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.3.2.1 18-Nov-2006  ad Sync with head.
 1.4.4.1 12-Apr-2007  bouyer Pull up following revision(s) (requested by njoly in ticket #564):
sys/compat/linux32/common/linux32_unistd.c: revision 1.8
Fix select() behaviour with NULL timeout, to blocks indefinitely
instead of returning immediately.
Reported by Edgar Fu� on port-amd64@.
 1.5.2.4 07-May-2007  yamt sync with head.
 1.5.2.3 15-Apr-2007  yamt sync with head.
 1.5.2.2 24-Mar-2007  yamt sync with head.
 1.5.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.6.1 29-Mar-2007  reinoud Pullup to -current
 1.6.4.1 11-Jul-2007  mjf Sync with head.
 1.6.2.3 15-Jul-2007  ad Sync with head.
 1.6.2.2 27-May-2007  ad Sync with head.
 1.6.2.1 10-Apr-2007  ad Sync with head.
 1.10.12.2 18-Nov-2007  bouyer Sync with HEAD
 1.10.12.1 13-Nov-2007  bouyer Sync with HEAD
 1.10.8.4 23-Mar-2008  matt sync with HEAD
 1.10.8.3 09-Jan-2008  matt sync with HEAD
 1.10.8.2 08-Nov-2007  matt sync with -HEAD
 1.10.8.1 06-Nov-2007  matt sync with HEAD
 1.10.6.5 09-Dec-2007  jmcneill Sync with HEAD.
 1.10.6.4 21-Nov-2007  joerg Sync with HEAD.
 1.10.6.3 11-Nov-2007  joerg Sync with HEAD.
 1.10.6.2 31-Oct-2007  joerg Sync with HEAD.
 1.10.6.1 28-Oct-2007  joerg Sync with HEAD.
 1.12.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.12.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.12.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.14.2.1 26-Dec-2007  ad Sync with head.
 1.15.4.2 19-Jan-2008  bouyer Sync with HEAD
 1.15.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.21.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.21.6.3 05-Oct-2008  mjf Sync with HEAD.
 1.21.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.21.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.22.10.1 19-Oct-2008  haad Sync with HEAD.
 1.22.6.3 10-Oct-2008  skrll Sync with HEAD.
 1.22.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.22.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.22.4.3 11-Mar-2010  yamt sync with head
 1.22.4.2 20-Jun-2009  yamt sync with head
 1.22.4.1 04-May-2009  yamt sync with head.
 1.24.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.24.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.30.2.2 23-Jul-2009  jym Sync with HEAD.
 1.30.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.34.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.34.4.1 21-Apr-2011  rmind sync with head
 1.35.18.1 18-May-2014  rmind sync with head
 1.35.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.4.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.36.2.1 10-Aug-2014  tls Rebase.
 1.40.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.10 23-Aug-2019  maxv Fix info leaks.
 1.9 19-Nov-2008  ad branches: 1.9.42; 1.9.54; 1.9.60; 1.9.68; 1.9.72;
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.8 24-Dec-2007  njoly branches: 1.8.6; 1.8.10; 1.8.12; 1.8.16; 1.8.18;
Add old_uname syscall.
 1.7 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.6 08-Dec-2007  dsl branches: 1.6.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.5 09-Nov-2007  njoly branches: 1.5.2;
Make linux32_sys_oldolduname use LINUX_UNAME_ARCH instead of machine,
like other uname syscalls. While here, remove unneeded
LINUX_UNAME_ARCH #ifdef/#endif checks.
 1.4 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.3 18-Mar-2007  dsl branches: 1.3.8; 1.3.10; 1.3.14; 1.3.16;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.2 09-Feb-2007  ad branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10;
Merge newlock2 to head.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_utsname.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.1.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.16.6 21-Jan-2008  yamt sync with head
 1.1.16.5 15-Nov-2007  yamt sync with head.
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 26-Feb-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 linux32_utsname.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_utsname.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_utsname.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.10.1 29-Mar-2007  reinoud Pullup to -current
 1.2.8.1 11-Jul-2007  mjf Sync with head.
 1.2.6.1 10-Apr-2007  ad Sync with head.
 1.2.2.1 24-Mar-2007  yamt sync with head.
 1.3.16.2 27-Dec-2007  mjf Sync with HEAD.
 1.3.16.1 19-Nov-2007  mjf Sync with HEAD.
 1.3.14.1 13-Nov-2007  bouyer Sync with HEAD
 1.3.10.1 09-Jan-2008  matt sync with HEAD
 1.3.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.8.1 11-Nov-2007  joerg Sync with HEAD.
 1.5.2.1 26-Dec-2007  ad Sync with head.
 1.6.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.8.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.8.12.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.8.12.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 04-May-2009  yamt sync with head.
 1.8.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.9.72.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.9.68.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.60.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.9.54.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.9.42.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.13 18-Aug-2023  christos Add linux waitid(2) from GSoC 2023 (Theodore Preduta)
 1.12 10-Nov-2016  christos GC WOPTSCHECKED
 1.11 04-Nov-2009  rmind branches: 1.11.22; 1.11.40; 1.11.44;
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.10 17-Jan-2009  njoly Convert linux/linux32 wait(4) to use a compat50 rusage structure.
 1.9 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.8 24-Apr-2008  ad branches: 1.8.2; 1.8.4; 1.8.8; 1.8.10;
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.7 23-Apr-2008  ad Catch up with linux.
 1.6 20-Dec-2007  dsl branches: 1.6.6; 1.6.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.5 17-Dec-2007  njoly Fix linux32_sys_wait4 by doing its own jobw instead off calling
linux_sys_wait4. It worked except when child resources were requested,
because 32/64 bits struct rusage differs in size ...

While here, update linux32_sys_waitpid to use linux32_sys_wait4 with a
NULL rusage.
 1.4 08-Dec-2007  dsl branches: 1.4.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.3 18-Mar-2007  dsl branches: 1.3.8; 1.3.10; 1.3.18;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.2 09-Feb-2007  ad branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10;
Merge newlock2 to head.
 1.1 09-Feb-2006  manu branches: 1.1.2; 1.1.10; 1.1.16; 1.1.20; 1.1.22;
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.22.2 09-Sep-2006  rpaulo sync with head
 1.1.22.1 09-Feb-2006  rpaulo file linux32_wait.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:04 +0000
 1.1.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.16.5 21-Jan-2008  yamt sync with head
 1.1.16.4 03-Sep-2007  yamt sync with head.
 1.1.16.3 26-Feb-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 linux32_wait.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:27 +0000
 1.1.10.2 22-Apr-2006  simonb Sync with head.
 1.1.10.1 09-Feb-2006  simonb file linux32_wait.c was added on branch simonb-timecounters on 2006-04-22 11:38:14 +0000
 1.1.2.2 18-Feb-2006  yamt sync with head.
 1.1.2.1 09-Feb-2006  yamt file linux32_wait.c was added on branch yamt-uio_vmspace on 2006-02-18 15:39:02 +0000
 1.2.10.1 29-Mar-2007  reinoud Pullup to -current
 1.2.8.1 11-Jul-2007  mjf Sync with head.
 1.2.6.1 10-Apr-2007  ad Sync with head.
 1.2.2.1 24-Mar-2007  yamt sync with head.
 1.3.18.1 26-Dec-2007  ad Sync with head.
 1.3.10.1 09-Jan-2008  matt sync with HEAD
 1.3.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.4.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.6.8.1 18-May-2008  yamt sync with head.
 1.6.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.6.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.8.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.8.4.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.8.4.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.2.2 11-Mar-2010  yamt sync with head
 1.8.2.1 04-May-2009  yamt sync with head.
 1.11.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.11.40.1 05-Dec-2016  skrll Sync with HEAD
 1.11.22.1 03-Dec-2017  jdolecek update from HEAD

RSS XML Feed