History log of /netbsd-current/sys/compat/linux/common/linux_exec.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.124 03-May-2020 thorpej

Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes
exist in different namespace depending on FUTEX_PRIVATE_FLAG. This appears
not to be the case in Linux, and some futex users will mix private and non-
private ops on the same futex object. Provide a convenience wrapper that
puts this logic in one place witn a comment explaining why.

While here, move the Linux futex wrapper out of its own file and plop
it in linux_misc.c, which is where it lives in the linux32 module.


# 1.123 26-Apr-2020 thorpej

Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.


Revision tags: bouyer-xenpvh-base2
# 1.122 24-Apr-2020 thorpej

Overhaul the way LWP IDs are allocated. Instead of each LWP having it's
own LWP ID space, LWP IDs came from the same number space as PIDs. The
lead LWP of a process gets the PID as its LID. If a multi-LWP process's
lead LWP exits, the PID persists for the process.

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

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

Nudged in this direction by ad@ and chs@.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.121 15-Feb-2020 ad

branches: 1.121.4;
PR kern/54922: 9.99.45@20200202 panic: diagnostic assertion linux ldconfig triggers vpp != NULL in exit1()->radixtree.c line 674

Create an lwp_renumber() from the code in emulexec() and use in
linux_e_proc_exec() and linux_e_proc_fork() too.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.120 10-Aug-2018 pgoyette

branches: 1.120.6;
Allow syscall_establish() to install new syscalls when the existing
entry-point is either sys_nomodule or sys_nosys. Update the
makesyscalls.sh script to create a const array of bits to allow
syscall_disestablish() to properly restore the original entry-point.
Update all the initializers of struct emul to initialize the pointer
to the bit array struct emul.

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

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

sys/arch/usermode/modules/syscallemu/syscallemu.c


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.119 06-May-2018 kamil

branches: 1.119.2;
Remove an element from struct emul: e_tracesig

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

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

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

Proposed on tech-kern@.

Welcome to NetBSD 8.99.16!

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.118 09-Jan-2018 maya

branches: 1.118.2;
remove struct emul's e_fault.

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

Ride 8.99.12 version bump.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.117 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 19-Feb-2012 rmind

branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.115 18-Aug-2011 christos

branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 rmind-uvmplock-base
# 1.114 07-Jul-2010 chs

many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.113 25-Oct-2009 rmind

branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.112 15-Mar-2009 cegger

ansify function definitions


# 1.111 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.110 17-Dec-2008 cegger

branches: 1.110.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.109 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base
# 1.108 28-Oct-2008 jmcneill

Only call release_futexes if LINUX_NPTL


# 1.107 26-Oct-2008 christos

branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.


Revision tags: matt-mips64-base2 haad-dm-base1
# 1.106 15-Oct-2008 wrstuden

Merge wrstuden-revivesa into HEAD.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.105 28-Apr-2008 martin

branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.104 24-Apr-2008 ad

branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.


# 1.103 23-Apr-2008 ad

Sprinkle locking.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.102 11-Apr-2008 njoly

branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...


# 1.101 08-Apr-2008 njoly

Cleanup unneeded LINUX_NPTL ifdef/endif.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-nbase mjf-devfs-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base
# 1.100 08-Dec-2007 dsl

branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base
# 1.99 04-Dec-2007 dsl

Remove all the __P


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 1.98 16-Nov-2007 njoly

branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.


Revision tags: jmcneill-base
# 1.97 19-Oct-2007 njoly

branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


# 1.96 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 mjf-ufs-trans-base vmlocking-base
# 1.95 22-Apr-2007 dsl

branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.


Revision tags: thorpej-atomic-base
# 1.94 09-Mar-2007 ad

branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.


# 1.93 04-Mar-2007 christos

Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.92 19-Feb-2007 cube

Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.


# 1.91 15-Feb-2007 ad

branches: 1.91.2;
Fix Linux compat on amd64.


Revision tags: post-newlock2-merge
# 1.90 09-Feb-2007 ad

Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.89 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.88 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.87 29-Sep-2006 christos

Coverity CID 2990: fix memory leak (from Arnaud Lacombe)


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.86 02-Sep-2006 christos

branches: 1.86.2; 1.86.4;
fix incomplete initializer


# 1.85 23-Aug-2006 manu

1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

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

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

3) Fix LINUX_CLONE_PARENT_SETTID semantics


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6
# 1.84 25-Jun-2006 manu

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

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

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

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.


Revision tags: chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.83 11-Dec-2005 christos

branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.82 23-Nov-2005 manu

To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 1.81 05-Nov-2005 manu

branches: 1.81.2;
Implement more of Linux futex(2)


# 1.80 05-Nov-2005 manu

Fix build when LINUX_NPTL is not defined


# 1.79 05-Nov-2005 manu

Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()


# 1.78 04-Nov-2005 manu

Implement Linux futex ang gettid


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.77 22-Jun-2005 manu

branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.


# 1.76 02-Jun-2005 tsutsui

Add a const.


# 1.75 20-May-2005 fvdl

Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.


Revision tags: yamt-km-base4 kent-audio2-base
# 1.74 26-Mar-2005 christos

s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!


# 1.73 26-Mar-2005 fvdl

Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.72 08-Aug-2004 jdolecek

branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug


# 1.71 08-Aug-2004 jdolecek

linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads


Revision tags: netbsd-2-0-base
# 1.70 20-Dec-2003 fvdl

branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.


# 1.69 20-Dec-2003 manu

Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.


# 1.68 05-Dec-2003 jdolecek

back the sigfilter emulation hook change off


# 1.67 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.66 03-Dec-2003 manu

Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

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

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

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)


# 1.65 24-Aug-2003 chs

add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

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

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

originally from openbsd, adapted for netbsd by me.


# 1.64 29-Jun-2003 fvdl

branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.63 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.62 01-Mar-2003 thorpej

Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.


# 1.61 18-Jan-2003 thorpej

Merge the nathanw_sa branch.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.60 01-Nov-2002 jdolecek

set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.59 21-Sep-2002 manu

- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.58 02-Apr-2002 jdolecek

rename sysctl_linux() to linux_sysctl() and hook it into emul_linux


Revision tags: eeh-devprop-base
# 1.57 16-Mar-2002 christos

make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.


Revision tags: newlock-base ifpoll-base
# 1.56 17-Jan-2002 bjh21

Fix typo in last commit.


# 1.55 17-Jan-2002 bjh21

On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.


# 1.54 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.53 18-Sep-2001 jdolecek

Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.52 18-Jun-2001 christos

branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.


# 1.51 16-Jun-2001 manu

Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?


# 1.50 07-May-2001 manu

Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.


# 1.49 06-May-2001 manu

Added two flags to emulation packages:

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

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.48 24-Mar-2001 jdolecek

Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.


# 1.47 22-Mar-2001 itojun

do not dereference p_vmspace, if it is not initialized yet (NULL).


# 1.46 15-Mar-2001 manu

Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.


# 1.45 19-Jan-2001 manu

branches: 1.45.2;
Added support for powerpc Linux compatibility


# 1.44 11-Dec-2000 mycroft

Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.


# 1.43 09-Dec-2000 jdolecek

always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()


# 1.42 02-Dec-2000 jdolecek

if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386


# 1.41 01-Dec-2000 jdolecek

if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha


# 1.40 01-Dec-2000 jdolecek

add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now


# 1.39 21-Nov-2000 jdolecek

(de)allocate linux emuldata on fork/exec/exit as needed


# 1.38 21-Nov-2000 jdolecek

restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures


# 1.37 29-Jun-2000 mrg

remove include of <vm/vm.h>


# 1.36 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.35 09-Feb-1999 christos

branches: 1.35.8;
const poisoning.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.34 07-Oct-1998 erh

The siginfo include line is not needed here anymore.


# 1.33 04-Oct-1998 fvdl

Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.32 03-Oct-1998 christos

Attempt to fix the mess.


# 1.31 01-Oct-1998 erh

Split compat/linux/linux_exec.c into common, elf and a.out parts.


# 1.30 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.29 05-Sep-1998 christos

Assign copyright to TNF.


# 1.28 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


# 1.27 28-Jul-1998 thorpej

Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.


# 1.26 24-Jan-1998 mycroft

Use linux_setregs().


# 1.25 13-Oct-1996 christos

branches: 1.25.14;
catch up with Jason's exec.h inclusion.


# 1.24 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.23 07-Oct-1996 cgd

include <sys/exec.h> rather than <machine/exec.h>


# 1.22 05-Oct-1996 jtk

update to compile; needs new enum name 'Elf_sht_progbits'


# 1.21 03-Oct-1996 cgd

kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.


# 1.20 03-Oct-1996 thorpej

Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.


# 1.19 30-Sep-1996 christos

Elf32_sht_progbits -> Elf_sht_progbits


# 1.18 27-Sep-1996 cgd

slightly clean up some of the changes made when ELF64 support went in


# 1.17 26-Sep-1996 cgd

adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.


# 1.16 03-Sep-1996 mycroft

Define execv() and execve() consistently across emulations.
Do path name translation.


# 1.15 13-Jun-1996 christos

Simplify and add comments.


# 1.14 13-Jun-1996 christos

- Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.


# 1.13 05-Apr-1996 christos

branches: 1.13.4;
Prototyping changes.


# 1.12 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.11 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.10 14-Aug-1995 mycroft

Rearrange #includes.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 16-May-1995 mycroft

Generate the new ps_strings format.


# 1.4 22-Apr-1995 christos

- added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.


# 1.3 07-Apr-1995 fvdl

Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.


# 1.123 26-Apr-2020 thorpej

Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.


Revision tags: bouyer-xenpvh-base2
# 1.122 24-Apr-2020 thorpej

Overhaul the way LWP IDs are allocated. Instead of each LWP having it's
own LWP ID space, LWP IDs came from the same number space as PIDs. The
lead LWP of a process gets the PID as its LID. If a multi-LWP process's
lead LWP exits, the PID persists for the process.

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

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

Nudged in this direction by ad@ and chs@.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.121 15-Feb-2020 ad

branches: 1.121.4;
PR kern/54922: 9.99.45@20200202 panic: diagnostic assertion linux ldconfig triggers vpp != NULL in exit1()->radixtree.c line 674

Create an lwp_renumber() from the code in emulexec() and use in
linux_e_proc_exec() and linux_e_proc_fork() too.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.120 10-Aug-2018 pgoyette

branches: 1.120.6;
Allow syscall_establish() to install new syscalls when the existing
entry-point is either sys_nomodule or sys_nosys. Update the
makesyscalls.sh script to create a const array of bits to allow
syscall_disestablish() to properly restore the original entry-point.
Update all the initializers of struct emul to initialize the pointer
to the bit array struct emul.

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

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

sys/arch/usermode/modules/syscallemu/syscallemu.c


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.119 06-May-2018 kamil

branches: 1.119.2;
Remove an element from struct emul: e_tracesig

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

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

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

Proposed on tech-kern@.

Welcome to NetBSD 8.99.16!

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.118 09-Jan-2018 maya

branches: 1.118.2;
remove struct emul's e_fault.

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

Ride 8.99.12 version bump.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.117 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 19-Feb-2012 rmind

branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.115 18-Aug-2011 christos

branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 rmind-uvmplock-base
# 1.114 07-Jul-2010 chs

many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.113 25-Oct-2009 rmind

branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.112 15-Mar-2009 cegger

ansify function definitions


# 1.111 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.110 17-Dec-2008 cegger

branches: 1.110.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.109 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base
# 1.108 28-Oct-2008 jmcneill

Only call release_futexes if LINUX_NPTL


# 1.107 26-Oct-2008 christos

branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.


Revision tags: matt-mips64-base2 haad-dm-base1
# 1.106 15-Oct-2008 wrstuden

Merge wrstuden-revivesa into HEAD.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.105 28-Apr-2008 martin

branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.104 24-Apr-2008 ad

branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.


# 1.103 23-Apr-2008 ad

Sprinkle locking.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.102 11-Apr-2008 njoly

branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...


# 1.101 08-Apr-2008 njoly

Cleanup unneeded LINUX_NPTL ifdef/endif.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-nbase mjf-devfs-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base
# 1.100 08-Dec-2007 dsl

branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base
# 1.99 04-Dec-2007 dsl

Remove all the __P


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 1.98 16-Nov-2007 njoly

branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.


Revision tags: jmcneill-base
# 1.97 19-Oct-2007 njoly

branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


# 1.96 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 mjf-ufs-trans-base vmlocking-base
# 1.95 22-Apr-2007 dsl

branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.


Revision tags: thorpej-atomic-base
# 1.94 09-Mar-2007 ad

branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.


# 1.93 04-Mar-2007 christos

Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.92 19-Feb-2007 cube

Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.


# 1.91 15-Feb-2007 ad

branches: 1.91.2;
Fix Linux compat on amd64.


Revision tags: post-newlock2-merge
# 1.90 09-Feb-2007 ad

Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.89 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.88 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.87 29-Sep-2006 christos

Coverity CID 2990: fix memory leak (from Arnaud Lacombe)


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.86 02-Sep-2006 christos

branches: 1.86.2; 1.86.4;
fix incomplete initializer


# 1.85 23-Aug-2006 manu

1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

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

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

3) Fix LINUX_CLONE_PARENT_SETTID semantics


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6
# 1.84 25-Jun-2006 manu

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

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

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

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.


Revision tags: chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.83 11-Dec-2005 christos

branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.82 23-Nov-2005 manu

To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 1.81 05-Nov-2005 manu

branches: 1.81.2;
Implement more of Linux futex(2)


# 1.80 05-Nov-2005 manu

Fix build when LINUX_NPTL is not defined


# 1.79 05-Nov-2005 manu

Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()


# 1.78 04-Nov-2005 manu

Implement Linux futex ang gettid


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.77 22-Jun-2005 manu

branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.


# 1.76 02-Jun-2005 tsutsui

Add a const.


# 1.75 20-May-2005 fvdl

Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.


Revision tags: yamt-km-base4 kent-audio2-base
# 1.74 26-Mar-2005 christos

s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!


# 1.73 26-Mar-2005 fvdl

Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.72 08-Aug-2004 jdolecek

branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug


# 1.71 08-Aug-2004 jdolecek

linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads


Revision tags: netbsd-2-0-base
# 1.70 20-Dec-2003 fvdl

branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.


# 1.69 20-Dec-2003 manu

Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.


# 1.68 05-Dec-2003 jdolecek

back the sigfilter emulation hook change off


# 1.67 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.66 03-Dec-2003 manu

Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

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

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

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)


# 1.65 24-Aug-2003 chs

add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

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

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

originally from openbsd, adapted for netbsd by me.


# 1.64 29-Jun-2003 fvdl

branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.63 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.62 01-Mar-2003 thorpej

Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.


# 1.61 18-Jan-2003 thorpej

Merge the nathanw_sa branch.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.60 01-Nov-2002 jdolecek

set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.59 21-Sep-2002 manu

- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.58 02-Apr-2002 jdolecek

rename sysctl_linux() to linux_sysctl() and hook it into emul_linux


Revision tags: eeh-devprop-base
# 1.57 16-Mar-2002 christos

make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.


Revision tags: newlock-base ifpoll-base
# 1.56 17-Jan-2002 bjh21

Fix typo in last commit.


# 1.55 17-Jan-2002 bjh21

On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.


# 1.54 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.53 18-Sep-2001 jdolecek

Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.52 18-Jun-2001 christos

branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.


# 1.51 16-Jun-2001 manu

Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?


# 1.50 07-May-2001 manu

Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.


# 1.49 06-May-2001 manu

Added two flags to emulation packages:

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

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.48 24-Mar-2001 jdolecek

Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.


# 1.47 22-Mar-2001 itojun

do not dereference p_vmspace, if it is not initialized yet (NULL).


# 1.46 15-Mar-2001 manu

Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.


# 1.45 19-Jan-2001 manu

branches: 1.45.2;
Added support for powerpc Linux compatibility


# 1.44 11-Dec-2000 mycroft

Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.


# 1.43 09-Dec-2000 jdolecek

always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()


# 1.42 02-Dec-2000 jdolecek

if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386


# 1.41 01-Dec-2000 jdolecek

if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha


# 1.40 01-Dec-2000 jdolecek

add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now


# 1.39 21-Nov-2000 jdolecek

(de)allocate linux emuldata on fork/exec/exit as needed


# 1.38 21-Nov-2000 jdolecek

restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures


# 1.37 29-Jun-2000 mrg

remove include of <vm/vm.h>


# 1.36 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.35 09-Feb-1999 christos

branches: 1.35.8;
const poisoning.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.34 07-Oct-1998 erh

The siginfo include line is not needed here anymore.


# 1.33 04-Oct-1998 fvdl

Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.32 03-Oct-1998 christos

Attempt to fix the mess.


# 1.31 01-Oct-1998 erh

Split compat/linux/linux_exec.c into common, elf and a.out parts.


# 1.30 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.29 05-Sep-1998 christos

Assign copyright to TNF.


# 1.28 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


# 1.27 28-Jul-1998 thorpej

Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.


# 1.26 24-Jan-1998 mycroft

Use linux_setregs().


# 1.25 13-Oct-1996 christos

branches: 1.25.14;
catch up with Jason's exec.h inclusion.


# 1.24 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.23 07-Oct-1996 cgd

include <sys/exec.h> rather than <machine/exec.h>


# 1.22 05-Oct-1996 jtk

update to compile; needs new enum name 'Elf_sht_progbits'


# 1.21 03-Oct-1996 cgd

kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.


# 1.20 03-Oct-1996 thorpej

Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.


# 1.19 30-Sep-1996 christos

Elf32_sht_progbits -> Elf_sht_progbits


# 1.18 27-Sep-1996 cgd

slightly clean up some of the changes made when ELF64 support went in


# 1.17 26-Sep-1996 cgd

adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.


# 1.16 03-Sep-1996 mycroft

Define execv() and execve() consistently across emulations.
Do path name translation.


# 1.15 13-Jun-1996 christos

Simplify and add comments.


# 1.14 13-Jun-1996 christos

- Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.


# 1.13 05-Apr-1996 christos

branches: 1.13.4;
Prototyping changes.


# 1.12 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.11 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.10 14-Aug-1995 mycroft

Rearrange #includes.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 16-May-1995 mycroft

Generate the new ps_strings format.


# 1.4 22-Apr-1995 christos

- added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.


# 1.3 07-Apr-1995 fvdl

Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.


# 1.122 24-Apr-2020 thorpej

Overhaul the way LWP IDs are allocated. Instead of each LWP having it's
own LWP ID space, LWP IDs came from the same number space as PIDs. The
lead LWP of a process gets the PID as its LID. If a multi-LWP process's
lead LWP exits, the PID persists for the process.

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

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

Nudged in this direction by ad@ and chs@.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.121 15-Feb-2020 ad

PR kern/54922: 9.99.45@20200202 panic: diagnostic assertion linux ldconfig triggers vpp != NULL in exit1()->radixtree.c line 674

Create an lwp_renumber() from the code in emulexec() and use in
linux_e_proc_exec() and linux_e_proc_fork() too.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.120 10-Aug-2018 pgoyette

branches: 1.120.6;
Allow syscall_establish() to install new syscalls when the existing
entry-point is either sys_nomodule or sys_nosys. Update the
makesyscalls.sh script to create a const array of bits to allow
syscall_disestablish() to properly restore the original entry-point.
Update all the initializers of struct emul to initialize the pointer
to the bit array struct emul.

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

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

sys/arch/usermode/modules/syscallemu/syscallemu.c


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.119 06-May-2018 kamil

branches: 1.119.2;
Remove an element from struct emul: e_tracesig

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

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

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

Proposed on tech-kern@.

Welcome to NetBSD 8.99.16!

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.118 09-Jan-2018 maya

branches: 1.118.2;
remove struct emul's e_fault.

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

Ride 8.99.12 version bump.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.117 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 19-Feb-2012 rmind

branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.115 18-Aug-2011 christos

branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 rmind-uvmplock-base
# 1.114 07-Jul-2010 chs

many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.113 25-Oct-2009 rmind

branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.112 15-Mar-2009 cegger

ansify function definitions


# 1.111 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.110 17-Dec-2008 cegger

branches: 1.110.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.109 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base
# 1.108 28-Oct-2008 jmcneill

Only call release_futexes if LINUX_NPTL


# 1.107 26-Oct-2008 christos

branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.


Revision tags: matt-mips64-base2 haad-dm-base1
# 1.106 15-Oct-2008 wrstuden

Merge wrstuden-revivesa into HEAD.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.105 28-Apr-2008 martin

branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.104 24-Apr-2008 ad

branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.


# 1.103 23-Apr-2008 ad

Sprinkle locking.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.102 11-Apr-2008 njoly

branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...


# 1.101 08-Apr-2008 njoly

Cleanup unneeded LINUX_NPTL ifdef/endif.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-nbase mjf-devfs-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base
# 1.100 08-Dec-2007 dsl

branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base
# 1.99 04-Dec-2007 dsl

Remove all the __P


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 1.98 16-Nov-2007 njoly

branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.


Revision tags: jmcneill-base
# 1.97 19-Oct-2007 njoly

branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


# 1.96 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 mjf-ufs-trans-base vmlocking-base
# 1.95 22-Apr-2007 dsl

branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.


Revision tags: thorpej-atomic-base
# 1.94 09-Mar-2007 ad

branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.


# 1.93 04-Mar-2007 christos

Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.92 19-Feb-2007 cube

Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.


# 1.91 15-Feb-2007 ad

branches: 1.91.2;
Fix Linux compat on amd64.


Revision tags: post-newlock2-merge
# 1.90 09-Feb-2007 ad

Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.89 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.88 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.87 29-Sep-2006 christos

Coverity CID 2990: fix memory leak (from Arnaud Lacombe)


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.86 02-Sep-2006 christos

branches: 1.86.2; 1.86.4;
fix incomplete initializer


# 1.85 23-Aug-2006 manu

1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

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

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

3) Fix LINUX_CLONE_PARENT_SETTID semantics


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6
# 1.84 25-Jun-2006 manu

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

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

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

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.


Revision tags: chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.83 11-Dec-2005 christos

branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.82 23-Nov-2005 manu

To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 1.81 05-Nov-2005 manu

branches: 1.81.2;
Implement more of Linux futex(2)


# 1.80 05-Nov-2005 manu

Fix build when LINUX_NPTL is not defined


# 1.79 05-Nov-2005 manu

Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()


# 1.78 04-Nov-2005 manu

Implement Linux futex ang gettid


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.77 22-Jun-2005 manu

branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.


# 1.76 02-Jun-2005 tsutsui

Add a const.


# 1.75 20-May-2005 fvdl

Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.


Revision tags: yamt-km-base4 kent-audio2-base
# 1.74 26-Mar-2005 christos

s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!


# 1.73 26-Mar-2005 fvdl

Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.72 08-Aug-2004 jdolecek

branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug


# 1.71 08-Aug-2004 jdolecek

linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads


Revision tags: netbsd-2-0-base
# 1.70 20-Dec-2003 fvdl

branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.


# 1.69 20-Dec-2003 manu

Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.


# 1.68 05-Dec-2003 jdolecek

back the sigfilter emulation hook change off


# 1.67 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.66 03-Dec-2003 manu

Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

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

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

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)


# 1.65 24-Aug-2003 chs

add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

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

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

originally from openbsd, adapted for netbsd by me.


# 1.64 29-Jun-2003 fvdl

branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.63 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.62 01-Mar-2003 thorpej

Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.


# 1.61 18-Jan-2003 thorpej

Merge the nathanw_sa branch.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.60 01-Nov-2002 jdolecek

set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.59 21-Sep-2002 manu

- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.58 02-Apr-2002 jdolecek

rename sysctl_linux() to linux_sysctl() and hook it into emul_linux


Revision tags: eeh-devprop-base
# 1.57 16-Mar-2002 christos

make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.


Revision tags: newlock-base ifpoll-base
# 1.56 17-Jan-2002 bjh21

Fix typo in last commit.


# 1.55 17-Jan-2002 bjh21

On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.


# 1.54 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.53 18-Sep-2001 jdolecek

Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.52 18-Jun-2001 christos

branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.


# 1.51 16-Jun-2001 manu

Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?


# 1.50 07-May-2001 manu

Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.


# 1.49 06-May-2001 manu

Added two flags to emulation packages:

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

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.48 24-Mar-2001 jdolecek

Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.


# 1.47 22-Mar-2001 itojun

do not dereference p_vmspace, if it is not initialized yet (NULL).


# 1.46 15-Mar-2001 manu

Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.


# 1.45 19-Jan-2001 manu

branches: 1.45.2;
Added support for powerpc Linux compatibility


# 1.44 11-Dec-2000 mycroft

Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.


# 1.43 09-Dec-2000 jdolecek

always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()


# 1.42 02-Dec-2000 jdolecek

if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386


# 1.41 01-Dec-2000 jdolecek

if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha


# 1.40 01-Dec-2000 jdolecek

add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now


# 1.39 21-Nov-2000 jdolecek

(de)allocate linux emuldata on fork/exec/exit as needed


# 1.38 21-Nov-2000 jdolecek

restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures


# 1.37 29-Jun-2000 mrg

remove include of <vm/vm.h>


# 1.36 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.35 09-Feb-1999 christos

branches: 1.35.8;
const poisoning.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.34 07-Oct-1998 erh

The siginfo include line is not needed here anymore.


# 1.33 04-Oct-1998 fvdl

Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.32 03-Oct-1998 christos

Attempt to fix the mess.


# 1.31 01-Oct-1998 erh

Split compat/linux/linux_exec.c into common, elf and a.out parts.


# 1.30 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.29 05-Sep-1998 christos

Assign copyright to TNF.


# 1.28 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


# 1.27 28-Jul-1998 thorpej

Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.


# 1.26 24-Jan-1998 mycroft

Use linux_setregs().


# 1.25 13-Oct-1996 christos

branches: 1.25.14;
catch up with Jason's exec.h inclusion.


# 1.24 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.23 07-Oct-1996 cgd

include <sys/exec.h> rather than <machine/exec.h>


# 1.22 05-Oct-1996 jtk

update to compile; needs new enum name 'Elf_sht_progbits'


# 1.21 03-Oct-1996 cgd

kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.


# 1.20 03-Oct-1996 thorpej

Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.


# 1.19 30-Sep-1996 christos

Elf32_sht_progbits -> Elf_sht_progbits


# 1.18 27-Sep-1996 cgd

slightly clean up some of the changes made when ELF64 support went in


# 1.17 26-Sep-1996 cgd

adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.


# 1.16 03-Sep-1996 mycroft

Define execv() and execve() consistently across emulations.
Do path name translation.


# 1.15 13-Jun-1996 christos

Simplify and add comments.


# 1.14 13-Jun-1996 christos

- Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.


# 1.13 05-Apr-1996 christos

branches: 1.13.4;
Prototyping changes.


# 1.12 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.11 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.10 14-Aug-1995 mycroft

Rearrange #includes.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 16-May-1995 mycroft

Generate the new ps_strings format.


# 1.4 22-Apr-1995 christos

- added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.


# 1.3 07-Apr-1995 fvdl

Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.


# 1.121 15-Feb-2020 ad

PR kern/54922: 9.99.45@20200202 panic: diagnostic assertion linux ldconfig triggers vpp != NULL in exit1()->radixtree.c line 674

Create an lwp_renumber() from the code in emulexec() and use in
linux_e_proc_exec() and linux_e_proc_fork() too.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.120 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.119 06-May-2018 kamil

branches: 1.119.2;
Remove an element from struct emul: e_tracesig

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

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

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

Proposed on tech-kern@.

Welcome to NetBSD 8.99.16!

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.118 09-Jan-2018 maya

branches: 1.118.2;
remove struct emul's e_fault.

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

Ride 8.99.12 version bump.


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.117 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 19-Feb-2012 rmind

branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.115 18-Aug-2011 christos

branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 rmind-uvmplock-base
# 1.114 07-Jul-2010 chs

many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.113 25-Oct-2009 rmind

branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.112 15-Mar-2009 cegger

ansify function definitions


# 1.111 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.110 17-Dec-2008 cegger

branches: 1.110.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.109 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base
# 1.108 28-Oct-2008 jmcneill

Only call release_futexes if LINUX_NPTL


# 1.107 26-Oct-2008 christos

branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.


Revision tags: matt-mips64-base2 haad-dm-base1
# 1.106 15-Oct-2008 wrstuden

Merge wrstuden-revivesa into HEAD.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.105 28-Apr-2008 martin

branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.104 24-Apr-2008 ad

branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.


# 1.103 23-Apr-2008 ad

Sprinkle locking.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.102 11-Apr-2008 njoly

branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...


# 1.101 08-Apr-2008 njoly

Cleanup unneeded LINUX_NPTL ifdef/endif.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-nbase mjf-devfs-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base
# 1.100 08-Dec-2007 dsl

branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base
# 1.99 04-Dec-2007 dsl

Remove all the __P


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 1.98 16-Nov-2007 njoly

branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.


Revision tags: jmcneill-base
# 1.97 19-Oct-2007 njoly

branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


# 1.96 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 mjf-ufs-trans-base vmlocking-base
# 1.95 22-Apr-2007 dsl

branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.


Revision tags: thorpej-atomic-base
# 1.94 09-Mar-2007 ad

branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.


# 1.93 04-Mar-2007 christos

Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.92 19-Feb-2007 cube

Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.


# 1.91 15-Feb-2007 ad

branches: 1.91.2;
Fix Linux compat on amd64.


Revision tags: post-newlock2-merge
# 1.90 09-Feb-2007 ad

Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.89 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.88 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.87 29-Sep-2006 christos

Coverity CID 2990: fix memory leak (from Arnaud Lacombe)


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.86 02-Sep-2006 christos

branches: 1.86.2; 1.86.4;
fix incomplete initializer


# 1.85 23-Aug-2006 manu

1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

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

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

3) Fix LINUX_CLONE_PARENT_SETTID semantics


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6
# 1.84 25-Jun-2006 manu

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

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

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

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.


Revision tags: chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.83 11-Dec-2005 christos

branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.82 23-Nov-2005 manu

To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 1.81 05-Nov-2005 manu

branches: 1.81.2;
Implement more of Linux futex(2)


# 1.80 05-Nov-2005 manu

Fix build when LINUX_NPTL is not defined


# 1.79 05-Nov-2005 manu

Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()


# 1.78 04-Nov-2005 manu

Implement Linux futex ang gettid


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.77 22-Jun-2005 manu

branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.


# 1.76 02-Jun-2005 tsutsui

Add a const.


# 1.75 20-May-2005 fvdl

Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.


Revision tags: yamt-km-base4 kent-audio2-base
# 1.74 26-Mar-2005 christos

s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!


# 1.73 26-Mar-2005 fvdl

Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.72 08-Aug-2004 jdolecek

branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug


# 1.71 08-Aug-2004 jdolecek

linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads


Revision tags: netbsd-2-0-base
# 1.70 20-Dec-2003 fvdl

branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.


# 1.69 20-Dec-2003 manu

Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.


# 1.68 05-Dec-2003 jdolecek

back the sigfilter emulation hook change off


# 1.67 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.66 03-Dec-2003 manu

Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

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

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

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)


# 1.65 24-Aug-2003 chs

add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

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

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

originally from openbsd, adapted for netbsd by me.


# 1.64 29-Jun-2003 fvdl

branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.63 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.62 01-Mar-2003 thorpej

Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.


# 1.61 18-Jan-2003 thorpej

Merge the nathanw_sa branch.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.60 01-Nov-2002 jdolecek

set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.59 21-Sep-2002 manu

- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.58 02-Apr-2002 jdolecek

rename sysctl_linux() to linux_sysctl() and hook it into emul_linux


Revision tags: eeh-devprop-base
# 1.57 16-Mar-2002 christos

make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.


Revision tags: newlock-base ifpoll-base
# 1.56 17-Jan-2002 bjh21

Fix typo in last commit.


# 1.55 17-Jan-2002 bjh21

On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.


# 1.54 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.53 18-Sep-2001 jdolecek

Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.52 18-Jun-2001 christos

branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.


# 1.51 16-Jun-2001 manu

Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?


# 1.50 07-May-2001 manu

Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.


# 1.49 06-May-2001 manu

Added two flags to emulation packages:

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

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.48 24-Mar-2001 jdolecek

Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.


# 1.47 22-Mar-2001 itojun

do not dereference p_vmspace, if it is not initialized yet (NULL).


# 1.46 15-Mar-2001 manu

Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.


# 1.45 19-Jan-2001 manu

branches: 1.45.2;
Added support for powerpc Linux compatibility


# 1.44 11-Dec-2000 mycroft

Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.


# 1.43 09-Dec-2000 jdolecek

always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()


# 1.42 02-Dec-2000 jdolecek

if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386


# 1.41 01-Dec-2000 jdolecek

if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha


# 1.40 01-Dec-2000 jdolecek

add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now


# 1.39 21-Nov-2000 jdolecek

(de)allocate linux emuldata on fork/exec/exit as needed


# 1.38 21-Nov-2000 jdolecek

restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures


# 1.37 29-Jun-2000 mrg

remove include of <vm/vm.h>


# 1.36 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.35 09-Feb-1999 christos

branches: 1.35.8;
const poisoning.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.34 07-Oct-1998 erh

The siginfo include line is not needed here anymore.


# 1.33 04-Oct-1998 fvdl

Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.32 03-Oct-1998 christos

Attempt to fix the mess.


# 1.31 01-Oct-1998 erh

Split compat/linux/linux_exec.c into common, elf and a.out parts.


# 1.30 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.29 05-Sep-1998 christos

Assign copyright to TNF.


# 1.28 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


# 1.27 28-Jul-1998 thorpej

Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.


# 1.26 24-Jan-1998 mycroft

Use linux_setregs().


# 1.25 13-Oct-1996 christos

branches: 1.25.14;
catch up with Jason's exec.h inclusion.


# 1.24 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.23 07-Oct-1996 cgd

include <sys/exec.h> rather than <machine/exec.h>


# 1.22 05-Oct-1996 jtk

update to compile; needs new enum name 'Elf_sht_progbits'


# 1.21 03-Oct-1996 cgd

kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.


# 1.20 03-Oct-1996 thorpej

Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.


# 1.19 30-Sep-1996 christos

Elf32_sht_progbits -> Elf_sht_progbits


# 1.18 27-Sep-1996 cgd

slightly clean up some of the changes made when ELF64 support went in


# 1.17 26-Sep-1996 cgd

adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.


# 1.16 03-Sep-1996 mycroft

Define execv() and execve() consistently across emulations.
Do path name translation.


# 1.15 13-Jun-1996 christos

Simplify and add comments.


# 1.14 13-Jun-1996 christos

- Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.


# 1.13 05-Apr-1996 christos

branches: 1.13.4;
Prototyping changes.


# 1.12 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.11 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.10 14-Aug-1995 mycroft

Rearrange #includes.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 16-May-1995 mycroft

Generate the new ps_strings format.


# 1.4 22-Apr-1995 christos

- added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.


# 1.3 07-Apr-1995 fvdl

Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.120 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


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521
# 1.119 06-May-2018 kamil

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>


Revision tags: pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.118 09-Jan-2018 maya

branches: 1.118.2;
remove struct emul's e_fault.

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

Ride 8.99.12 version bump.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.117 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 19-Feb-2012 rmind

branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.115 18-Aug-2011 christos

branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 rmind-uvmplock-base
# 1.114 07-Jul-2010 chs

many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.113 25-Oct-2009 rmind

branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.112 15-Mar-2009 cegger

ansify function definitions


# 1.111 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.110 17-Dec-2008 cegger

branches: 1.110.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.109 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base
# 1.108 28-Oct-2008 jmcneill

Only call release_futexes if LINUX_NPTL


# 1.107 26-Oct-2008 christos

branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.


Revision tags: matt-mips64-base2 haad-dm-base1
# 1.106 15-Oct-2008 wrstuden

Merge wrstuden-revivesa into HEAD.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.105 28-Apr-2008 martin

branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.104 24-Apr-2008 ad

branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.


# 1.103 23-Apr-2008 ad

Sprinkle locking.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.102 11-Apr-2008 njoly

branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...


# 1.101 08-Apr-2008 njoly

Cleanup unneeded LINUX_NPTL ifdef/endif.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-nbase mjf-devfs-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base
# 1.100 08-Dec-2007 dsl

branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base
# 1.99 04-Dec-2007 dsl

Remove all the __P


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 1.98 16-Nov-2007 njoly

branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.


Revision tags: jmcneill-base
# 1.97 19-Oct-2007 njoly

branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


# 1.96 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 mjf-ufs-trans-base vmlocking-base
# 1.95 22-Apr-2007 dsl

branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.


Revision tags: thorpej-atomic-base
# 1.94 09-Mar-2007 ad

branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.


# 1.93 04-Mar-2007 christos

Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.92 19-Feb-2007 cube

Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.


# 1.91 15-Feb-2007 ad

branches: 1.91.2;
Fix Linux compat on amd64.


Revision tags: post-newlock2-merge
# 1.90 09-Feb-2007 ad

Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.89 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.88 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.87 29-Sep-2006 christos

Coverity CID 2990: fix memory leak (from Arnaud Lacombe)


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.86 02-Sep-2006 christos

branches: 1.86.2; 1.86.4;
fix incomplete initializer


# 1.85 23-Aug-2006 manu

1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

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

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

3) Fix LINUX_CLONE_PARENT_SETTID semantics


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6
# 1.84 25-Jun-2006 manu

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

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

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

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.


Revision tags: chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.83 11-Dec-2005 christos

branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.82 23-Nov-2005 manu

To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 1.81 05-Nov-2005 manu

branches: 1.81.2;
Implement more of Linux futex(2)


# 1.80 05-Nov-2005 manu

Fix build when LINUX_NPTL is not defined


# 1.79 05-Nov-2005 manu

Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()


# 1.78 04-Nov-2005 manu

Implement Linux futex ang gettid


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.77 22-Jun-2005 manu

branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.


# 1.76 02-Jun-2005 tsutsui

Add a const.


# 1.75 20-May-2005 fvdl

Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.


Revision tags: yamt-km-base4 kent-audio2-base
# 1.74 26-Mar-2005 christos

s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!


# 1.73 26-Mar-2005 fvdl

Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.72 08-Aug-2004 jdolecek

branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug


# 1.71 08-Aug-2004 jdolecek

linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads


Revision tags: netbsd-2-0-base
# 1.70 20-Dec-2003 fvdl

branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.


# 1.69 20-Dec-2003 manu

Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.


# 1.68 05-Dec-2003 jdolecek

back the sigfilter emulation hook change off


# 1.67 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.66 03-Dec-2003 manu

Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

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

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

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)


# 1.65 24-Aug-2003 chs

add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

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

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

originally from openbsd, adapted for netbsd by me.


# 1.64 29-Jun-2003 fvdl

branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.63 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.62 01-Mar-2003 thorpej

Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.


# 1.61 18-Jan-2003 thorpej

Merge the nathanw_sa branch.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.60 01-Nov-2002 jdolecek

set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.59 21-Sep-2002 manu

- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.58 02-Apr-2002 jdolecek

rename sysctl_linux() to linux_sysctl() and hook it into emul_linux


Revision tags: eeh-devprop-base
# 1.57 16-Mar-2002 christos

make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.


Revision tags: newlock-base ifpoll-base
# 1.56 17-Jan-2002 bjh21

Fix typo in last commit.


# 1.55 17-Jan-2002 bjh21

On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.


# 1.54 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.53 18-Sep-2001 jdolecek

Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.52 18-Jun-2001 christos

branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.


# 1.51 16-Jun-2001 manu

Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?


# 1.50 07-May-2001 manu

Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.


# 1.49 06-May-2001 manu

Added two flags to emulation packages:

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

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.48 24-Mar-2001 jdolecek

Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.


# 1.47 22-Mar-2001 itojun

do not dereference p_vmspace, if it is not initialized yet (NULL).


# 1.46 15-Mar-2001 manu

Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.


# 1.45 19-Jan-2001 manu

branches: 1.45.2;
Added support for powerpc Linux compatibility


# 1.44 11-Dec-2000 mycroft

Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.


# 1.43 09-Dec-2000 jdolecek

always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()


# 1.42 02-Dec-2000 jdolecek

if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386


# 1.41 01-Dec-2000 jdolecek

if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha


# 1.40 01-Dec-2000 jdolecek

add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now


# 1.39 21-Nov-2000 jdolecek

(de)allocate linux emuldata on fork/exec/exit as needed


# 1.38 21-Nov-2000 jdolecek

restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures


# 1.37 29-Jun-2000 mrg

remove include of <vm/vm.h>


# 1.36 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.35 09-Feb-1999 christos

branches: 1.35.8;
const poisoning.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.34 07-Oct-1998 erh

The siginfo include line is not needed here anymore.


# 1.33 04-Oct-1998 fvdl

Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.32 03-Oct-1998 christos

Attempt to fix the mess.


# 1.31 01-Oct-1998 erh

Split compat/linux/linux_exec.c into common, elf and a.out parts.


# 1.30 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.29 05-Sep-1998 christos

Assign copyright to TNF.


# 1.28 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


# 1.27 28-Jul-1998 thorpej

Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.


# 1.26 24-Jan-1998 mycroft

Use linux_setregs().


# 1.25 13-Oct-1996 christos

branches: 1.25.14;
catch up with Jason's exec.h inclusion.


# 1.24 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.23 07-Oct-1996 cgd

include <sys/exec.h> rather than <machine/exec.h>


# 1.22 05-Oct-1996 jtk

update to compile; needs new enum name 'Elf_sht_progbits'


# 1.21 03-Oct-1996 cgd

kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.


# 1.20 03-Oct-1996 thorpej

Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.


# 1.19 30-Sep-1996 christos

Elf32_sht_progbits -> Elf_sht_progbits


# 1.18 27-Sep-1996 cgd

slightly clean up some of the changes made when ELF64 support went in


# 1.17 26-Sep-1996 cgd

adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.


# 1.16 03-Sep-1996 mycroft

Define execv() and execve() consistently across emulations.
Do path name translation.


# 1.15 13-Jun-1996 christos

Simplify and add comments.


# 1.14 13-Jun-1996 christos

- Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.


# 1.13 05-Apr-1996 christos

branches: 1.13.4;
Prototyping changes.


# 1.12 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.11 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.10 14-Aug-1995 mycroft

Rearrange #includes.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 16-May-1995 mycroft

Generate the new ps_strings format.


# 1.4 22-Apr-1995 christos

- added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.


# 1.3 07-Apr-1995 fvdl

Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.


# 1.118 09-Jan-2018 maya

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.


Revision tags: tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.117 09-Nov-2014 maxv

Do not uselessly include <sys/malloc.h>.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base rmind-smpnet-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 19-Feb-2012 rmind

branches: 1.116.2; 1.116.14;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.115 18-Aug-2011 christos

branches: 1.115.2; 1.115.6;
sizeof type -> sizeof *var


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 rmind-uvmplock-base
# 1.114 07-Jul-2010 chs

many changes for COMPAT_LINUX:
- update the linux syscall table for each platform.
- support new-style (NPTL) linux pthreads on all platforms.
clone() with CLONE_THREAD uses 1 process with many LWPs
instead of separate processes.
- move the contents of sys__lwp_setprivate() into a new
lwp_setprivate() and use that everywhere.
- update linux_release[] and linux32_release[] to "2.6.18".
- adjust placement of emul fork/exec/exit hooks as needed
and adjust other emul code to match.
- convert all struct emul definitions to use named initializers.
- change the pid allocator to allow multiple pids to refer to the same proc.
- remove a few fields from struct proc that are no longer needed.
- disable the non-functional "vdso" code in linux32/amd64,
glibc works fine without it.
- fix a race in the futex code where we could miss a wakeup after
a requeue operation.
- redo futex locking to be a little more efficient.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.113 25-Oct-2009 rmind

branches: 1.113.2; 1.113.4;
Initialise struct emul members by name (it is readable now and one can search
them in the tree).


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.112 15-Mar-2009 cegger

ansify function definitions


# 1.111 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.110 17-Dec-2008 cegger

branches: 1.110.2;
kill MALLOC and FREE macros.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base
# 1.109 19-Nov-2008 ad

Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base
# 1.108 28-Oct-2008 jmcneill

Only call release_futexes if LINUX_NPTL


# 1.107 26-Oct-2008 christos

branches: 1.107.2;
futex support fixes from FreeBSD via cube+pengo.


Revision tags: matt-mips64-base2 haad-dm-base1
# 1.106 15-Oct-2008 wrstuden

Merge wrstuden-revivesa into HEAD.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.105 28-Apr-2008 martin

branches: 1.105.2; 1.105.6;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.104 24-Apr-2008 ad

branches: 1.104.2;
Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

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

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

- The system spends less time at IPL_SCHED, and there is less lock activity.


# 1.103 23-Apr-2008 ad

Sprinkle locking.


Revision tags: yamt-pf42-baseX yamt-pf42-base
# 1.102 11-Apr-2008 njoly

branches: 1.102.2;
Under NPTL emulation, do not reparent all members of a thread group,
but only the processes that emulate threads (with LINUX_CLONE_THREAD
set).

This fix a problem for child processes that share address space with
the parent. At exit, the child will die silently, leaving the parent
waiting indefinitely for its end ...


# 1.101 08-Apr-2008 njoly

Cleanup unneeded LINUX_NPTL ifdef/endif.


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base matt-armv6-nbase mjf-devfs-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base
# 1.100 08-Dec-2007 dsl

branches: 1.100.12;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...


Revision tags: vmlocking2-base2 reinoud-bufcleanup-nbase reinoud-bufcleanup-base
# 1.99 04-Dec-2007 dsl

Remove all the __P


Revision tags: vmlocking2-base1 bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base
# 1.98 16-Nov-2007 njoly

branches: 1.98.2;
Cleanup. Remove a few linux syscalls definitions, now identical to
native ones (with stackgap and ALT_CHECK_xxx removal). No functional
changes expected.


Revision tags: jmcneill-base
# 1.97 19-Oct-2007 njoly

branches: 1.97.2;
Add compat_linux and exec_linux_elf lkm support for amd64:
- Add needed COMPAT_OSSAUDIO to GENERIC.
- Add missing includes needed by linux_syscallargs.h.
- Add lkm building.


# 1.96 19-Oct-2007 ad

machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 mjf-ufs-trans-base vmlocking-base
# 1.95 22-Apr-2007 dsl

branches: 1.95.6; 1.95.8; 1.95.12;
Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.


Revision tags: thorpej-atomic-base
# 1.94 09-Mar-2007 ad

branches: 1.94.2; 1.94.4;
- Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.


# 1.93 04-Mar-2007 christos

Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.92 19-Feb-2007 cube

Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create. It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.


# 1.91 15-Feb-2007 ad

branches: 1.91.2;
Fix Linux compat on amd64.


Revision tags: post-newlock2-merge
# 1.90 09-Feb-2007 ad

Merge newlock2 to head.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.89 16-Nov-2006 christos

__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.88 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.87 29-Sep-2006 christos

Coverity CID 2990: fix memory leak (from Arnaud Lacombe)


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.86 02-Sep-2006 christos

branches: 1.86.2; 1.86.4;
fix incomplete initializer


# 1.85 23-Aug-2006 manu

1) Complete Linux exit_group() emulation
Members of the thread group must die without reporting to the parent and
without going to zombie stage. We do that by reparenting to init before
catching a SIGKILL. The parent will not see the child death.

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

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

3) Fix LINUX_CLONE_PARENT_SETTID semantics


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6
# 1.84 25-Jun-2006 manu

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

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

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

- Fix setprioriry() and getpriority()

Thanks to Nicolas Joly for tracking down the problem and providing me the
hardware to fix them.


Revision tags: chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.83 11-Dec-2005 christos

branches: 1.83.4; 1.83.8; 1.83.16;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.82 23-Nov-2005 manu

To awake all processes sleeping on a futex, set maximum value to 0x7fffffff
instead of -1 (0xffffffff): the value is signed...


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base
# 1.81 05-Nov-2005 manu

branches: 1.81.2;
Implement more of Linux futex(2)


# 1.80 05-Nov-2005 manu

Fix build when LINUX_NPTL is not defined


# 1.79 05-Nov-2005 manu

Instead of ifdef'ing __amd64__ all the Linux NPTL stuff, introduce an
ifdef LINUX_NPTL.
Also implement SETTLS flag to Linux clone()


# 1.78 04-Nov-2005 manu

Implement Linux futex ang gettid


Revision tags: yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.77 22-Jun-2005 manu

branches: 1.77.2;
Implent CLONE_PARENT_SETTID, CLONE_CHILD_CLEARTID, and CLONE_CHILD_SETTID
options to clone(). This makes fork() work on amd64.

clone() prototype has changed and the changes is probably revelant on some
other arches.


# 1.76 02-Jun-2005 tsutsui

Add a const.


# 1.75 20-May-2005 fvdl

Define linux_usertrap function, and set it in struct emul. For all
but amd64, it just returns 0, doing nothing.

For amd64, it implements vsyscalls through cheating: if the faulting
address is in the vsyscall area (which is statically known on Linux/amd64),
and the intruction pointer is too, it must have been a vsyscall. In that
case, retrieve the return address from the user stack, fix up %rip and
%rsp, and just execute the normal system call. It will return as if
the vsyscall has been executed.


Revision tags: yamt-km-base4 kent-audio2-base
# 1.74 26-Mar-2005 christos

s/uvm_map_defaultaddr/uvm_default_mapaddr/ HI FRANK!


# 1.73 26-Mar-2005 fvdl

Fix some things regarding COMPAT_NETBSD32 and limits/VM addresses.

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

Tested on amd64, compile-tested on sparc64.


Revision tags: yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.72 08-Aug-2004 jdolecek

branches: 1.72.4; 1.72.6; 1.72.10;
fix two bugs in previous:
* flags passed from fork1() are FORK_*, not CLONE_*; thus, correct is to check
for FORK_SHAREVM, not CLONE_VM
* fix a reference counting bug


# 1.71 08-Aug-2004 jdolecek

linux processes sharing VM space (via clone() call) must also
share same 'break' value used for brk()/sbrk(), otherwise application SIGSEGVs
quickly once different threads try to adjust data segment size

this fixes linux Mozilla crashes with SuSE 9.1 libraries, and possibly
other linux applications using real threads


Revision tags: netbsd-2-0-base
# 1.70 20-Dec-2003 fvdl

branches: 1.70.2;
Put back Emmanuel's sigfilter hooks, as decided by Core.


# 1.69 20-Dec-2003 manu

Introduce lwp_emuldata and the associated hooks. No hook is provided for the
exec case, as the emulation already has the ability to intercept that
with the e_proc_exec hook. It is the responsability of the emulation to
take appropriaye action about lwp_emuldata in e_proc_exec.

Patch reviewed by Christos.


# 1.68 05-Dec-2003 jdolecek

back the sigfilter emulation hook change off


# 1.67 04-Dec-2003 atatat

Dynamic sysctl.

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

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

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

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.


# 1.66 03-Dec-2003 manu

Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

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

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

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)


# 1.65 24-Aug-2003 chs

add support for non-executable mappings (where the hardware allows this)
and make the stack and heap non-executable by default. the changes
fall into two basic catagories:

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

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

originally from openbsd, adapted for netbsd by me.


# 1.64 29-Jun-2003 fvdl

branches: 1.64.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.63 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.62 01-Mar-2003 thorpej

Do the syscall_plain/syscall_fancy dance on ARM. Shaves a fair number
of cycles off the syscall overhead.

Since all COMPAT_LINUX platforms now support __HAVE_SYSCALL_INTERN,
garbage-collect the LINUX_SYSCALL_FUNCTION stuff.


# 1.61 18-Jan-2003 thorpej

Merge the nathanw_sa branch.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base
# 1.60 01-Nov-2002 jdolecek

set struct emul's nsysent to compat SYS_NSYSENT, not SYS_MAXSYSCALL


Revision tags: kqueue-aftermerge kqueue-beforemerge kqueue-base
# 1.59 21-Sep-2002 manu

- Introduce a e_fault field in struct proc to provide emulation specific
memory fault handler. IRIX uses irix_vm_fault, and all other emulation
use NULL, which means to use uvm_fault.

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

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

- In IRIX share groups, all the VM space is shared, except one page.
This bounds us to have different VM spaces and synchronize modifications
to the VM space accross share group members. We need an IRIX specific hook
to the page fault handler in order to propagate VM space modifications
caused by page faults.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.58 02-Apr-2002 jdolecek

rename sysctl_linux() to linux_sysctl() and hook it into emul_linux


Revision tags: eeh-devprop-base
# 1.57 16-Mar-2002 christos

make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.


Revision tags: newlock-base ifpoll-base
# 1.56 17-Jan-2002 bjh21

Fix typo in last commit.


# 1.55 17-Jan-2002 bjh21

On platforms that don't __HAVE_SYSCALL_INTERN, define LINUX_SYSCALL_FUNCTION
to be the value of emul_linux.e_syscall that we want. This allows it to differ
between machines, so I can have a separate linux_syscall() on arm.


# 1.54 13-Nov-2001 lukem

add RCSIDs (including regeneration of files as appropriate)


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.53 18-Sep-2001 jdolecek

Make the setregs hook emulation-specific, rather than executable
format specific.
Struct emul has a e_setregs hook back, which points to emulation-specific
setregs function. es_setregs of struct execsw now only points to
optional executable-specific setup function (this is only used for
ECOFF).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.52 18-Jun-2001 christos

branches: 1.52.2; 1.52.4;
Add an e_trapsignal member to struct emul, so that emulated processes can
send the appropriate signal depending on the trap type.


# 1.51 16-Jun-2001 manu

Removed obsoletes EMUL_NO_BSD_ASYNCIO_PIPE and EMUL_NO_SIGIO_ON_READ flags.
Async I/O OS specifities should now handled in OS specific code. Linux
has been done, but other emulation should be handled. See case LINUX_F_SETFL
in sys/compat/linux/common/linux_file.c:linux_sys_fcntl() for more details.

The data that has been collected yet:

Net Free Open Linux SunOS AIX OSF1 Darwin
send SIGIO to write end of pipe Y N N N N N Y Y
send SIGIO to read end of pipe Y Y N N N ? Y ?
send SIGIO to write end of socket Y Y Y N N Y Y Y
send SIGIO to read end of socket Y Y Y Y Y ? Y ?


# 1.50 07-May-2001 manu

Changed EMUL_BSD_ASYNCIO_PIPE to EMUL_NO_BSD_ASYNCIO_PIPE, so that
the native emulation (NetBSD) does not have a flag.


# 1.49 06-May-2001 manu

Added two flags to emulation packages:

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

EMUL_NO_SIGIO_ON_READ notes that the emulated binaries that requested
asynchrnous I/O expect the reader process to be notified by a SIGIO, but
not the writer process. OSes without this flag expect the reader and the
writer to be notified when some data has arrived or when some data have been
read. As far as we know, the OSes that need EMUL_NO_SIGIO_ON_READ are Linux
and SunOS.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.48 24-Mar-2001 jdolecek

Use parent's vmspace in linux_e_proc_fork() hook, the child does not
have vmspace setup yet. This fixes lossage discussed on current-users,
thread "hard lockups with -current and Netscape", and should fix
kern/12433 by <kawamoto@tenjin.org>, maybe also kern/12455.

XXX Threads forked via linux_sys_clone() should share the brk value
XXX if they share vmspace. This needs to be implemented.


# 1.47 22-Mar-2001 itojun

do not dereference p_vmspace, if it is not initialized yet (NULL).


# 1.46 15-Mar-2001 manu

Fixed brk() emulation. We now keep track of the processes' idea of the
break value. See http://mail-index.netbsd.org/tech-kern/2001/03/15/0000.html
for more details.


# 1.45 19-Jan-2001 manu

branches: 1.45.2;
Added support for powerpc Linux compatibility


# 1.44 11-Dec-2000 mycroft

Introduce 2 new flags in types.h:
* __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by
e_syscall_intern, which is called at key places in the kernel. This can be
used to set a MD syscall handler pointer. This obsoletes and replaces the
*_HAS_SEPARATED_SYSCALL flags.
* __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in
struct emul are omitted.


# 1.43 09-Dec-2000 jdolecek

always fill in e_syscall in respective emul_*; if the emulation doesn't
have it's own separated *_syscall() function, use syscall()


# 1.42 02-Dec-2000 jdolecek

if machdep define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL is defined, put
linux_syscall() to emul_linux
define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL for i386


# 1.41 01-Dec-2000 jdolecek

if LINUX_MACHDEP_PASS_PPID_AND_EUID is defined for given arch, add
flags EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID to emul_linux
define this option for alpha


# 1.40 01-Dec-2000 jdolecek

add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

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

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now


# 1.39 21-Nov-2000 jdolecek

(de)allocate linux emuldata on fork/exec/exit as needed


# 1.38 21-Nov-2000 jdolecek

restructure struct emul and execsw, in preparation to make emulations LKMable:
* move all exec-type specific information from struct emul to execsw[] and
provide single struct emul per emulation
* elf:
- kern/exec_elf32.c:probe_funcs[] is gone, execsw[] how has one entry
per emulation and contains pointer to respective probe function
- interp is allocated via MALLOC() rather than on stack
- elf_args structure is allocated via MALLOC() rather than malloc()
* ecoff: the per-emulation hooks moved from alpha and mips specific code
to OSF1 and Ultrix compat code as appropriate, execsw[] has one entry per
emulation supporting ecoff with appropriate probe function
* the makecmds/probe functions don't set emulation, pointer to emulation is
part of appropriate execsw[] entry
* constify couple of structures


# 1.37 29-Jun-2000 mrg

remove include of <vm/vm.h>


# 1.36 26-Jun-2000 mrg

remove redundant vm includes.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-4-PATCH003 netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base netbsd-1-4-PATCH002 chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.35 09-Feb-1999 christos

branches: 1.35.8;
const poisoning.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.34 07-Oct-1998 erh

The siginfo include line is not needed here anymore.


# 1.33 04-Oct-1998 fvdl

Assign my copyright to TNF. Merge with others were appropriate.
Regen syscall files after script change.


# 1.32 03-Oct-1998 christos

Attempt to fix the mess.


# 1.31 01-Oct-1998 erh

Split compat/linux/linux_exec.c into common, elf and a.out parts.


# 1.30 11-Sep-1998 mycroft

Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.


# 1.29 05-Sep-1998 christos

Assign copyright to TNF.


# 1.28 09-Aug-1998 perry

bzero->memset, bcopy->memcpy, bcmp->memcmp


# 1.27 28-Jul-1998 thorpej

Change the "aresid" argument of vn_rdwr() from an int * to a size_t *,
to match the new uio_resid type.


# 1.26 24-Jan-1998 mycroft

Use linux_setregs().


# 1.25 13-Oct-1996 christos

branches: 1.25.14;
catch up with Jason's exec.h inclusion.


# 1.24 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.23 07-Oct-1996 cgd

include <sys/exec.h> rather than <machine/exec.h>


# 1.22 05-Oct-1996 jtk

update to compile; needs new enum name 'Elf_sht_progbits'


# 1.21 03-Oct-1996 cgd

kill (re)definitions of EXEC_ELF32. They're no longer necessary
(because of the EXEC_* option changes), and now cause warnings.


# 1.20 03-Oct-1996 thorpej

Fix a section header check that didn't get updated with the elf32/elf64
changes. Make this compile again with the new EXEC_* options.


# 1.19 30-Sep-1996 christos

Elf32_sht_progbits -> Elf_sht_progbits


# 1.18 27-Sep-1996 cgd

slightly clean up some of the changes made when ELF64 support went in


# 1.17 26-Sep-1996 cgd

adapt ELF-using compat code to use new ELF definitions/code. At this point,
these are restricted to 32-bit ELF, and should be severely cleaned.


# 1.16 03-Sep-1996 mycroft

Define execv() and execve() consistently across emulations.
Do path name translation.


# 1.15 13-Jun-1996 christos

Simplify and add comments.


# 1.14 13-Jun-1996 christos

- Pass the Elf32_Ehdr in the linux probe function, and use it!

Since linux binaries are (mostly) always compiled with gcc, look for
the gcc signature in the .comment section header: "\0 GCC: (GNU) ".
I've changed the probe order in kern/exec_elf.c to probe for linux ELF
binaries first and fall back to SVR4 binaries. This makes statically
linked binaries work for both linux and svr4. Note that gcc-compiled
svr4 binaries, still contain the operating system signature first and
then the GCC signature, so there is no conflict. Yes this is a hack.


# 1.13 05-Apr-1996 christos

branches: 1.13.4;
Prototyping changes.


# 1.12 07-Oct-1995 mycroft

Prefix names of system call implementation functions with `sys_'.


# 1.11 19-Sep-1995 thorpej

Make system calls conform to a standard prototype and bring those
prototypes into scope.


# 1.10 14-Aug-1995 mycroft

Rearrange #includes.


# 1.9 24-Jun-1995 christos

Use compat_util.[ch].


# 1.8 22-Jun-1995 fvdl

* Changed to use generic ELF code from kern/exec_elf.c (which was taken
from the svr4 exec code plus the linux compat mods)
* Include file change
* Add multicast sockopts (from John Brezak)


# 1.7 11-Jun-1995 fvdl

Don't forget to acknowledge that all the ELF stuff was taken from
Christos' svr4 code.


# 1.6 11-Jun-1995 fvdl

* Make Linux ELF binaries work. Lots of code duplication, but it will have to do
for now.
* Add a sanity check in linux_uselib


# 1.5 16-May-1995 mycroft

Generate the new ps_strings format.


# 1.4 22-Apr-1995 christos

- added struct emul to all emulations.
- removed all setup functions.
- added copyargs() functions where needed.


# 1.3 07-Apr-1995 fvdl

Handle Linux signal tramp code differently. Some changes because of the
now seperate Linux signal trampoline code. Add linux_sigreturn to
syscalls.master.


# 1.2 05-Mar-1995 fvdl

Added a few more system calls.
More consistent alternate root file semantics throughout.


# 1.1 28-Feb-1995 fvdl

Added Linux compat code.