Commit Graph

537 Commits

Author SHA1 Message Date
ad a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
martin 777a451a3d Remove old posix_fadvise compat code 2008-02-24 15:02:15 +00:00
martin 93cbe0f210 Regen (old posix_fadvise ignored) 2008-02-24 12:53:47 +00:00
martin a8ed8bb731 Desupport compatibility for the old posix_fadvise syscall per yamt's
request and just ignore it.
2008-02-24 12:52:54 +00:00
dsl 4e55f805dd Fix build 2008-02-02 15:17:06 +00:00
dsl 020f5fa28f Use the netbsd32_[u]int64 type for all 64bit items to ensure we have the
correct alignment/padding rules.
Removed the now-unnecessary #pragma packed for amd64.
Should fix the alignment of 'struct netbsd32_kevent' on non-amd64.
2008-02-02 14:34:56 +00:00
dsl 0df418f9cb Change u_intxx_t to uintxx_t and uint to unsigined int etc.
Fix indentation.
2008-02-02 13:58:18 +00:00
ad 25153c3ec9 PR kern/37706 (forced unmount of file systems is unsafe):
- Do reference counting for 'struct mount'. Each vnode associated with a
  mount takes a reference, and in turn the mount takes a reference to the
  vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
  locking inherited from 4.4BSD with a recursable rwlock.
2008-01-30 11:46:59 +00:00
martin e68297ad60 wrong argument type 2008-01-28 00:19:28 +00:00
martin 98e544d2b4 Regen (posix_fadvise versionend) 2008-01-27 20:14:12 +00:00
martin c9146bcc25 Catch up with versioning of posix_fadvise 2008-01-27 20:13:07 +00:00
dsl cb0033a159 Call do_posix_fadvise() in netbsd32_posix_fadvise() 2008-01-27 19:51:40 +00:00
dsl 769c734483 Remove some dubious casting of the address of integer variables that
can only be 'not invalid' if the sizes match - when it is unnecessary.
2008-01-26 21:01:23 +00:00
dsl d84d2af8e2 Split the return value of sys_lseek() into two 32 bit halves for retval[0/1]
in a manner that is endianness independant.
Should mean the amd64 will return correct offsets > 2^32 (sparc64 had a
special define).
Any new netbsd32 ports should work regardless of the endianness.
2008-01-26 20:57:46 +00:00
dsl a94c98311a Don't try to bound the return value for pread/pwrite/pathconf by casting
an 'ssize_t' or 'long' variable to 'register_t'.
If the sizes were different it would either overwrite stack or return
uninitialised stack.  On big-endian systems things would be worse!
2008-01-26 09:07:01 +00:00
dsl fe0f1a7e5d regen 2008-01-26 08:44:48 +00:00
dsl be09b9791a Add a wrapper for posix_fadvise() 2008-01-26 08:35:51 +00:00
joerg 3615cf7715 Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
2008-01-20 18:09:03 +00:00
dsl da6834a7bc Regen for netbsd32_mremap 2008-01-19 22:25:36 +00:00
dsl e7cd2030cf Add netbsd32 wrapper for sys_mremap(), compiles, and assuming the mmap()
wrapper is ok, it should work!
I presume the kernel knows not to map above 4GB though....
2008-01-19 22:25:12 +00:00
ad 77e0b2120f Patch up sysctl locking:
- Lock processes, credentials, filehead etc correctly.
- Acquire a read hold on sysctl_treelock if only doing a query.
- Don't wire down the output buffer. It doesn't work correctly and the code
  regularly does long term sleeps with it held - it's not worth it.
- Don't hold locks other than sysctl_lock while doing copyout().
- Drop sysctl_lock while doing copyout / allocating memory in a few places.
- Don't take kernel_lock for sysctl.
- Fix a number of bugs spotted along the way
2008-01-07 16:12:52 +00:00
dsl 95a195791a Use FILE_LOCK() and FILE_UNLOCK().
Attempt to fix all the code paths so that the 'fp' returned by fd_getfile()
isn't left locked, and is always unlocked (and ref-counted) before
doing anything that might sleep.
2008-01-05 19:14:07 +00:00
perry b6a2ef7569 Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
2007-12-25 18:33:32 +00:00
dsl f00ef3a2d4 Fix prototypes used when NTP is not in use.
Pointed out by Robert Swindells.
2007-12-21 17:36:09 +00:00
dsl 6fb2884c3a regen 2007-12-20 23:07:25 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
dsl 686e359d32 Regen without any 'const' members of the syscall argument structures. 2007-12-17 20:47:31 +00:00
dsl bf434e38c7 Remove all the 'const'. Although the fields might be 32bit pointers to
constant data, the 'const' applies to the field itself - which is stupid.
2007-12-17 20:45:29 +00:00
wiz 9c131e8d5c Remove last argument from NDINIT call, following
"Remove cn_lwp from struct componentname.  curlwp should be used
from on.  The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure." from pooka.
2007-12-09 12:50:29 +00:00
pooka db06a930e6 Remove cn_lwp from struct componentname. curlwp should be used
from on.  The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
2007-12-08 19:29:36 +00:00
dsl 28bae79b27 ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
2007-12-08 18:35:53 +00:00
ad 9c8beda3c8 Reg... hang on, why don't we build this at compile time?!? 2007-12-07 22:42:11 +00:00
ad bca34dfe7a Add: _lwp_setname, _lwp_getname, _lwp_ctl. 2007-12-07 22:41:05 +00:00
dsl f2af9174b9 Remove all the __P 2007-12-04 18:40:07 +00:00
dogcow 3465a006e9 more VFS_STATVFS(x,y,z) fallout; change them to VFS_STATVFS(x,y). (hi, pooka!) 2007-11-27 09:47:15 +00:00
elad abb7851f4d Refactor time modification checks and place them in the secmodel code.
okay christos@
2007-11-25 00:35:26 +00:00
dsl f36a9ec28b Fix builds for ports that don't define __HAVE_MINIMAL_EMUL (eg sparc64).
Fallout from a change that made #define names for syscalls (etc) start
NETBSD32 (not netbsd32).
2007-11-10 18:55:42 +00:00
dsl ee077208d9 Regen 2007-11-09 15:10:27 +00:00
dsl 3107f9cd42 Add arguments to sys_syscall and sys___syscall.
Use MI wrappers for them in netbsd32.
Change prefix for constants from netbsd32 to NETBSD32 (used in #defines etc).
2007-11-09 15:05:33 +00:00
ad 53b26d467e mountlist_slock is now a mutex. 2007-10-10 22:00:53 +00:00
ad 62fdbc4b9a LOCK_ASSERT -> KASSERT 2007-10-08 18:07:24 +00:00
dsl 2e20a70dbf Change the way p->p_limit (and hence p->p_rlimit) is locked.
Should fix PR/36939 and make the rlimit code MP safe.
Posted for comment to tech-kern (non received!)

The p_limit field (for a process) is only be changed once (on the first
  write), and a reference to the old structure is kept (for code paths
  that have cached the pointer).
Only p->p_limit is now locked by p->p_mutex, and since the referenced memory
  will not go away, is only needed if the pointer is to be changed.
The contents of 'struct plimit' are all locked by pl_mutex, except that the
  code doesn't bother to acquire it for reads (which are basically atomic).
Add FORK_SHARELIMIT that causes fork1() to share the limits between parent
  and child, use it for the IRIX_PR_SULIMIT.
Fix borked test for both IRIX_PR_SUMASK and IRIX_PR_SDIR being set.
2007-09-29 12:22:30 +00:00
dsl 2b7c33c183 Use netbsd32_uint64 instead of fsblkcnt_t and fsfilcnt_t in order to get
the correct alignment (4 bytes for i386) for the whole structure.
2007-09-29 10:47:45 +00:00
dsl 4bacff8183 Rename members of 'struct plimit' so that the fields are 'pl_xxx' and
no longer have the same names as members of 'struct proc'.
2007-09-21 19:19:20 +00:00
dsl 06b0a1bdab Define netbsd32_uint64 for 64bit integers with the alignment requirement
of the corresponding 32bit architecture.
Use it for the 64bit items in netbsd32_statvfs so that the structure
doesn't collect 8byte alignment (and 4 bytes of trailing padding).
This replaces the 'packed' attribute which wasn't architecture specific
and would cause massive overheads accessing every member of sparc64.
Should allow the MIPS64 port do DTRT.
2007-09-16 22:35:01 +00:00
cube 7a185660d8 Some more licence clean up. 2007-09-10 10:54:20 +00:00
cube c725329722 Remove 3rd clause and my name from all the licences which were only in my
name.
2007-09-10 10:35:51 +00:00
ad d3675885a8 Regen. 2007-08-15 12:09:12 +00:00
ad 63c4506184 Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
2007-08-15 12:07:23 +00:00
ad 06f7ccf01d Regen. 2007-08-07 19:01:23 +00:00
ad 830ab6bb3c - Fix a bug with _lwp_park() where if the computed wakeup time was under
1 microsecond into the future, the thread could enter an untimed sleep.
- Change the signature of _lwp_park() to accept an lwpid_t and second
  hint pointer, but do so in a way that remains compatible with older
  pthread libraries. This can be used to wake another thread before the
  calling thread goes asleep, saving at least one syscall + involuntary
  context switch. This turns out to be a fairly large win on the condvar
  benchmarks that I have tried.
- Mark some more syscalls MP safe.
2007-08-07 19:00:42 +00:00
briggs 883152ac0b Fix typo: mnfromname -> mntfromname. 2007-07-18 13:53:34 +00:00
christos 18754a7640 kill silly constants. 2007-07-17 20:39:42 +00:00
christos ecb7144e3a include <compat/sys/mount.h> MFSNAMELEN 2007-07-17 20:36:11 +00:00
dsl 0bfa8b4ee7 Adapt for sys_mount() becoming compat_40_sys_mount(), 2007-07-14 15:47:26 +00:00
dsl 53e0243f27 Changes to sompat socket function to avoid the dreaded stackgap. 2007-06-30 15:31:49 +00:00
dsl 879c84a74d The code to directly call sigaction1() and sigaltstack1() is much shorter
than the mess required to call the compat_43_xxx functions.
2007-06-16 22:31:08 +00:00
dsl ec918d6dc6 Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
2007-06-16 20:04:27 +00:00
ad c741f88d56 Acquire proclist_mutex before sending signals. XXX irix emul needs a bit
of work.
2007-06-09 21:25:49 +00:00
dsl 938cde68e5 Add a #define that expands to the compat wrapper for sigaltstack1().
Use it for the netbsd32_compat_13.c version of the code.
2007-06-03 14:59:46 +00:00
dsl 671dc7790c sendmsg() shouldn't modify the 'msg' parameter, and recvmsg() doesn't have
to modify the 'iov' array - it isn't updated.
2007-06-03 11:30:59 +00:00
dsl 97d93705e5 Calling sigaltstack1() directly is so much easier than going via
compat_13_sys_sigaltstack().
2007-06-03 11:09:35 +00:00
dsl ed63ffe787 Split netbsd32___semctl14() so that it is callable from
compat_10_netbsd32_sys_semsys() (where the one parameter is already in
kernel space).
Note that the code in compat_10_netbsd32_sys_semsys() has always been wrong,
since it called compat_14_sys___semctl() - which would read 64bit values!
2007-06-03 10:55:10 +00:00
dsl 7ba299c5d4 Split sys__lwp_park() so that the compat/netbsd32 code can copyin and convert
its timeout then call the standard function.
2007-06-03 09:50:12 +00:00
dsl d7f93c5c67 Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
  and control are already in mbufs, and that the uio structure is in userspace
  for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
  passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.
2007-06-01 22:53:52 +00:00
christos ab89ea8ca6 message size == 0 is valid. From Markus Mayer 2007-05-31 23:34:42 +00:00
christos 9bf57b1f3a make this compile again
XXX: The ioctls will need to be fixed.
2007-05-30 00:00:59 +00:00
christos c61eed39a8 rename si_sigval -> si_value to match POSIX RTS. 2007-05-21 15:35:47 +00:00
dsl c83f8a10ad Change the compat sys_[fl]utime code to not use the stackgap. 2007-05-12 17:28:19 +00:00
dsl 1844147fa9 Split sys_wait4() so that compat code can fiddle with the returned 'status'
and 'rusage' without having to copy data to/from stackgap buffers.
The old split (find_stopped_child) could be removed.
amd64 seems to run netbsd32, linux and linux32 emulations. sparc64 compiles.
2007-05-07 16:53:17 +00:00
dsl 906b9af2a7 Rework compat stat() and statvfs() code so that it no longer uses the stackgap. 2007-04-30 14:05:47 +00:00
dsl 8932ebd238 Remove some unused calls to stackgap_init() 2007-04-30 09:20:18 +00:00
dsl 0df00dcf55 Split the statvfs functions so that the 'work' is done to a kernel buffer
which can either be copied directly to userspace, or converted then copied.
Saves replicating a lot of code in the compat functions (esp. for
getvfsstat) at a cast of an extra function call in the non-emulated case -
which is unlikely to be measurable given the other costs of the actions
involved (even on vax).
Remove dofhstat() and dofhstatvfs() (and the last caller).
Remove some redundant stackgap_init() calls.
2007-04-30 08:32:14 +00:00
dsl d0b9f67395 Delete a diagnostic printf and some unused 'stack gap' initialisation. 2007-04-22 14:10:30 +00:00
dsl 313aae0af3 Actually report an error when sys__stat30() fails. 2007-04-22 10:54:43 +00:00
dsl b8fbaf8c4b 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.
2007-04-22 08:29:55 +00:00
pooka 652606289c I'm not sure if I want to know what MNT_LAXY means, so I'll just
assume the comment has a tyop of MNT_LAZY.
2007-04-16 18:33:39 +00:00
cube c8ff1b6980 Count environment vars with envc, not argc [hi dsl!]. Reported by Nicolas
Joly in private mail.
2007-03-26 17:12:02 +00:00
njoly 226b6c843f Add ktrace I/O support to netbsd32_ioctl() syscall.
Reviewed by cube.
2007-03-20 11:02:18 +00:00
cube e8beebe1e2 More SCARG_P32 fallout. 2007-03-20 08:25:37 +00:00
cube 35a0a309fb Fix typo. Reported by martin. 2007-03-20 08:12:42 +00:00
dsl d364d308c7 Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx). 2007-03-18 21:38:32 +00:00
dsl a065e51621 remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers.  Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
2007-03-16 22:21:40 +00:00
dsl 893faeae9e Update all the compat stuff to not use the 'stackgap' for processing
sys_stat() and friends, instead use do_sys_stat() and do_sys_fstat()
that write the answer into a kernel buffer (on stack) that can be
converted to the correct form and written the userspace.
I've test compiled a few kernels, and tested i386 netbsd1.6 ls.
Given I think I've fixed some bugs, it might be 50-50 with new ones.
2007-03-10 21:40:23 +00:00
christos fffc9c66c9 fix fallout from caddr_t changes. 2007-03-04 07:54:07 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
cube 26a6c15e1a Regen (a few MPSAFE additions). 2007-02-19 15:33:20 +00:00
cube b2d510bccc Mark MPSAFE the syscalls that are not translated (and of course, only when
the native syscall is itself marked MPSAFE).
2007-02-19 15:32:43 +00:00
cube 632ece3eaf 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.
2007-02-19 15:10:02 +00:00
cube 0ff7d99ddb Make netbsd32_{get,set}ucontext and associated functions
{get,set}ucontext32 look like their native counterparts again after
newlock2 merge.  This avoids entering sigprocmask1 without the proc mutex
held...
2007-02-19 14:39:43 +00:00
cube c7565916df Regen (missing lwp syscalls). 2007-02-18 15:00:14 +00:00
cube c376ba15d1 Add missing lwp syscalls. Put them all together into a new file,
netbsd32_lwp.c, and remove remaining traces of SA.

This still needs some MD (and possibly MI, depending on the chosen
solution) changes to actually work.
2007-02-18 09:03:54 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
hubertf eda05c6413 Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
2007-01-29 01:52:43 +00:00
christos d6bc4d2b49 deal with RLIM_INFINITY in the setrlimit case. 2006-11-21 18:50:01 +00:00
christos 887f588c92 adjust limits takes struct proc again. 2006-11-21 15:02:18 +00:00
christos 0470afd097 Simplify previous commit not to use dosetrlimit(), since we don't want the
kauth tests etc.
2006-11-21 14:57:54 +00:00
christos 1882355e27 From Nicolas Joly:
> It seems that 32bits programs, running under compat_netbsd32, using
> setrlimit force all other programs to have their maximum data size
> fixed at 3GB, where native 64bits apps used 8GB previously.

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

The fix is to use `dosetrlimit()' to ensure the needed copy-on-write
behaviour for shared structure.
2006-11-21 14:32:27 +00:00
elad 68f43d80fe Clean some KAUTH_GENERIC_ISSUSER usage in compat code. 2006-11-14 13:34:29 +00:00
cube 3574e17e23 Regen (PR#34951 fixes). 2006-11-09 14:10:21 +00:00