Commit Graph

926 Commits

Author SHA1 Message Date
Poul-Henning Kamp
fc5571cc25 Remove duplicate code. 2005-01-13 19:27:28 +00:00
Warner Losh
898b0535b7 Start each of the license/copyright comments with /*- 2005-01-05 22:34:37 +00:00
John Baldwin
c88379381b - Move the function prototypes for kern_setrlimit() and kern_wait() to
sys/syscallsubr.h where all the other kern_foo() prototypes live.
- Resort kern_execve() while I'm there.
2005-01-05 22:19:44 +00:00
John Baldwin
d7d1139749 Regenerate. 2005-01-04 18:54:40 +00:00
John Baldwin
20ae37df8c Partial sync up to the master syscalls.master file:
- Mark mount, unmount and nmount MPSAFE.
- Add a stub for _umtx_op().
- Mark open(), link(), unlink(), and freebsd32_sigaction() MPSAFE.

Pointy hats to:	several
2005-01-04 18:53:32 +00:00
John Baldwin
63710c4d35 Stop explicitly touching td_base_pri outside of the scheduler and simply
set a thread's priority via sched_prio() when that is the desired action.
The schedulers will start managing td_base_pri internally shortly.
2004-12-30 20:29:58 +00:00
Poul-Henning Kamp
c9b621fb98 Do not blindly pass linux filesystem specific mount data across. 2004-12-03 18:14:22 +00:00
Colin Percival
691b3b0df9 Fix unvalidated pointer dereference. This is FreeBSD-SA-04:17.procfs. 2004-12-01 21:33:02 +00:00
David Schultz
6004362e66 Don't include sys/user.h merely for its side-effect of recursively
including other headers.
2004-11-27 06:51:39 +00:00
David Schultz
d3adf76902 Axe the semblance of support for PECOFF and Linux a.out core dumps. 2004-11-27 06:46:45 +00:00
Poul-Henning Kamp
f8524838b9 Ignore MNT_NODEV option, it is implicit in choice of filesystem. 2004-11-26 07:39:20 +00:00
David Schultz
0ef5c36ff1 Maintain the broken state of backwards compatibilty for a.out (and
PECOFF!) core dumps.  None of the old versions of gdb I tried were
able to read a.out core dumps before or after this change.

Reviewed by:	arch@
2004-11-20 02:32:04 +00:00
Mark Santcroos
463b173e50 Rebuild from compat/freebsd32/syscalls.master:1.43
Reviewed by:	imp, phk, njl, peter
Approved by:	njl
2004-11-18 23:56:09 +00:00
Mark Santcroos
f16ab45fbc 32-bit FreeBSD ABI compatibility stubs from syscalls.master:1.179
Reviewed by:	imp, phk, njl, peter
Approved by:	njl
2004-11-18 23:54:26 +00:00
Poul-Henning Kamp
124e4c3be8 Introduce an alias for FILEDESC_{UN}LOCK() with the suffix _FAST.
Use this in all the places where sleeping with the lock held is not
an issue.

The distinction will become significant once we finalize the exact
lock-type to use for this kind of case.
2004-11-13 11:53:02 +00:00
Poul-Henning Kamp
7689860fd5 Pick up the inode number using VOP_GETATTR() rather than caching it
in all vnodes on the off chance that linprocfs needs it.  If we can afford
to call vn_fullpath() we can afford the much cheaper VOP_GETATTR().
2004-11-10 07:25:37 +00:00
Poul-Henning Kamp
0ac3a7f694 More sensible FILEDESC_ locking. 2004-11-07 15:59:27 +00:00
Robert Watson
a4bde6f695 Rebuild from FreeBSD32 syscalls.master:1.42. 2004-10-23 20:05:42 +00:00
Robert Watson
8e36528346 32-bit FreeBSD ABI compatibility stubs from syscalls.master:1.178. 2004-10-23 20:04:56 +00:00
Peter Wemm
a7bc3102c4 Put on my peril sensitive sunglasses and add a flags field to the internal
sysctl routines and state.  Add some code to use it for signalling the need
to downconvert a data structure to 32 bits on a 64 bit OS when requested by
a 32 bit app.

I tried to do this in a generic abi wrapper that intercepted the sysctl
oid's, or looked up the format string etc, but it was a real can of worms
that turned into a fragile mess before I even got it partially working.

With this, we can now run 'sysctl -a' on a 32 bit sysctl binary and have
it not abort.  Things like netstat, ps, etc have a long way to go.

This also fixes a bug in the kern.ps_strings and kern.usrstack hacks.
These do matter very much because they are used by libc_r and other things.
2004-10-11 22:04:16 +00:00
David Malone
08de85f54a Rename thread args to be called "td" rather than "p" to be
consistent with other bits of this file. There should be no
functional change.

Submitted by:	Andrea Campi (many moons ago)
MFC after:	2 month
2004-10-10 18:34:30 +00:00
Mike Makonnen
401901ac43 Close a race between a thread exiting and the freeing of it's stack.
After some discussion the best option seems to be to signal the thread's
death from within the kernel. This requires that thr_exit() take an
argument.

Discussed with: davidxu, deischen, marcel
MFC after: 3 days
2004-10-06 14:23:00 +00:00
John Baldwin
78c85e8dfc Rework how we store process times in the kernel such that we always store
the raw values including for child process statistics and only compute the
system and user timevals on demand.

- Fix the various kern_wait() syscall wrappers to only pass in a rusage
  pointer if they are going to use the result.
- Add a kern_getrusage() function for the ABI syscalls to use so that they
  don't have to play stackgap games to call getrusage().
- Fix the svr4_sys_times() syscall to just call calcru() to calculate the
  times it needs rather than calling getrusage() twice with associated
  stackgap, etc.
- Add a new rusage_ext structure to store raw time stats such as tick counts
  for user, system, and interrupt time as well as a bintime of the total
  runtime.  A new p_rux field in struct proc replaces the same inline fields
  from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime).  A new p_crux
  field in struct proc contains the "raw" child time usage statistics.
  ruadd() has been changed to handle adding the associated rusage_ext
  structures as well as the values in rusage.  Effectively, the values in
  rusage_ext replace the ru_utime and ru_stime values in struct rusage.  These
  two fields in struct rusage are no longer used in the kernel.
- calcru() has been split into a static worker function calcru1() that
  calculates appropriate timevals for user and system time as well as updating
  the rux_[isu]u fields of a passed in rusage_ext structure.  calcru() uses a
  copy of the process' p_rux structure to compute the timevals after updating
  the runtime appropriately if any of the threads in that process are
  currently executing.  It also now only locks sched_lock internally while
  doing the rux_runtime fixup.  calcru() now only requires the caller to
  hold the proc lock and calcru1() only requires the proc lock internally.
  calcru() also no longer allows callers to ask for an interrupt timeval
  since none of them actually did.
- calcru() now correctly handles threads executing on other CPUs.
- A new calccru() function computes the child system and user timevals by
  calling calcru1() on p_crux.  Note that this means that any code that wants
  child times must now call this function rather than reading from p_cru
  directly.  This function also requires the proc lock.
- This finishes the locking for rusage and friends so some of the Giant locks
  in exit1() and kern_wait() are now gone.
- The locking in ttyinfo() has been tweaked so that a shared lock of the
  proctree lock is used to protect the process group rather than the process
  group lock.  By holding this lock until the end of the function we now
  ensure that the process/thread that we pick to dump info about will no
  longer vanish while we are trying to output its info to the console.

Submitted by:	bde (mostly)
MFC after:	1 month
2004-10-05 18:51:11 +00:00
John Baldwin
4afec35169 Add a proc *p pointer for td->td_proc to make this code easier to read. 2004-09-24 20:26:15 +00:00
Poul-Henning Kamp
f69f5fbd42 Hold thread reference while frobbing cdevsw. 2004-09-24 06:37:00 +00:00
John Baldwin
7eaec467d8 Various small style fixes. 2004-09-22 15:24:33 +00:00
Bruce M Simpson
6120a003b4 Fix compiler warnings, when __stdcall is #defined, by adding explicit casts.
These normally only manifest if the ndis compat module is statically
compiled into a kernel image by way of 'options NDISAPI'.

Submitted by:	Dmitri Nikulin
Approved by:	wpaul
PR:		kern/71449
MFC after:	1 week
2004-09-17 19:54:26 +00:00
John Baldwin
8a7aa72dec Regenerate after fcntl() wrappers were marked MP safe. 2004-08-24 20:24:34 +00:00
John Baldwin
2ca25ab53e Fix the ABI wrappers to use kern_fcntl() rather than calling fcntl()
directly.  This removes a few more users of the stackgap and also marks
the syscalls using these wrappers MP safe where appropriate.

Tested on:	i386 with linux acroread5
Compiled on:	i386, alpha LINT
2004-08-24 20:21:21 +00:00
Dag-Erling Smørgrav
72261b9f61 Don't try to translate the control message unless we're certain it's
valid; otherwise a caller could trick us into changing any 32-bit word
in kernel memory to LINUX_SOL_SOCKET (0x00000001) if its previous value
is SOL_SOCKET (0x0000ffff).

MFC after:	3 days
2004-08-23 12:41:29 +00:00
Bill Paul
ae58ccaa60 I'm a dumbass: remember to initialize fh->nf_map to NULL in
ndis_open_file() in the module loading case.
2004-08-16 19:25:27 +00:00
Bill Paul
161a639981 The Texas Instruments ACX111 driver wants srand(), so provide it. 2004-08-16 18:52:37 +00:00
Bill Paul
f454f98c31 Make the Texas Instruments 802.11g chipset work with the NDISulator.
This was tested with a Netgear WG311v2 802.11b/g PCI card. Things
that were fixed:

- This chip has two memory mapped regions, one at PCIR_BAR(0) and the
  other at PCIR_BAR(1). This is a little different from the other
  chips I've seen with two PCI shared memory regions, since they tend
  to have the second BAR ad PCIR_BAR(2). if_ndis_pci.c tests explicitly
  for PCIR_BAR(2). This has been changed to simply fill in ndis_res_mem
  first and ndis_res_altmem second, if a second shared memory range
  exists. Given that NDIS drivers seem to scan for BARs in ascending
  order, I think this should be ok.

- Fixed the code that tries to process firmware images that have been
  loaded as .ko files. To save a step, I was setting up the address
  mapping in ndis_open_file(), but ndis_map_file() flags pre-existing
  mappings as an error (to avoid duplicate mappings). Changed this so
  that the mapping is now donw in ndis_map_file() as expected.

- Made the typedef for 'driver_entry' explicitly include __stdcall
  to silence gcc warning in ndis_load_driver().

NOTE: the Texas Instruments ACX111 driver needs firmware. With my
card, there were 3 .bin files shipped with the driver. You must
either put these files in /compat/ndis or convert them with
ndiscvt -f and kldload them so the driver can use them. Without
the firmware image, the NIC won't work.
2004-08-16 18:50:20 +00:00
David E. O'Brien
b61c60d401 Fix the 'DEBUG' argument code to unbreak the amd64 LINT build. 2004-08-16 12:15:07 +00:00
David E. O'Brien
4a16b489ca Fix the 'DEBUG' argument code to unbreak the amd64 LINT build. 2004-08-16 11:12:57 +00:00
David E. O'Brien
3a2e3a4aa7 Fix the 'DEBUG' argument code to unbreak the LINT build. 2004-08-16 10:36:12 +00:00
Tim J. Robbins
84880f87d0 Add support for 32-bit Linux binary emulation on amd64:
- include <machine/../linux32/linux.h> instead of <machine/../linux/linux.h>
  if building with the COMPAT_LINUX32 option.
- make minimal changes to the i386 linprocfs_docpuinfo() function to support
  amd64. We return a fake CPU family of 6 for now.
2004-08-16 08:19:18 +00:00
Tim J. Robbins
4af2762336 Changes to MI Linux emulation code necessary to run 32-bit Linux binaries
on AMD64, and the general case where the emulated platform has different
size pointers than we use natively:
- declare certain structure members as l_uintptr_t and use the new PTRIN
  and PTROUT macros to convert to and from native pointers.
- declare some structures __packed on amd64 when the layout would differ
  from that used on i386.
- include <machine/../linux32/linux.h> instead of <machine/../linux/linux.h>
  if compiling with COMPAT_LINUX32. This will need to be revisited before
  32-bit and 64-bit Linux emulation support can coexist in the same kernel.
- other small scattered changes.

This should be a no-op on i386 and Alpha.
2004-08-16 07:28:16 +00:00
Tim J. Robbins
ae8e14a6ac Replace linux_getitimer() and linux_setitimer() with implementations
based on those in freebsd32_misc.c, removing the assumption that Linux
uses the same layout for struct itimerval as we use natively.
2004-08-15 12:34:15 +00:00
Tim J. Robbins
d1d6dbf120 Avoid assuming that l_timeval is the same as the native struct timeval
in linux_select().
2004-08-15 12:24:05 +00:00
Tim J. Robbins
6fa534bad8 Use sv_psstrings from the current process's sysentvec structure instead
of PS_STRINGS. This is a no-op at present, but it will be needed when
running 32-bit Linux binaries on amd64 to ensure PS_STRINGS is in
addressable memory.
2004-08-15 11:52:45 +00:00
Poul-Henning Kamp
41befa53a4 Add XXX comment about findcdev() misuse. 2004-08-14 08:38:17 +00:00
Marcel Moolenaar
4da47b2fec Add __elfN(dump_thread). This function is called from __elfN(coredump)
to allow dumping per-thread machine specific notes. On ia64 we use this
function to flush the dirty registers onto the backingstore before we
write out the PRSTATUS notes.

Tested on: alpha, amd64, i386, ia64 & sparc64
Not tested on: arm, powerpc
2004-08-11 02:35:06 +00:00
Bill Paul
6f4481422e More minor cleanups and one small bug fix:
- In ntoskrnl_var.h, I had defined compat macros for
  ntoskrnl_acquire_spinlock() and ntoskrnl_release_spinlock() but
  never used them. This is fortunate since they were stale. Fix them
  to work properly. (In Windows/x86 KeAcquireSpinLock() is a macro that
  calls KefAcquireSpinLock(), which lives in HAL.dll. To imitate this,
  ntoskrnl_acquire_spinlock() is just a macro that calls hal_lock(),
  which lives in subr_hal.o.)

- Add macros for ntoskrnl_raise_irql() and ntoskrnl_lower_irql() that
  call hal_raise_irql() and hal_lower_irql().

- Use these macros in kern_ndis.c, subr_ndis.c and subr_ntoskrnl.c.

- Along the way, I realised subr_ndis.c:ndis_lock() was not calling
  hal_lock() correctly (it was using the FASTCALL2() wrapper when
  in reality this routine is FASTCALL1()). Using the
  ntoskrnl_acquire_spinlock() fixes this. Not sure if this actually
  caused any bugs since hal_lock() would have just ignored what
  was in %edx, but it was still bogus.

This hides many of the uses of the FASTCALLx() macros which makes the
code a little cleaner. Should not have any effect on generated object
code, other than the one fix in ndis_lock().
2004-08-04 18:22:50 +00:00
Bill Paul
20b03f4992 In ndis_alloc_bufpool() and ndis_alloc_packetpool(), the test to see if
allocating pool memory succeeded was checking the wrong pointer (should
have been looking at *pool, not pool). Corrected this.
2004-08-01 21:15:29 +00:00
Bill Paul
f13b900a9e Big mess 'o changes:
- Give ndiscvt(8) the ability to process a .SYS file directly into
  a .o file so that we don't have to emit big messy char arrays into
  the ndis_driver_data.h file. This behavior is currently optional, but
  may become the default some day.

- Give ndiscvt(8) the ability to turn arbitrary files into .ko files
  so that they can be pre-loaded or kldloaded. (Both this and the
  previous change involve using objcopy(1)).

- Give NdisOpenFile() the ability to 'read' files out of kernel memory
  that have been kldloaded or pre-loaded, and disallow the use of
  the normal vn_open() file opening method during bootstrap (when no
  filesystems have been mounted yet). Some people have reported that
  kldloading if_ndis.ko works fine when the system is running multiuser
  but causes a panic when the modile is pre-loaded by /boot/loader. This
  happens with drivers that need to use NdisOpenFile() to access
  external files (i.e. firmware images). NdisOpenFile() won't work
  during kernel bootstrapping because no filesystems have been mounted.
  To get around this, you can now do the following:

        o Say you have a firmware file called firmware.img
        o Do: ndiscvt -f firmware.img -- this creates firmware.img.ko
        o Put the firmware.img.ko in /boot/kernel
        o add firmware.img_load="YES" in /boot/loader.conf
        o add if_ndis_load="YES" and ndis_load="YES" as well

  Now the loader will suck the additional file into memory as a .ko. The
  phony .ko has two symbols in it: filename_start and filename_end, which
  are generated by objcopy(1). ndis_open_file() will traverse each module
  in the module list looking for these symbols and, if it finds them, it'll
  use them to generate the file mapping address and length values that
  the caller of NdisOpenFile() wants.

  As a bonus, this will even work if the file has been statically linked
  into the kernel itself, since the "kernel" module is searched too.
  (ndiscvt(8) will generate both filename.o and filename.ko for you).

- Modify the mechanism used to provide make-pretend FASTCALL support.
  Rather than using inline assembly to yank the first two arguments
  out of %ecx and %edx, we now use the __regparm__(3) attribute (and
  the __stdcall__ attribute) and use some macro magic to re-order
  the arguments and provide dummy arguments as needed so that the
  arguments passed in registers end up in the right place. Change
  taken from DragonflyBSD version of the NDISulator.
2004-08-01 20:04:31 +00:00
Poul-Henning Kamp
ebb48ffd65 Use kernel_vmount() instead of vfs_nmount(). 2004-07-27 21:38:42 +00:00
Colin Percival
56f21b9d74 Rename suser_cred()'s PRISON_ROOT flag to SUSER_ALLOWJAIL. This is
somewhat clearer, but more importantly allows for a consistent naming
scheme for suser_cred flags.

The old name is still defined, but will be removed in a few days (unless I
hear any complaints...)

Discussed with:	rwatson, scottl
Requested by:	jhb
2004-07-26 07:24:04 +00:00
Bill Paul
020732be39 *sigh* Fix source code compatibility with 5.2.1-RELEASE _again_.
(Make kdb stuff conditional.)
2004-07-20 20:28:57 +00:00
David Malone
fb75797e40 I missed two pieces of the commit to this file. Robert has already
added one, this adds the other.
2004-07-18 09:26:34 +00:00