Home | History | Annotate | only in /src/sys/compat/netbsd32
History log of /src/sys/compat/netbsd32
RevisionDateAuthorComments
 1.8 14-Jan-2014  christos use new bsd.syscall.mk
 1.7 20-Mar-2012  martin branches: 1.7.2; 1.7.4;
Remove spurious bsd.kinc.mk include, which seems to not be needed here
and does not work at all (missing bsd.own.mk for ACTIVE_CC) anyway.
 1.6 11-Dec-2005  christos branches: 1.6.112; 1.6.116;
merge ktrace-lwp.
 1.5 26-Feb-2005  perry make this rebuild generated files by default
 1.4 15-Nov-2003  thorpej branches: 1.4.8; 1.4.10;
We have CVS; there is no reason to make .bak files when generating the
syscall tables.
 1.3 26-Oct-2003  lukem Use ${HOST_SH} instead of `sh'.

If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
 1.2 25-Mar-1999  mrg branches: 1.2.42;
move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.2.42.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.2.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.42.1 03-Aug-2004  skrll Sync with HEAD
 1.4.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.8.1 29-Apr-2005  kent sync with -current
 1.6.116.1 05-Apr-2012  mrg sync to latest -current.
 1.6.112.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.6.112.1 17-Apr-2012  yamt sync with head
 1.7.4.1 18-May-2014  rmind sync with head
 1.7.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.56 19-May-2024  christos version dup3
 1.55 30-Jul-2023  rin COMPAT_NETBSD32: Add support for epoll(2).
 1.54 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.53 17-Apr-2021  simonb Compile in compat32 syscall names all the time, as we do for native
syscall names. Needed for dtrace.
 1.52 16-May-2020  christos branches: 1.52.4;
Add ACL support for FFS. From FreeBSD.
 1.51 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.50 12-Mar-2020  pgoyette Split out the quota code from the rest of compat_netbsd32 module. This
allows loading of compat_netbsd32 on kernels that don't have ``options
QUOTA'' enabled.
 1.49 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.48 20-Aug-2019  christos make things compile again.
 1.47 20-Aug-2019  maxv Disable netbsd32_drm.c until it receives proper review.
 1.46 20-Aug-2019  christos compat32 drm ioctl support from Surya Shankar at GSoC 2019
 1.45 18-Jun-2019  christos use option quota
 1.44 27-Jan-2019  christos remove dup
 1.43 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.42 24-Dec-2018  mrg quotactl is always included, regardless of options QUOTA.
 1.41 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.40 24-Dec-2018  mrg move rlimit and quota code into their own modules.

(netbsd32_netbsd.c should have only simple shims. anything more
than copying arguments from one args struct to the other should
not be placed in this file. still a couple more to move out.)
 1.39 19-Oct-2016  skrll branches: 1.39.14; 1.39.16;
PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel

Updated from the original patch in the PR by me.
 1.38 03-Dec-2015  pgoyette branches: 1.38.2;
Missed these.

Only include the compat_14 sys calls if this being compiled as part of
the compat_netbsd32_sysvipc module.
 1.37 01-Dec-2015  pgoyette Properly mark netbsd32_mqueue.c to depend on 'options MQUEUE'

Yes, MQUEUE is included in all kernels by default, but it can be removed.
If it is removed, the compat_netbsd32 module should not include it, either.
 1.36 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.35 20-Jun-2015  martin Implement modctl, sigqueinfo and mq_*
 1.34 17-Nov-2014  uebayasi branches: 1.34.2;
Define compat modules (but without dependencies yet).
 1.33 29-Mar-2013  christos branches: 1.33.10;
compat glue for new lwp_park
 1.32 10-Mar-2012  joerg branches: 1.32.2;
P1003_1B_SEMAPHORE is no longer optional.
 1.31 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.30 04-Jan-2011  matt branches: 1.30.8; 1.30.12;
Make the SA support as optional as is possible.
 1.29 10-Dec-2009  matt branches: 1.29.4;
Move saemul_netbsd32 to netbsd32_sa.c and allow the KERN_SA bits to be omitted.
 1.28 11-Jan-2009  christos merge christos-time_t
 1.27 19-Nov-2008  ad branches: 1.27.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.26 15-Oct-2008  wrstuden branches: 1.26.2;
Merge wrstuden-revivesa into HEAD.
 1.25 18-Feb-2007  cube branches: 1.25.38; 1.25.42; 1.25.44; 1.25.48;
Add missing lwp syscalls. Put them all together into a new file,
netbsd32_lwp.c, and remove remaining traces of SA.

This still needs some MD (and possibly MI, depending on the chosen
solution) changes to actually work.
 1.24 09-Nov-2006  cube branches: 1.24.4;
- Make better use of COMPAT_XX type in syscalls.master
- Remove useless (thanks to COMPAT_XX behaviour) #ifdefs in
syscalls.master
- Make netbsd32_compat_43.c compiled per COMPAT_LINUX32 because the latter
needs stuff from it.

Fixes Perry's PR#34951.
 1.23 30-Aug-2006  cube branches: 1.23.2; 1.23.4;
netbsd32_core.c is need only under options COREDUMP.
 1.22 29-Mar-2006  cube Implement the _lwp* and sa_* families of syscalls, using the newly
introduced hooks in the native code.
 1.21 05-Mar-2006  cube branches: 1.21.2; 1.21.4; 1.21.6;
Implement the ksem_* family of syscalls.
 1.20 11-Dec-2005  christos branches: 1.20.4; 1.20.6;
merge ktrace-lwp.
 1.19 23-Oct-2005  cube - Split sys_kevent into kevent1 so that it can be used by COMPAT_NETBSD32
code.

- To achieve COMPAT_NETBSD32 compatibility, introduce a parameter to
kevent1 that points to functions that do the actual copyin/copyout
operations. This is similar to what was done in FreeBSD by Paul Saab.

- Add the COMPAT_NETBSD32 definitions and hooks.
 1.18 19-Aug-2005  christos branches: 1.18.2;
64 bit inode changes.
 1.17 17-Jun-2004  cube branches: 1.17.12;
o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.16 16-Jan-2004  mrg clean up a little:
- delete ktrsyscall32()
- add a check #ifdef _LP64 to do the conversion if P_32 is set to the
standard ktrsyscall()
- add a couple of similar _LP64/P_32 checks to the systrace code.

this should get systrace working for 32 bit apps as well as complete
ktrace support for "trace_enter/trace_exit" using platforms such as amd64.

XXX: systrace isn't supported on sparc64 currently... (it doesn't use
trace_enter/trace_exit, or have it's own calls to systrace_xxx()...)
 1.15 15-Jan-2004  mrg add a copy of the ktrsyscall() entry point for 32 bit emulated calls.
the main purpose of this function is to adjust the "argsize" value of
the ktrace syscall record, otherwise userland will see N/2 (rounded
down) arguments instead of N.
 1.14 25-Oct-2003  chs allow COMPAT_SUNOS without COMPAT_43.
 1.13 15-Oct-2003  fvdl Don't put the netbsd32_compat*.c files in the 'compat library'. Unconditionally
compiling these causes a ripple effect making it hard to conditionalize
anything on COMPAT_* in the kernel.
 1.12 29-Apr-2002  mrg branches: 1.12.10;
build the netbsd32_compat* objects into libcompat.a, so they are available
to emulations not just netbsd itself. rename the compat_10 functions to
match everything else. fixes a problem reported by julian coleman.
 1.11 08-Dec-2001  thorpej Make the coredump routine exec-format/emulation specific. Split
out traditional NetBSD coredump routines into core_netbsd.c and
netbsd32_core.c (for COMPAT_NETBSD32).
 1.10 06-Jun-2001  mrg branches: 1.10.2;
add netbsd32_uvm_unix.c and netbsd32_kern_sig.c
 1.9 08-Feb-2001  mrg branches: 1.9.2;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.8 07-Feb-2001  mrg compat_sunos needs netbsd32_compat_09.c
 1.7 01-Dec-2000  jdolecek put a.out/elf32 specific things in netbsd32_exec_{aout|elf32}.c
emul_netbsd32 was moved to netbsd32_netbsd.c
g/c netbsd32_exec.c now
 1.6 11-Oct-1999  eeh branches: 1.6.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.5 24-Apr-1999  eeh branches: 1.5.2;
Don't defopt COMPAT_NETBSD32 here; it's done in sys/conf/files.
 1.4 25-Mar-1999  mrg branches: 1.4.4;
clean and up make compile
 1.3 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.2 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.4.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.6.2.1 08-Dec-2000  bouyer Sync with HEAD.
 1.9.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.9.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.9.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.10.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.10.1 03-Aug-2004  skrll Sync with HEAD
 1.17.12.3 26-Feb-2007  yamt sync with head.
 1.17.12.2 30-Dec-2006  yamt sync with head.
 1.17.12.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 26-Oct-2005  yamt sync with head
 1.20.6.1 22-Apr-2006  simonb Sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.21.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.21.4.1 19-Apr-2006  elad sync with head.
 1.21.2.3 03-Sep-2006  yamt sync with head.
 1.21.2.2 01-Apr-2006  yamt sync with head.
 1.21.2.1 05-Mar-2006  yamt file files.netbsd32 was added on branch yamt-pdpolicy on 2006-04-01 12:06:41 +0000
 1.23.4.1 10-Dec-2006  yamt sync with head.
 1.23.2.1 18-Nov-2006  ad Sync with head.
 1.24.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.25.48.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.25.48.1 19-Oct-2008  haad Sync with HEAD.
 1.25.44.1 28-Sep-2008  skrll Adapt the SA COMPAT_NETBSD32 stuff to this branch.
 1.25.42.2 11-Mar-2010  yamt sync with head
 1.25.42.1 04-May-2009  yamt sync with head.
 1.25.38.1 17-Jan-2009  mjf Sync with HEAD.
 1.26.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.27.4.2 04-Jan-2009  christos add new syscalls.
 1.27.4.1 19-Nov-2008  christos file files.netbsd32 was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.29.4.1 05-Mar-2011  rmind sync with head
 1.30.12.2 11-Mar-2012  mrg sync to latest -current
 1.30.12.1 24-Feb-2012  mrg sync to -current.
 1.30.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.30.8.1 17-Apr-2012  yamt sync with head
 1.32.2.2 03-Dec-2017  jdolecek update from HEAD
 1.32.2.1 23-Jun-2013  tls resync from head
 1.33.10.1 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.34.2.3 05-Dec-2016  skrll Sync with HEAD
 1.34.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.34.2.1 22-Sep-2015  skrll Sync with HEAD
 1.38.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.39.16.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.39.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.39.16.1 10-Jun-2019  christos Sync with HEAD
 1.39.14.6 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.39.14.5 23-Sep-2018  pgoyette More work on kern_proc_32
 1.39.14.4 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.39.14.3 12-Sep-2018  pgoyette Add a compat_netbsd32_16 to handle the sigcode stuff.
 1.39.14.2 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.39.14.1 21-Mar-2018  pgoyette Split compat/rndpseudo_50.c into two pieces, one for native compat and
a second piece for compat32. Update both modules accordingly.
 1.52.4.1 17-Apr-2021  thorpej Sync with HEAD.
 1.143 30-Jul-2023  rin COMPAT_NETBSD32: Add support for epoll(2).
 1.142 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 1.141 12-Feb-2023  andvar s/strucure/structure/ and s/structues/structures/ in comments.
 1.140 23-Apr-2022  reinoud Implement support for mounting UDF in compat32
Fixes PR#56801
 1.139 11-Nov-2021  martin Adapt to recent posix_spawn extensions.
 1.138 06-Nov-2021  thorpej COMPAT_NETBSD32 is all about running the 32-bit flavor of native
binaries on a 64-bit platform[*], as such:
- Make the logic about which "sendsig" flavor to call MI (as it is in the
native 64-bit environment) and follow the same rules as the native 32-bit
environment.
- Make COMPAT_NETBSD32 x COMPAT_16 work the same as it would in the
native 32-bit environment by providing a netbsd32_sendsig_sigcontext_16_hook,
rather than overriding the entire sendsig logic with a netbsd32_sendsig_hook.
- In netbsd32___sigaction_sigtramp(), make sure the compat_netbsd32_16
module is loaded if the trampoline version specifies a sigcontext style
handler, otherwise return EINVAL so that libc can try again with siginfo
style.

[*] ...except for arm32, which uses it to mean "run 32-bit OABI binaries
from the 32-bit EABI environment". Doing it this way was arguably a mistake,
but we are stuck with it for now, so support it by providing a machine-
dependent override for netbsd32_sendsig() that also disables the corresponding
logic in netbsd32___sigaction_sigtramp().

Fixes PR kern/56487.
 1.137 19-Jan-2021  simonb The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.136 18-Jan-2021  simonb s/u_intN_t/uintN_t/
 1.135 14-Jan-2021  simonb Handle FSSIOCSET and FSSIOCGET; vndconfig(8) works with compat32 now.
XXX: FSSIOCSET50 and FSSIOCGET50 are not (yet) handled.
 1.134 01-Nov-2020  pgoyette Separate the compat_netbsd32_coredump from the compat_netbsd32 and
coredump modules, into its own module.

Welcome to 7.99.75 !!!
 1.133 16-May-2020  christos branches: 1.133.2;
Add ACL support for FFS. From FreeBSD.
 1.132 24-Dec-2019  kamil Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO

PT_LWPINFO is a legacy ptrace(2) operation that was originally intended
to retrieve the thread (LWP) information inside a traced process.

It has a number of flaws and is confused with PT_LWPINFO from FreeBSD.

PT_LWPSTATUS and PT_LWPNEXT address the problems (shortly by: rename,
removal of pl_event) and introduces new features: signal context
(pl_sigpend, pl_sigmask), LWP name (pl_name), LWP TLS base address
(pl_private). The private pointer was so far missing information for
a debugger.

PT_LWPSTATUS@nnn is now shipped with core(5) files and contain LWP specific
information, so far missed in the core(5) files.

PT_LWPSTATUS retrieves LWP information for the prompted thread.
PT_LWPNEXT retrieves LWP information for the next thread, borrowing the
semantics from NetBSD specific PT_LWPINFO.

PT_LWPINFO is namespaced with __LEGACY_PT_LWPINFO and still available for
the foreseeable future, without plans of removing it.

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
 1.131 18-Nov-2019  rin 8-byte objects on i386 or arm-oabi are aligned in 4-byte boundary.
Therefore, we must use __attribute__((__aligned__(4))) for them.
netbsd32_{,u}int64 are provided for this purpose. However, we
cannot use it in <compat/sys/siginfo.h> due to circular dependency
b/w <machine/netbsd32_machdep.h>.

In order to distangle it, we choose here to have a duplicate type,
netbsd32_siginfo_uint64, in <compat/sys/siginfo.h>. The equivalence
with netbsd32_uint64 is asserted in <compat/netbsd32/netbsd32.h>.

Now, gdb for i386 works again on amd64 kernel.

Based on patch provided by kamil. Thanks!

XXX
pullup to netbsd-9
 1.130 18-Nov-2019  rin Sorry, revert unintentional parts of the previous commit:
http://mail-index.netbsd.org/source-changes/2019/11/18/msg110946.html

I was going to commit only netbsd32_signal.c.
 1.129 18-Nov-2019  rin Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
 1.128 07-Nov-2019  rin For netbsd32_statvfs, f_spare should be netbsd32_uint64, not uint64_t.

Fix syscalls using struct statvfs on COMPAT_NETBSD32 on amd64, where
NETBSD32_INT64_ALIGN is __attribute__((__aligned__(4))).
 1.127 03-Oct-2019  kamil Switch kevent udata from intptr_t void*

Synchromize the struct field format with other BSDs and Darwin.

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

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

Discussed with core@ and there were no objections for this move.
 1.126 26-Sep-2019  christos accrightslen should be u_int for compat too
 1.125 25-Sep-2019  christos avoid signed-compare warning; use uintmax_t to print.
 1.124 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.123 20-Feb-2019  mrg branches: 1.123.4;
use KASSERTMSG() in netbsd32_ptr32i().
 1.122 09-Feb-2019  mrg - expand the comment about what netbsd32_machdep.h should provide.
- add missing NETBSD32_POINTER_TYPE
- add static inline functions to convert pointers to/from 32 bit,
inclusing an overflow check for NETBSD32PTR32PLUS().
 1.121 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.120 25-Nov-2018  mlelstv Restore netbsd32 compat code for new NPF ABI.
 1.119 11-Aug-2018  mrg support nullfs in netbsd32.
 1.118 10-May-2018  christos branches: 1.118.2;
add {send,recv}mmsg
 1.117 14-Apr-2018  mrg redo the previous -- compat/sys/siginfo.h is already included
later, as is another header. move them up near the top.
 1.116 18-Dec-2017  mrg branches: 1.116.2;
include <compat/sys/siginfo.h> for siginfo32_t.
 1.115 17-Dec-2017  christos handle siginfo requests for ptrace32
 1.114 13-Nov-2016  rin branches: 1.114.8;
tv_usec in netbsd32_timeval is suseconds_t (aka int32_t) rather than
netbsd32_long (considered harmless)

approved by martin
 1.113 19-Oct-2016  skrll PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel

Updated from the original patch in the PR by me.
 1.112 23-Sep-2016  skrll Trailing whitespace
 1.111 23-Sep-2016  skrll Types for wait6 and clock_getcpuclockid2
 1.110 17-Sep-2016  christos deal with not having KTRACE
 1.109 26-Nov-2015  martin branches: 1.109.2;
We never exec(2) with a kernel vmspace, so do not test for that, but instead
KASSERT() that we don't.
When calculating the load address for the interpreter (e.g. ld.elf_so),
we need to take into account wether the exec'd process will run with
topdown memory or bottom up. We can not use the current vmspace's flags
to test for that, as this happens too early. Luckily the execpack already
knows what the new state will be later, so instead of testing the current
vmspace, pass the info as additional argument to struct emul
e_vm_default_addr.
Fix all such functions and adopt all callers.
 1.108 10-Aug-2015  mrg move some header-specific pointer-typedefs into a header-specific area.
 1.107 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.106 21-Jun-2015  mrg s/sparc64/native 64 bit/ in a comment...
 1.105 21-Jun-2015  martin Implement trivial conversion for pset_*
 1.104 20-Jun-2015  martin Implement modctl, sigqueinfo and mq_*
 1.103 05-Oct-2014  christos branches: 1.103.2;
add tmpfs.
 1.102 28-Jun-2014  dholland branches: 1.102.2;
Revert the following changes:

src/sys/sys/quotactl.h 1.37
src/sys/compat/netbsd32/netbsd32.h 1.101
src/sys/compat/netbsd32/netbsd32_netbsd.c 1.188, 1.189
src/sys/kern/vfs_quotactl.c 1.39
src/sys/kern/vfs_syscalls.c 1.483
src/sys/ufs/lfs/ulfs_quota.c 1.11
src/sys/ufs/ufs/ufs_quota.c 1.116
src/lib/libquota/quota_kernel.c 1.5

and do them correctly.

If you're going to change the name of something, you need to change
the name of *all* the things with the same name, not just a handful,
and you should change it to something similar so it still matches the
rest of the system rather than just picking an arbitrarily different
name.

Hi, Joerg.

To wit, rename the quotactl "delete" operation to "del", because
"delete" is a reserved word in C++ and for some reason Joerg wants to
run internal interfaces used only by C code through his C++ compiler.
Do not rename it to "remove" instead, because this doesn't match
libquota or the rest of the usage throughout the system; and rename
all the related identifiers, not just the ones that blew the mind of
Joerg's C++ compiler.

Because this is not a user-facing API (the only userland consumer
sys/quotactl.h is libquota) it is sort of ok to make arbitrary
source-incompatible changes; however, by the same token it's completely
unnecessary. If it *were* a user-facing API that someone might have a
semi-rational reason to want to run a C++ compiler on, it would be
incorrect to change it at this point.
 1.101 13-Jun-2014  joerg delete -> remove
 1.100 30-Apr-2014  njoly Do not use native off_t type under compat netbsd32, but a new
netbsd32_off_t that provide the expected alignment for 64bit types.
 1.99 03-Feb-2014  manu branches: 1.99.2;
Properly translate struct swapent for COMPAT_NETBSD32 (missing commit)
 1.98 24-Jan-2014  christos sigaction until 1.4 had an int sigmask, don't trash the stack.
 1.97 01-Jan-2014  dsl Change the type of the 'cookie' that holds the state of the core dump file
from 'void *' to the actual type 'struct coredump_iostate *'.
In most of the code the contents of the structure are still unknown.
This just stops the wrong type of pointer being passed to the 'void *'
parameter.
I hope I've found everything, amd64 GENERIC and i386 GENERIC & ALL compile.
 1.96 12-Oct-2012  christos branches: 1.96.2;
fix pre-5 stat system call structure which should have used the pre-64-time_t
timestamps!
 1.95 08-Apr-2012  martin branches: 1.95.2;
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
 1.94 06-Mar-2012  macallan allow mounting ext2fs and msdosfs
while there also enable lfs but that's untested
 1.93 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.92 01-Feb-2012  dholland branches: 1.92.2;
Be consistent about whether idtype and objtype codes are signed or
unsigned. They are signed. (While unsigned might have been a better
choice, it doesn't really matter and the majority of preexisting uses
were signed. And consistency is good.)
 1.91 01-Feb-2012  dholland Improve the names of some members of struct quotactl_args. These are
effectively function parameter names, but since they need to be
described with the same names in the man page the choices do matter.
Some.
 1.90 01-Feb-2012  dholland Update compat_netbsd32 for new quotactl.
 1.89 31-Jan-2012  matt Add netbsd32_socklenp_t
 1.88 12-Oct-2011  dholland branches: 1.88.2; 1.88.6;
As a precaution, add sys/param.h explicitly to some headers that will
no longer get it via sys/ucred.h and don't already include it
explicitly. These should in turn be removed when it can be confirmed
that it's safe to do so. (Because sys/param.h is full of things that
are often tested with #if, it's not in general safe to remove it
without checking, as such tests fail silently if the symbol goes
missing.)
 1.87 30-Jun-2011  wiz dependant -> dependent
 1.86 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.85 22-Jan-2011  matt Add the ability to mount NFS filesystems in COMPAT_NETBSD32
If in the kernel and NFS_ARGS_ONLY, just export struct nfs_args and its flags.
 1.84 14-Dec-2009  matt branches: 1.84.4; 1.84.6; 1.84.8;
Merge from matt-nb5-mips64
 1.83 12-Dec-2009  njoly Remove semicolon from NETBSD32TOx_UAP macro definitions.
 1.82 16-Mar-2009  njoly Fix dev_t alignment, by not using the new 64bit value directly but
rather a 32bit aligned version (netbsd32_dev_t = netbsd32_uint64).

ok by cube@.
 1.81 28-Jan-2009  njoly branches: 1.81.2;
Revert the previous packed attribute fix. Instead make netbsd32_time_t
of type netbsd32_int64 which provides a 64-bit value with a 32-bit
alignment.

Suggested by dsl.
 1.80 28-Jan-2009  njoly Make netbsd32_timespec/netbsd32_timeval structures packed. This fix an
alignment problem between 64-bit kernel and 32-bit userland versions,
which ended in different structure sizes.
 1.79 11-Jan-2009  christos merge christos-time_t
 1.78 22-Nov-2008  mrg branches: 1.78.4;
implement netbsd32__sched_setparam(), netbsd32__sched_getparam(),
netbsd32__sched_setaffinity() and netbsd32__sched_getaffinity().
 1.77 15-Oct-2008  wrstuden branches: 1.77.2; 1.77.4;
Merge wrstuden-revivesa into HEAD.
 1.76 29-May-2008  mrg branches: 1.76.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.75 24-May-2008  njoly Fix netbsd32_ipc_perm and netbsd32_shmid_ds structures to use correct
types.
 1.74 02-Feb-2008  dsl branches: 1.74.6; 1.74.8; 1.74.10; 1.74.12;
Fix build
 1.73 02-Feb-2008  dsl Use the netbsd32_[u]int64 type for all 64bit items to ensure we have the
correct alignment/padding rules.
Removed the now-unnecessary #pragma packed for amd64.
Should fix the alignment of 'struct netbsd32_kevent' on non-amd64.
 1.72 02-Feb-2008  dsl Change u_intxx_t to uintxx_t and uint to unsigined int etc.
Fix indentation.
 1.71 25-Dec-2007  perry Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.70 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.69 07-Dec-2007  ad branches: 1.69.4;
Add: _lwp_setname, _lwp_getname, _lwp_ctl.
 1.68 29-Sep-2007  dsl branches: 1.68.4; 1.68.6;
Use netbsd32_uint64 instead of fsblkcnt_t and fsfilcnt_t in order to get
the correct alignment (4 bytes for i386) for the whole structure.
 1.67 16-Sep-2007  dsl branches: 1.67.2;
Define netbsd32_uint64 for 64bit integers with the alignment requirement
of the corresponding 32bit architecture.
Use it for the 64bit items in netbsd32_statvfs so that the structure
doesn't collect 8byte alignment (and 4 bytes of trailing padding).
This replaces the 'packed' attribute which wasn't architecture specific
and would cause massive overheads accessing every member of sparc64.
Should allow the MIPS64 port do DTRT.
 1.66 17-Jul-2007  christos branches: 1.66.6; 1.66.8;
include <compat/sys/mount.h> MFSNAMELEN
 1.65 30-Jun-2007  dsl Changes to sompat socket function to avoid the dreaded stackgap.
 1.64 03-Jun-2007  dsl Split netbsd32___semctl14() so that it is callable from
compat_10_netbsd32_sys_semsys() (where the one parameter is already in
kernel space).
Note that the code in compat_10_netbsd32_sys_semsys() has always been wrong,
since it called compat_14_sys___semctl() - which would read 64bit values!
 1.63 30-Apr-2007  dsl Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.62 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.61 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.60 04-Mar-2007  christos branches: 1.60.2; 1.60.4; 1.60.6;
fix fallout from caddr_t changes.
 1.59 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.58 19-Feb-2007  cube Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.
 1.57 09-Feb-2007  ad branches: 1.57.2;
Merge newlock2 to head.
 1.56 21-Nov-2006  christos adjust limits takes struct proc again.
 1.55 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.54 13-Jul-2006  martin branches: 1.54.4;
Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.53 31-May-2006  drochner branches: 1.53.2;
support ntp_gettime again
compile tested by Havard Eidnes
 1.52 11-May-2006  mrg branches: 1.52.2;
add an extra (uintptr_t) cast to NETBSD32TOP.
 1.51 29-Mar-2006  cube Implement the _lwp* and sa_* families of syscalls, using the newly
introduced hooks in the native code.
 1.50 06-Mar-2006  cube branches: 1.50.2; 1.50.4;
Implement the SysV IPC family of syscalls.
 1.49 05-Mar-2006  cube branches: 1.49.2;
Implement the ksem_* family of syscalls.
 1.48 11-Dec-2005  christos branches: 1.48.4; 1.48.6;
merge ktrace-lwp.
 1.47 24-Oct-2005  cube Move prototypes for siginfo32 to/from siginfo converters at the right
place.
 1.46 23-Oct-2005  cube - Split sys_kevent into kevent1 so that it can be used by COMPAT_NETBSD32
code.

- To achieve COMPAT_NETBSD32 compatibility, introduce a parameter to
kevent1 that points to functions that do the actual copyin/copyout
operations. This is similar to what was done in FreeBSD by Paul Saab.

- Add the COMPAT_NETBSD32 definitions and hooks.
 1.45 07-Oct-2005  chs branches: 1.45.2;
make the previous apply only to x86_64.
 1.44 07-Oct-2005  chs add __attribute__((packed)) to struct netbsd32_stat13. the alignment of
64-bit values is annoying in the x86 world: they require 64-bit alignment
in 64-bit mode but only 32-bit alignment in 32-bit mode.
 1.43 27-Sep-2005  chs this needs stuff from compat/sys/siginfo.h now, just include it here.
 1.42 27-Sep-2005  chs make this compile again.
 1.41 24-Sep-2005  christos make the siginfo converters static and comment out the one that is not used.
 1.40 20-Aug-2005  kent fix a compilation problem on NetBSD/amd64
 1.39 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.38 19-Aug-2005  christos 64 bit inode changes.
 1.37 23-Jul-2005  cube Regen (__sigtimedwait(2)).
 1.36 23-Jul-2005  cube Implement the timer_create(2) family of syscalls.
 1.35 13-Jul-2005  cube netbsd32_execve2() doesn't exist anymore.
 1.34 04-Jul-2005  cube branches: 1.34.2;
Implement uuidgen(2).
 1.33 10-Jun-2005  matt Rework the coredump code to have no explicit knownledge of how coredump
i/o is done. Instead, pass an opaque cookie which is then passed to a
new routine, coredump_write, which does the actual i/o. This allows the
method of doing i/o to change without affecting any future MD code.
Also, make netbsd32_core.c [re]use core_netbsd.c (in a similar manner that
core_elf64.c uses core_elf32.c) and eliminate that code duplication.
cpu_coredump{,32} is now called twice, first with a NULL iocookie to fill
the core structure and a second to actually write md parts of the coredump.
All i/o is nolonger random access and is suitable for shipping over a stream.
 1.32 02-Jun-2005  drochner in siginfo conversion functions, declare the source operand as "const"
 1.31 26-Mar-2005  fvdl Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.
 1.30 26-Feb-2005  perry branches: 1.30.2;
nuke trailing whitespace
 1.29 17-Jun-2004  cube branches: 1.29.4; 1.29.6;
o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.28 20-May-2004  atatat Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.

This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.

linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.27 21-Jan-2004  mrg branches: 1.27.2;
delete ktrsyscall32() prototype
 1.26 15-Jan-2004  mrg add a copy of the ktrsyscall() entry point for 32 bit emulated calls.
the main purpose of this function is to adjust the "argsize" value of
the ktrace syscall record, otherwise userland will see N/2 (rounded
down) arguments instead of N.
 1.25 13-Oct-2003  fvdl Implement 32bit get/setcontext entry points.
 1.24 18-Jan-2003  thorpej branches: 1.24.2;
Merge the nathanw_sa branch.
 1.23 27-Nov-2002  atatat Complete the rename: s/sa_/<compat>_sa_/g

Also tweak the darwin siginfo stuff to avoid the same type of collision.
 1.22 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.21 08-Dec-2001  thorpej Make the coredump routine exec-format/emulation specific. Split
out traditional NetBSD coredump routines into core_netbsd.c and
netbsd32_core.c (for COMPAT_NETBSD32).
 1.20 25-Aug-2001  mrg update copyright notices.
 1.19 19-Jun-2001  fvdl branches: 1.19.2;
Some of this was sparc-specific, so ifdef __sparc__ it (XXX). Also,
change the alignment of one structure with an MD ifdef. Should
be moved into the netbsd32_machdep parts.
 1.18 06-Jun-2001  mrg proto for coredump32
 1.17 04-Feb-2001  mrg branches: 1.17.2;
make sysctl vm.loadavg work.
 1.16 02-Feb-2001  mrg de-static netbsd32_exec_aout_prep_[zno]magic().
de-static netbsd32_from_stat43().
move the guts of netbsd32_execve() into netbsd32_execve2().

all of are for the forthcoming sunos32 compat mode (for sparc64).
 1.15 03-Dec-2000  fvdl Add systm.h to pull in copyout* prototypes.
 1.14 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.13 18-Nov-2000  mrg kill gcc warnings.
 1.12 22-Aug-2000  mrg declare struct firm_event32
 1.11 09-Jul-2000  mrg - massive warning fix fest.
- fix pread/pwrite return values (plus some other syscalls that looked
similarly broken).
- prototypes and clean up for netbsd32_ioctl.c

now getpw*() works under compat32!
 1.10 30-Dec-1999  eeh branches: 1.10.4;
Update to 32-bit compatibility routines.
 1.9 11-Oct-1999  eeh branches: 1.9.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.8 12-Jul-1999  kleink branches: 1.8.2;
XSH5: change function signature to `void *sbrk(intptr_t)'.
 1.7 25-Mar-1999  mrg branches: 1.7.4;
clean and up make compile
 1.6 25-Mar-1999  mrg SPARC32->NETBSD32
 1.5 25-Mar-1999  mrg include the MD header.
 1.4 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.3 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.2 07-Sep-1998  eeh Need to make sure high bits of addresses are zeroed out.
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.7.4.1 02-Aug-1999  thorpej Regen.
 1.8.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.9.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.9.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.10.4.1 26-Aug-2000  mrg pull up 1.12. approved by thorpej:
>Fix netbsd32_ioctls.
 1.17.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.17.2.6 11-Nov-2002  nathanw Catch up to -current
 1.17.2.5 23-Aug-2002  petrov lwpification.
 1.17.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.17.2.3 08-Jan-2002  nathanw Catch up to -current.
 1.17.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.17.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.19.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.24.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.2.5 01-Apr-2005  skrll Sync with HEAD.
 1.24.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.24.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.2.1 03-Aug-2004  skrll Sync with HEAD
 1.27.2.1 23-May-2004  tron Pull up revision 1.28 (requested by atatat in ticket #374):
Tweak sysctl setup functions (the macros, actually) for use in lkms,
and tweak lkminit_*.c (where applicable) to call them, and to call
sysctl_teardown() when being unloaded.
This consists of (1) making setup functions not be static when being
compiled as lkms (change to sys/sysctl.h), (2) making prototypes
visible for the various setup functions in header files (changes to
various header files), and (3) making simple "load" and "unload"
functions in the actual lkminit stuff.
linux_sysctl.c also needs its root exposed (ie, made not static) for
this (when built as an lkm).
 1.29.6.2 26-Mar-2005  yamt sync with head.
 1.29.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.29.4.1 29-Apr-2005  kent sync with -current
 1.30.2.1 18-Sep-2005  tron Pull up following revision(s) (requested by fvdl in ticket #798):
sys/compat/sunos/sunos_exec.c: revision 1.47
sys/compat/pecoff/pecoff_emul.c: revision 1.11
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.45
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.12
sys/sys/proc.h: revision 1.198
sys/compat/mach/mach_exec.c: revision 1.56
sys/compat/freebsd/freebsd_exec.c: revision 1.27
sys/arch/sparc64/include/vmparam.h: revision 1.27
sys/kern/kern_resource.c: revision 1.91
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.88
sys/compat/osf1/osf1_exec.c: revision 1.39
sys/compat/svr4_32/svr4_32_resource.c: revision 1.5
sys/compat/ultrix/ultrix_misc.c: revision 1.99
sys/compat/svr4_32/svr4_32_exec.h: revision 1.9
sys/kern/exec_elf32.c: revision 1.103
sys/compat/aoutm68k/aoutm68k_exec.c: revision 1.19
sys/compat/sunos32/sunos32_exec.c: revision 1.20
sys/compat/hpux/hpux_exec.c: revision 1.46
sys/compat/darwin/darwin_exec.c: revision 1.40
sys/kern/sysv_shm.c: revision 1.83
sys/uvm/uvm_extern.h: revision 1.99
sys/uvm/uvm_mmap.c: revision 1.89
sys/kern/kern_exec.c: revision 1.195
sys/compat/netbsd32/netbsd32.h: revision 1.31
sys/arch/sparc64/sparc64/svr4_32_machdep.c: revision 1.20
sys/compat/svr4/svr4_exec.c: revision 1.56
sys/compat/irix/irix_exec.c: revision 1.41
sys/compat/ibcs2/ibcs2_exec.c: revision 1.63
sys/compat/svr4_32/svr4_32_exec.c: revision 1.16
sys/arch/amd64/include/vmparam.h: revision 1.8
sys/compat/linux/common/linux_exec.c: revision 1.73
Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
that will return the default VM map address. The default function
is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
macro. This gives emulations control over the default map address,
and allows things to be mapped at the right address (in 32bit range)
for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2
Tested on amd64, compile-tested on sparc64.
 1.34.2.7 04-Feb-2008  yamt sync with head.
 1.34.2.6 21-Jan-2008  yamt sync with head
 1.34.2.5 27-Oct-2007  yamt sync with head.
 1.34.2.4 03-Sep-2007  yamt sync with head.
 1.34.2.3 26-Feb-2007  yamt sync with head.
 1.34.2.2 30-Dec-2006  yamt sync with head.
 1.34.2.1 21-Jun-2006  yamt sync with head.
 1.45.2.1 26-Oct-2005  yamt sync with head
 1.48.6.2 01-Jun-2006  kardel Sync with head.
 1.48.6.1 22-Apr-2006  simonb Sync with head.
 1.48.4.1 09-Sep-2006  rpaulo sync with head
 1.49.2.6 11-Aug-2006  yamt sync with head
 1.49.2.5 26-Jun-2006  yamt sync with head.
 1.49.2.4 24-May-2006  yamt sync with head.
 1.49.2.3 01-Apr-2006  yamt sync with head.
 1.49.2.2 13-Mar-2006  yamt sync with head.
 1.49.2.1 05-Mar-2006  yamt file netbsd32.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:07 +0000
 1.50.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.50.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.50.2.2 11-May-2006  elad sync with head
 1.50.2.1 19-Apr-2006  elad sync with head.
 1.52.2.1 19-Jun-2006  chap Sync with head.
 1.53.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.54.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.54.4.1 12-Jan-2007  ad Sync with head.
 1.57.2.3 07-May-2007  yamt sync with head.
 1.57.2.2 24-Mar-2007  yamt sync with head.
 1.57.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.60.6.3 09-Dec-2007  reinoud Pullup to HEAD
 1.60.6.2 29-Mar-2007  reinoud Pullup to -current
 1.60.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.60.4.1 11-Jul-2007  mjf Sync with head.
 1.60.2.6 09-Oct-2007  ad Sync with head.
 1.60.2.5 20-Aug-2007  ad Sync with HEAD.
 1.60.2.4 15-Jul-2007  ad Sync with head.
 1.60.2.3 09-Jun-2007  ad Sync with head.
 1.60.2.2 27-May-2007  ad Sync with head.
 1.60.2.1 10-Apr-2007  ad Sync with head.
 1.66.8.3 23-Mar-2008  matt sync with HEAD
 1.66.8.2 09-Jan-2008  matt sync with HEAD
 1.66.8.1 06-Nov-2007  matt sync with HEAD
 1.66.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.66.6.1 02-Oct-2007  joerg Sync with HEAD.
 1.67.2.1 06-Oct-2007  yamt sync with head.
 1.68.6.2 26-Dec-2007  ad Sync with head.
 1.68.6.1 08-Dec-2007  ad Sync with head.
 1.68.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.68.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.68.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.69.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.74.12.4 24-Sep-2008  skrll Some build fixes.
 1.74.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.74.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.74.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.74.10.2 11-Mar-2010  yamt sync with head
 1.74.10.1 04-May-2009  yamt sync with head.
 1.74.8.1 04-Jun-2008  yamt sync with head
 1.74.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.74.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.76.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.76.4.1 19-Oct-2008  haad Sync with HEAD.
 1.77.4.1 25-Nov-2008  snj branches: 1.77.4.1.4;
Pull up following revision(s) (requested by mrg in ticket #121):
sys/compat/netbsd32/syscalls.master: revision 1.74
sys/compat/netbsd32/netbsd32.h: revision 1.78
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.149
implement netbsd32__sched_setparam(), netbsd32__sched_getparam(),
netbsd32__sched_setaffinity() and netbsd32__sched_getaffinity().
 1.77.4.1.4.1 12-Sep-2009  matt Add support for netbsd32___mount50. There's got to be a better of doing this.
Maybe pushing it down to vfs. This only supports mfs/ufs/cd9660 and probably
tmpfs.
 1.77.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.77.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.77.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.78.4.2 04-Jan-2009  christos add new syscalls.
 1.78.4.1 22-Nov-2008  christos file netbsd32.h was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.81.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.84.8.2 15-Feb-2011  bouyer implement COMPAT_NETBSD32 quotactl syscalls (both new and COMPAT_50)
 1.84.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.84.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.84.4.2 21-Apr-2011  rmind sync with head
 1.84.4.1 05-Mar-2011  rmind sync with head
 1.88.6.4 29-Apr-2012  mrg sync to latest -current.
 1.88.6.3 06-Mar-2012  mrg sync to -current
 1.88.6.2 24-Feb-2012  mrg sync to -current.
 1.88.6.1 18-Feb-2012  mrg merge to -current.
 1.88.2.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.88.2.2 30-Oct-2012  yamt sync with head
 1.88.2.1 17-Apr-2012  yamt sync with head
 1.92.2.3 18-Mar-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1025):
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.184
sys/uvm/uvm_swap.c: revision 1.166
sys/uvm/uvm_swap.h: revision 1.20
sys/compat/netbsd32/netbsd32.h: revision 1.99
Properly translate struct swapent for COMPAT_NETBSD32
Properly translate struct swapent for COMPAT_NETBSD32 (missing commit)
 1.92.2.2 13-Dec-2012  riz Pull up following revision(s) (requested by bouyer in ticket #742):
sys/compat/netbsd32/netbsd32.h: revision 1.94
sys/compat/netbsd32/netbsd32_fs.c: revision 1.63
allow mounting ext2fs and msdosfs
while there also enable lfs but that's untested
 1.92.2.1 12-Apr-2012  riz Pull up following revision(s) (requested by martin in ticket #175):
sys/kern/kern_exit.c: revision 1.238
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.4
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.5
sys/uvm/uvm_extern.h: revision 1.183
lib/libc/gen/posix_spawn_fileactions.c: revision 1.2
sys/kern/kern_exec.c: revision 1.348
sys/kern/kern_exec.c: revision 1.349
sys/compat/netbsd32/syscalls.master: revision 1.95
sys/uvm/uvm_glue.c: revision 1.159
sys/uvm/uvm_map.c: revision 1.317
sys/compat/netbsd32/netbsd32.h: revision 1.95
sys/kern/exec_elf.c: revision 1.38
sys/sys/spawn.h: revision 1.2
sys/sys/exec.h: revision 1.135
sys/compat/netbsd32/netbsd32_execve.c: revision 1.34
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
Fix asynchronous posix_spawn child exit status (and test for it).
 1.95.2.3 03-Dec-2017  jdolecek update from HEAD
 1.95.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.95.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.96.2.1 18-May-2014  rmind sync with head
 1.99.2.1 10-Aug-2014  tls Rebase.
 1.102.2.1 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.103.2.4 05-Dec-2016  skrll Sync with HEAD
 1.103.2.3 05-Oct-2016  skrll Sync with HEAD
 1.103.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.103.2.1 22-Sep-2015  skrll Sync with HEAD
 1.109.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.109.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.114.8.4 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1833):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.114.8.3 25-Aug-2018  martin Pull up following revision(s) (requested by mrg in ticket #977):

sys/compat/netbsd32/netbsd32_fs.c: revision 1.81
sys/compat/netbsd32/netbsd32.h: revision 1.119

support nullfs in netbsd32.
 1.114.8.2 14-Apr-2018  snj Pull up revision 1.116 of sys/compat/netbsd32/netbsd32.h to fix fallout
from ticket #713:
include <compat/sys/siginfo.h> for siginfo32_t.
 1.114.8.1 12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #713):

sys/modules/procfs/Makefile: revision 1.4
sys/miscfs/procfs/procfs_vfsops.c: revision 1.98
bin/ps/ps.1: revision 1.108
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.32
sys/miscfs/procfs/procfs_vnops.c: revision 1.198
sys/kern/sys_ptrace_common.c: revision 1.23
sys/kern/sys_ptrace_common.c: revision 1.24
sbin/mount_procfs/mount_procfs.8: revision 1.36
sys/kern/sys_ptrace_common.c: revision 1.25
sys/kern/sys_ptrace.c: revision 1.5
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.30
sys/sys/proc.h: revision 1.342
sys/kern/sys_ptrace_common.c: revision 1.26
sys/miscfs/procfs/procfs_ctl.c: file removal
sys/kern/sys_ptrace_common.c: revision 1.27
sys/miscfs/procfs/procfs_subr.c: revision 1.109
sys/kern/sys_ptrace_common.c: revision 1.28
sys/secmodel/extensions/secmodel_extensions.c: revision 1.8
sys/kern/sys_ptrace_common.c: revision 1.29
sys/sys/ptrace.h: revision 1.62
sys/compat/netbsd32/netbsd32_signal.c: revision 1.45
share/man/man9/kauth.9: revision 1.109
sys/miscfs/procfs/files.procfs: revision 1.12
sys/compat/netbsd32/netbsd32.h: revision 1.115
sys/miscfs/procfs/procfs.h: revision 1.72
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.5
sys/kern/kern_sig.c: revision 1.337
sys/sys/kauth.h: revision 1.75
sys/sys/sysctl.h: revision 1.224
sys/kern/sys_ptrace_common.c: revision 1.30
sys/kern/sys_ptrace_common.c: revision 1.31
sys/kern/sys_ptrace_common.c: revision 1.32
sys/kern/sys_ptrace_common.c: revision 1.33
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.20
sys/kern/sys_ptrace_common.c: revision 1.34
sys/kern/sys_ptrace_common.c: revision 1.36
sys/kern/kern_proc.c: revision 1.207
sys/kern/kern_exit.c: revision 1.269
doc/TODO.ptrace: revision 1.29

Make {s,g}et{db,fp,}regs work again for PK_32 processes
XXX: pullup-8

add disgusting magic to handle compat_netbsd32 as a module.

use process_*reg32 instead of struct *reg32.

Remove the filesystem tracing feature

This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
- /proc/#/ctl from mount_procfs(8)
- P_FSTRACE note from the documentation of ps(1)
- /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
- KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
- source code file miscfs/procfs/procfs_ctl.c
- PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
- KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
- PSL_FSTRACE (0x00010000) from sys/sys/proc.h
- P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed

PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).
Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>

untangle the mess:
- factor out common code
- break each ptrace subcall to its own sub-function
.. more to come ...
- reduce ifdef ugliness by moving it up top.
- factor out PT_IO and make PT_{READ,WRITE}_{I,D} use it
- factor out PT_DUMPCORE
- factor out sendsig code
.. more to come ...

handle siginfo requests for ptrace32

ptrace: Partially undo PT_{READ,WRITE}_{I,D} and unbreak these commands

The refactored code did not work and was generating EFAULT.

Sponsored by <The NetBSD Foundation>

Merge the code back; the problem was that since we are reading/writing
to a kernel address for PT_{READ,WRITE}_{I,D} we need the kernel vmspace.
provide separate read and write functions to accomodate register functions
that need a size argument.

don't ignore error from copyout_piod

Use the proper process (the tracee) to get information about lwps and
registers and the tracer for vmspace.

Add new sysctl(3) entry: security.models.extensions.user_set_dbregs

Model this new sysctl(3) entry after "user_set_cpu_affinity" in the same
level of sysctl(3) switches.

Allow to read unconditionally Debug Registers (no change here). This is
convenient as even if a user of a debugger does not use hardware assisted
watchpoints/breakpoints, a debugger can still prompt these values to store
in an internal cache with context of registers. Reading them should have
no security concerns.

Add a paranoid MI switch that prohibits by default setting these registers
by a regular user (non-superuser). Make this switch disabled by default.
There are enough reserved bits out there to allow using them
unconditionally on hardened hosts.

Features shipped with Debug Registers are optional features in debuggers.
There is no reduction in elementary functionality.

Reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.116.2.19 25-Jan-2019  pgoyette Move the netbsd32_machine32_hook into the main kernel with most of
the other hooks.

Although this hook might better belong in compat/netbsd32/ code,
there are some machines without a netbsd32 module (for example, i386
and sgimips) which still have consumers/users of this hook. :(
 1.116.2.18 24-Jan-2019  pgoyette Rework placement of the new netbsd32_machine32_hook
 1.116.2.17 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.116.2.16 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.116.2.15 27-Sep-2018  pgoyette Hook up the arm compat_netbsd32_13 & _16 code
 1.116.2.14 24-Sep-2018  pgoyette syntax: add missing )
 1.116.2.13 24-Sep-2018  pgoyette Convert yet another function pointer to the MP-safe mechanism
 1.116.2.12 23-Sep-2018  pgoyette The kern_proc_32 hook is defined in non-compat code. Don't redefine.
 1.116.2.11 23-Sep-2018  pgoyette More work on kern_proc_32
 1.116.2.10 23-Sep-2018  pgoyette White space for readability
 1.116.2.9 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.116.2.8 18-Sep-2018  pgoyette Use the MP-safe compat hooks for netbsd32_compat_80.c's modctl
 1.116.2.7 14-Sep-2018  pgoyette Forward declaration of struct netbsd32_modctl_args
 1.116.2.6 14-Sep-2018  pgoyette Move some extern definitions into netbsd32_netbsd.h rather than having
them in the .c files.
 1.116.2.5 14-Sep-2018  pgoyette OMG it builds!

Finish rearranging the amd64 MD compat_netbsd32 code.

XXX Other architectures will be dealt with later.
 1.116.2.4 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.116.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.116.2.2 21-May-2018  pgoyette Sync with HEAD
 1.116.2.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.118.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.118.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.118.2.1 10-Jun-2019  christos Sync with HEAD
 1.123.4.3 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.123.4.2 24-Apr-2022  martin Pull up following revision(s) (requested by reinoud in ticket #1438):

sys/compat/netbsd32/netbsd32.h: revision 1.140
sys/compat/netbsd32/netbsd32_fs.c: revision 1.95
sys/fs/udf/udf_subr.c: revision 1.169

Fix endian issue with UDF extended attribute handling

Implement support for mounting UDF in compat32
Fixes PR#56801
 1.123.4.1 19-Nov-2019  martin Pull up following revision(s) (requested by rin in ticket #457):

sys/compat/sys/siginfo.h: revision 1.9
sys/compat/netbsd32/netbsd32.h: revision 1.131

8-byte objects on i386 or arm-oabi are aligned in 4-byte boundary.

Therefore, we must use __attribute__((__aligned__(4))) for them.
netbsd32_{,u}int64 are provided for this purpose. However, we
cannot use it in <compat/sys/siginfo.h> due to circular dependency
b/w <machine/netbsd32_machdep.h>.

In order to distangle it, we choose here to have a duplicate type,
netbsd32_siginfo_uint64, in <compat/sys/siginfo.h>. The equivalence
with netbsd32_uint64 is asserted in <compat/netbsd32/netbsd32.h>.

Now, gdb for i386 works again on amd64 kernel.

Based on patch provided by kamil. Thanks!

XXX
pullup to netbsd-9
 1.133.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.133.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.3 25-Apr-2021  christos All mips64 has compat_netbsd32
 1.2 06-Mar-2020  pgoyette branches: 1.2.8;
According to mrg@ we need to include aarch64 in the list of those
that need to support COMPAT_NETBSD32
 1.1 04-Feb-2019  mrg branches: 1.1.4;
don't assume _LP64 == supports COMPAT_NETBSD32.

this is not true for alpha, ia64 and arm32 ports, and the first two
were not building because of it, and the latter would be missing
the oabi support (likely not a big deal, but still wrong.)

add a makefile fragment that tells you if it is supported and include
it where needed to define COMPAT_NETBSD32 when building the normal
kernel (ie, modules & rump.)


fixes alpha build, probably fixes ia64 build.


XXX: still leaves some netbsd32 code in rf_netbsdkintf.c, that should
be moved into some hooks, but first the configuration setup
needs to be moved into a common function the netbsd32 code can
call into, vs living in the switch case itself.
 1.1.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.4.2 10-Jun-2019  christos Sync with HEAD
 1.1.4.1 04-Feb-2019  christos file netbsd32.mk was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.2.8.1 13-May-2021  thorpej Sync with HEAD.
 1.1 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.20 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.19 27-Jan-2019  pgoyette branches: 1.19.12;
Merge the [pgoyette-compat] branch
 1.18 29-May-2008  mrg branches: 1.18.12; 1.18.86; 1.18.88;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.17 20-Dec-2007  dsl branches: 1.17.6; 1.17.8; 1.17.10; 1.17.12;
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 08-Dec-2007  dsl branches: 1.16.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.15 18-Mar-2007  dsl branches: 1.15.8; 1.15.10; 1.15.18;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.14 09-Feb-2007  ad branches: 1.14.2; 1.14.6; 1.14.8; 1.14.10;
Merge newlock2 to head.
 1.13 11-Dec-2005  christos branches: 1.13.20;
merge ktrace-lwp.
 1.12 04-Dec-2003  atatat branches: 1.12.16;
Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.11 29-Jun-2003  fvdl branches: 1.11.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.10 29-Jun-2003  martin struct proc * -> struct lwp *
 1.9 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.7 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.6 30-Nov-2000  jdolecek branches: 1.6.2; 1.6.4;
fix typo - it should be compat_09_netbsd32_uname, not compat_09_netbsd32_ouname
 1.5 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 11-Oct-1999  eeh branches: 1.4.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.3 25-Mar-1999  mrg branches: 1.3.8;
SPARC32->NETBSD32
 1.2 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.2.4 11-Nov-2002  nathanw Catch up to -current
 1.6.2.3 23-Aug-2002  petrov lwpification.
 1.6.2.2 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.6.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.16.3 21-Jan-2008  yamt sync with head
 1.12.16.2 03-Sep-2007  yamt sync with head.
 1.12.16.1 26-Feb-2007  yamt sync with head.
 1.13.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.14.10.1 29-Mar-2007  reinoud Pullup to -current
 1.14.8.1 11-Jul-2007  mjf Sync with head.
 1.14.6.1 10-Apr-2007  ad Sync with head.
 1.14.2.1 24-Mar-2007  yamt sync with head.
 1.15.18.1 26-Dec-2007  ad Sync with head.
 1.15.10.1 09-Jan-2008  matt sync with HEAD
 1.15.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.17.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.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.17.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.17.10.1 04-May-2009  yamt sync with head.
 1.17.8.1 04-Jun-2008  yamt sync with head
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.88.1 10-Jun-2019  christos Sync with HEAD
 1.18.86.6 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.18.86.5 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.18.86.4 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.18.86.3 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.18.86.2 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.18.86.1 10-Sep-2018  pgoyette Initial cut at a compat_netbsd32_09 and compat_netbsd32_12 modules.
 1.18.12.2 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.18.12.1 29-May-2008  mrg file netbsd32_compat_09.c was added on branch christos-time_t on 2008-05-29 14:51:27 +0000
 1.19.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.26 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.25 03-Dec-2015  pgoyette branches: 1.25.16; 1.25.18;
Split out the SYSV IPC stuff into its own compat_netbsd32_sysvipc
module. Adjust dependencies as needed.
 1.24 23-Apr-2010  rmind branches: 1.24.18; 1.24.36;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.23 11-Jan-2009  christos branches: 1.23.4; 1.23.6;
merge christos-time_t
 1.22 20-Dec-2007  dsl branches: 1.22.6; 1.22.10; 1.22.12; 1.22.18; 1.22.24;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.21 08-Dec-2007  dsl branches: 1.21.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.20 03-Jun-2007  dsl branches: 1.20.6; 1.20.8; 1.20.16;
Split netbsd32___semctl14() so that it is callable from
compat_10_netbsd32_sys_semsys() (where the one parameter is already in
kernel space).
Note that the code in compat_10_netbsd32_sys_semsys() has always been wrong,
since it called compat_14_sys___semctl() - which would read 64bit values!
 1.19 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.18 04-Mar-2007  christos branches: 1.18.2; 1.18.4; 1.18.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 09-Feb-2007  ad branches: 1.17.2;
Merge newlock2 to head.
 1.16 10-Nov-2005  christos branches: 1.16.22;
need compat/sys/shm.h
 1.15 18-Jan-2003  thorpej branches: 1.15.2; 1.15.18;
Merge the nathanw_sa branch.
 1.14 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.13 29-Apr-2002  mrg build the netbsd32_compat* objects into libcompat.a, so they are available
to emulations not just netbsd itself. rename the compat_10 functions to
match everything else. fixes a problem reported by julian coleman.
 1.12 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.11 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.10 30-May-2001  mrg branches: 1.10.2;
use _KERNEL_OPT.
 1.9 29-Nov-2000  jdolecek branches: 1.9.2;
LKMify
 1.8 18-Nov-2000  mrg get rid of remaining warnings.
 1.7 18-Nov-2000  mrg kill gcc warnings.
 1.6 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.4 11-Oct-1999  eeh branches: 1.4.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.3 25-Mar-1999  mrg branches: 1.3.8;
move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.2 19-Oct-1998  tron Defopt SYSVMSG, SYSVSEM and SYSVSHM.
 1.1 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.4.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.9.2.7 11-Nov-2002  nathanw Catch up to -current
 1.9.2.6 23-Aug-2002  petrov lwpification.
 1.9.2.5 20-Jun-2002  nathanw Catch up to -current.
 1.9.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.9.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.9.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.9.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.18.4 21-Jan-2008  yamt sync with head
 1.15.18.3 03-Sep-2007  yamt sync with head.
 1.15.18.2 26-Feb-2007  yamt sync with head.
 1.15.18.1 21-Jun-2006  yamt sync with head.
 1.15.2.1 11-Dec-2005  christos Sync with head.
 1.16.22.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.17.2.2 24-Mar-2007  yamt sync with head.
 1.17.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.18.4.1 11-Jul-2007  mjf Sync with head.
 1.18.2.2 09-Jun-2007  ad Sync with head.
 1.18.2.1 10-Apr-2007  ad Sync with head.
 1.20.16.1 26-Dec-2007  ad Sync with head.
 1.20.8.1 09-Jan-2008  matt sync with HEAD
 1.20.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.21.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.22.24.1 04-Jan-2009  christos fix module build.
 1.22.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.22.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.22.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.22.10.2 11-Aug-2010  yamt sync with head.
 1.22.10.1 04-May-2009  yamt sync with head.
 1.22.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.23.6.1 30-May-2010  rmind sync with head
 1.23.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.24.36.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.24.18.1 03-Dec-2017  jdolecek update from HEAD
 1.25.18.1 10-Jun-2019  christos Sync with HEAD
 1.25.16.3 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.25.16.2 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.25.16.1 10-Sep-2018  pgoyette Initial cut at a compat_netbsd32_09 and compat_netbsd32_12 modules.
 1.4 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.3 29-Jul-2023  rin COMPAT_NETBSD32: No need to have compat_100_netbsd32_kevent_fetch_timeout.
NFCI.
 1.2 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 1.1 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.3 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4; 1.2.14;
Merge the [pgoyette-compat] branch
 1.1 12-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_compat_10_sysv.c was initially added on branch pgoyette-compat.
 1.1.2.1 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.2.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file netbsd32_compat_10_sysv.c was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.2 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.1 19-May-2024  christos version dup3
 1.36 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.35 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.34 27-Jan-2019  pgoyette branches: 1.34.4; 1.34.12;
Merge the [pgoyette-compat] branch
 1.33 10-Dec-2012  chs branches: 1.33.30; 1.33.36; 1.33.38;
fix these *stat routines: don't pass a kernel stack buffer
to a function that will try to copyout() to it.
just do both layers of compat translation here.
 1.32 30-Jan-2009  njoly branches: 1.32.14; 1.32.24;
Cleanup. Kill a few netbsd32_caddr_t in syscalls argument types.
 1.31 29-May-2008  mrg branches: 1.31.6; 1.31.12;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.30 20-Dec-2007  dsl branches: 1.30.6; 1.30.8; 1.30.10; 1.30.12;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.29 08-Dec-2007  dsl branches: 1.29.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.28 04-Dec-2007  dsl Remove all the __P
 1.27 30-Apr-2007  dsl branches: 1.27.6; 1.27.8; 1.27.14; 1.27.16;
Remove some unused calls to stackgap_init()
 1.26 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.25 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.24 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.23 04-Mar-2007  christos branches: 1.23.2; 1.23.4; 1.23.6;
fix fallout from caddr_t changes.
 1.22 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.21 09-Feb-2007  ad branches: 1.21.2;
Merge newlock2 to head.
 1.20 11-Dec-2005  christos branches: 1.20.20;
merge ktrace-lwp.
 1.19 13-Sep-2005  christos make this compile again.
 1.18 29-Jun-2003  fvdl branches: 1.18.2; 1.18.18;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.17 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.16 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.15 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.14 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.13 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.12 25-Aug-2001  mrg update copyright notices.
 1.11 30-May-2001  mrg branches: 1.11.2;
use _KERNEL_OPT.
 1.10 07-Feb-2001  mrg branches: 1.10.2;
compat_12_netbsd32_{,fl}stat12() were not copyout()ing the converted result.
 1.9 03-Dec-2000  fvdl Include opt_* files to make sure prototypes are included.
 1.8 01-Dec-2000  jdolecek prototype netbsd32_stat12_to_netbsd32()
 1.7 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.6 11-Oct-1999  eeh branches: 1.6.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.5 25-Mar-1999  mrg branches: 1.5.8;
SPARC32->NETBSD32
 1.4 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.3 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.2 29-Aug-1998  mrg move <vm/vm_swap.h> to <sys/swap.h>. <vm/vm_swap.h> still works for now (goes away later)
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.5.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.6.2.1 08-Dec-2000  bouyer Sync with HEAD.
 1.10.2.7 11-Nov-2002  nathanw Catch up to -current
 1.10.2.6 23-Aug-2002  petrov lwpification.
 1.10.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.10.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.10.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.10.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.10.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.18.18.5 21-Jan-2008  yamt sync with head
 1.18.18.4 07-Dec-2007  yamt sync with head
 1.18.18.3 03-Sep-2007  yamt sync with head.
 1.18.18.2 26-Feb-2007  yamt sync with head.
 1.18.18.1 21-Jun-2006  yamt sync with head.
 1.18.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.20.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.21.2.3 07-May-2007  yamt sync with head.
 1.21.2.2 24-Mar-2007  yamt sync with head.
 1.21.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.23.6.2 29-Mar-2007  reinoud Pullup to -current
 1.23.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.23.4.1 11-Jul-2007  mjf Sync with head.
 1.23.2.2 27-May-2007  ad Sync with head.
 1.23.2.1 10-Apr-2007  ad Sync with head.
 1.27.16.2 26-Dec-2007  ad Sync with head.
 1.27.16.1 08-Dec-2007  ad Sync with head.
 1.27.14.2 27-Dec-2007  mjf Sync with HEAD.
 1.27.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.27.8.1 09-Jan-2008  matt sync with HEAD
 1.27.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.29.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.30.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.30.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.30.10.1 04-May-2009  yamt sync with head.
 1.30.8.1 04-Jun-2008  yamt sync with head
 1.30.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.31.12.2 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.31.12.1 29-May-2008  mrg file netbsd32_compat_12.c was added on branch christos-time_t on 2008-05-29 14:51:27 +0000
 1.31.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.32.24.1 25-Feb-2013  tls resync with head
 1.32.14.1 16-Jan-2013  yamt sync with (a bit old) head
 1.33.38.1 10-Jun-2019  christos Sync with HEAD
 1.33.36.9 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.33.36.8 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.33.36.7 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.33.36.6 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.33.36.5 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.33.36.4 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.33.36.3 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.33.36.2 10-Sep-2018  pgoyette More compat_netbsd32_xx modules
 1.33.36.1 10-Sep-2018  pgoyette Initial cut at a compat_netbsd32_09 and compat_netbsd32_12 modules.
 1.33.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.34.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.34.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

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

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.28 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.27 27-Jan-2019  pgoyette branches: 1.27.12;
Merge the [pgoyette-compat] branch
 1.26 24-Jan-2014  christos branches: 1.26.28; 1.26.30;
need to lock the process.
 1.25 29-May-2008  mrg branches: 1.25.12; 1.25.34; 1.25.44; 1.25.50;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.24 20-Dec-2007  dsl branches: 1.24.6; 1.24.8; 1.24.10; 1.24.12;
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.23 08-Dec-2007  dsl branches: 1.23.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.22 16-Jun-2007  dsl branches: 1.22.6; 1.22.8; 1.22.16;
Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
 1.21 03-Jun-2007  dsl Add a #define that expands to the compat wrapper for sigaltstack1().
Use it for the netbsd32_compat_13.c version of the code.
 1.20 03-Jun-2007  dsl Calling sigaltstack1() directly is so much easier than going via
compat_13_sys_sigaltstack().
 1.19 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.18 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.17 04-Mar-2007  christos branches: 1.17.2; 1.17.4; 1.17.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 09-Feb-2007  ad branches: 1.16.2;
Merge newlock2 to head.
 1.15 11-Dec-2005  christos branches: 1.15.20;
merge ktrace-lwp.
 1.14 13-Sep-2005  christos make this compile again.
 1.13 18-Jan-2003  thorpej branches: 1.13.2; 1.13.18;
Merge the nathanw_sa branch.
 1.12 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.11 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.10 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.9 25-Aug-2001  mrg update copyright notices.
 1.8 07-Feb-2001  mrg branches: 1.8.2; 1.8.4;
fix the glaring errors in compat_13_netbsd32_sigaltstack13
 1.7 09-Jul-2000  mrg - massive warning fix fest.
- fix pread/pwrite return values (plus some other syscalls that looked
similarly broken).
- prototypes and clean up for netbsd32_ioctl.c

now getpw*() works under compat32!
 1.6 30-Mar-2000  augustss Kill register declarations.
 1.5 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.4 11-Oct-1999  eeh branches: 1.4.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.3 25-Mar-1999  mrg branches: 1.3.8;
move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.2 26-Aug-1998  mrg use right syscalls
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.8.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.2.6 11-Nov-2002  nathanw Catch up to -current
 1.8.2.5 23-Aug-2002  petrov lwpification.
 1.8.2.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.8.2.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.13.18.4 21-Jan-2008  yamt sync with head
 1.13.18.3 03-Sep-2007  yamt sync with head.
 1.13.18.2 26-Feb-2007  yamt sync with head.
 1.13.18.1 21-Jun-2006  yamt sync with head.
 1.13.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.20.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.20.2 11-Jan-2007  ad Checkpoint work in progress.
 1.15.20.1 21-Oct-2006  ad Checkpoint work in progress on locking and per-LWP signals. Very much a
a work in progress and there is still a lot to do.
 1.16.2.2 24-Mar-2007  yamt sync with head.
 1.16.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.6.2 29-Mar-2007  reinoud Pullup to -current
 1.17.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.17.4.1 11-Jul-2007  mjf Sync with head.
 1.17.2.3 15-Jul-2007  ad Sync with head.
 1.17.2.2 09-Jun-2007  ad Sync with head.
 1.17.2.1 10-Apr-2007  ad Sync with head.
 1.22.16.1 26-Dec-2007  ad Sync with head.
 1.22.8.1 09-Jan-2008  matt sync with HEAD
 1.22.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.23.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.24.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.24.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.24.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.24.10.1 04-May-2009  yamt sync with head.
 1.24.8.1 04-Jun-2008  yamt sync with head
 1.24.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.50.1 18-May-2014  rmind sync with head
 1.25.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.34.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.12.2 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.25.12.1 29-May-2008  mrg file netbsd32_compat_13.c was added on branch christos-time_t on 2008-05-29 14:51:27 +0000
 1.26.30.1 10-Jun-2019  christos Sync with HEAD
 1.26.28.9 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.26.28.8 29-Sep-2018  pgoyette Make sure that the netbsd32_compat_16 code is available to compat_netbsd_13
 1.26.28.7 27-Sep-2018  pgoyette Hook up the arm compat_netbsd32_13 & _16 code
 1.26.28.6 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.26.28.5 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.26.28.4 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.26.28.3 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.26.28.2 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.26.28.1 10-Sep-2018  pgoyette More compat_netbsd32_xx modules
 1.27.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.30 27-Feb-2019  mrg this file was moved to netbsd32_compat_14_sysv.c.
 1.29 21-Feb-2019  mrg fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)
 1.28 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.27 27-Dec-2018  maxv Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.26 07-Jan-2016  joerg branches: 1.26.10; 1.26.16; 1.26.18;
Avoid defining inline functions that are never used when certain options
are missing.
 1.25 03-Dec-2015  pgoyette Strange patch(1) behavior got me three copies of the code. One is
sufficient so remove the excess.
 1.24 03-Dec-2015  pgoyette If compiling as part of a built-in kernel module, make sure we include
the relevant opt_sysv.h file
 1.23 03-Dec-2015  pgoyette Missed these.

Only include the compat_14 sys calls if this being compiled as part of
the compat_netbsd32_sysvipc module.
 1.22 03-Dec-2015  pgoyette Split out the SYSV IPC stuff into its own compat_netbsd32_sysvipc
module. Adjust dependencies as needed.
 1.21 20-Dec-2007  dsl branches: 1.21.12; 1.21.56; 1.21.74; 1.21.76; 1.21.78; 1.21.82;
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 08-Dec-2007  dsl branches: 1.20.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.19 20-Mar-2007  cube branches: 1.19.8; 1.19.10; 1.19.18;
More SCARG_P32 fallout.
 1.18 20-Mar-2007  cube Fix typo. Reported by martin.
 1.17 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.16 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.15 04-Mar-2007  christos branches: 1.15.2; 1.15.4; 1.15.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 09-Feb-2007  ad branches: 1.14.2;
Merge newlock2 to head.
 1.13 23-Jul-2006  ad branches: 1.13.4;
Use the LWP cached credentials where sane.
 1.12 24-Dec-2005  perry branches: 1.12.4; 1.12.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.11 10-Nov-2005  christos need compat/sys/shm.h
 1.10 26-Feb-2005  perry branches: 1.10.4;
nuke trailing whitespace
 1.9 18-Jan-2003  thorpej branches: 1.9.2; 1.9.10; 1.9.12;
Merge the nathanw_sa branch.
 1.8 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.7 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.6 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.5 30-Nov-2000  jdolecek branches: 1.5.2; 1.5.4;
only define SYSVMSG, SYSVSEM, SYSVSHM if it's not defined already
 1.4 18-Nov-2000  mrg kill gcc warnings.
 1.3 09-Jul-2000  mrg - massive warning fix fest.
- fix pread/pwrite return values (plus some other syscalls that looked
similarly broken).
- prototypes and clean up for netbsd32_ioctl.c

now getpw*() works under compat32!
 1.2 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.1 11-Oct-1999  eeh branches: 1.1.2; 1.1.8;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.5 11-Nov-2002  nathanw Catch up to -current
 1.5.2.4 23-Aug-2002  petrov lwpification.
 1.5.2.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.5.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.5.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.9.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.10.1 29-Apr-2005  kent sync with -current
 1.9.2.2 11-Dec-2005  christos Sync with head.
 1.9.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.4.5 21-Jan-2008  yamt sync with head
 1.10.4.4 03-Sep-2007  yamt sync with head.
 1.10.4.3 26-Feb-2007  yamt sync with head.
 1.10.4.2 30-Dec-2006  yamt sync with head.
 1.10.4.1 21-Jun-2006  yamt sync with head.
 1.12.8.1 11-Aug-2006  yamt sync with head
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.14.2.2 24-Mar-2007  yamt sync with head.
 1.14.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.6.2 29-Mar-2007  reinoud Pullup to -current
 1.15.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 10-Apr-2007  ad Sync with head.
 1.19.18.1 26-Dec-2007  ad Sync with head.
 1.19.10.1 09-Jan-2008  matt sync with HEAD
 1.19.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.20.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.21.82.2 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.21.82.1 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1668):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.21.78.2 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.21.78.1 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1668):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.21.76.2 19-Mar-2016  skrll Sync with HEAD
 1.21.76.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.21.74.2 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.21.74.1 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1668):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.21.56.1 03-Dec-2017  jdolecek update from HEAD
 1.21.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.21.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.26.18.1 10-Jun-2019  christos Sync with HEAD
 1.26.16.1 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.26.10.2 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.26.10.1 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1151):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.4 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.3 21-Feb-2019  mrg branches: 1.3.4; 1.3.14;
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.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 12-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_compat_14_sysv.c was initially added on branch pgoyette-compat.
 1.1.2.2 03-Jan-2019  pgoyette Bring in some more changes from HEAD.
 1.1.2.1 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.3.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3.4.2 10-Jun-2019  christos Sync with HEAD
 1.3.4.1 21-Feb-2019  christos file netbsd32_compat_14_sysv.c was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.10 28-Feb-2025  wiz whitespace
 1.9 28-Feb-2025  christos fix previous (wrong ifdef), thanks wiz@
 1.8 28-Feb-2025  christos PR/59100: Onno van der Linden: i386 compat32 broken on amd64
 1.7 22-Nov-2024  mlelstv Crude patch to allow building and loading of compat_16 and compat_netbsd32_16 code
on aarch64.
 1.6 18-Aug-2024  riastradh netbsd32_compat_16.c: Fix whitespace.

No functional change intended.
 1.5 01-May-2024  mlelstv branches: 1.5.2;
Enable compat sigreturn system call.
 1.4 26-Nov-2021  ryo branches: 1.4.4;
Fix anonymous memory object leak for sigcode.

- Repeating "modload compat_linux && /emul/linux/bin/ls && modunload compat_linux"
will reproduce this problem.
- It cause in exec_sigcode_map(), anon-object for sigcode was created at
first exec, but it remained even after exec_remove.
- Fixed that the anon-object for sigcode is created at exec_add(), and the
anon-object reference is removed at exec_remove().
- sigobject_lock is no longer needed since it is locked by exec_lock.
- The compat_16 module rewrites the e_sigcode entry in emul_netbsd directly and
does not use exec_add()/exec_remove(), so it needs to call
sigcode_alloc()/sigcode_free() on its own.
 1.3 15-Dec-2019  tsutsui Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4; 1.2.6;
Merge the [pgoyette-compat] branch
 1.1 12-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_compat_16.c was initially added on branch pgoyette-compat.
 1.1.2.5 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.1.2.4 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.1.2.3 14-Sep-2018  pgoyette OMG it builds!

Finish rearranging the amd64 MD compat_netbsd32 code.

XXX Other architectures will be dealt with later.
 1.1.2.2 14-Sep-2018  pgoyette Work in progress - get the arch-specific netbsd32_machdep.c code to
build as a module.

XXX Doesn't work when the code is built-in to the kernel.
 1.1.2.1 12-Sep-2018  pgoyette Add some more module glue
 1.2.6.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.2.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file netbsd32_compat_16.c was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.4.4.1 26-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #989):

sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.6
sys/compat/netbsd32/netbsd32_signal.c: revision 1.54

In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Enable compat sigreturn system call.

netbsd32_compat_16.c: Fix whitespace.
No functional change intended.
 1.5.2.1 02-Aug-2025  perseant Sync with HEAD
 1.42 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.41 19-Jan-2021  wiz Fix syntax error
 1.40 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.39 01-Jan-2020  maxv branches: 1.39.8;
Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.38 27-Jan-2019  pgoyette branches: 1.38.4;
Merge the [pgoyette-compat] branch
 1.37 10-May-2018  christos branches: 1.37.2;
add {send,recv}mmsg
 1.36 13-Apr-2017  hannken branches: 1.36.4; 1.36.10;
Switch compat_20_netbsd32_getfsstat() to mountlist iterator.
 1.35 28-Mar-2017  chs never pass mp->mnt_stat to dostatvfs(), always use a separate buffer.
dostatvfs() clears its buffer, but mp->mnt_stat should never be cleared.
 1.34 05-Sep-2014  matt branches: 1.34.2; 1.34.4; 1.34.6;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.33 24-Jan-2014  christos branches: 1.33.4; 1.33.10;
remove useless flag mangling. It is done already.
 1.32 24-Jan-2014  christos Fix locking botch, and ...
Yes, we want to be careful because the sizes are different.
 1.31 27-Nov-2013  christos Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
 1.30 23-Nov-2013  christos fix open-coded mountlist scan
 1.29 23-Nov-2013  riz Since mountlist is now a TAILQ, convert some missed usages
so things build again.
 1.28 23-Apr-2010  rmind branches: 1.28.8; 1.28.18; 1.28.22;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.27 29-Jun-2009  dholland branches: 1.27.2; 1.27.4;
Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.26 24-Jun-2008  ad branches: 1.26.10; 1.26.12;
Replace references to getsock/getvnode.
 1.25 29-May-2008  mrg branches: 1.25.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.24 06-May-2008  ad branches: 1.24.2;
PR kern/38141 lookup/vfs_busy acquire rwlock recursively

Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
 1.23 30-Apr-2008  ad PR kern/38135 vfs_busy/vfs_trybusy confusion

The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.
 1.22 30-Apr-2008  jmmv Fix build of these files after the vfs_trybusy change. Apply the same
modification done in compat/common/vfs_syscalls_20.c:1.27.
 1.21 21-Mar-2008  ad branches: 1.21.2; 1.21.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.20 30-Jan-2008  ad branches: 1.20.6;
PR kern/37706 (forced unmount of file systems is unsafe):

- Do reference counting for 'struct mount'. Each vnode associated with a
mount takes a reference, and in turn the mount takes a reference to the
vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
locking inherited from 4.4BSD with a recursable rwlock.
 1.19 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.18 08-Dec-2007  pooka branches: 1.18.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.17 08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.16 27-Nov-2007  dogcow branches: 1.16.2;
more VFS_STATVFS(x,y,z) fallout; change them to VFS_STATVFS(x,y). (hi, pooka!)
 1.15 10-Oct-2007  ad branches: 1.15.4;
mountlist_slock is now a mutex.
 1.14 18-Jul-2007  briggs branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10;
Fix typo: mnfromname -> mntfromname.
 1.13 17-Jul-2007  christos branches: 1.13.2;
kill silly constants.
 1.12 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.11 16-Apr-2007  pooka I'm not sure if I want to know what MNT_LAXY means, so I'll just
assume the comment has a tyop of MNT_LAZY.
 1.10 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.9 04-Mar-2007  christos branches: 1.9.2; 1.9.4; 1.9.6;
fix fallout from caddr_t changes.
 1.8 04-Mar-2007  christos 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 31-Jul-2006  martin branches: 1.6.4;
Make filehandles opaque to userland
 1.5 07-Mar-2006  thorpej branches: 1.5.2;
Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.4 24-Dec-2005  perry branches: 1.4.4; 1.4.6; 1.4.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.1 17-Jun-2004  cube branches: 1.1.2; 1.1.14;
o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.1.14.9 24-Mar-2008  yamt sync with head.
 1.1.14.8 04-Feb-2008  yamt sync with head.
 1.1.14.7 21-Jan-2008  yamt sync with head
 1.1.14.6 07-Dec-2007  yamt sync with head
 1.1.14.5 27-Oct-2007  yamt sync with head.
 1.1.14.4 03-Sep-2007  yamt sync with head.
 1.1.14.3 26-Feb-2007  yamt sync with head.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 21-Jun-2006  yamt sync with head.
 1.1.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.3 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 17-Jun-2004  skrll file netbsd32_compat_20.c was added on branch ktrace-lwp on 2004-08-03 10:44:21 +0000
 1.4.8.2 11-Aug-2006  yamt sync with head
 1.4.8.1 13-Mar-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.2.2 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.5.2.1 07-Mar-2006  thorpej file netbsd32_compat_20.c was added on branch elad-kernelauth on 2006-03-07 03:32:07 +0000
 1.6.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 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.9.6.1 29-Mar-2007  reinoud Pullup to -current
 1.9.4.1 11-Jul-2007  mjf Sync with head.
 1.9.2.5 09-Oct-2007  ad Fix merge error.
 1.9.2.4 20-Aug-2007  ad Sync with HEAD.
 1.9.2.3 27-May-2007  ad Sync with head.
 1.9.2.2 10-Apr-2007  ad Sync with head.
 1.9.2.1 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.13.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.14.10.2 18-Jul-2007  briggs Fix typo: mnfromname -> mntfromname.
 1.14.10.1 18-Jul-2007  briggs file netbsd32_compat_20.c was added on branch matt-mips64 on 2007-07-18 13:53:35 +0000
 1.14.8.1 14-Oct-2007  yamt sync with head.
 1.14.6.3 23-Mar-2008  matt sync with HEAD
 1.14.6.2 09-Jan-2008  matt sync with HEAD
 1.14.6.1 06-Nov-2007  matt sync with HEAD
 1.14.4.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.14.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.14.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.15.4.3 18-Feb-2008  mjf Sync with HEAD.
 1.15.4.2 27-Dec-2007  mjf Sync with HEAD.
 1.15.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.2.1 26-Dec-2007  ad Sync with head.
 1.18.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.20.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.20.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.20.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.4.4 11-Aug-2010  yamt sync with head.
 1.21.4.3 18-Jul-2009  yamt sync with head.
 1.21.4.2 04-May-2009  yamt sync with head.
 1.21.4.1 16-May-2008  yamt sync with head.
 1.21.2.2 04-Jun-2008  yamt sync with head
 1.21.2.1 18-May-2008  yamt sync with head.
 1.24.2.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.24.2.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.24.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

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

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

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

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.25.2.1 27-Jun-2008  simonb Sync with head.
 1.26.12.1 23-Jul-2009  jym Sync with HEAD.
 1.26.10.2 24-Jun-2008  ad Replace references to getsock/getvnode.
 1.26.10.1 24-Jun-2008  ad file netbsd32_compat_20.c was added on branch christos-time_t on 2008-06-24 11:18:16 +0000
 1.27.4.1 30-May-2010  rmind sync with head
 1.27.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.28.22.1 18-May-2014  rmind sync with head
 1.28.18.2 03-Dec-2017  jdolecek update from HEAD
 1.28.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.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.33.10.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1720:

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

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.33.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.34.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.34.4.1 26-Apr-2017  pgoyette Sync with HEAD
 1.34.2.1 28-Aug-2017  skrll Sync with HEAD
 1.36.10.10 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.36.10.9 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.36.10.8 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.36.10.7 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.36.10.6 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.36.10.5 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.36.10.4 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.36.10.3 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.36.10.2 10-Sep-2018  pgoyette More compat_netbsd32_xx modules
 1.36.10.1 21-May-2018  pgoyette Sync with HEAD
 1.36.4.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.36.4.1 21-Jan-2020  martin Pull up the following, requested by christos in ticket #1487:

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

Fix various info leaks, out of bound access, usage of uninitialized
values and direct access to userland variables from kernel space
and memory leaks in system calls implemented for the compatibility
subsystems.
 1.37.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.37.2.1 10-Jun-2019  christos Sync with HEAD
 1.38.4.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

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

sys/compat: Memset zero before copyout.

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

sys/compat/common/kern_sig_43.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.39
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.59
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.44

Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.

Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.

Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.39.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.36 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.35 31-Jan-2020  maxv branches: 1.35.6;
Fix copyout overflows in fhstat, found by the LGTM bot. Not a big problem
since this syscall is privileged.
 1.34 17-Jan-2020  ad VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode. Matches
FreeBSD.
 1.33 27-Jan-2019  pgoyette branches: 1.33.6;
Merge the [pgoyette-compat] branch
 1.32 03-Sep-2018  riastradh 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.31 05-Dec-2014  maxv branches: 1.31.16; 1.31.18;
User-triggerable kmem_alloc(0).

Ok martin@ christos@

User
 1.30 23-Apr-2010  rmind branches: 1.30.14; 1.30.18; 1.30.20; 1.30.28; 1.30.34; 1.30.36;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.29 26-Jan-2009  njoly branches: 1.29.4; 1.29.6;
Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.28 11-Jan-2009  christos merge christos-time_t
 1.27 19-Nov-2008  ad branches: 1.27.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.26 24-Jun-2008  ad branches: 1.26.2; 1.26.4;
Replace references to getsock/getvnode.
 1.25 29-May-2008  mrg branches: 1.25.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.24 21-Mar-2008  ad branches: 1.24.2; 1.24.4; 1.24.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.23 20-Dec-2007  dsl branches: 1.23.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.22 08-Dec-2007  dsl branches: 1.22.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.21 30-Apr-2007  dsl branches: 1.21.6; 1.21.8; 1.21.16;
Split the statvfs functions so that the 'work' is done to a kernel buffer
which can either be copied directly to userspace, or converted then copied.
Saves replicating a lot of code in the compat functions (esp. for
getvfsstat) at a cast of an extra function call in the non-emulated case -
which is unlikely to be measurable given the other costs of the actions
involved (even on vax).
Remove dofhstat() and dofhstatvfs() (and the last caller).
Remove some redundant stackgap_init() calls.
 1.20 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.19 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.18 10-Mar-2007  dsl branches: 1.18.2; 1.18.4;
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.17 04-Mar-2007  christos branches: 1.17.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 09-Feb-2007  ad branches: 1.16.2;
Merge newlock2 to head.
 1.15 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.14 09-Nov-2006  cube - Make better use of COMPAT_XX type in syscalls.master
- Remove useless (thanks to COMPAT_XX behaviour) #ifdefs in
syscalls.master
- Make netbsd32_compat_43.c compiled per COMPAT_LINUX32 because the latter
needs stuff from it.

Fixes Perry's PR#34951.
 1.13 04-Aug-2006  yamt branches: 1.13.4; 1.13.6;
some filehandle syscall related changes.

- remove the support of variable-sized filehandle from compat version of
syscalls. (strictly speaking, it breaks abi. i don't think it's a problem
because this feature is short-lived and there are no affected in-tree
filesystems.)
- unify vfs_copyinfh_alloc and vfs_copyinfh_alloc_size.
- vfs_copyinfh_alloc_size: check fhsize strictly.
- reduce code duplication between compat and current syscalls.
 1.12 31-Jul-2006  martin Make filehandles opaque to userland
 1.11 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.10 13-Jul-2006  pavel do not protect the getfh syscall by
#if defined(NFS) || defined(NFSSERVER).
The native syscall also isn't.
 1.9 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.8 27-May-2006  simonb branches: 1.8.2; 1.8.4;
Limit the size of any kernel buffers allocated by the VOP_READDIR
routines to MAXBSIZE.
 1.7 14-May-2006  elad branches: 1.7.2;
integrate kauth.
 1.6 05-May-2006  cube Move fhstat as sys___fhstat30 in netbsd32_fs.c because it doesn't belong
to netbsd32_netbsd.c (which incidentally means it had been broken for a
while I guess). Add compat_30 version.
 1.5 07-Mar-2006  thorpej branches: 1.5.2; 1.5.4;
Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.4 12-Dec-2005  christos branches: 1.4.4; 1.4.6; 1.4.8;
more proc to lwp problems.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 19-Aug-2005  christos branches: 1.2.6;
Fix lossage I created with the 64 bit ino_t change.
 1.1 19-Aug-2005  christos 64 bit inode changes.
 1.2.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.6.1 19-Aug-2005  skrll file netbsd32_compat_30.c was added on branch ktrace-lwp on 2005-11-10 14:01:20 +0000
 1.4.8.4 11-Aug-2006  yamt sync with head
 1.4.8.3 26-Jun-2006  yamt sync with head.
 1.4.8.2 24-May-2006  yamt sync with head.
 1.4.8.1 13-Mar-2006  yamt sync with head.
 1.4.6.2 01-Jun-2006  kardel Sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.4.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.5.2.3 12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.5.2.2 11-May-2006  elad sync with head
 1.5.2.1 07-Mar-2006  elad file netbsd32_compat_30.c was added on branch elad-kernelauth on 2006-05-11 23:27:31 +0000
 1.7.2.1 19-Jun-2006  chap Sync with head.
 1.8.4.7 24-Mar-2008  yamt sync with head.
 1.8.4.6 21-Jan-2008  yamt sync with head
 1.8.4.5 03-Sep-2007  yamt sync with head.
 1.8.4.4 26-Feb-2007  yamt sync with head.
 1.8.4.3 30-Dec-2006  yamt sync with head.
 1.8.4.2 21-Jun-2006  yamt sync with head.
 1.8.4.1 27-May-2006  yamt file netbsd32_compat_30.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:35 +0000
 1.8.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.13.6.1 10-Dec-2006  yamt sync with head.
 1.13.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.13.4.1 18-Nov-2006  ad Sync with head.
 1.16.2.3 07-May-2007  yamt sync with head.
 1.16.2.2 24-Mar-2007  yamt sync with head.
 1.16.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.2.3 27-May-2007  ad Sync with head.
 1.17.2.2 10-Apr-2007  ad Sync with head.
 1.17.2.1 13-Mar-2007  ad Sync with head.
 1.18.4.1 29-Mar-2007  reinoud Pullup to -current
 1.18.2.1 11-Jul-2007  mjf Sync with head.
 1.21.16.1 26-Dec-2007  ad Sync with head.
 1.21.8.1 09-Jan-2008  matt sync with HEAD
 1.21.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.22.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.23.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.23.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.23.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.23.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.6.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.24.6.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.24.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.24.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.24.4.2 11-Aug-2010  yamt sync with head.
 1.24.4.1 04-May-2009  yamt sync with head.
 1.24.2.1 04-Jun-2008  yamt sync with head
 1.25.2.1 27-Jun-2008  simonb Sync with head.
 1.26.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.26.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.27.4.2 04-Jan-2009  christos add new syscalls.
 1.27.4.1 19-Nov-2008  christos file netbsd32_compat_30.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.29.6.1 30-May-2010  rmind sync with head
 1.29.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.30.36.1 06-Apr-2015  skrll Sync with HEAD
 1.30.34.1 12-Dec-2014  martin Pull up following revision(s) (requested by maxv in ticket #314):
sys/compat/netbsd32/netbsd32_compat_30.c: revision 1.31
User-triggerable kmem_alloc(0).
Ok martin@ christos@
User
 1.30.28.1 14-Dec-2014  martin Pull up revision 1.31, requested by maxv in #1209:

Prevent a user-triggerable kmem_alloc(0).
 1.30.20.1 14-Dec-2014  martin Pull up revision 1.31, requested by maxv in #1209:

Prevent a user-triggerable kmem_alloc(0).
 1.30.18.1 03-Dec-2017  jdolecek update from HEAD
 1.30.14.1 14-Dec-2014  martin Pull up revision 1.31, requested by maxv in #1209:

Prevent a user-triggerable kmem_alloc(0).
 1.31.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.31.18.1 10-Jun-2019  christos Sync with HEAD
 1.31.16.14 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.31.16.13 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.31.16.12 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.31.16.11 25-Sep-2018  pgoyette Additional use of NTP function pointers, since the NTP code might not
exist in the kernel. (NTP is not (yet) a module, so we don't need to
use the MP-safe mechanism.)
 1.31.16.10 23-Sep-2018  pgoyette Revert previous. Instead, don't put an entry for ntp_gettime in the
syscall package if we don't have NTP.
 1.31.16.9 23-Sep-2018  pgoyette Provide a dummy version of netbsd32_ntp_gettime for systems where NTP
isn't defined.
 1.31.16.8 11-Sep-2018  pgoyette Move the NTP compat_30 and compat_50 routines into the version-specific
modules.
 1.31.16.7 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.31.16.6 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.31.16.5 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.31.16.4 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.31.16.3 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.31.16.2 10-Sep-2018  pgoyette More compat_netbsd32_xx modules
 1.31.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.33.6.2 29-Feb-2020  ad Sync with head.
 1.33.6.1 17-Jan-2020  ad Sync with head.
 1.35.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 28-Jan-2019  mlelstv branches: 1.4.4;
add missing includes
 1.3 28-Jan-2019  pgoyette Add the appropriate module glue. Seems to have gotten lost during
the merge.
 1.2 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.1 12-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_compat_40.c was initially added on branch pgoyette-compat.
 1.1.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.3 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.1.2.2 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.1.2.1 12-Sep-2018  pgoyette Add some more module glue
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 28-Jan-2019  christos file netbsd32_compat_40.c was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.65 20-Dec-2024  mlelstv revert previous, msg_flags is already initialized as MSG_NAMEMBUF
to free the sockname mbuf.
 1.64 20-Dec-2024  mlelstv Don't use flags uninitialized.
 1.63 01-Nov-2021  thorpej branches: 1.63.10;
Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.62 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.61 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.60 07-Mar-2020  pgoyette branches: 1.60.4;
Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents. With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9
 1.59 01-Jan-2020  maxv Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.

Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.
 1.58 23-Aug-2019  maxv Fix info leak.
 1.57 27-Jan-2019  pgoyette branches: 1.57.4;
Merge the [pgoyette-compat] branch
 1.56 03-May-2018  christos branches: 1.56.2;
Fix COMPAT_NETBSD32 cmsg handling:

1. alignment was wrong for > 1 message
2. macros were doing incorrect pointer comparisons, fortunately ending
the iteration early after the fists cmsg instead of crashing.
3. don't output 32 bit ktrace records for cmsg. 32 bit programs running
under emulation on 64 bit systems should produce 64 bit ktrace records
so that the native ktrace can handle the records; remove extra arguments
that are now not needed (the 32 bit msghdr).
4. output the correct type for cmsg trace records.
5. output all the cmsg records in traces instead of just the first one.

Welcome to 8.99.15 because of the argument removal.

XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR
macros...
 1.55 16-Mar-2018  christos PR/53103: Timo Buhrmester: linux emulation of sendto(2) broken

The sockargs refactoring broke it, because sockargs only works with a user
address. Added an argument to sockargs to indicate where the address is
coming from. Welcome to 8.99.14.
 1.54 13-Sep-2016  martin branches: 1.54.8; 1.54.14;
Make the ktrace record written by do_sys_sendmsg/do_sys_recvmsg overridable
by the caller. Use this in compat_netbsd32 to log the 32bit version, so
the 32bit userland kdump is happy.
 1.53 23-Apr-2010  joerg branches: 1.53.18; 1.53.34; 1.53.36; 1.53.44;
Fix compilation.
 1.52 23-Apr-2010  rmind Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.51 30-Jan-2009  njoly branches: 1.51.4; 1.51.6;
Cleanup. Kill a few netbsd32_caddr_t in syscalls argument types.
 1.50 29-May-2008  mrg branches: 1.50.6; 1.50.12;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.49 21-Mar-2008  ad branches: 1.49.2; 1.49.4; 1.49.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.48 26-Jan-2008  dsl branches: 1.48.6;
Remove some dubious casting of the address of integer variables that
can only be 'not invalid' if the sizes match - when it is unnecessary.
 1.47 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.46 08-Dec-2007  dsl branches: 1.46.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.45 04-Dec-2007  dsl Remove all the __P
 1.44 30-Jun-2007  dsl branches: 1.44.6; 1.44.8; 1.44.14; 1.44.16;
Changes to sompat socket function to avoid the dreaded stackgap.
 1.43 16-Jun-2007  dsl The code to directly call sigaction1() and sigaltstack1() is much shorter
than the mess required to call the compat_43_xxx functions.
 1.42 03-Jun-2007  dsl sendmsg() shouldn't modify the 'msg' parameter, and recvmsg() doesn't have
to modify the 'iov' array - it isn't updated.
 1.41 30-Apr-2007  dsl Rework compat stat() and statvfs() code so that it no longer uses the stackgap.
 1.40 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.39 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.38 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.37 04-Mar-2007  christos branches: 1.37.2; 1.37.4; 1.37.6;
fix fallout from caddr_t changes.
 1.36 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 09-Feb-2007  ad branches: 1.35.2;
Merge newlock2 to head.
 1.34 11-Dec-2005  christos branches: 1.34.20;
merge ktrace-lwp.
 1.33 24-Sep-2005  christos need compat/sys/socket.h
 1.32 24-Sep-2005  chs need to include sys/socket.h here now, sys/mount.h no longer does it for us.
 1.31 13-Sep-2005  christos make this compile again.
 1.30 26-Feb-2005  perry branches: 1.30.4;
nuke trailing whitespace
 1.29 04-Dec-2003  atatat branches: 1.29.8; 1.29.10;
Dynamic sysctl.

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

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

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

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

Bump the kernel rev up to 1.6V
 1.24 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.23 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.22 04-May-2002  martin Add missing prototype for compat_43_netbsd32_sigsetmask.
 1.21 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.20 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.19 25-Aug-2001  mrg update copyright notices.
 1.18 15-Aug-2001  eeh Fix bug in netbsd32_compat_43_olseek return value.
 1.17 30-May-2001  mrg branches: 1.17.2;
use _KERNEL_OPT.
 1.16 05-Feb-2001  mrg branches: 1.16.2;
fix the glaring errors in emulations for osendmsg, orecvmsg, osigvec and osigstack.
 1.15 02-Feb-2001  mrg properly implement compat_43_netbsd32_stat43, compat_43_netbsd32_lstat43
and compat_43_netbsd32_fstat43. now 32-bit ls(1) works. so does static
sunos `/sbin/sh' on sparc64.
 1.14 02-Feb-2001  mrg de-static netbsd32_exec_aout_prep_[zno]magic().
de-static netbsd32_from_stat43().
move the guts of netbsd32_execve() into netbsd32_execve2().

all of are for the forthcoming sunos32 compat mode (for sparc64).
 1.13 03-Dec-2000  fvdl Include opt_* files to make sure prototypes are included.
 1.12 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.11 24-Sep-2000  martin The ovadvise syscall is (correctly) listed as STD, so move it's implementation
to another place. This makes kernels without options COMPAT_43 link.
 1.10 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.9 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.8 11-Oct-1999  eeh branches: 1.8.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.7 14-Apr-1999  mrg branches: 1.7.2;
fix errors in the copyright on this.
 1.6 25-Mar-1999  mrg branches: 1.6.2;
SPARC32->NETBSD32
 1.5 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.4 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.3 29-Aug-1998  mrg move <vm/vm_swap.h> to <sys/swap.h>. <vm/vm_swap.h> still works for now (goes away later)
 1.2 26-Aug-1998  mrg use right syscalls
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.6.2.1 15-Apr-1999  mrg branches: 1.6.2.1.2;
pull up 1.7
 1.6.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.8.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.16.2.9 11-Nov-2002  nathanw Catch up to -current
 1.16.2.8 23-Aug-2002  petrov lwpification.
 1.16.2.7 20-Jun-2002  nathanw Catch up to -current.
 1.16.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.16.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.16.2.4 14-Nov-2001  nathanw Catch up to -current.
 1.16.2.3 21-Sep-2001  nathanw Catch up to -current.
 1.16.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.16.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.17.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.17.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.17.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.27.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.27.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.27.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.27.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.27.2.2 03-Aug-2004  skrll Sync with HEAD
 1.27.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.29.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.29.8.1 29-Apr-2005  kent sync with -current
 1.30.4.7 24-Mar-2008  yamt sync with head.
 1.30.4.6 04-Feb-2008  yamt sync with head.
 1.30.4.5 21-Jan-2008  yamt sync with head
 1.30.4.4 07-Dec-2007  yamt sync with head
 1.30.4.3 03-Sep-2007  yamt sync with head.
 1.30.4.2 26-Feb-2007  yamt sync with head.
 1.30.4.1 21-Jun-2006  yamt sync with head.
 1.34.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.35.2.3 07-May-2007  yamt sync with head.
 1.35.2.2 24-Mar-2007  yamt sync with head.
 1.35.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.6.2 29-Mar-2007  reinoud Pullup to -current
 1.37.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.37.4.1 11-Jul-2007  mjf Sync with head.
 1.37.2.4 15-Jul-2007  ad Sync with head.
 1.37.2.3 09-Jun-2007  ad Sync with head.
 1.37.2.2 27-May-2007  ad Sync with head.
 1.37.2.1 10-Apr-2007  ad Sync with head.
 1.44.16.2 26-Dec-2007  ad Sync with head.
 1.44.16.1 08-Dec-2007  ad Sync with head.
 1.44.14.3 18-Feb-2008  mjf Sync with HEAD.
 1.44.14.2 27-Dec-2007  mjf Sync with HEAD.
 1.44.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.44.8.2 23-Mar-2008  matt sync with HEAD
 1.44.8.1 09-Jan-2008  matt sync with HEAD
 1.44.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.46.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.48.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.48.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.49.6.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.49.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.49.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.49.4.2 11-Aug-2010  yamt sync with head.
 1.49.4.1 04-May-2009  yamt sync with head.
 1.49.2.1 04-Jun-2008  yamt sync with head
 1.50.12.2 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.50.12.1 29-May-2008  mrg file netbsd32_compat_43.c was added on branch christos-time_t on 2008-05-29 14:51:27 +0000
 1.50.6.1 03-Mar-2009  skrll Sync with HEAD.
 1.51.6.1 30-May-2010  rmind sync with head
 1.51.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.53.44.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.53.36.1 05-Oct-2016  skrll Sync with HEAD
 1.53.34.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.53.18.1 03-Dec-2017  jdolecek update from HEAD
 1.54.14.5 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.54.14.4 11-Sep-2018  pgoyette Typo
 1.54.14.3 11-Sep-2018  pgoyette Make compat_netbsd32_43 into a stand-alone module.
 1.54.14.2 21-May-2018  pgoyette Sync with HEAD
 1.54.14.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.54.8.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.54.8.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.56.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.56.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.56.2.1 10-Jun-2019  christos Sync with HEAD
 1.57.4.4 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

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

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.57.4.3 08-Mar-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #761):

sys/compat/netbsd32/syscalls.master: revision 1.132
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.60

Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents. With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9
 1.57.4.2 02-Jan-2020  martin Pull up following revision(s) (requested by maxv in ticket #597):

sys/compat/common/kern_sig_43.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.39
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.59
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.44

Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.

Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.

Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.57.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.60.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.63.10.1 02-Aug-2025  perseant Sync with HEAD
 1.56 29-Jul-2023  rin COMPAT_NETBSD32: Reorganize the previous; Make compat_netbsd32_50 recursively
depended on compat_netbsd32_100, rather than directly depended on it.

Thanks pgoyette@ again for useful comments!
 1.55 29-Jul-2023  rin Now, netbsd32_compat_50 module requires netbsd32_compat_100.
Thanks pgoyette@ for hints.
 1.54 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 1.53 26-Oct-2022  riastradh sys: Put externs for time_adjtime and time_adjusted in .h files.

time_adjtime: sys/timex.h (defined in ntp code)
time_adjusted: sys/timevar.h (defined in non-ntp code)

(Not really sure this is a valuable distinction to maintain; there's
non-ntp code that uses time_adjtime too.)
 1.52 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.51 18-Feb-2021  simonb In the compat setitimer(2) calls, don't validate which timer is being
used since dosetitimer() does this anyway. The compat functions hadn't
been updated since ITIMER_MONOTONIC was introduced, so they reported
that that ITIMER_MONOTONIC timer was invalid.
 1.50 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.49 30-Apr-2020  riastradh branches: 1.49.2;
Omit needless #include <sys/rnd.h>.
 1.48 15-Mar-2020  pgoyette Now that we have split the quota code out of the compat_netbsd32_50
module, it no longer depends on compat_50_quota.

Should address PR kern/55073
 1.47 12-Mar-2020  pgoyette Split out the quota code from the rest of compat_netbsd32 module. This
allows loading of compat_netbsd32 on kernels that don't have ``options
QUOTA'' enabled.
 1.46 27-Feb-2020  pgoyette Module compat_netbsd32_50 requires module compat_50_quota
 1.45 29-Jan-2020  ad - Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case. Replace scans of p->p_lwps with lookups in the
tree. Find free LIDs for new LWPs in the tree. Replace the hashed sleep
queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
line.

- Add some comments.
 1.44 01-Jan-2020  maxv branches: 1.44.2;
Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.43 15-Dec-2019  tsutsui Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.42 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.41 05-Oct-2019  kamil Validate input before converting timeval::tv_usec in compat/netbsd32
 1.40 20-Sep-2019  kamil Validate usec ranges in compat_50_netbsd32_select()

Later in the code selcommon() checks for proper timespec, check only
correct usec of timeval before type conversions.
 1.39 27-Jun-2019  christos branches: 1.39.2;
Include the right stuff so compat_netbsd32_50 compiles.
 1.38 18-Jun-2019  kamil Drop unused retval pointer from do_sys_mknod{,at}()

No functional change intended.
 1.37 18-Jun-2019  christos regen
 1.36 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.35 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.34 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.33 26-Dec-2018  mrg remove duplicated prototypes and dated XXX comments.
 1.32 03-Dec-2015  pgoyette branches: 1.32.10; 1.32.16; 1.32.18;
Split out the SYSV IPC stuff into its own compat_netbsd32_sysvipc
module. Adjust dependencies as needed.
 1.31 01-Dec-2015  pgoyette Prepare for new compat_netbsd32_mqueue module to be split out of
compat_netbsd32. Refactor the COMPAT_50 code related to mqueue,
and update the syscall definitions. Remove dependency on mqueue
from the compat_netbsd32 module (the new module will gain this
dependency).

Continuation of work on PR kern/50489
 1.30 24-Jul-2015  maxv Unused inits (harmless).

Found by Brainy.
 1.29 21-Jun-2015  martin Move compat calls, requested by mrg@
 1.28 27-Oct-2014  christos branches: 1.28.2;
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.
 1.27 05-Sep-2014  matt Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.26 05-Sep-2014  matt Don't use private as a variable name since it's reserved in C++
 1.25 21-Aug-2014  maxv Remove dead returns:

return VAR/func(XX);
return VAR;

The latter is never reached. Sent on tech-kern@, no disagreement.
 1.24 24-Jun-2014  maxv branches: 1.24.2;
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.

ok christos@
 1.23 29-Mar-2013  christos branches: 1.23.8;
compat glue for new lwp_park
 1.22 03-Nov-2012  njoly Move rusage computation to a new getrusage1() function. Adjust all
compat/emulations to make use of it.
 1.21 02-Oct-2012  christos kernel portion of clock_nanosleep()
 1.20 18-Nov-2011  christos branches: 1.20.6; 1.20.10; 1.20.12; 1.20.14;
add a copyin function for sigset so that we can use sigtimedwait1 from
emulations.
 1.19 23-May-2011  joerg branches: 1.19.4;
Update from GNU extension to C99 syntax for designated initializer
 1.18 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.17 30-May-2010  drochner branches: 1.17.2; 1.17.4;
-fix internal use of sigwaitinfo(2) by sigwait(3): The former returns
the signal number now, as required by POSIX. The latter should just
return 0 on success. Fixes a mysql problem reported by Kurt Schreiner.
-document the new behavior of sigwaitinfo and sigtimedwait
-retain non-POSIX behavior for NetBSD-5 binary compatibility -- the fix
would likely not be polled into the .0-branches, and having 5.0.x and
5.x behave differently would be confusing. Besides that, it was
documented in the manpage all the time.
 1.16 23-Apr-2010  rmind Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.15 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.14 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.13 29-Mar-2010  njoly Convert linux/linux32/netbsd32 clock_settime syscalls, to use the
common clock_settime1() function.
 1.12 29-Mar-2010  njoly Make compat netbsd32 clock_getres copyout the netbsd32 timespec
structure, not the native one.
 1.11 28-Mar-2010  njoly Cleanup compat netbsd32 nanosleep syscalls to use the common
nanosleep1() call instead of their own stuff.
 1.10 02-Mar-2010  pooka branches: 1.10.2;
regen for conditional lfs syscall removal
 1.9 19-Jan-2010  pooka branches: 1.9.2;
A few more instances of __sigtimedwait1 -> sigtimedwait1
 1.8 21-Dec-2009  njoly Do not include fs_lfs.h unless _KERNEL_OPT is defined.
 1.7 11-Nov-2009  rmind - selcommon/pollcommon: drop redundant l argument.
- Use cached curlwp->l_fd, instead of p->p_fd.
- Inline selscan/pollscan.
 1.6 04-Nov-2009  rmind do_sys_wait(): fix previous by checking for ru != NULL. Noticed by
Onno van der Linden. Also, remove redundant arguments (seems that
was_zombie was not used since rev 1.177 ?).
 1.5 09-Aug-2009  haad Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions
can be called from kernel, too.

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

Oked by ad@.
 1.4 29-Mar-2009  christos branches: 1.4.2;
Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
 1.3 26-Jan-2009  njoly branches: 1.3.2;
Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.2 11-Jan-2009  christos branches: 1.2.2; 1.2.4;
merge christos-time_t
 1.1 04-Jan-2009  christos branches: 1.1.2;
file netbsd32_compat_50.c was initially added on branch christos-time_t.
 1.1.2.1 04-Jan-2009  christos add new syscalls.
 1.2.4.4 28-Apr-2009  skrll Sync with HEAD.
 1.2.4.3 03-Mar-2009  skrll Sync with HEAD.
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 11-Jan-2009  skrll file netbsd32_compat_50.c was added on branch nick-hppapmap on 2009-01-19 13:17:36 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 11-Jan-2009  mjf file netbsd32_compat_50.c was added on branch mjf-devfs2 on 2009-01-17 13:28:46 +0000
 1.3.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.2.5 11-Aug-2010  yamt sync with head.
 1.4.2.4 11-Mar-2010  yamt sync with head
 1.4.2.3 19-Aug-2009  yamt sync with head.
 1.4.2.2 04-May-2009  yamt sync with head.
 1.4.2.1 29-Mar-2009  yamt file netbsd32_compat_50.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:25 +0000
 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.4 31-May-2011  rmind sync with head
 1.10.2.3 21-Apr-2011  rmind sync with head
 1.10.2.2 03-Jul-2010  rmind sync with head
 1.10.2.1 30-May-2010  rmind sync with head
 1.17.4.1 15-Feb-2011  bouyer implement COMPAT_NETBSD32 quotactl syscalls (both new and COMPAT_50)
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.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.19.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.19.4.2 30-Oct-2012  yamt sync with head
 1.19.4.1 17-Apr-2012  yamt sync with head
 1.20.14.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1179):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.28
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.
 1.20.14.1 30-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1090):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.24
sys/compat/netbsd32/netbsd32_event.c: revision 1.11
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.
ok christos@
 1.20.12.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1179):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.28
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.
 1.20.12.1 30-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1090):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.24
sys/compat/netbsd32/netbsd32_event.c: revision 1.11
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.
ok christos@
 1.20.10.4 03-Dec-2017  jdolecek update from HEAD
 1.20.10.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.10.2 23-Jun-2013  tls resync from head
 1.20.10.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.20.6.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1179):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.28
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.
 1.20.6.1 30-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1090):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.24
sys/compat/netbsd32/netbsd32_event.c: revision 1.11
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.
ok christos@
 1.23.8.1 10-Aug-2014  tls Rebase.
 1.24.2.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.24.2.1 30-Oct-2014  martin branches: 1.24.2.1.6;
Pull up following revision(s) (requested by maxv in ticket #166):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.28
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.
 1.24.2.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.28.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.28.2.1 22-Sep-2015  skrll Sync with HEAD
 1.32.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.32.18.1 10-Jun-2019  christos Sync with HEAD
 1.32.16.16 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.32.16.15 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.32.16.14 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.32.16.13 12-Oct-2018  pgoyette Use a MP-safe hook for the rnd_ioctl compat_50 calls.
 1.32.16.12 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.32.16.11 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.32.16.10 25-Sep-2018  pgoyette Additional use of NTP function pointers, since the NTP code might not
exist in the kernel. (NTP is not (yet) a module, so we don't need to
use the MP-safe mechanism.)
 1.32.16.9 23-Sep-2018  pgoyette Be selective about including the NTP syscall ntp_gettime
 1.32.16.8 11-Sep-2018  pgoyette Move the NTP compat_30 and compat_50 routines into the version-specific
modules.
 1.32.16.7 11-Sep-2018  pgoyette Move netbsd32_rndpseudo_50.c out of the main netbsd32 module and into
the module that handles netbsd32_50 compatability.
 1.32.16.6 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.32.16.5 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.32.16.4 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.32.16.3 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.32.16.2 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.32.16.1 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.32.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.32.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.39.2.3 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.39.2.2 02-Jan-2020  martin Pull up following revision(s) (requested by maxv in ticket #597):

sys/compat/common/kern_sig_43.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.39
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.59
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.44

Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.

Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.

Fix three stack info leaks, found by kMSan when just invoking all syscalls
with a zero page as argument.

MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat()
MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack()
MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
 1.39.2.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.44.2.1 29-Feb-2020  ad Sync with head.
 1.49.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.1 12-Mar-2020  pgoyette branches: 1.1.2; 1.1.6;
Split out the quota code from the rest of compat_netbsd32 module. This
allows loading of compat_netbsd32 on kernels that don't have ``options
QUOTA'' enabled.
 1.1.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.2.1 12-Mar-2020  martin file netbsd32_compat_50_quota.c was added on branch phil-wifi on 2020-04-08 14:08:01 +0000
 1.4 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.3 15-Dec-2019  tsutsui branches: 1.3.8;
Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 03-Dec-2015  pgoyette branches: 1.1.2; 1.1.18; 1.1.20; 1.1.22;
Split out the SYSV IPC stuff into its own compat_netbsd32_sysvipc
module. Adjust dependencies as needed.
 1.1.22.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 03-Dec-2015  jdolecek file netbsd32_compat_50_sysv.c was added on branch tls-maxphys on 2017-12-03 11:36:55 +0000
 1.1.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.1 03-Dec-2015  skrll file netbsd32_compat_50_sysv.c was added on branch nick-nhusb on 2015-12-27 12:09:47 +0000
 1.2.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.3.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 29-Jan-2020  ad - Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case. Replace scans of p->p_lwps with lookups in the
tree. Find free LIDs for new LWPs in the tree. Replace the hashed sleep
queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
line.

- Add some comments.
 1.5 15-Dec-2019  tsutsui branches: 1.5.2;
Remove clause 3 and 4 leftovers from TNF licenses in more sources.

Confirmed by martin@ in PR/54760.
 1.4 27-Jan-2019  pgoyette branches: 1.4.4;
Merge the [pgoyette-compat] branch
 1.3 06-Dec-2017  christos branches: 1.3.2; 1.3.4;
don't forget to convert the timespec.
XXX: pullup-8
 1.2 21-Aug-2014  maxv branches: 1.2.12;
Remove dead returns:

return VAR/func(XX);
return VAR;

The latter is never reached. Sent on tech-kern@, no disagreement.
 1.1 29-Mar-2013  christos branches: 1.1.4; 1.1.12; 1.1.14;
lwp park glue
 1.1.14.1 13-Mar-2019  msaitoh Pull up following revision(s) (requested by martin in ticket #1683):
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.3
don't forget to convert the timespec.
XXX: pullup-8
 1.1.12.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.12.1 29-Mar-2013  yamt file netbsd32_compat_60.c was added on branch yamt-pagecache on 2014-05-22 11:40:17 +0000
 1.1.4.3 03-Dec-2017  jdolecek update from HEAD
 1.1.4.2 23-Jun-2013  tls resync from head
 1.1.4.1 29-Mar-2013  tls file netbsd32_compat_60.c was added on branch tls-maxphys on 2013-06-23 06:20:16 +0000
 1.2.12.1 12-Mar-2019  snj Pull up following revision(s) (requested by martin in ticket #1211):
sys/compat/netbsd32/netbsd32_compat_60.c: 1.3
don't forget to convert the timespec.
 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.9 03-Oct-2018  pgoyette Normalize the required lists. Each compat_netbsd32_xx needs the
non-32bit module of the same version _and_ the 32-bit module for
the next higher version.
 1.3.2.8 03-Oct-2018  pgoyette Make sure that each version-specific compat_netbsd32_xx module depends
on all higher-version-specific modules, similar to the non-32bit
compat_xx modules.
 1.3.2.7 13-Sep-2018  pgoyette Another dependency typo
 1.3.2.6 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.3.2.5 11-Sep-2018  pgoyette Also need to declare the emul_netbsd32 !
 1.3.2.4 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.3.2.3 11-Sep-2018  pgoyette Use netbsd32 syscall names in the establish/disestablish tables
 1.3.2.2 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.3.2.1 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.4.4.1 18-Dec-2019  martin Pull up following revision(s) (requested by tsutsui in ticket #570):

sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3
sys/dev/raidframe/rf_compat50.h: revision 1.6
sys/arch/emips/emips/bus_space.c: revision 1.3
sys/compat/net/if.h: revision 1.5
sys/arch/emips/stand/common/bootinfo.c: revision 1.2
sys/compat/common/sysv_msg_50.c: revision 1.5
sys/compat/common/kern_time_30.c: revision 1.8
sys/arch/emips/stand/common/bootinfo.h: revision 1.2
sys/arch/ia64/include/bus.h: revision 1.4
sys/arch/ia64/ia64/bus_space.c: revision 1.2
sys/compat/common/sysv_shm_50.c: revision 1.5
sys/dev/ic/adw.h: revision 1.15
sys/compat/common/uipc_syscalls_50.c: revision 1.10
sys/arch/emips/ebus/flash_ebus.c: revision 1.22
sys/dev/ic/adv.h: revision 1.15
sys/dev/ic/adwmcode.c: revision 1.18
sys/dev/ic/advlib.c: revision 1.29
sys/arch/hpcarm/include/kloader.h: revision 1.3
sys/dev/usb/uberry.c: revision 1.16
sys/compat/common/sysv_sem_50.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43
sys/dev/ic/advlib.h: revision 1.21
sys/dev/ic/adv.c: revision 1.50
sys/compat/netinet6/in6_var.h: revision 1.5
sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2
sys/arch/emips/include/loadfile_machdep.h: revision 1.3
sys/arch/emips/stand/common/prom_iface.c: revision 1.7
sys/dev/ic/adw.c: revision 1.56
sys/dev/ic/adwmcode.h: revision 1.12
sys/dev/ic/advmcode.c: revision 1.10
sys/arch/emips/ebus/ace_ebus.c: revision 1.22
sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5
sys/dev/raidframe/rf_compat50.c: revision 1.13
sys/arch/x68k/dev/intiovar.h: revision 1.15
sys/dev/usb/uipad.c: revision 1.8
sys/arch/zaurus/include/kloader.h: revision 1.3
sys/arch/emips/stand/common/bootxx.c: revision 1.2
sys/dev/ic/adwlib.h: revision 1.23
sys/dev/ic/adwlib.c: revision 1.44
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3
sys/arch/amigappc/include/intr.h: revision 1.27
sys/arch/x68k/dev/mfp.c: revision 1.27
sys/arch/arm/at91/at91dbgu.c: revision 1.17
sys/dev/ic/advmcode.h: revision 1.7
sys/compat/ultrix/ultrix_exec.h: revision 1.7
sys/compat/common/vfs_syscalls_50.c: revision 1.24
sys/arch/mips/cavium/octeon_dma.c: revision 1.3
sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2

Remove clause 3 and 4 from TNF licenses.
Ok'ed by martin@ in PR/54760.

Remove clause 3 and 4 leftovers from TNF licenses in more sources.
Confirmed by martin@ in PR/54760.
 1.5.2.1 29-Feb-2020  ad Sync with head.
 1.8 29-Jul-2023  pgoyette Don't skip compat_netbsd32_90 in the dependency chain.
 1.7 29-Jul-2023  rin COMPAT_NETBSD32: Reorganize the previous; Make compat_netbsd32_50 recursively
depended on compat_netbsd32_100, rather than directly depended on it.

Thanks pgoyette@ again for useful comments!
 1.6 12-Dec-2019  pgoyette branches: 1.6.26;
Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.5 01-Mar-2019  pgoyette branches: 1.5.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.4 30-Jan-2019  pgoyette Remove #ifdef COMPAT_80

The file will only be selected if "options COMPAT_80" is defined in
the config file. The COMPAT_80 macro is defined only if the option
is explicitly defined, and not if it is implicitly defined due to
inclusion of lesser-version COMPATs.
 1.3 28-Jan-2019  pgoyette Include new compatability header
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 10-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_compat_80.c was initially added on branch pgoyette-compat.
 1.1.2.6 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.5 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.1.2.4 18-Sep-2018  pgoyette Use the MP-safe compat hooks for netbsd32_compat_80.c's modctl
 1.1.2.3 11-Sep-2018  pgoyette Remove unused variable
 1.1.2.2 11-Sep-2018  pgoyette Regen
 1.1.2.1 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.5.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.4.2 10-Jun-2019  christos Sync with HEAD
 1.5.4.1 01-Mar-2019  christos file netbsd32_compat_80.c was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.6.26.1 26-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #987):

sys/compat/netbsd32/netbsd32_compat_80.c: revision 1.7,1.8 (patch)

Don't skip compat_netbsd32_90 in the dependency chain.
 1.2 29-Jul-2023  pgoyette Don't skip compat_netbsd32_90 in the dependency chain.
 1.1 22-Sep-2019  christos branches: 1.1.8;
Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.1.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.8.1 22-Sep-2019  martin file netbsd32_compat_90.c was added on branch phil-wifi on 2020-04-13 08:04:16 +0000
 1.48 30-Jul-2023  rin COMPAT_NETBSD32: Add support for epoll(2).
 1.47 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 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-Jan-2021  simonb The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.44 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.43 18-Jan-2021  simonb s/u_intN_t/uintN_t/
 1.42 18-Nov-2019  rin branches: 1.42.8;
Sorry, revert unintentional parts of the previous commit:
http://mail-index.netbsd.org/source-changes/2019/11/18/msg110946.html

I was going to commit only netbsd32_signal.c.
 1.41 18-Nov-2019  rin Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
 1.40 03-Oct-2019  kamil Switch kevent udata from intptr_t void*

Synchromize the struct field format with other BSDs and Darwin.

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

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

Discussed with core@ and there were no objections for this move.
 1.39 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.38 21-Feb-2019  mrg branches: 1.38.4;
for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.

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

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


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

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

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


XXX: the naming of compat functions have too many styles. there
are at least 3 different ones changed here.
 1.37 27-Dec-2018  maxv Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.36 25-Nov-2018  mlelstv Restore netbsd32 compat code for new NPF ABI.
 1.35 10-May-2018  christos branches: 1.35.2;
add {send,recv}mmsg
 1.34 19-Apr-2018  christos s/static inline/static __inline/g for consistency.
 1.33 31-Oct-2017  martin branches: 1.33.2;
PR kern/52681: fix msghdr conversion.
 1.32 31-Jul-2017  maxv Remove references to COMPAT_OLDSOCK (itself removed years ago).
 1.31 13-Nov-2016  rin branches: 1.31.8;
correct wrong casting. some are considered harmless, but
- tv_sec in netbsd32_timeval is netbsd32_time_t (aka netbsd32_int64_t)
rather than time_t (int64_t)
- tv_sec in netbsd32_timespec is netbsd32_time_t rather than
netbsd32_long (y2038 problem)
approved by martin
 1.30 22-Jun-2015  mrg branches: 1.30.2;
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.29 20-Jun-2015  martin Implement modctl, sigqueinfo and mq_*
 1.28 18-Mar-2014  riastradh branches: 1.28.4; 1.28.6; 1.28.8;
Merge riastradh-drm2 to HEAD.
 1.27 20-Jul-2013  njoly Initialise destination before performing stat structure conversion.
Avoid getting garbage for structure members not set explicitely.
 1.26 06-Mar-2011  bouyer branches: 1.26.4; 1.26.14; 1.26.18; 1.26.26;
merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.25 20-Feb-2011  matt Don't bother the iov in netbsd32_to_msghdr since it needs to handled specially.
 1.24 16-Jan-2011  njoly branches: 1.24.2; 1.24.4;
In stat structure conversions, do set st_birthtimespec member values
if exists.
 1.23 04-Jan-2011  matt Need to deal with msg_iov in netbsd32_to_msghdr.
 1.22 25-Jan-2009  christos branches: 1.22.6;
fix casts.
 1.21 11-Jan-2009  christos merge christos-time_t
 1.20 12-Nov-2008  ad branches: 1.20.4;
Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.19 02-Jun-2008  njoly branches: 1.19.4; 1.19.6; 1.19.12;
When converting msqid_ds structure from/to netbsd32 for msgctl(2)
IPC_STAT/IPC_SET, do not try to fill private struct members
_msg_first/_msg_last which do not exists.
 1.18 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.17 04-Dec-2007  dsl branches: 1.17.12; 1.17.14; 1.17.16; 1.17.18;
Remove all the __P
 1.16 16-Mar-2007  dsl branches: 1.16.8; 1.16.10; 1.16.16; 1.16.18;
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.15 04-Mar-2007  christos branches: 1.15.2; 1.15.4; 1.15.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 16-Feb-2006  perry branches: 1.14.20;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.13 24-Dec-2005  perry branches: 1.13.2; 1.13.4; 1.13.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.12 11-Dec-2005  christos merge ktrace-lwp.
 1.11 23-Oct-2005  cube - Split sys_kevent into kevent1 so that it can be used by COMPAT_NETBSD32
code.

- To achieve COMPAT_NETBSD32 compatibility, introduce a parameter to
kevent1 that points to functions that do the actual copyin/copyout
operations. This is similar to what was done in FreeBSD by Paul Saab.

- Add the COMPAT_NETBSD32 definitions and hooks.
 1.10 13-Sep-2005  christos branches: 1.10.2;
make this compile again.
 1.9 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.8 19-Aug-2005  christos 64 bit inode changes.
 1.7 23-Jul-2005  cube Constify conversion functions.
 1.6 23-Jul-2005  cube Implement the timer_create(2) family of syscalls.
 1.5 26-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 17-Jun-2004  cube branches: 1.4.4; 1.4.6;
o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.3 21-Apr-2004  christos try to make this compile. XXX: this will not work yet (hi simon)
 1.2 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.1 07-Feb-2001  mrg branches: 1.1.2; 1.1.26;
move the static inline conversion functions into a header file so other
files can see these. note a bunch of functions that should be moved
into their own files.
 1.1.26.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.26.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.26.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 07-Feb-2001  bouyer file netbsd32_conv.h was added on branch thorpej_scsipi on 2001-02-11 19:14:11 +0000
 1.4.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.5.4.3 07-Dec-2007  yamt sync with head
 1.5.4.2 03-Sep-2007  yamt sync with head.
 1.5.4.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 26-Oct-2005  yamt sync with head
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.13.2.1 18-Feb-2006  yamt sync with head.
 1.14.20.2 24-Mar-2007  yamt sync with head.
 1.14.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.15.4.1 11-Jul-2007  mjf Sync with head.
 1.15.2.1 10-Apr-2007  ad Sync with head.
 1.16.18.1 08-Dec-2007  ad Sync with head.
 1.16.16.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.10.1 09-Jan-2008  matt sync with HEAD
 1.16.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.17.18.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.17.16.1 04-May-2009  yamt sync with head.
 1.17.14.1 04-Jun-2008  yamt sync with head
 1.17.12.3 17-Jan-2009  mjf Sync with HEAD.
 1.17.12.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.17.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.12.1 09-Jun-2010  matt Fix socket passing in netbsd32 compat. unfdpasses and incoming ssh
interactive session now work.
 1.19.6.2 03-Mar-2009  skrll Sync with HEAD.
 1.19.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.20.4.2 04-Jan-2009  christos add new syscalls.
 1.20.4.1 12-Nov-2008  christos file netbsd32_conv.h was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.22.6.2 21-Apr-2011  rmind sync with head
 1.22.6.1 05-Mar-2011  rmind sync with head
 1.24.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.24.4.1 15-Feb-2011  bouyer implement COMPAT_NETBSD32 quotactl syscalls (both new and COMPAT_50)
 1.24.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.26.1 23-Jul-2013  riastradh sync with HEAD
 1.26.18.1 28-Aug-2013  rmind sync with head
 1.26.14.2 03-Dec-2017  jdolecek update from HEAD
 1.26.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.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.28.8.2 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.28.8.1 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1668):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.28.6.3 28-Aug-2017  skrll Sync with HEAD
 1.28.6.2 05-Dec-2016  skrll Sync with HEAD
 1.28.6.1 22-Sep-2015  skrll Sync with HEAD
 1.28.4.3 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.28.4.2 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1668):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.28.4.1 04-Nov-2015  riz branches: 1.28.4.1.4;
Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.28.4.1.4.2 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.28.4.1.4.1 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1668):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.30.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.31.8.5 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.31.8.4 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1833):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.31.8.3 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.31.8.2 02-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1151):

sys/compat/netbsd32/netbsd32_conv.h: revision 1.37
sys/compat/netbsd32/netbsd32_compat_14.c: revision 1.27
sys/compat/sys/msg.h: revision 1.5

Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0xffffffff80bad7a7 in kleak_copyout
| #1 0xffffffff8048e71b in netbsd32___msgctl50
| #2 0xffffffff8022fb5b in netbsd32_syscall
| #3 0xffffffff802096dd in handle_syscall
 1.31.8.1 06-Nov-2017  snj Pull up following revision(s) (requested by martin in ticket #339):
sys/compat/netbsd32/netbsd32_conv.h: revision 1.33
PR kern/52681: fix msghdr conversion.
 1.33.2.5 05-Jan-2019  pgoyette Fix typo in previous
 1.33.2.4 03-Jan-2019  pgoyette Bring in some more changes from HEAD.
 1.33.2.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.33.2.2 21-May-2018  pgoyette Sync with HEAD
 1.33.2.1 22-Apr-2018  pgoyette Sync with HEAD
 1.35.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.35.2.1 10-Jun-2019  christos Sync with HEAD
 1.38.4.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

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

sys/compat: Memset zero before copyout.

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

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.42.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.18 08-Nov-2020  rin Fix typo; s/__LP64/_LP64/
 1.17 04-Nov-2020  pgoyette Use opt_execfmt.h to get build options.

Only include elf32 hooks if we have elf32 defined and elf32 is not the
"native" emulation. This allows for having compat_netbsd32 without
elf32 (although it's probably not too useful), and also enables arm's
old-ABI usage of compat_netbsd32.
 1.16 01-Nov-2020  pgoyette Separate the compat_netbsd32_coredump from the compat_netbsd32 and
coredump modules, into its own module.

Welcome to 7.99.75 !!!
 1.15 20-Nov-2019  pgoyette branches: 1.15.8;
Move all non-emulation-specific coredump code into the coredump module,
and remove all #ifdef COREDUMP conditional compilation. Now, the
coredump module is completely separated from the emulation modules, and
they can all be independently loaded and unloaded.

Welcome to 9.99.18 !
 1.14 02-Feb-2011  chuck branches: 1.14.56;
udpate license clauses on my code to match the new-style BSD licenses.
verified with Mike Hibler it is ok to remove clause 3 on utah copyright,
as per UCB.
based on diff that rmind@ sent me.

no functional change with this commit.
 1.13 11-Dec-2005  christos branches: 1.13.100; 1.13.106; 1.13.108;
merge ktrace-lwp.
 1.12 10-Jun-2005  matt Rework the coredump code to have no explicit knownledge of how coredump
i/o is done. Instead, pass an opaque cookie which is then passed to a
new routine, coredump_write, which does the actual i/o. This allows the
method of doing i/o to change without affecting any future MD code.
Also, make netbsd32_core.c [re]use core_netbsd.c (in a similar manner that
core_elf64.c uses core_elf32.c) and eliminate that code duplication.
cpu_coredump{,32} is now called twice, first with a NULL iocookie to fill
the core structure and a second to actually write md parts of the coredump.
All i/o is nolonger random access and is suitable for shipping over a stream.
 1.11 02-Jun-2005  matt When writing coredumps, don't write zero uninstantiated demand-zero pages.
Also, with ELF core dumps, trim trailing zeroes from sections. These two
changes can shrink coredumps by over 50% in size.
 1.10 17-Sep-2004  skrll There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.9 15-Sep-2003  christos catch up with latest sigctx changes; reported by John Heasley, thanks!
 1.8 07-Sep-2003  rafal Catch up to Christos' SIGINFO changes.
 1.7 29-Jun-2003  fvdl branches: 1.7.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.6 29-Jun-2003  martin struct proc * -> struct lwp *
 1.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 10-Dec-2001  thorpej branches: 1.4.2; 1.4.4;
I can't win today -- make this link.
 1.3 10-Dec-2001  thorpej Move the code that walks the process's VM map during a coredump
into uvm_coredump_walkmap(), and use callbacks into the coredump
routine to do something with each section.
 1.2 09-Dec-2001  thorpej Fix compilation problems.
 1.1 08-Dec-2001  thorpej Make the coredump routine exec-format/emulation specific. Split
out traditional NetBSD coredump routines into core_netbsd.c and
netbsd32_core.c (for COMPAT_NETBSD32).
 1.4.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.4.1 10-Dec-2001  thorpej file netbsd32_core.c was added on branch kqueue on 2002-01-10 19:51:54 +0000
 1.4.2.3 23-Aug-2002  petrov lwpification.
 1.4.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.4.2.1 10-Dec-2001  nathanw file netbsd32_core.c was added on branch nathanw_sa on 2002-01-08 00:29:08 +0000
 1.7.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.108.1 08-Feb-2011  bouyer Sync with HEAD
 1.13.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.100.1 05-Mar-2011  rmind sync with head
 1.14.56.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.4 28-Sep-2019  christos branches: 1.4.8;
fix sign-compare.
 1.3 20-Aug-2019  christos From maxv@:

1) In compat_drm_agp_info(), seems like it should be info64to32.
2) In compat_drm_getstats(), the assignments in the loop are inverted, it's
st32 which should be set to the values of st64, not the other way around.
3) In compat_drm_dma(), again inverted 32<->64, and there is no copyout (?).
4) In compat_drm_agp_enable(), m64 is uninitialized, everything is wrong in
this function it seems.
 1.2 20-Aug-2019  christos add NetBSD copyright.
 1.1 20-Aug-2019  christos compat32 drm ioctl support from Surya Shankar at GSoC 2019
 1.4.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.8.1 28-Sep-2019  martin file netbsd32_drm.c was added on branch phil-wifi on 2020-04-13 08:04:16 +0000
 1.5 02-Sep-2023  mrg redo previous: use same variable type for the interator as the comparison
 1.4 30-Aug-2023  mrg use unsigned for iterator, fixes -Wsigned-comapre issue in module build.
 1.3 30-Jul-2023  rin netbsd32_epoll_pwait2: Dedup slightly. NFCI.
 1.2 30-Jul-2023  rin netbsd32_epoll_pwait2: Early return if no event arrived;
Do not attempt to allocate 0-byte buffer by kmem_alloc(9).
 1.1 30-Jul-2023  rin COMPAT_NETBSD32: Add support for epoll(2).
 1.14 29-Jul-2023  rin COMPAT_NETBSD32: No need to have compat_100_netbsd32_kevent_fetch_timeout.
NFCI.
 1.13 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 1.12 05-Sep-2014  matt Don't use private as a variable name since it's reserved in C++
 1.11 24-Jun-2014  maxv Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.

ok christos@
 1.10 23-Jan-2014  manu branches: 1.10.2;
Fix netbsd32 compatibility bug in kevent()

The keo_put_events() callback copies the events from kernel to userland.
It is called for sets of up to 8 events (constant chosen in kevbuf
definitition in kevent1()). The callback is called with pointer to userland
buffer, count of events to copy, and an index parameter which tracks where
we are in userland buffer when called multiple time.

COMPAT_NETBSD32's flavor of keo_put_events() is netbsd32_kevent_put_events().
It did not honour the index parameter, which caused invalid event data to
be returned when userland requested more that 8 events. This caused many
reliability problems, and the obvious startup crash of dovecot log process
when it accessed udata in the nineth event in its buffer, which was NULL.
 1.9 23-May-2011  joerg branches: 1.9.4; 1.9.10; 1.9.14; 1.9.16; 1.9.18; 1.9.24;
Update from GNU extension to C99 syntax for designated initializer
 1.8 23-Apr-2010  rmind branches: 1.8.2;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.7 11-Jan-2009  christos branches: 1.7.4; 1.7.6;
merge christos-time_t
 1.6 29-Apr-2008  martin branches: 1.6.8; 1.6.14;
Convert to new 2 clause license
 1.5 21-Mar-2008  ad branches: 1.5.2; 1.5.4;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.4 20-Dec-2007  dsl branches: 1.4.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.3 10-Sep-2007  cube branches: 1.3.8; 1.3.12;
Remove 3rd clause and my name from all the licences which were only in my
name.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.32; 1.2.46; 1.2.48;
merge ktrace-lwp.
 1.1 23-Oct-2005  cube branches: 1.1.4; 1.1.6;
- Split sys_kevent into kevent1 so that it can be used by COMPAT_NETBSD32
code.

- To achieve COMPAT_NETBSD32 compatibility, introduce a parameter to
kevent1 that points to functions that do the actual copyin/copyout
operations. This is similar to what was done in FreeBSD by Paul Saab.

- Add the COMPAT_NETBSD32 definitions and hooks.
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 23-Oct-2005  skrll file netbsd32_event.c was added on branch ktrace-lwp on 2005-11-10 14:01:21 +0000
 1.1.4.2 26-Oct-2005  yamt sync with head
 1.1.4.1 23-Oct-2005  yamt file netbsd32_event.c was added on branch yamt-vop on 2005-10-26 08:32:44 +0000
 1.2.48.2 09-Jan-2008  matt sync with HEAD
 1.2.48.1 06-Nov-2007  matt sync with HEAD
 1.2.46.1 02-Oct-2007  joerg Sync with HEAD.
 1.2.32.1 09-Oct-2007  ad Sync with head.
 1.2.18.5 24-Mar-2008  yamt sync with head.
 1.2.18.4 21-Jan-2008  yamt sync with head
 1.2.18.3 27-Oct-2007  yamt sync with head.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file netbsd32_event.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:35 +0000
 1.3.12.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.8.1 26-Dec-2007  ad Sync with head.
 1.4.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.4.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.4.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.4.3 11-Aug-2010  yamt sync with head.
 1.5.4.2 04-May-2009  yamt sync with head.
 1.5.4.1 16-May-2008  yamt sync with head.
 1.5.2.1 18-May-2008  yamt sync with head.
 1.6.14.2 04-Jan-2009  christos add new syscalls.
 1.6.14.1 29-Apr-2008  christos file netbsd32_event.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.6.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.6.2 31-May-2011  rmind sync with head
 1.7.6.1 30-May-2010  rmind sync with head
 1.7.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.24.1 30-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1090):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.24
sys/compat/netbsd32/netbsd32_event.c: revision 1.11
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.
ok christos@
 1.9.18.1 18-May-2014  rmind sync with head
 1.9.16.1 30-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1090):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.24
sys/compat/netbsd32/netbsd32_event.c: revision 1.11
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.
ok christos@
 1.9.14.2 03-Dec-2017  jdolecek update from HEAD
 1.9.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.10.2 30-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1090):
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.24
sys/compat/netbsd32/netbsd32_event.c: revision 1.11
Allocate directly KQ_NEVENTS bytes. Otherwise a user can panic the system.
ok christos@
 1.9.10.1 18-Mar-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1021):
sys/compat/netbsd32/netbsd32_event.c: revision 1.10
Fix netbsd32 compatibility bug in kevent().

The keo_put_events() callback copies the events from kernel to userland.
It is called for sets of up to 8 events (constant chosen in kevbuf
definitition in kevent1()). The callback is called with pointer to
userland buffer, count of events to copy, and an index parameter which tracks
where we are in userland buffer when called multiple time.
COMPAT_NETBSD32's flavor of keo_put_events() is
netbsd32_kevent_put_events(). It did not honour the index parameter, which
caused invalid event data to be returned when userland requested more that 8
events. This caused many reliability problems, and the obvious startup crash
of dovecot log process when it accessed udata in the nineth event in its
buffer, which was NULL.
 1.9.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.10.2.1 10-Aug-2014  tls Rebase.
 1.2 29-Jul-2023  rin COMPAT_NETBSD32: No need to have compat_100_netbsd32_kevent_fetch_timeout.
NFCI.
 1.1 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 1.27 01-Dec-2000  jdolecek put a.out/elf32 specific things in netbsd32_exec_{aout|elf32}.c
emul_netbsd32 was moved to netbsd32_netbsd.c
g/c netbsd32_exec.c now
 1.26 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.25 01-Dec-2000  mrg in netbsd32_elf32_probe(), 'pos' is really a pointer to an Elf_Addr, not a
vaddr_t. cast the pointer before dereferencing it to avoid the alignment
fault that broke compat_netbsd32, cuz pos is defined like:
Elf_Addr phdr = 0, pos = 0;
in exec_elf32.c.
 1.24 27-Nov-2000  jdolecek adapt to execsw[] changes
 1.23 21-Nov-2000  jdolecek restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures
 1.22 13-Nov-2000  jdolecek change the type of *syscallnames[] array to 'const char * const foo[]'
 1.21 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.20 06-Jun-2000  soren defopt SYSCALL_DEBUG.
 1.19 11-Apr-2000  chs branches: 1.19.2;
add a new function vn_marktext() for exec code to let others know
that the vnode is now being used as process text.
 1.18 06-Feb-2000  eeh Add support for -current's ELF32 exec format.
 1.17 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.16 11-Oct-1999  eeh branches: 1.16.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.15 26-Mar-1999  eeh branches: 1.15.4; 1.15.8;
COMPAT_SPARC32 -> COMPAT_NETBSD32
 1.14 25-Mar-1999  mrg clean and up make compile
 1.13 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.12 18-Dec-1998  drochner OMPAT_xxx option review: add missing opt_compat_sunos.h
 1.11 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.10 10-Sep-1998  eeh Use correct 32-bit signal trampoline code in the emul.
 1.9 09-Sep-1998  thorpej Cosmetic changes.
 1.8 09-Sep-1998  thorpej If we don't find a valid magic, return ENOEXEC, not EINVAL.
 1.7 09-Sep-1998  thorpej If we succeed in preparing the exec package, set the package's emulation
to emul_sparc32.
 1.6 09-Sep-1998  thorpej MID_MACHINE -> MID_SPARC
 1.5 06-Sep-1998  eeh Copyout 32-bit args.
 1.4 30-Aug-1998  eeh Some more 64-bit cleanup. Now everything compiles.
 1.3 29-Aug-1998  eeh Some more 64-bit-ification.
 1.2 26-Aug-1998  mrg fake sendsig for now..
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.15.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.15.4.1 04-Jul-1999  chs after setting VTEXT on a vnode, flush any UBC mappings
to try to prevent unnecessary VAC aliases.
 1.16.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.16.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.16.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.19.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.37 06-Nov-2021  thorpej COMPAT_NETBSD32 is all about running the 32-bit flavor of native
binaries on a 64-bit platform[*], as such:
- Make the logic about which "sendsig" flavor to call MI (as it is in the
native 64-bit environment) and follow the same rules as the native 32-bit
environment.
- Make COMPAT_NETBSD32 x COMPAT_16 work the same as it would in the
native 32-bit environment by providing a netbsd32_sendsig_sigcontext_16_hook,
rather than overriding the entire sendsig logic with a netbsd32_sendsig_hook.
- In netbsd32___sigaction_sigtramp(), make sure the compat_netbsd32_16
module is loaded if the trampoline version specifies a sigcontext style
handler, otherwise return EINVAL so that libc can try again with siginfo
style.

[*] ...except for arm32, which uses it to mean "run 32-bit OABI binaries
from the 32-bit EABI environment". Doing it this way was arguably a mistake,
but we are stuck with it for now, so support it by providing a machine-
dependent override for netbsd32_sendsig() that also disables the corresponding
logic in netbsd32___sigaction_sigtramp().

Fixes PR kern/56487.
 1.36 19-Jan-2021  simonb Whitespace nits.
 1.35 18-Jan-2021  simonb s/u_intN_t/uintN_t/
 1.34 27-Jan-2019  pgoyette branches: 1.34.12;
Merge the [pgoyette-compat] branch
 1.33 25-Jan-2017  jakllsch branches: 1.33.12; 1.33.14;
Catch netbsd32_copyargs() up to changes in r1.441 src/sys/kern/kern_exec.c
 1.32 24-Oct-2014  christos branches: 1.32.2; 1.32.4; 1.32.6;
sync with the regular method; no functional diff
 1.31 10-Dec-2009  matt branches: 1.31.22;
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.30 15-Aug-2009  matt Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for you.
 1.29 15-Mar-2009  cegger ansify function definition
 1.28 19-Nov-2008  ad branches: 1.28.4; 1.28.6;
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.27 29-May-2008  mrg branches: 1.27.4; 1.27.6;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.26 04-Dec-2007  dsl branches: 1.26.12; 1.26.14; 1.26.16; 1.26.18;
Remove all the __P
 1.25 26-Mar-2007  cube branches: 1.25.8; 1.25.10; 1.25.16; 1.25.18;
Count environment vars with envc, not argc [hi dsl!]. Reported by Nicolas
Joly in private mail.
 1.24 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.23 16-Feb-2006  perry branches: 1.23.20; 1.23.24; 1.23.26; 1.23.28;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.22 24-Dec-2005  perry branches: 1.22.2; 1.22.4; 1.22.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.21 11-Dec-2005  christos merge ktrace-lwp.
 1.20 26-Feb-2005  perry branches: 1.20.4;
nuke trailing whitespace
 1.19 26-Mar-2004  drochner branches: 1.19.8; 1.19.10;
all ports define __HAVE_SIGINFO now, so remove the CPP conditionals
 1.18 11-Oct-2003  chs fix typo in previous.
 1.17 10-Oct-2003  matt Define SIGINFO variant of netbsd32_sendsig when __HAVE_SIGINFO is defined.
 1.16 26-Sep-2003  christos bring in MI declarations.
 1.15 29-Jun-2003  fvdl branches: 1.15.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.14 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.13 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.12 26-Aug-2002  christos Implement passing AT_{E,R}{U,G}ID in the elf aux vector, like solaris.
- pass struct proc to copyargs.
- eliminate svr4_copyargs, since it is the same as ours now.
 1.11 04-Jun-2002  eeh Prototype for probing noteless 32-bit emulation binaries.
 1.10 25-Aug-2001  mrg branches: 1.10.12;
update copyright notices.
 1.9 29-Jul-2001  christos Adjust to the new copyargs() footprint.
 1.8 02-Feb-2001  mrg branches: 1.8.2; 1.8.4;
de-static netbsd32_exec_aout_prep_[zno]magic().
de-static netbsd32_from_stat43().
move the guts of netbsd32_execve() into netbsd32_execve2().

all of are for the forthcoming sunos32 compat mode (for sparc64).
 1.7 01-Dec-2000  jdolecek make netbsd32_copyargs() an inline
 1.6 27-Nov-2000  jdolecek adapt to execsw[] changes
 1.5 21-Nov-2000  jdolecek restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures
 1.4 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.3 25-Mar-1999  mrg branches: 1.3.8;
SPARC32->NETBSD32
 1.2 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.3.8.4 11-Feb-2001  bouyer Sync with HEAD.
 1.3.8.3 08-Dec-2000  bouyer Sync with HEAD.
 1.3.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.8.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.8.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.8.4.1 03-Aug-2001  lukem update to -current
 1.8.2.5 11-Nov-2002  nathanw Catch up to -current
 1.8.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.8.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.8.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.8.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.10.12.2 29-Aug-2002  gehenna catch up with -current.
 1.10.12.1 20-Jun-2002  gehenna catch up with -current.
 1.15.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.2.5 04-Feb-2005  skrll Adapt to branch.
 1.15.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.2 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.19.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.19.8.1 29-Apr-2005  kent sync with -current
 1.20.4.3 07-Dec-2007  yamt sync with head
 1.20.4.2 03-Sep-2007  yamt sync with head.
 1.20.4.1 21-Jun-2006  yamt sync with head.
 1.22.6.1 22-Apr-2006  simonb Sync with head.
 1.22.4.1 09-Sep-2006  rpaulo sync with head
 1.22.2.1 18-Feb-2006  yamt sync with head.
 1.23.28.2 29-Mar-2007  reinoud Pullup to -current
 1.23.28.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.23.26.1 11-Jul-2007  mjf Sync with head.
 1.23.24.1 10-Apr-2007  ad Sync with head.
 1.23.20.2 15-Apr-2007  yamt sync with head.
 1.23.20.1 24-Mar-2007  yamt sync with head.
 1.25.18.1 08-Dec-2007  ad Sync with head.
 1.25.16.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.10.1 09-Jan-2008  matt sync with HEAD
 1.25.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.26.18.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.26.16.3 11-Mar-2010  yamt sync with head
 1.26.16.2 19-Aug-2009  yamt sync with head.
 1.26.16.1 04-May-2009  yamt sync with head.
 1.26.14.1 04-Jun-2008  yamt sync with head
 1.26.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.26.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.27.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.27.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.27.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.28.6.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.4.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.28.4.1 19-Nov-2008  ad file netbsd32_exec.h was added on branch christos-time_t on 2008-11-19 18:36:06 +0000
 1.31.22.1 03-Dec-2017  jdolecek update from HEAD
 1.32.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.32.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.32.2.1 05-Feb-2017  skrll Sync with HEAD
 1.33.14.1 10-Jun-2019  christos Sync with HEAD
 1.33.12.1 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.34.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.31 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.30 06-Aug-2016  maxv branches: 1.30.28;
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.29 05-Dec-2014  christos Add compatibility for pre MIDMAGIC a.out binaries (with COMPAT_NOMID)
Oldzmagic binaries need "sysctl -w vm.user_va0_disable=0"
 1.28 24-Oct-2014  christos branches: 1.28.2;
remove unused prototypes
 1.27 25-Jan-2014  christos Clear the VM_TOPDOWN flag only when we succeed.
 1.26 25-Jan-2014  christos a.out binaries can't handle topdown.
Now 1.0 binaries work correctly on NetBSD-current.
 1.25 23-Apr-2010  rmind branches: 1.25.8; 1.25.18; 1.25.22;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.24 29-May-2008  mrg branches: 1.24.12; 1.24.20; 1.24.22;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.23 08-Dec-2007  dsl branches: 1.23.12; 1.23.14; 1.23.16; 1.23.18;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.22 04-Dec-2007  dsl Remove all the __P
 1.21 11-Dec-2005  christos branches: 1.21.44; 1.21.46; 1.21.52; 1.21.56;
merge ktrace-lwp.
 1.20 26-Feb-2005  perry branches: 1.20.4;
nuke trailing whitespace
 1.19 20-Feb-2004  drochner branches: 1.19.8; 1.19.10;
did this ever work? The EXEC_32 flag must be set _before_
exec_aout_prep_*magic(), otherwise setup_stack() fails.
 1.18 20-Feb-2004  drochner -MID_SPARC->NETBSD32_MID_MACHINE
-check for zero BSS size, as in kern/exec_aout.c rev. 1.23
 1.17 13-Oct-2003  agc Move Matt Green's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22396 by Joel Baker, the changes
were confirmed to the board by Matt Green.
 1.16 08-Aug-2003  christos - GC all the setup_stack functions
- add one for linux/i386
 1.15 29-Jun-2003  fvdl branches: 1.15.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.14 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.13 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.12 10-Dec-2002  thorpej Rename __LDPGSZ to AOUT_LDPGSZ, to accurately reflect what it is.
 1.11 10-Dec-2002  thorpej Use __LDPGSZ (which must be == USRTEXT) as the text address for a.out
executables, and eliminate the USRTEXT constant, which was only used
by the a.out exec code.
 1.10 05-Oct-2002  chs count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.9 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.8 13-Nov-2001  lukem branches: 1.8.10;
add RCSIDs (including regeneration of files as appropriate)
 1.7 30-Oct-2001  thorpej - Add a new vnode flag VEXECMAP, which indicates that a vnode has
executable mappings. Stop overloading VTEXT for this purpose (VTEXT
also has another meaning).
- Rename vn_marktext() to vn_markexec(), and use it when executable
mappings of a vnode are established.
- In places where we want to set VTEXT, set it in v_flag directly, rather
than making a function call to do this (it no longer makes sense to
use a function call, since we no longer overload VTEXT with VEXECMAP's
meaning).

VEXECMAP suggested by Chuq Silvers.
 1.6 25-Aug-2001  mrg branches: 1.6.4;
update copyright notices.
 1.5 14-Feb-2001  eeh branches: 1.5.2; 1.5.4;
Support flexible process address space limits and bump kernel version number.
 1.4 03-Feb-2001  mrg s/sizeof(struct exec)/sizeof(struct netbsd32_exec)/ when calculating file offsets. now sunos32 nmagic/omagic work.
 1.3 02-Feb-2001  mrg de-static netbsd32_exec_aout_prep_[zno]magic().
de-static netbsd32_from_stat43().
move the guts of netbsd32_execve() into netbsd32_execve2().

all of are for the forthcoming sunos32 compat mode (for sparc64).
 1.2 18-Dec-2000  mrg copy exec_aout.c:exec_aout_setup_stack to netbsd32_exec_aout_setup_stack,
but use USRSTACK32 not USRSTACK, so that we get 32-bit stack addresses.

now 32 bit a.out binaries work on sparc64.
 1.1 01-Dec-2000  jdolecek branches: 1.1.2;
put a.out/elf32 specific things in netbsd32_exec_{aout|elf32}.c
emul_netbsd32 was moved to netbsd32_netbsd.c
g/c netbsd32_exec.c now
 1.1.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.1.2.1 01-Dec-2000  bouyer file netbsd32_exec_aout.c was added on branch thorpej_scsipi on 2000-12-08 09:08:34 +0000
 1.5.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.5.2.4 11-Dec-2002  thorpej Sync with HEAD.
 1.5.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.5.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.5.2.1 21-Sep-2001  nathanw Catch up to -current.
 1.6.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.8.10.2 02-Oct-2003  tron Pull up revision 1.10 (requested by junyoung in ticket #1488):
count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.8.10.1 27-Sep-2003  tron Pull up revision 1.9 (requested by junyoung in ticket #1466):
remove trailing \n in panic(). approved perry.
 1.15.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.2.5 04-Feb-2005  skrll Adapt to branch.
 1.15.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.2 03-Aug-2004  skrll Sync with HEAD
 1.15.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.19.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.19.8.1 29-Apr-2005  kent sync with -current
 1.20.4.3 21-Jan-2008  yamt sync with head
 1.20.4.2 07-Dec-2007  yamt sync with head
 1.20.4.1 21-Jun-2006  yamt sync with head.
 1.21.56.2 26-Dec-2007  ad Sync with head.
 1.21.56.1 08-Dec-2007  ad Sync with head.
 1.21.52.2 27-Dec-2007  mjf Sync with HEAD.
 1.21.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.21.46.1 09-Jan-2008  matt sync with HEAD
 1.21.44.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.23.18.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23.16.2 11-Aug-2010  yamt sync with head.
 1.23.16.1 04-May-2009  yamt sync with head.
 1.23.14.1 04-Jun-2008  yamt sync with head
 1.23.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.24.22.1 30-May-2010  rmind sync with head
 1.24.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.24.12.2 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.24.12.1 29-May-2008  mrg file netbsd32_exec_aout.c was added on branch christos-time_t on 2008-05-29 14:51:27 +0000
 1.25.22.1 18-May-2014  rmind sync with head
 1.25.18.2 03-Dec-2017  jdolecek update from HEAD
 1.25.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.25.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.28.2.2 05-Oct-2016  skrll Sync with HEAD
 1.28.2.1 06-Apr-2015  skrll Sync with HEAD
 1.30.28.1 03-Apr-2021  thorpej Sync with HEAD.
 1.45 07-Jun-2019  christos deduplicate the elf auxv builder code, welcome to 8.99.43
 1.44 07-Jun-2019  christos Sync auxv vector generation with exec_elf.c. Fixes $ORIGIN on compat_netbsd32.
Found by zerous as part of GSoC
 1.43 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.42 26-Feb-2019  rin Push AT_STACKBASE. Otherwise, pthread_attr_getstack(3) cannot
find the stack address for initial thread (LID 1).

Now, rust for i386 and armv7 work on amd64 and aarch64,
respectively.
 1.41 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.40 06-Aug-2016  maxv branches: 1.40.14; 1.40.16;
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.39 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.38 24-Oct-2014  christos branches: 1.38.2;
remove unused prototypes
 1.37 25-Jul-2014  maxv branches: 1.37.2;
Remove ELF_ROUND and ELF_TRUNC (unused). Found by my code scanner.
 1.36 03-Aug-2012  matt branches: 1.36.2; 1.36.12;
Only set EXEC_32 if on LP64 platform.
 1.35 03-Feb-2012  matt Add a hook for freeing an ep_emul_arg. Add a wrapper routine
(exec_free_emul_arg) to call the hook and then clear the ep_emul_arg
and ep_emul_arg_free members in the exec_package.
Change users/accessors to use these routines.
Approved by releng.
 1.34 03-Feb-2012  christos elf_args needs to be freed with kmem_free() since it is now allocated with
kmem_alloc(). Should fix running 32 bit elf binaries.
 1.33 07-Mar-2011  joerg branches: 1.33.4; 1.33.8;
Pass down ELF Auxillary Vectors for static NetBSD binaries too.
Rename __libc_init to _libc_init and call it explicitly from CSU code.
This enforces the constructor run order for newly linked programs.
Keep it as constructor with run-once semantic for binary compatibility.
Implement dl_iterate_phdr for statically linked programs.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.32 14-Dec-2009  mrg branches: 1.32.4; 1.32.6;
replace mips:elf_check_itp() and ELFNAME2(netbsd32,probe_noteless) that
it's based upon with a common compat_elf_check_interp().

tested on MALTA64 and sparc64.
 1.31 14-Dec-2009  matt Merge from matt-nb5-mips64
 1.30 29-Jun-2009  dholland Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.29 26-Oct-2008  mrg branches: 1.29.8; 1.29.10; 1.29.14;
if the interpreter is literally "/usr/libexec/ld.elf_so" or
"/libexec/ld.elf_so", try <path>-<machine32arch>.
 1.28 29-May-2008  mrg branches: 1.28.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.27 22-Apr-2007  dsl branches: 1.27.28; 1.27.30; 1.27.32; 1.27.34;
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.26 23-Jul-2006  ad branches: 1.26.10; 1.26.14; 1.26.16;
Use the LWP cached credentials where sane.
 1.25 14-May-2006  elad integrate kauth.
 1.24 27-Dec-2005  cube branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10; 1.24.12;
More ktrace-lwp merge fallout: netbsd_elf32_signature's prototype has
changed. Too bad C doesn't have signatures in symbols.

Fixes PR#32388 by Nicolas Joly.
 1.23 11-Dec-2005  christos merge ktrace-lwp.
 1.22 26-Feb-2005  perry branches: 1.22.4;
nuke trailing whitespace
 1.21 31-Oct-2003  drochner branches: 1.21.8; 1.21.10;
adapt for changes to kern/exec_elf32.c
 1.20 13-Oct-2003  agc Move Matt Green's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22396 by Joel Baker, the changes
were confirmed to the board by Matt Green.
 1.19 29-Jun-2003  fvdl branches: 1.19.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.18 29-Jun-2003  martin struct proc * -> struct lwp *
 1.17 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.16 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.15 01-Dec-2002  agc Make this compile in the presence of -Werror
 1.14 29-Nov-2002  jdolecek use emul_find_interp(), rathern than calling emul_find() second time
with prefix set to "/"
XXX not tested
 1.13 29-Aug-2002  martin Adapt to recent exec changes.
 1.12 29-Aug-2002  christos s/au_/a_/g noticed by martin
 1.11 26-Aug-2002  christos Implement passing AT_{E,R}{U,G}ID in the elf aux vector, like solaris.
- pass struct proc to copyargs.
- eliminate svr4_copyargs, since it is the same as ours now.
 1.10 01-Jun-2002  fvdl Make this compile again since the previous change. KNF.
 1.9 31-May-2002  eeh Support chroot-ing to a 32-bit installation.
 1.8 13-Nov-2001  lukem branches: 1.8.8;
add RCSIDs (including regeneration of files as appropriate)
 1.7 25-Aug-2001  mrg update copyright notices.
 1.6 30-Jul-2001  eeh Add missing `error'.
 1.5 29-Jul-2001  christos Adjust to the new copyargs() footprint.
 1.4 14-Feb-2001  eeh branches: 1.4.2; 1.4.4;
Support flexible process address space limits and bump kernel version number.
 1.3 11-Feb-2001  eeh Don't play fast and loose with pointers.
 1.2 02-Dec-2000  mrg branches: 1.2.2;
pull over lost fix from nebsd32_exec.c:
>revision 1.25
>date: 2000/12/01 08:59:02; author: mrg; state: Exp; lines: +2 -2
>in netbsd32_elf32_probe(), 'pos' is really a pointer to an Elf_Addr, not a
>vaddr_t. cast the pointer before dereferencing it to avoid the alignment
>fault that broke compat_netbsd32, cuz pos is defined like:
> Elf_Addr phdr = 0, pos = 0;
>in exec_elf32.c.
 1.1 01-Dec-2000  jdolecek put a.out/elf32 specific things in netbsd32_exec_{aout|elf32}.c
emul_netbsd32 was moved to netbsd32_netbsd.c
g/c netbsd32_exec.c now
 1.2.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1 02-Dec-2000  bouyer file netbsd32_exec_elf32.c was added on branch thorpej_scsipi on 2000-12-08 09:08:34 +0000
 1.4.4.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.4.4.1 03-Aug-2001  lukem update to -current
 1.4.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.4.2.6 05-Sep-2002  petrov Catch up with -current.
 1.4.2.5 27-Aug-2002  nathanw Catch up to -current.
 1.4.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.4.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.4.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.4.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.8.8.3 31-Aug-2002  gehenna catch up with -current.
 1.8.8.2 29-Aug-2002  gehenna catch up with -current.
 1.8.8.1 20-Jun-2002  gehenna catch up with -current.
 1.19.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.3 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.19.2.2 03-Aug-2004  skrll Sync with HEAD
 1.19.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.21.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.21.8.1 29-Apr-2005  kent sync with -current
 1.22.4.3 03-Sep-2007  yamt sync with head.
 1.22.4.2 30-Dec-2006  yamt sync with head.
 1.22.4.1 21-Jun-2006  yamt sync with head.
 1.24.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.24.10.2 12-May-2006  elad include sys/kauth.h where appropriate.
 1.24.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.24.8.2 11-Aug-2006  yamt sync with head
 1.24.8.1 24-May-2006  yamt sync with head.
 1.24.6.1 01-Jun-2006  kardel Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.26.16.1 11-Jul-2007  mjf Sync with head.
 1.26.14.1 27-May-2007  ad Sync with head.
 1.26.10.1 07-May-2007  yamt sync with head.
 1.27.34.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.32.3 11-Mar-2010  yamt sync with head
 1.27.32.2 18-Jul-2009  yamt sync with head.
 1.27.32.1 04-May-2009  yamt sync with head.
 1.27.30.1 04-Jun-2008  yamt sync with head
 1.27.28.2 17-Jan-2009  mjf Sync with HEAD.
 1.27.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.29.14.2 14-Dec-2009  mrg pullup from -current:
>replace mips:elf_check_itp() and ELFNAME2(netbsd32,probe_noteless) that
>it's based upon with a common compat_elf_check_interp().
>
>tested on MALTA64 and sparc64.
 1.29.14.1 12-Sep-2009  matt Add support/hooks for ELF_MD_PROBE_FUNC and ELF_INTERP_NON_RELOCATABLE.
 1.29.10.1 23-Jul-2009  jym Sync with HEAD.
 1.29.8.2 26-Oct-2008  mrg if the interpreter is literally "/usr/libexec/ld.elf_so" or
"/libexec/ld.elf_so", try <path>-<machine32arch>.
 1.29.8.1 26-Oct-2008  mrg file netbsd32_exec_elf32.c was added on branch christos-time_t on 2008-10-26 07:07:36 +0000
 1.32.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.4.1 21-Apr-2011  rmind sync with head
 1.33.8.1 18-Feb-2012  mrg merge to -current.
 1.33.4.2 30-Oct-2012  yamt sync with head
 1.33.4.1 17-Apr-2012  yamt sync with head
 1.36.12.1 10-Aug-2014  tls Rebase.
 1.36.2.2 03-Dec-2017  jdolecek update from HEAD
 1.36.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.37.2.1 29-Mar-2015  martin Pull up following revision(s) (requested by maxv in ticket #650):
sys/compat/netbsd32/netbsd32_exec_elf32.c: revision 1.39
sys/kern/exec_elf.c: revision 1.71
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.18
sys/compat/linux/common/linux_exec_elf32.c: revision 1.92
sys/compat/svr4_32/svr4_32_exec_elf32.c: revision 1.24
Zero-fill the ELF auxiliary vectors. Otherwise, on 64bit systems, the
padding between a_v and a_type contains kernel garbage, therefore
exposed to userland.
Original report by uebayasi@
 1.38.2.2 05-Oct-2016  skrll Sync with HEAD
 1.38.2.1 06-Apr-2015  skrll Sync with HEAD
 1.40.16.1 10-Jun-2019  christos Sync with HEAD
 1.40.14.2 24-Jan-2019  pgoyette Use correct macro name
 1.40.14.1 24-Jan-2019  pgoyette Found a couple other consumers of machine32 - adapt them to use the hook
 1.44 11-Nov-2021  martin Adapt to recent posix_spawn extensions.
 1.43 13-Apr-2021  mrg GCC 10 does not like casting from one identical anonymous enum
to another enum. supply some quietening cast.
 1.42 19-Apr-2020  thorpej branches: 1.42.4;
- 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.41 17-Sep-2019  christos branches: 1.41.6;
Add a boolean argument to indicate if we have a path/true (execve) or an
fd/false (fexecve). This is needed to differentiate between them because
NULL/-1 can be readily passed from userland.
 1.40 15-Sep-2019  christos fix fexecve
 1.39 03-Sep-2018  riastradh 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.38 02-Feb-2014  martin branches: 1.38.28; 1.38.30;
Limit the amount of kernel memory a posix_spawn syscall can use (for handling
the file action list) by limiting the maximum number of file actions to
twice the current file descriptor limit.
Fix a few bugs in the support functions and document the new limit.
From Maxime Villard.
 1.37 15-Jan-2013  hannken branches: 1.37.2;
netbsd32_posix_spawn_fa_alloc: use the right length for path allocation.

This error lead to memory pool corruption when freeing kmem with wrong size.
 1.36 02-May-2012  rmind branches: 1.36.2;
Revert posix_spawn() clean up for now, there are some bugs.
 1.35 30-Apr-2012  rmind posix_spawn:
- Remove copy-pasting in error paths, use execve_free_{vmspace,data}().
- Move some code (both in the init and exit paths) out of the locks.
- Slightly simplify do_posix_spawn() callers.
- Add few asserts and comments.
 1.34 08-Apr-2012  martin Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
 1.33 31-Jan-2012  matt branches: 1.33.2;
Add missing *at syscalls among others
 1.32 29-May-2008  mrg branches: 1.32.12; 1.32.34; 1.32.38;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.31 20-Dec-2007  dsl branches: 1.31.6; 1.31.8; 1.31.10; 1.31.12;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.30 22-Apr-2007  dsl branches: 1.30.8; 1.30.16; 1.30.20;
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.29 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.28 04-Mar-2007  christos branches: 1.28.2; 1.28.4; 1.28.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.27 09-Feb-2007  ad branches: 1.27.2;
Merge newlock2 to head.
 1.26 07-Mar-2006  thorpej branches: 1.26.2; 1.26.12;
Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.25 11-Dec-2005  christos branches: 1.25.4; 1.25.6; 1.25.8;
merge ktrace-lwp.
 1.24 13-Jul-2005  cube Do the CHECK_ALT_EXIST dance again in netbsd32_execve(). It was lost in
previous commit.
 1.23 11-Jul-2005  cube Split sys_execve() and add execve1() that does most of the work, and takes
as an argument a function that will retrieve an element of the pointer
arrays in user space. This allows COMPAT_NETBSD32 to share the code for
the emulated version of execve(2), and fixes various issues that came from
the slow drift between the two implementations.

Note: when splitting up a syscall function, I'll use two different ways
of naming the resulting helper function. If it stills does
copyin/out operations, it will be named <syscall>1(). If it does
not (as it was the case for get/setitimer), it will be named
do<syscall>.
 1.22 31-May-2005  christos branches: 1.22.2;
- add const
- avoid shadowed variables.
 1.21 19-May-2005  elad Some changes in veriexec.

New features:

- Add a veriexec_report() routine to make most reporting consistent and
remove some common code.
- Add 'strict' mode that controls how veriexec behaves.
- Add sysctl knobs:
o kern.veriexec.verbose controls verbosity levels. Value: 0, 1.
o kern.veriexec.strict controls strict level. Values: 0, 1, 2. See
documentation in sysctl(3) for details.
o kern.veriexec.algorithms returns a string with a space separated
list of supported hashing algorithms in veriexec.
- Updated documentation in man pages for sysctl(3) and sysctl(8).

Bug fixes:

- veriexec_removechk(): Code cleanup + handle FINGERPRINT_NOTEVAL
correctly.
- exec_script(): Don't pass 0 as flag when executing a script; use the
defined VERIEXEC_INDIRECT - which is 1. Makes indirect execution
enforcement work.
- Fix some printing formats and types..
 1.20 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.19 26-Feb-2005  perry branches: 1.19.2;
nuke trailing whitespace
 1.18 25-Feb-2004  drochner branches: 1.18.8; 1.18.10;
allow to start other emulations (eg native code)
from here: set p_execsw to the new thing, and call
the new emulation's syscall_intern()

XXX there are more differences to kern_exec.c, sa/ras
related afaics, this is harmliss for now since
netbsd32 doesn't support multithreaded programs yet --
one day one execve() implementation should be shared
by native and netbsd32 code.
 1.17 29-Jun-2003  fvdl branches: 1.17.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.16 29-Jun-2003  martin struct proc * -> struct lwp *
 1.15 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.14 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.13 16-Sep-2002  martin branches: 1.13.2;
p->p_sigacts -> p->p_sigctx
 1.12 26-Aug-2002  christos Implement passing AT_{E,R}{U,G}ID in the elf aux vector, like solaris.
- pass struct proc to copyargs.
- eliminate svr4_copyargs, since it is the same as ours now.
 1.11 25-Aug-2002  thorpej Fix some signed/unsigned comparison warnings from GCC 3.3.
 1.10 06-Jun-2002  fvdl Fix wrong psstr computation.
(XXX why is there an entire copy of sys_execve here?)
 1.9 22-Mar-2002  jdolecek branches: 1.9.2; 1.9.4;
invoke setregs hooks correctly, as in sys_execve()
Problem noted and fix tested by Eduardo Horvath
 1.8 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.7 23-Nov-2001  jdolecek branches: 1.7.4;
if the LKM support is not compiled in, don't bother using exec_lock
at all, it's only needed in LKM case

use #if defined(LKM) || defined(_LKM) condition for netbsd32_execve.c,
to DTRT when either compiled statically into kernel with LKM support,
or compiled as a LKM
 1.6 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.5 29-Jul-2001  christos carry on the copyargs() and exit1() changes from kern_exec.c
 1.4 15-Jun-2001  thorpej branches: 1.4.2;
In check_exec(), don't bother checking P_TRACED along with
MNT_NOSUID, just check MNT_NOSUID to clear the S{U,G}ID bits
in the attributes for the vnode we're about to exec.

We now check P_TRACED right before we would actually perform
the s{u,g}id function in the exec code.

This closes a race condition between exec of a setuid binary
and ptrace(2).
 1.3 30-May-2001  mrg use _KERNEL_OPT.
 1.2 04-Mar-2001  mrg branches: 1.2.2;
be more verbose about failed vmcmds.
 1.1 08-Feb-2001  mrg branches: 1.1.2;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_execve.c was added on branch thorpej_scsipi on 2001-02-11 19:14:13 +0000
 1.2.2.10 17-Sep-2002  nathanw Catch up to -current.
 1.2.2.9 27-Aug-2002  nathanw Catch up to -current.
 1.2.2.8 23-Aug-2002  petrov lwpification.
 1.2.2.7 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.2.2.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.4 08-Jan-2002  nathanw Catch up to -current.
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 24-Aug-2001  nathanw Catch up with -current.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 03-Aug-2001  lukem update to -current
 1.7.4.1 17-Mar-2002  thorpej Make the exec_lock an rwlock, and rename it to exec_rwlock.
 1.9.4.1 07-Jun-2002  thorpej pullup-1-6 ticket #189:

syssrc/sys/compat/netbsd32/netbsd32_execve.c 1.10

Original log message:

Fix wrong psstr computation.
(XXX why is there an entire copy of sys_execve here?)
 1.9.2.2 29-Aug-2002  gehenna catch up with -current.
 1.9.2.1 20-Jun-2002  gehenna catch up with -current.
 1.13.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.17.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.7 01-Apr-2005  skrll Sync with HEAD.
 1.17.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.17.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.3 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.17.2.2 03-Aug-2004  skrll Sync with HEAD
 1.17.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.18.10.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.10.1 25-Jan-2005  yamt convert to new apis.
 1.18.8.1 29-Apr-2005  kent sync with -current
 1.19.2.2 12-Sep-2005  tron Apply patch (requested by martin in ticket #740):
Defopt VERIFIED_EXEC.
 1.19.2.1 10-Jun-2005  tron Pull up revision 1.21 (requested by elad in ticket #389):
Some changes in veriexec.
New features:
- Add a veriexec_report() routine to make most reporting consistent and
remove some common code.
- Add 'strict' mode that controls how veriexec behaves.
- Add sysctl knobs:
o kern.veriexec.verbose controls verbosity levels. Value: 0, 1.
o kern.veriexec.strict controls strict level. Values: 0, 1, 2. See
documentation in sysctl(3) for details.
o kern.veriexec.algorithms returns a string with a space separated
list of supported hashing algorithms in veriexec.
- Updated documentation in man pages for sysctl(3) and sysctl(8).
Bug fixes:
- veriexec_removechk(): Code cleanup + handle FINGERPRINT_NOTEVAL
correctly.
- exec_script(): Don't pass 0 as flag when executing a script; use the
defined VERIEXEC_INDIRECT - which is 1. Makes indirect execution
enforcement work.
- Fix some printing formats and types..
 1.22.2.4 21-Jan-2008  yamt sync with head
 1.22.2.3 03-Sep-2007  yamt sync with head.
 1.22.2.2 26-Feb-2007  yamt sync with head.
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.25.8.1 13-Mar-2006  yamt sync with head.
 1.25.6.1 22-Apr-2006  simonb Sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.12.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.26.2.2 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.26.2.1 07-Mar-2006  thorpej file netbsd32_execve.c was added on branch elad-kernelauth on 2006-03-07 03:32:07 +0000
 1.27.2.3 07-May-2007  yamt sync with head.
 1.27.2.2 24-Mar-2007  yamt sync with head.
 1.27.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.28.6.1 29-Mar-2007  reinoud Pullup to -current
 1.28.4.1 11-Jul-2007  mjf Sync with head.
 1.28.2.2 27-May-2007  ad Sync with head.
 1.28.2.1 10-Apr-2007  ad Sync with head.
 1.30.20.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.16.1 26-Dec-2007  ad Sync with head.
 1.30.8.1 09-Jan-2008  matt sync with HEAD
 1.31.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.31.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.31.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.31.10.1 04-May-2009  yamt sync with head.
 1.31.8.1 04-Jun-2008  yamt sync with head
 1.31.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.38.2 29-Apr-2012  mrg sync to latest -current.
 1.32.38.1 18-Feb-2012  mrg merge to -current.
 1.32.34.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.32.34.2 23-Jan-2013  yamt sync with head
 1.32.34.1 17-Apr-2012  yamt sync with head
 1.32.12.2 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.32.12.1 29-May-2008  mrg file netbsd32_execve.c was added on branch christos-time_t on 2008-05-29 14:51:27 +0000
 1.33.2.3 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.33.2.2 08-Feb-2013  riz branches: 1.33.2.2.2;
Pull up following revision(s) (requested by hannken in ticket #793):
sys/compat/netbsd32/netbsd32_execve.c: revision 1.37
netbsd32_posix_spawn_fa_alloc: use the right length for path allocation.
This error lead to memory pool corruption when freeing kmem with wrong size.
 1.33.2.1 12-Apr-2012  riz branches: 1.33.2.1.4;
Pull up following revision(s) (requested by martin in ticket #175):
sys/kern/kern_exit.c: revision 1.238
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.4
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.5
sys/uvm/uvm_extern.h: revision 1.183
lib/libc/gen/posix_spawn_fileactions.c: revision 1.2
sys/kern/kern_exec.c: revision 1.348
sys/kern/kern_exec.c: revision 1.349
sys/compat/netbsd32/syscalls.master: revision 1.95
sys/uvm/uvm_glue.c: revision 1.159
sys/uvm/uvm_map.c: revision 1.317
sys/compat/netbsd32/netbsd32.h: revision 1.95
sys/kern/exec_elf.c: revision 1.38
sys/sys/spawn.h: revision 1.2
sys/sys/exec.h: revision 1.135
sys/compat/netbsd32/netbsd32_execve.c: revision 1.34
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
Fix asynchronous posix_spawn child exit status (and test for it).
 1.33.2.2.2.1 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.33.2.1.4.2 03-Feb-2014  sborrill Pull up the following revisions(s) (requested by martin in ticket #1023):
lib/libc/gen/posix_spawn.3: revision 1.5
lib/libc/gen/posix_spawn_file_actions_addopen.3: revision 1.4
lib/libc/gen/posix_spawn_file_actions_init.3: revision 1.4
lib/libc/gen/posix_spawn_fileactions.c: revision 1.3
sys/compat/netbsd32/netbsd32_execve.c: revision 1.38
sys/kern/kern_exec.c: revision 1.373

Limit the amount of kernel memory a posix_spawn syscall can use (for
handling the file action list) by limiting the maximum number of file
actions to twice the current file descriptor limit. Fix a few bugs in
the support functions and document the new limit. From Maxime Villard.
 1.33.2.1.4.1 08-Feb-2013  riz Pull up following revision(s) (requested by hannken in ticket #793):
sys/compat/netbsd32/netbsd32_execve.c: revision 1.37
netbsd32_posix_spawn_fa_alloc: use the right length for path allocation.
This error lead to memory pool corruption when freeing kmem with wrong size.
 1.36.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.2.1 25-Feb-2013  tls resync with head
 1.37.2.1 18-May-2014  rmind sync with head
 1.38.30.3 21-Apr-2020  martin Sync with HEAD
 1.38.30.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.38.30.1 10-Jun-2019  christos Sync with HEAD
 1.38.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.41.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.42.4.1 17-Apr-2021  thorpej Sync with HEAD.
 1.1 24-Dec-2018  mrg branches: 1.1.2; 1.1.6;
move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 24-Dec-2018  christos file netbsd32_fd.c was added on branch phil-wifi on 2019-06-10 22:07:01 +0000
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file netbsd32_fd.c was added on branch pgoyette-compat on 2018-12-26 14:01:46 +0000
 1.95 23-Apr-2022  reinoud Implement support for mounting UDF in compat32
Fixes PR#56801
 1.94 11-Sep-2021  riastradh sys/kern: Allow custom fileops to specify fo_seek method.

Previously only vnodes allowed lseek/pread[v]/pwrite[v], which meant
converting a regular device to a cloning device doesn't always work.

Semantics is:

(*fp->f_ops->fo_seek)(fp, delta, whence, newoffp, flags)

1. Compute a new offset according to whence + delta -- that is, if
whence is SEEK_CUR, add delta to fp->f_offset; if whence is
SEEK_END, add delta to end of file; if whence is SEEK_CUR, use delta
as is.

2. If newoffp is nonnull, return the new offset in *newoffp.

3. If flags & FOF_UPDATE_OFFSET, set fp->f_offset to the new offset.

Access to fp->f_offset, and *newoffp if newoffp = &fp->f_offset, must
happen under the object lock (e.g., vnode lock), in order to
synchronize fp->f_offset reads and writes.

This change has the side effect that every call to VOP_SEEK happens
under the vnode lock now, when previously it didn't. However, from a
review of all the VOP_SEEK implementations, it does not appear that
any file system even examines the vnode, let alone locks it. So I
think this is safe -- and essentially the only reasonable way to do
things, given that it is used to validate a change from oldoff to
newoff, and oldoff becomes stale the moment we unlock the vnode.

No kernel bump because this reuses a spare entry in struct fileops,
and it is safe for the entry to be null, so all existing fileops will
continue to work as before (rejecting seek).
 1.93 16-Feb-2021  simonb In netbsd32___mount50() zero out the native fs_args union before use so
we don't pass stack garbage to the lower layers in the MNT_GETARGS case.

Fixes random errors like "Bad address" from "mount -vv" with nfs mounts.
 1.92 19-Jan-2021  simonb The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.91 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.90 23-May-2020  ad branches: 1.90.2;
Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
 1.89 27-Apr-2020  christos data_len == 0 on mount means "the kernel knows". Fixes amd on compat32.
 1.88 21-Apr-2020  ad Revert the changes made in February to make cwdinfo use mostly lockless,
which relied on taking extra vnode refs.

Having benchmarked various experimental changes over the past few months it
seems that it's better to avoid vnode refs as much as possible. cwdi_lock
as a RW lock already did that to some extent for getcwd() and will permit
the same for namei() too.
 1.87 23-Feb-2020  ad branches: 1.87.4;
Merge from ad-namecache:

- Have a stab at clustering the members of vnode_t and vnode_impl_t in a
more cache-conscious way. With that done, go back to adjusting v_usecount
with atomics and keep vi_lock directly in vnode_impl_t (saves KVA).

- Allow VOP_LOCK(LK_NONE) for the benefit of VFS_VGET() and VFS_ROOT().
Make sure LK_UPGRADE always comes with LK_NOWAIT.

- Make cwdinfo use mostly lockless.
 1.86 31-Jan-2020  maxv Fix copyout overflows in fhstat, found by the LGTM bot. Not a big problem
since this syscall is privileged.
 1.85 26-Sep-2019  christos branches: 1.85.2;
use size_t for counters (which are compared and set with unsigneds)
 1.84 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.83 21-Sep-2019  maxv Fix netbsd32___mount50():

- zero out fs_args32 to prevent info leaks
- remove unused and non-functional copyin in NFS (lgtm bot)
- declare udata, and don't pass kernel pointers to copyout (lgtm bot)
- make sure data_len is just big enough, to mimic the native behavior
- don't forget to update *retval with the 32bit value
- add an XXX for NFS
 1.82 26-Dec-2018  mrg branches: 1.82.4;
remove duplicated prototypes and dated XXX comments.
 1.81 11-Aug-2018  mrg support nullfs in netbsd32.
 1.80 01-Jun-2017  chs branches: 1.80.2; 1.80.8; 1.80.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.79 01-Dec-2016  mrg s/netbds32_copyout_statvfs/netbsd32_copyout_statvfs/
 1.78 21-Oct-2016  mrg add a ktrgenio() call to netbsd32___getdents30().
from dholland, tested by me.
 1.77 19-Oct-2016  skrll Oops... unintended commit - one day maybe.
 1.76 19-Oct-2016  skrll PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel

Updated from the original patch in the PR by me.
 1.75 16-Oct-2016  dholland Use ktrgeniov, not ktrgenio, in writev.
 1.74 21-Mar-2016  mrg branches: 1.74.2;
avoid some stupid GCC errors seen only with -Os and -O3.
 1.73 23-Oct-2015  maxv Change do_sys_mount() so that it only takes as argument the type of the
drive instead of its associated vfsops. Makes it more friendly, and allows
compat binaries to autoload VFS modules if needed.

sent on tech-kern@, ok christos@
 1.72 05-Oct-2014  christos branches: 1.72.2;
add tmpfs.
 1.71 05-Sep-2014  matt Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.70 30-Apr-2014  njoly Do not use native off_t type under compat netbsd32, but a new
netbsd32_off_t that provide the expected alignment for 64bit types.
 1.69 17-Oct-2013  njoly branches: 1.69.2;
Change mknodat(2) device argument type from uint32_t to dev_t.
Adds needed extra PAD argument for 64bit alignment, and libc wrapper.
 1.68 30-Jul-2013  njoly Add a new get_utimens32() helper function that fetch struct timespec
data if not NULL, to be used by netbsd32_utimensat() and
netbsd32_futimens().
 1.67 18-Jul-2013  matt futimens uses two timespec as well.
 1.66 18-Jul-2013  matt Deal with timespecs properly in futimens and utimensat.
PR/48060
 1.65 18-Jul-2013  matt Move *at syscall handlers to netbsd32_fs.c from netbsd32_netbsd.c
Fix netbsd32_fstatat to emit a 32bit stat structure.
 1.64 13-Dec-2012  matt branches: 1.64.2; 1.64.8;
Fix inverted error check.
 1.63 06-Mar-2012  macallan branches: 1.63.2;
allow mounting ext2fs and msdosfs
while there also enable lfs but that's untested
 1.62 25-Jan-2012  christos branches: 1.62.2; 1.62.6;
Add FNOSIGPIPE for compat32; noted by yamt.
 1.61 05-Jun-2011  dsl branches: 1.61.2; 1.61.6;
Delete some splurious commas and very unexpected trailing space
 1.60 22-Jan-2011  matt branches: 1.60.2;
Add the ability to mount NFS filesystems in COMPAT_NETBSD32
If in the kernel and NFS_ARGS_ONLY, just export struct nfs_args and its flags.
 1.59 23-Apr-2010  rmind branches: 1.59.2; 1.59.4;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.58 14-Dec-2009  matt branches: 1.58.2; 1.58.4;
Merge from matt-nb5-mips64
 1.57 26-Jan-2009  njoly Make all fstat(2) compat syscalls consistently use do_sys_fstat(),
instead of fd_getfile()/fd_putfile() dance.

ok by christos.
 1.56 11-Jan-2009  christos merge christos-time_t
 1.55 24-Jun-2008  ad branches: 1.55.4; 1.55.6; 1.55.10; 1.55.14;
Replace references to getsock/getvnode.
 1.54 29-May-2008  mrg branches: 1.54.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.53 24-Apr-2008  ad branches: 1.53.2; 1.53.4;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.
 1.52 23-Apr-2008  ad Fix locking.
 1.51 21-Mar-2008  ad branches: 1.51.2;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.50 05-Jan-2008  dsl branches: 1.50.6;
Use FILE_LOCK() and FILE_UNLOCK().
Attempt to fix all the code paths so that the 'fp' returned by fd_getfile()
isn't left locked, and is always unlocked (and ref-counted) before
doing anything that might sleep.
 1.49 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.48 08-Dec-2007  dsl branches: 1.48.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.47 04-Dec-2007  dsl Remove all the __P
 1.46 15-Aug-2007  ad branches: 1.46.2; 1.46.8; 1.46.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.45 30-Jun-2007  dsl branches: 1.45.2; 1.45.6;
Changes to sompat socket function to avoid the dreaded stackgap.
 1.44 09-Jun-2007  ad Acquire proclist_mutex before sending signals. XXX irix emul needs a bit
of work.
 1.43 12-May-2007  dsl Change the compat sys_[fl]utime code to not use the stackgap.
 1.42 30-Apr-2007  dsl Split the statvfs functions so that the 'work' is done to a kernel buffer
which can either be copied directly to userspace, or converted then copied.
Saves replicating a lot of code in the compat functions (esp. for
getvfsstat) at a cast of an extra function call in the non-emulated case -
which is unlikely to be measurable given the other costs of the actions
involved (even on vax).
Remove dofhstat() and dofhstatvfs() (and the last caller).
Remove some redundant stackgap_init() calls.
 1.41 22-Apr-2007  dsl Actually report an error when sys__stat30() fails.
 1.40 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.39 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.38 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.37 10-Mar-2007  dsl branches: 1.37.2; 1.37.4;
Update all the compat stuff to not use the 'stackgap' for processing
sys_stat() and friends, instead use do_sys_stat() and do_sys_fstat()
that write the answer into a kernel buffer (on stack) that can be
converted to the correct form and written the userspace.
I've test compiled a few kernels, and tested i386 netbsd1.6 ls.
Given I think I've fixed some bugs, it might be 50-50 with new ones.
 1.36 04-Mar-2007  christos branches: 1.36.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 09-Feb-2007  ad branches: 1.35.2;
Merge newlock2 to head.
 1.34 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.33 04-Aug-2006  yamt branches: 1.33.4; 1.33.6;
some filehandle syscall related changes.

- remove the support of variable-sized filehandle from compat version of
syscalls. (strictly speaking, it breaks abi. i don't think it's a problem
because this feature is short-lived and there are no affected in-tree
filesystems.)
- unify vfs_copyinfh_alloc and vfs_copyinfh_alloc_size.
- vfs_copyinfh_alloc_size: check fhsize strictly.
- reduce code duplication between compat and current syscalls.
 1.32 31-Jul-2006  martin Make filehandles opaque to userland
 1.31 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.30 16-Jul-2006  yamt adapt to vfs_copyinfh -> vfs_copyinfh_alloc rename.
 1.29 14-Jul-2006  martin netbsd32_sys___fhstat30 and netbsd32_sys___fhstatvfs have nothing to do
with compat_30 - so use full/variable sized filehandles here too.
Fixes PR kern/34004.
 1.28 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.27 14-May-2006  elad branches: 1.27.4;
integrate kauth.
 1.26 05-May-2006  cube Move fhstat as sys___fhstat30 in netbsd32_fs.c because it doesn't belong
to netbsd32_netbsd.c (which incidentally means it had been broken for a
while I guess). Add compat_30 version.
 1.25 15-Mar-2006  cube branches: 1.25.2;
Move malloc calls outside of the block where a lock is held.
 1.24 01-Mar-2006  yamt branches: 1.24.2; 1.24.4;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.23 11-Dec-2005  christos branches: 1.23.2; 1.23.4; 1.23.6;
merge ktrace-lwp.
 1.22 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.21 19-Aug-2005  christos 64 bit inode changes.
 1.20 10-Jul-2005  cube NOFOLLOW should be passed to NDINIT() instead of FOLLOW for lstat(2).
Reported by Martin Husemann.
 1.19 26-Feb-2005  perry branches: 1.19.4;
nuke trailing whitespace
 1.18 17-Jun-2004  cube branches: 1.18.4; 1.18.6;
o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.17 22-Apr-2004  hannken Fix statfs->statvfs fallout.
 1.16 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.15 21-Oct-2003  fvdl Don't compare an integer value against 0.
 1.14 29-Jun-2003  fvdl branches: 1.14.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.13 29-Jun-2003  martin struct proc * -> struct lwp *
 1.12 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.11 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.10 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.9 24-Mar-2002  jdolecek use FILE_USE()/FILE_UNUSE() as appropriate, use malloc()/free()
instead of MALLOC()/FREE() for variable-size allocations (sync
with kern/sys_generic.c)
XXX not tested
 1.8 16-Mar-2002  christos make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.7 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.6 14-Jun-2001  thorpej branches: 1.6.2;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.5 30-May-2001  mrg use _KERNEL_OPT.
 1.4 09-Apr-2001  jdolecek Change the first arg to fileops fo_stat routine to struct file *, adjust
callers and appropriate routines to cope. This makes fo_stat more
consistent with rest of fileops routines and also makes the fo_stat
match FreeBSD as an added bonus.
Discussed with Luke Mewburn on tech-kern@.
 1.3 09-Apr-2001  jdolecek Call file descriptor stat function via (*fp->f_ops->fo_stat) instead
of a switch statement and explicit call.
Sprinkle some FILE_USE()/FILE_UNUSE() as appropriate.
 1.2 08-Apr-2001  ross Fix soo_stat() calls for the new parameter, even if the direct call is
now obsolete, so that kernels will at least compile. I guess it was too
much trouble to change all 10 call sites, or perhaps, these days, only
things that build on i386 are important. Maybe it's the full moon tonight.
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.7 11-Nov-2002  nathanw Catch up to -current
 1.1.4.6 23-Aug-2002  petrov lwpification.
 1.1.4.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_fs.c was added on branch thorpej_scsipi on 2001-02-11 19:14:13 +0000
 1.6.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.7 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.6 19-Feb-2005  skrll Make this compile for both KTRACE and !KTRACE builds.
 1.14.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.3 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.14.2.2 03-Aug-2004  skrll Sync with HEAD
 1.14.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.18.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.4.1 29-Apr-2005  kent sync with -current
 1.19.4.7 24-Mar-2008  yamt sync with head.
 1.19.4.6 21-Jan-2008  yamt sync with head
 1.19.4.5 07-Dec-2007  yamt sync with head
 1.19.4.4 03-Sep-2007  yamt sync with head.
 1.19.4.3 26-Feb-2007  yamt sync with head.
 1.19.4.2 30-Dec-2006  yamt sync with head.
 1.19.4.1 21-Jun-2006  yamt sync with head.
 1.23.6.2 01-Jun-2006  kardel Sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.23.2.1 18-Feb-2006  yamt adapt the rest of MI code.
 1.24.4.6 12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.24.4.5 12-May-2006  elad include sys/kauth.h where appropriate.
 1.24.4.4 11-May-2006  elad sync with head
 1.24.4.3 19-Apr-2006  elad sync with head.
 1.24.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.24.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.24.2.3 11-Aug-2006  yamt sync with head
 1.24.2.2 24-May-2006  yamt sync with head.
 1.24.2.1 01-Apr-2006  yamt sync with head.
 1.25.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.27.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.33.6.1 10-Dec-2006  yamt sync with head.
 1.33.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.33.4.1 18-Nov-2006  ad Sync with head.
 1.35.2.4 17-May-2007  yamt sync with head.
 1.35.2.3 07-May-2007  yamt sync with head.
 1.35.2.2 24-Mar-2007  yamt sync with head.
 1.35.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.2.6 20-Aug-2007  ad Sync with HEAD.
 1.36.2.5 15-Jul-2007  ad Sync with head.
 1.36.2.4 27-May-2007  ad Sync with head.
 1.36.2.3 10-Apr-2007  ad Sync with head.
 1.36.2.2 13-Mar-2007  ad Pull in the initial set of changes for the vmlocking branch.
 1.36.2.1 13-Mar-2007  ad Sync with head.
 1.37.4.2 29-Mar-2007  reinoud Pullup to -current
 1.37.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.37.2.1 11-Jul-2007  mjf Sync with head.
 1.45.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.45.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.45.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.46.10.2 26-Dec-2007  ad Sync with head.
 1.46.10.1 08-Dec-2007  ad Sync with head.
 1.46.8.3 18-Feb-2008  mjf Sync with HEAD.
 1.46.8.2 27-Dec-2007  mjf Sync with HEAD.
 1.46.8.1 08-Dec-2007  mjf Sync with HEAD.
 1.46.2.1 09-Jan-2008  matt sync with HEAD
 1.48.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.48.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.50.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.50.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.50.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.50.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.51.2.2 04-Jun-2008  yamt sync with head
 1.51.2.1 18-May-2008  yamt sync with head.
 1.53.4.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.53.4.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.53.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.53.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.53.2.3 11-Aug-2010  yamt sync with head.
 1.53.2.2 11-Mar-2010  yamt sync with head
 1.53.2.1 04-May-2009  yamt sync with head.
 1.54.2.1 27-Jun-2008  simonb Sync with head.
 1.55.14.2 16-Nov-2009  matt remove debug printf
 1.55.14.1 13-Sep-2009  matt Move netbsd32___mount50 from netbsd32_netbsd.c to netbsd32_fs.c
 1.55.10.2 04-Jan-2009  christos add new syscalls.
 1.55.10.1 24-Jun-2008  christos file netbsd32_fs.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.55.6.1 13-Jan-2013  bouyer Pull up following revision(s) (requested by matt in ticket #1829):
sys/compat/netbsd32/netbsd32_fs.c: revision 1.64
Fix inverted error check.
 1.55.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.55.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.58.4.3 12-Jun-2011  rmind sync with head
 1.58.4.2 05-Mar-2011  rmind sync with head
 1.58.4.1 30-May-2010  rmind sync with head
 1.58.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.59.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.59.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.60.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.61.6.2 06-Mar-2012  mrg sync to -current
 1.61.6.1 18-Feb-2012  mrg merge to -current.
 1.61.2.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.61.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.61.2.1 17-Apr-2012  yamt sync with head
 1.62.6.1 17-Dec-2012  riz Pull up following revision(s) (requested by matt in ticket #756):
sys/compat/netbsd32/netbsd32_fs.c: revision 1.64
Fix inverted error check.
 1.62.2.2 17-Dec-2012  riz Pull up following revision(s) (requested by matt in ticket #756):
sys/compat/netbsd32/netbsd32_fs.c: revision 1.64
Fix inverted error check.
 1.62.2.1 13-Dec-2012  riz Pull up following revision(s) (requested by bouyer in ticket #742):
sys/compat/netbsd32/netbsd32.h: revision 1.94
sys/compat/netbsd32/netbsd32_fs.c: revision 1.63
allow mounting ext2fs and msdosfs
while there also enable lfs but that's untested
 1.63.2.3 03-Dec-2017  jdolecek update from HEAD
 1.63.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.63.2.1 25-Feb-2013  tls resync with head
 1.64.8.1 23-Jul-2013  riastradh sync with HEAD
 1.64.2.2 18-May-2014  rmind sync with head
 1.64.2.1 28-Aug-2013  rmind sync with head
 1.69.2.1 10-Aug-2014  tls Rebase.
 1.72.2.4 28-Aug-2017  skrll Sync with HEAD
 1.72.2.3 05-Dec-2016  skrll Sync with HEAD
 1.72.2.2 22-Apr-2016  skrll Sync with HEAD
 1.72.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.74.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.74.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.80.10.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.80.10.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.80.10.1 10-Jun-2019  christos Sync with HEAD
 1.80.8.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.80.8.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.80.2.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1833):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.80.2.1 25-Aug-2018  martin Pull up following revision(s) (requested by mrg in ticket #977):

sys/compat/netbsd32/netbsd32_fs.c: revision 1.81
sys/compat/netbsd32/netbsd32.h: revision 1.119

support nullfs in netbsd32.
 1.82.4.4 01-Apr-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1620):

sys/compat/netbsd32/netbsd32_fs.c: revision 1.89

data_len == 0 on mount means "the kernel knows". Fixes amd on compat32.
 1.82.4.3 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.82.4.2 24-Apr-2022  martin Pull up following revision(s) (requested by reinoud in ticket #1438):

sys/compat/netbsd32/netbsd32.h: revision 1.140
sys/compat/netbsd32/netbsd32_fs.c: revision 1.95
sys/fs/udf/udf_subr.c: revision 1.169

Fix endian issue with UDF extended attribute handling

Implement support for mounting UDF in compat32
Fixes PR#56801
 1.82.4.1 16-Oct-2019  martin Pull up following revision(s) (requested by maxv in ticket #337):

sys/compat/netbsd32/netbsd32_fs.c: revision 1.83

Fix netbsd32___mount50():
- zero out fs_args32 to prevent info leaks
- remove unused and non-functional copyin in NFS (lgtm bot)
- declare udata, and don't pass kernel pointers to copyout (lgtm bot)
- make sure data_len is just big enough, to mimic the native behavior
- don't forget to update *retval with the 32bit value
- add an XXX for NFS
 1.85.2.2 29-Feb-2020  ad Sync with head.
 1.85.2.1 25-Jan-2020  ad Make cwdinfo use mostly lockless, and largely hide the details in vfs_cwd.c.
 1.87.4.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.90.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 26-Apr-2020  thorpej Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
 1.122 10-Nov-2024  riastradh netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.

No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.121 11-May-2024  martin branches: 1.121.2;
PR 58235: add support for SIOCGIFDATA and SIOCZIFDATA ioctls.
 1.120 22-Dec-2021  roy branches: 1.120.4;
Handle the SIOCGNBRINFO ioctl for compat32.
arp -a works with compat32 now.

Credit to simonb@ for the ndp fix from which this is cribbed.
 1.119 14-Apr-2021  mlelstv Add DIOCGDISKINFO compat.
 1.118 17-Jan-2021  simonb branches: 1.118.2;
Handle the SIOCGNBRINFO_IN6 ioctl for compat32. ndp -a works with
compat32 now.
 1.117 14-Jan-2021  simonb Remove some blank lines to group the VND and FSS ioctls together.
 1.116 14-Jan-2021  simonb Handle the KFILTER_BYFILTER and KFILTER_BYNAME ioctls for compat32.
Passes "atf kernel/kqueue/t_ioctl".
 1.115 14-Jan-2021  simonb Handle FSSIOCSET and FSSIOCGET; vndconfig(8) works with compat32 now.
XXX: FSSIOCSET50 and FSSIOCGET50 are not (yet) handled.
 1.114 21-Jul-2020  simonb branches: 1.114.2;
Add lockstat(1) ioctl handling.

mrg@: "looks ok."
 1.113 18-Jul-2020  jmcneill Add BIOCSETWF32 (bpf)
 1.112 16-Mar-2020  christos Unfortunately all the clockctl ioctls contain pointers to structs instead
of the structs themselves, so they need special handling. Undo previous
and do the permissions checks explicitly. It would be better to fix the
clockctl ioctls to contain the structs themselves...
 1.111 16-Mar-2020  christos Don't open-code ioctls, pass back to the 64 bit ones (found by maxv@),
 1.110 14-Mar-2020  maxv wrong size passed to copyout
 1.109 11-Feb-2020  mlelstv Where did the +1 came from ?
 1.108 10-Feb-2020  mlelstv Don't use strlcpy to copy untrusted input, it may not be NUL-terminated.
 1.107 01-Feb-2020  riastradh Load struct filedesc::fd_dt with atomic_load_consume.

Exceptions: when fd_refcnt <= 1, or when holding fd_lock.

While here:

- Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused.
=> This is used only in fd_close and fd_abort, where it holds.
- Move bounds check assertion in fd_putfile to where it matters.
- Store fd_dt with atomic_store_release.
- Move load of fd_dt under lock in knote_fdclose.
- Omit membar_consumer in fdesc_readdir.
=> atomic_load_consume serves the same purpose now.
=> Was needed only on alpha anyway.
 1.106 18-Nov-2019  rin branches: 1.106.2;
Sorry, revert unintentional parts of the previous commit:
http://mail-index.netbsd.org/source-changes/2019/11/18/msg110946.html

I was going to commit only netbsd32_signal.c.
 1.105 18-Nov-2019  rin Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
 1.104 20-Aug-2019  christos compat32 drm ioctl support from Surya Shankar at GSoC 2019
 1.103 17-May-2019  msaitoh branches: 1.103.2;
The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.102 23-Apr-2019  msaitoh KNF. No functional change.
 1.101 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.100 25-Nov-2018  mlelstv Restore netbsd32 compat code for new NPF ABI.
 1.99 12-Oct-2018  rin PR kern/53666
Correct misleading names of dummy variables. No binary changes intended.
 1.98 11-Oct-2018  christos PR/53666: Rin Okuyama: tcpdump for i386 does not work with COMPAT_NETBSD32
on amd64. Add BIOCSRTIMEOUT32.
 1.97 06-Oct-2018  christos comment out unused
 1.96 29-Sep-2018  rmind NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.
 1.95 24-Sep-2018  jdolecek fix DIOCLWEDGES to at least not fail with ENOTTY due to struct size difference,
but probably more needs to be done to work if any actual wedges are configured
 1.94 24-Sep-2018  jdolecek add support for DIOCGSTRATEGY and DIOCSSTRATEGY
 1.93 03-Sep-2018  riastradh 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.92 06-Mar-2018  mlelstv branches: 1.92.2;
Add DIOCLWEDGES
 1.91 19-Jan-2018  macallan branches: 1.91.2;
add conversion goop for WSDISPLAYIO_LDFONT and _SFONT
tested on mips64
 1.90 26-Nov-2017  jmcneill Add support for SIOCGIFGENERIC and SIOCSIFGENERIC ioctls.
 1.89 14-Jan-2017  maya branches: 1.89.8;
appease coverity by using strlcpy instead of strncpy

ok riastradh
 1.88 26-Dec-2016  christos Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)
 1.87 21-Nov-2016  rin Handle CLOCKCTL_NTP_ADJTIME32 even when compiled with !NTP;
just return ENOTTY in order to avoid possible failure when
main kernel and compat_netbsd32 module are compiled with
different NTP options in future.

Suggested and approved by mlelstv
 1.86 15-Nov-2016  rin Protect NPT stuff by "#ifdef NTP". Fix non-NTP kernel.
Approved by martin.
 1.85 12-Nov-2016  mlelstv Fix netbsd32 emulation for clockctl_ntp_adjtime.

The ioctl args reference a timex structure that needs to be
transformed to 64bit layout and back.

The 32bit ioctl definition was wrong for mips, as register_t is 64bit
for N32 abi.
 1.84 13-Jul-2016  jmcneill branches: 1.84.2;
Add netbsd32 support for drvctl(4)
 1.83 08-Dec-2015  christos Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
 1.82 02-Aug-2015  maxv Wrong logic. Here, userland can control the size and the data copied, which
basically means it can overflow kernel memory.

ok martin@ christos@
 1.81 01-Jun-2015  roy Add support for NPF ioctls.
 1.80 01-Jun-2015  roy Back out prior

gimpy1@ we don't #include driver .h in netbsd32
 1.79 31-May-2015  roy Revert prior change, optionally include PPPOE and SPPP support again.
Fix compat_netbsd32 module building by enforcing both.
 1.78 31-May-2015  roy It seems we cannot depend on kernel config in modules, so always compile
in PPP(,oE) support.
 1.77 31-May-2015  roy Add support for PPPOEGETPARMS and PPPOESETPARMS.
 1.76 31-May-2015  roy Support SPPPGETAUTHCFG and SPPPSETAUTHCFG.
 1.75 31-May-2015  roy Fixup ifdrv parameter order.
 1.74 27-May-2015  matt Fix netbsd32 ifdrv copy routines to not use memcpy.
 1.73 27-May-2015  matt Add missing SIOCGDRVSPEC32
Fix SIOCGETSGCNT32
 1.72 20-May-2015  matt Rework ksym defines and includes.
 1.71 20-May-2015  matt Change the ksyms ioctls to more compat_netbsd32 friendly. Use _IOWR ioctls
to avoid extra copyouts. With these changes, netstat and vmstat work on
mips64eb with the normal N32 userland and a N64 kernel.
 1.70 18-May-2015  martin Implement SIOCIFGCLONERS for netbsd32, so ifconfig -C works.
 1.69 24-Jan-2014  bouyer branches: 1.69.4; 1.69.6;
Support WSDISPLAYIO_GETCMAP/WSDISPLAYIO_PUTCMAP. Tested on evbmips/loongson
 1.68 24-Jan-2014  manu Add ATAIOCCOMMAND ioctl form COMPAT_NETBSD32

This enables SMART monitoring by a netbsd32 binary.
 1.67 06-Aug-2012  skrll branches: 1.67.2; 1.67.4;
Ensure correct alignment for stack buffers when long != 64-bit, e.g.
arm.
 1.66 28-May-2012  christos compat for 80211 ioctls from jmcneill
 1.65 11-May-2012  christos provide clockctl ioctl emulation
 1.64 06-Oct-2011  macallan branches: 1.64.2; 1.64.6; 1.64.8; 1.64.12; 1.64.14;
fix pasto, now SIOCS80211NWKEY and SIOCG80211NWKEY actually work
 1.63 05-Oct-2011  macallan forgot SIOCG80211NWKEY32 when adding SIOCS80211NWKEY32
 1.62 28-Sep-2011  macallan support WSDISPLAYIO_GCURSOR and WSDISPLAYIO_SCURSOR
 1.61 07-Sep-2011  macallan support ioctl(POWER_EVENT_RECVDICT) - now powerd turns my gdium's backlight
off when the lid is closed
 1.60 30-Aug-2011  bouyer Provide netbsd32 compat for bpf. Beside the ioctls, the structure
returned to userland by read(2) also needs to be converted.
For this, the bpf descriptor is flagged as compat32 (or not) in the
open and ioctl functions (where the user process's pid is also updated
in the descriptor). When the bpf buffer is filled in, the 32bits or native
header is used depending on the information stored in the descriptor.

This won't work if a 64bit binary does the open and ioctls, and then
exec a 32bit program which will do the read. But this is very
unlikely to happen in real life ...

Tested on i386 and loongson; with these changes my loongson can run
dhclient and tcpdump with a n32 userland.
 1.59 30-Aug-2011  macallan support SIOCG80211NWKEY
 1.58 30-Aug-2011  macallan add WSDISPLAYIO_ADDSCREEN
 1.57 27-Aug-2011  bouyer translate WDOGIOC_GWDOGS
 1.56 04-Apr-2011  ahoka remove FLASH_GET_INFO compat as it is no longer using size_t
 1.55 19-Mar-2011  cliff compat/netbsd32 ioctl support for FLASH_GET_INFO
 1.54 01-Feb-2011  matt Define 32bit version of SIOC[GS]IFADDRPREF32. We wouldn't need this to
if i386 actually aligned a uint64_t on a 64bit boundary but it doesn't.
So all that work in sockaddr_storage goes for naught.
 1.53 22-Jan-2011  matt Fix c&p error.
 1.52 18-Jan-2011  matt branches: 1.52.2;
Make struct disklabel 8 byte aligned. This increases its size by 4 bytes
on IPL32 platforms so add code in sys_ioctl (and netbsd32_ioctl) to deal
with the older/smaller diskabel size. This change makes disklabel the
same for both IPL32 and LP64 platforms.
 1.51 24-Sep-2010  njoly branches: 1.51.2;
Add support for envsys(4) version 2 ioctls.
 1.50 19-Sep-2010  mrg add (runtime untested) support for AUDIO_WSEEK.
 1.49 19-Sep-2010  mrg add support for the netbsd 5.0 versions of the VND* ioctls.
 1.48 19-Sep-2010  mrg support VND* ioctls.
 1.47 23-Apr-2010  rmind Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.46 11-Dec-2009  njoly branches: 1.46.2; 1.46.4;
In netbsd32_from_{ifreq,oifreq}(), use the compat structure size for
memcpy.

From mrg.
 1.45 10-Dec-2009  njoly Kill debug printf.
 1.44 10-Dec-2009  njoly Make netbsd32_from_{ifreq,oifreq}() copy the whole structure, not only
the interface name. Finally fix my own PR/39424.

ok by christos.
 1.43 09-Dec-2009  christos Add netbsd32_oifreq and fix issue in copying the interface name. With this
patch OSIOC{G,S}IFFLAGS is supposed to work, but unfortunately getifaddrs
seems to be the next problem getting the 4.99.x i386 ifconfig working on an
amd64 current machine.
 1.42 24-May-2009  ad More changes to improve kern_descrip.c.

- Avoid atomics in more places.
- Remove the per-descriptor mutex, and just use filedesc_t::fd_lock.
It was only being used to synchronize close, and in any case we needed
to take fd_lock to free the descriptor slot.
- Optimize certain paths for the <NDFDFILE case.
- Sprinkle more comments and assertions.
- Cache more stuff in filedesc_t.
- Fix numerous minor bugs spotted along the way.
- Restructure how the open files array is maintained, for clarity and so
that we can eliminate the membar_consumer() call in fd_getfile(). This is
mostly syntactic sugar; the main functional change is that fd_nfiles now
lives alongside the open file array.

Some measurements with libmicro:

- simple file syscalls are like close() are between 1 to 10% faster.
- some nice improvements, e.g. poll(1000) which is ~50% faster.
 1.41 02-Jul-2008  matt branches: 1.41.10; 1.41.12;
Change {ff,fd}_exclose and ff_allocated to bool. Change exclose arg to
fd_dup to bool. Switch assignments from 1/0 to true/false.

This make alpha kernels compile. Bump kern to 4.99.69 since structure
changed.
 1.40 23-Jun-2008  njoly Update compat netbsd32 SIOCGIFCONF ioctls definitions to follow native
ones.
 1.39 29-May-2008  mrg branches: 1.39.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.38 21-Mar-2008  ad branches: 1.38.2; 1.38.4; 1.38.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.37 20-Dec-2007  dsl branches: 1.37.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.36 08-Dec-2007  dsl branches: 1.36.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.35 15-Aug-2007  ad branches: 1.35.2; 1.35.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.34 30-May-2007  christos branches: 1.34.2; 1.34.6;
make this compile again
XXX: The ioctls will need to be fixed.
 1.33 20-Mar-2007  njoly Add ktrace I/O support to netbsd32_ioctl() syscall.
Reviewed by cube.
 1.32 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.31 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.30 04-Mar-2007  christos branches: 1.30.2; 1.30.4; 1.30.6;
fix fallout from caddr_t changes.
 1.29 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 09-Feb-2007  ad branches: 1.28.2;
Merge newlock2 to head.
 1.27 29-Jan-2007  hubertf Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
 1.26 24-Sep-2006  fvdl EPASSTHROUGH from lower layers is returned as ENOTTY to the (system) caller.
Make it so.
 1.25 24-Dec-2005  perry branches: 1.25.20; 1.25.22;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.24 11-Dec-2005  christos merge ktrace-lwp.
 1.23 26-Feb-2005  perry branches: 1.23.4;
nuke trailing whitespace
 1.22 15-Jan-2004  mrg branches: 1.22.8; 1.22.10;
begin to implement some ifreq ioctls... long long way to go.
 1.21 21-Sep-2003  jdolecek cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.20 29-Jun-2003  fvdl branches: 1.20.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.19 29-Jun-2003  martin struct proc * -> struct lwp *
 1.18 12-Apr-2003  christos get rid of the ASYNCMAP ioctls
 1.17 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.16 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.15 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.14 03-Jan-2002  mrg move sparc specific ioctl handling (fb & openprom) into arch/sparc64.
 1.13 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.12 19-Sep-2001  thorpej machine/fbio.h -> dev/sun/fbio.h
 1.11 25-Aug-2001  mrg branches: 1.11.2;
update copyright notices.
 1.10 19-Jun-2001  fvdl branches: 1.10.2;
Some of this was sparc-specific, so ifdef __sparc__ it (XXX). Also,
change the alignment of one structure with an MD ifdef. Should
be moved into the netbsd32_machdep parts.
 1.9 14-Jun-2001  thorpej Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.8 05-Dec-2000  eeh branches: 1.8.2;
Fix uninitialized pointer bug.
 1.7 19-Aug-2000  eeh Fix netbsd32_ioctls.
 1.6 09-Jul-2000  mrg - massive warning fix fest.
- fix pread/pwrite return values (plus some other syscalls that looked
similarly broken).
- prototypes and clean up for netbsd32_ioctl.c

now getpw*() works under compat32!
 1.5 30-Dec-1999  eeh branches: 1.5.4;
Update to 32-bit compatibility routines.
 1.4 11-Oct-1999  eeh branches: 1.4.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.3 25-Mar-1999  mrg branches: 1.3.8;
SPARC32->NETBSD32
 1.2 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.4.1 26-Aug-2000  mrg pull up 1.7. approved by thorpej:
>Fix netbsd32_ioctls.
 1.8.2.8 11-Nov-2002  nathanw Catch up to -current
 1.8.2.7 23-Aug-2002  petrov lwpification.
 1.8.2.6 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.8.2.5 28-Feb-2002  nathanw Catch up to -current.
 1.8.2.4 11-Jan-2002  nathanw More catchup.
 1.8.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.8.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.11.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.20.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.20.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.8.1 29-Apr-2005  kent sync with -current
 1.23.4.6 24-Mar-2008  yamt sync with head.
 1.23.4.5 21-Jan-2008  yamt sync with head
 1.23.4.4 03-Sep-2007  yamt sync with head.
 1.23.4.3 26-Feb-2007  yamt sync with head.
 1.23.4.2 30-Dec-2006  yamt sync with head.
 1.23.4.1 21-Jun-2006  yamt sync with head.
 1.25.22.1 22-Oct-2006  yamt sync with head
 1.25.20.3 01-Feb-2007  ad Sync with head.
 1.25.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.25.20.1 18-Nov-2006  ad Sync with head.
 1.28.2.2 24-Mar-2007  yamt sync with head.
 1.28.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.30.6.2 29-Mar-2007  reinoud Pullup to -current
 1.30.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.30.4.1 11-Jul-2007  mjf Sync with head.
 1.30.2.3 20-Aug-2007  ad Sync with HEAD.
 1.30.2.2 09-Jun-2007  ad Sync with head.
 1.30.2.1 10-Apr-2007  ad Sync with head.
 1.34.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.34.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.34.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.35.10.1 26-Dec-2007  ad Sync with head.
 1.35.2.1 09-Jan-2008  matt sync with HEAD
 1.36.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.37.6.4 02-Jul-2008  mjf Sync with HEAD.
 1.37.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.37.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.37.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.38.6.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.38.6.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.38.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.38.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.38.4.5 09-Oct-2010  yamt sync with head
 1.38.4.4 11-Aug-2010  yamt sync with head.
 1.38.4.3 11-Mar-2010  yamt sync with head
 1.38.4.2 20-Jun-2009  yamt sync with head
 1.38.4.1 04-May-2009  yamt sync with head.
 1.38.2.1 04-Jun-2008  yamt sync with head
 1.39.2.2 03-Jul-2008  simonb Sync with head.
 1.39.2.1 27-Jun-2008  simonb Sync with head.
 1.41.12.1 23-Jul-2009  jym Sync with HEAD.
 1.41.10.2 02-Jul-2008  matt Change {ff,fd}_exclose and ff_allocated to bool. Change exclose arg to
fd_dup to bool. Switch assignments from 1/0 to true/false.

This make alpha kernels compile. Bump kern to 4.99.69 since structure
changed.
 1.41.10.1 02-Jul-2008  matt file netbsd32_ioctl.c was added on branch christos-time_t on 2008-07-02 16:45:21 +0000
 1.46.4.3 21-Apr-2011  rmind sync with head
 1.46.4.2 05-Mar-2011  rmind sync with head
 1.46.4.1 30-May-2010  rmind sync with head
 1.46.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.46.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.52.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.64.14.1 02-Aug-2015  martin Pull up following revision(s) (requested by maxv in ticket #1318):
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.82
Wrong logic. Here, userland can control the size and the data copied, which
basically means it can overflow kernel memory.
ok martin@ christos@
 1.64.12.1 02-Aug-2015  martin Pull up following revision(s) (requested by maxv in ticket #1318):
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.82
Wrong logic. Here, userland can control the size and the data copied, which
basically means it can overflow kernel memory.
ok martin@ christos@
 1.64.8.2 02-Aug-2015  martin Pull up following revision(s) (requested by maxv in ticket #1318):
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.82
Wrong logic. Here, userland can control the size and the data copied, which
basically means it can overflow kernel memory.
ok martin@ christos@
 1.64.8.1 18-Mar-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1022):
sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.44
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.68
Add ATAIOCCOMMAND ioctl form COMPAT_NETBSD32
This enables SMART monitoring by a netbsd32 binary.
 1.64.6.1 02-Jun-2012  mrg sync to latest -current.
 1.64.2.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.64.2.2 30-Oct-2012  yamt sync with head
 1.64.2.1 23-May-2012  yamt sync with head.
 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.69.6.6 05-Feb-2017  skrll Sync with HEAD
 1.69.6.5 05-Dec-2016  skrll Sync with HEAD
 1.69.6.4 05-Oct-2016  skrll Sync with HEAD
 1.69.6.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.69.6.2 22-Sep-2015  skrll Sync with HEAD
 1.69.6.1 06-Jun-2015  skrll Sync with HEAD
 1.69.4.1 02-Aug-2015  martin Pull up following revision(s) (requested by maxv in ticket #930):
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.82
Wrong logic. Here, userland can control the size and the data copied, which
basically means it can overflow kernel memory.
ok martin@ christos@
 1.84.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.84.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.89.8.3 13-Feb-2020  martin Pull up following revision(s) (requested by mlelstv in ticket #1504):

sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.108
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.109

Don't use strlcpy to copy untrusted input, it may not be NUL-terminated.

Where did the +1 came from ?
 1.89.8.2 22-Jul-2019  martin Pull up following revision(s) (requested by rin in ticket #1054):

sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.65
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.98
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.99

PR/53666: Rin Okuyama: tcpdump for i386 does not work with COMPAT_NETBSD32
on amd64. Add BIOCSRTIMEOUT32.

-

Correct misleading names of dummy variables. No binary changes intended.
 1.89.8.1 27-Nov-2017  martin Pull up following revision(s) (requested by jmcneill in ticket #396):
sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.57
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.90
Add support for SIOCGIFGENERIC and SIOCSIFGENERIC ioctls.
 1.91.2.6 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.91.2.5 20-Oct-2018  pgoyette Sync with head
 1.91.2.4 30-Sep-2018  pgoyette Ssync with HEAD
 1.91.2.3 25-Sep-2018  pgoyette Additional use of NTP function pointers, since the NTP code might not
exist in the kernel. (NTP is not (yet) a module, so we don't need to
use the MP-safe mechanism.)
 1.91.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.91.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.92.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.92.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.92.2.1 10-Jun-2019  christos Sync with HEAD
 1.103.2.3 20-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1921):

sys/kern/kern_event.c: revision 1.106
sys/kern/sys_select.c: revision 1.51
sys/kern/subr_exec_fd.c: revision 1.10
sys/kern/sys_aio.c: revision 1.46
sys/kern/kern_descrip.c: revision 1.244
sys/kern/kern_descrip.c: revision 1.245
sys/ddb/db_xxx.c: revision 1.72
sys/ddb/db_xxx.c: revision 1.73
sys/miscfs/fdesc/fdesc_vnops.c: revision 1.132
sys/kern/uipc_usrreq.c: revision 1.195
sys/kern/sys_descrip.c: revision 1.36
sys/kern/uipc_usrreq.c: revision 1.196
sys/kern/uipc_socket2.c: revision 1.135
sys/kern/uipc_socket2.c: revision 1.136
sys/kern/kern_sig.c: revision 1.383
sys/kern/kern_sig.c: revision 1.384
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.107
sys/miscfs/procfs/procfs_vnops.c: revision 1.208
sys/kern/subr_exec_fd.c: revision 1.9
sys/kern/kern_descrip.c: revision 1.252
(all via patch)

Load struct filedesc::fd_dt with atomic_load_consume.

Exceptions: when fd_refcnt <= 1, or when holding fd_lock.

While here:
- Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused.
=> This is used only in fd_close and fd_abort, where it holds.
- Move bounds check assertion in fd_putfile to where it matters.
- Store fd_dt with atomic_store_release.
- Move load of fd_dt under lock in knote_fdclose.
- Omit membar_consumer in fdesc_readdir.
=> atomic_load_consume serves the same purpose now.
=> Was needed only on alpha anyway.

Load struct fdfile::ff_file with atomic_load_consume.
Exceptions: when we're only testing whether it's there, not about to
dereference it.

Note: We do not use atomic_store_release to set it because the
preceding mutex_exit should be enough.

(That said, it's not clear the mutex_enter/exit is needed unless
refcnt > 0 already, in which case maybe it would be a win to switch
from the membar implied by mutex_enter to the membar implied by
atomic_store_release -- which I would generally expect to be much
cheaper. And a little clearer without a long comment.)
kern_descrip.c: Fix membars around reference count decrement.

In general, the `last one out hit the lights' style of reference
counting (as opposed to the `whoever's destroying must wait for
pending users to finish' style) requires memory barriers like so:

... usage of resources associated with object ...
membar_release();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_acquire();
... freeing of resources associated with object ...

This way, all usage happens-before all freeing. This fixes several
errors:
- fd_close failed to ensure whatever its caller did would
happen-before the freeing, in the case where another thread is
concurrently trying to close the fd (ff->ff_file == NULL).
Fix: Add membar_release before atomic_dec_uint(&ff->ff_refcnt) in
that branch.
- fd_close failed to ensure all loads its caller had issued will have
happened-before the freeing, in the case where the fd is still in
use by another thread (fdp->fd_refcnt > 1 and ff->ff_refcnt-- > 0).
Fix: Change membar_producer to membar_release before
atomic_dec_uint(&ff->ff_refcnt).
- fd_close failed to ensure that any usage of fp by other callers
would happen-before any freeing it does.
Fix: Add membar_acquire after atomic_dec_uint_nv(&ff->ff_refcnt).
- fd_free failed to ensure that any usage of fdp by other callers
would happen-before any freeing it does.
Fix: Add membar_acquire after atomic_dec_uint_nv(&fdp->fd_refcnt).

While here, change membar_exit -> membar_release. No semantic
change, just updating away from the legacy API.
 1.103.2.2 18-Nov-2024  martin Pull up following revision(s) (requested by 1922):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.

Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices

netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:

PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.103.2.1 13-Feb-2020  martin Pull up following revision(s) (requested by mlelstv in ticket #706):

sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.108
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.109

Don't use strlcpy to copy untrusted input, it may not be NUL-terminated.

Where did the +1 came from ?
 1.106.2.1 29-Feb-2020  ad Sync with head.
 1.114.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.118.2.1 17-Apr-2021  thorpej Sync with HEAD.
 1.120.4.2 17-Nov-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1007):

tests/kernel/Makefile: revision 1.83
sys/sys/filedesc.h: revision 1.71
distrib/sets/lists/tests/mi: revision 1.1346
tests/kernel/h_cloexec.c: revision 1.1
tests/kernel/t_cloexec.c: revision 1.1
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.122
distrib/sets/lists/debug/mi: revision 1.454

tests/kernel/t_cloexec: New tests for close-on-exec.
Verified that the following tests fail on a netbsd-10 kernel:
- clonedev_posixspawn
- dup3_posixspawn
- fcntldupfd_posixspawn
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


sys/filedesc.h: Add a note about writing to ff_exclose.
No functional change intended -- just a reminder to avoid repeating a
class of bugs we've had.
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices


netbsd32_ioctl: Use fd_set_exclose instead of open-coding it.
No functional change intended -- this just reduces unnecessary
copies of open-coded logic which, when copied incompletely, led to:
PR kern/58822: close-on-exec is broken for dup3 and opening cloning
devices
 1.120.4.1 26-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #988):

sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.80
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.121

PR 58235: add support for SIOCGIFDATA and SIOCZIFDATA ioctls.
 1.121.2.1 02-Aug-2025  perseant Sync with HEAD
 1.80 11-May-2024  martin PR 58235: add support for SIOCGIFDATA and SIOCZIFDATA ioctls.
 1.79 22-Dec-2021  roy branches: 1.79.4;
Handle the SIOCGNBRINFO ioctl for compat32.
arp -a works with compat32 now.

Credit to simonb@ for the ndp fix from which this is cribbed.
 1.78 14-Apr-2021  mlelstv Add DIOCGDISKINFO compat.
 1.77 17-Jan-2021  simonb branches: 1.77.2;
Handle the SIOCGNBRINFO_IN6 ioctl for compat32. ndp -a works with
compat32 now.
 1.76 14-Jan-2021  simonb Handle the KFILTER_BYFILTER and KFILTER_BYNAME ioctls for compat32.
Passes "atf kernel/kqueue/t_ioctl".
 1.75 14-Jan-2021  simonb Handle FSSIOCSET and FSSIOCGET; vndconfig(8) works with compat32 now.
XXX: FSSIOCSET50 and FSSIOCGET50 are not (yet) handled.
 1.74 14-Jan-2021  simonb Use netbsd32_* types instead of relying on __packed in the vnd ioctl
structures. __packed didn't work on archs where 64-bit types were
64-bit aligned with a 32-bit ABI (eg MIPS n32).

OK mrg@
 1.73 07-Sep-2020  mrg branches: 1.73.2;
remove __packed from struct netbsd32_lsdisable. the structure
is already properly aligned (the embedded int64 already has
align(4) marker applied where needed.)

same size structure generated.
 1.72 21-Jul-2020  simonb Add lockstat(1) ioctl handling.

mrg@: "looks ok."
 1.71 18-Jul-2020  jmcneill Add BIOCSETWF32 (bpf)
 1.70 18-Nov-2019  rin Sorry, revert unintentional parts of the previous commit:
http://mail-index.netbsd.org/source-changes/2019/11/18/msg110946.html

I was going to commit only netbsd32_signal.c.
 1.69 18-Nov-2019  rin Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
 1.68 20-Aug-2019  christos compat32 drm ioctl support from Surya Shankar at GSoC 2019
 1.67 17-May-2019  msaitoh The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
- We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
- FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
- FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
macro for matching both TYPE and SUBTYPE.
- Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

* if_media Options word:
* Bits Use
* ---- -------
* 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others
* 5-7 Media type
* 8-15 Type specific options
* 16-18 Mode (for multi-mode devices)
* 19 (Reserved for Future Use)
* 20-27 Shared (global) options
* 28-31 Instance
*
* 3 2 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-------+---------------+-+-----+---------------+-----+---------+
* | | |R| | | | |
* | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK |
* | | |U| |XTMSK| | | |
* +-------+---------------+-+-----+-----+---------+-----+---------+
* <-----> <---> <--->
* IFM_INST() IFM_MODE() IFM_TYPE()
*
* IFM_SUBTYPE(other than ETH)<------->
*
* <---> IFM_SUBTYPE(ETH)<------->
*
*
* <-------------> <------------->
* IFM_OPTIONS()
 1.66 25-Nov-2018  mlelstv Restore netbsd32 compat code for new NPF ABI.
 1.65 11-Oct-2018  christos PR/53666: Rin Okuyama: tcpdump for i386 does not work with COMPAT_NETBSD32
on amd64. Add BIOCSRTIMEOUT32.
 1.64 29-Sep-2018  rmind NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
previous versions. Also, different serialisation format means NPF
connection/config saving and loading is not compatible with the
previous versions either.

Thanks to christos@ for extra testing.
 1.63 24-Sep-2018  jdolecek fix DIOCLWEDGES to at least not fail with ENOTTY due to struct size difference,
but probably more needs to be done to work if any actual wedges are configured
 1.62 24-Sep-2018  jdolecek add support for DIOCGSTRATEGY and DIOCSSTRATEGY
 1.61 06-Sep-2018  maxv Remove the network ATM code.
 1.60 02-Sep-2018  maxv remove dead references to IPF; also remove references to netccitt/, it was
removed 12 years ago.
 1.59 06-Mar-2018  mlelstv branches: 1.59.2;
Add DIOCLWEDGES
 1.58 19-Jan-2018  macallan branches: 1.58.2;
add conversion goop for WSDISPLAYIO_LDFONT and _SFONT
tested on mips64
 1.57 26-Nov-2017  jmcneill Add support for SIOCGIFGENERIC and SIOCSIFGENERIC ioctls.
 1.56 26-Dec-2016  christos branches: 1.56.8;
Sync NPF with the version on github: backport standalone NPF changes,
which allow us to create and run separate NPF instances. Minor fixes.
(from rmind@)
 1.55 12-Nov-2016  mlelstv Fix netbsd32 emulation for clockctl_ntp_adjtime.

The ioctl args reference a timex structure that needs to be
transformed to 64bit layout and back.

The 32bit ioctl definition was wrong for mips, as register_t is 64bit
for N32 abi.
 1.54 13-Jul-2016  jmcneill branches: 1.54.2;
Add netbsd32 support for drvctl(4)
 1.53 08-Dec-2015  christos Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
 1.52 01-Jun-2015  roy Add support for NPF ioctls.
 1.51 31-May-2015  roy Add support for PPPOEGETPARMS and PPPOESETPARMS.
 1.50 31-May-2015  roy Support SPPPGETAUTHCFG and SPPPSETAUTHCFG.
 1.49 27-May-2015  matt Add missing SIOCGDRVSPEC32
Fix SIOCGETSGCNT32
 1.48 20-May-2015  matt Use Elf_Sym
 1.47 20-May-2015  matt Only define the KIOC netbsd32 stuff if the KIOC ioctls have been defined.
 1.46 20-May-2015  matt Change the ksyms ioctls to more compat_netbsd32 friendly. Use _IOWR ioctls
to avoid extra copyouts. With these changes, netstat and vmstat work on
mips64eb with the normal N32 userland and a N64 kernel.
 1.45 18-May-2015  martin Implement SIOCIFGCLONERS for netbsd32, so ifconfig -C works.
 1.44 24-Jan-2014  manu branches: 1.44.6;
Add ATAIOCCOMMAND ioctl form COMPAT_NETBSD32

This enables SMART monitoring by a netbsd32 binary.
 1.43 28-May-2012  christos branches: 1.43.2; 1.43.4;
compat for 80211 ioctls from jmcneill
 1.42 11-May-2012  christos provide clockctl ioctl emulation
 1.41 28-Sep-2011  macallan branches: 1.41.2; 1.41.6; 1.41.8;
support WSDISPLAYIO_GCURSOR and WSDISPLAYIO_SCURSOR
 1.40 07-Sep-2011  macallan support ioctl(POWER_EVENT_RECVDICT) - now powerd turns my gdium's backlight
off when the lid is closed
 1.39 30-Aug-2011  bouyer Provide netbsd32 compat for bpf. Beside the ioctls, the structure
returned to userland by read(2) also needs to be converted.
For this, the bpf descriptor is flagged as compat32 (or not) in the
open and ioctl functions (where the user process's pid is also updated
in the descriptor). When the bpf buffer is filled in, the 32bits or native
header is used depending on the information stored in the descriptor.

This won't work if a 64bit binary does the open and ioctls, and then
exec a 32bit program which will do the read. But this is very
unlikely to happen in real life ...

Tested on i386 and loongson; with these changes my loongson can run
dhclient and tcpdump with a n32 userland.
 1.38 30-Aug-2011  macallan support SIOCG80211NWKEY
 1.37 30-Aug-2011  macallan add WSDISPLAYIO_ADDSCREEN
 1.36 27-Aug-2011  bouyer translate WDOGIOC_GWDOGS
 1.35 04-Apr-2011  ahoka remove FLASH_GET_INFO compat as it is no longer using size_t
 1.34 04-Apr-2011  ahoka flash_addr_t -> flash_off_t
 1.33 19-Mar-2011  cliff include flashio.h
 1.32 19-Mar-2011  cliff compat/netbsd32 ioctl support for FLASH_GET_INFO
 1.31 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.30 01-Feb-2011  matt Define 32bit version of SIOC[GS]IFADDRPREF32. We wouldn't need this to
if i386 actually aligned a uint64_t on a 64bit boundary but it doesn't.
So all that work in sockaddr_storage goes for naught.
 1.29 24-Sep-2010  njoly branches: 1.29.2; 1.29.4;
Add support for envsys(4) version 2 ioctls.
 1.28 19-Sep-2010  mrg add (runtime untested) support for AUDIO_WSEEK.
 1.27 19-Sep-2010  mrg add support for the netbsd 5.0 versions of the VND* ioctls.
 1.26 19-Sep-2010  mrg support VND* ioctls.
 1.25 09-Dec-2009  christos branches: 1.25.2; 1.25.4;
Add netbsd32_oifreq and fix issue in copying the interface name. With this
patch OSIOC{G,S}IFFLAGS is supposed to work, but unfortunately getifaddrs
seems to be the next problem getting the 4.99.x i386 ifconfig working on an
amd64 current machine.
 1.24 23-Jun-2008  njoly branches: 1.24.10;
Update compat netbsd32 SIOCGIFCONF ioctls definitions to follow native
ones.
 1.23 22-Jun-2008  njoly netbsd32_ifreq_tp_t should be of type netbsd32_pointer_t, not int32_t.
 1.22 29-May-2008  mrg branches: 1.22.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.21 21-Mar-2008  ad branches: 1.21.2; 1.21.4; 1.21.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.20 16-Mar-2007  dsl branches: 1.20.30;
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.19 04-Mar-2007  christos branches: 1.19.2; 1.19.4; 1.19.6;
fix fallout from caddr_t changes.
 1.18 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 11-Dec-2005  christos branches: 1.17.26;
merge ktrace-lwp.
 1.16 26-Feb-2005  perry branches: 1.16.4;
nuke trailing whitespace
 1.15 15-Jan-2004  mrg branches: 1.15.8; 1.15.10;
begin to implement some ifreq ioctls... long long way to go.
 1.14 29-Jun-2003  fvdl branches: 1.14.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.13 29-Jun-2003  martin struct proc * -> struct lwp *
 1.12 12-Apr-2003  christos get rid of the ASYNCMAP ioctls
 1.11 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.10 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.9 03-Jan-2002  mrg fix error in previous; pointed out by andrew brown.
 1.8 03-Jan-2002  mrg clean up
 1.7 03-Jan-2002  mrg move sparc specific ioctl handling (fb & openprom) into arch/sparc64.
 1.6 25-Aug-2001  mrg update copyright notices.
 1.5 19-Jun-2001  fvdl branches: 1.5.2;
Some of this was sparc-specific, so ifdef __sparc__ it (XXX). Also,
change the alignment of one structure with an MD ifdef. Should
be moved into the netbsd32_machdep parts.
 1.4 19-Aug-2000  eeh branches: 1.4.2;
Fix netbsd32_ioctls.
 1.3 25-Mar-1999  mrg branches: 1.3.8; 1.3.18;
move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.2 24-Nov-1998  mrg add some missing comment ends.
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.3.18.1 26-Aug-2000  mrg pull up 1.4. approved by thorpej:
>Fix netbsd32_ioctls.
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.4.2.5 11-Nov-2002  nathanw Catch up to -current
 1.4.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.3 11-Jan-2002  nathanw More catchup.
 1.4.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.14.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.16.4.3 24-Mar-2008  yamt sync with head.
 1.16.4.2 03-Sep-2007  yamt sync with head.
 1.16.4.1 21-Jun-2006  yamt sync with head.
 1.17.26.2 24-Mar-2007  yamt sync with head.
 1.17.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.19.4.1 11-Jul-2007  mjf Sync with head.
 1.19.2.1 10-Apr-2007  ad Sync with head.
 1.20.30.3 29-Jun-2008  mjf Sync with HEAD.
 1.20.30.2 02-Jun-2008  mjf Sync with HEAD.
 1.20.30.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.21.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.21.4.3 09-Oct-2010  yamt sync with head
 1.21.4.2 11-Mar-2010  yamt sync with head
 1.21.4.1 04-May-2009  yamt sync with head.
 1.21.2.1 04-Jun-2008  yamt sync with head
 1.22.2.1 27-Jun-2008  simonb Sync with head.
 1.24.10.2 23-Jun-2008  njoly Update compat netbsd32 SIOCGIFCONF ioctls definitions to follow native
ones.
 1.24.10.1 23-Jun-2008  njoly file netbsd32_ioctl.h was added on branch christos-time_t on 2008-06-23 23:14:43 +0000
 1.25.4.2 21-Apr-2011  rmind sync with head
 1.25.4.1 05-Mar-2011  rmind sync with head
 1.25.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.29.4.2 15-Feb-2011  bouyer implement COMPAT_NETBSD32 quotactl syscalls (both new and COMPAT_50)
 1.29.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.29.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.41.8.1 18-Mar-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1022):
sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.44
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.68
Add ATAIOCCOMMAND ioctl form COMPAT_NETBSD32
This enables SMART monitoring by a netbsd32 binary.
 1.41.6.1 02-Jun-2012  mrg sync to latest -current.
 1.41.2.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.41.2.2 30-Oct-2012  yamt sync with head
 1.41.2.1 23-May-2012  yamt sync with head.
 1.43.4.1 18-May-2014  rmind sync with head
 1.43.2.2 03-Dec-2017  jdolecek update from HEAD
 1.43.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.44.6.5 05-Feb-2017  skrll Sync with HEAD
 1.44.6.4 05-Dec-2016  skrll Sync with HEAD
 1.44.6.3 05-Oct-2016  skrll Sync with HEAD
 1.44.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.44.6.1 06-Jun-2015  skrll Sync with HEAD
 1.54.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.56.8.2 22-Jul-2019  martin Pull up following revision(s) (requested by rin in ticket #1054):

sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.65
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.98
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.99

PR/53666: Rin Okuyama: tcpdump for i386 does not work with COMPAT_NETBSD32
on amd64. Add BIOCSRTIMEOUT32.

-

Correct misleading names of dummy variables. No binary changes intended.
 1.56.8.1 27-Nov-2017  martin Pull up following revision(s) (requested by jmcneill in ticket #396):
sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.57
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.90
Add support for SIOCGIFGENERIC and SIOCSIFGENERIC ioctls.
 1.58.2.5 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.58.2.4 20-Oct-2018  pgoyette Sync with head
 1.58.2.3 30-Sep-2018  pgoyette Ssync with HEAD
 1.58.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.58.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.59.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.59.2.1 10-Jun-2019  christos Sync with HEAD
 1.73.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.77.2.1 17-Apr-2021  thorpej Sync with HEAD.
 1.79.4.1 26-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #988):

sys/compat/netbsd32/netbsd32_ioctl.h: revision 1.80
sys/compat/netbsd32/netbsd32_ioctl.c: revision 1.121

PR 58235: add support for SIOCGIFDATA and SIOCZIFDATA ioctls.
 1.23 23-May-2025  hannken Fix typos in SEM_PRINTF(): usemid->semid, usops->sops, use NETBSD32PTR64().

Kernels ALL/i386 and ALL/amd64 build again.
 1.22 10-May-2025  riastradh netbsd32_ipc.c: KNF
 1.21 09-May-2025  martin Change semop(2) compat code to use the common code (instead of the syscall
code directly).
Implement semtimedop(2) for compat_netbsd32.
Fixes PR 59352.
 1.20 19-Jan-2021  simonb branches: 1.20.24;
KNF consistency: No parentheses are needed around the return value.
 1.19 27-Jan-2019  pgoyette branches: 1.19.12;
Merge the [pgoyette-compat] branch
 1.18 03-Dec-2015  pgoyette branches: 1.18.16; 1.18.18;
Split out the SYSV IPC stuff into its own compat_netbsd32_sysvipc
module. Adjust dependencies as needed.
 1.17 12-Dec-2009  njoly branches: 1.17.22; 1.17.40;
Add missing semicolons after NETBSD32TOx_UAP macro calls.
 1.16 11-Jan-2009  christos merge christos-time_t
 1.15 29-May-2008  mrg branches: 1.15.6; 1.15.12;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.14 20-Dec-2007  dsl branches: 1.14.6; 1.14.8; 1.14.10; 1.14.12;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.13 08-Dec-2007  dsl branches: 1.13.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.12 03-Jun-2007  dsl branches: 1.12.6; 1.12.8; 1.12.16;
Split netbsd32___semctl14() so that it is callable from
compat_10_netbsd32_sys_semsys() (where the one parameter is already in
kernel space).
Note that the code in compat_10_netbsd32_sys_semsys() has always been wrong,
since it called compat_14_sys___semctl() - which would read 64bit values!
 1.11 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.10 09-Feb-2007  ad branches: 1.10.2; 1.10.6; 1.10.8; 1.10.10;
Merge newlock2 to head.
 1.9 23-Jul-2006  ad branches: 1.9.4;
Use the LWP cached credentials where sane.
 1.8 06-Mar-2006  cube Implement the SysV IPC family of syscalls.
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.6; 1.7.8;
merge ktrace-lwp.
 1.6 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.5 18-Jan-2003  thorpej branches: 1.5.2; 1.5.18;
Merge the nathanw_sa branch.
 1.4 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.3 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.2 30-May-2001  mrg branches: 1.2.2;
use _KERNEL_OPT.
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.5 11-Nov-2002  nathanw Catch up to -current
 1.1.4.4 23-Aug-2002  petrov lwpification.
 1.1.4.3 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_ipc.c was added on branch thorpej_scsipi on 2001-02-11 19:14:14 +0000
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.18.5 21-Jan-2008  yamt sync with head
 1.5.18.4 03-Sep-2007  yamt sync with head.
 1.5.18.3 26-Feb-2007  yamt sync with head.
 1.5.18.2 30-Dec-2006  yamt sync with head.
 1.5.18.1 21-Jun-2006  yamt sync with head.
 1.5.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.8.2 11-Aug-2006  yamt sync with head
 1.7.8.1 13-Mar-2006  yamt sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.9.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.10.10.1 29-Mar-2007  reinoud Pullup to -current
 1.10.8.1 11-Jul-2007  mjf Sync with head.
 1.10.6.2 09-Jun-2007  ad Sync with head.
 1.10.6.1 10-Apr-2007  ad Sync with head.
 1.10.2.1 24-Mar-2007  yamt sync with head.
 1.12.16.1 26-Dec-2007  ad Sync with head.
 1.12.8.1 09-Jan-2008  matt sync with HEAD
 1.12.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.13.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.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.14.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.14.10.2 11-Mar-2010  yamt sync with head
 1.14.10.1 04-May-2009  yamt sync with head.
 1.14.8.1 04-Jun-2008  yamt sync with head
 1.14.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.14.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.12.2 04-Jan-2009  christos add new syscalls.
 1.15.12.1 29-May-2008  christos file netbsd32_ipc.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.15.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.40.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.22.1 03-Dec-2017  jdolecek update from HEAD
 1.18.18.1 10-Jun-2019  christos Sync with HEAD
 1.18.16.6 13-Sep-2018  pgoyette More clean-up of module dependencies
 1.18.16.5 12-Sep-2018  pgoyette Use correct module name for dependency
 1.18.16.4 12-Sep-2018  pgoyette Split compat_netbsd32_sysvipc into version-specific modules
 1.18.16.3 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.18.16.2 13-Mar-2018  pgoyette Use correct module name for dependency
 1.18.16.1 10-Mar-2018  pgoyette Update module dependency - it now requires compat_sysvipc
 1.19.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.20.24.1 02-Aug-2025  perseant Sync with HEAD
 1.6 05-Sep-2020  riastradh Round of uvm.h cleanup.

The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
to query whether curlwp is the pagedaemon, which should maybe be
exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
by it. We should split up uvm_extern.h but this will serve for now
to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
UVMHIST(ubchist), since ubchist is declared in uvm.h but the
reference evaporates if UVMHIST is not defined, so we reduce header
file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
here.

ok chs@
 1.5 12-Dec-2019  pgoyette Rather than keeping a separate mutex, condvar, and pserialize for each
module hook, we can share a common set of synchronization structures.
This cuts the amount of cacheline_aligned data for these structures by
50%.

Note that we still have a per-hook localcount, since we need to count
individual references.

As discussed with riastradh@

Welcome to 9.99.22 !
 1.4 01-Mar-2019  pgoyette branches: 1.4.4;
Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.3 29-Jan-2019  pgoyette Normalize all the compat hooks' names to the form

<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
 1.2 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.1 23-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_kern_proc.c was initially added on branch pgoyette-compat.
 1.1.2.8 23-Jan-2019  pgoyette Convert the macros for setting and unsetting a hook to generate
in-line code rather than using an intermediary hook##set routine.
Hooks are set and unset only in one place, so the intermediary
routine provides no benefit. IMHO using the macro at the point-
of-call is more readable than using it elsewhere in the code and
then calling the generated intermediary routine (for which you
won't even find its declaration or definition unless you remember
to search for the HOOK_SET macro instead).

NFC intended, will verify with a bulk build and an atf test run.
 1.1.2.7 22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.1.2.6 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.1.2.5 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.1.2.4 23-Sep-2018  pgoyette Use a .h file to define the xxx_{init,fini} routines, and include
the compat_stub.h header to get the definition of the kern_proc_32
hook.
 1.1.2.3 23-Sep-2018  pgoyette Use the proper test: _RUMPKERNEL vs _RUMP_KERNEL
 1.1.2.2 23-Sep-2018  pgoyette This hook doesn't exist for _RUMPSERVER
 1.1.2.1 23-Sep-2018  pgoyette More work on kern_proc_32
 1.4.4.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.4.2 10-Jun-2019  christos Sync with HEAD
 1.4.4.1 01-Mar-2019  christos file netbsd32_kern_proc.c was added on branch phil-wifi on 2019-06-10 22:07:02 +0000
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 23-Sep-2018  pgoyette branches: 1.1.2;
file netbsd32_kern_proc.h was initially added on branch pgoyette-compat.
 1.1.2.1 23-Sep-2018  pgoyette More work on kern_proc_32
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file netbsd32_kern_proc.h was added on branch phil-wifi on 2019-06-10 22:07:02 +0000
 1.3 08-Dec-2001  thorpej Make the coredump routine exec-format/emulation specific. Split
out traditional NetBSD coredump routines into core_netbsd.c and
netbsd32_core.c (for COMPAT_NETBSD32).
 1.2 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.1 06-Jun-2001  mrg branches: 1.1.2; 1.1.4;
LKM friendly: move coredump32() here
 1.1.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.1 06-Jun-2001  nathanw file netbsd32_kern_sig.c was added on branch nathanw_sa on 2001-06-21 20:00:04 +0000
 1.2 16-Jan-2004  mrg clean up a little:
- delete ktrsyscall32()
- add a check #ifdef _LP64 to do the conversion if P_32 is set to the
standard ktrsyscall()
- add a couple of similar _LP64/P_32 checks to the systrace code.

this should get systrace working for 32 bit apps as well as complete
ktrace support for "trace_enter/trace_exit" using platforms such as amd64.

XXX: systrace isn't supported on sparc64 currently... (it doesn't use
trace_enter/trace_exit, or have it's own calls to systrace_xxx()...)
 1.1 15-Jan-2004  mrg add a copy of the ktrsyscall() entry point for 32 bit emulated calls.
the main purpose of this function is to adjust the "argsize" value of
the ktrace syscall record, otherwise userland will see N/2 (rounded
down) arguments instead of N.
 1.23 14-Jan-2021  simonb Handle rev 1.62 of kern/sys_lwp.c
make _lwp_park return the remaining time to sleep in the "ts" argument
if it is a relative timestamp, as discussed in tech-kern.
for compat32. Thanks skrll@ for some cleanup tips.
 1.22 29-Jan-2020  ad branches: 1.22.6;
- Track LWPs in a per-process radixtree. It uses no extra memory in the
single threaded case. Replace scans of p->p_lwps with lookups in the
tree. Find free LIDs for new LWPs in the tree. Replace the hashed sleep
queues for park/unpark with lookups in the tree under cover of a RW lock.

- lwp_wait(): if waiting on a specific LWP, find the LWP via tree lookup and
return EINVAL if it's detached, not ESRCH.

- Group the locks in struct proc at the end of the struct in their own cache
line.

- Add some comments.
 1.21 26-Jan-2020  ad Correction to previous: don't leak newuc if copyout() fails.
 1.20 25-Jan-2020  ad - Fix a race between the kernel and libpthread, where a new thread can start
life without its self->pt_lid being filled in.

- Fix an error path in _lwp_create(). If the new LID can't be copied out,
then get rid of the new LWP (i.e. either succeed or fail, not both).

- Mark l_dopreempt and l_nopreempt volatile in struct lwp.
 1.19 21-Apr-2017  christos branches: 1.19.12; 1.19.18;
- Propagate the signal mask from the ucontext_t to the newly created thread
as specified by _lwp_create(2)
- Reset the signal stack for threads created with _lwp_create(2)
 1.18 15-May-2015  matt branches: 1.18.2; 1.18.4;
Simplify a tiny bit.
 1.17 15-May-2015  matt In lwp_ctl, convert ptr to 32 bits before copyout.
 1.16 15-May-2015  matt Fix _lwp_ctl for big endian 64-bit platforms. (little-endian too but not
as noticable).
 1.15 29-Mar-2013  christos branches: 1.15.10; 1.15.12;
compat glue for new lwp_park
 1.14 20-Jul-2012  christos branches: 1.14.2;
always allocate a full ucontext structure so that we don't corrupt memory.
XXX: needs pullup to 6?
 1.13 21-May-2012  martin Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.

To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.

Add an exhaustive atf test case, based partly on code from Joel Sing.

Should finally fix the remaining open part of PR kern/43903.
 1.12 05-Feb-2011  yamt branches: 1.12.4; 1.12.8; 1.12.10;
netbsd32__lwp_create: add a comment and CTASSERT.
 1.11 11-Jan-2009  christos branches: 1.11.6; 1.11.8; 1.11.10;
merge christos-time_t
 1.10 29-Apr-2008  martin branches: 1.10.8; 1.10.14;
Convert to new 2 clause license
 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 07-Dec-2007  ad branches: 1.8.4;
Add: _lwp_setname, _lwp_getname, _lwp_ctl.
 1.7 10-Sep-2007  cube branches: 1.7.6; 1.7.8;
Some more licence clean up.
 1.6 07-Aug-2007  ad branches: 1.6.2;
- Fix a bug with _lwp_park() where if the computed wakeup time was under
1 microsecond into the future, the thread could enter an untimed sleep.
- Change the signature of _lwp_park() to accept an lwpid_t and second
hint pointer, but do so in a way that remains compatible with older
pthread libraries. This can be used to wake another thread before the
calling thread goes asleep, saving at least one syscall + involuntary
context switch. This turns out to be a fairly large win on the condvar
benchmarks that I have tried.
- Mark some more syscalls MP safe.
 1.5 03-Jun-2007  dsl branches: 1.5.2; 1.5.6;
Split sys__lwp_park() so that the compat/netbsd32 code can copyin and convert
its timeout then call the standard function.
 1.4 18-Mar-2007  dsl 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 04-Mar-2007  christos branches: 1.2.2; 1.2.4; 1.2.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.1 18-Feb-2007  cube branches: 1.1.2; 1.1.6;
Add missing lwp syscalls. Put them all together into a new file,
netbsd32_lwp.c, and remove remaining traces of SA.

This still needs some MD (and possibly MI, depending on the chosen
solution) changes to actually work.
 1.1.6.4 24-Mar-2007  yamt sync with head.
 1.1.6.3 12-Mar-2007  rmind Sync with HEAD.
 1.1.6.2 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.1.6.1 18-Feb-2007  yamt file netbsd32_lwp.c was added on branch yamt-idlelwp on 2007-02-27 16:53:38 +0000
 1.1.2.5 21-Jan-2008  yamt sync with head
 1.1.2.4 27-Oct-2007  yamt sync with head.
 1.1.2.3 03-Sep-2007  yamt sync with head.
 1.1.2.2 26-Feb-2007  yamt sync with head.
 1.1.2.1 18-Feb-2007  yamt file netbsd32_lwp.c was added on branch yamt-lazymbuf on 2007-02-26 09:09:31 +0000
 1.2.6.3 09-Dec-2007  reinoud Pullup to HEAD
 1.2.6.2 29-Mar-2007  reinoud Pullup to -current
 1.2.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.2.4.1 11-Jul-2007  mjf Sync with head.
 1.2.2.4 09-Oct-2007  ad Sync with head.
 1.2.2.3 20-Aug-2007  ad Sync with HEAD.
 1.2.2.2 09-Jun-2007  ad Sync with head.
 1.2.2.1 10-Apr-2007  ad Sync with head.
 1.5.6.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.5.6.2 02-Oct-2007  joerg Sync with HEAD.
 1.5.6.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.5.2.1 15-Aug-2007  skrll Sync with HEAD.
 1.6.2.2 09-Jan-2008  matt sync with HEAD
 1.6.2.1 06-Nov-2007  matt sync with HEAD
 1.7.8.2 26-Dec-2007  ad Sync with head.
 1.7.8.1 08-Dec-2007  ad Sync with head.
 1.7.6.2 27-Dec-2007  mjf Sync with HEAD.
 1.7.6.1 08-Dec-2007  mjf Sync with HEAD.
 1.8.4.1 02-Jan-2008  bouyer 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.1 18-May-2008  yamt sync with head.
 1.9.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.9.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.14.2 04-Jan-2009  christos add new syscalls.
 1.10.14.1 29-Apr-2008  christos file netbsd32_lwp.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.10.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.10.1 08-Feb-2011  bouyer Sync with HEAD
 1.11.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.6.1 05-Mar-2011  rmind sync with head
 1.12.10.2 21-Jul-2012  riz Pull up following revision(s) (requested by christos in ticket #431):
sys/compat/netbsd32/netbsd32_lwp.c: revision 1.14
always allocate a full ucontext structure so that we don't corrupt memory.
XXX: needs pullup to 6?
 1.12.10.1 21-May-2012  riz Pull up following revision(s) (requested by martin in ticket #274):
sys/arch/amd64/amd64/process_machdep.c: revision 1.20
sys/kern/sys_lwp.c: revision 1.54
sys/arch/sparc64/sparc64/machdep.c: revision 1.267
sys/arch/mips/mips/cpu_subr.c: revision 1.16
sys/arch/vax/vax/machdep.c: revision 1.188
sys/sys/lwp.h: revision 1.161
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.98
sys/arch/alpha/alpha/machdep.c: revision 1.339
sys/compat/sys/ucontext.h: revision 1.6
sys/arch/hppa/hppa/hppa_machdep.c: revision 1.28
distrib/sets/lists/tests/mi: revision 1.469
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.42
tests/lib/libc/sys/t_lwp_create.c: revision 1.1
tests/lib/libc/sys/Makefile: revision 1.23
sys/arch/arm/arm/sig_machdep.c: revision 1.42
sys/arch/amd64/include/mcontext.h: revision 1.15
sys/arch/amd64/amd64/machdep.c: revision 1.183
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.99
sys/arch/i386/i386/machdep.c: revision 1.727
sys/compat/netbsd32/netbsd32_lwp.c: revision 1.13
sys/arch/sparc/sparc/machdep.c: revision 1.319
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.76
sys/arch/m68k/m68k/sig_machdep.c: revision 1.49
sys/sys/ucontext.h: revision 1.16
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.9
lib/libc/sys/_lwp_create.2: revision 1.5
Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.
To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.
Add an exhaustive atf test case, based partly on code from Joel Sing.
Should finally fix the remaining open part of PR kern/43903.
 1.12.8.1 02-Jun-2012  mrg sync to latest -current.
 1.12.4.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.12.4.2 30-Oct-2012  yamt sync with head
 1.12.4.1 23-May-2012  yamt sync with head.
 1.14.2.2 03-Dec-2017  jdolecek update from HEAD
 1.14.2.1 23-Jun-2013  tls resync from head
 1.15.12.2 28-Aug-2017  skrll Sync with HEAD
 1.15.12.1 06-Jun-2015  skrll Sync with HEAD
 1.15.10.1 16-May-2015  martin Pull up the following revisions, requested by matt in ticket #776:

src/sys/compat/netbsd32/netbsd32_lwp.c 1.15-1.18

Fix _lwp_ctl for big endian 64-bit platforms. (Little-endian too but not
as noticable).
 1.18.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.18.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.19.18.2 29-Feb-2020  ad Sync with head.
 1.19.18.1 25-Jan-2020  ad Sync with head.
 1.19.12.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.22.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.23 08-Aug-2020  christos PR/55547: Dan Plassche: Fix BSD/OS binary emulation.
Centralize lcall sniffer and recognize the BSD/OS flavor.
 1.22 21-Mar-2020  pgoyette Restore code to sysctl_free() the compat32 shadow tree
 1.21 15-Mar-2020  pgoyette Use SYSCTL_SETUP mechanism to establish our sysctl tree, rather than
using explicit calls to netbsd32_sysctl_{init,fini}()
 1.20 09-Mar-2020  pgoyette Rework previous, so that the real syscall code is not invoked from within
the module_hook code. Otherwise, if the syscall just happens to be exit()
we will exit while still holding a reference to the hook's localcount, and
nothing will ever release that reference. Attempts to manually unload the
module will hang indefinitely, as will modstat(8).

XXX pullup-9
 1.19 09-Mar-2020  pgoyette If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART. For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction. For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path. Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9
 1.18 08-Mar-2020  pgoyette fix indentation. NFCI
 1.17 08-Mar-2020  pgoyette Fix another left-over from last year's [pgoyette-compat] work. This
allows recognition of the oosyscall sequence for amd64.

Fixes PR kern/55038

XXX pullup-9
 1.16 20-Nov-2019  pgoyette Move all non-emulation-specific coredump code into the coredump module,
and remove all #ifdef COREDUMP conditional compilation. Now, the
coredump module is completely separated from the emulation modules, and
they can all be independently loaded and unloaded.

Welcome to 9.99.18 !
 1.15 27-Jan-2019  pgoyette branches: 1.15.4;
Merge the [pgoyette-compat] branch
 1.14 26-Dec-2018  mrg remove duplicated prototypes and dated XXX comments.
 1.13 03-Dec-2015  pgoyette branches: 1.13.16; 1.13.18;
Merge the compat_sysv module into the sysv_ipc module - it should
never have been a separate module in the first place (my bad).

Adjust dependencies as appropriate.
 1.12 01-Dec-2015  pgoyette Prepare for new compat_netbsd32_mqueue module to be split out of
compat_netbsd32. Refactor the COMPAT_50 code related to mqueue,
and update the syscall definitions. Remove dependency on mqueue
from the compat_netbsd32 module (the new module will gain this
dependency).

Continuation of work on PR kern/50489
 1.11 01-Dec-2015  pgoyette Add MODULE infrastructure to netbsd32_nfssvc.c, remove dependency on it
from netbsd32_mod.c
 1.10 30-Nov-2015  pgoyette Factor the basic dependency list out of the #ifdef _KERNEL_OPT block, since
the only difference was ksem (which is available as either built-in or
loadable module).
 1.9 10-Oct-2015  pgoyette Ooops, spell the module name in full. "mqueue" vs "mq"
 1.8 10-Oct-2015  pgoyette And yet another dependency, this time on mq
 1.7 10-Oct-2015  pgoyette Add another dependency for nfsserver
 1.6 13-Jun-2015  christos we need compat_sysv now.
 1.5 22-Jul-2014  maxv branches: 1.5.2; 1.5.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.4 11-Jul-2014  maxv netbsd32 should depend on exec_elf32, since it will use exec_elf32's functions.
This fixes
# modload compat_netbsd32
when exec_elf32 is not loaded.

ok njoly@
 1.3 07-Mar-2014  christos branches: 1.3.2;
c99 initializers for struct execsw
 1.2 19-Sep-2013  christos exec modules need to be of the exec kind
 1.1 19-Nov-2008  ad branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.14; 1.1.26; 1.1.36; 1.1.40;
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.40.1 18-May-2014  rmind sync with head
 1.1.36.2 03-Dec-2017  jdolecek update from HEAD
 1.1.36.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.26.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.14.2 04-May-2009  yamt sync with head.
 1.1.14.1 19-Nov-2008  yamt file netbsd32_mod.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:25 +0000
 1.1.10.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.10.1 19-Nov-2008  skrll file netbsd32_mod.c was added on branch nick-hppapmap on 2009-01-19 13:17:36 +0000
 1.1.8.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.8.1 19-Nov-2008  mjf file netbsd32_mod.c was added on branch mjf-devfs2 on 2009-01-17 13:28:46 +0000
 1.1.6.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.6.1 19-Nov-2008  ad file netbsd32_mod.c was added on branch christos-time_t on 2008-11-19 18:36:06 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 19-Nov-2008  haad file netbsd32_mod.c was added on branch haad-dm on 2008-12-13 01:14:03 +0000
 1.3.2.1 10-Aug-2014  tls Rebase.
 1.5.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5.4.1 22-Sep-2015  skrll Sync with HEAD
 1.5.2.2 17-Nov-2015  riz Revert ticket #1020, per pgoyette in ticket #1041.
 1.5.2.1 08-Nov-2015  riz Pull up following revision(s) (requested by pgoyette in ticket #1020):
sys/compat/netbsd32/netbsd32_mod.c: revision 1.6
sys/compat/netbsd32/netbsd32_mod.c: revision 1.7
sys/compat/netbsd32/netbsd32_mod.c: revision 1.8
sys/compat/netbsd32/netbsd32_mod.c: revision 1.9
sys/compat/linux/common/linux_mod.c: revision 1.5
Add an additional dependency on compat_sysv
Add another dependency for nfsserver
And yet another dependency, this time on mq
Ooops, spell the module name in full. "mqueue" vs "mq"
we need compat_sysv now.
 1.13.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.13.18.1 10-Jun-2019  christos Sync with HEAD
 1.13.16.19 25-Jan-2019  pgoyette Move the netbsd32_machine32_hook into the main kernel with most of
the other hooks.

Although this hook might better belong in compat/netbsd32/ code,
there are some machines without a netbsd32 module (for example, i386
and sgimips) which still have consumers/users of this hook. :(
 1.13.16.18 24-Jan-2019  pgoyette Rework placement of the new netbsd32_machine32_hook
 1.13.16.17 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.13.16.16 23-Sep-2018  pgoyette Use a .h file to define the xxx_{init,fini} routines, and include
the compat_stub.h header to get the definition of the kern_proc_32
hook.
 1.13.16.15 23-Sep-2018  pgoyette The kern_proc_32 hook is in the main kernel, so don't make another
one here.
 1.13.16.14 23-Sep-2018  pgoyette More work on kern_proc_32
 1.13.16.13 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.13.16.12 18-Sep-2018  pgoyette Use the MP-safe compat hooks for netbsd32_compat_80.c's modctl
 1.13.16.11 14-Sep-2018  pgoyette OMG it builds!

Finish rearranging the amd64 MD compat_netbsd32 code.

XXX Other architectures will be dealt with later.
 1.13.16.10 14-Sep-2018  pgoyette Work in progress - get the arch-specific netbsd32_machdep.c code to
build as a module.

XXX Doesn't work when the code is built-in to the kernel.
 1.13.16.9 14-Sep-2018  pgoyette Require coredump since netbsd32 module will be built with COREDUMP enabled.
 1.13.16.8 13-Sep-2018  pgoyette More clean-up of module dependencies
 1.13.16.7 13-Sep-2018  pgoyette Now that compat_netbsd32 is no longer monolithic, it no longer
requires compat_09 (and all higher) compat code. Adjust the
requirements list accordingly.
 1.13.16.6 11-Sep-2018  pgoyette Move netbsd32_rndpseudo_50.c out of the main netbsd32 module and into
the module that handles netbsd32_50 compatability.
 1.13.16.5 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.13.16.4 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.13.16.3 09-Sep-2018  pgoyette The compat_netbsd32 module requires compat_09 and above. Since we
removed the alias names, we need to explicitly refer to the oldest
non-32 required compat module.
 1.13.16.2 21-Mar-2018  pgoyette Split compat/rndpseudo_50.c into two pieces, one for native compat and
a second piece for compat32. Update both modules accordingly.
 1.13.16.1 11-Mar-2018  pgoyette Update module dependencies
 1.15.4.4 10-Mar-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #778):

sys/compat/netbsd32/netbsd32_mod.c: revision 1.20
sys/arch/amd64/amd64/trap.c: revision 1.127

Rework previous, so that the real syscall code is not invoked from within
the module_hook code. Otherwise, if the syscall just happens to be exit()
we will exit while still holding a reference to the hook's localcount, and
nothing will ever release that reference. Attempts to manually unload the
module will hang indefinitely, as will modstat(8).

XXX pullup-9
 1.15.4.3 09-Mar-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #770):

sys/compat/netbsd32/netbsd32_mod.c: revision 1.19

If a syscall requires a module to be autoloaded, the initial invocation
of that syscall will return ERESTART. For amd64's netbsd32_syscall()
that means we need to back up the PC saved in the trap frame so we can
re-issue the syscall instruction. For "normal" syscall traps, we saved
the instruction length in the trap frame, but this was missing for the
oosyscall/lcall path. Since the PC was not backed up, the kernel-only
value ERESTART was returned to userland, causing all sort of grief for
old compat_netbsd32 executables!

XXX Pullup-9
 1.15.4.2 09-Mar-2020  martin Apply patch, requested by pgoyette in ticket #775 to fix fallout from
ticket #762:

sys/compat/netbsd32/netbsd32_mod.c (patched)

Fiy arguments to MODULE_HOOK_SET for the new amd64_oosyscall_hook.
 1.15.4.1 08-Mar-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #762):

sys/arch/amd64/amd64/trap.c: revision 1.126
sys/compat/netbsd32/netbsd32_mod.c: revision 1.17
sys/compat/netbsd32/netbsd32_mod.c: revision 1.18
sys/sys/compat_stub.h: revision 1.23

Fix another left-over from last year's [pgoyette-compat] work. This
allows recognition of the oosyscall sequence for amd64.

Fixes PR kern/55038
XXX pullup-9

-

fix indentation. NFCI
 1.11 24-May-2022  andvar s/build-in/built-in/ in comments.
 1.10 01-Mar-2019  pgoyette Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
 1.9 31-Jan-2019  christos remove unused variable
 1.8 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.7 03-Sep-2018  riastradh 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.6 18-Jan-2018  maxv branches: 1.6.2; 1.6.4;
Don't return the address of the kernel modules if the user is not
privileged. Discussed on tech-kern@.
 1.5 01-Jun-2017  chs branches: 1.5.8;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.4 19-Dec-2015  maxv Missing field (was here before my change).
 1.3 12-Dec-2015  maxv Put the code in charge of handling MODCTL_STAT (32bit) into a separate
function. No functional change.
 1.2 21-Jun-2015  msaitoh branches: 1.2.2;
Add missing sys/kauth.h
 1.1 20-Jun-2015  martin Implement modctl, sigqueinfo and mq_*
 1.2.2.4 28-Aug-2017  skrll Sync with HEAD
 1.2.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.2.2 22-Sep-2015  skrll Sync with HEAD
 1.2.2.1 21-Jun-2015  skrll file netbsd32_module.c was added on branch nick-nhusb on 2015-09-22 12:05:55 +0000
 1.5.8.2 03-Dec-2017  jdolecek update from HEAD
 1.5.8.1 01-Jun-2017  jdolecek file netbsd32_module.c was added on branch tls-maxphys on 2017-12-03 11:36:56 +0000
 1.6.4.1 10-Jun-2019  christos Sync with HEAD
 1.6.2.13 22-Jan-2019  pgoyette Convert the MODULE_{,VOID_}HOOK_CALL macros to do everything in-line
rather than defining an intermediate hook##call function. Almost
all of the hooks are called only once, and although we lose the
ability of doing things like

if (MODULE_HOOK_CALL(...) == 0) ...

we simplify things quite a bit. With this change, we no longer need
to have both declaration and definition macros, and the definition
no longer needs to have both prototype argument list and a "real"
argument list.

FWIW, the above if now needs to written as

int ret;

MODULE_HOOK_CALL(..., ret);
if (ret == 0) ...

with appropriate use of braces {}.
 1.6.2.12 18-Jan-2019  pgoyette Don't restrict hooks to having only int or void types. Pass the hook's
type to the various macros, as needed.

Allows us to reduce diffs to original in at least one or two places (we
no longer have to provide an additional parameter to the hook routine
for returning a non-int return value).
 1.6.2.11 14-Jan-2019  pgoyette Create a variant of the HOOK macros that handles hook routines of
type void, and use them where appropriate.
 1.6.2.10 13-Jan-2019  pgoyette Remove the HOOK2 versions of the MODULE_HOOK macros. There were
only a few uses, and using them led to some lack of clarity in the
code. Instead, we now use two separate hooks, with names that
make it clear(er) what we're doing.

This also positions us to start unraveling some of the rtsock_50
mess, which will need (at least) five hooks.
 1.6.2.9 29-Sep-2018  pgoyette In MODULE_HOOK_CALL_DECL we don't need to provide the actual argument
list for calling the hook function, nor do we need to provide the
default value (for when the hook has not been set).
 1.6.2.8 18-Sep-2018  pgoyette The COMPAT_HOOK macros were renamed to MODULE_HOOK, adjust all callers
 1.6.2.7 18-Sep-2018  pgoyette Use the MP-safe compat hooks for netbsd32_compat_80.c's modctl
 1.6.2.6 14-Sep-2018  pgoyette Move some extern definitions into netbsd32_netbsd.h rather than having
them in the .c files.
 1.6.2.5 11-Sep-2018  pgoyette Install the syscalls into the netbsd32 table, not the default/native table.
 1.6.2.4 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.6.2.3 07-Sep-2018  pgoyette At the request of reviewers, remove the module alias functionality.

We will rely only on module names and duplicate-symbol detection to
detect module conflicts.
 1.6.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.2.1 03-Apr-2018  pgoyette Remove fixed allocation of modules' "required" lists (previously
limited to MAXMODDEPS entries). Update the modctl(MODCTL_STAT)
syscall to return the required data in a new format, and retain
the previous data format in MODCTL_OSTAT. Update the compat_80
and compat_netbsd32 modules as needed.
 1.7 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.6 01-Dec-2015  pgoyette branches: 1.6.16; 1.6.18; 1.6.20;
Prepare for new compat_netbsd32_mqueue module to be split out of
compat_netbsd32. Refactor the COMPAT_50 code related to mqueue,
and update the syscall definitions. Remove dependency on mqueue
from the compat_netbsd32 module (the new module will gain this
dependency).

Continuation of work on PR kern/50489
 1.5 30-Jun-2015  christos branches: 1.5.2;
whitespace police.
 1.4 30-Jun-2015  martin Fix reversed arguments in copyin(9), c.f. kern/sys_mqueue.c rev 1.39.
 1.3 21-Jun-2015  martin Move compat calls, requested by mrg@
 1.2 21-Jun-2015  martin Fix compat/versioning confusion and add the missing new versioned ones.
 1.1 20-Jun-2015  martin Implement modctl, sigqueinfo and mq_*
 1.5.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5.2.2 22-Sep-2015  skrll Sync with HEAD
 1.5.2.1 30-Jun-2015  skrll file netbsd32_mqueue.c was added on branch nick-nhusb on 2015-09-22 12:05:55 +0000
 1.6.20.1 10-Jun-2019  christos Sync with HEAD
 1.6.18.3 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.6.18.2 11-Sep-2018  pgoyette Revert previous - it was wrong.
 1.6.18.1 11-Sep-2018  pgoyette Regen
 1.6.16.2 03-Dec-2017  jdolecek update from HEAD
 1.6.16.1 01-Dec-2015  jdolecek file netbsd32_mqueue.c was added on branch tls-maxphys on 2017-12-03 11:36:56 +0000
 1.237 20-May-2024  christos Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.236 19-May-2024  christos version dup3
 1.235 30-Jul-2023  rin COMPAT_NETBSD32: Add support for memfd_create(2).
 1.234 30-Jul-2023  rin netbsd32_netbsd: Sort headers. No binary changes.
 1.233 20-Sep-2021  thorpej Add the eventfd(2) system call to COMPAT_NETBSD32.
 1.232 19-Jan-2021  simonb The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.231 15-Jan-2021  simonb Remove unused LIMITCHECK() macro (now contained in netbsd32_rlimit.c).
 1.230 10-Oct-2020  rin branches: 1.230.2;
Teach about getrandom(2) to COMPAT_NETBSD32.
 1.229 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.228 20-Jun-2019  kamil branches: 1.228.2;
Add mkfifo{,at}(2) mode in mknod{,at}(2) as requested by POSIX

mknod with mode & S_IFIFO and dev=0 shall behave like mkfifo.

Update the documentation to reflect this state.

Add ATF tests.

This is an in-kernel implementation as typically user-space programs use
mkfifo(2) directly, however whenever there is need to bypass libc (like in
valgrind) then portable POSIX software calls the mknod syscall.

Noted on tech-kern@ by Greg Troxel.
 1.227 18-Jun-2019  kamil Drop unused retval pointer from do_sys_mknod{,at}()

No functional change intended.
 1.226 18-Jun-2019  christos sort -u opt_ to remove dup.
 1.225 18-Jun-2019  christos Add options for quota.
 1.224 18-Jun-2019  pgoyette Include opt_quota.h

Fixes (at least) the amd64 build.
 1.223 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.222 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.221 24-Dec-2018  mrg move rlimit and quota code into their own modules.

(netbsd32_netbsd.c should have only simple shims. anything more
than copying arguments from one args struct to the other should
not be placed in this file. still a couple more to move out.)
 1.220 24-Dec-2018  mrg fix style consistency.
remove obsolete comments or commented code.
NFC.
 1.219 24-Dec-2018  mrg pset_create() takes a pointer so it needs special handling.
 1.218 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.217 31-Jul-2018  rjs Add getsockopt2().
 1.216 06-May-2018  kamil branches: 1.216.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.215 15-Mar-2018  christos Untangle the swapctl compat code mess. Welcome to lucky 13.
 1.214 09-Jan-2018  maya branches: 1.214.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.213 06-Jan-2018  kamil Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.212 26-Dec-2017  kamil Refactor pipe1() and correct a bug in sys_pipe2() (SYS_pipe2)

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

The first returned value is (on success) 0.

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

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

Before the changes on NetBSD/amd64:

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

After the changes:

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

There should not be a visible change for current users.

Sponsored by <The NetBSD Foundation>
 1.211 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.210 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.209 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.208 06-Dec-2017  christos disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
trace records, the only record that we can't parse is that one :-)
XXX: pullup-8
 1.207 31-Jul-2017  maxv Remove references to COMPAT_OLDSOCK (itself removed years ago).
 1.206 29-Apr-2017  christos branches: 1.206.2;
move MAP_COPY in compat
 1.205 19-Oct-2016  skrll branches: 1.205.6;
PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel

Updated from the original patch in the PR by me.
 1.204 17-Sep-2016  christos deal with not having KTRACE
 1.203 13-Sep-2016  martin Allow emulations to override the creation of ktrace records for posting
signals. In compat_netbsd32 use this to write the 32bit version of
the records, so a 32bit userland kdump is happy.
 1.202 10-Sep-2016  skrll Trailing whitespace
 1.201 10-Sep-2016  skrll +netbsd32__sched_protect
 1.200 13-May-2016  christos branches: 1.200.2;
clamp getrlimit the same way we clamp setrlimit
 1.199 28-Feb-2016  khorben Add missing newline character in error message

This is related to kern/50469.
 1.198 01-Dec-2015  pgoyette Adapt to per-emulation syscall_autoload capability (the table of syscalls
that can be autoloaded is currently empty).
 1.197 30-Jul-2015  maxv Lock before calling uvm_swap_stats(). Otherwise a race condition could
corrupt memory.
 1.196 21-Jun-2015  martin Implement trivial conversion for pset_*
 1.195 16-Jun-2015  martin Implement posix_fallocate and fdiscard compat
 1.194 16-Jun-2015  matt Fix a comment.
 1.193 31-Jul-2014  maxv branches: 1.193.2; 1.193.4; 1.193.6; 1.193.10;
Just return sys_open(). COMPAT_10 will be handled internally.

ok christos@
 1.192 28-Jun-2014  dholland Revert the following changes:

src/sys/sys/quotactl.h 1.37
src/sys/compat/netbsd32/netbsd32.h 1.101
src/sys/compat/netbsd32/netbsd32_netbsd.c 1.188, 1.189
src/sys/kern/vfs_quotactl.c 1.39
src/sys/kern/vfs_syscalls.c 1.483
src/sys/ufs/lfs/ulfs_quota.c 1.11
src/sys/ufs/ufs/ufs_quota.c 1.116
src/lib/libquota/quota_kernel.c 1.5

and do them correctly.

If you're going to change the name of something, you need to change
the name of *all* the things with the same name, not just a handful,
and you should change it to something similar so it still matches the
rest of the system rather than just picking an arbitrarily different
name.

Hi, Joerg.

To wit, rename the quotactl "delete" operation to "del", because
"delete" is a reserved word in C++ and for some reason Joerg wants to
run internal interfaces used only by C code through his C++ compiler.
Do not rename it to "remove" instead, because this doesn't match
libquota or the rest of the usage throughout the system; and rename
all the related identifiers, not just the ones that blew the mind of
Joerg's C++ compiler.

Because this is not a user-facing API (the only userland consumer
sys/quotactl.h is libquota) it is sort of ok to make arbitrary
source-incompatible changes; however, by the same token it's completely
unnecessary. If it *were* a user-facing API that someone might have a
semi-rational reason to want to run a C++ compiler on, it would be
incorrect to change it at this point.
 1.191 28-Jun-2014  maxv Sync getfh() with the native implementation. It also fixes:
a) a return value
b) a vnode lock
c) a user-controlled memory allocation

ok christos@, on tech-kern
 1.190 22-Jun-2014  maxv Sync swapctl() with netbsd32. Return EINVAL when misc<0, and 0 when misc=0
or uvmexp.nswapdev=0.
 1.189 13-Jun-2014  joerg delete -> remove
 1.188 12-Jun-2014  joerg Don't t use a C++ keyword as field name.
 1.187 15-May-2014  manu Fix cases where count <= 0 (thanks to Maxime Villard for raising this)
 1.186 30-Apr-2014  njoly Do not use native off_t type under compat netbsd32, but a new
netbsd32_off_t that provide the expected alignment for 64bit types.
 1.185 22-Mar-2014  maxv branches: 1.185.2;
Fix a potential - but very unlikely - NULL pointer dereference.
(it does not introduce a new error code for open(), since
pathbuf_copyin() is already there and can return ENOMEM)

Found by my code scanner.
 1.184 03-Feb-2014  manu Properly translate struct swapent for COMPAT_NETBSD32
 1.183 25-Jan-2014  christos ifdef debug printf
 1.182 25-Jan-2014  christos compat_10 fix: open(NULL) == open(".");
 1.181 18-Jul-2013  matt Move *at syscall handlers to netbsd32_fs.c from netbsd32_netbsd.c
Fix netbsd32_fstatat to emit a 32bit stat structure.
 1.180 19-Feb-2012  rmind branches: 1.180.2; 1.180.4; 1.180.10;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.179 01-Feb-2012  dholland branches: 1.179.2;
Improve the names of some members of struct quotactl_args. These are
effectively function parameter names, but since they need to be
described with the same names in the man page the choices do matter.
Some.
 1.178 01-Feb-2012  dholland Update compat_netbsd32 for new quotactl.
 1.177 31-Jan-2012  matt Add missing *at syscalls among others
 1.176 29-Jan-2012  dholland Add vfs_quotactl() in between the syscall and VFS_QUOTACTL. Call it
from the COMPAT_50 code as well as the current sys_quotactl instead
of going directly to VFS_QUOTACTL. Doesn't actually do anything yet.
 1.175 15-Nov-2011  njoly branches: 1.175.4;
Fix pipe2 return value.
 1.174 08-Nov-2011  njoly Add kqueue1(2) support.
 1.173 31-Aug-2011  njoly branches: 1.173.2;
Add dup3 syscall support.
 1.172 05-Jul-2011  njoly Add pipe2 syscall now needed for popen(3).
 1.171 05-Jun-2011  dsl Delete some splurious commas and very unexpected trailing space
 1.170 01-May-2011  rmind branches: 1.170.2;
Catch up with lim_privatise() change (missed in previous commit).
 1.169 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.168 19-Nov-2010  dholland branches: 1.168.2; 1.168.4;
Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

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

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.167 23-Apr-2010  rmind Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.166 02-Mar-2010  pooka branches: 1.166.2;
remove nfssvc emulation (or non-emulation)
 1.165 02-Mar-2010  pooka -fs_lfs.h
 1.164 02-Mar-2010  pooka remove unused lfs compat stubs
 1.163 14-Dec-2009  matt branches: 1.163.2;
Merge from matt-nb5-mips64
 1.162 12-Dec-2009  njoly Add missing semicolons after NETBSD32TOx_UAP macro calls.
 1.161 10-Dec-2009  matt Move saemul_netbsd32 to netbsd32_sa.c and allow the KERN_SA bits to be omitted.
 1.160 21-Nov-2009  njoly Kill redundant assignment.
 1.159 25-Oct-2009  rmind Initialise struct emul members by name (it is readable now and one can search
them in the tree).
 1.158 09-Aug-2009  haad Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions
can be called from kernel, too.

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

Oked by ad@.
 1.157 17-May-2009  pooka pad -> PAD. Fixes build problem reported by Paul Goyette in private email.
 1.156 16-Mar-2009  njoly Fix dev_t alignment, by not using the new 64bit value directly but
rather a 32bit aligned version (netbsd32_dev_t = netbsd32_uint64).

ok by cube@.
 1.155 04-Mar-2009  skrll Fix the posix_fadvise return value... finally.

Tested martin on sparc64/m68k and me on hppa.
 1.154 30-Jan-2009  njoly branches: 1.154.2;
Cleanup. Kill a few netbsd32_caddr_t in syscalls argument types.
 1.153 21-Jan-2009  tron Revert accidental of some rogue changes which broke the build.
 1.152 20-Jan-2009  tron Include "bsd.own.mk" to get the definition of "NETBSDSRCDIR" via
"/etc/mk.conf". This fixes manual use of "make cleandir".
 1.151 11-Jan-2009  nakayama Follow christos-time_t merge.
 1.150 11-Jan-2009  christos merge christos-time_t
 1.149 22-Nov-2008  mrg branches: 1.149.4;
implement netbsd32__sched_setparam(), netbsd32__sched_getparam(),
netbsd32__sched_setaffinity() and netbsd32__sched_getaffinity().
 1.148 20-Nov-2008  tron Make it possible to compile a kernel with COMPAT_NETBSD32 but without
COMPAT_40. This fixes PR port-amd64/39967.
 1.147 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.146 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.145 15-Oct-2008  wrstuden branches: 1.145.2; 1.145.4;
Merge wrstuden-revivesa into HEAD.
 1.144 29-May-2008  mrg branches: 1.144.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.143 21-Mar-2008  ad branches: 1.143.2; 1.143.4; 1.143.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.142 24-Feb-2008  martin Remove old posix_fadvise compat code
 1.141 28-Jan-2008  martin branches: 1.141.2; 1.141.6;
wrong argument type
 1.140 27-Jan-2008  martin Catch up with versioning of posix_fadvise
 1.139 27-Jan-2008  dsl Call do_posix_fadvise() in netbsd32_posix_fadvise()
 1.138 26-Jan-2008  dsl Split the return value of sys_lseek() into two 32 bit halves for retval[0/1]
in a manner that is endianness independant.
Should mean the amd64 will return correct offsets > 2^32 (sparc64 had a
special define).
Any new netbsd32 ports should work regardless of the endianness.
 1.137 26-Jan-2008  dsl Don't try to bound the return value for pread/pwrite/pathconf by casting
an 'ssize_t' or 'long' variable to 'register_t'.
If the sizes were different it would either overwrite stack or return
uninitialised stack. On big-endian systems things would be worse!
 1.136 26-Jan-2008  dsl Add a wrapper for posix_fadvise()
 1.135 19-Jan-2008  dsl Add netbsd32 wrapper for sys_mremap(), compiles, and assuming the mmap()
wrapper is ok, it should work!
I presume the kernel knows not to map above 4GB though....
 1.134 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.133 09-Dec-2007  wiz branches: 1.133.2;
Remove last argument from NDINIT call, following
"Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure." from pooka.
 1.132 08-Dec-2007  dsl branches: 1.132.2;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.131 04-Dec-2007  dsl Remove all the __P
 1.130 10-Nov-2007  dsl branches: 1.130.2;
Fix builds for ports that don't define __HAVE_MINIMAL_EMUL (eg sparc64).
Fallout from a change that made #define names for syscalls (etc) start
NETBSD32 (not netbsd32).
 1.129 09-Nov-2007  dsl Add arguments to sys_syscall and sys___syscall.
Use MI wrappers for them in netbsd32.
Change prefix for constants from netbsd32 to NETBSD32 (used in #defines etc).
 1.128 29-Sep-2007  dsl branches: 1.128.2; 1.128.4;
Change the way p->p_limit (and hence p->p_rlimit) is locked.
Should fix PR/36939 and make the rlimit code MP safe.
Posted for comment to tech-kern (non received!)

The p_limit field (for a process) is only be changed once (on the first
write), and a reference to the old structure is kept (for code paths
that have cached the pointer).
Only p->p_limit is now locked by p->p_mutex, and since the referenced memory
will not go away, is only needed if the pointer is to be changed.
The contents of 'struct plimit' are all locked by pl_mutex, except that the
code doesn't bother to acquire it for reads (which are basically atomic).
Add FORK_SHARELIMIT that causes fork1() to share the limits between parent
and child, use it for the IRIX_PR_SULIMIT.
Fix borked test for both IRIX_PR_SUMASK and IRIX_PR_SDIR being set.
 1.127 21-Sep-2007  dsl branches: 1.127.2;
Rename members of 'struct plimit' so that the fields are 'pl_xxx' and
no longer have the same names as members of 'struct proc'.
 1.126 15-Aug-2007  ad branches: 1.126.2;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.125 14-Jul-2007  dsl branches: 1.125.2; 1.125.6;
Adapt for sys_mount() becoming compat_40_sys_mount(),
 1.124 30-Jun-2007  dsl Changes to sompat socket function to avoid the dreaded stackgap.
 1.123 22-Apr-2007  dsl Delete a diagnostic printf and some unused 'stack gap' initialisation.
 1.122 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.121 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.120 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.119 04-Mar-2007  christos branches: 1.119.2; 1.119.4; 1.119.6;
fix fallout from caddr_t changes.
 1.118 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.117 19-Feb-2007  cube Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.
 1.116 09-Feb-2007  ad branches: 1.116.2;
Merge newlock2 to head.
 1.115 21-Nov-2006  christos deal with RLIM_INFINITY in the setrlimit case.
 1.114 21-Nov-2006  christos Simplify previous commit not to use dosetrlimit(), since we don't want the
kauth tests etc.
 1.113 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.112 14-Nov-2006  elad Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.111 01-Sep-2006  matt branches: 1.111.2; 1.111.4;
When calling PTRACE from an LKM, use sysent[SYS_ptrace].sy_call in case
the sys_ptrace symbol isn't present.
 1.110 30-Aug-2006  cube Protect netbsd32_ptrace with options PTRACE.
 1.109 31-Jul-2006  martin Make filehandles opaque to userland
 1.108 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.107 13-Jul-2006  pavel do not protect the getfh syscall by
#if defined(NFS) || defined(NFSSERVER).
The native syscall also isn't.
 1.106 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.105 26-Jun-2006  mrg version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
 1.104 14-May-2006  elad branches: 1.104.4;
integrate kauth.
 1.103 11-May-2006  mrg use socklen_t where appropriate.
 1.102 05-May-2006  cube Move fhstat as sys___fhstat30 in netbsd32_fs.c because it doesn't belong
to netbsd32_netbsd.c (which incidentally means it had been broken for a
while I guess). Add compat_30 version.
 1.101 29-Mar-2006  cube Implement the _lwp* and sa_* families of syscalls, using the newly
introduced hooks in the native code.
 1.100 09-Feb-2006  manu branches: 1.100.2; 1.100.4; 1.100.6;
Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
 1.99 11-Dec-2005  christos branches: 1.99.2; 1.99.4; 1.99.6;
merge ktrace-lwp.
 1.98 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.97 12-Jul-2005  martin When returning 64bit values (from netbsd32_lseek) fix up the return
value vector (of 32bit values, most likely) via a MD macro.
 1.96 12-Jul-2005  cube Add the *xattr(2) family of syscalls. Just like the *extattr(2) family,
they're waiting for an actual FS back-end to be tested, but are still
straightforward enough.
 1.95 11-Jul-2005  cube Add rasctl(2). Thanks to the regression tests for that syscall, I was able
to discover the bugs in netbsd32_setitimer() and netbsd32_execve().
 1.94 10-Jul-2005  cube Add support for fsync_range(2).
 1.93 10-Jul-2005  cube Implement __clone(2).
 1.92 08-Jul-2005  cube Add mlockall(2) and munlockall(2).
 1.91 08-Jul-2005  cube Implement the extattr(3) family of syscalls.

XXX However, those remain untested as there are currently no backend for
XXX extattr(9) in NetBSD.
 1.90 04-Jul-2005  cube branches: 1.90.2;
Implement uuidgen(2).
 1.89 30-May-2005  chs track change to swapctl args in kern/syscalls.master.
 1.88 26-Mar-2005  fvdl Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.
 1.87 26-Feb-2005  perry branches: 1.87.2;
nuke trailing whitespace
 1.86 17-Jun-2004  cube branches: 1.86.4; 1.86.6;
o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.85 22-Apr-2004  christos Add the missing 'v' to fhstatvfs1
 1.84 21-Apr-2004  christos try to make this compile. XXX: this will not work yet (hi simon)
 1.83 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.82 26-Mar-2004  drochner use netbsd32_sigcode with COMPAT_16 only
 1.81 21-Mar-2004  mrg fix a (syscall args) comment.
 1.80 20-Dec-2003  fvdl Put back Emmanuel's sigfilter hooks, as decided by Core.
 1.79 20-Dec-2003  manu Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

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

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

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

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

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

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

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

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

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

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

originally from openbsd, adapted for netbsd by me.
 1.73 29-Jun-2003  fvdl branches: 1.73.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.72 29-Jun-2003  martin struct proc * -> struct lwp *
 1.71 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.70 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.69 06-Dec-2002  scw branches: 1.69.2;
After a discussion with various folks, fix the strict-alias warning
by ditching 'void *rt' and passing retval directly to sys_mmap().
 1.68 06-Dec-2002  scw Avoid strict-alias warnings.
 1.67 01-Nov-2002  jdolecek set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL
 1.66 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.65 21-Sep-2002  manu - Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.
 1.64 07-Jul-2002  fvdl Move netbsd32_sysarch to netbsd32_machdep.c
 1.63 16-Mar-2002  christos branches: 1.63.4;
make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.62 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.61 18-Sep-2001  jdolecek Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).
 1.60 19-Jun-2001  fvdl branches: 1.60.2; 1.60.4;
Some of this was sparc-specific, so ifdef __sparc__ it (XXX). Also,
change the alignment of one structure with an MD ifdef. Should
be moved into the netbsd32_machdep parts.
 1.59 18-Jun-2001  christos Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.
 1.58 30-May-2001  mrg use _KERNEL_OPT.
 1.57 08-Feb-2001  mrg branches: 1.57.2;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.56 07-Feb-2001  mrg move the static inline conversion functions into a header file so other
files can see these. note a bunch of functions that should be moved
into their own files.
 1.55 06-Feb-2001  eeh Specify a process' address space limits for uvmspace_exec().
 1.54 04-Feb-2001  mrg change_utimes32() was copyin()ing a struct timeval, not netbsd32_timeval.
general clean up.
 1.53 04-Feb-2001  mrg emulate kern.boottime. now 32-bit w(1) works properly.
 1.52 04-Feb-2001  mrg make sysctl vm.loadavg work.
 1.51 03-Feb-2001  mrg sync a comment from sys_execve().
make netbsd32_recvfrom() work.
 1.50 02-Feb-2001  mrg implement netbsd32_lchflags & netbsd32_utrace
 1.49 02-Feb-2001  mrg de-static netbsd32_exec_aout_prep_[zno]magic().
de-static netbsd32_from_stat43().
move the guts of netbsd32_execve() into netbsd32_execve2().

all of are for the forthcoming sunos32 compat mode (for sparc64).
 1.48 22-Jan-2001  jdolecek Use CHECK_ALT_SYMLINK() instead CHECK_ALT_EXISTS() where appropriate.
This addresses kern/11757.
 1.47 22-Dec-2000  jdolecek split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.46 12-Dec-2000  mycroft Do the __HAVE_SYSCALL_INTERN and __HAVE_MINIMAL_EMUL dance.
 1.45 09-Dec-2000  jdolecek always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()
 1.44 08-Dec-2000  jdolecek add infrastructure to load emulations and their executable support dynamically
via LKM
 1.43 03-Dec-2000  fvdl Use a copied fktrace syscall arg structure with out 'const int' for the
filedescriptor to copy arguments, avoiding a warning. XXX
 1.42 01-Dec-2000  jdolecek always define COMPAT_OLDSOCK (this tracks rev.1.55 of kern/uipc_syscalls.c)
move definition of emul_netbsd32 from netbsd32_exec.c here
fix couple of compile nits I encountered while compiling this with
sparc cross-compiler
 1.41 01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.40 30-Nov-2000  jdolecek sync netbsd32_execve() with sys_execve() - this involves
VMCMD_RELATIVE support, couple of debugging printfs and addition of
doexechooks() call
also fix one FREE() which should be free()
 1.39 28-Nov-2000  mrg make this compile again, after execsw/lkm changes.
 1.38 28-Sep-2000  eeh Add support for variable end of user stacks needed to support COMPAT_NETBSD32:

`struct vmspace' has a new field `vm_minsaddr' which is the user TOS.

PS_STRINGS is deprecated in favor of curproc->p_pstr which is derived
from `vm_minsaddr'.

Bump the kernel version number.
 1.37 24-Sep-2000  martin The ovadvise syscall is (correctly) listed as STD, so move it's implementation
to another place. This makes kernels without options COMPAT_43 link.
 1.36 19-Aug-2000  eeh Fix netbsd32_ioctls.
 1.35 03-Aug-2000  thorpej Convert namei pathname buffer allocation to use the pool allocator.
 1.34 14-Jul-2000  thorpej - Fix the likely cause of the "ps(1) hangs machine" problem. Always
vslock the user pages for the data being copied out to userspace,
so that we won't sleep while holding a lock in case we need to
fault the pages in.
- Sprinkle some const and ANSI'ify some things while here.
 1.33 13-Jul-2000  thorpej Sync w/ kern_time.c and sys_generic.c
 1.32 09-Jul-2000  mrg - massive warning fix fest.
- fix pread/pwrite return values (plus some other syscalls that looked
similarly broken).
- prototypes and clean up for netbsd32_ioctl.c

now getpw*() works under compat32!
 1.31 09-Jul-2000  mrg look in /emul/netbsd32 for __stat13() and __lstat13().
 1.30 28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.29 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.28 30-May-2000  eeh branches: 1.28.2;
Include "opt_DDB.h" to enable the DDB sysctls.
 1.27 27-May-2000  thorpej branches: 1.27.2;
sleep() -> tsleep()
 1.26 27-May-2000  sommerfeld Reduce use of curproc in several places:

- Change ktrace interface to pass in the current process, rather than
p->p_tracep, since the various ktr* function need curproc anyway.

- Add curproc as a parameter to mi_switch() since all callers had it
handy anyway.

- Add a second proc argument for inferior() since callers all had
curproc handy.

Also, miscellaneous cleanups in ktrace:

- ktrace now always uses file-based, rather than vnode-based I/O
(simplifies, increases type safety); eliminate KTRFLAG_FD & KTRFAC_FD.
Do non-blocking I/O, and yield a finite number of times when receiving
EWOULDBLOCK before giving up.

- move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

- simplify interface to ktrwrite()
 1.25 30-Mar-2000  augustss Kill register declarations.
 1.24 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.23 06-Feb-2000  eeh Add support for -current's ELF32 exec format.
 1.22 31-Jan-2000  christos Regen
 1.21 31-Dec-1999  eeh netbsd32_close() would work better if it called sys_close() rather than
sys_write().
netbsd32_getfsstat() cannot just copyin()/copyout(), convert the structures,
and call sys_getffstat(). sys_getffstat() wants to do its own
copyin()/copyout(). So we need to implent the whole of sys_getffstat()
in netbsd32_getfsstat().
 1.20 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.19 11-Oct-1999  eeh branches: 1.19.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.18 28-Sep-1999  bouyer branches: 1.18.2;
Remplace kern.shortcorename sysctl with a more flexible sheme,
core filename format, which allow to change the name of the core dump,
and to relocate it in a directory. Credits to Bill Sommerfeld for giving me
the idea :)
The default core filename format can be changed by options DEFCORENAME and/or
kern.defcorename
Create a new sysctl tree, proc, which holds per-process values (for now
the corename format, and resources limits). Process is designed by its pid
at the second level name. These values are inherited on fork, and the corename
fomat is reset to defcorename on suid/sgid exec.
Create a p_sugid() function, to take appropriate actions on suid/sgid
exec (for now set the P_SUGID flag and reset the per-proc corename).
Adjust dosetrlimit() to allow changing limits of one proc by another, with
credential controls.
 1.17 05-Aug-1999  thorpej Change the semantics of splsoftclock() to be like other spl*() functions,
that is priority is rasied. Add a new spllowersoftclock() to provide the
atomic drop-to-softclock semantics that the old splsoftclock() provided,
and update calls accordingly.

This fixes a problem with using the "rnd" pseudo-device from within
interrupt context to extract random data (e.g. from within the softnet
interrupt) where doing so would incorrectly unblock interrupts (causing
all sorts of lossage).

XXX 4 platforms do not have priority-raising capability: newsmips, sparc,
XXX sparc64, and VAX. This platforms still have this bug until their
XXX spl*() functions are fixed.
 1.16 20-Jul-1999  thorpej Move the call of cpu_wait() out of the wait4() functions, and into the
body of reaper(), right before the call to uvm_exit(). cpu_wait() must
be done before uvm_exit() because the resources it frees might be located
in the PCB.
 1.15 17-Jun-1999  thorpej Make uvm_vslock() return the error code from uvm_fault_wire(). All places
which use uvm_vslock() should now test the return value. If it's not
KERN_SUCCESS, wiring the pages failed, so the operation which is using
uvm_vslock() should error out.

XXX We currently just EFAULT a failed uvm_vslock(). We may want to do
more about translating error codes in the future.
 1.14 09-Jun-1999  christos Propagate kern changes
 1.13 26-May-1999  thorpej XXX Pass VM_PROT_NONE to uvm_vslock() as access_type. Why are we even
vslocking here?! copyout() on its own seems to suffice just about everwhere
else, and it's not like the process is going to exit; it's in a system
call!
 1.12 05-May-1999  thorpej Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
 1.11 25-Mar-1999  mrg branches: 1.11.4;
SPARC32->NETBSD32
 1.10 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.9 25-Mar-1999  mrg formatting nits
 1.8 24-Mar-1999  mrg completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.7 18-Dec-1998  drochner solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.
 1.6 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.5 11-Sep-1998  eeh Add some copyin()/copyout()s. These need to be done but there are more
annoying issues, so I'll just check in this snapshot.
 1.4 30-Aug-1998  eeh Some more 64-bit cleanup. Now everything compiles.
 1.3 29-Aug-1998  eeh Some more 64-bit-ification.
 1.2 26-Aug-1998  mrg use right syscalls. add converters for timespec and semid_ds
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.11.4.2 02-Aug-1999  thorpej Update from trunk.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.18.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.19.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.19.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.19.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.19.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.27.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.28.2.5 16-Jun-2001  he Apply patch (from netbsd32_execve.c revision 1.4, requested by thorpej):
Close a race condition between exec of a setuid binary and
ptrace(2): check P_TRACED right before adjusting the privilege
settings in the exec code.
 1.28.2.4 18-Oct-2000  tv Pullup by patch [eeh]:
Support userspace at multiple addresses by making PSSTRINGS variable (using
p_psstr), and fix stackgap_init() appropriately.
 1.28.2.3 26-Aug-2000  mrg pull up 1.36. approved by thorpej:
>Fix netbsd32_ioctls.
 1.28.2.2 14-Jul-2000  thorpej Update from trunk:
- Fix the likely cause of the "ps(1) hangs machine" problem. Always
vslock the user pages for the data being copied out to userspace,
so that we won't sleep while holding a lock in case we need to
fault the pages in.
- Sprinkle some const and ANSI'ify some things while here.
 1.28.2.1 13-Jul-2000  thorpej Pull up rev. 1.33:
Sync w/ kern_time.c and sys_generic.c
 1.57.2.10 11-Dec-2002  thorpej Sync with HEAD.
 1.57.2.9 11-Nov-2002  nathanw Catch up to -current
 1.57.2.8 18-Oct-2002  nathanw Catch up to -current.
 1.57.2.7 23-Aug-2002  petrov lwpification.
 1.57.2.6 01-Aug-2002  nathanw Catch up to -current.
 1.57.2.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.57.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.57.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.57.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.57.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.60.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.60.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.60.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.60.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.60.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.63.4.1 15-Jul-2002  gehenna catch up with -current.
 1.69.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.73.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.73.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.73.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.73.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.73.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.73.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.73.2.1 03-Aug-2004  skrll Sync with HEAD
 1.86.6.2 26-Mar-2005  yamt sync with head.
 1.86.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.86.4.1 29-Apr-2005  kent sync with -current
 1.87.2.1 18-Sep-2005  tron Pull up following revision(s) (requested by fvdl in ticket #798):
sys/compat/sunos/sunos_exec.c: revision 1.47
sys/compat/pecoff/pecoff_emul.c: revision 1.11
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.45
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.12
sys/sys/proc.h: revision 1.198
sys/compat/mach/mach_exec.c: revision 1.56
sys/compat/freebsd/freebsd_exec.c: revision 1.27
sys/arch/sparc64/include/vmparam.h: revision 1.27
sys/kern/kern_resource.c: revision 1.91
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.88
sys/compat/osf1/osf1_exec.c: revision 1.39
sys/compat/svr4_32/svr4_32_resource.c: revision 1.5
sys/compat/ultrix/ultrix_misc.c: revision 1.99
sys/compat/svr4_32/svr4_32_exec.h: revision 1.9
sys/kern/exec_elf32.c: revision 1.103
sys/compat/aoutm68k/aoutm68k_exec.c: revision 1.19
sys/compat/sunos32/sunos32_exec.c: revision 1.20
sys/compat/hpux/hpux_exec.c: revision 1.46
sys/compat/darwin/darwin_exec.c: revision 1.40
sys/kern/sysv_shm.c: revision 1.83
sys/uvm/uvm_extern.h: revision 1.99
sys/uvm/uvm_mmap.c: revision 1.89
sys/kern/kern_exec.c: revision 1.195
sys/compat/netbsd32/netbsd32.h: revision 1.31
sys/arch/sparc64/sparc64/svr4_32_machdep.c: revision 1.20
sys/compat/svr4/svr4_exec.c: revision 1.56
sys/compat/irix/irix_exec.c: revision 1.41
sys/compat/ibcs2/ibcs2_exec.c: revision 1.63
sys/compat/svr4_32/svr4_32_exec.c: revision 1.16
sys/arch/amd64/include/vmparam.h: revision 1.8
sys/compat/linux/common/linux_exec.c: revision 1.73
Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.
* For sparc64 and amd64, define *SIZ32 VM constants.
* Add a new function pointer to struct emul, pointing at a function
that will return the default VM map address. The default function
is uvm_map_defaultaddr, which just uses the VM_DEFAULT_ADDRESS
macro. This gives emulations control over the default map address,
and allows things to be mapped at the right address (in 32bit range)
for COMPAT_NETBSD32.
* Add code to adjust the data and stack limits when a COMPAT_NETBSD32
or COMPAT_SVR4_32 binary is executed.
* Don't use USRSTACK in kern_resource.c, use p_vmspace->vm_minsaddr
instead (emulations might have set it differently)
* Since this changes struct emul, bump kernel version to 3.99.2
Tested on amd64, compile-tested on sparc64.
 1.90.2.11 24-Mar-2008  yamt sync with head.
 1.90.2.10 27-Feb-2008  yamt sync with head.
 1.90.2.9 04-Feb-2008  yamt sync with head.
 1.90.2.8 21-Jan-2008  yamt sync with head
 1.90.2.7 07-Dec-2007  yamt sync with head
 1.90.2.6 15-Nov-2007  yamt sync with head.
 1.90.2.5 27-Oct-2007  yamt sync with head.
 1.90.2.4 03-Sep-2007  yamt sync with head.
 1.90.2.3 26-Feb-2007  yamt sync with head.
 1.90.2.2 30-Dec-2006  yamt sync with head.
 1.90.2.1 21-Jun-2006  yamt sync with head.
 1.99.6.2 01-Jun-2006  kardel Sync with head.
 1.99.6.1 22-Apr-2006  simonb Sync with head.
 1.99.4.1 09-Sep-2006  rpaulo sync with head
 1.99.2.1 18-Feb-2006  yamt sync with head.
 1.100.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.100.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.100.4.6 12-May-2006  elad include sys/kauth.h where appropriate.
 1.100.4.5 11-May-2006  elad sync with head
 1.100.4.4 19-Apr-2006  elad sync with head.
 1.100.4.3 18-Apr-2006  elad zap unused var
 1.100.4.2 14-Mar-2006  elad Use kauth_cred_[sg]etgroups() where appropriate.
 1.100.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.100.2.4 03-Sep-2006  yamt sync with head.
 1.100.2.3 11-Aug-2006  yamt sync with head
 1.100.2.2 24-May-2006  yamt sync with head.
 1.100.2.1 01-Apr-2006  yamt sync with head.
 1.104.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.111.4.1 10-Dec-2006  yamt sync with head.
 1.111.2.4 05-Feb-2007  ad - When clearing signals dequeue siginfo first and free later, once
outside the lock permiter.
- Push kernel_lock back in a a couple of places.
- Adjust limcopy() to be MP safe (this needs redoing).
- Fix a couple of bugs noticed along the way.
- Catch up with condvar changes.
 1.111.2.3 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.111.2.2 12-Jan-2007  ad Sync with head.
 1.111.2.1 18-Nov-2006  ad Sync with head.
 1.116.2.4 07-May-2007  yamt sync with head.
 1.116.2.3 24-Mar-2007  yamt sync with head.
 1.116.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.116.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.119.6.2 29-Mar-2007  reinoud Pullup to -current
 1.119.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.119.4.1 11-Jul-2007  mjf Sync with head.
 1.119.2.5 09-Oct-2007  ad Sync with head.
 1.119.2.4 20-Aug-2007  ad Sync with HEAD.
 1.119.2.3 15-Jul-2007  ad Sync with head.
 1.119.2.2 27-May-2007  ad Sync with head.
 1.119.2.1 10-Apr-2007  ad Sync with head.
 1.125.6.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.125.6.3 11-Nov-2007  joerg Sync with HEAD.
 1.125.6.2 02-Oct-2007  joerg Sync with HEAD.
 1.125.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.125.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.126.2.3 23-Mar-2008  matt sync with HEAD
 1.126.2.2 09-Jan-2008  matt sync with HEAD
 1.126.2.1 06-Nov-2007  matt sync with HEAD
 1.127.2.1 06-Oct-2007  yamt sync with head.
 1.128.4.4 18-Feb-2008  mjf Sync with HEAD.
 1.128.4.3 27-Dec-2007  mjf Sync with HEAD.
 1.128.4.2 08-Dec-2007  mjf Sync with HEAD.
 1.128.4.1 19-Nov-2007  mjf Sync with HEAD.
 1.128.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.130.2.2 26-Dec-2007  ad Sync with head.
 1.130.2.1 08-Dec-2007  ad Sync with head.
 1.132.2.1 11-Dec-2007  yamt sync with head.
 1.133.2.2 20-Jan-2008  bouyer Sync with HEAD
 1.133.2.1 02-Jan-2008  bouyer Sync with HEAD
 1.141.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.141.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.141.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.141.2.1 24-Mar-2008  keiichi sync with head.
 1.143.6.5 28-Sep-2008  skrll Adapt the SA COMPAT_NETBSD32 stuff to this branch.
 1.143.6.4 21-Jul-2008  wrstuden Add support for compiling SA as an option. Implied by COMPAT_40.

i386 kernels both with COMPAT_40 and with no compat options (and thus
no SA) compile.

No functional changes intended.
 1.143.6.3 27-Jun-2008  wrstuden Add getucontext32_sa() and getucontext_sa(), and use them. They
are sa-specific versions of getucontext{,32}(). The main difference
is that they do NOT require the p_lock be held. We report an empty
signal mask, both to avoid needing p_lock and because the process
signal mask is almost always 0 for SA.
 1.143.6.2 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.143.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.143.4.5 11-Aug-2010  yamt sync with head.
 1.143.4.4 11-Mar-2010  yamt sync with head
 1.143.4.3 19-Aug-2009  yamt sync with head.
 1.143.4.2 20-Jun-2009  yamt sync with head
 1.143.4.1 04-May-2009  yamt sync with head.
 1.143.2.1 04-Jun-2008  yamt sync with head
 1.144.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.144.4.1 19-Oct-2008  haad Sync with HEAD.
 1.145.4.2 25-Nov-2008  snj branches: 1.145.4.2.4;
Pull up following revision(s) (requested by mrg in ticket #121):
sys/compat/netbsd32/syscalls.master: revision 1.74
sys/compat/netbsd32/netbsd32.h: revision 1.78
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.149
implement netbsd32__sched_setparam(), netbsd32__sched_getparam(),
netbsd32__sched_setaffinity() and netbsd32__sched_getaffinity().
 1.145.4.1 22-Nov-2008  snj Pull up following revision(s) (requested by tron in ticket #100):
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.148
sys/compat/netbsd32/netbsd32_sa.c: revision 1.8
Make it possible to compile a kernel with COMPAT_NETBSD32 but without
COMPAT_40. This fixes PR port-amd64/39967.
 1.145.4.2.4.2 13-Sep-2009  matt Move netbsd32___mount50 from netbsd32_netbsd.c to netbsd32_fs.c
 1.145.4.2.4.1 12-Sep-2009  matt Add support for netbsd32___mount50. There's got to be a better of doing this.
Maybe pushing it down to vfs. This only supports mfs/ufs/cd9660 and probably
tmpfs.
 1.145.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.145.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.145.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.149.4.2 04-Jan-2009  christos add new syscalls.
 1.149.4.1 22-Nov-2008  christos file netbsd32_netbsd.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.154.2.2 23-Jul-2009  jym Sync with HEAD.
 1.154.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.163.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.166.2.5 12-Jun-2011  rmind sync with head
 1.166.2.4 31-May-2011  rmind sync with head
 1.166.2.3 21-Apr-2011  rmind sync with head
 1.166.2.2 05-Mar-2011  rmind sync with head
 1.166.2.1 30-May-2010  rmind sync with head
 1.168.4.3 15-Feb-2011  bouyer implement COMPAT_NETBSD32 quotactl syscalls (both new and COMPAT_50)
 1.168.4.2 09-Feb-2011  bouyer Proper definitions for quotactl
 1.168.4.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.168.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.170.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.173.2.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.173.2.2 17-Apr-2012  yamt sync with head
 1.173.2.1 10-Nov-2011  yamt sync with head
 1.175.4.2 24-Feb-2012  mrg sync to -current.
 1.175.4.1 18-Feb-2012  mrg merge to -current.
 1.179.2.2 26-Jun-2014  msaitoh Pull up following revision(s) (requested by maxv in ticket #1084):
sys/compat/netbsd32/netbsd32_netbsd.c rev. 1.187

Fix cases where count <= 0 (thanks to Maxime Villard for raising this).
 1.179.2.1 18-Mar-2014  msaitoh Pull up following revision(s) (requested by manu in ticket #1025):
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.184
sys/uvm/uvm_swap.c: revision 1.166
sys/uvm/uvm_swap.h: revision 1.20
sys/compat/netbsd32/netbsd32.h: revision 1.99
Properly translate struct swapent for COMPAT_NETBSD32
Properly translate struct swapent for COMPAT_NETBSD32 (missing commit)
 1.180.10.1 23-Jul-2013  riastradh sync with HEAD
 1.180.4.2 18-May-2014  rmind sync with head
 1.180.4.1 28-Aug-2013  rmind sync with head
 1.180.2.2 03-Dec-2017  jdolecek update from HEAD
 1.180.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.185.2.1 10-Aug-2014  tls Rebase.
 1.193.10.1 25-Dec-2018  martin Apply patch, requested by maxv in ticket #1666:
Fix similar to:

sys/uvm/uvm_swap.c: revision 1.178

Woah man, fix enormous leak.

Possible info leak: [len=1056, leaked=931]
#0 0xffffffff80bad351 in kleak_copyout
#1 0xffffffff80b2cf64 in uvm_swap_stats.part.1
#2 0xffffffff80b2d38d in uvm_swap_stats
#3 0xffffffff80b2d43c in sys_swapctl
#4 0xffffffff80259b82 in syscall
 1.193.6.1 25-Dec-2018  martin Apply patch, requested by maxv in ticket #1666:
Fix similar to:

sys/uvm/uvm_swap.c: revision 1.178

Woah man, fix enormous leak.

Possible info leak: [len=1056, leaked=931]
#0 0xffffffff80bad351 in kleak_copyout
#1 0xffffffff80b2cf64 in uvm_swap_stats.part.1
#2 0xffffffff80b2d38d in uvm_swap_stats
#3 0xffffffff80b2d43c in sys_swapctl
#4 0xffffffff80259b82 in syscall
 1.193.4.7 28-Aug-2017  skrll Sync with HEAD
 1.193.4.6 05-Dec-2016  skrll Sync with HEAD
 1.193.4.5 05-Oct-2016  skrll Sync with HEAD
 1.193.4.4 29-May-2016  skrll Sync with HEAD
 1.193.4.3 19-Mar-2016  skrll Sync with HEAD
 1.193.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.193.4.1 22-Sep-2015  skrll Sync with HEAD
 1.193.2.1 25-Dec-2018  martin Apply patch, requested by maxv in ticket #1666:
Fix similar to:

sys/uvm/uvm_swap.c: revision 1.178

Woah man, fix enormous leak.

Possible info leak: [len=1056, leaked=931]
#0 0xffffffff80bad351 in kleak_copyout
#1 0xffffffff80b2cf64 in uvm_swap_stats.part.1
#2 0xffffffff80b2d38d in uvm_swap_stats
#3 0xffffffff80b2d43c in sys_swapctl
#4 0xffffffff80259b82 in syscall
 1.200.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.205.6.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.206.2.3 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1833):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.206.2.2 27-Dec-2018  martin Pull up following revision(s) (requested by mrg in ticket #1146):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.219

pset_create() takes a pointer so it needs special handling.
 1.206.2.1 25-Dec-2018  martin Apply patch, requested by maxv in ticket #1142:
Similar to:

sys/uvm/uvm_swap.c: revision 1.178

Fix kernel info leak in swapctl(2).

Possible info leak: [len=1056, leaked=931]
#0 0xffffffff80bad351 in kleak_copyout
#1 0xffffffff80b2cf64 in uvm_swap_stats.part.1
#2 0xffffffff80b2d38d in uvm_swap_stats
#3 0xffffffff80b2d43c in sys_swapctl
#4 0xffffffff80259b82 in syscall
 1.214.2.7 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.214.2.6 14-Sep-2018  pgoyette Move some extern definitions into netbsd32_netbsd.h rather than having
them in the .c files.
 1.214.2.5 12-Sep-2018  pgoyette Add a compat_netbsd32_16 to handle the sigcode stuff.
 1.214.2.4 12-Sep-2018  pgoyette Add a netbsd32_compat40 module, move the 4.0 mount stuff there.
 1.214.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.214.2.2 21-May-2018  pgoyette Sync with HEAD
 1.214.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.216.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.216.2.1 10-Jun-2019  christos Sync with HEAD
 1.228.2.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.230.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 11-Dec-2021  mrg remove clause 3 from all my licenses that aren't conflicting with
another copyright claim line. again. (i did this in 2008 and then
did not update all of my personal templates.)
 1.8 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.7 30-Aug-2021  riastradh compat_netbsd32: Copy out 32-bit version in nfssvc32_nsd_out.
 1.6 27-Jan-2019  pgoyette branches: 1.6.4;
Merge the [pgoyette-compat] branch
 1.5 15-Oct-2016  skrll branches: 1.5.8; 1.5.14; 1.5.16; 1.5.18;
Trailing whitespace
 1.4 01-Dec-2015  pgoyette branches: 1.4.2;
Add MODULE infrastructure to netbsd32_nfssvc.c, remove dependency on it
from netbsd32_mod.c
 1.3 05-Aug-2015  mrg branches: 1.3.2; 1.3.4;
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.2 23-Jun-2015  dholland add missing opt_nfsserver.h
 1.1 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.3.4.3 06-Nov-2015  martin Additionally pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.2
sys/compat/netbsd32/syscalls.master: revision 1.109
Don't reference netbsd32_nfssvc unless NFSSERVER is defined.
Fixes PR 49994.
add missing opt_nfsserver.h
 1.3.4.2 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.3.4.1 05-Aug-2015  riz file netbsd32_nfssvc.c was added on branch netbsd-7 on 2015-11-04 17:46:21 +0000
 1.3.2.4 05-Dec-2016  skrll Sync with HEAD
 1.3.2.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3.2.2 22-Sep-2015  skrll Sync with HEAD
 1.3.2.1 05-Aug-2015  skrll file netbsd32_nfssvc.c was added on branch nick-nhusb on 2015-09-22 12:05:55 +0000
 1.4.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.5.18.1 10-Jun-2019  christos Sync with HEAD
 1.5.16.1 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.5.14.2 03-Dec-2017  jdolecek update from HEAD
 1.5.14.1 15-Oct-2016  jdolecek file netbsd32_nfssvc.c was added on branch tls-maxphys on 2017-12-03 11:36:56 +0000
 1.5.8.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1840):

sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.7

compat_netbsd32: Copy out 32-bit version in nfssvc32_nsd_out.
 1.5.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.6.4.2 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

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

sys/compat: Memset zero before copyout.

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

sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.7

compat_netbsd32: Copy out 32-bit version in nfssvc32_nsd_out.
 1.9 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.8 24-Dec-2019  kamil Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO

PT_LWPINFO is a legacy ptrace(2) operation that was originally intended
to retrieve the thread (LWP) information inside a traced process.

It has a number of flaws and is confused with PT_LWPINFO from FreeBSD.

PT_LWPSTATUS and PT_LWPNEXT address the problems (shortly by: rename,
removal of pl_event) and introduces new features: signal context
(pl_sigpend, pl_sigmask), LWP name (pl_name), LWP TLS base address
(pl_private). The private pointer was so far missing information for
a debugger.

PT_LWPSTATUS@nnn is now shipped with core(5) files and contain LWP specific
information, so far missed in the core(5) files.

PT_LWPSTATUS retrieves LWP information for the prompted thread.
PT_LWPNEXT retrieves LWP information for the next thread, borrowing the
semantics from NetBSD specific PT_LWPINFO.

PT_LWPINFO is namespaced with __LEGACY_PT_LWPINFO and still available for
the foreseeable future, without plans of removing it.

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
 1.7 04-Jun-2019  mgorny branches: 1.7.2;
compat32: Translate userland PT_* request values into kernel codes

Currently, the compat32 passes PT_* request values to kernel functions
without translation. This works fine for low PT_* requests that happen
to have the same values both on i386 and amd64. However, for requests
higher than PT_SETFPREGS, the value passed from userland (matching i386
const) does not match the correct kernel (amd64) request. As a result,
e.g. when compat32 process calls PT_GETDBREGS, kernel actually processes
it as PT_SETSTEP.

To resolve this, introduce support for compat32 PT_* request
translation. The interface is based on PTRACE_TRANSLATE_REQUEST32 macro
that is defined to a mapping function on architectures needing it.
In case of amd64, this function maps userland i386 PT_* values into
appropriate amd64 PT_* values.

For the time being, the two additional PT_GETXMMREGS and PT_SETXMMREGS
requests are unsupported due to lack of matching free amd64 constant.
 1.6 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.5 17-Dec-2017  christos branches: 1.5.2; 1.5.4;
handle siginfo requests for ptrace32
 1.4 23-Feb-2017  kamil branches: 1.4.6; 1.4.12;
Introduce PT_GETDBREGS and PT_SETDBREGS in ptrace(2) on i386 and amd64

This interface is modeled after FreeBSD API with the usage.

This replaced previous watchpoint API. The previous one was introduced
recently in NetBSD-current and remove its spurs without any
backward-compatibility.

Design choices for Debug Register accessors:
- exec() (TRAP_EXEC event) must remove debug registers from LWP
- debug registers are only per-LWP, not per-process globally
- debug registers must not be inherited after (v)forking a process
- debug registers must not be inherited after forking a thread
- a debugger is responsible to set global watchpoints/breakpoints with the
debug registers, to achieve this PTRACE_LWP_CREATE/PTRACE_LWP_EXIT event
monitoring function is designed to be used
- debug register traps must generate SIGTRAP with si_code TRAP_DBREG
- debugger is responsible to retrieve debug register state to distinguish
the exact debug register trap (DR6 is Status Register on x86)
- kernel must not remove debug register traps after triggering a trap event
a debugger is responsible to detach this trap with appropriate PT_SETDBREGS
call (DR7 is Control Register on x86)
- debug registers must not be exposed in mcontext
- userland must not be allowed to set a trap on the kernel

Implementation notes on i386 and amd64:
- the initial state of debug register is retrieved on boot and this value is
stored in a local copy (initdbregs), this value is used to initialize dbreg
context after PT_GETDBREGS
- struct dbregs is stored in pcb as a pointer and by default not initialized
- reserved registers (DR4-DR5, DR9-DR15) are ignored

Further ideas:
- restrict this interface with securelevel

Tested on real hardware i386 (Intel Pentium IV) and amd64 (Intel i7).

This commit enables 390 debug register ATF tests in kernel/arch/x86.
All tests are passing.

This commit does not cover netbsd32 compat code. Currently other interface
PT_GET_SIGINFO/PT_SET_SIGINFO is required in netbsd32 compat code in order to
validate reliably PT_GETDBREGS/PT_SETDBREGS.

This implementation does not cover FreeBSD specific defines in their
<x86/reg.h>: DBREG_DR7_LOCAL_ENABLE, DBREG_DR7_GLOBAL_ENABLE, DBREG_DR7_LEN_1
etc. These values tend to be reinvented by each tracer on its own. GNU
Debugger (GDB) works with NetBSD debug registers after adding this patch:

--- gdb/amd64bsd-nat.c.orig 2016-02-10 03:19:39.000000000 +0000
+++ gdb/amd64bsd-nat.c
@@ -167,6 +167,10 @@ amd64bsd_target (void)

#ifdef HAVE_PT_GETDBREGS

+#ifndef DBREG_DRX
+#define DBREG_DRX(d,x) ((d)->dr[(x)])
+#endif
+
static unsigned long
amd64bsd_dr_get (ptid_t ptid, int regnum)
{


Another reason to stop introducing unpopular defines covering machine
specific register macros is that these value varies across generations of
the same CPU family.

GDB demo:
(gdb) c
Continuing.

Watchpoint 2: traceme

Old value = 0
New value = 16
main (argc=1, argv=0x7f7fff79fe30) at test.c:8
8 printf("traceme=%d\n", traceme);

(Currently the GDB interface is not reliable due to NetBSD support bugs)

Sponsored by <The NetBSD Foundation>
 1.3 15-Dec-2016  kamil branches: 1.3.2;
Add support for hardware assisted watchpoints/breakpoints API in ptrace(2)

Add new ptrace(2) calls:
- PT_COUNT_WATCHPOINTS - count the number of available hardware watchpoints
- PT_READ_WATCHPOINT - read struct ptrace_watchpoint from the kernel state
- PT_WRITE_WATCHPOINT - write new struct ptrace_watchpoint state, this
includes enabling and disabling watchpoints

The ptrace_watchpoint structure contains MI and MD parts:

typedef struct ptrace_watchpoint {
int pw_index; /* HW Watchpoint ID (count from 0) */
lwpid_t pw_lwpid; /* LWP described */
struct mdpw pw_md; /* MD fields */
} ptrace_watchpoint_t;

For example amd64 defines MD as follows:
struct mdpw {
void *md_address;
int md_condition;
int md_length;
};

These calls are protected with the __HAVE_PTRACE_WATCHPOINTS guard.

Tested on amd64, initial support added for i386 and XEN.

Sponsored by <The NetBSD Foundation>
 1.2 02-Nov-2016  pgoyette branches: 1.2.2; 1.2.4;
* Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
 1.1 19-Oct-2016  skrll PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel

Updated from the original patch in the PR by me.
 1.2.4.4 28-Aug-2017  skrll Sync with HEAD
 1.2.4.3 05-Feb-2017  skrll Sync with HEAD
 1.2.4.2 05-Dec-2016  skrll Sync with HEAD
 1.2.4.1 02-Nov-2016  skrll file netbsd32_ptrace.c was added on branch nick-nhusb on 2016-12-05 10:55:00 +0000
 1.2.2.4 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.2.2.1 02-Nov-2016  pgoyette file netbsd32_ptrace.c was added on branch pgoyette-localcount on 2016-11-04 14:49:07 +0000
 1.3.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.12.2 03-Dec-2017  jdolecek update from HEAD
 1.4.12.1 23-Feb-2017  jdolecek file netbsd32_ptrace.c was added on branch tls-maxphys on 2017-12-03 11:36:56 +0000
 1.4.6.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

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

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.4.6.1 12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #713):

sys/modules/procfs/Makefile: revision 1.4
sys/miscfs/procfs/procfs_vfsops.c: revision 1.98
bin/ps/ps.1: revision 1.108
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.32
sys/miscfs/procfs/procfs_vnops.c: revision 1.198
sys/kern/sys_ptrace_common.c: revision 1.23
sys/kern/sys_ptrace_common.c: revision 1.24
sbin/mount_procfs/mount_procfs.8: revision 1.36
sys/kern/sys_ptrace_common.c: revision 1.25
sys/kern/sys_ptrace.c: revision 1.5
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.30
sys/sys/proc.h: revision 1.342
sys/kern/sys_ptrace_common.c: revision 1.26
sys/miscfs/procfs/procfs_ctl.c: file removal
sys/kern/sys_ptrace_common.c: revision 1.27
sys/miscfs/procfs/procfs_subr.c: revision 1.109
sys/kern/sys_ptrace_common.c: revision 1.28
sys/secmodel/extensions/secmodel_extensions.c: revision 1.8
sys/kern/sys_ptrace_common.c: revision 1.29
sys/sys/ptrace.h: revision 1.62
sys/compat/netbsd32/netbsd32_signal.c: revision 1.45
share/man/man9/kauth.9: revision 1.109
sys/miscfs/procfs/files.procfs: revision 1.12
sys/compat/netbsd32/netbsd32.h: revision 1.115
sys/miscfs/procfs/procfs.h: revision 1.72
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.5
sys/kern/kern_sig.c: revision 1.337
sys/sys/kauth.h: revision 1.75
sys/sys/sysctl.h: revision 1.224
sys/kern/sys_ptrace_common.c: revision 1.30
sys/kern/sys_ptrace_common.c: revision 1.31
sys/kern/sys_ptrace_common.c: revision 1.32
sys/kern/sys_ptrace_common.c: revision 1.33
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.20
sys/kern/sys_ptrace_common.c: revision 1.34
sys/kern/sys_ptrace_common.c: revision 1.36
sys/kern/kern_proc.c: revision 1.207
sys/kern/kern_exit.c: revision 1.269
doc/TODO.ptrace: revision 1.29

Make {s,g}et{db,fp,}regs work again for PK_32 processes
XXX: pullup-8

add disgusting magic to handle compat_netbsd32 as a module.

use process_*reg32 instead of struct *reg32.

Remove the filesystem tracing feature

This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
- /proc/#/ctl from mount_procfs(8)
- P_FSTRACE note from the documentation of ps(1)
- /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
- KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
- source code file miscfs/procfs/procfs_ctl.c
- PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
- KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
- PSL_FSTRACE (0x00010000) from sys/sys/proc.h
- P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed

PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).
Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>

untangle the mess:
- factor out common code
- break each ptrace subcall to its own sub-function
.. more to come ...
- reduce ifdef ugliness by moving it up top.
- factor out PT_IO and make PT_{READ,WRITE}_{I,D} use it
- factor out PT_DUMPCORE
- factor out sendsig code
.. more to come ...

handle siginfo requests for ptrace32

ptrace: Partially undo PT_{READ,WRITE}_{I,D} and unbreak these commands

The refactored code did not work and was generating EFAULT.

Sponsored by <The NetBSD Foundation>

Merge the code back; the problem was that since we are reading/writing
to a kernel address for PT_{READ,WRITE}_{I,D} we need the kernel vmspace.
provide separate read and write functions to accomodate register functions
that need a size argument.

don't ignore error from copyout_piod

Use the proper process (the tracee) to get information about lwps and
registers and the tracer for vmspace.

Add new sysctl(3) entry: security.models.extensions.user_set_dbregs

Model this new sysctl(3) entry after "user_set_cpu_affinity" in the same
level of sysctl(3) switches.

Allow to read unconditionally Debug Registers (no change here). This is
convenient as even if a user of a debugger does not use hardware assisted
watchpoints/breakpoints, a debugger can still prompt these values to store
in an internal cache with context of registers. Reading them should have
no security concerns.

Add a paranoid MI switch that prohibits by default setting these registers
by a regular user (non-superuser). Make this switch disabled by default.
There are enough reserved bits out there to allow using them
unconditionally on hardened hosts.

Features shipped with Debug Registers are optional features in debuggers.
There is no reduction in elementary functionality.

Reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.5.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.4.1 10-Jun-2019  christos Sync with HEAD
 1.5.2.1 11-Sep-2018  pgoyette Put the ``extern struct emul'' into the netbsd32_netbsd.h header
so it doesn't have to be separately declared in each source file.

Thanks mrg@
 1.7.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.3 12-Mar-2020  pgoyette Split out the quota code from the rest of compat_netbsd32 module. This
allows loading of compat_netbsd32 on kernels that don't have ``options
QUOTA'' enabled.
 1.2 18-Jun-2019  christos Add options for quota.
 1.1 24-Dec-2018  mrg branches: 1.1.2; 1.1.6;
move rlimit and quota code into their own modules.

(netbsd32_netbsd.c should have only simple shims. anything more
than copying arguments from one args struct to the other should
not be placed in this file. still a couple more to move out.)
 1.1.6.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 24-Dec-2018  christos file netbsd32_quota.c was added on branch phil-wifi on 2019-06-10 22:07:02 +0000
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file netbsd32_quota.c was added on branch pgoyette-compat on 2018-12-26 14:01:46 +0000
 1.2 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.1 24-Dec-2018  mrg branches: 1.1.2; 1.1.6; 1.1.16;
move rlimit and quota code into their own modules.

(netbsd32_netbsd.c should have only simple shims. anything more
than copying arguments from one args struct to the other should
not be placed in this file. still a couple more to move out.)
 1.1.16.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 24-Dec-2018  christos file netbsd32_rlimit.c was added on branch phil-wifi on 2019-06-10 22:07:02 +0000
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file netbsd32_rlimit.c was added on branch pgoyette-compat on 2018-12-26 14:01:46 +0000
 1.6 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.5 30-Apr-2020  riastradh branches: 1.5.2;
Omit needless #include <sys/rnd.h>.
 1.4 26-Sep-2019  christos use size_t for counters (which are compared and set with unsigneds)
 1.3 27-Jun-2019  christos Include the right stuff so compat_netbsd32_50 compiles.
 1.2 27-Jan-2019  pgoyette branches: 1.2.4;
Merge the [pgoyette-compat] branch
 1.1 21-Mar-2018  pgoyette branches: 1.1.2;
file netbsd32_rndpseudo_50.c was initially added on branch pgoyette-compat.
 1.1.2.1 21-Mar-2018  pgoyette Split compat/rndpseudo_50.c into two pieces, one for native compat and
a second piece for compat32. Update both modules accordingly.
 1.2.4.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 27-Jan-2019  christos file netbsd32_rndpseudo_50.c was added on branch phil-wifi on 2019-06-10 22:07:02 +0000
 1.5.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.14 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.13 04-Jan-2011  pgoyette branches: 1.13.8; 1.13.12;
Fix the build breakage, at least on amd64
 1.12 04-Jan-2011  matt Make the SA support as optional as is possible.
 1.11 10-Dec-2009  matt branches: 1.11.4;
Move saemul_netbsd32 to netbsd32_sa.c and allow the KERN_SA bits to be omitted.
 1.10 21-Jan-2009  tron Revert accidental of some rogue changes which broke the build.
 1.9 20-Jan-2009  tron Include "bsd.own.mk" to get the definition of "NETBSDSRCDIR" via
"/etc/mk.conf". This fixes manual use of "make cleandir".
 1.8 20-Nov-2008  tron branches: 1.8.4;
Make it possible to compile a kernel with COMPAT_NETBSD32 but without
COMPAT_40. This fixes PR port-amd64/39967.
 1.7 15-Oct-2008  wrstuden branches: 1.7.2; 1.7.4;
Merge wrstuden-revivesa into HEAD. Catch some files that I forgot
to revive on HEAD in previous commit.
 1.6 11-May-2008  wrstuden branches: 1.6.2; 1.6.6;
Oops. These are supposed to come alive on the branch, not the head.
 1.5 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.4 18-Feb-2007  cube branches: 1.4.26; 1.4.30;
Add missing lwp syscalls. Put them all together into a new file,
netbsd32_lwp.c, and remove remaining traces of SA.

This still needs some MD (and possibly MI, depending on the chosen
solution) changes to actually work.
 1.3 09-Feb-2007  ad branches: 1.3.2;
Merge newlock2 to head.
 1.2 25-Jun-2006  yamt branches: 1.2.4; 1.2.6;
netbsd32_sacopyout: don't leak kernel stack garbage to userland.
 1.1 29-Mar-2006  cube branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.12; 1.1.14;
Implement the _lwp* and sa_* families of syscalls, using the newly
introduced hooks in the native code.
 1.1.14.4 26-Feb-2007  yamt sync with head.
 1.1.14.3 30-Dec-2006  yamt sync with head.
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 29-Mar-2006  yamt file netbsd32_sa.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:35 +0000
 1.1.12.1 13-Jul-2006  gdamore Merge from HEAD.
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 29-Mar-2006  simonb file netbsd32_sa.c was added on branch simonb-timecounters on 2006-04-22 11:38:17 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 29-Mar-2006  elad file netbsd32_sa.c was added on branch elad-kernelauth on 2006-04-19 04:01:22 +0000
 1.1.4.3 26-Jun-2006  yamt sync with head.
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 29-Mar-2006  yamt file netbsd32_sa.c was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 29-Mar-2006  tron file netbsd32_sa.c was added on branch peter-altq on 2006-03-31 09:45:13 +0000
 1.2.6.2 09-Sep-2006  rpaulo sync with head
 1.2.6.1 25-Jun-2006  rpaulo file netbsd32_sa.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:12 +0000
 1.2.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.3.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.4.30.2 11-Mar-2010  yamt sync with head
 1.4.30.1 04-May-2009  yamt sync with head.
 1.4.26.1 17-Jan-2009  mjf Sync with HEAD.
 1.6.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.6.1 19-Oct-2008  haad Sync with HEAD.
 1.6.2.3 28-Sep-2008  skrll Adapt the SA COMPAT_NETBSD32 stuff to this branch.
 1.6.2.2 11-May-2008  wrstuden Try this again, on the correct branch this time!

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.2.1 11-May-2008  wrstuden file netbsd32_sa.c was added on branch wrstuden-revivesa on 2008-05-11 00:23:34 +0000
 1.7.4.1 22-Nov-2008  snj Pull up following revision(s) (requested by tron in ticket #100):
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.148
sys/compat/netbsd32/netbsd32_sa.c: revision 1.8
Make it possible to compile a kernel with COMPAT_NETBSD32 but without
COMPAT_40. This fixes PR port-amd64/39967.
 1.7.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.4.2 20-Nov-2008  tron Make it possible to compile a kernel with COMPAT_NETBSD32 but without
COMPAT_40. This fixes PR port-amd64/39967.
 1.8.4.1 20-Nov-2008  tron file netbsd32_sa.c was added on branch christos-time_t on 2008-11-20 11:56:41 +0000
 1.11.4.1 05-Mar-2011  rmind sync with head
 1.13.12.1 24-Feb-2012  mrg sync to -current.
 1.13.8.1 17-Apr-2012  yamt sync with head
 1.7 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.6 10-Dec-2009  matt branches: 1.6.12; 1.6.16;
Move saemul_netbsd32 to netbsd32_sa.c and allow the KERN_SA bits to be omitted.
 1.5 15-Oct-2008  wrstuden branches: 1.5.8;
Merge wrstuden-revivesa into HEAD. Catch some files that I forgot
to revive on HEAD in previous commit.
 1.4 11-May-2008  wrstuden branches: 1.4.2; 1.4.6;
Oops. These are supposed to come alive on the branch, not the head.
 1.3 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.2 18-Feb-2007  cube branches: 1.2.26; 1.2.30;
Add missing lwp syscalls. Put them all together into a new file,
netbsd32_lwp.c, and remove remaining traces of SA.

This still needs some MD (and possibly MI, depending on the chosen
solution) changes to actually work.
 1.1 29-Mar-2006  cube branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.20; 1.1.26;
Implement the _lwp* and sa_* families of syscalls, using the newly
introduced hooks in the native code.
 1.1.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 29-Mar-2006  rpaulo file netbsd32_sa.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:12 +0000
 1.1.14.3 26-Feb-2007  yamt sync with head.
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 29-Mar-2006  yamt file netbsd32_sa.h was added on branch yamt-lazymbuf on 2006-06-21 14:59:35 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 29-Mar-2006  simonb file netbsd32_sa.h was added on branch simonb-timecounters on 2006-04-22 11:38:17 +0000
 1.1.6.2 19-Apr-2006  elad sync with head.
 1.1.6.1 29-Mar-2006  elad file netbsd32_sa.h was added on branch elad-kernelauth on 2006-04-19 04:01:22 +0000
 1.1.4.2 11-Apr-2006  yamt sync files somehow mis-tagged by yamt-pdpolicy-base2.
 1.1.4.1 29-Mar-2006  yamt file netbsd32_sa.h was added on branch yamt-pdpolicy on 2006-04-11 12:20:52 +0000
 1.1.2.2 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.1.2.1 29-Mar-2006  tron file netbsd32_sa.h was added on branch peter-altq on 2006-03-31 09:45:13 +0000
 1.2.30.2 11-Mar-2010  yamt sync with head
 1.2.30.1 04-May-2009  yamt sync with head.
 1.2.26.1 17-Jan-2009  mjf Sync with HEAD.
 1.4.6.1 19-Oct-2008  haad Sync with HEAD.
 1.4.2.3 28-Sep-2008  skrll Adapt the SA COMPAT_NETBSD32 stuff to this branch.
 1.4.2.2 11-May-2008  wrstuden Try this again, on the correct branch this time!

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

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.4.2.1 11-May-2008  wrstuden file netbsd32_sa.h was added on branch wrstuden-revivesa on 2008-05-11 00:23:35 +0000
 1.5.8.2 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD. Catch some files that I forgot
to revive on HEAD in previous commit.
 1.5.8.1 15-Oct-2008  wrstuden file netbsd32_sa.h was added on branch christos-time_t on 2008-10-15 06:52:39 +0000
 1.6.16.1 24-Feb-2012  mrg sync to -current.
 1.6.12.1 17-Apr-2012  yamt sync with head
 1.20 20-Sep-2019  kamil Validate usec ranges in netbsd32___select50()

Later in the code selcommon() checks for proper timespec, check only
correct usec of timeval before type conversions.
 1.19 23-Apr-2010  rmind branches: 1.19.60;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.18 11-Nov-2009  rmind branches: 1.18.2; 1.18.4;
- selcommon/pollcommon: drop redundant l argument.
- Use cached curlwp->l_fd, instead of p->p_fd.
- Inline selscan/pollscan.
 1.17 29-Mar-2009  christos Move the internal poll/select related API's to use timespec instead
of timeval (rides the uvm bump).
 1.16 11-Jan-2009  christos branches: 1.16.2;
merge christos-time_t
 1.15 29-May-2008  mrg branches: 1.15.6; 1.15.12;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.14 20-Dec-2007  dsl branches: 1.14.6; 1.14.8; 1.14.10; 1.14.12;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.13 08-Dec-2007  dsl branches: 1.13.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.12 18-Mar-2007  dsl branches: 1.12.8; 1.12.10; 1.12.18;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.11 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.10 04-Mar-2007  christos branches: 1.10.2; 1.10.4; 1.10.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 11-Dec-2005  christos branches: 1.9.26;
merge ktrace-lwp.
 1.8 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.7 09-Jul-2005  cube Implement pselect(2) and pollts(2).
 1.6 09-Jul-2005  cube Make netbsd32_select() use selcommon() instead of a gross copy/paste of
the old sys_select() code.
 1.5 26-Oct-2003  christos branches: 1.5.16;
Don't do the tsleep dance if timo is 0; simplify the code.
 1.4 18-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.2 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4; 1.1.6;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.3 11-Nov-2002  nathanw Catch up to -current
 1.1.4.2 23-Aug-2002  petrov lwpification.
 1.1.4.1 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_select.c was added on branch thorpej_scsipi on 2001-02-11 19:14:16 +0000
 1.4.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.3 21-Jan-2008  yamt sync with head
 1.5.16.2 03-Sep-2007  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.9.26.2 24-Mar-2007  yamt sync with head.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.6.2 29-Mar-2007  reinoud Pullup to -current
 1.10.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.10.4.1 11-Jul-2007  mjf Sync with head.
 1.10.2.1 10-Apr-2007  ad Sync with head.
 1.12.18.1 26-Dec-2007  ad Sync with head.
 1.12.10.1 09-Jan-2008  matt sync with HEAD
 1.12.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.13.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.10.3 11-Aug-2010  yamt sync with head.
 1.14.10.2 11-Mar-2010  yamt sync with head
 1.14.10.1 04-May-2009  yamt sync with head.
 1.14.8.1 04-Jun-2008  yamt sync with head
 1.14.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.14.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.12.2 04-Jan-2009  christos add new syscalls.
 1.15.12.1 29-May-2008  christos file netbsd32_select.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.15.6.2 28-Apr-2009  skrll Sync with HEAD.
 1.15.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.16.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.4.1 30-May-2010  rmind sync with head
 1.18.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12 03-Feb-2019  thorpej Implement support for "pshared" POSIX semaphores.

Fixes lib/53273 (and Firefox's multi-process tab feature).
 1.11 19-Sep-2014  matt branches: 1.11.20;
#include <sys/condvar.h>
 1.10 10-Mar-2012  joerg branches: 1.10.2;
P1003_1B_SEMAPHORE is no longer optional.
 1.9 08-Mar-2012  joerg Implement sem_timedwait.
 1.8 14-Nov-2008  ad branches: 1.8.4; 1.8.18; 1.8.22;
Replace semid_t with intptr_t. No function change. This is a libc/kernel
private interface and so the name change should not affect any third
party code.
 1.7 29-Apr-2008  martin branches: 1.7.2; 1.7.6; 1.7.8;
Convert to new 2 clause license
 1.6 20-Dec-2007  dsl branches: 1.6.6; 1.6.8; 1.6.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.5 10-Sep-2007  cube branches: 1.5.8; 1.5.12;
Remove 3rd clause and my name from all the licences which were only in my
name.
 1.4 18-Mar-2007  dsl branches: 1.4.8; 1.4.10;
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 09-Feb-2007  ad branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10;
Merge newlock2 to head.
 1.1 05-Mar-2006  cube branches: 1.1.2; 1.1.8; 1.1.14; 1.1.18; 1.1.20;
Implement the ksem_* family of syscalls.
 1.1.20.2 09-Sep-2006  rpaulo sync with head
 1.1.20.1 05-Mar-2006  rpaulo file netbsd32_sem.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:46:12 +0000
 1.1.18.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.1.14.6 21-Jan-2008  yamt sync with head
 1.1.14.5 27-Oct-2007  yamt sync with head.
 1.1.14.4 03-Sep-2007  yamt sync with head.
 1.1.14.3 26-Feb-2007  yamt sync with head.
 1.1.14.2 21-Jun-2006  yamt sync with head.
 1.1.14.1 05-Mar-2006  yamt file netbsd32_sem.c was added on branch yamt-lazymbuf on 2006-06-21 14:59:35 +0000
 1.1.8.2 22-Apr-2006  simonb Sync with head.
 1.1.8.1 05-Mar-2006  simonb file netbsd32_sem.c was added on branch simonb-timecounters on 2006-04-22 11:38:17 +0000
 1.1.2.2 05-Mar-2006  cube Implement the ksem_* family of syscalls.
 1.1.2.1 05-Mar-2006  cube file netbsd32_sem.c was added on branch yamt-pdpolicy on 2006-03-05 01:28:21 +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.2 09-Oct-2007  ad 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.10.2 09-Jan-2008  matt sync with HEAD
 1.4.10.1 06-Nov-2007  matt sync with HEAD
 1.4.8.1 02-Oct-2007  joerg Sync with HEAD.
 1.5.12.1 02-Jan-2008  bouyer Sync with HEAD
 1.5.8.1 26-Dec-2007  ad Sync with head.
 1.6.10.2 04-May-2009  yamt sync with head.
 1.6.10.1 16-May-2008  yamt 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.7.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.7.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.7.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.8.22.1 11-Mar-2012  mrg sync to latest -current
 1.8.18.1 17-Apr-2012  yamt sync with head
 1.8.4.2 14-Nov-2008  ad Replace semid_t with intptr_t. No function change. This is a libc/kernel
private interface and so the name change should not affect any third
party code.
 1.8.4.1 14-Nov-2008  ad file netbsd32_sem.c was added on branch christos-time_t on 2008-11-14 15:49:21 +0000
 1.10.2.1 03-Dec-2017  jdolecek update from HEAD
 1.11.20.1 10-Jun-2019  christos Sync with HEAD
 1.55 22-Nov-2024  mlelstv Crude patch to allow building and loading of compat_16 and compat_netbsd32_16 code
on aarch64.
 1.54 29-Apr-2024  mlelstv branches: 1.54.2;
In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Needs pullup to netbsd-10.
 1.53 06-Nov-2021  thorpej branches: 1.53.4;
COMPAT_NETBSD32 is all about running the 32-bit flavor of native
binaries on a 64-bit platform[*], as such:
- Make the logic about which "sendsig" flavor to call MI (as it is in the
native 64-bit environment) and follow the same rules as the native 32-bit
environment.
- Make COMPAT_NETBSD32 x COMPAT_16 work the same as it would in the
native 32-bit environment by providing a netbsd32_sendsig_sigcontext_16_hook,
rather than overriding the entire sendsig logic with a netbsd32_sendsig_hook.
- In netbsd32___sigaction_sigtramp(), make sure the compat_netbsd32_16
module is loaded if the trampoline version specifies a sigcontext style
handler, otherwise return EINVAL so that libc can try again with siginfo
style.

[*] ...except for arm32, which uses it to mean "run 32-bit OABI binaries
from the 32-bit EABI environment". Doing it this way was arguably a mistake,
but we are stuck with it for now, so support it by providing a machine-
dependent override for netbsd32_sendsig() that also disables the corresponding
logic in netbsd32___sigaction_sigtramp().

Fixes PR kern/56487.
 1.52 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.51 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.50 18-Nov-2019  rin branches: 1.50.8;
TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.

Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
 1.49 18-Nov-2019  rin When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).

- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9
 1.48 18-Nov-2019  rin Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.

Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
 1.47 18-Nov-2019  rin Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9
 1.46 18-Nov-2019  rin Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
 1.45 17-Dec-2017  christos branches: 1.45.4; 1.45.8;
handle siginfo requests for ptrace32
 1.44 06-Dec-2017  christos disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
trace records, the only record that we can't parse is that one :-)
XXX: pullup-8
 1.43 18-Sep-2016  christos branches: 1.43.8;
remove multiple default.
 1.42 18-Sep-2016  christos more ifdef KTRACE
fix wraps
 1.41 17-Sep-2016  christos deal with not having KTRACE
 1.40 13-Sep-2016  martin Allow emulations to override the creation of ktrace records for posting
signals. In compat_netbsd32 use this to write the 32bit version of
the records, so a 32bit userland kdump is happy.
 1.39 20-Jun-2015  martin branches: 1.39.2;
Implement modctl, sigqueinfo and mq_*
 1.38 24-Jan-2014  christos branches: 1.38.6;
sigaction until 1.4 had an int sigmask, don't trash the stack.
 1.37 19-Feb-2012  rmind branches: 1.37.2; 1.37.4;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.36 18-Nov-2011  christos branches: 1.36.4;
add a copyin function for sigset so that we can use sigtimedwait1 from
emulations.
 1.35 03-Feb-2011  joerg branches: 1.35.4;
Explicitly initialize ucontext before calling getmcontext.
 1.34 23-Apr-2010  rmind branches: 1.34.2; 1.34.4;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.33 19-Jan-2010  pooka branches: 1.33.2; 1.33.4;
A few more instances of __sigtimedwait1 -> sigtimedwait1
 1.32 11-Jan-2009  christos merge christos-time_t
 1.31 15-Oct-2008  wrstuden branches: 1.31.2; 1.31.4; 1.31.8;
Merge wrstuden-revivesa into HEAD.
 1.30 29-May-2008  mrg branches: 1.30.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.29 24-Apr-2008  ad branches: 1.29.2; 1.29.4;
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.28 20-Dec-2007  dsl branches: 1.28.6; 1.28.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.27 08-Dec-2007  dsl branches: 1.27.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.26 08-Oct-2007  ad branches: 1.26.6;
LOCK_ASSERT -> KASSERT
 1.25 16-Jun-2007  dsl branches: 1.25.6; 1.25.8; 1.25.10;
Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
 1.24 21-May-2007  christos rename si_sigval -> si_value to match POSIX RTS.
 1.23 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.22 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.21 04-Mar-2007  christos branches: 1.21.2; 1.21.4; 1.21.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 19-Feb-2007  cube Make netbsd32_{get,set}ucontext and associated functions
{get,set}ucontext32 look like their native counterparts again after
newlock2 merge. This avoids entering sigprocmask1 without the proc mutex
held...
 1.19 09-Feb-2007  ad branches: 1.19.2;
Merge newlock2 to head.
 1.18 08-Nov-2006  drochner -SUS says that a successful call to setcontext(2) does not return. This
implies that _UC_CPU must be set in the context passed. Check for this
and return EINVAL if not; this gives a cheap test for corrupted
ucontexts eg on a signal handler stack which would go unnoticed otherwise.
-Don't ckeck for NULL ucontext pointers explicitely. This is an error,
except in the swapcontext() case where it can be easily caught in
userland.
 1.17 15-Mar-2006  cube branches: 1.17.10; 1.17.12;
SA introduce a new case of siginfo structure. Be ready for it when the
time comes to support SA in COMPAT_NETBSD32 (which is soon).
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10;
merge ktrace-lwp.
 1.15 27-Sep-2005  chs make this compile again.
 1.14 24-Sep-2005  christos make the siginfo converters static and comment out the one that is not used.
 1.13 24-Sep-2005  christos include new compat siginfo header.
 1.12 13-Sep-2005  christos make this compile again.
 1.11 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.10 23-Jul-2005  cube Implement __sigtimedwait(2).
 1.9 02-Jun-2005  drochner branches: 1.9.2;
in siginfo conversion functions, declare the source operand as "const"
 1.8 26-Feb-2005  perry nuke trailing whitespace
 1.7 13-Oct-2003  fvdl branches: 1.7.8; 1.7.10;
Implement 32bit get/setcontext entry points.
 1.6 18-Jan-2003  thorpej branches: 1.6.2;
Merge the nathanw_sa branch.
 1.5 27-Nov-2002  atatat Complete the rename: s/sa_/<compat>_sa_/g

Also tweak the darwin siginfo stuff to avoid the same type of collision.
 1.4 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.3 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

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

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.2 13-Nov-2001  lukem branches: 1.2.8;
add RCSIDs (including regeneration of files as appropriate)
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4; 1.1.6;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.6 11-Dec-2002  thorpej Sync with HEAD.
 1.1.4.5 20-Nov-2002  petrov lwpify netbsd32___sigaction_sigtramp.
 1.1.4.4 11-Nov-2002  nathanw Catch up to -current
 1.1.4.3 23-Aug-2002  petrov lwpification.
 1.1.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_signal.c was added on branch thorpej_scsipi on 2001-02-11 19:14:16 +0000
 1.2.8.1 15-Jul-2002  gehenna catch up with -current.
 1.6.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.9.2.6 21-Jan-2008  yamt sync with head
 1.9.2.5 27-Oct-2007  yamt sync with head.
 1.9.2.4 03-Sep-2007  yamt sync with head.
 1.9.2.3 26-Feb-2007  yamt sync with head.
 1.9.2.2 30-Dec-2006  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.16.10.1 19-Apr-2006  elad sync with head.
 1.16.8.1 01-Apr-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.17.12.1 10-Dec-2006  yamt sync with head.
 1.17.10.4 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.17.10.3 18-Nov-2006  ad Sync with head.
 1.17.10.2 17-Nov-2006  ad Checkpoint work in progress.
 1.17.10.1 21-Oct-2006  ad Checkpoint work in progress on locking and per-LWP signals. Very much a
a work in progress and there is still a lot to do.
 1.19.2.3 24-Mar-2007  yamt sync with head.
 1.19.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.19.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.21.6.2 29-Mar-2007  reinoud Pullup to -current
 1.21.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.21.4.1 11-Jul-2007  mjf Sync with head.
 1.21.2.4 22-Aug-2007  ad Make it compile.
 1.21.2.3 15-Jul-2007  ad Sync with head.
 1.21.2.2 27-May-2007  ad Sync with head.
 1.21.2.1 10-Apr-2007  ad Sync with head.
 1.25.10.1 14-Oct-2007  yamt sync with head.
 1.25.8.2 09-Jan-2008  matt sync with HEAD
 1.25.8.1 06-Nov-2007  matt sync with HEAD
 1.25.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.25.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.26.6.1 26-Dec-2007  ad Sync with head.
 1.27.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.28.8.2 04-Jun-2008  yamt sync with head
 1.28.8.1 18-May-2008  yamt sync with head.
 1.28.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.28.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.4.6 28-Sep-2008  skrll Adapt the SA COMPAT_NETBSD32 stuff to this branch.
 1.29.4.5 25-Sep-2008  skrll Typo in comment and define 'p' in getucontext32_sa.
 1.29.4.4 27-Jun-2008  wrstuden Add getucontext32_sa() and getucontext_sa(), and use them. They
are sa-specific versions of getucontext{,32}(). The main difference
is that they do NOT require the p_lock be held. We report an empty
signal mask, both to avoid needing p_lock and because the process
signal mask is almost always 0 for SA.
 1.29.4.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.4.2 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.29.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.29.2.3 11-Aug-2010  yamt sync with head.
 1.29.2.2 11-Mar-2010  yamt sync with head
 1.29.2.1 04-May-2009  yamt sync with head.
 1.30.4.1 19-Oct-2008  haad Sync with HEAD.
 1.31.8.2 04-Jan-2009  christos add new syscalls.
 1.31.8.1 15-Oct-2008  christos file netbsd32_signal.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.31.4.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by joerg in ticket #1556):
sys/compat/irix/irix_signal.c: revision 1.56
sys/compat/svr4/svr4_signal.c: revision 1.65
sys/compat/netbsd32/netbsd32_signal.c: revision 1.35
sys/kern/sys_sig.c: revision 1.31
Explicitly initialize ucontext before calling getmcontext.
 1.31.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.33.4.2 05-Mar-2011  rmind sync with head
 1.33.4.1 30-May-2010  rmind sync with head
 1.33.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.34.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.35.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.35.4.1 17-Apr-2012  yamt sync with head
 1.36.4.1 24-Feb-2012  mrg sync to -current.
 1.37.4.1 18-May-2014  rmind sync with head
 1.37.2.2 03-Dec-2017  jdolecek update from HEAD
 1.37.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.6.2 05-Oct-2016  skrll Sync with HEAD
 1.38.6.1 22-Sep-2015  skrll Sync with HEAD
 1.39.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.43.8.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.43.8.1 12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #713):

sys/modules/procfs/Makefile: revision 1.4
sys/miscfs/procfs/procfs_vfsops.c: revision 1.98
bin/ps/ps.1: revision 1.108
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.32
sys/miscfs/procfs/procfs_vnops.c: revision 1.198
sys/kern/sys_ptrace_common.c: revision 1.23
sys/kern/sys_ptrace_common.c: revision 1.24
sbin/mount_procfs/mount_procfs.8: revision 1.36
sys/kern/sys_ptrace_common.c: revision 1.25
sys/kern/sys_ptrace.c: revision 1.5
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.30
sys/sys/proc.h: revision 1.342
sys/kern/sys_ptrace_common.c: revision 1.26
sys/miscfs/procfs/procfs_ctl.c: file removal
sys/kern/sys_ptrace_common.c: revision 1.27
sys/miscfs/procfs/procfs_subr.c: revision 1.109
sys/kern/sys_ptrace_common.c: revision 1.28
sys/secmodel/extensions/secmodel_extensions.c: revision 1.8
sys/kern/sys_ptrace_common.c: revision 1.29
sys/sys/ptrace.h: revision 1.62
sys/compat/netbsd32/netbsd32_signal.c: revision 1.45
share/man/man9/kauth.9: revision 1.109
sys/miscfs/procfs/files.procfs: revision 1.12
sys/compat/netbsd32/netbsd32.h: revision 1.115
sys/miscfs/procfs/procfs.h: revision 1.72
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.5
sys/kern/kern_sig.c: revision 1.337
sys/sys/kauth.h: revision 1.75
sys/sys/sysctl.h: revision 1.224
sys/kern/sys_ptrace_common.c: revision 1.30
sys/kern/sys_ptrace_common.c: revision 1.31
sys/kern/sys_ptrace_common.c: revision 1.32
sys/kern/sys_ptrace_common.c: revision 1.33
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.20
sys/kern/sys_ptrace_common.c: revision 1.34
sys/kern/sys_ptrace_common.c: revision 1.36
sys/kern/kern_proc.c: revision 1.207
sys/kern/kern_exit.c: revision 1.269
doc/TODO.ptrace: revision 1.29

Make {s,g}et{db,fp,}regs work again for PK_32 processes
XXX: pullup-8

add disgusting magic to handle compat_netbsd32 as a module.

use process_*reg32 instead of struct *reg32.

Remove the filesystem tracing feature

This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
- /proc/#/ctl from mount_procfs(8)
- P_FSTRACE note from the documentation of ps(1)
- /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
- KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
- source code file miscfs/procfs/procfs_ctl.c
- PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
- KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
- PSL_FSTRACE (0x00010000) from sys/sys/proc.h
- P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed

PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).
Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>

untangle the mess:
- factor out common code
- break each ptrace subcall to its own sub-function
.. more to come ...
- reduce ifdef ugliness by moving it up top.
- factor out PT_IO and make PT_{READ,WRITE}_{I,D} use it
- factor out PT_DUMPCORE
- factor out sendsig code
.. more to come ...

handle siginfo requests for ptrace32

ptrace: Partially undo PT_{READ,WRITE}_{I,D} and unbreak these commands

The refactored code did not work and was generating EFAULT.

Sponsored by <The NetBSD Foundation>

Merge the code back; the problem was that since we are reading/writing
to a kernel address for PT_{READ,WRITE}_{I,D} we need the kernel vmspace.
provide separate read and write functions to accomodate register functions
that need a size argument.

don't ignore error from copyout_piod

Use the proper process (the tracee) to get information about lwps and
registers and the tracer for vmspace.

Add new sysctl(3) entry: security.models.extensions.user_set_dbregs

Model this new sysctl(3) entry after "user_set_cpu_affinity" in the same
level of sysctl(3) switches.

Allow to read unconditionally Debug Registers (no change here). This is
convenient as even if a user of a debugger does not use hardware assisted
watchpoints/breakpoints, a debugger can still prompt these values to store
in an internal cache with context of registers. Reading them should have
no security concerns.

Add a paranoid MI switch that prohibits by default setting these registers
by a regular user (non-superuser). Make this switch disabled by default.
There are enough reserved bits out there to allow using them
unconditionally on hardened hosts.

Features shipped with Debug Registers are optional features in debuggers.
There is no reduction in elementary functionality.

Reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.45.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.45.8.1 19-Nov-2019  martin Pull up following revision(s) (requested by rin in ticket #456):

sys/compat/netbsd32/netbsd32_signal.c: revision 1.46
sys/compat/netbsd32/netbsd32_signal.c: revision 1.47
sys/compat/netbsd32/netbsd32_signal.c: revision 1.48
sys/compat/netbsd32/netbsd32_signal.c: revision 1.49
sys/compat/netbsd32/netbsd32_signal.c: revision 1.50

Belatedly catch up with kern_sig.c rev 1.358:
Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.
With some minor changes:
- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9

Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9

When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).
- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9

TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
 1.45.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.53.4.1 26-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #989):

sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.6
sys/compat/netbsd32/netbsd32_signal.c: revision 1.54

In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Enable compat sigreturn system call.

netbsd32_compat_16.c: Fix whitespace.
No functional change intended.
 1.54.2.1 02-Aug-2025  perseant Sync with HEAD
 1.56 19-Jan-2021  simonb The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.55 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.54 18-Jan-2021  simonb s/u_intN_t/uintN_t/
 1.53 28-Sep-2019  mlelstv branches: 1.53.8;
signed/unsigned comparison.
 1.52 27-Sep-2019  mlelstv Ensure failure if resid goes negative.
 1.51 27-Sep-2019  mlelstv signed/unsigned mismatch.
 1.50 26-Sep-2019  christos use size_t for counters (which are compared and set with unsigneds)
 1.49 14-Nov-2018  hannken branches: 1.49.4;
Apply the recent fixes to {send,recv}mmsg() to their compat variants.
 1.48 12-Nov-2018  maxv Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.47 13-May-2018  christos branches: 1.47.2;
PR/53280: Andreas Gustafsson: Fix panic in the fdpass test. This is probably
the only 32 bit binary in the tests...
 1.46 10-May-2018  christos add {send,recv}mmsg
 1.45 03-May-2018  christos Fix COMPAT_NETBSD32 cmsg handling:

1. alignment was wrong for > 1 message
2. macros were doing incorrect pointer comparisons, fortunately ending
the iteration early after the fists cmsg instead of crashing.
3. don't output 32 bit ktrace records for cmsg. 32 bit programs running
under emulation on 64 bit systems should produce 64 bit ktrace records
so that the native ktrace can handle the records; remove extra arguments
that are now not needed (the 32 bit msghdr).
4. output the correct type for cmsg trace records.
5. output all the cmsg records in traces instead of just the first one.

Welcome to 8.99.15 because of the argument removal.

XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR
macros...
 1.44 13-Sep-2016  martin branches: 1.44.8; 1.44.14;
Make the ktrace record written by do_sys_sendmsg/do_sys_recvmsg overridable
by the caller. Use this in compat_netbsd32 to log the 32bit version, so
the 32bit userland kdump is happy.
 1.43 08-Sep-2016  martin recvmsg: ktrace the 32bit message header, not the native (64bit) version.
 1.42 22-Jul-2015  maxv Memory leak, triggerable from an unprivileged user.
 1.41 18-Aug-2012  martin branches: 1.41.2; 1.41.14; 1.41.16;
Do not use a userland pointer, but the copied-in kernel version instead.
While there, reorder loop end condition for efficency.
Fixes net/fdpass tests on all archs with separate kernel/userland VA.
 1.40 30-Jul-2012  matt Make SCM_RIGHTS work correctly. (make sure to advance m if we've completely
dealt with, the next mbuf (if any) comes into play).
 1.39 20-Jan-2012  joerg branches: 1.39.2;
Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.38 13-Jan-2012  joerg Reduce difference between recvfrom/recvmsg for netbsd32 and the native
version. This fixes the bug of lost file descriptors when the control
space is not large enough.
 1.37 23-Apr-2010  rmind branches: 1.37.8; 1.37.12;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.36 22-Jul-2009  njoly branches: 1.36.2; 1.36.4;
Make compat netbsd32 sendmsg follow the native version by allowing
empty messages. This let unfdpass regression test work as expected.
 1.35 15-Jun-2009  njoly Make netbsd32 sendmsg(2), do not use an uninitialised value for
fetching iovec structures.
While here, sync recvmsg(2) to avoid some unneeded casts.
 1.34 17-Dec-2008  cegger branches: 1.34.2; 1.34.4;
kill MALLOC and FREE macros.
 1.33 24-Jun-2008  ad branches: 1.33.4; 1.33.12;
Replace references to getsock/getvnode.
 1.32 29-May-2008  mrg branches: 1.32.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.31 21-Mar-2008  ad branches: 1.31.2; 1.31.4; 1.31.6;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.30 20-Dec-2007  dsl branches: 1.30.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.29 08-Dec-2007  dsl branches: 1.29.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.28 04-Dec-2007  dsl Remove all the __P
 1.27 15-Aug-2007  ad branches: 1.27.2; 1.27.8; 1.27.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.26 01-Jun-2007  dsl branches: 1.26.2; 1.26.6;
Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.
 1.25 31-May-2007  christos message size == 0 is valid. From Markus Mayer
 1.24 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.23 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.22 04-Mar-2007  christos branches: 1.22.2; 1.22.4; 1.22.6;
fix fallout from caddr_t changes.
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 09-Feb-2007  ad branches: 1.20.2;
Merge newlock2 to head.
 1.19 19-Mar-2006  matt branches: 1.19.8;
More variable sized MALLOC -> malloc changes.
 1.18 18-Mar-2006  matt MALLOC -> malloc
 1.17 01-Mar-2006  yamt branches: 1.17.2; 1.17.4; 1.17.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.16 11-Dec-2005  christos branches: 1.16.2; 1.16.4; 1.16.6;
merge ktrace-lwp.
 1.15 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.14 31-May-2005  christos branches: 1.14.2;
- add const
- avoid shadowed variables.
 1.13 26-Feb-2005  perry nuke trailing whitespace
 1.12 21-Oct-2003  fvdl branches: 1.12.8; 1.12.10;
Fix some int vs. NULL comparisons.
 1.11 29-Jun-2003  fvdl branches: 1.11.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.10 29-Jun-2003  martin struct proc * -> struct lwp *
 1.9 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.8 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.7 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.6 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.5 17-Jul-2001  jdolecek Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.
 1.4 25-Jun-2001  jdolecek branches: 1.4.2;
Back off the sendit()/recvit() change, some have problems with it
 1.3 25-Jun-2001  jdolecek Add 'kernsa' parameter for sendit()/recvit(); if nonzero, msg->msg_name
is supposed to point directly to struct mbuf or struct sockaddr in kernel
space as appropriate, rather than being a pointer to memory in userland.

This is to be used by compat/* when emulation needs to wrap
send{to|msg}(2)/recv{from|msg}(2) and modify the passed struct
sockaddr.
 1.2 30-May-2001  mrg use _KERNEL_OPT.
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.6 11-Nov-2002  nathanw Catch up to -current
 1.1.4.5 23-Aug-2002  petrov lwpification.
 1.1.4.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_socket.c was added on branch thorpej_scsipi on 2001-02-11 19:14:17 +0000
 1.4.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 03-Aug-2001  lukem update to -current
 1.11.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.11.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.3 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.11.2.2 03-Aug-2004  skrll Sync with HEAD
 1.11.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.12.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.8.1 29-Apr-2005  kent sync with -current
 1.14.2.6 24-Mar-2008  yamt sync with head.
 1.14.2.5 21-Jan-2008  yamt sync with head
 1.14.2.4 07-Dec-2007  yamt sync with head
 1.14.2.3 03-Sep-2007  yamt sync with head.
 1.14.2.2 26-Feb-2007  yamt sync with head.
 1.14.2.1 21-Jun-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.16.2.1 18-Feb-2006  yamt adapt the rest of MI code.
 1.17.6.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.17.4.1 19-Apr-2006  elad sync with head.
 1.17.2.1 01-Apr-2006  yamt sync with head.
 1.19.8.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.20.2.2 24-Mar-2007  yamt sync with head.
 1.20.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.6.2 29-Mar-2007  reinoud Pullup to -current
 1.22.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.22.4.1 11-Jul-2007  mjf Sync with head.
 1.22.2.3 20-Aug-2007  ad Sync with HEAD.
 1.22.2.2 09-Jun-2007  ad Sync with head.
 1.22.2.1 10-Apr-2007  ad Sync with head.
 1.26.6.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.26.6.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.26.2.1 03-Sep-2007  skrll Sync with HEAD.
 1.27.10.2 26-Dec-2007  ad Sync with head.
 1.27.10.1 08-Dec-2007  ad Sync with head.
 1.27.8.2 27-Dec-2007  mjf Sync with HEAD.
 1.27.8.1 08-Dec-2007  mjf Sync with HEAD.
 1.27.2.1 09-Jan-2008  matt sync with HEAD
 1.29.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.30.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.30.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.30.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.31.6.4 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.31.6.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.31.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.31.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.31.4.4 11-Aug-2010  yamt sync with head.
 1.31.4.3 19-Aug-2009  yamt sync with head.
 1.31.4.2 20-Jun-2009  yamt sync with head
 1.31.4.1 04-May-2009  yamt sync with head.
 1.31.2.1 04-Jun-2008  yamt sync with head
 1.32.2.1 27-Jun-2008  simonb Sync with head.
 1.33.12.1 09-Jun-2010  matt Fix socket passing in netbsd32 compat. unfdpasses and incoming ssh
interactive session now work.
 1.33.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.4.1 23-Jul-2009  jym Sync with HEAD.
 1.34.2.2 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.34.2.1 17-Dec-2008  cegger file netbsd32_socket.c was added on branch christos-time_t on 2008-12-17 20:51:35 +0000
 1.36.4.1 30-May-2010  rmind sync with head
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.37.12.1 18-Feb-2012  mrg merge to -current.
 1.37.8.2 30-Oct-2012  yamt sync with head
 1.37.8.1 17-Apr-2012  yamt sync with head
 1.39.2.3 21-Apr-2016  martin Pull up following revision(s) (requested by christos in ticket #1378):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.39.2.2 18-Aug-2012  riz branches: 1.39.2.2.4; 1.39.2.2.6;
Pull up following revision(s) (requested by martin in ticket #510):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.41
Do not use a userland pointer, but the copied-in kernel version instead.
While there, reorder loop end condition for efficency.
Fixes net/fdpass tests on all archs with separate kernel/userland VA.
 1.39.2.1 30-Jul-2012  martin Pull up following revision(s) (requested by matt in ticket #452):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.40
Make SCM_RIGHTS work correctly. (make sure to advance m if we've completely
dealt with, the next mbuf (if any) comes into play).
 1.39.2.2.6.1 21-Apr-2016  martin Pull up following revision(s) (requested by christos in ticket #1378):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.39.2.2.4.1 21-Apr-2016  martin Pull up following revision(s) (requested by christos in ticket #1378):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.41.16.2 05-Oct-2016  skrll Sync with HEAD
 1.41.16.1 22-Sep-2015  skrll Sync with HEAD
 1.41.14.2 21-Nov-2018  martin Pull up following revision(s) (requested by maxv in ticket #1652):

sys/compat/netbsd32/netbsd32_socket.c: revision 1.48 (via patch)

Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.41.14.1 08-Aug-2015  martin branches: 1.41.14.1.2; 1.41.14.1.6;
Pull up following revision(s) (requested by maxv in ticket #941):
sys/compat/netbsd32/netbsd32_socket.c: revision 1.42
Memory leak, triggerable from an unprivileged user.
 1.41.14.1.6.1 21-Nov-2018  martin Pull up following revision(s) (requested by maxv in ticket #1652):

sys/compat/netbsd32/netbsd32_socket.c: revision 1.48 (via patch)

Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.41.14.1.2.1 21-Nov-2018  martin Pull up following revision(s) (requested by maxv in ticket #1652):

sys/compat/netbsd32/netbsd32_socket.c: revision 1.48 (via patch)

Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.41.2.1 03-Dec-2017  jdolecek update from HEAD
 1.44.14.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.44.14.1 21-May-2018  pgoyette Sync with HEAD
 1.44.8.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1833):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.44.8.1 13-Nov-2018  snj Pull up following revision(s) (requested by maxv in ticket #1093):
sys/compat/netbsd32/netbsd32_socket.c: 1.48
Fix inverted logic, which leads to buffer overflow. Detected by kASan.
 1.47.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.47.2.1 10-Jun-2019  christos Sync with HEAD
 1.49.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1489):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.232
sys/compat/netbsd32/netbsd32_socket.c: revision 1.56
sys/compat/netbsd32/netbsd32_conv.h: revision 1.45
sys/compat/netbsd32/netbsd32_fs.c: revision 1.92
sys/compat/netbsd32/netbsd32.h: revision 1.137

The read/write/send/recv system calls return ssize_t because -1 is
returned on error. Therefore we must restrict the lengths of any
buffers to NETBSD32_SSIZE_MAX with compat32 to avoid garbage return
values.

Fixes ATF lib/libc/sys/t_write:write_err.
 1.53.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.163 09-May-2025  martin PR 59352: netbsd32 compat for semtimedop(2): regen
 1.162 20-May-2024  christos branches: 1.162.2;
regen
 1.161 19-May-2024  christos regen
 1.160 30-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.144
 1.159 30-Jul-2023  rin COMPANT_NETBSD32: Regen for syscalls.master,v 1.143
 1.158 29-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.142
 1.157 20-Sep-2021  thorpej Regen for eventfd(2).
 1.156 20-Sep-2021  thorpej Regen for timerfd.
 1.155 10-Oct-2020  rin regen for getrandom(2)
 1.154 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.153 26-Apr-2020  thorpej Regen for native futex calls.
 1.152 22-Apr-2020  thorpej Regen for removal of _lwp_gettid(2).
 1.151 04-Apr-2020  thorpej branches: 1.151.2;
Regen for _lwp_gettid(2).
 1.150 12-Mar-2020  pgoyette regen
 1.149 07-Mar-2020  pgoyette Regen
 1.148 18-Jan-2020  pgoyette Regen generated files _after_ committing changes to the source file.

This gets the "Generated from" comments to use the new version number.

No functional change.
 1.147 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.146 04-Nov-2019  rin branches: 1.146.2;
regen
 1.145 04-Nov-2019  rin regen
 1.144 13-Oct-2019  christos regen
 1.143 22-Sep-2019  christos regen
 1.142 18-Jun-2019  christos branches: 1.142.2;
Regen
 1.141 18-Jun-2019  christos regen
 1.140 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.139 24-Dec-2018  mrg regen.
 1.138 10-Aug-2018  pgoyette Regen
 1.137 31-Jul-2018  rjs regen.
 1.136 12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

* Removes "options PERFCTRS", the associated includes, and the associated
ifdefs. In doing so, it removes several XXXSMPs in the MI code, which is
good.

* Removes the PMC code of ARM XSCALE.

* Removes all the pmc.h files. They were all empty, except for ARM XSCALE.

* Reorders the x86 PMC code not to rely on the legacy pmc.h file. The
definitions are put in sysarch.h.

* Removes the kern/sys_pmc.c file, and along with it, the sys_pmc_control
and sys_pmc_get_info syscalls. They are marked as OBSOL in kern,
netbsd32 and rump.

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.135 10-May-2018  christos branches: 1.135.2;
regen
 1.134 06-Jan-2018  kamil branches: 1.134.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.133 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.132 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.131 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.130 19-Dec-2017  kamil Sync syscalls.master in compat_netbsd32(8) with kern/syscalls.master

___lwp_part60 removed 'const' from the ts argument.

'const struct timespec *ts' -> 'struct timespec *ts'

Sponsored by <The NetBSD Foundation>
 1.129 10-May-2017  riastradh branches: 1.129.2;
regen
 1.128 16-Jan-2017  christos branches: 1.128.4;
regen
 1.127 13-Jan-2017  christos branches: 1.127.2;
regen
 1.126 28-Oct-2016  christos regen
 1.125 19-Oct-2016  skrll Regen
 1.124 23-Sep-2016  skrll regen
 1.123 10-Sep-2016  skrll Regen
 1.122 03-Dec-2015  pgoyette branches: 1.122.2;
Regen syscall definitions - the compat_netbsd32 sysv-ipc stuff is now
modular and can be autoloaded when needed
 1.121 01-Dec-2015  pgoyette Regen for new compat_netbsd32_mqueue module
 1.120 01-Dec-2015  pgoyette Regen.
 1.119 01-Dec-2015  pgoyette Regen
 1.118 24-Sep-2015  christos regen
 1.117 23-Jun-2015  dholland regen
 1.116 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.115 21-Jun-2015  martin Regen (pset_*)
 1.114 21-Jun-2015  martin regen (versioned mq_* calls)
 1.113 20-Jun-2015  martin Regen (sigqueinfo, modctl, mq_*)
 1.112 16-Jun-2015  martin Regen for posix_fallocate and fdiscard
 1.111 07-Mar-2015  christos regen
 1.110 25-Feb-2015  christos regen
 1.109 13-Jun-2014  joerg branches: 1.109.2; 1.109.4;
Regnerate
 1.108 15-May-2014  njoly Regen for setcontext signature.
 1.107 30-Apr-2014  njoly Regen for netbsd32_off_t.
 1.106 17-Oct-2013  njoly branches: 1.106.2;
Regen for mknodat(2) device argument type change.
 1.105 29-Mar-2013  christos branches: 1.105.4;
regen
 1.104 02-Oct-2012  christos regen
 1.103 08-Apr-2012  martin branches: 1.103.2;
Regen (posix_spawn)
 1.102 10-Mar-2012  joerg P1003_1B_SEMAPHORE is no longer optional.
 1.101 08-Mar-2012  joerg Implement sem_timedwait.
 1.100 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.99 01-Feb-2012  dholland branches: 1.99.2;
Regen syscalls with proper id info.
 1.98 01-Feb-2012  dholland Update compat_netbsd32 for new quotactl.
 1.97 31-Jan-2012  matt Regen.
 1.96 08-Nov-2011  njoly branches: 1.96.4;
Regen for kqueue1.
 1.95 31-Aug-2011  njoly branches: 1.95.2;
Regen for dup3.
 1.94 05-Jul-2011  njoly Regen for pipe2.
 1.93 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.92 02-Mar-2010  pooka branches: 1.92.2; 1.92.4; 1.92.6;
regen:
- remove nfssvc / fs_nfs.h / #ifdef NFS
- make getfh unconditional
 1.91 02-Mar-2010  pooka regen for conditional lfs syscall removal
 1.90 14-Dec-2009  matt branches: 1.90.2;
Regen (new makesyscalls.sh)
 1.89 14-Dec-2009  matt Merge from matt-nb5-mips64
 1.88 17-May-2009  pooka regen: pad -> PAD
 1.87 16-Mar-2009  njoly Regen for netbsd32_dev_t.
 1.86 26-Feb-2009  christos Regen
 1.85 13-Jan-2009  pooka branches: 1.85.2;
Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.84 13-Jan-2009  pooka regen: UNIMPL police
 1.83 11-Jan-2009  christos merge christos-time_t
 1.82 22-Nov-2008  mrg branches: 1.82.4;
regenerate
 1.81 19-Nov-2008  ad Regen.
 1.80 14-Nov-2008  ad Regen.
 1.79 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.78 15-Oct-2008  wrstuden branches: 1.78.2; 1.78.4;
Merge wrstuden-revivesa into HEAD.
 1.77 24-Apr-2008  ad branches: 1.77.2; 1.77.4; 1.77.8;
Regen.
 1.76 24-Feb-2008  martin branches: 1.76.2;
Regen (old posix_fadvise ignored)
 1.75 27-Jan-2008  martin branches: 1.75.2; 1.75.6;
Regen (posix_fadvise versionend)
 1.74 26-Jan-2008  dsl regen
 1.73 19-Jan-2008  dsl Regen for netbsd32_mremap
 1.72 20-Dec-2007  dsl regen
 1.71 17-Dec-2007  dsl Regen without any 'const' members of the syscall argument structures.
 1.70 07-Dec-2007  ad branches: 1.70.4;
Reg... hang on, why don't we build this at compile time?!?
 1.69 09-Nov-2007  dsl branches: 1.69.2;
Regen
 1.68 15-Aug-2007  ad branches: 1.68.2; 1.68.6; 1.68.8;
Regen.
 1.67 07-Aug-2007  ad Regen.
 1.66 04-Mar-2007  christos branches: 1.66.2; 1.66.6; 1.66.10; 1.66.14;
fix fallout from caddr_t changes.
 1.65 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.64 19-Feb-2007  cube Regen (a few MPSAFE additions).
 1.63 18-Feb-2007  cube Regen (missing lwp syscalls).
 1.62 09-Feb-2007  ad branches: 1.62.2;
Merge newlock2 to head.
 1.61 09-Nov-2006  cube Regen (PR#34951 fixes).
 1.60 01-Sep-2006  matt branches: 1.60.2; 1.60.4;
Regen.
 1.59 30-Aug-2006  cube Regen (netbsd32_ptrace protection).
 1.58 31-Jul-2006  martin Make filehandles opaque to userland
 1.57 13-Jul-2006  pavel regen.
 1.56 13-Jul-2006  martin regen
 1.55 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.54 26-Jun-2006  mrg regenerate.
 1.53 31-May-2006  drochner branches: 1.53.2;
regen
 1.52 29-May-2006  drochner regen
 1.51 05-May-2006  cube branches: 1.51.2;
Regen (fhstat versioning, posix_fadvise).
 1.50 29-Mar-2006  cube Regen (_lwp*, sa_*).
 1.49 06-Mar-2006  cube branches: 1.49.2; 1.49.4;
Regen (SysV IPC).
 1.48 05-Mar-2006  cube branches: 1.48.2;
Regen (ksem_*).
 1.47 11-Dec-2005  christos branches: 1.47.4; 1.47.6;
merge ktrace-lwp.
 1.46 23-Oct-2005  cube Regen (kqueue, kevent).
 1.45 19-Aug-2005  christos branches: 1.45.2;
Fix lossage I created with the 64 bit ino_t change.
 1.44 23-Jul-2005  cube Regen (__sigtimedwait(2)).
 1.43 23-Jul-2005  cube Regen (timer_create(2) and friends).
 1.42 12-Jul-2005  cube Regen (*xattr(2)).
 1.41 11-Jul-2005  cube Regen (rasctl(2)).
 1.40 10-Jul-2005  cube Regen.
 1.39 10-Jul-2005  cube Regen.
 1.38 09-Jul-2005  cube Regen.
 1.37 08-Jul-2005  cube Regen.
 1.36 08-Jul-2005  cube Regen
 1.35 04-Jul-2005  cube branches: 1.35.2;
Regen
 1.34 30-May-2005  chs regen
 1.33 26-Feb-2005  perry regen
 1.32 17-Jun-2004  cube branches: 1.32.4; 1.32.6;
Regen.
 1.31 25-Oct-2003  chs regen
 1.30 13-Oct-2003  fvdl Regenerate.
 1.29 18-Jan-2003  thorpej branches: 1.29.2;
Regen for correct RCS ID.
 1.28 18-Jan-2003  thorpej Regen: Merge the nathanw_sa branch.
 1.27 01-Nov-2002  jdolecek set nsysent to 512
 1.26 23-Oct-2002  scw Regen to pick up netbsd32___sigaction_sigtramp addition.
 1.25 29-Apr-2002  mrg regenerate.
 1.24 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.23 30-May-2001  mrg branches: 1.23.2;
use _KERNEL_OPT.
 1.22 10-Apr-2001  kleink Regen.
 1.21 02-Feb-2001  mrg branches: 1.21.2;
regen
 1.20 27-Jan-2001  thorpej Regen; getpid(2) is MP-safe.
 1.19 27-Jan-2001  thorpej Regen; add sy_flags.
 1.18 09-Dec-2000  mycroft Regen.
 1.17 30-Nov-2000  jdolecek always include netbsd32_ntp_adjtime(), LKMify
 1.16 18-Aug-2000  cgd update for changed makesyscalls.master
 1.15 07-Aug-2000  bjh21 Second phase of changes to remove ntp_adjtime(2) from the kernel entirely if
NTP is not defined.

Also removes sysctl_ntptime, since that's unreferenced without NTP.

ntp_gettime(2) is left alone, since it doesn't raise SIGSYS, which sys_nosys()
does.
 1.14 09-Jul-2000  mrg regen
 1.13 31-Jan-2000  christos Regen
 1.12 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.11 11-Oct-1999  eeh branches: 1.11.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.10 09-Jun-1999  christos branches: 1.10.2;
Regen
 1.9 25-Mar-1999  mrg branches: 1.9.4;
regen
 1.8 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.7 25-Mar-1999  mrg regen
 1.6 10-Dec-1998  christos Regen
 1.5 19-Oct-1998  tron Regen.
 1.4 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.3 26-Aug-1998  mrg regen.
 1.2 26-Aug-1998  mrg regen
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.9.4.2 02-Aug-1999  thorpej Regen.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.11.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.11.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.2.5 11-Nov-2002  nathanw Catch up to -current
 1.21.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.21.2.3 29-May-2002  nathanw Regen.
 1.21.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.21.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.23.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.29.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.4.1 29-Apr-2005  kent sync with -current
 1.35.2.8 27-Feb-2008  yamt sync with head.
 1.35.2.7 04-Feb-2008  yamt sync with head.
 1.35.2.6 21-Jan-2008  yamt sync with head
 1.35.2.5 15-Nov-2007  yamt sync with head.
 1.35.2.4 03-Sep-2007  yamt sync with head.
 1.35.2.3 26-Feb-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.45.2.1 26-Oct-2005  yamt sync with head
 1.47.6.2 01-Jun-2006  kardel Sync with head.
 1.47.6.1 22-Apr-2006  simonb Sync with head.
 1.47.4.1 09-Sep-2006  rpaulo sync with head
 1.48.2.7 03-Sep-2006  yamt sync with head.
 1.48.2.6 11-Aug-2006  yamt sync with head
 1.48.2.5 26-Jun-2006  yamt sync with head.
 1.48.2.4 24-May-2006  yamt sync with head.
 1.48.2.3 01-Apr-2006  yamt sync with head.
 1.48.2.2 13-Mar-2006  yamt sync with head.
 1.48.2.1 05-Mar-2006  yamt file netbsd32_syscall.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:08 +0000
 1.49.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.49.2.2 11-May-2006  elad sync with head
 1.49.2.1 19-Apr-2006  elad sync with head.
 1.51.2.1 19-Jun-2006  chap Sync with head.
 1.53.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.60.4.1 10-Dec-2006  yamt sync with head.
 1.60.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.60.2.1 18-Nov-2006  ad Sync with head.
 1.62.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.62.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.66.14.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.66.14.3 11-Nov-2007  joerg Sync with HEAD.
 1.66.14.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.66.14.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.66.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.66.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.66.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.66.2.1 20-Aug-2007  ad Sync with HEAD.
 1.68.8.4 18-Feb-2008  mjf Sync with HEAD.
 1.68.8.3 27-Dec-2007  mjf Sync with HEAD.
 1.68.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.68.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.68.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.68.2.2 23-Mar-2008  matt sync with HEAD
 1.68.2.1 09-Jan-2008  matt sync with HEAD
 1.69.2.2 26-Dec-2007  ad Sync with head.
 1.69.2.1 08-Dec-2007  ad Sync with head.
 1.70.4.2 20-Jan-2008  bouyer Sync with HEAD
 1.70.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.75.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.75.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.75.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.75.2.1 24-Mar-2008  keiichi sync with head.
 1.76.2.1 18-May-2008  yamt sync with head.
 1.77.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.77.8.1 19-Oct-2008  haad Sync with HEAD.
 1.77.4.2 28-Sep-2008  skrll Regen.
 1.77.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.77.2.3 11-Mar-2010  yamt sync with head
 1.77.2.2 20-Jun-2009  yamt sync with head
 1.77.2.1 04-May-2009  yamt sync with head.
 1.78.4.1 25-Nov-2008  snj branches: 1.78.4.1.4;
Regen for ticket 121.
 1.78.4.1.4.1 12-Sep-2009  matt Regen.
 1.78.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.78.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.78.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.82.4.3 04-Jan-2009  christos fix module build.
 1.82.4.2 04-Jan-2009  christos add new syscalls.
 1.82.4.1 22-Nov-2008  christos file netbsd32_syscall.h was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.85.2.2 23-Jul-2009  jym Sync with HEAD.
 1.85.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.90.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.92.6.2 09-Feb-2011  bouyer Regen
 1.92.6.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.92.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.92.2.1 21-Apr-2011  rmind sync with head
 1.95.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.95.2.3 30-Oct-2012  yamt sync with head
 1.95.2.2 17-Apr-2012  yamt sync with head
 1.95.2.1 10-Nov-2011  yamt sync with head
 1.96.4.4 29-Apr-2012  mrg sync to latest -current.
 1.96.4.3 11-Mar-2012  mrg sync to latest -current
 1.96.4.2 24-Feb-2012  mrg sync to -current.
 1.96.4.1 18-Feb-2012  mrg merge to -current.
 1.99.2.2 14-Apr-2015  msaitoh Pull up following revision(s) (requested by khorben in ticket #1264):

include/unistd.h 1.144
sys/kern/init_sysent.c regen
sys/kern/syscalls.c regen
sys/kern/syscalls.master 1.272
sys/rump/include/rump/rump_syscalls.h regen
sys/rump/librump/rumpkern/rump_syscalls.c regen
sys/sys/syscall.h regen
sys/sys/syscallargs.h regen
sys/compat/netbds32/netbsd32_syscall.h regen
sys/compat/netbds32/netbsd32_syscallargs.h regen
sys/compat/netbds32/netbsd32_syscalls.c regen
sys/compat/netbds32/netbsd32_sysent.c regen
sys/compat/netbsd32/syscalls.master 1.102

Fix return type of the readlinkat(2) syscall. PR#49684.
 1.99.2.1 12-Apr-2012  riz Regen for ticket 175.
 1.103.2.4 03-Dec-2017  jdolecek update from HEAD
 1.103.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.103.2.2 23-Jun-2013  tls resync from head
 1.103.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.105.4.1 18-May-2014  rmind sync with head
 1.106.2.1 10-Aug-2014  tls Rebase.
 1.109.4.5 05-Dec-2016  skrll Sync with HEAD
 1.109.4.4 05-Oct-2016  skrll Sync with HEAD
 1.109.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.109.4.2 22-Sep-2015  skrll Sync with HEAD
 1.109.4.1 06-Apr-2015  skrll Sync with HEAD
 1.109.2.4 04-Nov-2019  martin Regen for ticket #1711
 1.109.2.3 06-Nov-2015  martin regen
 1.109.2.2 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.109.2.1 07-Mar-2015  snj regen for ticket 560
 1.122.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.122.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.127.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.128.4.1 11-May-2017  pgoyette Sync with HEAD
 1.129.2.1 04-Nov-2019  martin Regen for ticket #398
 1.134.2.18 09-Jan-2019  pgoyette Regen - otherwise compat_40_mount() is wrongly included in sysent.c

Missed this during earlier conflict resolution.
 1.134.2.17 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.134.2.16 29-Sep-2018  pgoyette Regen
 1.134.2.15 29-Sep-2018  pgoyette Regen
 1.134.2.14 14-Sep-2018  pgoyette Regen
 1.134.2.13 14-Sep-2018  pgoyette Regen
 1.134.2.12 13-Sep-2018  pgoyette Regen
 1.134.2.11 12-Sep-2018  pgoyette Regen
 1.134.2.10 12-Sep-2018  pgoyette Regen
 1.134.2.9 12-Sep-2018  pgoyette regen
 1.134.2.8 12-Sep-2018  pgoyette Regen with updated module information for ntp 30 and 50 compat calls
 1.134.2.7 11-Sep-2018  pgoyette Regen
 1.134.2.6 11-Sep-2018  pgoyette And regen again
 1.134.2.5 11-Sep-2018  pgoyette Regen
 1.134.2.4 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.134.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.134.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.134.2.1 21-May-2018  pgoyette Sync with HEAD
 1.135.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.135.2.1 10-Jun-2019  christos Sync with HEAD
 1.142.2.2 08-Mar-2020  martin Regen (for ticket #761)
 1.142.2.1 04-Nov-2019  martin Regen for ticket #398
 1.146.2.1 25-Jan-2020  ad Sync with head.
 1.151.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.162.2.1 02-Aug-2025  perseant Sync with HEAD
 1.162 09-May-2025  martin PR 59352: netbsd32 compat for semtimedop(2): regen
 1.161 20-May-2024  christos branches: 1.161.2;
regen
 1.160 19-May-2024  christos regen
 1.159 30-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.144
 1.158 30-Jul-2023  rin COMPANT_NETBSD32: Regen for syscalls.master,v 1.143
 1.157 29-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.142
 1.156 20-Sep-2021  thorpej Regen for eventfd(2).
 1.155 20-Sep-2021  thorpej Regen for timerfd.
 1.154 10-Oct-2020  rin regen for getrandom(2)
 1.153 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.152 26-Apr-2020  thorpej Regen for native futex calls.
 1.151 22-Apr-2020  thorpej Regen for removal of _lwp_gettid(2).
 1.150 04-Apr-2020  thorpej branches: 1.150.2;
Regen for _lwp_gettid(2).
 1.149 12-Mar-2020  pgoyette regen
 1.148 07-Mar-2020  pgoyette Regen
 1.147 18-Jan-2020  pgoyette Regen generated files _after_ committing changes to the source file.

This gets the "Generated from" comments to use the new version number.

No functional change.
 1.146 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.145 04-Nov-2019  rin branches: 1.145.2;
regen
 1.144 04-Nov-2019  rin regen
 1.143 13-Oct-2019  christos regen
 1.142 22-Sep-2019  christos regen
 1.141 18-Jun-2019  christos branches: 1.141.2;
Regen
 1.140 18-Jun-2019  christos regen
 1.139 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.138 24-Dec-2018  mrg regen.
 1.137 10-Aug-2018  pgoyette Regen
 1.136 31-Jul-2018  rjs regen.
 1.135 10-May-2018  christos branches: 1.135.2;
regen
 1.134 06-Jan-2018  kamil branches: 1.134.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.133 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.132 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.131 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.130 19-Dec-2017  kamil Sync syscalls.master in compat_netbsd32(8) with kern/syscalls.master

___lwp_part60 removed 'const' from the ts argument.

'const struct timespec *ts' -> 'struct timespec *ts'

Sponsored by <The NetBSD Foundation>
 1.129 10-May-2017  riastradh branches: 1.129.2;
regen
 1.128 16-Jan-2017  christos branches: 1.128.4;
regen
 1.127 13-Jan-2017  christos branches: 1.127.2;
regen
 1.126 28-Oct-2016  christos regen
 1.125 19-Oct-2016  skrll Regen
 1.124 23-Sep-2016  skrll regen
 1.123 10-Sep-2016  skrll Regen
 1.122 03-Dec-2015  pgoyette branches: 1.122.2;
Regen syscall definitions - the compat_netbsd32 sysv-ipc stuff is now
modular and can be autoloaded when needed
 1.121 01-Dec-2015  pgoyette Regen for new compat_netbsd32_mqueue module
 1.120 01-Dec-2015  pgoyette Regen.
 1.119 01-Dec-2015  pgoyette Regen
 1.118 24-Sep-2015  christos regen
 1.117 23-Jun-2015  dholland regen
 1.116 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.115 21-Jun-2015  martin Regen (pset_*)
 1.114 21-Jun-2015  martin regen (versioned mq_* calls)
 1.113 20-Jun-2015  martin Regen (sigqueinfo, modctl, mq_*)
 1.112 16-Jun-2015  martin Regen for posix_fallocate and fdiscard
 1.111 07-Mar-2015  christos regen
 1.110 25-Feb-2015  christos regen
 1.109 13-Jun-2014  joerg branches: 1.109.2; 1.109.4;
Regnerate
 1.108 15-May-2014  njoly Regen for setcontext signature.
 1.107 30-Apr-2014  njoly Regen for netbsd32_off_t.
 1.106 17-Oct-2013  njoly branches: 1.106.2;
Regen for mknodat(2) device argument type change.
 1.105 29-Mar-2013  christos branches: 1.105.4;
regen
 1.104 02-Oct-2012  christos regen
 1.103 08-Apr-2012  martin branches: 1.103.2;
Regen (posix_spawn)
 1.102 10-Mar-2012  joerg P1003_1B_SEMAPHORE is no longer optional.
 1.101 08-Mar-2012  joerg Implement sem_timedwait.
 1.100 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.99 01-Feb-2012  dholland branches: 1.99.2;
Regen syscalls with proper id info.
 1.98 01-Feb-2012  dholland Update compat_netbsd32 for new quotactl.
 1.97 31-Jan-2012  matt Regen.
 1.96 08-Nov-2011  njoly branches: 1.96.4;
Regen for kqueue1.
 1.95 31-Aug-2011  njoly branches: 1.95.2;
Regen for dup3.
 1.94 05-Jul-2011  njoly Regen for pipe2.
 1.93 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.92 02-Mar-2010  pooka branches: 1.92.2; 1.92.4; 1.92.6;
regen:
- remove nfssvc / fs_nfs.h / #ifdef NFS
- make getfh unconditional
 1.91 02-Mar-2010  pooka regen for conditional lfs syscall removal
 1.90 14-Dec-2009  matt branches: 1.90.2;
Regen (new makesyscalls.sh)
 1.89 14-Dec-2009  matt Merge from matt-nb5-mips64
 1.88 17-May-2009  pooka regen: pad -> PAD
 1.87 16-Mar-2009  njoly Regen for netbsd32_dev_t.
 1.86 26-Feb-2009  christos Regen
 1.85 13-Jan-2009  pooka branches: 1.85.2;
Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.84 13-Jan-2009  pooka regen: UNIMPL police
 1.83 11-Jan-2009  christos merge christos-time_t
 1.82 22-Nov-2008  mrg branches: 1.82.4;
regenerate
 1.81 19-Nov-2008  ad Regen.
 1.80 14-Nov-2008  ad Regen.
 1.79 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.78 15-Oct-2008  wrstuden branches: 1.78.2; 1.78.4;
Merge wrstuden-revivesa into HEAD.
 1.77 24-Apr-2008  ad branches: 1.77.2; 1.77.4; 1.77.8;
Regen.
 1.76 24-Feb-2008  martin branches: 1.76.2;
Regen (old posix_fadvise ignored)
 1.75 27-Jan-2008  martin branches: 1.75.2; 1.75.6;
Regen (posix_fadvise versionend)
 1.74 26-Jan-2008  dsl regen
 1.73 19-Jan-2008  dsl Regen for netbsd32_mremap
 1.72 20-Dec-2007  dsl regen
 1.71 17-Dec-2007  dsl Regen without any 'const' members of the syscall argument structures.
 1.70 07-Dec-2007  ad branches: 1.70.4;
Reg... hang on, why don't we build this at compile time?!?
 1.69 09-Nov-2007  dsl branches: 1.69.2;
Regen
 1.68 15-Aug-2007  ad branches: 1.68.2; 1.68.6; 1.68.8;
Regen.
 1.67 07-Aug-2007  ad Regen.
 1.66 04-Mar-2007  christos branches: 1.66.2; 1.66.6; 1.66.10; 1.66.14;
fix fallout from caddr_t changes.
 1.65 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.64 19-Feb-2007  cube Regen (a few MPSAFE additions).
 1.63 18-Feb-2007  cube Regen (missing lwp syscalls).
 1.62 09-Feb-2007  ad branches: 1.62.2;
Merge newlock2 to head.
 1.61 09-Nov-2006  cube Regen (PR#34951 fixes).
 1.60 01-Sep-2006  matt branches: 1.60.2; 1.60.4;
Regen.
 1.59 30-Aug-2006  cube Regen (netbsd32_ptrace protection).
 1.58 31-Jul-2006  martin Make filehandles opaque to userland
 1.57 13-Jul-2006  pavel regen.
 1.56 13-Jul-2006  martin regen
 1.55 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.54 26-Jun-2006  mrg regenerate.
 1.53 31-May-2006  drochner branches: 1.53.2;
regen
 1.52 29-May-2006  drochner regen
 1.51 05-May-2006  cube branches: 1.51.2;
Regen (fhstat versioning, posix_fadvise).
 1.50 29-Mar-2006  cube Regen (_lwp*, sa_*).
 1.49 06-Mar-2006  cube branches: 1.49.2; 1.49.4;
Regen (SysV IPC).
 1.48 05-Mar-2006  cube branches: 1.48.2;
Regen (ksem_*).
 1.47 11-Dec-2005  christos branches: 1.47.4; 1.47.6;
merge ktrace-lwp.
 1.46 23-Oct-2005  cube Regen (kqueue, kevent).
 1.45 19-Aug-2005  christos branches: 1.45.2;
Fix lossage I created with the 64 bit ino_t change.
 1.44 23-Jul-2005  cube Regen (__sigtimedwait(2)).
 1.43 23-Jul-2005  cube Regen (timer_create(2) and friends).
 1.42 12-Jul-2005  cube Regen (*xattr(2)).
 1.41 11-Jul-2005  cube Regen (rasctl(2)).
 1.40 10-Jul-2005  cube Regen.
 1.39 10-Jul-2005  cube Regen.
 1.38 09-Jul-2005  cube Regen.
 1.37 08-Jul-2005  cube Regen.
 1.36 08-Jul-2005  cube Regen
 1.35 04-Jul-2005  cube branches: 1.35.2;
Regen
 1.34 30-May-2005  chs regen
 1.33 26-Feb-2005  perry regen
 1.32 17-Jun-2004  cube branches: 1.32.4; 1.32.6;
Regen.
 1.31 25-Oct-2003  chs regen
 1.30 13-Oct-2003  fvdl Regenerate.
 1.29 18-Jan-2003  thorpej branches: 1.29.2;
Regen for correct RCS ID.
 1.28 18-Jan-2003  thorpej Regen: Merge the nathanw_sa branch.
 1.27 23-Oct-2002  scw Regen to pick up netbsd32___sigaction_sigtramp addition.
 1.26 29-Apr-2002  mrg regenerate.
 1.25 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.24 30-May-2001  mrg branches: 1.24.2;
use _KERNEL_OPT.
 1.23 10-Apr-2001  kleink Regen.
 1.22 02-Feb-2001  mrg branches: 1.22.2;
regen
 1.21 27-Jan-2001  thorpej Regen; getpid(2) is MP-safe.
 1.20 27-Jan-2001  thorpej Regen; add sy_flags.
 1.19 09-Dec-2000  mycroft Regen.
 1.18 30-Nov-2000  jdolecek always include netbsd32_ntp_adjtime(), LKMify
 1.17 18-Aug-2000  cgd update for changed makesyscalls.master
 1.16 18-Aug-2000  cgd update for changed makesyscalls.sh
 1.15 07-Aug-2000  bjh21 Second phase of changes to remove ntp_adjtime(2) from the kernel entirely if
NTP is not defined.

Also removes sysctl_ntptime, since that's unreferenced without NTP.

ntp_gettime(2) is left alone, since it doesn't raise SIGSYS, which sys_nosys()
does.
 1.14 09-Jul-2000  mrg regen
 1.13 31-Jan-2000  christos Regen
 1.12 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.11 11-Oct-1999  eeh branches: 1.11.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.10 09-Jun-1999  christos branches: 1.10.2;
Regen
 1.9 25-Mar-1999  mrg branches: 1.9.4;
regen
 1.8 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.7 25-Mar-1999  mrg regen
 1.6 10-Dec-1998  christos Regen
 1.5 19-Oct-1998  tron Regen.
 1.4 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.3 26-Aug-1998  mrg regen.
 1.2 26-Aug-1998  mrg regen
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.9.4.2 02-Aug-1999  thorpej Regen.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.11.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.11.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.22.2.5 11-Nov-2002  nathanw Catch up to -current
 1.22.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.22.2.3 29-May-2002  nathanw Regen.
 1.22.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.22.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.24.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.24.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.29.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.4.1 29-Apr-2005  kent sync with -current
 1.35.2.8 27-Feb-2008  yamt sync with head.
 1.35.2.7 04-Feb-2008  yamt sync with head.
 1.35.2.6 21-Jan-2008  yamt sync with head
 1.35.2.5 15-Nov-2007  yamt sync with head.
 1.35.2.4 03-Sep-2007  yamt sync with head.
 1.35.2.3 26-Feb-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.45.2.1 26-Oct-2005  yamt sync with head
 1.47.6.2 01-Jun-2006  kardel Sync with head.
 1.47.6.1 22-Apr-2006  simonb Sync with head.
 1.47.4.1 09-Sep-2006  rpaulo sync with head
 1.48.2.7 03-Sep-2006  yamt sync with head.
 1.48.2.6 11-Aug-2006  yamt sync with head
 1.48.2.5 26-Jun-2006  yamt sync with head.
 1.48.2.4 24-May-2006  yamt sync with head.
 1.48.2.3 01-Apr-2006  yamt sync with head.
 1.48.2.2 13-Mar-2006  yamt sync with head.
 1.48.2.1 05-Mar-2006  yamt file netbsd32_syscallargs.h was added on branch yamt-pdpolicy on 2006-03-13 09:07:08 +0000
 1.49.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.49.2.2 11-May-2006  elad sync with head
 1.49.2.1 19-Apr-2006  elad sync with head.
 1.51.2.1 19-Jun-2006  chap Sync with head.
 1.53.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.60.4.1 10-Dec-2006  yamt sync with head.
 1.60.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.60.2.1 18-Nov-2006  ad Sync with head.
 1.62.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.62.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.66.14.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.66.14.3 11-Nov-2007  joerg Sync with HEAD.
 1.66.14.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.66.14.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.66.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.66.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.66.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.66.2.1 20-Aug-2007  ad Sync with HEAD.
 1.68.8.4 18-Feb-2008  mjf Sync with HEAD.
 1.68.8.3 27-Dec-2007  mjf Sync with HEAD.
 1.68.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.68.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.68.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.68.2.2 23-Mar-2008  matt sync with HEAD
 1.68.2.1 09-Jan-2008  matt sync with HEAD
 1.69.2.2 26-Dec-2007  ad Sync with head.
 1.69.2.1 08-Dec-2007  ad Sync with head.
 1.70.4.2 20-Jan-2008  bouyer Sync with HEAD
 1.70.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.75.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.75.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.75.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.75.2.1 24-Mar-2008  keiichi sync with head.
 1.76.2.1 18-May-2008  yamt sync with head.
 1.77.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.77.8.1 19-Oct-2008  haad Sync with HEAD.
 1.77.4.2 28-Sep-2008  skrll Regen.
 1.77.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.77.2.3 11-Mar-2010  yamt sync with head
 1.77.2.2 20-Jun-2009  yamt sync with head
 1.77.2.1 04-May-2009  yamt sync with head.
 1.78.4.1 25-Nov-2008  snj branches: 1.78.4.1.4;
Regen for ticket 121.
 1.78.4.1.4.1 12-Sep-2009  matt Regen.
 1.78.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.78.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.78.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.82.4.3 04-Jan-2009  christos fix module build.
 1.82.4.2 04-Jan-2009  christos add new syscalls.
 1.82.4.1 22-Nov-2008  christos file netbsd32_syscallargs.h was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.85.2.2 23-Jul-2009  jym Sync with HEAD.
 1.85.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.90.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.92.6.2 09-Feb-2011  bouyer Regen
 1.92.6.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.92.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.92.2.1 21-Apr-2011  rmind sync with head
 1.95.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.95.2.3 30-Oct-2012  yamt sync with head
 1.95.2.2 17-Apr-2012  yamt sync with head
 1.95.2.1 10-Nov-2011  yamt sync with head
 1.96.4.4 29-Apr-2012  mrg sync to latest -current.
 1.96.4.3 11-Mar-2012  mrg sync to latest -current
 1.96.4.2 24-Feb-2012  mrg sync to -current.
 1.96.4.1 18-Feb-2012  mrg merge to -current.
 1.99.2.2 14-Apr-2015  msaitoh Pull up following revision(s) (requested by khorben in ticket #1264):

include/unistd.h 1.144
sys/kern/init_sysent.c regen
sys/kern/syscalls.c regen
sys/kern/syscalls.master 1.272
sys/rump/include/rump/rump_syscalls.h regen
sys/rump/librump/rumpkern/rump_syscalls.c regen
sys/sys/syscall.h regen
sys/sys/syscallargs.h regen
sys/compat/netbds32/netbsd32_syscall.h regen
sys/compat/netbds32/netbsd32_syscallargs.h regen
sys/compat/netbds32/netbsd32_syscalls.c regen
sys/compat/netbds32/netbsd32_sysent.c regen
sys/compat/netbsd32/syscalls.master 1.102

Fix return type of the readlinkat(2) syscall. PR#49684.
 1.99.2.1 12-Apr-2012  riz Regen for ticket 175.
 1.103.2.4 03-Dec-2017  jdolecek update from HEAD
 1.103.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.103.2.2 23-Jun-2013  tls resync from head
 1.103.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.105.4.1 18-May-2014  rmind sync with head
 1.106.2.1 10-Aug-2014  tls Rebase.
 1.109.4.6 28-Aug-2017  skrll Sync with HEAD
 1.109.4.5 05-Dec-2016  skrll Sync with HEAD
 1.109.4.4 05-Oct-2016  skrll Sync with HEAD
 1.109.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.109.4.2 22-Sep-2015  skrll Sync with HEAD
 1.109.4.1 06-Apr-2015  skrll Sync with HEAD
 1.109.2.4 04-Nov-2019  martin Regen for ticket #1711
 1.109.2.3 06-Nov-2015  martin regen
 1.109.2.2 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.109.2.1 07-Mar-2015  snj regen for ticket 560
 1.122.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.122.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.127.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.128.4.1 11-May-2017  pgoyette Sync with HEAD
 1.129.2.1 04-Nov-2019  martin Regen for ticket #398
 1.134.2.17 09-Jan-2019  pgoyette Regen - otherwise compat_40_mount() is wrongly included in sysent.c

Missed this during earlier conflict resolution.
 1.134.2.16 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.134.2.15 29-Sep-2018  pgoyette Regen
 1.134.2.14 29-Sep-2018  pgoyette Regen
 1.134.2.13 14-Sep-2018  pgoyette Regen
 1.134.2.12 14-Sep-2018  pgoyette Regen
 1.134.2.11 13-Sep-2018  pgoyette Regen
 1.134.2.10 12-Sep-2018  pgoyette Regen
 1.134.2.9 12-Sep-2018  pgoyette Regen
 1.134.2.8 12-Sep-2018  pgoyette regen
 1.134.2.7 12-Sep-2018  pgoyette Regen with updated module information for ntp 30 and 50 compat calls
 1.134.2.6 11-Sep-2018  pgoyette Regen
 1.134.2.5 11-Sep-2018  pgoyette And regen again
 1.134.2.4 11-Sep-2018  pgoyette Regen
 1.134.2.3 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.134.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.134.2.1 21-May-2018  pgoyette Sync with HEAD
 1.135.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.135.2.1 10-Jun-2019  christos Sync with HEAD
 1.141.2.2 08-Mar-2020  martin Regen (for ticket #761)
 1.141.2.1 04-Nov-2019  martin Regen for ticket #398
 1.145.2.1 25-Jan-2020  ad Sync with head.
 1.150.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.161.2.1 02-Aug-2025  perseant Sync with HEAD
 1.162 09-May-2025  martin PR 59352: netbsd32 compat for semtimedop(2): regen
 1.161 20-May-2024  christos branches: 1.161.2;
regen
 1.160 19-May-2024  christos regen
 1.159 30-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.144
 1.158 30-Jul-2023  rin COMPANT_NETBSD32: Regen for syscalls.master,v 1.143
 1.157 29-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.142
 1.156 20-Sep-2021  thorpej Regen for eventfd(2).
 1.155 20-Sep-2021  thorpej Regen for timerfd.
 1.154 10-Oct-2020  rin regen for getrandom(2)
 1.153 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.152 26-Apr-2020  thorpej Regen for native futex calls.
 1.151 22-Apr-2020  thorpej Regen for removal of _lwp_gettid(2).
 1.150 04-Apr-2020  thorpej branches: 1.150.2;
Regen for _lwp_gettid(2).
 1.149 12-Mar-2020  pgoyette regen
 1.148 07-Mar-2020  pgoyette Regen
 1.147 18-Jan-2020  pgoyette Regen generated files _after_ committing changes to the source file.

This gets the "Generated from" comments to use the new version number.

No functional change.
 1.146 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.145 04-Nov-2019  rin branches: 1.145.2;
regen
 1.144 04-Nov-2019  rin regen
 1.143 13-Oct-2019  christos regen
 1.142 22-Sep-2019  christos regen
 1.141 18-Jun-2019  christos branches: 1.141.2;
Regen
 1.140 18-Jun-2019  christos regen
 1.139 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.138 24-Dec-2018  mrg regen.
 1.137 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.136 10-Aug-2018  pgoyette Regen
 1.135 31-Jul-2018  rjs regen.
 1.134 12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

* Removes "options PERFCTRS", the associated includes, and the associated
ifdefs. In doing so, it removes several XXXSMPs in the MI code, which is
good.

* Removes the PMC code of ARM XSCALE.

* Removes all the pmc.h files. They were all empty, except for ARM XSCALE.

* Reorders the x86 PMC code not to rely on the legacy pmc.h file. The
definitions are put in sysarch.h.

* Removes the kern/sys_pmc.c file, and along with it, the sys_pmc_control
and sys_pmc_get_info syscalls. They are marked as OBSOL in kern,
netbsd32 and rump.

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.133 10-May-2018  christos branches: 1.133.2;
regen
 1.132 06-Jan-2018  kamil branches: 1.132.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.131 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.130 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.129 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.128 10-May-2017  riastradh branches: 1.128.2;
regen
 1.127 16-Jan-2017  christos branches: 1.127.4;
regen
 1.126 13-Jan-2017  christos branches: 1.126.2;
regen
 1.125 28-Oct-2016  christos regen
 1.124 19-Oct-2016  skrll Regen
 1.123 23-Sep-2016  skrll regen
 1.122 10-Sep-2016  skrll Regen
 1.121 03-Dec-2015  pgoyette branches: 1.121.2;
Regen syscall definitions - the compat_netbsd32 sysv-ipc stuff is now
modular and can be autoloaded when needed
 1.120 01-Dec-2015  pgoyette Regen for new compat_netbsd32_mqueue module
 1.119 01-Dec-2015  pgoyette Regen.
 1.118 01-Dec-2015  pgoyette Regen
 1.117 24-Sep-2015  christos regen
 1.116 23-Jun-2015  dholland regen
 1.115 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.114 21-Jun-2015  martin Regen (pset_*)
 1.113 21-Jun-2015  martin regen (versioned mq_* calls)
 1.112 20-Jun-2015  martin Regen (sigqueinfo, modctl, mq_*)
 1.111 16-Jun-2015  martin Regen for posix_fallocate and fdiscard
 1.110 07-Mar-2015  christos regen
 1.109 25-Feb-2015  christos regen
 1.108 13-Jun-2014  joerg branches: 1.108.2; 1.108.4;
Regnerate
 1.107 15-May-2014  njoly Regen for setcontext signature.
 1.106 30-Apr-2014  njoly Regen for netbsd32_off_t.
 1.105 17-Oct-2013  njoly branches: 1.105.2;
Regen for mknodat(2) device argument type change.
 1.104 29-Mar-2013  christos branches: 1.104.4;
regen
 1.103 02-Oct-2012  christos regen
 1.102 08-Apr-2012  martin branches: 1.102.2;
Regen (posix_spawn)
 1.101 10-Mar-2012  joerg P1003_1B_SEMAPHORE is no longer optional.
 1.100 08-Mar-2012  joerg Implement sem_timedwait.
 1.99 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.98 01-Feb-2012  dholland branches: 1.98.2;
Regen syscalls with proper id info.
 1.97 01-Feb-2012  dholland Update compat_netbsd32 for new quotactl.
 1.96 31-Jan-2012  matt Regen.
 1.95 08-Nov-2011  njoly branches: 1.95.4;
Regen for kqueue1.
 1.94 31-Aug-2011  njoly branches: 1.94.2;
Regen for dup3.
 1.93 05-Jul-2011  njoly Regen for pipe2.
 1.92 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.91 02-Mar-2010  pooka branches: 1.91.2; 1.91.4; 1.91.6;
regen:
- remove nfssvc / fs_nfs.h / #ifdef NFS
- make getfh unconditional
 1.90 02-Mar-2010  pooka regen for conditional lfs syscall removal
 1.89 14-Dec-2009  matt branches: 1.89.2;
Regen (new makesyscalls.sh)
 1.88 14-Dec-2009  matt Merge from matt-nb5-mips64
 1.87 17-May-2009  pooka regen: pad -> PAD
 1.86 16-Mar-2009  njoly Regen for netbsd32_dev_t.
 1.85 26-Feb-2009  christos Regen
 1.84 13-Jan-2009  pooka branches: 1.84.2;
Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.83 13-Jan-2009  pooka regen: UNIMPL police
 1.82 11-Jan-2009  christos merge christos-time_t
 1.81 22-Nov-2008  mrg branches: 1.81.4;
regenerate
 1.80 19-Nov-2008  ad Regen.
 1.79 14-Nov-2008  ad Regen.
 1.78 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.77 15-Oct-2008  wrstuden branches: 1.77.2; 1.77.4;
Merge wrstuden-revivesa into HEAD.
 1.76 24-Apr-2008  ad branches: 1.76.2; 1.76.4; 1.76.8;
Regen.
 1.75 24-Feb-2008  martin branches: 1.75.2;
Regen (old posix_fadvise ignored)
 1.74 27-Jan-2008  martin branches: 1.74.2; 1.74.6;
Regen (posix_fadvise versionend)
 1.73 26-Jan-2008  dsl regen
 1.72 19-Jan-2008  dsl Regen for netbsd32_mremap
 1.71 20-Dec-2007  dsl regen
 1.70 17-Dec-2007  dsl Regen without any 'const' members of the syscall argument structures.
 1.69 07-Dec-2007  ad branches: 1.69.4;
Reg... hang on, why don't we build this at compile time?!?
 1.68 09-Nov-2007  dsl branches: 1.68.2;
Regen
 1.67 15-Aug-2007  ad branches: 1.67.2; 1.67.6; 1.67.8;
Regen.
 1.66 07-Aug-2007  ad Regen.
 1.65 04-Mar-2007  christos branches: 1.65.2; 1.65.6; 1.65.10; 1.65.14;
fix fallout from caddr_t changes.
 1.64 19-Feb-2007  cube Regen (a few MPSAFE additions).
 1.63 18-Feb-2007  cube Regen (missing lwp syscalls).
 1.62 09-Feb-2007  ad branches: 1.62.2;
Merge newlock2 to head.
 1.61 09-Nov-2006  cube Regen (PR#34951 fixes).
 1.60 01-Sep-2006  matt branches: 1.60.2; 1.60.4;
Regen.
 1.59 30-Aug-2006  cube Regen (netbsd32_ptrace protection).
 1.58 31-Jul-2006  martin Make filehandles opaque to userland
 1.57 13-Jul-2006  pavel regen.
 1.56 13-Jul-2006  martin regen
 1.55 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.54 26-Jun-2006  mrg regenerate.
 1.53 31-May-2006  drochner branches: 1.53.2;
regen
 1.52 29-May-2006  drochner regen
 1.51 05-May-2006  cube branches: 1.51.2;
Regen (fhstat versioning, posix_fadvise).
 1.50 29-Mar-2006  cube Regen (_lwp*, sa_*).
 1.49 06-Mar-2006  cube branches: 1.49.2; 1.49.4;
Regen (SysV IPC).
 1.48 05-Mar-2006  cube branches: 1.48.2;
Regen (ksem_*).
 1.47 11-Dec-2005  christos branches: 1.47.4; 1.47.6;
merge ktrace-lwp.
 1.46 23-Oct-2005  cube Regen (kqueue, kevent).
 1.45 19-Aug-2005  christos branches: 1.45.2;
Fix lossage I created with the 64 bit ino_t change.
 1.44 23-Jul-2005  cube Regen (__sigtimedwait(2)).
 1.43 23-Jul-2005  cube Regen (timer_create(2) and friends).
 1.42 12-Jul-2005  cube Regen (*xattr(2)).
 1.41 11-Jul-2005  cube Regen (rasctl(2)).
 1.40 10-Jul-2005  cube Regen.
 1.39 10-Jul-2005  cube Regen.
 1.38 09-Jul-2005  cube Regen.
 1.37 08-Jul-2005  cube Regen.
 1.36 08-Jul-2005  cube Regen
 1.35 04-Jul-2005  cube branches: 1.35.2;
Regen
 1.34 30-May-2005  chs regen
 1.33 26-Feb-2005  perry regen
 1.32 17-Jun-2004  cube branches: 1.32.4; 1.32.6;
Regen.
 1.31 25-Oct-2003  chs regen
 1.30 13-Oct-2003  fvdl Regenerate.
 1.29 18-Jan-2003  thorpej branches: 1.29.2;
Regen for correct RCS ID.
 1.28 18-Jan-2003  thorpej Regen: Merge the nathanw_sa branch.
 1.27 23-Oct-2002  scw Regen to pick up netbsd32___sigaction_sigtramp addition.
 1.26 29-Apr-2002  mrg regenerate.
 1.25 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.24 30-May-2001  mrg branches: 1.24.2;
use _KERNEL_OPT.
 1.23 10-Apr-2001  kleink Regen.
 1.22 02-Feb-2001  mrg branches: 1.22.2;
regen
 1.21 27-Jan-2001  thorpej Regen; getpid(2) is MP-safe.
 1.20 27-Jan-2001  thorpej Regen; add sy_flags.
 1.19 09-Dec-2000  mycroft Regen.
 1.18 30-Nov-2000  jdolecek always include netbsd32_ntp_adjtime(), LKMify
 1.17 13-Nov-2000  jdolecek change the type of *syscallnames[] array to 'const char * const foo[]'
 1.16 18-Aug-2000  cgd update for changed makesyscalls.master
 1.15 07-Aug-2000  bjh21 Second phase of changes to remove ntp_adjtime(2) from the kernel entirely if
NTP is not defined.

Also removes sysctl_ntptime, since that's unreferenced without NTP.

ntp_gettime(2) is left alone, since it doesn't raise SIGSYS, which sys_nosys()
does.
 1.14 09-Jul-2000  mrg regen
 1.13 31-Jan-2000  christos Regen
 1.12 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.11 11-Oct-1999  eeh branches: 1.11.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.10 09-Jun-1999  christos branches: 1.10.2;
Regen
 1.9 25-Mar-1999  mrg branches: 1.9.4;
regen
 1.8 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.7 25-Mar-1999  mrg regen
 1.6 10-Dec-1998  christos Regen
 1.5 19-Oct-1998  tron Regen.
 1.4 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.3 26-Aug-1998  mrg regen.
 1.2 26-Aug-1998  mrg regen
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.9.4.2 02-Aug-1999  thorpej Regen.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.2.6 21-Apr-2001  bouyer Sync with HEAD
 1.11.2.5 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.4 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.11.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.11.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.22.2.5 11-Nov-2002  nathanw Catch up to -current
 1.22.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.22.2.3 29-May-2002  nathanw Regen.
 1.22.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.22.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.24.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.24.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.29.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.4.1 29-Apr-2005  kent sync with -current
 1.35.2.8 27-Feb-2008  yamt sync with head.
 1.35.2.7 04-Feb-2008  yamt sync with head.
 1.35.2.6 21-Jan-2008  yamt sync with head
 1.35.2.5 15-Nov-2007  yamt sync with head.
 1.35.2.4 03-Sep-2007  yamt sync with head.
 1.35.2.3 26-Feb-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.45.2.1 26-Oct-2005  yamt sync with head
 1.47.6.2 01-Jun-2006  kardel Sync with head.
 1.47.6.1 22-Apr-2006  simonb Sync with head.
 1.47.4.1 09-Sep-2006  rpaulo sync with head
 1.48.2.7 03-Sep-2006  yamt sync with head.
 1.48.2.6 11-Aug-2006  yamt sync with head
 1.48.2.5 26-Jun-2006  yamt sync with head.
 1.48.2.4 24-May-2006  yamt sync with head.
 1.48.2.3 01-Apr-2006  yamt sync with head.
 1.48.2.2 13-Mar-2006  yamt sync with head.
 1.48.2.1 05-Mar-2006  yamt file netbsd32_syscalls.c was added on branch yamt-pdpolicy on 2006-03-13 09:07:08 +0000
 1.49.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.49.2.2 11-May-2006  elad sync with head
 1.49.2.1 19-Apr-2006  elad sync with head.
 1.51.2.1 19-Jun-2006  chap Sync with head.
 1.53.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.60.4.1 10-Dec-2006  yamt sync with head.
 1.60.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.60.2.1 18-Nov-2006  ad Sync with head.
 1.62.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.62.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.65.14.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.65.14.3 11-Nov-2007  joerg Sync with HEAD.
 1.65.14.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.65.14.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.65.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.65.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.65.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.65.2.1 20-Aug-2007  ad Sync with HEAD.
 1.67.8.4 18-Feb-2008  mjf Sync with HEAD.
 1.67.8.3 27-Dec-2007  mjf Sync with HEAD.
 1.67.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.67.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.67.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.67.2.2 23-Mar-2008  matt sync with HEAD
 1.67.2.1 09-Jan-2008  matt sync with HEAD
 1.68.2.2 26-Dec-2007  ad Sync with head.
 1.68.2.1 08-Dec-2007  ad Sync with head.
 1.69.4.2 20-Jan-2008  bouyer Sync with HEAD
 1.69.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.74.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.74.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.74.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.74.2.1 24-Mar-2008  keiichi sync with head.
 1.75.2.1 18-May-2008  yamt sync with head.
 1.76.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.76.8.1 19-Oct-2008  haad Sync with HEAD.
 1.76.4.3 28-Sep-2008  skrll Regen.
 1.76.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.76.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.76.2.3 11-Mar-2010  yamt sync with head
 1.76.2.2 20-Jun-2009  yamt sync with head
 1.76.2.1 04-May-2009  yamt sync with head.
 1.77.4.1 25-Nov-2008  snj branches: 1.77.4.1.4;
Regen for ticket 121.
 1.77.4.1.4.1 12-Sep-2009  matt Regen.
 1.77.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.77.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.77.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.81.4.3 04-Jan-2009  christos fix module build.
 1.81.4.2 04-Jan-2009  christos add new syscalls.
 1.81.4.1 22-Nov-2008  christos file netbsd32_syscalls.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.84.2.2 23-Jul-2009  jym Sync with HEAD.
 1.84.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.89.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.91.6.2 09-Feb-2011  bouyer Regen
 1.91.6.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.91.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.91.2.1 21-Apr-2011  rmind sync with head
 1.94.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.94.2.3 30-Oct-2012  yamt sync with head
 1.94.2.2 17-Apr-2012  yamt sync with head
 1.94.2.1 10-Nov-2011  yamt sync with head
 1.95.4.4 29-Apr-2012  mrg sync to latest -current.
 1.95.4.3 11-Mar-2012  mrg sync to latest -current
 1.95.4.2 24-Feb-2012  mrg sync to -current.
 1.95.4.1 18-Feb-2012  mrg merge to -current.
 1.98.2.2 14-Apr-2015  msaitoh Pull up following revision(s) (requested by khorben in ticket #1264):

include/unistd.h 1.144
sys/kern/init_sysent.c regen
sys/kern/syscalls.c regen
sys/kern/syscalls.master 1.272
sys/rump/include/rump/rump_syscalls.h regen
sys/rump/librump/rumpkern/rump_syscalls.c regen
sys/sys/syscall.h regen
sys/sys/syscallargs.h regen
sys/compat/netbds32/netbsd32_syscall.h regen
sys/compat/netbds32/netbsd32_syscallargs.h regen
sys/compat/netbds32/netbsd32_syscalls.c regen
sys/compat/netbds32/netbsd32_sysent.c regen
sys/compat/netbsd32/syscalls.master 1.102

Fix return type of the readlinkat(2) syscall. PR#49684.
 1.98.2.1 12-Apr-2012  riz Regen for ticket 175.
 1.102.2.4 03-Dec-2017  jdolecek update from HEAD
 1.102.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.102.2.2 23-Jun-2013  tls resync from head
 1.102.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.104.4.1 18-May-2014  rmind sync with head
 1.105.2.1 10-Aug-2014  tls Rebase.
 1.108.4.5 05-Dec-2016  skrll Sync with HEAD
 1.108.4.4 05-Oct-2016  skrll Sync with HEAD
 1.108.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.108.4.2 22-Sep-2015  skrll Sync with HEAD
 1.108.4.1 06-Apr-2015  skrll Sync with HEAD
 1.108.2.4 04-Nov-2019  martin Regen for ticket #1711
 1.108.2.3 06-Nov-2015  martin regen
 1.108.2.2 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.108.2.1 07-Mar-2015  snj regen for ticket 560
 1.121.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.121.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.126.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.127.4.1 11-May-2017  pgoyette Sync with HEAD
 1.128.2.1 04-Nov-2019  martin Regen for ticket #398
 1.132.2.18 09-Jan-2019  pgoyette Regen - otherwise compat_40_mount() is wrongly included in sysent.c

Missed this during earlier conflict resolution.
 1.132.2.17 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.132.2.16 29-Sep-2018  pgoyette Regen
 1.132.2.15 29-Sep-2018  pgoyette Regen
 1.132.2.14 14-Sep-2018  pgoyette Regen
 1.132.2.13 14-Sep-2018  pgoyette Regen
 1.132.2.12 13-Sep-2018  pgoyette Regen
 1.132.2.11 12-Sep-2018  pgoyette Regen
 1.132.2.10 12-Sep-2018  pgoyette Regen
 1.132.2.9 12-Sep-2018  pgoyette regen
 1.132.2.8 12-Sep-2018  pgoyette Regen with updated module information for ntp 30 and 50 compat calls
 1.132.2.7 11-Sep-2018  pgoyette Regen
 1.132.2.6 11-Sep-2018  pgoyette And regen again
 1.132.2.5 11-Sep-2018  pgoyette Regen
 1.132.2.4 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.132.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.132.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.132.2.1 21-May-2018  pgoyette Sync with HEAD
 1.133.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.133.2.1 10-Jun-2019  christos Sync with HEAD
 1.141.2.2 08-Mar-2020  martin Regen (for ticket #761)
 1.141.2.1 04-Nov-2019  martin Regen for ticket #398
 1.145.2.1 25-Jan-2020  ad Sync with head.
 1.150.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.161.2.1 02-Aug-2025  perseant Sync with HEAD
 1.42 09-May-2025  martin PR 59352: netbsd32 compat for semtimedop(2): regen
 1.41 20-May-2024  christos branches: 1.41.2;
regen
 1.40 19-May-2024  christos regen
 1.39 30-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.144
 1.38 30-Jul-2023  rin COMPANT_NETBSD32: Regen for syscalls.master,v 1.143
 1.37 29-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.142
 1.36 20-Sep-2021  thorpej Regen for eventfd(2).
 1.35 20-Sep-2021  thorpej Regen for timerfd.
 1.34 10-Oct-2020  rin regen for getrandom(2)
 1.33 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.32 26-Apr-2020  thorpej Regen for native futex calls.
 1.31 22-Apr-2020  thorpej Regen for removal of _lwp_gettid(2).
 1.30 04-Apr-2020  thorpej branches: 1.30.2;
Regen for _lwp_gettid(2).
 1.29 12-Mar-2020  pgoyette regen
 1.28 07-Mar-2020  pgoyette Regen
 1.27 18-Jan-2020  pgoyette Regen generated files _after_ committing changes to the source file.

This gets the "Generated from" comments to use the new version number.

No functional change.
 1.26 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.25 04-Nov-2019  rin branches: 1.25.2;
regen
 1.24 04-Nov-2019  rin regen
 1.23 13-Oct-2019  christos regen
 1.22 22-Sep-2019  christos regen
 1.21 18-Jun-2019  christos branches: 1.21.2;
Regen
 1.20 18-Jun-2019  christos regen
 1.19 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.18 24-Dec-2018  mrg regen.
 1.17 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.16 10-Aug-2018  pgoyette Regen
 1.15 31-Jul-2018  rjs regen.
 1.14 10-May-2018  christos branches: 1.14.2;
regen
 1.13 06-Jan-2018  kamil branches: 1.13.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.12 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.11 10-May-2017  riastradh branches: 1.11.2; 1.11.8;
regen
 1.10 16-Jan-2017  christos branches: 1.10.4;
regen
 1.9 13-Jan-2017  christos branches: 1.9.2;
regen
 1.8 28-Oct-2016  christos regen
 1.7 19-Oct-2016  skrll Regen
 1.6 23-Sep-2016  skrll regen
 1.5 10-Sep-2016  skrll Regen
 1.4 03-Dec-2015  pgoyette branches: 1.4.2; 1.4.4;
Regen syscall definitions - the compat_netbsd32 sysv-ipc stuff is now
modular and can be autoloaded when needed
 1.3 01-Dec-2015  pgoyette Regen for new compat_netbsd32_mqueue module
 1.2 01-Dec-2015  pgoyette Regen.
 1.1 01-Dec-2015  pgoyette Regen
 1.4.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.2.4 05-Dec-2016  skrll Sync with HEAD
 1.4.2.3 05-Oct-2016  skrll Sync with HEAD
 1.4.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.4.2.1 03-Dec-2015  skrll file netbsd32_syscalls_autoload.c was added on branch nick-nhusb on 2015-12-27 12:09:47 +0000
 1.9.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.10.4.1 11-May-2017  pgoyette Sync with HEAD
 1.11.8.2 03-Dec-2017  jdolecek update from HEAD
 1.11.8.1 10-May-2017  jdolecek file netbsd32_syscalls_autoload.c was added on branch tls-maxphys on 2017-12-03 11:36:56 +0000
 1.11.2.1 04-Nov-2019  martin Regen for ticket #398
 1.13.2.17 09-Jan-2019  pgoyette Regen - otherwise compat_40_mount() is wrongly included in sysent.c

Missed this during earlier conflict resolution.
 1.13.2.16 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.13.2.15 29-Sep-2018  pgoyette Regen
 1.13.2.14 29-Sep-2018  pgoyette Regen
 1.13.2.13 14-Sep-2018  pgoyette Regen
 1.13.2.12 14-Sep-2018  pgoyette Regen
 1.13.2.11 13-Sep-2018  pgoyette Regen
 1.13.2.10 12-Sep-2018  pgoyette Regen
 1.13.2.9 12-Sep-2018  pgoyette Regen
 1.13.2.8 12-Sep-2018  pgoyette regen
 1.13.2.7 12-Sep-2018  pgoyette Regen with updated module information for ntp 30 and 50 compat calls
 1.13.2.6 11-Sep-2018  pgoyette Regen
 1.13.2.5 11-Sep-2018  pgoyette And regen again
 1.13.2.4 11-Sep-2018  pgoyette Regen
 1.13.2.3 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.13.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.13.2.1 21-May-2018  pgoyette Sync with HEAD
 1.14.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.2.1 10-Jun-2019  christos Sync with HEAD
 1.21.2.2 08-Mar-2020  martin Regen (for ticket #761)
 1.21.2.1 04-Nov-2019  martin Regen for ticket #398
 1.25.2.1 25-Jan-2020  ad Sync with head.
 1.30.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.41.2.1 02-Aug-2025  perseant Sync with HEAD
 1.45 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.44 21-Mar-2020  pgoyette branches: 1.44.4;
Restore code to sysctl_free() the compat32 shadow tree
 1.43 17-Mar-2020  pgoyette Remove a debug printf() that accidentally got committed. :(
 1.42 15-Mar-2020  pgoyette Use SYSCTL_SETUP mechanism to establish our sysctl tree, rather than
using explicit calls to netbsd32_sysctl_{init,fini}()
 1.41 02-Jan-2020  thorpej - Eliminate the global "boottime" variable, which was being accessed
without any synchronization against changes by e.g. clock_settime().
- Replace with new getbinboottime() / getnanoboottime() / getmicroboottime()
functions (naming mirrors that of other time access functions in kern_tc.c).
It returns the (maybe-converted) value of timebasebin, which also tracks
our estimate of when the system was booted (i.e. the legacy "boottime" was
redundant).

XXX There needs to be a lockless synchronization mechanism for reading
timebasebin, but this is a problem in kern_tc.c that pre-existed these
"boottime" changes. At least now the problem is centralized in one location.
 1.40 26-May-2018  kamil branches: 1.40.2;
Fix sysctl(3):vm.minaddress in compat_netbsd32(8)

Cast minaddress from LP64-specific long (64-bit) to 32-bit long (int).

This value is usually 0 or 0+PAGE_SIZE. There is need to change type in
order to keep original code functional, without prompting the value with
'long long' or a similar approach.


There are more CTLTYPE_LONG with a need for fixes in the compat code:

uipc_usrreq.c
1975 CTLTYPE_LONG, "sendspace",
1981 CTLTYPE_LONG, "recvspace",
1987 CTLTYPE_LONG, "sendspace",
1993 CTLTYPE_LONG, "recvspace",
vfs_bio.c
1921 CTLTYPE_LONG, "bufmem",
1928 CTLTYPE_LONG, "bufmem_lowater",
1935 CTLTYPE_LONG, "bufmem_hiwater",

Sponsored by <The NetBSD Foundation>
 1.39 26-May-2018  kamil Handle vm.maxaddress in compat_netbsd32(8)

Return VM_MAXUSER_ADDRESS32 instead of the 64-bit specific address.

Use CTLTYPE_INT instead of CTLTYPE_LONG in order to retain the same integer
type between 64-bit native kernel and 32-bit emulated program.

There probably should be CTLTYPE_LONG32 available for this purpose.

On NetBSD/i386:
vm.maxaddress=bfeff000

On NetBSD/amd64:
vm.maxaddress=7fbfdfeff000

On NetBSD/amd64 running i386 program:
vm.maxaddress=fffff000

A 32-bit program on the 64-bit kernel can use larger user space, this
difference is on purpose and expected.

Sponsored by <The NetBSD Foundation>
 1.38 31-Oct-2017  kre branches: 1.38.2;

unconst machine_arch32 for sysctl data .. pointed out by Riccardo Mottola
 1.37 31-Oct-2017  martin Allow architectures to define a macro PROC_MACHINE_ARCH(P) and
PROC_MACHINE_ARCH32(P) to override the value for sysctl hw.machine_arch
(native and netbsd32 commpat resp.).

Use these for arm and mips instead of the (not working, noisy, in case
of arm) sysctl override and #ifdef __mips__ in architecture neutral
code.
 1.36 17-May-2015  matt machine_arch on mips depends on the ABI so we need a routine to return
the right value.
 1.35 13-Jun-2014  joerg branches: 1.35.4;
Rename stack gap arguments.
 1.34 16-May-2014  martin Get rid of all sysc_init_field uses - initialize fields directly in C99
notation.
 1.33 20-Jan-2012  joerg branches: 1.33.6; 1.33.10; 1.33.20;
Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.32 23-May-2011  joerg branches: 1.32.4; 1.32.8;
Use __UNCONST to get rid of const
 1.31 23-Apr-2010  rmind branches: 1.31.2;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.30 11-Jan-2009  christos branches: 1.30.4; 1.30.6;
merge christos-time_t
 1.29 19-Nov-2008  ad branches: 1.29.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.28 07-Jan-2008  ad branches: 1.28.6; 1.28.10; 1.28.12; 1.28.16; 1.28.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.27 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.26 08-Dec-2007  dsl branches: 1.26.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.25 15-Aug-2007  ad branches: 1.25.2; 1.25.8; 1.25.10;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.24 18-Mar-2007  dsl branches: 1.24.4; 1.24.8;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.23 09-Feb-2007  ad branches: 1.23.2; 1.23.6; 1.23.8; 1.23.10;
Merge newlock2 to head.
 1.22 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.21 11-Dec-2005  christos branches: 1.21.20; 1.21.22;
merge ktrace-lwp.
 1.20 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.19 03-Jul-2005  cube branches: 1.19.2;
Constify machine32 and machine_arch32.
 1.18 03-Jul-2005  cube Make COMPAT_NETBSD32 emulate hw.machine. While it might seem wrong to do
so, it introduces breakage because a lot of applications make assumptions
from its value. It's especially bad in the sparc64 case, where 64-bits
instructions can be used in 32-bits addressing mode. However, there are
other means to know the capabilities of the CPU.
 1.17 22-Jun-2005  atatat Also fix (wrt the new const stuff) the one user of sysctl_locate()
outside of the main sysctl code.
 1.16 20-Jun-2005  atatat Change the rest of the sysctl subsystem to use const consistently.
The __UNCONST macro is now used only where necessary and the RW macros
are gone. Most of the changes here are consumers of the
sysctl_createv(9) interface that now takes a pair of const pointers
which used not to be.
 1.15 27-Apr-2004  atatat Be consistent about using sysc_init_field()
 1.14 24-Mar-2004  atatat branches: 1.14.2;
Tango on sysctl_createv() and flags. The flags have all been renamed,
and sysctl_createv() now uses more arguments.
 1.13 09-Mar-2004  atatat I obviously put this (__SYSCTL_PRIVATE) here, but I have no
recollection of what it was for and it's now just useless, so it goes.
 1.12 04-Dec-2003  atatat Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.11 21-Oct-2003  fvdl Fix some int vs. NULL comparisons.
 1.10 29-Jun-2003  fvdl branches: 1.10.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.9 29-Jun-2003  martin struct proc * -> struct lwp *
 1.8 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.7 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.6 14-Jun-2002  eeh Provide the correct architecture for HW_MACHINE_ARCH so things like
"sysctl -p" can tell they are in 32-bit land.
 1.5 14-Feb-2002  chs branches: 1.5.4; 1.5.8; 1.5.10;
allow writing to write-only mappings. fixes PR 3493.
 1.4 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.3 30-May-2001  mrg branches: 1.3.2;
use _KERNEL_OPT.
 1.2 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.8 11-Nov-2002  nathanw Catch up to -current
 1.1.4.7 23-Aug-2002  petrov lwpification.
 1.1.4.6 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.5 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.1.4.4 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.3 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.1.2.3 27-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_sysctl.c was added on branch thorpej_scsipi on 2001-02-11 19:14:21 +0000
 1.3.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.10.1 15-Jun-2002  lukem Pull up revision 1.6 (requested by eeh in ticket #275):
Provide the correct architecture for HW_MACHINE_ARCH so things like
"sysctl -p" can tell they are in 32-bit land.
 1.5.8.1 20-Jun-2002  gehenna catch up with -current.
 1.5.4.1 11-Mar-2002  thorpej Convert sysctl_memlock to an adaptive mutex.
 1.10.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.2.1 29-Apr-2004  jmc Pullup rev 1.15 (requested by atatat in ticket #206)

Be consistent about using sysc_init_field()
 1.19.2.5 21-Jan-2008  yamt sync with head
 1.19.2.4 03-Sep-2007  yamt sync with head.
 1.19.2.3 26-Feb-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.21.22.1 22-Oct-2006  yamt sync with head
 1.21.20.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.21.20.1 18-Nov-2006  ad Sync with head.
 1.23.10.1 29-Mar-2007  reinoud Pullup to -current
 1.23.8.1 11-Jul-2007  mjf Sync with head.
 1.23.6.2 20-Aug-2007  ad Sync with HEAD.
 1.23.6.1 10-Apr-2007  ad Sync with head.
 1.23.2.1 24-Mar-2007  yamt sync with head.
 1.24.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.24.8.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.24.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.25.10.1 26-Dec-2007  ad Sync with head.
 1.25.8.1 18-Feb-2008  mjf Sync with HEAD.
 1.25.2.1 09-Jan-2008  matt sync with HEAD
 1.26.4.2 08-Jan-2008  bouyer Sync with HEAD
 1.26.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.28.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.28.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.28.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.28.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.28.10.2 11-Aug-2010  yamt sync with head.
 1.28.10.1 04-May-2009  yamt sync with head.
 1.28.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.29.4.2 04-Jan-2009  christos add new syscalls.
 1.29.4.1 19-Nov-2008  christos file netbsd32_sysctl.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.30.6.2 31-May-2011  rmind sync with head
 1.30.6.1 30-May-2010  rmind sync with head
 1.30.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.31.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.8.1 18-Feb-2012  mrg merge to -current.
 1.32.4.1 17-Apr-2012  yamt sync with head
 1.33.20.1 10-Aug-2014  tls Rebase.
 1.33.10.1 18-May-2014  rmind sync with head
 1.33.6.2 03-Dec-2017  jdolecek update from HEAD
 1.33.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.4.1 06-Jun-2015  skrll Sync with HEAD
 1.38.2.6 25-Jan-2019  pgoyette Revert previous change(s). There's no good reason to use the hook when
the required value is available locally (in the current module).

Thanks mrg@ for pointing this out.
 1.38.2.5 24-Jan-2019  pgoyette I must be getting tired - use the correct name of the hook
 1.38.2.4 24-Jan-2019  pgoyette I wrote this stuff, when will I ever learn to use MODULE_CALL_HOOK
instead of MODULE_HOOK_CALL ? :)
 1.38.2.3 24-Jan-2019  pgoyette Use the hook to get the value of machine32
 1.38.2.2 24-Jan-2019  pgoyette Found a couple other consumers of machine32 - adapt them to use the hook
 1.38.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.40.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.44.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 21-Mar-2020  pgoyette Restore code to sysctl_free() the compat32 shadow tree
 1.2 15-Mar-2020  pgoyette Use SYSCTL_SETUP mechanism to establish our sysctl tree, rather than
using explicit calls to netbsd32_sysctl_{init,fini}()
 1.1 19-Nov-2008  ad branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10; 1.1.14; 1.1.78;
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.78.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.14.2 04-May-2009  yamt sync with head.
 1.1.14.1 19-Nov-2008  yamt file netbsd32_sysctl.h was added on branch yamt-nfs-mp on 2009-05-04 08:12:25 +0000
 1.1.10.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.10.1 19-Nov-2008  skrll file netbsd32_sysctl.h was added on branch nick-hppapmap on 2009-01-19 13:17:37 +0000
 1.1.8.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.8.1 19-Nov-2008  mjf file netbsd32_sysctl.h was added on branch mjf-devfs2 on 2009-01-17 13:28:47 +0000
 1.1.6.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.6.1 19-Nov-2008  ad file netbsd32_sysctl.h was added on branch christos-time_t on 2008-11-19 18:36:06 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 19-Nov-2008  haad file netbsd32_sysctl.h was added on branch haad-dm on 2008-12-13 01:14:03 +0000
 1.163 09-May-2025  martin PR 59352: netbsd32 compat for semtimedop(2): regen
 1.162 20-May-2024  christos branches: 1.162.2;
regen
 1.161 19-May-2024  christos regen
 1.160 01-May-2024  mlelstv Revert previous, the syscall needs to be enabled at runtime.

The compat_16 module just enables it for the "netbsd" emulation, but
nothing enables it yet for "netbsd32".
 1.159 30-Apr-2024  mlelstv Enable compat sigreturn system call.

The previous bug in netbsd32___sigaction_sigtramp hid the problem,
as it failed all but the first installation of a signal handler.
 1.158 30-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.144
 1.157 30-Jul-2023  rin COMPANT_NETBSD32: Regen for syscalls.master,v 1.143
 1.156 29-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.142
 1.155 20-Sep-2021  thorpej Regen for eventfd(2).
 1.154 20-Sep-2021  thorpej Regen for timerfd.
 1.153 10-Oct-2020  rin regen for getrandom(2)
 1.152 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.151 26-Apr-2020  thorpej Regen for native futex calls.
 1.150 22-Apr-2020  thorpej Regen for removal of _lwp_gettid(2).
 1.149 04-Apr-2020  thorpej branches: 1.149.2;
Regen for _lwp_gettid(2).
 1.148 12-Mar-2020  pgoyette regen
 1.147 07-Mar-2020  pgoyette Regen
 1.146 18-Jan-2020  pgoyette Regen generated files _after_ committing changes to the source file.

This gets the "Generated from" comments to use the new version number.

No functional change.
 1.145 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.144 04-Nov-2019  rin branches: 1.144.2;
regen
 1.143 04-Nov-2019  rin regen
 1.142 13-Oct-2019  christos regen
 1.141 22-Sep-2019  christos regen
 1.140 18-Jun-2019  christos branches: 1.140.2;
Regen
 1.139 18-Jun-2019  christos regen
 1.138 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.137 24-Dec-2018  mrg regen.
 1.136 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.135 10-Aug-2018  pgoyette Regen
 1.134 31-Jul-2018  rjs regen.
 1.133 10-May-2018  christos branches: 1.133.2;
regen
 1.132 06-Jan-2018  kamil branches: 1.132.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.131 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.130 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.129 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.128 10-May-2017  riastradh branches: 1.128.2;
regen
 1.127 16-Jan-2017  christos branches: 1.127.4;
regen
 1.126 13-Jan-2017  christos branches: 1.126.2;
regen
 1.125 28-Oct-2016  christos regen
 1.124 19-Oct-2016  skrll Regen
 1.123 23-Sep-2016  skrll regen
 1.122 10-Sep-2016  skrll Regen
 1.121 03-Dec-2015  pgoyette branches: 1.121.2;
Regen syscall definitions - the compat_netbsd32 sysv-ipc stuff is now
modular and can be autoloaded when needed
 1.120 01-Dec-2015  pgoyette Regen for new compat_netbsd32_mqueue module
 1.119 01-Dec-2015  pgoyette Regen.
 1.118 01-Dec-2015  pgoyette Regen
 1.117 24-Sep-2015  christos regen
 1.116 23-Jun-2015  dholland regen
 1.115 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.114 21-Jun-2015  martin Regen (pset_*)
 1.113 21-Jun-2015  martin regen (versioned mq_* calls)
 1.112 20-Jun-2015  martin Regen (sigqueinfo, modctl, mq_*)
 1.111 16-Jun-2015  martin Regen for posix_fallocate and fdiscard
 1.110 07-Mar-2015  christos regen
 1.109 25-Feb-2015  christos regen
 1.108 13-Jun-2014  joerg branches: 1.108.2; 1.108.4;
Regnerate
 1.107 15-May-2014  njoly Regen for setcontext signature.
 1.106 30-Apr-2014  njoly Regen for netbsd32_off_t.
 1.105 17-Oct-2013  njoly branches: 1.105.2;
Regen for mknodat(2) device argument type change.
 1.104 29-Mar-2013  christos branches: 1.104.4;
regen
 1.103 02-Oct-2012  christos regen
 1.102 08-Apr-2012  martin branches: 1.102.2;
Regen (posix_spawn)
 1.101 10-Mar-2012  joerg P1003_1B_SEMAPHORE is no longer optional.
 1.100 08-Mar-2012  joerg Implement sem_timedwait.
 1.99 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.98 01-Feb-2012  dholland branches: 1.98.2;
Regen syscalls with proper id info.
 1.97 01-Feb-2012  dholland Update compat_netbsd32 for new quotactl.
 1.96 31-Jan-2012  matt Regen.
 1.95 08-Nov-2011  njoly branches: 1.95.4;
Regen for kqueue1.
 1.94 31-Aug-2011  njoly branches: 1.94.2;
Regen for dup3.
 1.93 05-Jul-2011  njoly Regen for pipe2.
 1.92 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.91 02-Mar-2010  pooka branches: 1.91.2; 1.91.4; 1.91.6;
regen:
- remove nfssvc / fs_nfs.h / #ifdef NFS
- make getfh unconditional
 1.90 02-Mar-2010  pooka regen for conditional lfs syscall removal
 1.89 14-Dec-2009  matt branches: 1.89.2;
Regen (new makesyscalls.sh)
 1.88 14-Dec-2009  matt Merge from matt-nb5-mips64
 1.87 17-May-2009  pooka regen: pad -> PAD
 1.86 16-Mar-2009  njoly Regen for netbsd32_dev_t.
 1.85 26-Feb-2009  christos Regen
 1.84 13-Jan-2009  pooka branches: 1.84.2;
Regen to prove I didn't screw up the conversion: purely RCSID changes.
 1.83 13-Jan-2009  pooka regen: UNIMPL police
 1.82 11-Jan-2009  christos merge christos-time_t
 1.81 22-Nov-2008  mrg branches: 1.81.4;
regenerate
 1.80 19-Nov-2008  ad Regen.
 1.79 14-Nov-2008  ad Regen.
 1.78 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.77 15-Oct-2008  wrstuden branches: 1.77.2; 1.77.4;
Merge wrstuden-revivesa into HEAD.
 1.76 24-Apr-2008  ad branches: 1.76.2; 1.76.4; 1.76.8;
Regen.
 1.75 24-Feb-2008  martin branches: 1.75.2;
Regen (old posix_fadvise ignored)
 1.74 27-Jan-2008  martin branches: 1.74.2; 1.74.6;
Regen (posix_fadvise versionend)
 1.73 26-Jan-2008  dsl regen
 1.72 19-Jan-2008  dsl Regen for netbsd32_mremap
 1.71 20-Dec-2007  dsl regen
 1.70 17-Dec-2007  dsl Regen without any 'const' members of the syscall argument structures.
 1.69 07-Dec-2007  ad branches: 1.69.4;
Reg... hang on, why don't we build this at compile time?!?
 1.68 09-Nov-2007  dsl branches: 1.68.2;
Regen
 1.67 15-Aug-2007  ad branches: 1.67.2; 1.67.6; 1.67.8;
Regen.
 1.66 07-Aug-2007  ad Regen.
 1.65 04-Mar-2007  christos branches: 1.65.2; 1.65.6; 1.65.10; 1.65.14;
fix fallout from caddr_t changes.
 1.64 19-Feb-2007  cube Regen (a few MPSAFE additions).
 1.63 18-Feb-2007  cube Regen (missing lwp syscalls).
 1.62 09-Feb-2007  ad branches: 1.62.2;
Merge newlock2 to head.
 1.61 09-Nov-2006  cube Regen (PR#34951 fixes).
 1.60 01-Sep-2006  matt branches: 1.60.2; 1.60.4;
Regen.
 1.59 30-Aug-2006  cube Regen (netbsd32_ptrace protection).
 1.58 31-Jul-2006  martin Make filehandles opaque to userland
 1.57 13-Jul-2006  pavel regen.
 1.56 13-Jul-2006  martin regen
 1.55 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.54 26-Jun-2006  mrg regenerate.
 1.53 31-May-2006  drochner branches: 1.53.2;
regen
 1.52 29-May-2006  drochner regen
 1.51 05-May-2006  cube branches: 1.51.2;
Regen (fhstat versioning, posix_fadvise).
 1.50 29-Mar-2006  cube Regen (_lwp*, sa_*).
 1.49 06-Mar-2006  cube branches: 1.49.2; 1.49.4;
Regen (SysV IPC).
 1.48 05-Mar-2006  cube branches: 1.48.2;
Regen (ksem_*).
 1.47 11-Dec-2005  christos branches: 1.47.4; 1.47.6;
merge ktrace-lwp.
 1.46 23-Oct-2005  cube Regen (kqueue, kevent).
 1.45 19-Aug-2005  christos branches: 1.45.2;
Fix lossage I created with the 64 bit ino_t change.
 1.44 23-Jul-2005  cube Regen (__sigtimedwait(2)).
 1.43 23-Jul-2005  cube Regen (timer_create(2) and friends).
 1.42 12-Jul-2005  cube Regen (*xattr(2)).
 1.41 11-Jul-2005  cube Regen (rasctl(2)).
 1.40 10-Jul-2005  cube Regen.
 1.39 10-Jul-2005  cube Regen.
 1.38 09-Jul-2005  cube Regen.
 1.37 08-Jul-2005  cube Regen.
 1.36 08-Jul-2005  cube Regen
 1.35 04-Jul-2005  cube branches: 1.35.2;
Regen
 1.34 30-May-2005  chs regen
 1.33 26-Feb-2005  perry regen
 1.32 17-Jun-2004  cube branches: 1.32.4; 1.32.6;
Regen.
 1.31 25-Oct-2003  chs regen
 1.30 13-Oct-2003  fvdl Implement 32bit get/setcontext entry points.
 1.29 18-Jan-2003  thorpej branches: 1.29.2;
Regen for correct RCS ID.
 1.28 18-Jan-2003  thorpej Regen: Merge the nathanw_sa branch.
 1.27 01-Nov-2002  jdolecek set nsysent to 512
 1.26 23-Oct-2002  scw Regen to pick up netbsd32___sigaction_sigtramp addition.
 1.25 29-Apr-2002  mrg regenerate.
 1.24 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.23 30-May-2001  mrg branches: 1.23.2;
use _KERNEL_OPT.
 1.22 10-Apr-2001  kleink Regen.
 1.21 02-Feb-2001  mrg branches: 1.21.2;
regen
 1.20 27-Jan-2001  thorpej Regen; getpid(2) is MP-safe.
 1.19 27-Jan-2001  thorpej Regen; add sy_flags.
 1.18 09-Dec-2000  mycroft Regen.
 1.17 30-Nov-2000  jdolecek always include netbsd32_ntp_adjtime(), LKMify
 1.16 18-Aug-2000  cgd update for changed makesyscalls.master
 1.15 07-Aug-2000  bjh21 Second phase of changes to remove ntp_adjtime(2) from the kernel entirely if
NTP is not defined.

Also removes sysctl_ntptime, since that's unreferenced without NTP.

ntp_gettime(2) is left alone, since it doesn't raise SIGSYS, which sys_nosys()
does.
 1.14 09-Jul-2000  mrg regen
 1.13 31-Jan-2000  christos Regen
 1.12 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.11 11-Oct-1999  eeh branches: 1.11.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.10 09-Jun-1999  christos branches: 1.10.2;
Regen
 1.9 25-Mar-1999  mrg branches: 1.9.4;
regen
 1.8 25-Mar-1999  mrg move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.7 25-Mar-1999  mrg regen
 1.6 10-Dec-1998  christos Regen
 1.5 19-Oct-1998  tron Regen.
 1.4 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.3 26-Aug-1998  mrg regen.
 1.2 26-Aug-1998  mrg regen
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.9.4.2 02-Aug-1999  thorpej Regen.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.11.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.11.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.2.5 11-Nov-2002  nathanw Catch up to -current
 1.21.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.21.2.3 29-May-2002  nathanw Regen.
 1.21.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.21.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.23.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.29.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.4.1 29-Apr-2005  kent sync with -current
 1.35.2.8 27-Feb-2008  yamt sync with head.
 1.35.2.7 04-Feb-2008  yamt sync with head.
 1.35.2.6 21-Jan-2008  yamt sync with head
 1.35.2.5 15-Nov-2007  yamt sync with head.
 1.35.2.4 03-Sep-2007  yamt sync with head.
 1.35.2.3 26-Feb-2007  yamt sync with head.
 1.35.2.2 30-Dec-2006  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.45.2.1 26-Oct-2005  yamt sync with head
 1.47.6.2 01-Jun-2006  kardel Sync with head.
 1.47.6.1 22-Apr-2006  simonb Sync with head.
 1.47.4.1 09-Sep-2006  rpaulo sync with head
 1.48.2.7 03-Sep-2006  yamt sync with head.
 1.48.2.6 11-Aug-2006  yamt sync with head
 1.48.2.5 26-Jun-2006  yamt sync with head.
 1.48.2.4 24-May-2006  yamt sync with head.
 1.48.2.3 01-Apr-2006  yamt sync with head.
 1.48.2.2 13-Mar-2006  yamt sync with head.
 1.48.2.1 05-Mar-2006  yamt file netbsd32_sysent.c was added on branch yamt-pdpolicy on 2006-03-13 09:07:08 +0000
 1.49.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.49.2.2 11-May-2006  elad sync with head
 1.49.2.1 19-Apr-2006  elad sync with head.
 1.51.2.1 19-Jun-2006  chap Sync with head.
 1.53.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.60.4.1 10-Dec-2006  yamt sync with head.
 1.60.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.60.2.1 18-Nov-2006  ad Sync with head.
 1.62.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.62.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.65.14.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.65.14.3 11-Nov-2007  joerg Sync with HEAD.
 1.65.14.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.65.14.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.65.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.65.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.65.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.65.2.1 20-Aug-2007  ad Sync with HEAD.
 1.67.8.4 18-Feb-2008  mjf Sync with HEAD.
 1.67.8.3 27-Dec-2007  mjf Sync with HEAD.
 1.67.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.67.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.67.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.67.2.2 23-Mar-2008  matt sync with HEAD
 1.67.2.1 09-Jan-2008  matt sync with HEAD
 1.68.2.2 26-Dec-2007  ad Sync with head.
 1.68.2.1 08-Dec-2007  ad Sync with head.
 1.69.4.2 20-Jan-2008  bouyer Sync with HEAD
 1.69.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.74.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.74.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.74.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.74.2.1 24-Mar-2008  keiichi sync with head.
 1.75.2.1 18-May-2008  yamt sync with head.
 1.76.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.76.8.1 19-Oct-2008  haad Sync with HEAD.
 1.76.4.3 28-Sep-2008  skrll Missed this one in the regen.
 1.76.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.76.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.76.2.3 11-Mar-2010  yamt sync with head
 1.76.2.2 20-Jun-2009  yamt sync with head
 1.76.2.1 04-May-2009  yamt sync with head.
 1.77.4.1 25-Nov-2008  snj branches: 1.77.4.1.4;
Regen for ticket 121.
 1.77.4.1.4.2 12-Sep-2009  matt Regen.
 1.77.4.1.4.1 12-Sep-2009  matt Regen.
 1.77.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.77.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.77.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.81.4.3 04-Jan-2009  christos fix module build.
 1.81.4.2 04-Jan-2009  christos add new syscalls.
 1.81.4.1 22-Nov-2008  christos file netbsd32_sysent.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.84.2.2 23-Jul-2009  jym Sync with HEAD.
 1.84.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.89.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.91.6.2 09-Feb-2011  bouyer Regen
 1.91.6.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.91.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.91.2.1 21-Apr-2011  rmind sync with head
 1.94.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.94.2.3 30-Oct-2012  yamt sync with head
 1.94.2.2 17-Apr-2012  yamt sync with head
 1.94.2.1 10-Nov-2011  yamt sync with head
 1.95.4.4 29-Apr-2012  mrg sync to latest -current.
 1.95.4.3 11-Mar-2012  mrg sync to latest -current
 1.95.4.2 24-Feb-2012  mrg sync to -current.
 1.95.4.1 18-Feb-2012  mrg merge to -current.
 1.98.2.2 14-Apr-2015  msaitoh Pull up following revision(s) (requested by khorben in ticket #1264):

include/unistd.h 1.144
sys/kern/init_sysent.c regen
sys/kern/syscalls.c regen
sys/kern/syscalls.master 1.272
sys/rump/include/rump/rump_syscalls.h regen
sys/rump/librump/rumpkern/rump_syscalls.c regen
sys/sys/syscall.h regen
sys/sys/syscallargs.h regen
sys/compat/netbds32/netbsd32_syscall.h regen
sys/compat/netbds32/netbsd32_syscallargs.h regen
sys/compat/netbds32/netbsd32_syscalls.c regen
sys/compat/netbds32/netbsd32_sysent.c regen
sys/compat/netbsd32/syscalls.master 1.102

Fix return type of the readlinkat(2) syscall. PR#49684.
 1.98.2.1 12-Apr-2012  riz Regen for ticket 175.
 1.102.2.4 03-Dec-2017  jdolecek update from HEAD
 1.102.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.102.2.2 23-Jun-2013  tls resync from head
 1.102.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.104.4.1 18-May-2014  rmind sync with head
 1.105.2.1 10-Aug-2014  tls Rebase.
 1.108.4.5 05-Dec-2016  skrll Sync with HEAD
 1.108.4.4 05-Oct-2016  skrll Sync with HEAD
 1.108.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.108.4.2 22-Sep-2015  skrll Sync with HEAD
 1.108.4.1 06-Apr-2015  skrll Sync with HEAD
 1.108.2.4 04-Nov-2019  martin Regen for ticket #1711
 1.108.2.3 06-Nov-2015  martin regen
 1.108.2.2 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.108.2.1 07-Mar-2015  snj regen for ticket 560
 1.121.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.121.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.126.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.127.4.1 11-May-2017  pgoyette Sync with HEAD
 1.128.2.1 04-Nov-2019  martin Regen for ticket #398
 1.132.2.17 09-Jan-2019  pgoyette Regen - otherwise compat_40_mount() is wrongly included in sysent.c

Missed this during earlier conflict resolution.
 1.132.2.16 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.132.2.15 29-Sep-2018  pgoyette Regen
 1.132.2.14 29-Sep-2018  pgoyette Regen
 1.132.2.13 14-Sep-2018  pgoyette Regen
 1.132.2.12 14-Sep-2018  pgoyette Regen
 1.132.2.11 13-Sep-2018  pgoyette Regen
 1.132.2.10 12-Sep-2018  pgoyette Regen
 1.132.2.9 12-Sep-2018  pgoyette Regen
 1.132.2.8 12-Sep-2018  pgoyette regen
 1.132.2.7 12-Sep-2018  pgoyette Regen with updated module information for ntp 30 and 50 compat calls
 1.132.2.6 11-Sep-2018  pgoyette Regen
 1.132.2.5 11-Sep-2018  pgoyette And regen again
 1.132.2.4 11-Sep-2018  pgoyette Regen
 1.132.2.3 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.132.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.132.2.1 21-May-2018  pgoyette Sync with HEAD
 1.133.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.133.2.1 10-Jun-2019  christos Sync with HEAD
 1.140.2.2 08-Mar-2020  martin Regen (for ticket #761)
 1.140.2.1 04-Nov-2019  martin Regen for ticket #398
 1.144.2.1 25-Jan-2020  ad Sync with head.
 1.149.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.162.2.1 02-Aug-2025  perseant Sync with HEAD
 1.55 09-May-2025  martin PR 59352: netbsd32 compat for semtimedop(2): regen
 1.54 20-May-2024  christos branches: 1.54.2;
regen
 1.53 19-May-2024  christos regen
 1.52 30-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.144
 1.51 30-Jul-2023  rin COMPANT_NETBSD32: Regen for syscalls.master,v 1.143
 1.50 29-Jul-2023  rin COMPAT_NETBSD32: Regen for syscalls.master,v 1.142
 1.49 20-Sep-2021  thorpej Regen for eventfd(2).
 1.48 20-Sep-2021  thorpej Regen for timerfd.
 1.47 14-Apr-2021  christos regen
 1.46 13-Apr-2021  christos regen
 1.45 10-Oct-2020  rin branches: 1.45.4;
regen for getrandom(2)
 1.44 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.43 26-Apr-2020  thorpej Regen for native futex calls.
 1.42 22-Apr-2020  thorpej Regen for removal of _lwp_gettid(2).
 1.41 04-Apr-2020  thorpej branches: 1.41.2;
Regen for _lwp_gettid(2).
 1.40 12-Mar-2020  pgoyette regen
 1.39 07-Mar-2020  pgoyette Regen
 1.38 18-Jan-2020  pgoyette Regen generated files _after_ committing changes to the source file.

This gets the "Generated from" comments to use the new version number.

No functional change.
 1.37 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.36 04-Nov-2019  rin branches: 1.36.2;
regen
 1.35 04-Nov-2019  rin regen
 1.34 13-Oct-2019  christos regen
 1.33 22-Sep-2019  christos regen
 1.32 18-Jun-2019  christos branches: 1.32.2;
Regen
 1.31 18-Jun-2019  christos regen
 1.30 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.29 24-Dec-2018  mrg regen.
 1.28 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.27 10-Aug-2018  pgoyette Regen
 1.26 31-Jul-2018  rjs regen.
 1.25 10-May-2018  christos branches: 1.25.2;
regen
 1.24 06-Jan-2018  kamil branches: 1.24.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.23 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.22 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.21 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.20 19-Dec-2017  kamil Sync syscalls.master in compat_netbsd32(8) with kern/syscalls.master

___lwp_part60 removed 'const' from the ts argument.

'const struct timespec *ts' -> 'struct timespec *ts'

Sponsored by <The NetBSD Foundation>
 1.19 10-May-2017  riastradh branches: 1.19.2; 1.19.8;
regen
 1.18 16-Jan-2017  christos branches: 1.18.4;
regen
 1.17 13-Jan-2017  christos branches: 1.17.2;
regen
 1.16 28-Oct-2016  christos regen
 1.15 19-Oct-2016  skrll Regen
 1.14 23-Sep-2016  skrll regen
 1.13 10-Sep-2016  skrll Regen
 1.12 03-Dec-2015  pgoyette branches: 1.12.2;
Regen syscall definitions - the compat_netbsd32 sysv-ipc stuff is now
modular and can be autoloaded when needed
 1.11 01-Dec-2015  pgoyette Regen for new compat_netbsd32_mqueue module
 1.10 01-Dec-2015  pgoyette Regen.
 1.9 01-Dec-2015  pgoyette Regen
 1.8 24-Sep-2015  christos regen
 1.7 23-Jun-2015  dholland regen
 1.6 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.5 21-Jun-2015  martin Regen (pset_*)
 1.4 21-Jun-2015  martin regen (versioned mq_* calls)
 1.3 20-Jun-2015  martin Regen (sigqueinfo, modctl, mq_*)
 1.2 16-Jun-2015  martin Regen for posix_fallocate and fdiscard
 1.1 07-Mar-2015  christos branches: 1.1.2;
regen
 1.1.2.6 05-Feb-2017  skrll Sync with HEAD
 1.1.2.5 05-Oct-2016  skrll Sync with HEAD
 1.1.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.3 22-Sep-2015  skrll Sync with HEAD
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 07-Mar-2015  skrll file netbsd32_systrace_args.c was added on branch nick-nhusb on 2015-04-06 15:18:07 +0000
 1.12.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.12.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.17.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.18.4.1 11-May-2017  pgoyette Sync with HEAD
 1.19.8.2 03-Dec-2017  jdolecek update from HEAD
 1.19.8.1 10-May-2017  jdolecek file netbsd32_systrace_args.c was added on branch tls-maxphys on 2017-12-03 11:36:56 +0000
 1.19.2.1 04-Nov-2019  martin Regen for ticket #398
 1.24.2.16 09-Jan-2019  pgoyette Regen - otherwise compat_40_mount() is wrongly included in sysent.c

Missed this during earlier conflict resolution.
 1.24.2.15 29-Sep-2018  pgoyette Regen
 1.24.2.14 29-Sep-2018  pgoyette Regen
 1.24.2.13 14-Sep-2018  pgoyette Regen
 1.24.2.12 14-Sep-2018  pgoyette Regen
 1.24.2.11 13-Sep-2018  pgoyette Regen
 1.24.2.10 12-Sep-2018  pgoyette Regen
 1.24.2.9 12-Sep-2018  pgoyette Regen
 1.24.2.8 12-Sep-2018  pgoyette regen
 1.24.2.7 12-Sep-2018  pgoyette Regen with updated module information for ntp 30 and 50 compat calls
 1.24.2.6 11-Sep-2018  pgoyette Regen
 1.24.2.5 11-Sep-2018  pgoyette And regen again
 1.24.2.4 11-Sep-2018  pgoyette Regen
 1.24.2.3 11-Sep-2018  pgoyette Regen syscall files and fix includes for syscallvar.h
 1.24.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.24.2.1 21-May-2018  pgoyette Sync with HEAD
 1.25.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.25.2.1 10-Jun-2019  christos Sync with HEAD
 1.32.2.2 08-Mar-2020  martin Regen (for ticket #761)
 1.32.2.1 04-Nov-2019  martin Regen for ticket #398
 1.36.2.1 25-Jan-2020  ad Sync with head.
 1.41.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.45.4.1 17-Apr-2021  thorpej Sync with HEAD.
 1.54.2.1 02-Aug-2025  perseant Sync with HEAD
 1.58 26-Oct-2022  riastradh sys: Put externs for time_adjtime and time_adjusted in .h files.

time_adjtime: sys/timex.h (defined in ntp code)
time_adjusted: sys/timevar.h (defined in non-ntp code)

(Not really sure this is a valuable distinction to maintain; there's
non-ntp code that uses time_adjtime too.)
 1.57 20-Sep-2021  thorpej Add timerfd system calls to COMPAT_NETBSD32.
 1.56 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.55 18-Feb-2021  simonb In the compat setitimer(2) calls, don't validate which timer is being
used since dosetitimer() does this anyway. The compat functions hadn't
been updated since ITIMER_MONOTONIC was introduced, so they reported
that that ITIMER_MONOTONIC timer was invalid.
 1.54 19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.53 05-Oct-2019  kamil branches: 1.53.8;
Validate input before converting timeval::tv_usec in compat/netbsd32
 1.52 26-Sep-2019  christos make the ?: expression types match
 1.51 27-Jan-2019  pgoyette branches: 1.51.4;
Merge the [pgoyette-compat] branch
 1.50 30-Oct-2018  riastradh Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.

These structs don't have padding but safer to keep the code
structured the same way between the various ntp_gettimes in case
anyone makes more copypasta of it for future updates.
 1.49 26-Feb-2017  njoly branches: 1.49.6; 1.49.12; 1.49.14;
Apply fix from natuve clock_nanosleep(2) to not copyout remaining time
struct if TIMER_ABSTIME flag is set.
 1.48 23-Sep-2016  skrll branches: 1.48.2;
Trailing whitespace
 1.47 23-Sep-2016  skrll Add netbsd32_clock_getcpuclockid2 and netbsd32_wait6 functions
 1.46 31-Oct-2015  njoly branches: 1.46.2;
Adjust compat netbsd32 clock_nanosleep(2) to match recent native
changes that return error number.
 1.45 22-Jul-2015  maxv Set 'error' properly.
 1.44 17-Jul-2015  skrll Unwrap lines.
 1.43 12-Jul-2015  martin Use the right type in sizeof() for copyin() in adjtime
 1.42 02-Oct-2012  christos branches: 1.42.12; 1.42.14;
kernel portion of clock_nanosleep()
 1.41 08-Apr-2010  njoly branches: 1.41.8; 1.41.18;
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.40 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.39 29-Mar-2010  njoly Convert linux/linux32/netbsd32 clock_settime syscalls, to use the
common clock_settime1() function.
 1.38 29-Mar-2010  njoly Make compat netbsd32 clock_getres copyout the netbsd32 timespec
structure, not the native one.
 1.37 28-Mar-2010  njoly Cleanup compat netbsd32 nanosleep syscalls to use the common
nanosleep1() call instead of their own stuff.
 1.36 26-Feb-2009  christos branches: 1.36.2; 1.36.4;
fix kernel build with no options NTP
 1.35 11-Jan-2009  christos branches: 1.35.2;
merge christos-time_t
 1.34 15-Jul-2008  christos branches: 1.34.2; 1.34.8;
Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
 1.33 29-May-2008  mrg branches: 1.33.2; 1.33.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.32 20-Jan-2008  joerg branches: 1.32.6; 1.32.8; 1.32.10; 1.32.12;
Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.31 21-Dec-2007  dsl Fix prototypes used when NTP is not in use.
Pointed out by Robert Swindells.
 1.30 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.29 08-Dec-2007  dsl branches: 1.29.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.28 25-Nov-2007  elad branches: 1.28.2;
Refactor time modification checks and place them in the secmodel code.

okay christos@
 1.27 18-Mar-2007  dsl branches: 1.27.8; 1.27.10; 1.27.16;
Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.26 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.25 04-Mar-2007  christos branches: 1.25.2; 1.25.4; 1.25.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.24 14-Nov-2006  elad branches: 1.24.4;
Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.23 23-Jul-2006  ad branches: 1.23.4; 1.23.6;
Use the LWP cached credentials where sane.
 1.22 07-Jun-2006  kardel merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
time.tv_sec -> time_second
- struct timeval mono_time is gone
mono_time.tv_sec -> time_uptime
- access to time via
{get,}{micro,nano,bin}time()
get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
 1.21 31-May-2006  drochner support ntp_gettime again
compile tested by Havard Eidnes
 1.20 14-May-2006  elad branches: 1.20.2;
integrate kauth.
 1.19 17-Feb-2006  he branches: 1.19.2; 1.19.4; 1.19.6;
Paste in the conditional declaration of the pps_* extern variables
from kern_ntptime.c, so that this file can build under PPS_SYNC.
 1.18 06-Dec-2005  christos branches: 1.18.2; 1.18.4; 1.18.6;
netbsd32_timevalp_t is not really a pointer.
 1.17 05-Dec-2005  christos remove conflict.
 1.16 05-Dec-2005  christos untagle a bit.
 1.15 05-Dec-2005  kleink Sync with kern_time.c rev. 1.98:
- make settime take timespec.
- pass struct proc down so that we can log a detailed message.
 1.14 11-Nov-2005  simonb Call nanotime() directly, instead of doing the
microtime()/TIMEVAL_TO_TIMESPEC() dance.
 1.13 23-Oct-2005  cube Implement a few changes needed to properly resolve PR#30924, as
discussed in the PR.

- introduce sys/timevar.h to hold kernel-specific stuff relevant to
sys/time.h. Ideally, timevar.h would contain all (or almost) of the
#ifdef _KERNEL part of time.h, but that's a pretty big and tedious
change to make. For now, it will contain only the prototypes I
introduced when working on COMPAT_NETBSD32.

- split copyinout_t into copyin_t and copyout_t, it makes prototypes more
explicit about the meaning of a given argument. Suggested by yamt@.

- move copyinout_t definition in sys/time.h to systm.h as copyin_t and
copyout_t

- make everything uses the new types and include the proper headers at
the proper places.
 1.12 19-Aug-2005  christos branches: 1.12.2;
Fix lossage I created with the 64 bit ino_t change.
 1.11 23-Jul-2005  cube Implement the timer_create(2) family of syscalls.
 1.10 11-Jul-2005  cube Split sys_getitimer and sys_setitimer to make it possible to share the
relevant code with the COMPAT_NETBSD32 version, and make the latter use
the new functions.

This fixes netbsd32_setitimer() which had drifted from the native syscall
and did not work properly anymore.
 1.9 31-May-2005  christos branches: 1.9.2;
- add const
- avoid shadowed variables.
 1.8 26-Feb-2005  perry nuke trailing whitespace
 1.7 14-Nov-2004  atatat branches: 1.7.4; 1.7.6;
Wrap TIMEVAL_TO_TIMESPEC and TIMESPEC_TO_TIMEVAL macros in

do { ... } while(/*CONSTCOND*/0)

so that they can be used unadorned in if/else blocks, etc. This means
that you now *have* to put a ; at the end of the "call" to these
macros.
 1.6 21-Oct-2003  fvdl Fix NULL vs. int comparison.
 1.5 18-Jan-2003  thorpej branches: 1.5.2;
Merge the nathanw_sa branch.
 1.4 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.3 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.2 30-May-2001  mrg branches: 1.2.2;
use _KERNEL_OPT.
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.4.5 20-Nov-2002  petrov p_timers changes.
 1.1.4.4 11-Nov-2002  nathanw Catch up to -current
 1.1.4.3 23-Aug-2002  petrov lwpification.
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_time.c was added on branch thorpej_scsipi on 2001-02-11 19:14:22 +0000
 1.2.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.2.7 11-Dec-2005  christos Sync with head.
 1.5.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.4 29-Nov-2004  skrll Sync with HEAD.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.9.2.5 21-Jan-2008  yamt sync with head
 1.9.2.4 07-Dec-2007  yamt sync with head
 1.9.2.3 03-Sep-2007  yamt sync with head.
 1.9.2.2 30-Dec-2006  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.12.2.1 26-Oct-2005  yamt sync with head
 1.18.6.5 03-Jun-2006  kardel remove unused decls
adjtime to ntp_adjtime1() interface
 1.18.6.4 02-Jun-2006  drochner remove a leftover CVS conflict marker
 1.18.6.3 01-Jun-2006  kardel Sync with head.
 1.18.6.2 30-Apr-2006  kardel - simplify emulation layer by avoiding code
replication from the actual implementation
 1.18.6.1 22-Apr-2006  simonb Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.18.2.1 18-Feb-2006  yamt sync with head.
 1.19.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.19.4.3 12-May-2006  elad include sys/kauth.h where appropriate.
 1.19.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.19.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.19.2.3 11-Aug-2006  yamt sync with head
 1.19.2.2 26-Jun-2006  yamt sync with head.
 1.19.2.1 24-May-2006  yamt sync with head.
 1.20.2.1 19-Jun-2006  chap Sync with head.
 1.23.6.1 10-Dec-2006  yamt sync with head.
 1.23.4.1 18-Nov-2006  ad Sync with head.
 1.24.4.2 24-Mar-2007  yamt sync with head.
 1.24.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.6.2 29-Mar-2007  reinoud Pullup to -current
 1.25.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.25.4.1 11-Jul-2007  mjf Sync with head.
 1.25.2.1 10-Apr-2007  ad Sync with head.
 1.27.16.3 18-Feb-2008  mjf Sync with HEAD.
 1.27.16.2 27-Dec-2007  mjf Sync with HEAD.
 1.27.16.1 08-Dec-2007  mjf Sync with HEAD.
 1.27.10.2 23-Mar-2008  matt sync with HEAD
 1.27.10.1 09-Jan-2008  matt sync with HEAD
 1.27.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.27.8.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.28.2.1 26-Dec-2007  ad Sync with head.
 1.29.4.2 23-Jan-2008  bouyer Sync with HEAD.
 1.29.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.32.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.32.10.2 11-Aug-2010  yamt sync with head.
 1.32.10.1 04-May-2009  yamt sync with head.
 1.32.8.1 04-Jun-2008  yamt sync with head
 1.32.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.32.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.32.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.4.1 19-Oct-2008  haad Sync with HEAD.
 1.33.2.1 18-Jul-2008  simonb Sync with head.
 1.34.8.3 04-Jan-2009  christos fix module build.
 1.34.8.2 04-Jan-2009  christos add new syscalls.
 1.34.8.1 15-Jul-2008  christos file netbsd32_time.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.34.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.34.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.35.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.4.1 30-May-2010  rmind sync with head
 1.36.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.41.18.2 03-Dec-2017  jdolecek update from HEAD
 1.41.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.41.8.1 30-Oct-2012  yamt sync with head
 1.42.14.4 28-Aug-2017  skrll Sync with HEAD
 1.42.14.3 05-Oct-2016  skrll Sync with HEAD
 1.42.14.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.42.14.1 22-Sep-2015  skrll Sync with HEAD
 1.42.12.1 17-Jul-2015  snj Pull up following revision(s) (requested by martin in ticket #879):
sys/compat/netbsd32/netbsd32_time.c: revision 1.43
Use the right type in sizeof() for copyin() in adjtime
 1.46.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.46.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.48.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.49.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.49.14.1 10-Jun-2019  christos Sync with HEAD
 1.49.12.4 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.49.12.3 27-Sep-2018  pgoyette typo: insert missing ')'
 1.49.12.2 25-Sep-2018  pgoyette Additional use of NTP function pointers, since the NTP code might not
exist in the kernel. (NTP is not (yet) a module, so we don't need to
use the MP-safe mechanism.)
 1.49.12.1 11-Sep-2018  pgoyette Move the NTP compat_30 and compat_50 routines into the version-specific
modules.
 1.49.6.2 21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1839):

sys/compat/common/kern_time_30.c: revision 1.6
sys/compat/netbsd32/netbsd32_time.c: revision 1.50

Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.

These structs don't have padding but safer to keep the code
structured the same way between the various ntp_gettimes in case
anyone makes more copypasta of it for future updates.
 1.49.6.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.51.4.1 03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

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

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.53.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 08-Dec-2001  thorpej Make the coredump routine exec-format/emulation specific. Split
out traditional NetBSD coredump routines into core_netbsd.c and
netbsd32_core.c (for COMPAT_NETBSD32).
 1.3 13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.2 06-Jun-2001  mrg branches: 1.2.2; 1.2.4;
sync with uvm_unix.c 1.23
 1.1 06-Jun-2001  mrg LKM friendly: move uvm_coredump32() here
 1.2.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.2.4 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.2.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.2.2.1 06-Jun-2001  nathanw file netbsd32_uvm_unix.c was added on branch nathanw_sa on 2001-06-21 20:00:12 +0000
 1.3 19-Jan-2021  simonb Also print mmap return value and error code #ifdef DEBUG_MMAP.
 1.2 07-Jan-2020  mrg branches: 1.2.8;
don't check the value of retval in netbsd32_mmap() if sys_mmap()
was not successful.
 1.1 24-Dec-2018  mrg branches: 1.1.2; 1.1.6;
move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.1.6.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.6.2 10-Jun-2019  christos Sync with HEAD
 1.1.6.1 24-Dec-2018  christos file netbsd32_vm.c was added on branch phil-wifi on 2019-06-10 22:07:02 +0000
 1.1.2.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.2.1 24-Dec-2018  pgoyette file netbsd32_vm.c was added on branch pgoyette-compat on 2018-12-26 14:01:46 +0000
 1.2.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.26 05-Dec-2021  msaitoh s/sytle/style/ in comment.
 1.25 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.24 15-Oct-2020  rin wait4(2): make error paths match with that of native wait4(2):

https://nxr.netbsd.org/xref/src/sys/kern/kern_exit.c#720
 1.23 23-Sep-2016  skrll branches: 1.23.8; 1.23.20;
Add netbsd32_clock_getcpuclockid2 and netbsd32_wait6 functions
 1.22 03-Nov-2012  njoly branches: 1.22.14; 1.22.18;
Move rusage computation to a new getrusage1() function. Adjust all
compat/emulations to make use of it.
 1.21 04-Nov-2009  rmind branches: 1.21.12; 1.21.22;
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.20 11-Jan-2009  christos merge christos-time_t
 1.19 29-May-2008  mrg branches: 1.19.6; 1.19.12;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.18 24-Apr-2008  ad branches: 1.18.2; 1.18.4;
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.17 20-Dec-2007  dsl branches: 1.17.6; 1.17.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.16 08-Dec-2007  dsl branches: 1.16.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.15 07-May-2007  dsl branches: 1.15.6; 1.15.8; 1.15.16;
Split sys_wait4() so that compat code can fiddle with the returned 'status'
and 'rusage' without having to copy data to/from stackgap buffers.
The old split (find_stopped_child) could be removed.
amd64 seems to run netbsd32, linux and linux32 emulations. sparc64 compiles.
 1.14 18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.13 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.12 04-Mar-2007  christos branches: 1.12.2; 1.12.4; 1.12.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 09-Feb-2007  ad branches: 1.11.2;
Merge newlock2 to head.
 1.10 11-Dec-2005  christos branches: 1.10.20;
merge ktrace-lwp.
 1.9 19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.8 22-Jul-2005  cube Remove duplication of code for netbsd32_wait4() by using stackgap(9).
 1.7 10-Jul-2005  cube Report changes from sys_wait4().
 1.6 14-Feb-2003  dsl branches: 1.6.2; 1.6.18;
Use find_stopped_child() and proc_free() in compat wait() code to
avoid code duplication.
(approved by christos)
 1.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 23-Oct-2002  scw branches: 1.4.2;
In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.3 28-Jul-2002  jdolecek Convert to use p_opptr rather than p_oppid. Part of fix for
security/14444 by David Sainty.
 1.2 13-Nov-2001  lukem branches: 1.2.8; 1.2.10;
add RCSIDs (including regeneration of files as appropriate)
 1.1 08-Feb-2001  mrg branches: 1.1.2; 1.1.4; 1.1.6;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.4 11-Nov-2002  nathanw Catch up to -current
 1.1.4.3 23-Aug-2002  petrov lwpification.
 1.1.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 08-Feb-2001  bouyer file netbsd32_wait.c was added on branch thorpej_scsipi on 2001-02-11 19:14:23 +0000
 1.2.10.1 29-Jul-2002  lukem Pull up revision 1.3 (requested by jdolocek in ticket #557):
Convert to use p_opptr rather than p_oppid. Part of fix for
security/14444 by David Sainty.
 1.2.8.1 29-Aug-2002  gehenna catch up with -current.
 1.4.2.1 18-Dec-2002  gmcgarry Merge pcred and ucred, and poolify. TBD: check backward compatibility
and factor-out some higher-level functionality.
 1.6.18.4 21-Jan-2008  yamt sync with head
 1.6.18.3 03-Sep-2007  yamt sync with head.
 1.6.18.2 26-Feb-2007  yamt sync with head.
 1.6.18.1 21-Jun-2006  yamt sync with head.
 1.6.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.20.1 17-Nov-2006  ad Checkpoint work in progress.
 1.11.2.3 17-May-2007  yamt sync with head.
 1.11.2.2 24-Mar-2007  yamt sync with head.
 1.11.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.6.2 29-Mar-2007  reinoud Pullup to -current
 1.12.6.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.12.4.1 11-Jul-2007  mjf Sync with head.
 1.12.2.2 27-May-2007  ad Sync with head.
 1.12.2.1 10-Apr-2007  ad Sync with head.
 1.15.16.1 26-Dec-2007  ad Sync with head.
 1.15.8.1 09-Jan-2008  matt sync with HEAD
 1.15.6.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.17.8.2 04-Jun-2008  yamt sync with head
 1.17.8.1 18-May-2008  yamt sync with head.
 1.17.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.17.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.4.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.2.2 11-Mar-2010  yamt sync with head
 1.18.2.1 04-May-2009  yamt sync with head.
 1.19.12.2 04-Jan-2009  christos add new syscalls.
 1.19.12.1 29-May-2008  christos file netbsd32_wait.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.19.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.22.2 03-Dec-2017  jdolecek update from HEAD
 1.21.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.12.1 16-Jan-2013  yamt sync with (a bit old) head
 1.22.18.1 04-Nov-2016  pgoyette Sync with HEAD
 1.22.14.1 05-Oct-2016  skrll Sync with HEAD
 1.23.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.23.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.19 19-May-2024  christos version dup3
 1.18 19-Dec-2022  pgoyette Create compat_100 module infrastructure now that we have branched
for NetBSD-10
 1.17 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.16 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.15 01-Dec-2015  pgoyette branches: 1.15.16; 1.15.18;
Adapt to per-emulation syscall_autoload capability (the table of syscalls
that can be autoloaded is currently empty).
 1.14 07-Mar-2015  christos regen
 1.13 16-Aug-2014  apb branches: 1.13.2;
Add COMPAT_70 to conf/files; add compat_70 to kern/syscalls.conf
and compat/netbsd32/syscalls.conf.
 1.12 29-Mar-2013  christos compat glue for new lwp_park
 1.11 11-Jan-2009  christos branches: 1.11.14; 1.11.24;
merge christos-time_t
 1.10 09-Nov-2007  dsl branches: 1.10.14; 1.10.18; 1.10.26; 1.10.32;
Add arguments to sys_syscall and sys___syscall.
Use MI wrappers for them in netbsd32.
Change prefix for constants from netbsd32 to NETBSD32 (used in #defines etc).
 1.9 05-May-2006  cube branches: 1.9.32; 1.9.34; 1.9.38; 1.9.40;
Add compat_30 as a compatopts.
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.6; 1.8.8; 1.8.10; 1.8.12;
merge ktrace-lwp.
 1.7 21-Apr-2004  christos branches: 1.7.12;
Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.6 13-Oct-2003  fvdl Define compat_16 as valid prefix; define the 1.6 compat sigreturn.
 1.5 01-Nov-2002  jdolecek branches: 1.5.6;
set nsysent to 512
 1.4 11-Oct-1999  eeh branches: 1.4.12;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.3 25-Mar-1999  mrg branches: 1.3.8;
move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.2 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.12.1 11-Nov-2002  nathanw Catch up to -current
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.12.2 15-Nov-2007  yamt sync with head.
 1.7.12.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.10.1 11-May-2006  elad sync with head
 1.8.8.1 24-May-2006  yamt sync with head.
 1.8.6.1 01-Jun-2006  kardel Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.40.1 19-Nov-2007  mjf Sync with HEAD.
 1.9.38.1 13-Nov-2007  bouyer Sync with HEAD
 1.9.34.1 09-Jan-2008  matt sync with HEAD
 1.9.32.1 11-Nov-2007  joerg Sync with HEAD.
 1.10.32.1 04-Jan-2009  christos add new syscalls.
 1.10.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.18.1 04-May-2009  yamt sync with head.
 1.10.14.1 17-Jan-2009  mjf Sync with HEAD.
 1.11.24.2 03-Dec-2017  jdolecek update from HEAD
 1.11.24.1 23-Jun-2013  tls resync from head
 1.11.14.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.13.2.1 06-Apr-2015  skrll Sync with HEAD
 1.15.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.15.18.1 10-Jun-2019  christos Sync with HEAD
 1.15.16.1 10-Sep-2018  pgoyette Another compat_80
 1.147 09-May-2025  martin PR 59352: add netbsd32 compat for semtimedop(2)
 1.146 20-May-2024  christos branches: 1.146.2;
Rename dup3110 to dup3100 to match historical practice for NetBSD-11,
because we already have kevent100. Fix compat_dup3 to belong in compat_100
not compat_110.
 1.145 19-May-2024  christos version dup3
 1.144 30-Jul-2023  rin COMPAT_NETBSD32: Add support for epoll(2).
 1.143 30-Jul-2023  rin COMPAT_NETBSD32: Add support for memfd_create(2).
 1.142 29-Jul-2023  rin COMPAT_NETBSD32: Catch up with sys___kevent100() addition.

XXX
Add epoll_* and memfd_create.
 1.141 20-Sep-2021  thorpej Add the eventfd(2) system call to COMPAT_NETBSD32.
 1.140 20-Sep-2021  thorpej Add timerfd system calls to COMPAT_NETBSD32.
 1.139 10-Oct-2020  rin Teach about getrandom(2) to COMPAT_NETBSD32.
 1.138 16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.137 26-Apr-2020  thorpej Mirror the change made to native -- move futex calls to 166-168.
 1.136 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.135 22-Apr-2020  thorpej Remove _lwp_gettid(2) system call. This problem is going to be solved
another way. (Note: this call was never exposed in libc, so we can just
recycle the syscall number.)
 1.134 04-Apr-2020  thorpej branches: 1.134.2;
Add support for lazily generating a "global thread ID" for a LWP. This
identifier uniquely identifies an LWP across the entire system, and will
be used in future improvements in user-space synchronization primitives.

(Test disabled and libc stub not included intentionally so as to avoid
multiple libc version bumps.)
 1.133 12-Mar-2020  pgoyette Split out the quota code from the rest of compat_netbsd32 module. This
allows loading of compat_netbsd32 on kernels that don't have ``options
QUOTA'' enabled.
 1.132 07-Mar-2020  pgoyette Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents. With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9
 1.131 18-Jan-2020  kamil Catch up after getpid/getgid/getuid changes in native ABI in 2008

getpid(), getuid() and getgid() used to call respectively sys_getpid(),
sys_getuid() and sys_getgid(). In the BSD4.3 compat mode there was a
fallback to call sys_getpid_with_ppid() and related functions.

In 2008 the compat ifdef was removed in sys/kern/syscalls.master r. 1.216.

For purity reasons we probably shall restore the NetBSD original behavior
and implement BSD4.3 one as a compat module, however it is not worth the
complexity.

Align the netbsd32 compat ABI to native ABI and call functions that return
two integers as in BSD4.3.
 1.130 04-Nov-2019  rin branches: 1.130.2;
netbsd32_size_t should be used instead of size_t for argument of
32-bit syscalls:

- netbsd32___getvfsstat90: bufsize
- netbsd32___fhstatvfs190: fh_size

No need to pullup, since these syscalls were introduced after
branch of netbsd-9.
 1.129 04-Nov-2019  rin For netbsd32_readlinkat(2), bufsize is netbsd_size_t, not size_t.
Since bufsize is the last argument, this affects only LP64EB.

XXX
pullup to netbsd-9, -8, and -7
 1.128 22-Sep-2019  christos Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
 1.127 18-Jun-2019  christos branches: 1.127.2;
Add ifdef for quota and include the syscall numbers header
 1.126 18-Jun-2019  christos use option quota
 1.125 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.124 24-Dec-2018  mrg move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat. mark old mount()
properly instead of manually #if'ing ito to ENOSYS.
 1.123 31-Jul-2018  rjs Add getsockopt2().
 1.122 12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

* Removes "options PERFCTRS", the associated includes, and the associated
ifdefs. In doing so, it removes several XXXSMPs in the MI code, which is
good.

* Removes the PMC code of ARM XSCALE.

* Removes all the pmc.h files. They were all empty, except for ARM XSCALE.

* Reorders the x86 PMC code not to rely on the legacy pmc.h file. The
definitions are put in sysarch.h.

* Removes the kern/sys_pmc.c file, and along with it, the sys_pmc_control
and sys_pmc_get_info syscalls. They are marked as OBSOL in kern,
netbsd32 and rump.

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.121 10-May-2018  christos branches: 1.121.2;
add {send,recv}mmsg
 1.120 06-Jan-2018  kamil branches: 1.120.2;
Revert vadvise(2) removal

This system call was used in legacy Lisp code, that was inherited to modern
age and still compiled against supported compat layers (e.g. in clisp,
oaklisp, Franz Lisp).

It used to instruct the kernel about paging policy (G/C aware, flush etc).

Newly compiled code (assuming that it will detect vadvise()) will use the
libc stub for vadvise(). The headers for this interface are gone.

vadvise(2) could be marked as COMPAT_80, but as long as we support ultrix,
sunos or aout68k ABI, don't bother with this.

Requested by <mrg>
 1.119 19-Dec-2017  kamil Drop SYS_vadvise

The (o)vadvise syscall is dummy since the beginning of NetBSD.

It is an obsolete remnant from the old UNIX.

Sponsored by <The NetBSD Foundation>
 1.118 19-Dec-2017  kamil Drop SYS_sbrk

sbrk - change data segment size

This syscall is dummy since the inception of the project.

Sponsored by <The NetBSD Foundation>
 1.117 19-Dec-2017  kamil Drop the sstk(2) syscall stub

sstk - change stack section size

This functionality has never been implemented and is a remnant from 16-bit
UNIX. This stub appeared with the first NetBSD commit.

Sponsored by <The NetBSD Foundation>
 1.116 19-Dec-2017  kamil Sync syscalls.master in compat_netbsd32(8) with kern/syscalls.master

___lwp_part60 removed 'const' from the ts argument.

'const struct timespec *ts' -> 'struct timespec *ts'

Sponsored by <The NetBSD Foundation>
 1.115 19-Oct-2016  skrll branches: 1.115.8;
PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel

Updated from the original patch in the PR by me.
 1.114 23-Sep-2016  skrll Add wait6 and clock_getcpuclockid2
 1.113 10-Sep-2016  skrll Add _sched_protect
 1.112 03-Dec-2015  pgoyette branches: 1.112.2;
Split out the SYSV IPC stuff into its own compat_netbsd32_sysvipc
module. Adjust dependencies as needed.
 1.111 01-Dec-2015  pgoyette Prepare for new compat_netbsd32_mqueue module to be split out of
compat_netbsd32. Refactor the COMPAT_50 code related to mqueue,
and update the syscall definitions. Remove dependency on mqueue
from the compat_netbsd32 module (the new module will gain this
dependency).

Continuation of work on PR kern/50489
 1.110 01-Dec-2015  pgoyette Mark the nfssvc syscall as auto-loadable from the compat_netbsd32_nfssrv
module (to be committed shortly).
 1.109 23-Jun-2015  dholland Don't reference netbsd32_nfssvc unless NFSSERVER is defined.
Fixes PR 49994.
 1.108 22-Jun-2015  mrg add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.

with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
 1.107 21-Jun-2015  martin Add pset_* calls
 1.106 21-Jun-2015  martin Cosmetics: fill in details about some currently unimplemented syscalls.
 1.105 21-Jun-2015  martin Add the two versioned mq_* calls I missed in the last round
 1.104 20-Jun-2015  martin Add sigqueuinfo, modctl and mq_*.
 1.103 16-Jun-2015  martin Add posix_fallocate and fdiscard
 1.102 25-Feb-2015  christos readlinkat returns ssize_t
 1.101 13-Jun-2014  joerg branches: 1.101.2; 1.101.4;
Rename argument like the native syscall.
 1.100 15-May-2014  njoly Fix setcontext signature, which has a single argument not three.
 1.99 30-Apr-2014  njoly Do not use native off_t type under compat netbsd32, but a new
netbsd32_off_t that provide the expected alignment for 64bit types.
 1.98 17-Oct-2013  njoly branches: 1.98.2;
Change mknodat(2) device argument type from uint32_t to dev_t.
Adds needed extra PAD argument for 64bit alignment, and libc wrapper.
 1.97 29-Mar-2013  christos branches: 1.97.4;
compat glue for new lwp_park
 1.96 02-Oct-2012  christos kernel portion of clock_nanosleep()
 1.95 08-Apr-2012  martin branches: 1.95.2;
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
 1.94 10-Mar-2012  joerg P1003_1B_SEMAPHORE is no longer optional.
 1.93 08-Mar-2012  joerg Add entry for _ksem_timedwait.
 1.92 19-Feb-2012  rmind Make SA calls obsolete (use stubs in kern case, as libc needs them for now).
 1.91 01-Feb-2012  dholland branches: 1.91.2;
Update compat_netbsd32 for new quotactl.
 1.90 01-Feb-2012  dholland Change the syscall API for quotas over to the new non-proplib one.

- struct vfs_quotactl_args -> struct quotactl_args
- add sys/stdint.h to sys/quotactl.h for clean userland build
- install sys/quotactl.h in /usr/include
- update set lists for same
- add new marshalling code in libquota
- add new unmarshalling code in vfs_syscalls.c
- discard proplib interpreter code in vfs_quotactl.c
- add dispatching code for the 14 quotactl ops in vfs_quotactl.c
- mark the proplib quotactl syscall obsolete
- add a new syscall number for the new quotactl syscall
- change the name of the syscall to __quotactl()
- remove the decl of the old quotactl from quota/quotaprop.h
- add a decl of the new quotactl to sys/quotactl.h
- update the libc build
- update ktruss
- remove proplib marshalling code from libquota
- update copy of syscall table in gdb ppc sources
- hack rumphijack to accomodate new quotactl name (as I recall,
pooka wanted such a name change to simplify something, but I
don't really see what/how)

This change appears to require a kernel version bump for rumpish
reasons.
 1.89 31-Jan-2012  matt Add the *at syscalls and other missing syscalls.
 1.88 08-Nov-2011  njoly branches: 1.88.4;
Add kqueue1(2) support.
 1.87 31-Aug-2011  njoly branches: 1.87.2;
Add dup3 syscall support.
 1.86 05-Jul-2011  njoly Add pipe2 syscall now needed for popen(3).
 1.85 06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.84 02-Mar-2010  pooka branches: 1.84.2; 1.84.4; 1.84.6;
Kill fs_nfs.h and #ifdef NFS by making getfh() support unconditional
and nfssvc unsupport unconditional. nfs server was just a fancy
NOP anyway for all except Ultrix. I know I'm boring but I couldn't
imagine why someone would want to run an Ultrix nfs server (and I
also doubt that it would work anymore with all the changes to fs
exporting etc).
 1.83 02-Mar-2010  pooka -fs_lfs.h
 1.82 02-Mar-2010  pooka Remove lfs syscall support from compat. I can't really imagine
anyone wanting to run lfs megamaid as a e.g. FreeBSD binary.
Besides, the real action has been in fcntl() for >5 years now.
The only place where the compat syscalls might have made the tiniest
bit of sense was netbsd32, but they were unimplemented there.
 1.81 14-Dec-2009  matt branches: 1.81.2;
Merge from matt-nb5-mips64
 1.80 17-May-2009  pooka pad -> PAD
 1.79 16-Mar-2009  njoly Fix dev_t alignment, by not using the new 64bit value directly but
rather a 32bit aligned version (netbsd32_dev_t = netbsd32_uint64).

ok by cube@.
 1.78 26-Feb-2009  christos fix kernel build with no options NTP
 1.77 13-Jan-2009  pooka branches: 1.77.2;
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.76 13-Jan-2009  pooka UNIMPL police: remove pseudo-prototypes
 1.75 11-Jan-2009  christos merge christos-time_t
 1.74 22-Nov-2008  mrg branches: 1.74.4;
implement netbsd32__sched_setparam(), netbsd32__sched_getparam(),
netbsd32__sched_setaffinity() and netbsd32__sched_getaffinity().
 1.73 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.72 14-Nov-2008  ad Replace semid_t with intptr_t. No function change. This is a libc/kernel
private interface and so the name change should not affect any third
party code.
 1.71 12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.70 15-Oct-2008  wrstuden branches: 1.70.2; 1.70.4;
Merge wrstuden-revivesa into HEAD.
 1.69 24-Apr-2008  ad branches: 1.69.2; 1.69.4; 1.69.8;
- Retire SYCALL_MPSAFE. With the exceptions of darwin and irix emulations,
all system calls are now MPSAFE.
- Remove unneeded acquire/release of kernel_lock.
 1.68 24-Feb-2008  martin branches: 1.68.2;
Desupport compatibility for the old posix_fadvise syscall per yamt's
request and just ignore it.
 1.67 27-Jan-2008  martin branches: 1.67.2; 1.67.6;
Catch up with versioning of posix_fadvise
 1.66 26-Jan-2008  dsl Add a wrapper for posix_fadvise()
 1.65 19-Jan-2008  dsl Add netbsd32 wrapper for sys_mremap(), compiles, and assuming the mmap()
wrapper is ok, it should work!
I presume the kernel knows not to map above 4GB though....
 1.64 17-Dec-2007  dsl Remove all the 'const'. Although the fields might be 32bit pointers to
constant data, the 'const' applies to the field itself - which is stupid.
 1.63 07-Dec-2007  ad branches: 1.63.4;
Add: _lwp_setname, _lwp_getname, _lwp_ctl.
 1.62 09-Nov-2007  dsl branches: 1.62.2;
Add arguments to sys_syscall and sys___syscall.
Use MI wrappers for them in netbsd32.
Change prefix for constants from netbsd32 to NETBSD32 (used in #defines etc).
 1.61 15-Aug-2007  ad branches: 1.61.2; 1.61.6; 1.61.8;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.60 07-Aug-2007  ad - Fix a bug with _lwp_park() where if the computed wakeup time was under
1 microsecond into the future, the thread could enter an untimed sleep.
- Change the signature of _lwp_park() to accept an lwpid_t and second
hint pointer, but do so in a way that remains compatible with older
pthread libraries. This can be used to wake another thread before the
calling thread goes asleep, saving at least one syscall + involuntary
context switch. This turns out to be a fairly large win on the condvar
benchmarks that I have tried.
- Mark some more syscalls MP safe.
 1.59 04-Mar-2007  christos branches: 1.59.2; 1.59.6; 1.59.10; 1.59.14;
fix fallout from caddr_t changes.
 1.58 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.57 19-Feb-2007  cube Mark MPSAFE the syscalls that are not translated (and of course, only when
the native syscall is itself marked MPSAFE).
 1.56 18-Feb-2007  cube Add missing lwp syscalls. Put them all together into a new file,
netbsd32_lwp.c, and remove remaining traces of SA.

This still needs some MD (and possibly MI, depending on the chosen
solution) changes to actually work.
 1.55 09-Feb-2007  ad branches: 1.55.2;
Merge newlock2 to head.
 1.54 09-Nov-2006  cube - Make better use of COMPAT_XX type in syscalls.master
- Remove useless (thanks to COMPAT_XX behaviour) #ifdefs in
syscalls.master
- Make netbsd32_compat_43.c compiled per COMPAT_LINUX32 because the latter
needs stuff from it.

Fixes Perry's PR#34951.
 1.53 01-Sep-2006  matt branches: 1.53.2; 1.53.4;
Don't conditionalize *sys_ptrace. The lack of sys_ptrace will be dealt
with differently.
 1.52 30-Aug-2006  cube Protect netbsd32_ptrace with options PTRACE.
 1.51 31-Jul-2006  martin Step 1 to make filehandles completely opaque to userland
 1.50 13-Jul-2006  pavel do not protect the getfh syscall by
#if defined(NFS) || defined(NFSSERVER).
The native syscall also isn't.
 1.49 13-Jul-2006  martin Fix alignement problems for fhandle_t, exposed by gcc4.1.

While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ,
version the getfh(2) syscall and explicitly pass the size available in
the filehandle from userland.

Discussed on tech-kern, with lots of help from yamt (thanks!).
 1.48 26-Jun-2006  mrg version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
 1.47 31-May-2006  drochner branches: 1.47.2;
support ntp_gettime again
compile tested by Havard Eidnes
 1.46 29-May-2006  drochner Remove emulation of ntp_gettime. In preparation for "timecounters" we
will change "struct ntptimeval", so some translation would be necessary.
ntp_gettine is considered dispensable, the only userland program known
to use it is "ntptime".
 1.45 05-May-2006  cube branches: 1.45.2;
Follow on fhstat(2) versioning. While there, add sys_posix_fadvise (no
emulation needed there).
 1.44 29-Mar-2006  cube Implement the _lwp* and sa_* families of syscalls, using the newly
introduced hooks in the native code.
 1.43 06-Mar-2006  cube branches: 1.43.2; 1.43.4;
Implement the SysV IPC family of syscalls.
 1.42 05-Mar-2006  cube branches: 1.42.2;
Implement the ksem_* family of syscalls.
 1.41 11-Dec-2005  christos branches: 1.41.4; 1.41.6;
merge ktrace-lwp.
 1.40 23-Oct-2005  cube - Split sys_kevent into kevent1 so that it can be used by COMPAT_NETBSD32
code.

- To achieve COMPAT_NETBSD32 compatibility, introduce a parameter to
kevent1 that points to functions that do the actual copyin/copyout
operations. This is similar to what was done in FreeBSD by Paul Saab.

- Add the COMPAT_NETBSD32 definitions and hooks.
 1.39 19-Aug-2005  christos branches: 1.39.2;
Fix lossage I created with the 64 bit ino_t change.
 1.38 19-Aug-2005  christos 64 bit inode changes.
 1.37 23-Jul-2005  cube Implement __sigtimedwait(2).
 1.36 23-Jul-2005  cube Implement the timer_create(2) family of syscalls.
 1.35 12-Jul-2005  cube Add the *xattr(2) family of syscalls. Just like the *extattr(2) family,
they're waiting for an actual FS back-end to be tested, but are still
straightforward enough.
 1.34 11-Jul-2005  cube Add rasctl(2). Thanks to the regression tests for that syscall, I was able
to discover the bugs in netbsd32_setitimer() and netbsd32_execve().
 1.33 10-Jul-2005  cube Add support for fsync_range(2).
 1.32 10-Jul-2005  cube Implement __clone(2).
 1.31 09-Jul-2005  cube Implement pselect(2) and pollts(2).
 1.30 08-Jul-2005  cube Add mlockall(2) and munlockall(2).
 1.29 08-Jul-2005  cube Implement the extattr(3) family of syscalls.

XXX However, those remain untested as there are currently no backend for
XXX extattr(9) in NetBSD.
 1.28 04-Jul-2005  cube branches: 1.28.2;
Implement uuidgen(2).
 1.27 30-May-2005  chs track change to swapctl args in kern/syscalls.master.
 1.26 17-Jun-2004  cube o Add support for the statvfs family of syscalls (statvfs1, fstatvfs1,
fhstatvfs1 and getvfsstat)
o Move the statfs family out of netbsd32_fs.c and netbsd32_netbsd.c to
netbsd_compat_20.c, compiled with COMPAT_20

Reviewed by christos@.
 1.25 25-Oct-2003  chs allow COMPAT_SUNOS without COMPAT_43.
 1.24 13-Oct-2003  fvdl Define compat_16 as valid prefix; define the 1.6 compat sigreturn.
 1.23 18-Jan-2003  thorpej branches: 1.23.2;
Merge the nathanw_sa branch.
 1.22 23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.21 29-Apr-2002  mrg build the netbsd32_compat* objects into libcompat.a, so they are available
to emulations not just netbsd itself. rename the compat_10 functions to
match everything else. fixes a problem reported by julian coleman.
 1.20 30-May-2001  mrg branches: 1.20.2;
use _KERNEL_OPT.
 1.19 10-Apr-2001  kleink Slight indentation nit.
 1.18 02-Feb-2001  mrg branches: 1.18.2;
add lchflags, issetugid, utrace, reserves for [gs]etcontext, and sched/SA.
 1.17 27-Jan-2001  thorpej getpid(2) is MP-safe.
 1.16 09-Dec-2000  mycroft Add the %% separators.
 1.15 30-Nov-2000  jdolecek always include netbsd32_ntp_adjtime(), LKMify
 1.14 07-Aug-2000  bjh21 Changes to syscalls.master to exclude ntp_adjtime(2) entirely if NTP is not
defined. Changes to other files will follow in a moment.
 1.13 09-Jul-2000  mrg - massive warning fix fest.
- fix pread/pwrite return values (plus some other syscalls that looked
similarly broken).
- prototypes and clean up for netbsd32_ioctl.c

now getpw*() works under compat32!
 1.12 31-Jan-2000  christos __semctl13 -> ____semctl13
 1.11 30-Dec-1999  eeh Update to 32-bit compatibility routines.
 1.10 11-Oct-1999  eeh branches: 1.10.2;
Add netbsd32_compat_14.c

Rename everything from compat_netbsd32 -> netbsd32 so we don't have silly
names like compat_14_compat_netbsd32_sys_shmctl().
 1.9 12-Jul-1999  kleink branches: 1.9.2;
XSH5: change function signature to `void *sbrk(intptr_t)'.
 1.8 09-Jun-1999  christos Propagate kern changes
 1.7 25-Mar-1999  mrg branches: 1.7.4;
move sparc32 to netbsd32; split out MD part (signal handling) (mostly via repository copy, rename and perl -pi :-)
 1.6 25-Mar-1999  mrg make this match the main syscalls.master a bit better.
 1.5 10-Dec-1998  christos Defopt COMPAT_43
 1.4 19-Oct-1998  tron Defopt SYSVMSG, SYSVSEM and SYSVSHM.
 1.3 01-Oct-1998  eeh Overhaul. Now will run simple things like /bin/sh and /bin/echo.
 1.2 26-Aug-1998  mrg make oreboot work.
 1.1 26-Aug-1998  mrg add a 32-bit compatibility module for the sparc64 port, so it can run NetBSD/sparc binaries with a LP64 kernel.
 1.7.4.2 02-Aug-1999  thorpej Update from trunk.
 1.7.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.2.5 21-Apr-2001  bouyer Sync with HEAD
 1.10.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.10.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.10.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.10.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.18.2.4 11-Nov-2002  nathanw Catch up to -current
 1.18.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.18.2.2 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.18.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.20.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.23.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.23.2.1 03-Aug-2004  skrll Sync with HEAD
 1.28.2.8 27-Feb-2008  yamt sync with head.
 1.28.2.7 04-Feb-2008  yamt sync with head.
 1.28.2.6 21-Jan-2008  yamt sync with head
 1.28.2.5 15-Nov-2007  yamt sync with head.
 1.28.2.4 03-Sep-2007  yamt sync with head.
 1.28.2.3 26-Feb-2007  yamt sync with head.
 1.28.2.2 30-Dec-2006  yamt sync with head.
 1.28.2.1 21-Jun-2006  yamt sync with head.
 1.39.2.1 26-Oct-2005  yamt sync with head
 1.41.6.2 01-Jun-2006  kardel Sync with head.
 1.41.6.1 22-Apr-2006  simonb Sync with head.
 1.41.4.1 09-Sep-2006  rpaulo sync with head
 1.42.2.6 11-Aug-2006  yamt sync with head
 1.42.2.5 26-Jun-2006  yamt sync with head.
 1.42.2.4 24-May-2006  yamt sync with head.
 1.42.2.3 01-Apr-2006  yamt sync with head.
 1.42.2.2 13-Mar-2006  yamt sync with head.
 1.42.2.1 05-Mar-2006  yamt file syscalls.master was added on branch yamt-pdpolicy on 2006-03-13 09:07:08 +0000
 1.43.4.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.43.4.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.43.2.2 11-May-2006  elad sync with head
 1.43.2.1 19-Apr-2006  elad sync with head.
 1.45.2.1 19-Jun-2006  chap Sync with head.
 1.47.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.53.4.1 10-Dec-2006  yamt sync with head.
 1.53.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.53.2.1 18-Nov-2006  ad Sync with head.
 1.55.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.59.14.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.59.14.3 11-Nov-2007  joerg Sync with HEAD.
 1.59.14.2 16-Aug-2007  jmcneill Sync with HEAD.
 1.59.14.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.59.10.2 03-Sep-2007  skrll Sync with HEAD.
 1.59.10.1 15-Aug-2007  skrll Sync with HEAD.
 1.59.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.59.2.1 20-Aug-2007  ad Sync with HEAD.
 1.61.8.4 18-Feb-2008  mjf Sync with HEAD.
 1.61.8.3 27-Dec-2007  mjf Sync with HEAD.
 1.61.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.61.8.1 19-Nov-2007  mjf Sync with HEAD.
 1.61.6.1 13-Nov-2007  bouyer Sync with HEAD
 1.61.2.2 23-Mar-2008  matt sync with HEAD
 1.61.2.1 09-Jan-2008  matt sync with HEAD
 1.62.2.2 26-Dec-2007  ad Sync with head.
 1.62.2.1 08-Dec-2007  ad Sync with head.
 1.63.4.2 20-Jan-2008  bouyer Sync with HEAD
 1.63.4.1 02-Jan-2008  bouyer Sync with HEAD
 1.67.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.67.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.67.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.67.2.1 24-Mar-2008  keiichi sync with head.
 1.68.2.1 18-May-2008  yamt sync with head.
 1.69.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.69.8.1 19-Oct-2008  haad Sync with HEAD.
 1.69.4.3 28-Sep-2008  skrll Re-add SA syscalls.
 1.69.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.69.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.69.2.3 11-Mar-2010  yamt sync with head
 1.69.2.2 20-Jun-2009  yamt sync with head
 1.69.2.1 04-May-2009  yamt sync with head.
 1.70.4.1 25-Nov-2008  snj branches: 1.70.4.1.4;
Pull up following revision(s) (requested by mrg in ticket #121):
sys/compat/netbsd32/syscalls.master: revision 1.74
sys/compat/netbsd32/netbsd32.h: revision 1.78
sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.149
implement netbsd32__sched_setparam(), netbsd32__sched_getparam(),
netbsd32__sched_setaffinity() and netbsd32__sched_getaffinity().
 1.70.4.1.4.1 12-Sep-2009  matt Add netbsd32___mount50
 1.70.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.70.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.70.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.74.4.3 04-Jan-2009  christos fix module build.
 1.74.4.2 04-Jan-2009  christos add new syscalls.
 1.74.4.1 22-Nov-2008  christos file syscalls.master was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.77.2.2 23-Jul-2009  jym Sync with HEAD.
 1.77.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.81.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.84.6.2 09-Feb-2011  bouyer Proper definitions for quotactl
 1.84.6.1 20-Jan-2011  bouyer Snapshot of work in progress on a modernised disk quota system:
- new quotactl syscall (versionned for backward compat), which takes
as parameter a path to a mount point, and a prop_dictionary
(in plistref format) describing commands and arguments.
For each command, status and data are returned as a prop_dictionary.
quota commands features will be added to take advantage of this,
exporting quota data or getting quota commands as plists.

- new on disk-format storage (all 64bit wide), integrated to metadata for
ffs (and playing nicely with wapbl).
Quotas are enabled on a ffs filesystem via superblock flags.
tunefs(8) can enable or disable quotas.
On a quota-enabled filesystem, fsck_ffs(8) will track per-uid/gid
block and inode usages, and will check and update quotas in Pass 6.
quota usage and limits are stored in unliked files (one for users,
one for groups)l fsck_ffs(8) will create the files if needed, or
free them if needed. This means that after enabling or disabling
quotas on a filesystem; a fsck_ffs(8) run is required.
quotacheck(8) is not needed any more, on a unclean shutdown
fsck or journal replay will take care of fixing quotas.
newfs(8) can create a ready-to-mount quota-enabled filesystem
(superblock flags are set and quota inodes are created).
Other new features or semantic changes:
- default quota datas, applied to users or groups which don't already
have a quota entry
- per-user/group grace time (instead of a filesystem global one)
- 0 really means "nothing allowed at all", not "no limit".
If you want "no limit", set the limit to UQUAD_MAX (tools will
understand "unlimited" and "-")

A quota file is structured as follow:
it starts with a header, containing a few per-filesystem values,
and the default quota limits.
Quota entries are linked together as a simple list, each entry has a
pointer (as an offset withing the file) to the next.
The header has a pointer to a list of free quota entries, and
a hash table of in-use entries. The size of the hash table depends
on the filesystem block size (header+hash table should fit in the
first block). The file is not sparse and is a multiple of
filesystem block size (when the free quota entry list is empty a new
filesystem block is allocated). quota entries to not cross
filesystem block boundaries.

In memory, the kernel keeps a cache of recently used quota entries
as a reference to the block number, and offset withing the block.
The quota entry itself is keept in the buf cache.

fsck_ffs(8), tunefs(8) and newfs(8) supports are completed (with
related atf tests :)
The kernel can update disk usage and report it via quotactl(2).

Todo: enforce quotas limits (limits are not checked by kernel yet)
update repquota, edquota and rpc.rquotad to the new world
implement compat_50_quotactl ioctl.
update quotactl(2) man page

fsck_ffs required fixes so that allocating new blocks or inodes will
properly update the superblock and cg sumaries. This was not an issue up
to now because superblock and cg sumaries check happened last, but now
allocations or frees can happen in pass 6.
 1.84.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.84.2.1 21-Apr-2011  rmind sync with head
 1.87.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.87.2.3 30-Oct-2012  yamt sync with head
 1.87.2.2 17-Apr-2012  yamt sync with head
 1.87.2.1 10-Nov-2011  yamt sync with head
 1.88.4.4 29-Apr-2012  mrg sync to latest -current.
 1.88.4.3 11-Mar-2012  mrg sync to latest -current
 1.88.4.2 24-Feb-2012  mrg sync to -current.
 1.88.4.1 18-Feb-2012  mrg merge to -current.
 1.91.2.2 14-Apr-2015  msaitoh Pull up following revision(s) (requested by khorben in ticket #1264):

include/unistd.h 1.144
sys/kern/init_sysent.c regen
sys/kern/syscalls.c regen
sys/kern/syscalls.master 1.272
sys/rump/include/rump/rump_syscalls.h regen
sys/rump/librump/rumpkern/rump_syscalls.c regen
sys/sys/syscall.h regen
sys/sys/syscallargs.h regen
sys/compat/netbds32/netbsd32_syscall.h regen
sys/compat/netbds32/netbsd32_syscallargs.h regen
sys/compat/netbds32/netbsd32_syscalls.c regen
sys/compat/netbds32/netbsd32_sysent.c regen
sys/compat/netbsd32/syscalls.master 1.102

Fix return type of the readlinkat(2) syscall. PR#49684.
 1.91.2.1 12-Apr-2012  riz Pull up following revision(s) (requested by martin in ticket #175):
sys/kern/kern_exit.c: revision 1.238
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.4
tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.5
sys/uvm/uvm_extern.h: revision 1.183
lib/libc/gen/posix_spawn_fileactions.c: revision 1.2
sys/kern/kern_exec.c: revision 1.348
sys/kern/kern_exec.c: revision 1.349
sys/compat/netbsd32/syscalls.master: revision 1.95
sys/uvm/uvm_glue.c: revision 1.159
sys/uvm/uvm_map.c: revision 1.317
sys/compat/netbsd32/netbsd32.h: revision 1.95
sys/kern/exec_elf.c: revision 1.38
sys/sys/spawn.h: revision 1.2
sys/sys/exec.h: revision 1.135
sys/compat/netbsd32/netbsd32_execve.c: revision 1.34
Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
(this part fixes PR 46286)
- increase parallelism between parent and child if arguments allow this,
avoiding a potential deadlock on exec_lock
- add a new flag for userland to request old (lockstepped) behaviour for
better error reporting
- adapt test cases to the previous two and add a new variant to test the
diagnostics flag
- fix a few memory (and lock) leaks
- provide netbsd32 compat
Fix asynchronous posix_spawn child exit status (and test for it).
 1.95.2.4 03-Dec-2017  jdolecek update from HEAD
 1.95.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.95.2.2 23-Jun-2013  tls resync from head
 1.95.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.97.4.1 18-May-2014  rmind sync with head
 1.98.2.1 10-Aug-2014  tls Rebase.
 1.101.4.5 05-Dec-2016  skrll Sync with HEAD
 1.101.4.4 05-Oct-2016  skrll Sync with HEAD
 1.101.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.101.4.2 22-Sep-2015  skrll Sync with HEAD
 1.101.4.1 06-Apr-2015  skrll Sync with HEAD
 1.101.2.4 04-Nov-2019  martin Pull up following revision(s) (requested by rin in ticket #1711):

sys/compat/netbsd32/syscalls.master: revision 1.129

For netbsd32_readlinkat(2), bufsize is netbsd_size_t, not size_t.

Since bufsize is the last argument, this affects only LP64EB.

XXX
pullup to netbsd-9, -8, and -7
 1.101.2.3 06-Nov-2015  martin Additionally pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.2
sys/compat/netbsd32/syscalls.master: revision 1.109
Don't reference netbsd32_nfssvc unless NFSSERVER is defined.
Fixes PR 49994.
add missing opt_nfsserver.h
 1.101.2.2 04-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #956):
sys/compat/netbsd32/files.netbsd32: revision 1.36
sys/compat/netbsd32/netbsd32_sysent.c: revision 1.115
sys/compat/netbsd32/netbsd32_syscallargs.h: revision 1.116
sys/nfs/nfs_var.h: revision 1.93
sys/compat/netbsd32/netbsd32_conv.h: revision 1.30
sys/compat/netbsd32/netbsd32_syscall.h: revision 1.116
sys/compat/netbsd32/netbsd32_syscalls.c: revision 1.115
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.1
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.3
sys/nfs/nfs_syscalls.c: revision 1.156
sys/compat/netbsd32/syscalls.master: revision 1.108
sys/compat/netbsd32/netbsd32.h: revision 1.107
add netbsd32 support for nfssvc(2). we do this by defining 5 copyin/out
functions that do all the ugly work, are just plain copyin/out for the
native system calls, and do the necessary translations for netbsd32.
with this i'm able to run 32 bit nfsd and mountd on 64 bit kernel and
mount the file systems remotely.
don't copy the first netbsd32_export_args nexports times, but actually
advance the userland pointer each entry through the loop. oops.
 1.101.2.1 07-Mar-2015  snj Pull up following revision(s) (requested by khorben in ticket #560):
sys/compat/netbsd32/syscalls.master: revision 1.102
readlinkat returns ssize_t
 1.112.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.115.8.1 04-Nov-2019  martin Pull up following revision(s) (requested by rin in ticket #398):

sys/compat/netbsd32/syscalls.master: revision 1.129

For netbsd32_readlinkat(2), bufsize is netbsd_size_t, not size_t.

Since bufsize is the last argument, this affects only LP64EB.

XXX
pullup to netbsd-9, -8, and -7
 1.120.2.19 29-Sep-2018  pgoyette Only keep the compat syscall entry; the main entry needs to remain
conditional.
 1.120.2.18 29-Sep-2018  pgoyette Don't #ifdef out the NTP compat calls.

The syscall number needs to be defined (for the autoload table) whether
or not the compat code is built in. The compat code will be included
in the module in all cases, but it makes explicit checks to ensure that
NTP code exists before executing.
 1.120.2.17 14-Sep-2018  pgoyette Add MODULAR attribute to sigreturn. I think this is the last one.
 1.120.2.16 14-Sep-2018  pgoyette Make sigreturn14 MODULAR
 1.120.2.15 13-Sep-2018  pgoyette More MODULAR tags
 1.120.2.14 12-Sep-2018  pgoyette Missed a couple of MODULAR tags
 1.120.2.13 12-Sep-2018  pgoyette Prepare for splitting compat_netbsd32_sysvipc into version-specific modules
 1.120.2.12 12-Sep-2018  pgoyette The netbsd32 40 mount code belongs in a netbsd32 40 module
 1.120.2.11 11-Sep-2018  pgoyette Move the NTP compat_30 and compat_50 routines into the version-specific
modules.
 1.120.2.10 11-Sep-2018  pgoyette Insert "MODULAR compat_netbsd32_43" as neeed
 1.120.2.9 11-Sep-2018  pgoyette More over-zealousness - what was I thinking?
 1.120.2.8 11-Sep-2018  pgoyette Don't be overzealous with changes! Return a few syscalls to their
original COMPAT_xx status (rather than STD)
 1.120.2.7 11-Sep-2018  pgoyette Update for module-provided compat syscalls
 1.120.2.6 10-Sep-2018  pgoyette More work on splitting the compat_netbsd32 module
 1.120.2.5 10-Sep-2018  pgoyette More compat_netbsd32_xx modules
 1.120.2.4 10-Sep-2018  pgoyette Initial cut at a compat_netbsd32_09 and compat_netbsd32_12 modules.
 1.120.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.120.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.120.2.1 21-May-2018  pgoyette Sync with HEAD
 1.121.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.121.2.1 10-Jun-2019  christos Sync with HEAD
 1.127.2.2 08-Mar-2020  martin Pull up following revision(s) (requested by pgoyette in ticket #761):

sys/compat/netbsd32/syscalls.master: revision 1.132
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.60

Properly mark netbsd32_compat_43 syscalls that are directly implemented
by calling their compat_43 equivalents. With these changes, and with
built-in versions of COMPAT_NETBSD32, COMPAT_NOMID, and COMPAT_09, I can
now run a netbsd-0.9 statically linked i386 (32-bit) version of /bin/ls
on a 9.99.x amd64 host!

Addresses PR kern/55047 but more changes coming to handle non-built-in
modules.

XXX pullup-9
 1.127.2.1 04-Nov-2019  martin Pull up following revision(s) (requested by rin in ticket #398):

sys/compat/netbsd32/syscalls.master: revision 1.129

For netbsd32_readlinkat(2), bufsize is netbsd_size_t, not size_t.

Since bufsize is the last argument, this affects only LP64EB.

XXX
pullup to netbsd-9, -8, and -7
 1.130.2.1 25-Jan-2020  ad Sync with head.
 1.134.2.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.146.2.1 02-Aug-2025  perseant Sync with HEAD

RSS XML Feed