Commit Graph

365 Commits

Author SHA1 Message Date
Matthew Dillon
356861db03 Remove the MPSAFE keyword from the parser for syscalls.master.
Instead introduce the [M] prefix to existing keywords.  e.g.
MSTD is the MP SAFE version of STD.  This is prepatory for a
massive Giant lock pushdown.  The old MPSAFE keyword made
syscalls.master too messy.

Begin comments MP-Safe procedures with the comment:
/*
 * MPSAFE
 */
This comments means that the procedure may be called without
Giant held (The procedure itself may still need to obtain
Giant temporarily to do its thing).

sv_prepsyscall() is now MP SAFE and assumed to be MP SAFE
sv_transtrap() is now MP SAFE and assumed to be MP SAFE

ktrsyscall() and ktrsysret() are now MP SAFE (Giant Pushdown)
trapsignal() is now MP SAFE (Giant Pushdown)

Places which used to do the if (mtx_owned(&Giant)) mtx_unlock(&Giant)
test in syscall[2]() in */*/trap.c now do not.  Instead they
explicitly unlock Giant if they previously obtained it, and then
assert that it is no longer held to catch broken system calls.

Rebuild syscall tables.
2001-08-30 18:50:57 +00:00
Jim Pirzyk
814c95264f Added the linux_sysinfo function to implement sysinfo(2).
PR:		kern/27759
Reviewed by:	marcel
Approved by:	marcel
MFC after:	1 week
2001-07-23 06:22:10 +00:00
Jim Pirzyk
3d39316d2b Added the proper arguments the sysinfo system call
PR:		kern/27759
Reviewed by:	marcel
Approved by:	marcel
Obtained from:	Linux man page sysinfo(2)
MFC after:	1 week
2001-07-23 06:17:34 +00:00
John Baldwin
6be523bca7 Add a new MI pointer to the process' trapframe p_frame instead of using
various differently named pointers buried under p_md.

Reviewed by:	jake (in principle)
2001-06-29 11:10:41 +00:00
Peter Wemm
f41325db5f With this commit, I hereby pronounce gensetdefs past its use-by date.
Replace the a.out emulation of 'struct linker_set' with something
a little more flexible.  <sys/linker_set.h> now provides macros for
accessing elements and completely hides the implementation.

The linker_set.h macros have been on the back burner in various
forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()),
John Polstra (ELF clue) and myself (cleaned up API and the conversion
of the rest of the kernel to use it).

The macros declare a strongly typed set.  They return elements with the
type that you declare the set with, rather than a generic void *.

For ELF, we use the magic ld symbols (__start_<setname> and
__stop_<setname>).  Thanks to Richard Henderson <rth@redhat.com> for the
trick about how to force ld to provide them for kld's.

For a.out, we use the old linker_set struct.

NOTE: the item lists are no longer null terminated.  This is why
the code impact is high in certain areas.

The runtime linker has a new method to find the linker set
boundaries depending on which backend format is in use.

linker sets are still module/kld unfriendly and should never be used
for anything that may be modular one day.

Reviewed by:	eivind
2001-06-13 10:58:39 +00:00
Robert Watson
b1fc0ec1a7 o Merge contents of struct pcred into struct ucred. Specifically, add the
real uid, saved uid, real gid, and saved gid to ucred, as well as the
  pcred->pc_uidinfo, which was associated with the real uid, only rename
  it to cr_ruidinfo so as not to conflict with cr_uidinfo, which
  corresponds to the effective uid.
o Remove p_cred from struct proc; add p_ucred to struct proc, replacing
  original macro that pointed.
  p->p_ucred to p->p_cred->pc_ucred.
o Universally update code so that it makes use of ucred instead of pcred,
  p->p_ucred instead of p->p_pcred, cr_ruidinfo instead of p_uidinfo,
  cr_{r,sv}{u,g}id instead of p_*, etc.
o Remove pcred0 and its initialization from init_main.c; initialize
  cr_ruidinfo there.
o Restruction many credential modification chunks to always crdup while
  we figure out locking and optimizations; generally speaking, this
  means moving to a structure like this:
        newcred = crdup(oldcred);
        ...
        p->p_ucred = newcred;
        crfree(oldcred);
  It's not race-free, but better than nothing.  There are also races
  in sys_process.c, all inter-process authorization, fork, exec, and
  exit.
o Remove sigio->sio_ruid since sigio->sio_ucred now contains the ruid;
  remove comments indicating that the old arrangement was a problem.
o Restructure exec1() a little to use newcred/oldcred arrangement, and
  use improved uid management primitives.
o Clean up exit1() so as to do less work in credential cleanup due to
  pcred removal.
o Clean up fork1() so as to do less work in credential cleanup and
  allocation.
o Clean up ktrcanset() to take into account changes, and move to using
  suser_xxx() instead of performing a direct uid==0 comparision.
o Improve commenting in various kern_prot.c credential modification
  calls to better document current behavior.  In a couple of places,
  current behavior is a little questionable and we need to check
  POSIX.1 to make sure it's "right".  More commenting work still
  remains to be done.
o Update credential management calls, such as crfree(), to take into
  account new ruidinfo reference.
o Modify or add the following uid and gid helper routines:
      change_euid()
      change_egid()
      change_ruid()
      change_rgid()
      change_svuid()
      change_svgid()
  In each case, the call now acts on a credential not a process, and as
  such no longer requires more complicated process locking/etc.  They
  now assume the caller will do any necessary allocation of an
  exclusive credential reference.  Each is commented to document its
  reference requirements.
o CANSIGIO() is simplified to require only credentials, not processes
  and pcreds.
o Remove lots of (p_pcred==NULL) checks.
o Add an XXX to authorization code in nfs_lock.c, since it's
  questionable, and needs to be considered carefully.
o Simplify posix4 authorization code to require only credentials, not
  processes and pcreds.  Note that this authorization, as well as
  CANSIGIO(), needs to be updated to use the p_cansignal() and
  p_cansched() centralized authorization routines, as they currently
  do not take into account some desirable restrictions that are handled
  by the centralized routines, as well as being inconsistent with other
  similar authorization instances.
o Update libkvm to take these changes into account.

Obtained from:	TrustedBSD Project
Reviewed by:	green, bde, jhb, freebsd-arch, freebsd-audit
2001-05-25 16:59:11 +00:00
Alfred Perlstein
2395531439 Introduce a global lock for the vm subsystem (vm_mtx).
vm_mtx does not recurse and is required for most low level
vm operations.

faults can not be taken without holding Giant.

Memory subsystems can now call the base page allocators safely.

Almost all atomic ops were removed as they are covered under the
vm mutex.

Alpha and ia64 now need to catch up to i386's trap handlers.

FFS and NFS have been tested, other filesystems will need minor
changes (grabbing the vm lock when twiddling page properties).

Reviewed (partially) by: jake, jhb
2001-05-19 01:28:09 +00:00
Daniel Eischen
b85c313a62 Preserve the state of the %gs register when setting up the signal
handler in Linux emulation.  According to bde, this is what Linux
does.

Recent versions of linuxthreads use %gs for thread-specific data,
while FreeBSD uses %fs (mostly because WINE uses %gs).

Tested by: drew
2001-05-12 03:23:10 +00:00
Mark Murray
fb919e4d5a Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by:	bde (with reservations)
2001-05-01 08:13:21 +00:00
Alan Cox
07be3b5e76 Regen after adding linux_sched_get_priority_max() and
linux_sched_get_priority_min().
2001-04-01 06:43:09 +00:00
Alan Cox
21c8cdfb96 Add linux_sched_get_priority_max() and linux_sched_get_priority_min(): The
policy parameter requires translation.
2001-04-01 06:37:40 +00:00
Dag-Erling Smørgrav
8f12c20f6c rfork() masks RFSTOPPED out of the flags it passes to fork1(), so we have
to call fork1() directly if we don't want out process queued right away.
This has the serendipitous side effect of saving us a call to pfind().

This makes threaded Linux apps (such as Opera) work again.
2001-03-11 18:52:10 +00:00
John Baldwin
19eb87d22a Grab the process lock while calling psignal and before calling psignal. 2001-03-07 03:37:06 +00:00
John Baldwin
6ad0e7c5cc Create clone'd linux processes as stopped processes at first and don't
actually make them runnable until after the emulator layer has had a chance
to perform fixups.
2001-03-06 02:59:46 +00:00
Matthew Dillon
0cc3ac8b6c Linux does not filesystem-sync file-backed writable mmap pages on
a regular basis.  Adjust our linux emulation to conform.  This will
cause more dirty pages to be left for the pagedaemon to deal with,
but our new low-memory handling code can deal with it.   The linux
way appears to be a trend, and we may very well make MAP_NOSYNC the
default for FreeBSD as well (once we have reasonable sequential
write-behind heuristics for random faults).
(will be MFC'd prior to 4.3 freeze)

Suggested by: Andrew Gallatin
2001-02-28 04:30:27 +00:00
Jake Burkholder
02318dac2c Remove the leading underscore from all symbols defined in x86 asm
and used in C or vice versa.  The elf compiler uses the same names
for both.  Remove asnames.h with great prejudice; it has served its
purpose.

Note that this does not affect the ability to generate an aout kernel
due to gcc's -mno-underscores option.

moral support from:	peter, jhb
2001-02-25 06:29:04 +00:00
David E. O'Brien
21a3ee0ead MFS: bring the consistent `compat_3_brand' support into -CURRENT
(the work was first done in the RELENG_4 branch near a release
	 during a MFC to make the code cleaner and more consistent)
2001-02-24 22:20:11 +00:00
Jonathan Lemon
2459336973 Allow debugging output to be controlled on a per-syscall granularity.
Also clean up debugging output in a slightly more uniform fashion.

The default behavior remains the same (all debugging output is turned on)
2001-02-16 16:40:43 +00:00
Jonathan Lemon
a25f3493bc Re-gen auto generated files. 2001-02-16 14:47:24 +00:00
Jonathan Lemon
3417b54986 Remove dummy stub functions. 2001-02-16 14:46:16 +00:00
Jonathan Lemon
705deb78a3 Add mount syscall to linux emulation. Also improve emulation of reboot. 2001-02-16 14:42:11 +00:00
John Baldwin
611d940790 Proc locking. 2001-01-24 00:27:28 +00:00
John Baldwin
fdfdfb786a - Proc locking.
- Use NULL instead of 0.
2001-01-24 00:23:30 +00:00
Dag-Erling Smørgrav
158eb2773f The Linuxulator needs sysvipc to work. 2001-01-14 18:16:01 +00:00
Dag-Erling Smørgrav
c094d916c4 Remove after repo-copy to sys/compat/linprocfs. 2000-12-12 22:01:59 +00:00
Dag-Erling Smørgrav
b51a26edb2 Add proc/<pid>/cmdline. 2000-12-09 16:20:48 +00:00
Dag-Erling Smørgrav
8b5a844af9 Add a dependency on procfs. 2000-12-09 16:20:35 +00:00
Dag-Erling Smørgrav
f786d43aac A bunch of fixes that have been rotting in my tree for a month or two
waiting for procfs to get fixed:

  - Use fill_eproc() to obtain correct VM stats. Attempt to compute VmLib.

  - Fill some more fields in proc/<pid>/stat, and add four (unimplemented)
    fields after studying a recent Linux kernel.

  - Compute CPU frequency only once instead of twice.

  - Fix some comments that were OBE.

  - Fix indentation except where it makes the code less readable.
2000-12-09 13:25:54 +00:00
John Baldwin
0de7d1da20 Protect access to p_stat with sched_lock. 2000-12-01 06:34:19 +00:00
Marcel Moolenaar
d034d459da Don't use p->p_sigstk.ss_flags to keep state of whether the
process is on the alternate stack or not. For compatibility
with sigstack(2) state is being updated if such is needed.

We now determine whether the process is on the alternate
stack by looking at its stack pointer. This allows a process
to siglongjmp from a signal handler on the alternate stack
to the place of the sigsetjmp on the normal stack. When
maintaining state, this would have invalidated the state
information and causing a subsequent signal to be delivered
on the normal stack instead of the alternate stack.

PR: 22286
2000-11-30 05:23:49 +00:00
Dag-Erling Smørgrav
fbbd9aebdd Add bogomips to cpuinfo (set it equal to the CPU frequency, which is bogus
but not more so than Linux' definition).
This should get the IBM JDK 1.3 working again.

Prompted by:	sobomax
2000-11-27 11:10:03 +00:00
Jonathan Lemon
14db7f978b Correct a misnamed argument hidden behind a #ifdef DEBUG
Found by:  LINT
2000-11-25 07:04:43 +00:00
Marcel Moolenaar
cc6ca9b35c o Change the argument of linux_sigreturn to be a pointer to a
struct sigframe. We need more than only the signal context.

o  Properly convert the signal mask when setting up the signal
   frame in linux_sendsig and properly convert it back in
   linux_sigreturn.

Do some cleanups and improve style while here.
2000-11-23 08:55:30 +00:00
Marcel Moolenaar
e26cc4467b Change the argument of linux_sigreturn to be a pointer to a
struct sigframe.
2000-11-23 08:53:19 +00:00
Marcel Moolenaar
466b14d758 Don't unregister the ioctl handlers before we verified we
can unload. Doing so leaves the linuxulator in a crippled
state (no ioctl support) when Linux binaries are run at
unload time.

While here, consistently spell ELF in capitals and perform
some minor style improvements.

ELF spelling submitted by: asmodai
2000-11-23 03:21:58 +00:00
Andrew Gallatin
088638dae4 remove redundant declaration of bsd_to_linux_sigset()
reviewed by: marcel
2000-11-16 02:08:40 +00:00
Andrew Gallatin
b595ab370b fix glaring bugs in rt signals -- copyout the right signal mask in
linux_rt_sendsig() and restore the same signal mask linux does
in rt_sigreturn().  This gets us saving/restoring all 64-bits of the
linux sigset_t in rt signals.

Reviewed by: marcel
2000-11-16 02:07:05 +00:00
Andrew Gallatin
2c4ab9ddfa Make linux_sendsig and linux_sigreturn use all 64 bits of a
linux_sigset_t by updating the linux_sigframe struct so as to include
linux's "extramask" field.  This field contains the upper 32-bits of
the sigset.  extramask sits behind a linux_fpstate struct, which I've
defined primarily for padding purposes.

While we're here, define LINUX_NSIG in terms of LINUX_NBPW (32) and
LINUX_NSIG_WORDS (2).

This fixes problems where threaded apps would accumulate a large
number of zombies.  This was happening because the exit signal resides
in the upper 32-bits of the sigset and was never getting unmasked by
the manager thread after the first child exited.

PR: 		misc/18530  (may be related, originator not yet contacted)
Reviewed by:	marcel
2000-11-13 20:44:05 +00:00
Marcel Moolenaar
ebea866055 Revert auto-generation. The Alpha port is broken.
Syncing with it is wrong.
2000-11-10 21:30:19 +00:00
Marcel Moolenaar
806d7daafe Make MINSIGSTKSZ machine dependent, and have the sigaltstack
syscall compare against a variable sv_minsigstksz in struct
sysentvec as to properly take the size of the machine- and
ABI dependent struct sigframe into account.

The SVR4 and iBCS2 modules continue to have a minsigstksz of
8192 to preserve behavior. The real values (if different) are
not known at this time. Other ABI modules use the real
values.

The native MINSIGSTKSZ is now defined as follows:

Arch		MINSIGSTKSZ
----		-----------
alpha		    4096
i386		    2048
ia64		   12288

Reviewed by: mjacob
Suggested by: bde
2000-11-09 08:25:48 +00:00
Marcel Moolenaar
2da829a0c8 Sync with Alpha:
Do not use sysent.c, proto.h and syscall.h in source tree;
use auto-generated versions.
2000-11-09 07:27:55 +00:00
Dag-Erling Smørgrav
fd9f324055 Check that p->p_pptr is not NULL - kernel processes have no parents! 2000-11-06 03:23:56 +00:00
David E. O'Brien
83d2913008 Make the target a little bit more generic. 2000-11-01 08:47:34 +00:00
Andrew Gallatin
84aa58ab03 fix the sigaltstack hack by lowering the stack size to the original value
if the request was for less than MINSIGSTKSZ (in which case we "round up").
discussed with: marcel
2000-10-31 03:10:41 +00:00
Poul-Henning Kamp
da936bf80a Remove unneeded <stddef.h> #includes. 2000-10-29 16:57:42 +00:00
Dag-Erling Smørgrav
f8c05e5019 Bring cpuinfo closer to what it looks like in Linux 2.2.
Submitted by:	R Bradford Jones <brad@kazrak.com>
2000-10-25 22:38:23 +00:00
Dag-Erling Smørgrav
886a6f6fca Add /proc/<pid>/status and /proc/<pid>/stat (the latter being mostly
zeroes for the time being).

Prompted by:	Nathan Boeger <nathan@khmere.com>
2000-10-25 22:12:59 +00:00
Andrew Gallatin
242fae60f0 Some linux apps, such as IBM's JDK 1.3, will attempt to mmap thread
stacks near the top of their address space.  If their TOS is greater
than vm_maxsaddr, vm_map_growstack() will confuse the thread stack
with the process stack and deliver a SEGV if they attempt to grow the
thread stack past their current stacksize rlimit.  To avoid this,
adjust vm_maxsaddr upwards to reflect the current stacksize rlimit
rather than the maximum possible stacksize.  It would be better to
adjust the mmap'ed region, but some apps (again, IBM's JDK 1.3) do not
check mmap's return value..

This commit (in conjunction with setting MINSIGSTKSZ to 2048 &
rebuilding your kernel and modules) will get IBM's JDK 1.3 working
with FreeBSD at least well enough to run many of the example applets.

Reviewed by: marcel
Tested by:   sto@stat.duke.edu, many others on freebsd-java@
2000-10-17 00:25:43 +00:00
Andrew Gallatin
21b0b22ce3 regen after addition of linux_rt_sigreturn 2000-10-17 00:03:02 +00:00
Andrew Gallatin
7936339495 A start at an implemention of linux_rt_sendsig & linux_rt_sigreturn
and associated user-level signal trampoline glue.

Without this patch, an SA_SIGINFO style handler can be installed by a linux
app, but if the handler accesses its sip argument, it will get a garbage
pointer and likely segfault.

We currently supply a valid pointer, but its contents are mainly
garbage.  Filling this in properly is future work.

This is the second of 3 commits that will get IBM's JDK 1.3 working with
FreeBSD ...
2000-10-17 00:00:20 +00:00