Home | History | Annotate | Download | only in netbsd32
History log of /src/sys/compat/netbsd32/netbsd32.h
RevisionDateAuthorComments
 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.

RSS XML Feed