Commit Graph

1992 Commits

Author SHA1 Message Date
Andrew Gallatin
2ea9877c1b give alpha a bus_space_subregion() so that ahd_pci compiles and moves
LINT one file further on.  Only 999,999 or so more files to go..
2002-10-20 20:55:37 +00:00
Marcel Moolenaar
1aeb23cdfa Add two hooks to signal module load and module unload to MD code.
The primary reason for this is to allow MD code to process machine
specific attributes, segments or sections in the ELF file and
update machine specific state accordingly. An immediate use of this
is in the ia64 port where unwind information is updated to allow
debugging and tracing in/across modules. Note that this commit
does not add the functionality to the ia64 port. See revision 1.9
of ia64/ia64/elf_machdep.c.

Validated on: alpha, i386, ia64
2002-10-19 19:16:03 +00:00
Robert Watson
c7063e5913 Permits UFS ACLs to be used with the GENERIC kernel. Due to recent
ACL configuration changes, this shouldn't result in different code paths
for file systems not explicitly configured for ACLs by the system
administrator.  For UFS1, administrators must still recompile their
kernel to add support for extended attributes; for UFS2, it's sufficient
to enable ACLs using tunefs or at mount-time (tunefs preferred for
reliability reasons).  UFS2, for a variety of reasons, including
performance and reliability, is the preferred file system for use with
ACLs.

Approved by:	re
2002-10-19 16:54:15 +00:00
Peter Wemm
af3f249f3a The a.out md_coredump stuff isn't referenced anywhere anymore, and
hasn't been filled in for ages..  Nuked.
2002-10-15 00:02:50 +00:00
Mike Barcroft
4275e0d98d Remove the P1003_1B kernel option; it is no longer used. 2002-10-13 16:29:17 +00:00
Mike Barcroft
7a77412855 Add standards visibility conditionals. Change any uses of sigset_t to
struct __sigset to avoid depending on objects from <sys/signal.h>.
2002-10-13 00:31:46 +00:00
Mike Barcroft
2b7f24d210 Change iov_base's type from char *' to the standard void *'. All
uses of iov_base which assume its type is `char *' (in order to do
pointer arithmetic) have been updated to cast iov_base to `char *'.
2002-10-11 14:58:34 +00:00
Maxim Sobolev
3ad9c842d2 - Add support for IPC_64 extensions into shmctl(2), semctl(2) and msgctl(2);
- add wrappers for mmap2(2) and ftruncate64(2) system calls;
- don't spam console with printf's when VFAT_READDIR_BOTH ioctl(2) is invoked;
- add support for SOUND_MIXER_READ_STEREODEVS ioctl(2);
- make msgctl(IPC_STAT) and IPC_SET actually working by converting from
  BSD msqid_ds to Linux and vice versa;
- properly return EINVAL if semget(2) is called with nsems being negative.

Reviewed by:	marcel
Approved by:	marcel
Tested with:	LSB runtime test
2002-10-11 11:43:09 +00:00
Mike Barcroft
ddb056b7d4 Add conditionals to allow va_list to be defined in other headers. 2002-10-06 22:02:06 +00:00
Mike Barcroft
0b058e3cbd o Add conditionals to allow va_list to be defined in other headers.
o Standardize on _MACHINE_STDARG_H_ to allow multiple header includes.
o Restrict the definition of va_copy() to C99 environments.
2002-10-06 22:01:07 +00:00
David E. O'Brien
8185498ac2 CPU_MAXID should 2002-10-06 05:24:13 +00:00
Poul-Henning Kamp
3bd6561289 NB: This commit does *NOT* make GEOM the default in FreeBSD
NB: But it will enable it in all kernels not having options "NO_GEOM"

Put the GEOM related options into the intended order.

Add "options NO_GEOM" to all kernel configs apart from NOTES.

In some order of controlled fashion, the NO_GEOM options will be
removed, architecture by architecture in the coming days.

There are currently three known issues which may force people to
need the NO_GEOM option:

boot0cfg/fdisk:
        Tries to update the MBR while it is being used to control
        slices.  GEOM does not allow this as a direct operation.

SCSI floppy drives:
        Appearantly the scsi-da driver return "EBUSY" if no media
        is inserted.  This is wrong, it should return ENXIO.

PC98:
        It is unclear if GEOM correctly recognizes all variants of
        PC98 disklabels.  (Help Wanted!  I have neither docs nor HW)

These issues are all being worked.

Sponsored by:	DARPA & NAI Labs.
2002-10-05 16:35:33 +00:00
Mike Barcroft
e61d3b10d7 Fix namespace issues by using visibility conditionals from
<sys/cdefs.h>.
2002-10-05 05:47:56 +00:00
Mike Barcroft
085f8416a2 style(9) <machine/setjmp.h> headers so they look mostly the same. 2002-10-04 22:10:06 +00:00
Sam Leffler
14c17bd293 New bus_dma interfaces for use by crypto device drivers:
o bus_dmamap_load_mbuf
o bus_dmamap_load_uio

Test on i386.  Known to compile on alpha and sparc64, but not tested.
Otherwise untried.
2002-10-04 20:40:39 +00:00
Giorgos Keramidas
7528dee5eb Add a couple of missing ':' in panic msgs.
Suggested by:	gallatin
2002-10-04 15:58:03 +00:00
Giorgos Keramidas
48eaa43e79 Fix typo in panic msg.
Reviewed by:	gallatin
2002-10-04 15:56:02 +00:00
Andrew Gallatin
5f570c5179 MFi386: fork1 apparently takes 4 args now
Forgotten by: scottl
2002-10-02 14:30:14 +00:00
Scott Long
316ec49abd Some kernel threads try to do significant work, and the default KSTACK_PAGES
doesn't give them enough stack to do much before blowing away the pcb.
This adds MI and MD code to allow the allocation of an alternate kstack
who's size can be speficied when calling kthread_create.  Passing the
value 0 prevents the alternate kstack from being created.  Note that the
ia64 MD code is missing for now, and PowerPC was only partially written
due to the pmap.c being incomplete there.
Though this patch does not modify anything to make use of the alternate
kstack, acpi and usb are good candidates.

Reviewed by:	jake, peter, jhb
2002-10-02 07:44:29 +00:00
Poul-Henning Kamp
fcd054483a Fix the same misinitialization of pmap_prefault_pageorder as on i386.
Suggeste by:	jake
2002-10-01 20:56:29 +00:00
Juli Mallett
1d9c56964d Back our kernel support for reliable signal queues.
Requested by:	rwatson, phk, and many others
2002-10-01 17:15:53 +00:00
Juli Mallett
1226f694e6 First half of implementation of ksiginfo, signal queues, and such. This
gets signals operating based on a TailQ, and is good enough to run X11,
GNOME, and do job control.  There are some intricate parts which could be
more refined to match the sigset_t versions, but those require further
evaluation of directions in which our signal system can expand and contract
to fit our needs.

After this has been in the tree for a while, I will make in kernel API
changes, most notably to trapsignal(9) and sendsig(9), to use ksiginfo
more robustly, such that we can actually pass information with our
(queued) signals to the userland.  That will also result in using a
struct ksiginfo pointer, rather than a signal number, in a lot of
kern_sig.c, to refer to an individual pending signal queue member, but
right now there is no defined behaviour for such.

CODAFS is unfinished in this regard because the logic is unclear in
some places.

Sponsored by:	New Gold Technology
Reviewed by:	bde, tjr, jake [an older version, logic similar]
2002-09-30 20:20:22 +00:00
Alfred Perlstein
4f492bfab5 use __packed. 2002-09-23 18:54:32 +00:00
Julian Elischer
d10fbbff27 Remove a bunch of stuff that is surplus now 2002-09-23 08:04:30 +00:00
Peter Wemm
c692fbe091 At great personal risk, add a __packed and __aligned(x) define that
expand to __attribute__((packed)) and __attribute__((aligned(x)))
respectively.  Replace the handful of gcc-ism's that use
__attribute__((aligned(16))) etc around the kernel with __aligned(16).

There are over 400 __attribute__((packed)) to deal with, that can come
later.  I just want to use __packed in new code rather than add more
gcc-ism's.
2002-09-23 05:55:10 +00:00
Mike Barcroft
c0d4804d67 Be careful not to define GCC-specific optimizations in the non-GCC
case.
2002-09-23 04:32:17 +00:00
Jake Burkholder
05ba50f522 Use the fields in the sysentvec and in the vm map header in place of the
constants VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK and PS_STRINGS.
This is mainly so that they can be variable even for the native abi, based
on different machine types.  Get stack protections from the sysentvec too.
This makes it trivial to map the stack non-executable for certain abis, on
machines that support it.
2002-09-21 22:07:17 +00:00
Alan Cox
60b09ad43c o Remove an initialized but unused variable from pmap_remove_all(). 2002-09-21 19:42:11 +00:00
Mark Murray
0a7d7bdc02 Wrap GNUish asm() code in #ifdef __GNUC__ 2002-09-21 19:12:59 +00:00
Poul-Henning Kamp
6fb3d70418 For reasons now lost in historical fog, the bounds_check_with_label()
function were put in i386/i386/machdep.c from where it has been
cut and pasted to other architectures with only minor corruption.

Disklabel is really a MI format in many ways, at least it certainly
is when you operate on struct disklabel.

Put bounds_check_with_label() back in subr_disklabel.c where it belongs.

Sponsored by:   DARPA & NAI Labs.
2002-09-20 17:51:00 +00:00
Poul-Henning Kamp
2fb81ca352 Remove needless <sys/disklabel.h> and <sys/diskslice.h> #includes.
Sponsored by:	DARPA & NAI Labs.
2002-09-20 16:37:15 +00:00
John Baldwin
c0193e5382 Fix last commit so that it actually works:
- Get test for valid trace request contents right.
- You don't use 'stq' to move a value from one register to another,
  use 'mov' to read sp.  Also, can't use nice names for registers
  in in-line asm in gcc.
- pc is not a publically accessible register, instead, create a label
  in the asm code and use 'lda' to load the address of that label into
  the pc field of the trace request.
- Use correction function name for db_print_backtrace().
2002-09-19 20:40:26 +00:00
John Baldwin
c79408a059 Implement db_print_backtrace() if DDB is compiled into the kernel. This
MD function is just a wrapper around db_stack_trace_cmd() that prints out
a backtrace of curthread.  Currently, this function is only implemented
on i386 and alpha (and the alpha version isn't quite tested yet, will do
that in a bit).  Other changes:

- For i386, fix a bug in the raw frame address case.  The eip we extract
  from the passed in frame address does not match the frame we received.
  Thus, instead of printing a bogus frame with the wrong eip, go ahead
  and advance frame down to the same frame as the eip we are using.
- For alpha, attempt to add a way of doing a raw trace for alpha.  Instead
  of passing a frame address in 'addr', pass in a pointer to a structure
  containing PC and KSP and use those to start the backtrace.  The alpha
  db_print_backtrace() uses asm to read in the current PC and KSP values
  into such a request.

Tested on:	i386
Requested by:	many
2002-09-19 18:46:29 +00:00
Mike Barcroft
86954511d2 Implement C99's va_copy() macro. 2002-09-18 07:33:16 +00:00
Peter Wemm
2480d1854f Add stub function for cpu_set_upcall_kse() 2002-09-17 07:49:40 +00:00
Peter Wemm
28487340f2 #if 0 out the following functions:
cpu_export_context()
  cpu_set_args()
  cpu_free_kse_mdstorage()
  cpu_export_context()
2002-09-17 07:47:10 +00:00
Peter Wemm
b069d4207c Make this compile after the last kse commit. 2002-09-17 07:44:28 +00:00
Peter Wemm
1822cdcafe It seems I accidently committed a change that removed the userland includes
from the kernel build.  This broke linux_genassym on the alpha.  For the
kernel, the correct place to get offsetof() is not in /usr/include/stddef.h
but rather <sys/types.h>
2002-09-17 07:22:23 +00:00
Peter Wemm
66422f5b7a Initiate deorbit burn for the i386-only a.out related support. Moves are
under way to move the remnants of the a.out toolchain to ports.  As the
comment in src/Makefile said, this stuff is deprecated and one should not
expect this to remain beyond 4.0-REL.  It has already lasted WAY beyond
that.

Notable exceptions:
gcc - I have not touched the a.out generation stuff there.
ldd/ldconfig - still have some code to interface with a.out rtld.
old as/ld/etc - I have not removed these yet, pending their move to ports.
some includes - necessary for ldd/ldconfig for now.

Tested on: i386 (extensively), alpha
2002-09-17 01:49:00 +00:00
Julian Elischer
4f0db5e08c Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.
next step is to allow > 1 to be allocated per process. This would give
multi-processor threads. (when the rest of the infrastructure is
in place)

While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc
are diverging more than they should.. corrective action needed soon.
2002-09-15 23:52:25 +00:00
Scott Long
d594cee0e0 kthread.h is not needed 2002-09-14 16:54:46 +00:00
Peter Wemm
8b10ca9ba9 The nfsroot code should be conditional on NFSCLIENT, not NFS (which no
longer exists as an option)
2002-09-13 20:29:42 +00:00
Peter Wemm
bf7eacb62f Somebody forgot to turn out the lights.
(ie: These files are long since obsolete)
2002-09-11 20:20:38 +00:00
Julian Elischer
71fad9fdee Completely redo thread states.
Reviewed by:	davidxu@freebsd.org
2002-09-11 08:13:56 +00:00
Juli Mallett
77c70ade18 Fill out two fields (si_pid, si_uid) in the siginfo structure handed back
to userland in the signal handler that were not being iflled out before, but
should and can be.

This part of sendsig could be slightly refactored to use an MI interface, or
ideally, *sendsig*() would have an API change to accept a siginfo_t, which
would be filled out by an MI function in the level above sendsig, and said MI
function would make a small call into MD code to fill out the MD parts (some
of which may be bogus, such as the si_addr stuff in some places).  This would
eventually make it possible for parts of the kernel sending signals to set up
a siginfo with meaningful information.

Reviewed by:	mux
MFC after:	2 weeks
2002-09-07 19:12:53 +00:00
Peter Wemm
1a50106e30 Zap the implementations of the i386-aout specific cpu_coredump function.
Most of the non-i386 platforms had rather broken implementations anyway.
2002-09-07 01:26:34 +00:00
Mike Barcroft
dd1b6791a8 Now that _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ are the same on all
architectures, move the definition directly into <time.h> and finish
the removal of <machine/ansi.h>.
2002-09-03 00:06:58 +00:00
Jake Burkholder
f36ba45234 Added fields for VM_MIN_ADDRESS, PS_STRINGS and stack protections to
sysentvec.  Initialized all fields of all sysentvecs, which will allow
them to be used instead of constants in more places.  Provided stack
fixup routines for emulations that previously used the default.
2002-09-01 21:41:24 +00:00
Peter Wemm
31cdffc6d8 Take a shot at fixing up a whole stack of style and other embarresing
unforced errors that Bruce identified.  I have not yet addressed all of
his concerns.
2002-08-31 03:33:32 +00:00
John Baldwin
ea9b09fef2 Maxmem is a long, so update printf format so this compiles. 2002-08-31 03:21:59 +00:00
Peter Wemm
447b3772dc Change hw.physmem and hw.usermem to unsigned long like they used to be
in the original hardwired sysctl implementation.

The buf size calculator still overflows an integer on machines with large
KVA (eg: ia64) where the number of pages does not fit into an int.  Use
'long' there.

Change Maxmem and physmem and related variables to 'long', mostly for
completeness.  Machines are not likely to overflow 'int' pages in the
near term, but then again, 640K ought to be enough for anybody.  This
comes for free on 32 bit machines, so why not?
2002-08-30 04:04:37 +00:00
Jake Burkholder
bafbd49201 Renamed poorly named setregs to exec_setregs. Moved its prototype to
imgact.h with the other exec support functions.
2002-08-29 06:17:48 +00:00
Mike Barcroft
091fe703a4 Fix a long-standing bug on alpha:
Change _BSD_CLK_TCK_ and _BSD_CLOCKS_PER_SEC_ to match stathz.  This
  should result in bug for bug compatibility in staticly linked
  programs and dynamicly linked programs should see an immediate
  correction.
2002-08-26 02:39:03 +00:00
Philippe Charnier
93b0017f88 Replace various spelling with FALLTHROUGH which is lint()able 2002-08-25 13:23:09 +00:00
Alan Cox
6508a194aa o Retire pmap_pageable(). It's an advisory routine that none
of our platforms implements.
2002-08-25 04:20:05 +00:00
Mike Barcroft
bd8e0716d9 Move several MI types from <machine/_types.h> to <sys/_types.h>.
These types are unlikely to ever become very MD.  They include:
clockid_t, ct_rune_t, fflags_t, intrmask_t, mbstate_t, off_t, pid_t,
rune_t, socklen_t, timer_t, wchar_t, and wint_t.

While moving them, make a few adjustments (submitted by bde):
o __ct_rune_t needs to be precisely `int', not necessarily __int32_t,
  since the arg type of the ctype functions is int.
o __rune_t, __wchar_t and __wint_t inherit this via a typedef of
  __ct_rune_t.
o Some minor wording changes in the comment blocks for ct_rune_t and
  mbstate_t.

Submitted by:	bde (partially)
2002-08-23 16:49:06 +00:00
Peter Wemm
bbf7bd333d Many of the alpha low level console drivers still have bogus compile time
dependencies on syscons.  Bandaid for now.
2002-08-22 19:52:16 +00:00
Mike Barcroft
abbd890233 o Merge <machine/ansi.h> and <machine/types.h> into a new header
called <machine/_types.h>.
o <machine/ansi.h> will continue to live so it can define MD clock
  macros, which are only MD because of gratuitous differences between
  architectures.
o Change all headers to make use of this.  This mainly involves
  changing:
    #ifdef _BSD_FOO_T_
    typedef	_BSD_FOO_T_	foo_t;
    #undef _BSD_FOO_T_
    #endif
  to:
    #ifndef _FOO_T_DECLARED
    typedef	__foo_t	foo_t;
    #define	_FOO_T_DECLARED
    #endif

Concept by:	bde
Reviewed by:	jake, obrien
2002-08-21 16:20:02 +00:00
Peter Wemm
f453022cd9 remove unit counts from atkbdc, pckbd, sc 2002-08-20 00:10:22 +00:00
Robert Watson
ea6027a8e1 Make similar changes to fo_stat() and fo_poll() as made earlier to
fo_read() and fo_write(): explicitly use the cred argument to fo_poll()
as "active_cred" using the passed file descriptor's f_cred reference
to provide access to the file credential.  Add an active_cred
argument to fo_stat() so that implementers have access to the active
credential as well as the file credential.  Generally modify callers
of fo_stat() to pass in td->td_ucred rather than fp->f_cred, which
was redundantly provided via the fp argument.  This set of modifications
also permits threads to perform these operations on behalf of another
thread without modifying their credential.

Trickle this change down into fo_stat/poll() implementations:

- badfo_poll(), badfo_stat(): modify/add arguments.
- kqueue_poll(), kqueue_stat(): modify arguments.
- pipe_poll(), pipe_stat(): modify/add arguments, pass active_cred to
  MAC checks rather than td->td_ucred.
- soo_poll(), soo_stat(): modify/add arguments, pass fp->f_cred rather
  than cred to pru_sopoll() to maintain current semantics.
- sopoll(): moidfy arguments.
- vn_poll(), vn_statfile(): modify/add arguments, pass new arguments
  to vn_stat().  Pass active_cred to MAC and fp->f_cred to VOP_POLL()
  to maintian current semantics.
- vn_close(): rename cred to file_cred to reflect reality while I'm here.
- vn_stat(): Add active_cred and file_cred arguments to vn_stat()
  and consumers so that this distinction is maintained at the VFS
  as well as 'struct file' layer.  Pass active_cred instead of
  td->td_ucred to MAC and to VOP_GETATTR() to maintain current semantics.

- fifofs: modify the creation of a "filetemp" so that the file
  credential is properly initialized and can be used in the socket
  code if desired.  Pass ap->a_td->td_ucred as the active
  credential to soo_poll().  If we teach the vnop interface about
  the distinction between file and active credentials, we would use
  the active credential here.

Note that current inconsistent passing of active_cred vs. file_cred to
VOP's is maintained.  It's not clear why GETATTR would be authorized
using active_cred while POLL would be authorized using file_cred at
the file system level.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-08-16 12:52:03 +00:00
Robert Watson
9ca435893b In order to better support flexible and extensible access control,
make a series of modifications to the credential arguments relating
to file read and write operations to cliarfy which credential is
used for what:

- Change fo_read() and fo_write() to accept "active_cred" instead of
  "cred", and change the semantics of consumers of fo_read() and
  fo_write() to pass the active credential of the thread requesting
  an operation rather than the cached file cred.  The cached file
  cred is still available in fo_read() and fo_write() consumers
  via fp->f_cred.  These changes largely in sys_generic.c.

For each implementation of fo_read() and fo_write(), update cred
usage to reflect this change and maintain current semantics:

- badfo_readwrite() unchanged
- kqueue_read/write() unchanged
  pipe_read/write() now authorize MAC using active_cred rather
  than td->td_ucred
- soo_read/write() unchanged
- vn_read/write() now authorize MAC using active_cred but
  VOP_READ/WRITE() with fp->f_cred

Modify vn_rdwr() to accept two credential arguments instead of a
single credential: active_cred and file_cred.  Use active_cred
for MAC authorization, and select a credential for use in
VOP_READ/WRITE() based on whether file_cred is NULL or not.  If
file_cred is provided, authorize the VOP using that cred,
otherwise the active credential, matching current semantics.

Modify current vn_rdwr() consumers to pass a file_cred if used
in the context of a struct file, and to always pass active_cred.
When vn_rdwr() is used without a file_cred, pass NOCRED.

These changes should maintain current semantics for read/write,
but avoid a redundant passing of fp->f_cred, as well as making
it more clear what the origin of each credential is in file
descriptor read/write operations.

Follow-up commits will make similar changes to other file descriptor
operations, and modify the MAC framework to pass both credentials
to MAC policy modules so they can implement either semantic for
revocation.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-08-15 20:55:08 +00:00
Jeff Roberson
619eb6e579 - Hold the vnode lock throughout execve.
- Set VV_TEXT in the top level execve code.
 - Fixup the image activators to deal with the newly locked vnode.
2002-08-13 06:55:28 +00:00
Alan Cox
e9ed460af2 o Remove an unnecessary vm_page_flash() from _pmap_unwire_pte_hold().
Reviewed by:	peter
2002-08-13 06:22:11 +00:00
Robert Watson
34a762e335 Teach the OSF/1 emulation layer a little more about mandatory access
control: perform checks during OSF/1 statfs()-related calls by
invoking mac_check_mount_stat().

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-08-12 01:16:55 +00:00
Matt Jacob
9b63136347 Add support for the LSI-Logic Fusion/MP architecture.
This is an architecture that present a thing message passing interface
to the OS. You can query as to how many ports and what kind are attached
and enable them and so on.

A less grand view is that this is just another way to package SCSI (SPI or
FC) and FC-IP into a one-driver interface set.

This driver support the following hardware:

LSI FC909:	Single channel, 1Gbps, Fibre Channel (FC-SCSI only)
LSI FC929:	Dual Channel, 1-2Gbps, Fibre Channel (FC-SCSI only)
LSI 53c1020:	Single Channel, Ultra4 (320M) (Untested)
LSI 53c1030:	Dual Channel, Ultra4 (320M)

Currently it's in fair shape, but expect a lot of changes over the
next few weeks as it stabilizes.

Credits:

The driver is mostly from some folks from Jeff Roberson's company- I've
been slowly migrating it to broader support that I it came to me as.

The hardware used in developing support came from:

	FC909: LSI-Logic, Advansys (now Connetix)
	FC929: LSI-Logic
	53c1030: Antares Microsystems (they make a very fine board!)

MFC after:	3 weeks
2002-08-11 23:34:20 +00:00
Alan Cox
38f612e053 o Remove the setting and clearing of the PG_MAPPED flag from the alpha and
ia64 pmap.
 o Remove the PG_MAPPED flag's declaration.
2002-08-10 18:01:39 +00:00
Brooks Davis
05c872ad62 Make ppp(4) devices clonable and unloadable. 2002-08-09 15:30:48 +00:00
Alan Cox
33559722db o Introduce pmap_page_is_mapped(). Its purpose is to obsolete
the PG_MAPPED flag.
2002-08-07 18:03:00 +00:00
Alan Cox
7ffcf9ec77 o Don't set PG_MAPPED or PG_WRITEABLE when a page is mapped
using pmap_kenter() or pmap_qenter().
 o Use VM_ALLOC_WIRED in pmap_new_thread().
2002-08-05 00:04:18 +00:00
Jeff Roberson
e6e370a7fe - Replace v_flag with v_iflag and v_vflag
- v_vflag is protected by the vnode lock and is used when synchronization
   with VOP calls is needed.
 - v_iflag is protected by interlock and is used for dealing with vnode
   management issues.  These flags include X/O LOCK, FREE, DOOMED, etc.
 - All accesses to v_iflag and v_vflag have either been locked or marked with
   mp_fixme's.
 - Many ASSERT_VOP_LOCKED calls have been added where the locking was not
   clear.
 - Many functions in vfs_subr.c were restructured to provide for stronger
   locking.

Idea stolen from:	BSD/OS
2002-08-04 10:29:36 +00:00
Peter Wemm
6a905efed3 ptvmmap does not exist on alpha. 2002-08-02 18:40:01 +00:00
Alan Cox
e5b95b1209 o Lock page queue accesses by vm_page_deactivate(). 2002-08-02 04:40:10 +00:00
Marc Fonvieille
c0727dcbfe Fix the link to the Handbook 2002-08-01 17:21:18 +00:00
John Baldwin
7e71ff5ea7 - Split the unaligned access check flags out of md_flags in struct mdthread
and move them into md_uac in struct mdproc.  mdproc is protected by the
  proc lock.  md_flags now is only ever modified by the current thread, so
  it doesn't need a lock.
- Rename the constants for all the per-thread MD flags to use MDTD_*
  instead of MDP_*.
2002-07-31 19:37:03 +00:00
Mike Barcroft
49545b3891 Create a new header <machine/_stdint.h> for storing MD parts of
<stdint.h>.  Previously, parts were defined in <machine/ansi.h> and
<machine/limits.h>.  This resulted in two problems:
  (1) Defining macros in <machine/ansi.h> gets in the way of that
      header only defining types.
  (2) Defining C99 limits in <machine/limits.h> adds pollution to
      <limits.h>.
2002-07-29 17:41:23 +00:00
Peter Wemm
697fc40af6 de-count pci now that ahc/ahd are taken care of. 2002-07-23 06:36:23 +00:00
Peter Wemm
e8ec5ae1d8 Add static unit count to pci 2002-07-21 23:10:59 +00:00
Peter Wemm
fc147d7fe9 Add explicit unit count on 'device pci' for ahc/ahd 2002-07-21 23:07:31 +00:00
Peter Wemm
3ebc124838 Infrastructure tweaks to allow having both an Elf32 and an Elf64 executable
handler in the kernel at the same time.  Also, allow for the
exec_new_vmspace() code to build a different sized vmspace depending on
the executable environment.  This is a big help for execing i386 binaries
on ia64.   The ELF exec code grows the ability to map partial pages when
there is a page size difference, eg: emulating 4K pages on 8K or 16K
hardware pages.

Flesh out the i386 emulation support for ia64.  At this point, the only
binary that I know of that fails is cvsup, because the cvsup runtime
tries to execute code in pages not marked executable.

Obtained from:  dfr (mostly, many tweaks from me).
2002-07-20 02:56:12 +00:00
Alan Cox
827b2fa091 o Introduce an argument, VM_ALLOC_WIRED, that requests vm_page_alloc()
to return a wired page.
 o Use VM_ALLOC_WIRED within Alpha's pmap_growkernel().  Also, because
   Alpha's pmap_growkernel() calls vm_page_alloc() from within a critical
   section, specify VM_ALLOC_INTERRUPT instead of VM_ALLOC_SYSTEM.  (Only
   VM_ALLOC_INTERRUPT is implemented entirely with a spin mutex.)
 o Assert that the page queues mutex is held in vm_page_wire()
   on Alpha, just like the other platforms.
2002-07-18 04:08:10 +00:00
John Baldwin
dde0429505 Various comment and minor style fixes. No actual content changes.
Inspired by:	bde
2002-07-16 18:20:17 +00:00
John Baldwin
6babe9434a Some style cleanups.
Submitted by:	bde
2002-07-16 15:40:19 +00:00
Mark Murray
e9b24da3d5 Retire the perl gethints.conf in favour of an awk version. Move
the awk version to a central place for maintenance.

Submitted by:	Cyrille Lefevre <cyrille.lefevre@laposte.net>
2002-07-16 09:28:25 +00:00
John Baldwin
abe6ff15e1 Add a NOTES file for the Alpha architecture. 2002-07-15 17:50:17 +00:00
John Baldwin
1d044dd784 The sources to the non-working esp device are no longer present in current. 2002-07-15 14:54:36 +00:00
John Baldwin
19612036d9 - Remove an irrelevant comment from i386 GENERIC.
- Remove unneeded quotes.
- Remove 'config' line.
- Rename ident to SIMOS.
2002-07-15 14:33:20 +00:00
Alan Cox
8b8b8202f9 o Lock page queue accesses by vm_page_wire() that aren't
within a critical section.
 o Assert that the page queues lock is held in vm_page_wire()
   unless an Alpha.
2002-07-14 23:51:55 +00:00
Alan Cox
1f54526952 o Complete the locking of page queue accesses by vm_page_unwire().
o Assert that the page queues lock is held in vm_page_unwire().
 o Make vm_page_lock_queues() and vm_page_unlock_queues() visible
   to kernel loadable modules.
2002-07-13 20:55:21 +00:00
Alfred Perlstein
f0eb293e88 Move COMPAT_FREEBSD4 to arch-neutral sys/conf/NOTES.
Add COMPAT_FREEBSD4 to GENERIC for arches that existed in FreeBSD 4's time,
not just i386. (alpha and pc98)

Requested by: bde
2002-07-13 16:43:53 +00:00
Jonathan Mini
08b38412c8 Add additional cred_free_thread() calls that I had missed the first time.
Pointed out by:	jhb
2002-07-13 04:36:50 +00:00
John Baldwin
33d7ad1abe Set the thread state of the newly chosen to run thread to TDS_RUNNING in
choosethread() in MI C code instead of doing it in in assembly in all the
various cpu_switch() functions.  This fixes problems on ia64 and sparc64.

Reviewed by:	julian, peter, benno
Tested on:	i386, alpha, sparc64
2002-07-12 18:34:22 +00:00
Mike Barcroft
f889202ba4 Remove label_t and physadr, which seem to have never been used in
FreeBSD.

Submitted by:	bde
2002-07-10 15:47:59 +00:00
David E. O'Brien
8442e07371 Desupport the TurboChannel Alpha's. This means the DEC3000/300* Pelic*
and DEC3000/[4-9]00 Flamingo/Sandpiper families.
2002-07-09 19:20:18 +00:00
Mike Barcroft
ba5fe51088 Move __offsetof() macro from <machine/ansi.h> to <sys/cdefs.h>. It's
hardly MD, since all our platforms share the same macro.  It's not
really compiler dependent either, but this helps in reducing
<machine/ansi.h> to only type definitions.
2002-07-08 16:43:35 +00:00
Peter Wemm
a58b3a6878 Add a special page zero entry point intended to be called via the single
threaded VM pagezero kthread outside of Giant.  For some platforms, this
is really easy since it can just use the direct mapped region.  For others,
IPI sending is involved or there are other issues, so grab Giant when
needed.

We still have preemption issues to deal with, but Alan Cox has an
interesting suggestion on how to minimize the problem on x86.

Use Luigi's hack for preserving the (lack of) priority.

Turn the idle zeroing back on since it can now actually do something useful
outside of Giant in many cases.
2002-07-08 04:24:26 +00:00
Peter Wemm
a136efe9b6 Collect all the (now equivalent) pmap_new_proc/pmap_dispose_proc/
pmap_swapin_proc/pmap_swapout_proc functions from the MD pmap code
and use a single equivalent MI version.  There are other cleanups
needed still.

While here, use the UMA zone hooks to keep a cache of preinitialized
proc structures handy, just like the thread system does.  This eliminates
one dependency on 'struct proc' being persistent even after being freed.
There are some comments about things that can be factored out into
ctor/dtor functions if it is worth it.  For now they are mostly just
doing statistics to get a feel of how it is working.
2002-07-07 23:05:27 +00:00
Peter Wemm
19594b9110 Retrofit changes from i386/pmap.c rev 1.328-1.331.
XXX should really replace the pmap_{new,swapin,swapout,dispose}_{proc,thread}
functions with the much cleaner sparc64 versions.
2002-07-04 01:53:09 +00:00
Mike Barcroft
a19d429398 Since printf(3) now supports the `j' conversion specifier, use that
when printing intmax_t and uintmax_t.

Forgotten by:	mike
Noticed by:	bde
2002-06-30 05:48:03 +00:00
Julian Elischer
8540497c50 Fix reverse ordering of locks. add a comment about locks on some platforms.
Submitted by:	jhb@freebsd.org
2002-06-29 23:58:50 +00:00
Julian Elischer
e602ba25fd Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)

Reviewed by:	Almost everyone who counts
	(at various times, peter, jhb, matt, alfred, mini, bernd,
	and a cast of thousands)

	NOTE: this is still Beta code, and contains lots of debugging stuff.
	expect slight instability in signals..
2002-06-29 17:26:22 +00:00
Julian Elischer
44990b8cb8 Add files that are new for KSE. 2002-06-29 07:04:59 +00:00
Jeff Roberson
09122f6371 Set the UMA_ZONE_VM flag on the pvzone to avoid kmem_map recursion. 2002-06-27 04:08:45 +00:00
Jake Burkholder
8ba3d077ff Add an MD callout like cpu_exit, but which is called after sched_lock is
obtained, when all other scheduling activity is suspended.  This is needed
on sparc64 to deactivate the vmspace of the exiting process on all cpus.
Otherwise if another unrelated process gets the exact same vmspace structure
allocated to it (same address), its address space will not be activated
properly.  This seems to fix some spontaneous signal 11 problems with smp
on sparc64.
2002-06-24 15:48:02 +00:00
Jonathan Mini
01ad8a53db Remove unused diagnostic function cread_free_thread().
Approved by:	alfred
2002-06-24 06:22:00 +00:00
Peter Wemm
7022a21abd Update an 'XXX what is this?' type comment about suswintr and fuswintr.
These are 16 bit short values used only by the profiling code.
2002-06-20 07:40:53 +00:00
Peter Wemm
b23619e02a Deorbit suibyte(). It was only used for split address space systems
for supporting UIO_USERISPACE (ie: it wasn't used).
2002-06-20 07:13:35 +00:00
Peter Wemm
2f9267ec23 Move the "- 1" into the RQB_FFS(mask) macro itself so that
implementations can provide a base zero ffs function if they wish.
This changes
  #define RQB_FFS(mask) (ffs64(mask))
  foo = RQB_FFS(mask) - 1;
to
  #define RQB_FFS(mask) (ffs64(mask) - 1)
  foo = RQB_FFS(mask);
On some platforms we can get the "- 1" for free, eg: those that use the
C code for ffs64().

Reviewed by:	jake (in principle)
2002-06-20 06:21:20 +00:00
Alfred Perlstein
1419eacb86 Squish the "could sleep with process lock" messages caused by calling
uifind() with a proc lock held.

change_ruid() and change_euid() have been modified to take a uidinfo
structure which will be pre-allocated by callers, they will then
call uihold() on the uidinfo structure so that the caller's logic
is simplified.

This allows one to call uifind() before locking the proc struct and
thereby avoid a potential blocking allocation with the proc lock
held.

This may need revisiting, perhaps keeping a spare uidinfo allocated
per process to handle this situation or re-examining if the proc
lock needs to be held over the entire operation of changing real
or effective user id.

Submitted by: Don Lewis <dl-freebsd@catspoiler.org>
2002-06-19 06:39:25 +00:00
Matt Jacob
46a23ac4ad Botcho. I included in the last commit the
device		mpt		# LSI-Logic MPT-Fusion

line. This driver isn't ready yet.

Submitted by:	Scott Long
2002-06-16 06:48:42 +00:00
Matt Jacob
3e104c7a84 Note that sio is required.
PR:		39305
Submitted by:	Michael Hogsett <hogsett@csl.sri.com>
MFC after:	1 week
2002-06-14 20:20:13 +00:00
John Baldwin
99cca534f3 - Fixup / remove obsolete comments.
- ktrace no longer requires Giant so do ktrace syscall events before and
  after acquiring and releasing Giant, respectively.
- For i386, ia32 syscalls on ia64, powerpc, and sparc64, get rid of the
  goto bad hack and instead use the model on ia64 and alpha were we
  skip the actual syscall invocation if error != 0.  This fixes a bug
  where if we the copyin() of the arguments failed for a syscall that
  was not marked MP safe, we would try to release Giant when we had
  not acquired it.
2002-06-07 05:47:35 +00:00
Jens Schweikhardt
21dc7d4f57 Fix typo in the BSD copyright: s/withough/without/
Spotted and suggested by:	des
MFC after:	3 weeks
2002-06-02 20:05:59 +00:00
Doug Rabson
99bd783419 Move the definition of ElfN_Hashelt to common headers. The only platform
which has a different definition for this is alpha.
2002-05-30 08:32:18 +00:00
Doug Rabson
396a429cfd Add declarations of suword32 and suword64. Add implementations of one or
the other (or both) to all the platforms. Similar for fuword32 and
fuword64.
2002-05-26 16:03:13 +00:00
Dag-Erling Smørgrav
7b856994fd Make sure there's a statement after the out: label in clockattach(). 2002-05-26 11:23:00 +00:00
Jake Burkholder
d2ac231616 Make the run queue parameters machine dependent. Optimize 64 bit
architectures by using a 64 bit word for the bit array which keeps
track of non-empty queues.

Reviewed by:	peter
2002-05-25 01:12:23 +00:00
John Baldwin
ae3f633bae - Apparently, the Alpha ABI mandates that arguments be passed sign-extended
regardless of if they are signed or unsigned since it is easier to work
  with sign-extended values.  Thus, remove the disabled zapnot to
  zero-extend the sign-extended value we read from *p in atomic_cmpset_32()
  since the cmpval we are comparing against should already be
  sign-extended.
- To ensure that the compiler knows to sign-extend the upper 32 bits of
  cmpval rather than leaving garbage in there, cast the appropriately in
  the constraints section.

Help from:	Richard Henderson <rth@redhat.com>
2002-05-17 05:45:39 +00:00
Tom Rhodes
d394511de3 More s/file system/filesystem/g 2002-05-16 21:28:32 +00:00
Andrew Gallatin
16b9af9990 Fixup unaligned bwx instructions (ldwu, stw). This may fix some mysterious
natd sigbus errors being reported on the freebsd-alpha@ mailing list.

Obtained from: NetBSD
2002-05-16 00:03:32 +00:00
Poul-Henning Kamp
6380601f64 Move MI stuff out of MD param.h files.
It can all still be overridden in the MD files should need suddenly arise.
2002-05-14 20:35:29 +00:00
Poul-Henning Kamp
4c51ae2155 Remove the unused definitions of ctod() and dotc(). 2002-05-14 20:01:34 +00:00
Jake Burkholder
26a9c7b7e1 These were repo-copied to dump_machdep.c. 2002-05-13 02:52:35 +00:00
Andrew Gallatin
338a21a47a Restore the ability to take crashdumps on alpha. This was cut and pasted
nearly in its entirety from i386, so it retains the phk/nati copyright.

Savecore likes the results, but I have no way to test it as gdb is
still broken.
2002-05-11 21:53:46 +00:00
John Baldwin
8f0dda1601 Temporarily disable Jeff's fix for atomic_cmpset_32() to zero-extend the
value we load from memory.  gcc3.1 passes in the u_int32_t old value to
compare against as a _sign_-extended 64-bit value for some reason (bug?).
This is a temporary workaround so kernels work again on alpha.
2002-05-11 04:27:39 +00:00
Andrew Gallatin
8bef1df9eb Remove ## concatination in the CFGREAD and CFGWRITE macros, as gcc3 complains
about them & they are not needed.  Same fix as to tsunami_pci.c.
(not surprising, as this code was cut and pasted from there when I wrote it).
2002-05-10 16:56:14 +00:00
David E. O'Brien
4c04f5d447 Opps, remove added bogon. 2002-05-10 02:21:05 +00:00
David E. O'Brien
fc336fdfbb Gcc 3.1 varargs support. 2002-05-10 02:02:54 +00:00
Matt Jacob
cc8371bc71 Only saying you're launching other CPUs if there are more than one to launch. 2002-05-08 23:12:00 +00:00
Jeff Roberson
c4b689f10a zapnot the signed bits in atomic_cmpset_32. Previously this did not work with
negative values because the original value was sign extended but the compared
value was not.
2002-05-08 05:19:56 +00:00
Juli Mallett
ea0b7a7699 Typo fix: detects -> detect.
Reviewed by:	phk
2002-05-03 17:59:25 +00:00
Peter Wemm
33438f3bac Remove two unused headers (<machine/frame.h> and <machine/psl.h>).
psl.h is 100% bogus to be referenced here, especially from alpha MD code.
2002-05-01 06:24:51 +00:00
Poul-Henning Kamp
2266fe776e Don't export timecounter structures under debug. with sysctl, they
contain no truly interesting data anymore.
2002-04-30 19:34:31 +00:00
Peter Wemm
db17c6fc07 Tidy up some loose ends.
i386/ia64/alpha - catch up to sparc64/ppc:
- replace pmap_kernel() with refs to kernel_pmap
- change kernel_pmap pointer to (&kernel_pmap_store)
  (this is a speedup since ld can set these at compile/link time)
all platforms (as suggested by jake):
- gc unused pmap_reference
- gc unused pmap_destroy
- gc unused struct pmap.pm_count
(we never used pm_count - we track address space sharing at the vmspace)
2002-04-29 07:43:16 +00:00
Alan Cox
644d87b30a MFi386 1.222: Remove vm_map_growstack() and acquisition and release of Giant
around vm_fault().
2002-04-27 09:34:15 +00:00
Marcel Moolenaar
d297ad160e Don't use the symbol name to lookup the symbol value when we can use
the symbol index defined by the relocation. The elf_lookup() support
function is to be used by elf_reloc() when symbol lookups need to be
done. The elf_lookup() function operates on the symbol index and
will do a symbol name based lookup when such is required, otherwise
it uses the symbol index directly. This solves the problem seen on
ia64 where the symbol hash table does not contain local symbols and
a symbol name based lookup would fail for those symbols.

Don't pass the symbol name to elf_reloc(), as it isn't used any more.
2002-04-25 01:22:16 +00:00
Robert Watson
91e007dc70 Since WITNESS doesn't just do mutexes, remove "mutex" from the WITNESS
comment in GENERIC config files of appropriate platforms.  For whatever
reason, powerpc didn't use WITNESS in GENERIC.
2002-04-18 03:44:44 +00:00
Bernd Walter
b5b4067771 Fix a compiler warning I missed in the last commit.
Reviewed by:	gallatin
Approved by:	gallatin
2002-04-17 15:32:11 +00:00
Bernd Walter
27c5b6c8f1 Revive dec_axppci_33_intr_route for LCA.
We now get valid interrupt lines for devices on secondary pci busses.

Reviewed by:	gallatin
Approved by:	gallatin
2002-04-17 14:08:22 +00:00
Bernd Walter
dd516e0773 Clear the error flags in the LCA_IOC_STAT0 register after
machine_checks.
This fixes pci config reads for non existing devices on secondary
pci busses.

Thanks to Andrew Gallatin for pointing me to the register

Reviewed by:	gallatin
Approved by:	gallatin
2002-04-17 13:57:50 +00:00
Maxime Henrion
d786139c76 Rework the kernel environment subsystem. We now convert the static
environment needed at boot time to a dynamic subsystem when VM is
up.  The dynamic kernel environment is protected by an sx lock.

This adds some new functions to manipulate the kernel environment :
freeenv(), setenv(), unsetenv() and testenv().  freeenv() has to be
called after every getenv() when you have finished using the string.
testenv() only tests if an environment variable is present, and
doesn't require a freeenv() call. setenv() and unsetenv() are self
explanatory.

The kenv(2) syscall exports these new functionalities to userland,
mainly for kenv(1).

Reviewed by:	peter
2002-04-17 13:06:36 +00:00
David E. O'Brien
200e654a4a I am not sure why ## was used in this macro, as w/o the string concatenation
the tokens are legal ANSI-C.  Maybe to enable 'op' to be a macro itself?
Anyway, with the ## concatenation Gcc 3.1's integrated `cpp' treats "=op("
as a single token vs. the three tokens it is.
2002-04-17 04:31:43 +00:00
Alan Cox
edbecb0cf5 Remove code that updates vm->vm_ssize. This duplicates work already
performed by vm_map_growstack().
2002-04-16 05:56:01 +00:00
David E. O'Brien
3f52464b1c Remove the .stab directives. I do not understand what is different about
Gcc 3.1's 'cpp' vs. 2.95.3's.  Maybe it is due to other code movement and
it just shows up weirdly in handling the .stab's.  Anyway, w/o this change
building a kernel gives:

    alpha/alpha/pal.s:75: relocation truncated to fit: REFLONG .text
    alpha/alpha/prom_disp.s:67: relocation truncated to fit: REFLONG .text
2002-04-15 21:44:19 +00:00
Peter Wemm
c58d96bb2f Fix an "oops!" that turned out to be mostly harmless (but gave a warning).
I did this right on the sparc64.  Store the direct mapped addresses in
the correct variables.

Submitted by:	jake
2002-04-15 16:07:52 +00:00
Peter Wemm
1a87a0da66 Pass vm_page_t instead of physical addresses to pmap_zero_page[_area]()
and pmap_copy_page().  This gets rid of a couple more physical addresses
in upper layers, with the eventual aim of supporting PAE and dealing with
the physical addressing mostly within pmap.  (We will need either 64 bit
physical addresses or page indexes, possibly both depending on the
circumstances.  Leaving this to pmap itself gives more flexibilitly.)

Reviewed by:	jake
Tested on:	i386, ia64 and (I believe) sparc64. (my alpha was hosed)
2002-04-15 16:00:03 +00:00
David E. O'Brien
76dcc6cba9 Modernize SCM ID. 2002-04-14 07:07:09 +00:00
Alan Cox
b7c8cbabf9 Add comment that sigreturn() is MPSAFE. 2002-04-13 23:37:10 +00:00
John Baldwin
094a945562 Rework logic of syscalls that modify process credentials as described in
rev 1.152 of sys/kern/kern_prot.c.
2002-04-13 23:11:23 +00:00
David E. O'Brien
0301e9c83b Turn on TGA support.
Submitted by:	Andrew M. Miklic <AndrwMklc@cs.com>
2002-04-13 22:34:16 +00:00
David E. O'Brien
a68bbb481b Quiet GCC 3.1 warning. 2002-04-13 22:21:28 +00:00
Mike Barcroft
795aff0ed9 Include <sys/cdefs.h> for definition of __BSD_VISIBLE.
Pointy hat to:	mike
2002-04-12 15:56:45 +00:00
Alan Cox
0d36f49e63 Add a comment that osigreturn() is MPSAFE. 2002-04-11 17:13:08 +00:00
Bernd Walter
0dc76ffdd4 LCA based systems can't handle more than 16 devices on pci bus 0.
Reviewed by:	gallatin
Approved by:	gallatin
2002-04-11 13:24:20 +00:00
Mike Barcroft
49285705cc Remove the hack for segsz_t from <sys/types.h>; use the normal
_BSD_FOO_T_ method for defining segsz_t.
2002-04-10 15:58:13 +00:00
Mike Barcroft
7f0f1cfd57 Add manifest constants: _LITTLE_ENDIAN, _BIG_ENDIAN, _PDP_ENDIAN, and
_BYTE_ORDER.  These are far more useful than their non-underscored
equivalents as these can be used in restricted namespace environments.
Mark the non-underscored variants as deprecated.
2002-04-10 14:39:14 +00:00
Poul-Henning Kamp
2ce7d7a033 GC various bits and pieces of USERCONFIG from all over the place. 2002-04-09 11:18:46 +00:00
Poul-Henning Kamp
67ec58a802 GC the "dumplo" variable, which is no longer used.
A lot of sys/*/*/machdep.c seems not to be.
2002-04-07 21:01:37 +00:00
Alan Cox
aa4d062142 o Eliminate the use of grow_stack() and useracc() from sendsig(), osendsig(),
and osf1_sendsig().
 o Eliminate the prototype for the MD grow_stack() now that it has been removed
   from all platforms.
2002-04-05 00:52:15 +00:00
Eric Melville
1bbfb90c3c Spell "privileges" correctly. 2002-04-05 00:08:38 +00:00
John Baldwin
6008862bc2 Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on:	i386, alpha, sparc64
2002-04-04 21:03:38 +00:00
Bruce Evans
79065dba2a Moved signal handling and rescheduling from userret() to ast() so that
they aren't in the usual path of execution for syscalls and traps.
The main complication for this is that we have to set flags to control
ast() everywhere that changes the signal mask.

Avoid locking in userret() in most of the remaining cases.

Submitted by:	luoqi (first part only, long ago, reorganized by me)
Reminded by:	dillon
2002-04-04 17:49:48 +00:00
Ruslan Ermilov
12c79eb288 Dike out a highly insecure UCONSOLE option.
TIOCCONS must be able to VOP_ACCESS() /dev/console to succeed.

Obtained from:	OpenBSD
2002-04-03 10:56:59 +00:00
John Baldwin
c53c013bae - Move the MI mutexes sched_lock and Giant from being declared in the
various machdep.c's to being declared in kern_mutex.c.
- Add a new function mutex_init() used to perform early initialization
  needed for mutexes such as setting up thread0's contested lock list
  and initializing MI mutexes.  Change the various MD startup routines
  to call this function instead of duplicating all the code themselves.

Tested on:	alpha, i386
2002-04-02 22:19:16 +00:00
Matthew Dillon
182da8209d Stage-2 commit of the critical*() code. This re-inlines cpu_critical_enter()
and cpu_critical_exit() and moves associated critical prototypes into their
own header file, <arch>/<arch>/critical.h, which is only included by the
three MI source files that need it.

Backout and re-apply improperly comitted syntactical cleanups made to files
that were still under active development.  Backout improperly comitted program
structure changes that moved localized declarations to the top of two
procedures.  Partially re-apply one of the program structure changes to
move 'mask' into an intermediate block rather then in three separate
sub-blocks to make the code more readable.  Re-integrate bug fixes that Jake
made to the sparc64 code.

Note: In general, developers should not gratuitously move declarations out
of sub-blocks.  They are where they are for reasons of structure, grouping,
readability, compiler-localizability, and to avoid developer-introduced bugs
similar to several found in recent years in the VFS and VM code.

Reviewed by:	jake
2002-04-01 23:51:23 +00:00
John Baldwin
44731cab3b Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API.  The entire API now consists of two functions
similar to the pre-KSE API.  The suser() function takes a thread pointer
as its only argument.  The td_ucred member of this thread must be valid
so the only valid thread pointers are curthread and a few kernel threads
such as thread0.  The suser_cred() function takes a pointer to a struct
ucred as its first argument and an integer flag as its second argument.
The flag is currently only used for the PRISON_ROOT flag.

Discussed on:	smp@
2002-04-01 21:31:13 +00:00
Poul-Henning Kamp
8d19a26558 Centralize the "bootdev" and "dumpdev" variables. They are still pretty
bogus all things considered, but at least now they don't camouflage as
being MD variables.
2002-03-31 07:15:28 +00:00
Wilko Bulte
7d8817d249 Make the comment section resemble English
MFC after:	2 days
2002-03-29 23:05:05 +00:00
Alan Cox
dceeb8c25c Use the MI vm_map_growstack() instead of the MD grow_stack() in trap(). 2002-03-29 18:55:07 +00:00
Jake Burkholder
d0ce9a7e07 Remove abuse of intr_disable/restore in MI code by moving the loop in ast()
back into the calling MD code.  The MD code must ensure no races between
checking the astpening flag and returning to usermode.

Submitted by:	peter (ia64 bits)
Tested on:	alpha (peter, jeff), i386, ia64 (peter), sparc64
2002-03-29 16:35:26 +00:00
David E. O'Brien
ae7c70d595 style(9)
Approved by:	jake
2002-03-28 02:54:44 +00:00
Wilko Bulte
30af5d1325 On 2nd thought, we can do without plip altogether 2002-03-27 21:10:38 +00:00
Jeff Roberson
f22a4b62f5 Add a new mtx_init option "MTX_DUPOK" which allows duplicate acquires of locks
with this flag.  Remove the dup_list and dup_ok code from subr_witness.  Now
we just check for the flag instead of doing string compares.

Also, switch the process lock, process group lock, and uma per cpu locks over
to this interface.  The original mechanism did not work well for uma because
per cpu lock names are unique to each zone.

Approved by:	jhb
2002-03-27 09:23:41 +00:00
Matthew Dillon
d74ac6819b Compromise for critical*()/cpu_critical*() recommit. Cleanup the interrupt
disablement assumptions in kern_fork.c by adding another API call,
cpu_critical_fork_exit().  Cleanup the td_savecrit field by moving it
from MI to MD.  Temporarily move cpu_critical*() from <arch>/include/cpufunc.h
to <arch>/<arch>/critical.c (stage-2 will clean this up).

Implement interrupt deferral for i386 that allows interrupts to remain
enabled inside critical sections.  This also fixes an IPI interlock bug,
and requires uses of icu_lock to be enclosed in a true interrupt disablement.

This is the stage-1 commit.  Stage-2 will occur after stage-1 has stabilized,
and will move cpu_critical*() into its own header file(s) + other things.
This commit may break non-i386 architectures in trivial ways.  This should
be temporary.

Reviewed by:	core
Approved by:	core
2002-03-27 05:39:23 +00:00
Doug Rabson
71d645d0a2 Initialise the AS4100 console at the same time as most of the other
platform types instead of deferring it until the mcpcia devices are
probed. This allows the use of e.g. kgdb before the busses are probed.
2002-03-26 19:46:40 +00:00
Wilko Bulte
e38bec6c63 plip has produced an error during attach on Alpha as long as I care
to remember. Nobody in the right sense of their mind would run IP on
the parallel port on Alpha so comment this one out.
2002-03-24 14:35:20 +00:00
David E. O'Brien
c543d983fa Guard against redefining __gnuc_va_list. 2002-03-24 11:25:46 +00:00
David E. O'Brien
439a4003ab ASM versions of __FBSDID. 2002-03-23 02:01:27 +00:00
Andrew Gallatin
60c406ad95 only read from the possibly bad address if we did not get a machine
check.  I don't know how this went unnoticed for so long.

obtained from: NetBSD
MFC after: 7 days
2002-03-22 15:55:56 +00:00
Andrew Gallatin
496ffc90e4 Allow SMP kernels (like GENERIC..) to boot on UP kernels on the alpha.
Pointy hat to: jeff
2002-03-22 15:54:31 +00:00
Andrew Gallatin
ddf23aa842 shut up the compiler 2002-03-21 18:48:00 +00:00
Warner Losh
b70c0e8b00 Fix abuses of cpu_critical_{enter,exit} by converting to
intr_{disable,restore} as well as providing an implemenation of
intr_{disable,restore}.
2002-03-21 06:14:58 +00:00
John Baldwin
f25fcd64b8 Change the way we ensure td_ucred is NULL if DIAGNOSTIC is defined.
Instead of caching the ucred reference, just go ahead and eat the
decerement and increment of the refcount.  Now that Giant is pushed down
into crfree(), we no longer have to get Giant in the common case.  In the
case when we are actually free'ing the ucred, we would normally free it on
the next kernel entry, so the cost there is not new, just in a different
place.  This also removse td_cache_ucred from struct thread.  This is
still only done #ifdef DIAGNOSTIC.

Tested on:	i386, alpha
2002-03-20 21:09:09 +00:00
David E. O'Brien
d0ce7d0078 Remove __P(). This was tested on the GENERIC kernel. 2002-03-20 18:58:47 +00:00
Jeff Roberson
851031501a Remove references to vm_zone.h and switch over to the new uma API. 2002-03-20 10:35:22 +00:00
Jeff Roberson
c186f9b280 Remove unused header. 2002-03-20 09:46:04 +00:00
Jeff Roberson
df66668c42 Force the boot cpu to wait for the APs to finish starting up. This eliminates
a race where the AP and the boot cpu were trying to printf at the same time,
which was confusing the console too much for it to continue working.
2002-03-20 02:27:55 +00:00
Jeff Roberson
8355f576a9 This is the first part of the new kernel memory allocator. This replaces
malloc(9) and vm_zone with a slab like allocator.

Reviewed by:	arch@
2002-03-19 09:11:49 +00:00
Dag-Erling Smørgrav
a2e0658045 Move the definition of PT_[GS]ET{,DB,FP}REGS from the MD ptrace.h to the
MI ptrace.h, since all platforms define them.  Keep the MD ptrace.h around
for FIX_SSTEP (which is currently only needed on Alpha).
2002-03-16 00:25:53 +00:00
Dag-Erling Smørgrav
830c02d426 Remove a bogus cast and deconstification that broke the Alpha kernel build. 2002-03-13 19:16:41 +00:00
Dag-Erling Smørgrav
979f47f40d Back out previous commit, it was the wrong patch! 2002-03-13 19:13:41 +00:00
Dag-Erling Smørgrav
51238e752e Remove a bogus cast that breaks the Alpha kernel build due to -Werror. 2002-03-13 19:12:31 +00:00
John Baldwin
bb7d54e8c7 Fix a misspelling of mine: s/optomization/optimization/.
Noticed by:	bmilekic
2002-03-11 19:58:53 +00:00
John Baldwin
ee1b1a6549 Grrr, turn preemption back off on the alpha again. It is still not stable.
Noticed by:	wilko, mjacob, jhb, peter, and others
2002-03-11 19:35:10 +00:00
Mike Barcroft
d846855da8 o Don't require long long support in bswap64() functions.
o In i386's <machine/endian.h>, macros have some advantages over
  inlines, so change some inlines to macros.
o In i386's <machine/endian.h>, ungarbage collect word_swap_int()
  (previously __uint16_swap_uint32), it has some uses on i386's with
  PDP endianness.

Submitted by:	bde

o Move a comment up in <machine/endian.h> that was accidentially moved
  down a few revisions ago.
o Reenable userland's use of optimized inline-asm versions of
  byteorder(3) functions.
o Fix ordering of prototypes vs. redefinition of byteorder(3)
  functions, so that the non-GCC (libc asm) case has proper
  prototypes.
o Add proper prototypes for byteorder(3) functions in <sys/param.h>.
o Prevent redundant duplicate prototypes by making use of the
  _BYTEORDER_PROTOTYPED define.
o Move the bswap16(), bswap32(), bswap64() C functions into MD space
  for platforms in which asm versions don't exist.  This significantly
  reduces the complexity of some things at the cost of duplicate code.

Reviewed by:	bde
2002-03-09 21:02:16 +00:00
Jake Burkholder
752dff3d9c Add needed includes of machine/smp.h, remove nested include in sys/smp.h
so that inlines in machine/smp.h can use variables declared in sys/smp.h.
2002-03-07 04:43:51 +00:00
Jeff Roberson
88c99cfbc8 Add a new variable mp_maxid. This is used so that per cpu datastructures may
be allocated as arrays indexed by the cpu id.  Previously the only reliable
way to know the max cpu id was through MAXCPU. mp_ncpus isn't useful here
because cpu ids may be sparsely mapped, although x86 and alpha do not do this.

Also, call cpu_mp_probe much earlier so the max cpu id is known before the VM
starts up.  This is intended to help support per cpu queues for the new
allocator, but may be useful elsewhere.

Reviewed by:	jake
Approved by:	jake
2002-03-05 10:01:46 +00:00
Matt Jacob
b96eda156f Make it compile again. 2002-03-01 23:15:45 +00:00
Matt Jacob
8f22da0d0b Fix mcpcia.c so it compiles again. 2002-03-01 23:10:19 +00:00
Andrew R. Reiter
66c862bc1b - Move a comment from being on the same line as a #ifdef to the line
following it.  This should have gone in the previous commit, but
  misviewed Bruce's patch.

Requested by: bde
2002-02-28 21:52:08 +00:00
Andrew Gallatin
ac278dcfc0 add inlines for bswap*.
smaller versions of the byteswap routines were obtained from NetBSD
2002-02-28 18:21:51 +00:00
Andrew Gallatin
030cb46918 recover from namespace collision caused by un-static'ing pci_alloc_resource()
in rev  1.187 of sys/dev/pci/pci.c
2002-02-28 18:18:41 +00:00
Andrew R. Reiter
216ae18217 - Fix panic() message and a couple style nits that snuck in from the
recent diagnostics commit (rev. 1.84).
2002-02-28 08:28:14 +00:00
Mike Silbersack
f4e18c9afd Fix a minor swap leak.
Previously, the UPAGES/KSTACK area of processes/threads would leak memory
at the time that a previously swapped process was terminated.  Lukcily, the
leak was only 12K/proc, so it was unlikely to be a major problem unless you
had an undersized swap partition.

Submitted by:	dillon
Reviewed by:	silby
MFC after:	1 week
2002-02-28 07:41:12 +00:00
John Baldwin
a854ed9893 Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.
2002-02-27 18:32:23 +00:00
Mike Silbersack
7f3a40933b Fix a horribly suboptimal algorithm in the vm_daemon.
In order to determine what to page out, the vm_daemon checks
reference bits on all pages belonging to all processes.  Unfortunately,
the algorithm used reacted badly with shared pages; each shared page
would be checked once per process sharing it; this caused an O(N^2)
growth of tlb invalidations.  The algorithm has been changed so that
each page will be checked only 16 times.

Prior to this change, a fork/sleepbomb of 1300 processes could cause
the vm_daemon to take over 60 seconds to complete, effectively
freezing the system for that time period.  With this change
in place, the vm_daemon completes in less than a second.  Any system
with hundreds of processes sharing pages should benefit from this change.

Note that the vm_daemon is only run when the system is under extreme
memory pressure.  It is likely that many people with loaded systems saw
no symptoms of this problem until they reached the point where swapping
began.

Special thanks go to dillon, peter, and Chuck Cranor, who helped me
get up to speed with vm internals.

PR:		33542, 20393
Reviewed by:	dillon
MFC after:	1 week
2002-02-27 18:03:02 +00:00
Thomas Moestl
90ce56c287 Add the following functions/macros to support byte order conversions and
device drivers for bus system with other endinesses than the CPU (using
interfaces compatible to NetBSD):

- bwap16() and bswap32(). These have optimized implementations on some
  architectures; for those that don't, there exist generic implementations.
- macros to convert from a certain byte order to host byte order and vice
  versa, using a naming scheme like le16toh(), htole16().
  These are implemented using the bswap functions.
- stream bus space access functions, which do not perform a byte order
  conversion (while the normal access functions would if the bus endianess
  differs from the CPU endianess).

htons(), htonl(), ntohs() and ntohl() are implemented using the new
functions above for kernel usage. None of the above interfaces is currently
exported to user land.

Make use of the new functions in a few places where local implementations
of the same functionality existed.

Reviewed by:	mike, bde
Tested on alpha by:	mike
2002-02-27 17:16:18 +00:00
Julian Elischer
77c4066424 Add some DIAGNOSTIC code.
While in userland, keep the thread's ucred reference in a shadow
field so that the usual place to store it is NULL.
If DIAGNOSTIC is not set, the thread ucred is kept valid until the next
kernel entry, at which time it is checked against the process cred
and possibly corrected. Produces a BIG speedup in
kernels with INVARIANTS set. (A previous commit corrected it
for the non INVARIANTS case already)

Reviewed by:	dillon@freebsd.org
2002-02-22 23:58:22 +00:00
Poul-Henning Kamp
1cbb9c3b03 Convert p->p_runtime and PCPU(switchtime) to bintime format. 2002-02-22 13:32:01 +00:00
Andrew Gallatin
7cacd13117 recovery from new binutils part II: fix the alpha kernel so that
it handles R_ALPHA_RELATIVE relocs with addends properly.

tested by: ticso
2002-02-21 23:34:09 +00:00
Andrew Gallatin
35a86b35c1 MFi386: merge changes from i386/trap.c rev 1.212
If the credential on an incoming thread is correct, don't bother
reaquiring it. In the same vein, don't bother dropping the thread cred
when going to userland. We are guaranteed to need it when we come back,
(which we are guaranteed to do).
2002-02-19 03:13:39 +00:00
Mike Barcroft
fd8e4ebc8c o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
  source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
  Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
  POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
  and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
  complexities associated with having MD (asm and inline) versions, and
  having to prevent exposure of these functions in other headers that
  happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
  third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on:	alpha, i386
Reviewed by:	bde, jake, tmm
2002-02-18 20:35:27 +00:00
Daniel Eischen
0270d57aef Use struct __ucontext in prototypes and associated functions instead of
ucontext_t.  Forward declare struct __ucontext in <sys/signal.h> and
remove reliance on <sys/ucontext.h> being included.

While I'm here, also hide osigcontext types from userland; suggested
by bde.

Namespace pollution noticed by: Kevin Day <toasty@shell.dragondata.com>
2002-02-17 17:40:34 +00:00
Garrett Wollman
3b7a4c4b1d Resurrect one of the easiest changes from my big include files roll-up
patch from a year ago: give file flags their own type.  This does not
(yet) change the type used by system calls or library functions.
The underlying type was chosen to match what is returned by stat().
2002-02-15 22:15:39 +00:00
Robert Watson
92b98fdabe Remove WITNESS from GENERIC by default: as we grow more locks, this gets
slower, and may be impeding adoption of -CURRENT by developers.  We
recommend turning on WITNESS by default on crash boxes, and when doing
locking development.  It will probably get turned on by default for a week
or two following any major locking commits, also.

Approved by:	all and sundry (jhb, phk, ...)
2002-02-13 07:44:59 +00:00
John Baldwin
2deac418f3 Don't grab the ICU lock while reading the current pending interrupts and
current masked interrupts from the AT PIC.

Requested by:	bde
2002-02-08 18:30:36 +00:00
John Baldwin
6c2b6a945d Turn SMP back on by default in GENERIC on the Alpha. 2002-02-08 18:25:07 +00:00
John Baldwin
0730d79121 Turn interrupt thread preemption back on on the alpha.
Tested by:	mjacob
2002-02-08 18:23:46 +00:00
Peter Wemm
fe0d0493ac Bah, I managed to turn cosmetic things into real bugs. Fix shadowed
variable declarations. :-(  Definately not my day today.
2002-02-08 08:56:01 +00:00
Peter Wemm
588e970c0b Fix a long line introduced in previous commit. 2002-02-07 22:29:41 +00:00
Peter Wemm
3953037ff8 Fix long line added in previous commit. 2002-02-07 22:28:24 +00:00
Peter Wemm
6e948886d3 Patch up some long lines introduced in previous commit. 2002-02-07 22:26:51 +00:00
Peter Wemm
2850a06d42 Fix style bug introduced in previous commit. 2002-02-07 22:26:07 +00:00
Matt Jacob
943e9b67f5 You cannot take the address of a variable with the 'register' qualifier.
MFC after:	1 day
2002-02-07 22:06:23 +00:00
Julian Elischer
079b7badea Pre-KSE/M3 commit.
this is a low-functionality change that changes the kernel to access the main
thread of a process via the linked list of threads rather than
assuming that it is embedded in the process. It IS still embeded there
but remove all teh code that assumes that in preparation for the next commit
which will actually move it out.

Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
2002-02-07 20:58:47 +00:00
Poul-Henning Kamp
e0ee6f5629 GC the PC_SWITCH* symbols which are not used in assembly anymore. 2002-02-07 10:27:58 +00:00
Matt Jacob
2a62c7174a Replace the MFREE that Marshal (Quick Draw) Dillon apparently didn't look for.
MFC after:	1 day
2002-02-07 08:39:26 +00:00
John Baldwin
78a1485fd1 Fixes for alpha pmap on SMP machines:
- Create a private list of active pmaps rather than abusing the list of all
  processes when we need to look up pmaps.  The process list needs a sx lock
  and we can't be getting sx locks in the middle of cpu_switch()
  (pmap_activate() can call pmap_get_asn() from cpu_switch()).  Instead, we
  protect the list with a spinlock.  This also means the list is shorter
  since a pmap can be used by more than one process and we could (at least
  in thoery) dink with pmap's more than once, but now we only touch each
  pmap once when we have to update all of them.
- Wrap pmap_activate()'s code to get a new ASN in an explicit critical section
  so that when it is called while doing an exec() we can't get preempted.
- Replace splhigh() in pmap_growkernel() with a critical section to prevent
  preemption while we are adjusting the kernel page tables.
- Fixes abuse of PCPU_GET(), which doesn't return an L-value.
- Also adds some slight cleanups to the ASN handling by adding some macros
  instead of magic numbers in relation to the ASN and ASN generations.

Reviewed by:	dfr
2002-02-06 04:30:26 +00:00
Bruce Evans
5c8d0a85b0 Improve the change in the previous commit: use a stub for osigreturn()
when it is not really used instead of unconditionalizing all of it.
2002-02-03 04:09:02 +00:00
Bruce Evans
55a9536b65 Compile osigreturn() unconditionally since it will always be needed on
some arches and the syscall table is machine-independent.  It was
(bogusly) conditional on COMPAT_43, so this usually makes no difference.

ia64: in addition:
- replace the bogus cloned comment before osigreturn() by a correct one.
  osigreturn() is just a stub fo ia64's.
- fix the formatting of cloned comment before sigreturn().
- fix the return code.  use nosys() instead of returning ENOSYS to get
  the same semantics as if the syscall is not in the syscall table.
  Generating SIGSYS is actually correct here.
- fix style bugs.

powerpc: copy the cleaned up ia64 stub.  This mainly fixes a bogus comment.

sparc64: copy the cleaned up the ia64 stub, since there was no stub before.
2002-02-01 15:44:03 +00:00
Andrew Gallatin
ae967e6461 Regenerated file from previous commit to syscalls.master 2002-01-23 22:47:47 +00:00
Andrew Gallatin
21e06996e4 Linux/alpha uses the same BSDish return mechanism we do for
getpid, getuid, getgid and pipe, since they bootstrapped from
OSF/1 and never cleaned up.  Switch to the native syscalls
on alpha so that the above functions work

MFC after: 7 days
2002-01-23 22:46:14 +00:00
Andrew Gallatin
500c14f6af Don't read the sigcontext pointer directly from userspace. If the process
is swapped out, this can cause a system panic.  Copy it in, instead

tested by: Bernd Walter <ticso@cicely8.cicely.de>
2002-01-22 02:40:39 +00:00
Peter Wemm
58815d1196 Avoid __func__ string concatenation 2002-01-18 04:41:23 +00:00
Matt Jacob
d5befad6dd Allow alpha kernels to compile again- make sure opt_ddb.h is included
and the reference to db_regs is *extern* from alpha/include/db_machdep.h
(put it in alpha/alpha/machdep.c)- this avoids the problems we've had
about different 'common' sizes prohibiting the kernel from linking.
2002-01-17 02:16:35 +00:00
John Baldwin
6a29486b53 - Catch up printtrap() to KSE by using curthread and testing it against
NULL rather than curproc.  Without this, if we trap early before
  curthread is set, we recursively panic.
- In an SMP kernel, if we trap before curthread is set, then trap is going
  to recursively panic trying to bump td->td_md.md_kernnest.  The trap is
  fatal anyways, so to make debugging easier just call printtrap() to
  dump the trap info to the console and then halt.
2002-01-15 14:17:07 +00:00
Alfred Perlstein
a4db49537b Replace ffind_* with fget calls.
Make fget MPsafe.

Make fgetvp and fgetsock use the fget subsystem to reduce code bloat.

Push giant down in fpathconf().
2002-01-14 00:13:45 +00:00
Alfred Perlstein
426da3bcfb SMP Lock struct file, filedesc and the global file list.
Seigo Tanimura (tanimura) posted the initial delta.

I've polished it quite a bit reducing the need for locking and
adapting it for KSE.

Locks:

1 mutex in each filedesc
   protects all the fields.
   protects "struct file" initialization, while a struct file
     is being changed from &badfileops -> &pipeops or something
     the filedesc should be locked.

1 mutex in each struct file
   protects the refcount fields.
   doesn't protect anything else.
   the flags used for garbage collection have been moved to
     f_gcflag which was the FILLER short, this doesn't need
     locking because the garbage collection is a single threaded
     container.
  could likely be made to use a pool mutex.

1 sx lock for the global filelist.

struct file *	fhold(struct file *fp);
        /* increments reference count on a file */

struct file *	fhold_locked(struct file *fp);
        /* like fhold but expects file to locked */

struct file *	ffind_hold(struct thread *, int fd);
        /* finds the struct file in thread, adds one reference and
                returns it unlocked */

struct file *	ffind_lock(struct thread *, int fd);
        /* ffind_hold, but returns file locked */

I still have to smp-safe the fget cruft, I'll get to that asap.
2002-01-13 11:58:06 +00:00
John Baldwin
e60c44e873 Add missing prototype for pmap_unmapdev(). 2002-01-11 09:41:03 +00:00
Daniel Eischen
8ec12ea9ce Use a spare slot in the machine context to identify the context format
and to inherently verify its validity.  Alpha signal frames and trap
frames are different; this field identifies which format the context
is

Set the machine context format (signal frame) before copying it out
when sending a signal.

Approved by:	-arch
2002-01-10 02:36:30 +00:00
Peter Wemm
ead8168ac0 Convert a bunch of 1 << PCPU_GET(cpuid) to PCPU_GET(cpumask). 2002-01-05 09:41:37 +00:00
John Baldwin
c86b6ff551 Change the preemption code for software interrupt thread schedules and
mutex releases to not require flags for the cases when preemption is
not allowed:

The purpose of the MTX_NOSWITCH and SWI_NOSWITCH flags is to prevent
switching to a higher priority thread on mutex releease and swi schedule,
respectively when that switch is not safe.  Now that the critical section
API maintains a per-thread nesting count, the kernel can easily check
whether or not it should switch without relying on flags from the
programmer.  This fixes a few bugs in that all current callers of
swi_sched() used SWI_NOSWITCH, when in fact, only the ones called from
fast interrupt handlers and the swi_sched of softclock needed this flag.
Note that to ensure that swi_sched()'s in clock and fast interrupt
handlers do not switch, these handlers have to be explicitly wrapped
in critical_enter/exit pairs.  Presently, just wrapping the handlers is
sufficient, but in the future with the fully preemptive kernel, the
interrupt must be EOI'd before critical_exit() is called.  (critical_exit()
can switch due to a deferred preemption in a fully preemptive kernel.)

I've tested the changes to the interrupt code on i386 and alpha.  I have
not tested ia64, but the interrupt code is almost identical to the alpha
code, so I expect it will work fine.  PowerPC and ARM do not yet have
interrupt code in the tree so they shouldn't be broken.  Sparc64 is
broken, but that's been ok'd by jake and tmm who will be fixing the
interrupt code for sparc64 shortly.

Reviewed by:	peter
Tested on:	i386, alpha
2002-01-05 08:47:13 +00:00
Dag-Erling Smørgrav
36bf75f010 This file does not need to include procfs.h. This fixes a bunch of warnings. 2002-01-01 14:46:57 +00:00
Thomas Moestl
01f1aed259 Use the new resource_list_print_type() function.
Pass the bus device to isa_init() (this is needed for the sparc64
version).
2001-12-21 21:54:56 +00:00
John Baldwin
98f9879242 Introduce a standard name for the lock protecting an interrupt controller
and it's associated state variables: icu_lock with the name "icu".  This
renames the imen_mtx for x86 SMP, but also uses the lock to protect
access to the 8259 PIC on x86 UP.  This also adds an appropriate lock to
the various Alpha chipsets which fixes problems with Alpha SMP machines
dropping interrupts with an SMP kernel.
2001-12-20 23:48:31 +00:00
Peter Wemm
3c2a5d7e30 Fix typo. s/pa/va/. *blush* 2001-12-20 22:47:20 +00:00
Peter Wemm
ff5a52e18e Replace a bunch of:
for (pv = TAILQ_FIRST(&m->md.pv_list);
               pv;
               pv = TAILQ_NEXT(pv, pv_list)) {
with:
      TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) {
2001-12-20 05:29:59 +00:00
Peter Wemm
b50e204300 Fix some whitespace nits, converge with other pmap.c's 2001-12-20 03:44:43 +00:00
John Baldwin
acec0a5867 Merge part of revision 1.18 of sys/i386/linux/linux_machdep.c: don't use
RFTHREAD in linux_clone().
2001-12-18 18:50:02 +00:00
John Baldwin
1857e7825f Whitespace fix. 2001-12-18 18:03:48 +00:00
John Baldwin
7e1f6dfe9d Modify the critical section API as follows:
- The MD functions critical_enter/exit are renamed to start with a cpu_
  prefix.
- MI wrapper functions critical_enter/exit maintain a per-thread nesting
  count and a per-thread critical section saved state set when entering
  a critical section while at nesting level 0 and restored when exiting
  to nesting level 0.  This moves the saved state out of spin mutexes so
  that interlocking spin mutexes works properly.
- Most low-level MD code that used critical_enter/exit now use
  cpu_critical_enter/exit.  MI code such as device drivers and spin
  mutexes use the MI wrappers.  Note that since the MI wrappers store
  the state in the current thread, they do not have any return values or
  arguments.
- mtx_intr_enable() is replaced with a constant CRITICAL_FORK which is
  assigned to curthread->td_savecrit during fork_exit().

Tested on:	i386, alpha
2001-12-18 00:27:18 +00:00
John Baldwin
1ecf0d56c8 Small cleanups to the SMP code:
- Axe inlvtlb_ok as it was completely redundant with smp_active.
- Remove references to non-existent variable and non-existent file
  in i386/include/smp.h.
- Don't perform initializations local to each CPU while holding the
  ap boot lock on i386 while an AP bootstraps itself.
- Reorganize the AP startup code some to unify the latter half of the
  functions to bring an AP up.  Eventually this might be broken out into
  a MI function in subr_smp.c.
2001-12-17 23:14:35 +00:00
Ian Dowse
1cb4661d56 Enable UFS_DIRHASH in the GENERIC kernel.
Suggested by:	silby
Reviewed by:	dillon
MFC after:	5 days
2001-12-14 16:27:11 +00:00
John Baldwin
0bbc882680 Overhaul the per-CPU support a bit:
- The MI portions of struct globaldata have been consolidated into a MI
  struct pcpu.  The MD per-CPU data are specified via a macro defined in
  machine/pcpu.h.  A macro was chosen over a struct mdpcpu so that the
  interface would be cleaner (PCPU_GET(my_md_field) vs.
  PCPU_GET(md.md_my_md_field)).
- All references to globaldata are changed to pcpu instead.  In a UP kernel,
  this data was stored as global variables which is where the original name
  came from.  In an SMP world this data is per-CPU and ideally private to each
  CPU outside of the context of debuggers.  This also included combining
  machine/globaldata.h and machine/globals.h into machine/pcpu.h.
- The pointer to the thread using the FPU on i386 was renamed from
  npxthread to fpcurthread to be identical with other architectures.
- Make the show pcpu ddb command MI with a MD callout to display MD
  fields.
- The globaldata_register() function was renamed to pcpu_init() and now
  init's MI fields of a struct pcpu in addition to registering it with
  the internal array and list.
- A pcpu_destroy() function was added to remove a struct pcpu from the
  internal array and list.

Tested on:	alpha, i386
Reviewed by:	peter, jake
2001-12-11 23:33:44 +00:00
David E. O'Brien
acdff873d8 style(9) 2001-12-09 19:12:07 +00:00
Matthew Dillon
66a11b9fb1 Allow maxusers to be specified as 0 in the kernel config, which will
cause the system to auto-size to between 32 and 512 depending on the
amount of memory.

MFC after:	1 week
2001-12-09 01:57:09 +00:00
Dag-Erling Smørgrav
4cdff317aa s/^options\t\t/options \t/ 2001-12-04 11:17:31 +00:00
Dag-Erling Smørgrav
3cdd7aa817 PROCFS requires PSEUDOFS. 2001-12-04 11:17:30 +00:00
Mike Barcroft
de2656d0ed o Stop abusing MD headers with non-MD types.
o Hide nonstandard functions and types in <netinet/in.h> when
  _POSIX_SOURCE is defined.
o Add some missing types (required by POSIX.1-200x) to <netinet/in.h>.
o Restore vendor ID from Rev 1.1 in <netinet/in.h> and make use of new
  __FBSDID() macro.
o Fix some miscellaneous issues in <arpa/inet.h>.
o Correct final argument for the inet_ntop() function (POSIX.1-200x).
o Get rid of the namespace pollution from <sys/types.h> in
  <arpa/inet.h>.

Reviewed by:		fenner
Partially submitted by:	bde
2001-12-01 03:43:01 +00:00
Andrew Gallatin
a58b29a603 fix DIAGNOSTIC panic caused by proc/thread typo
tested by: Martijn Pronk <martijn@smartie.xs4all.nl>
2001-11-29 15:33:46 +00:00
Jonathan Lemon
9497337452 The DEC kn300 has special code for console handling hardcoded here, so add
a call to promcndetach() to explicitly turn off the prom console.

Tested by: Jeff Roberson
2001-11-22 02:41:34 +00:00
Peter Wemm
0891c82c32 Cosmetic tweak to eliminate some diffs 2001-11-16 02:44:55 +00:00
Peter Wemm
ee0e75a4e0 Merge another missing part of i386/pmap.c rev 1.220. Dont blindly clear
the PG_BUSY flag without using the code that wakes up something else that
may be sleeping on it.
2001-11-16 02:41:31 +00:00
Peter Wemm
ab29f8765d Oops, I accidently merged a whitespace error from the original commit.
(whitespace at end of line in rev 1.264 pmap.c).  Fix them all.
2001-11-16 02:31:20 +00:00
Peter Wemm
303f52d500 Merge rev 1.264 from i386/pmap.c (tegge via alfred):
Protect against an infinite loop when prefaulting pages.  This can
happen when the vm system maps past the end of an object or tries
to map a zero length object, the pmap layer misses the fact that
offsets wrap into negative numbers and we get stuck.
2001-11-16 02:28:33 +00:00
Peter Wemm
88b5258822 Merge rev 1.202 from i386/pmap.c (back in 1998 by John Dyson):
Make flushing dirty pages work correctly on filesystems that
unexpectedly do not complete writes even with sync I/O requests.
This should help the behavior of mmaped files when using
softupdates (and perhaps in other circumstances also.)
2001-11-16 02:25:29 +00:00
Peter Wemm
79eb7b284f Merge rev 1.293 of i386/pmap.c - skip PG_UNMANAGED in pmap_collect() 2001-11-16 02:20:40 +00:00
Peter Wemm
8ad881324c Converge/fix some debug code (#if 0'ed on alpha, but whatever)
- use NPTEPG/NPDEPG instead of magic 1024 (important for PAE)
- use pt_entry_t instead of unsigned (important for PAE)
- use vm_offset_t instead of unsigned for va's (important for x86-64)
2001-11-16 02:17:18 +00:00
Peter Wemm
704be0159c Converge with i386/pmap.c - dont refer to curproc, use curthread. 2001-11-16 02:06:06 +00:00
Peter Wemm
4cd0f1ee99 Merge part of i386/pmap.c rev 1.220 that got missed in alpha/pmap.c
rev 1.10
2001-11-16 02:02:21 +00:00
Peter Wemm
024c3fd9d5 As part of a general cleanup and reconvergence of related pmap code,
start tidying up some loose ends.  The DEBUG_VA stuff has long since
passed its use-by date.  It wasn't used on ia64 but got cut/pasted there.
2001-11-16 01:56:34 +00:00
Poul-Henning Kamp
efd1585a7a Don't call cdevsw_add(). 2001-11-04 11:50:08 +00:00
Andrew Gallatin
cd4e23cead Introduce a boot environment variable (clock_compat_osf1) which can
be set to 1 to make FreeBSD and Tru64 coexist peacefully on a dual
boot system and not clobber each other's year in the TOY clock.
(Tru64 uses an offset 52 years higher than one would expect)

Obtained from: NetBSD
MFC After: 1 week
2001-11-03 17:22:50 +00:00
Poul-Henning Kamp
b8ea5f7f0f Remove unneeded and #if 0'ed code to register in cdevsw[] 2001-11-03 17:05:12 +00:00
Matthew Dillon
5d339e3d47 Implement i386/i386/pmap.c 1.292 for alpha, ia64 (avoid free
page exhaustion / kernel panic for certain madvise() scenarios)
2001-11-03 01:08:55 +00:00
Mike Barcroft
0ac2d551f2 o Add new header <sys/stdint.h>.
o Make <stdint.h> a symbolic link to <sys/stdint.h>.
o Move most of <sys/inttypes.h> into <sys/stdint.h>, as per C99.
o Remove <sys/inttypes.h>.
o Adjust includes in sys/types.h and boot/efi/include/ia64/efibind.h
  to reflect new location of integer types in <sys/stdint.h>.
o Remove previously symbolicly linked <inttypes.h>, instead create a
  new file.
o Add MD headers <machine/_inttypes.h> from NetBSD.
o Include <sys/stdint.h> in <inttypes.h>, as required by C99; and
  include <machine/_inttypes.h> in <inttypes.h>, to fill in the
  remaining requirements for <inttypes.h>.
o Add additional integer types in <machine/ansi.h> and
  <machine/limits.h> which are included via <sys/stdint.h>.

Partially obtain from:	NetBSD
Tested on:		alpha, i386
Discussed on:		freebsd-standards@bostonradio.org
Reviewed by:		bde, fenner, obrien, wollman
2001-11-02 18:05:43 +00:00
Mike Barcroft
23ab7d0fa2 Rather than just change the arguments to suser() change the function to
suser_xxx() as well.

Pointy hat to:	rwatson
2001-11-02 17:42:03 +00:00
Peter Wemm
97c97bb16b "Fix" a problem that got copied from alpha to ia64 and broke there.
When we truncate the msgbuf size because the last chunk is too small,
correctly terminate the phys_avail[] array - the VM system tests
the *end* for zero, not the start.  This leads the VM startup to
attempt to recreate a duplicate set of pages for all physical memory.

XXX the msgbuf handling is suspiciously different on i386 vs
alpha/ia64...
2001-11-02 00:41:00 +00:00
Robert Watson
309b8fb98a o Permit osf1-emulated programs to modify uid/gid under jail by
switching suser() to suser_xxx() and adding PRISON_ROOT flag.
2001-11-01 20:16:03 +00:00
Matt Jacob
f43f61207d Fix misspelling in comment. 2001-10-31 18:07:38 +00:00
Dag-Erling Smørgrav
a08d68de5b Eliminate the prefix parameter to linux_emul_find(), which was always
linux_emul_path anyway.  Linux_emul_find() has interesting bugs in its
prefix handling (which luckily are not currently exploitable); this
commit is preliminary to an attempt at cleaning it up.

Approved by:	marcel
2001-10-27 11:15:19 +00:00
Matthew Dillon
8d5c8e9f04 minor commenting based on syscall environment 2001-10-26 20:35:52 +00:00
Matt Jacob
831039f850 Detach the prom console when platform.cons_init is called. This seems
to avoid most of the double character kernel goop we've been having by having
both a prom console && a normal console.

Was not able to test with graphics head. Hope this doesn't break anything.

Reviewed by:	silence on alpha
2001-10-26 16:13:47 +00:00
John Baldwin
8e2e767b1f Add a per-thread ucred reference for syscalls and synchronous traps from
userland.  The per thread ucred reference is immutable and thus needs no
locks to be read.  However, until all the proc locking associated with
writes to p_ucred are completed, it is still not safe to use the per-thread
reference.

Tested on:	x86 (SMP), alpha, sparc64
2001-10-26 08:12:54 +00:00
Jonathan Lemon
553b79aa63 cn_tab no longer exists, use cnadd() to add a console device. Note that
this may result in duplicate console output in some cases.
2001-10-24 18:30:05 +00:00
Jonathan Lemon
b792b54c89 Remove call to cninit_finish(). 2001-10-24 17:42:01 +00:00
Mike Barcroft
3a72286480 Remove funky right justification.
Pointed out by:	bde
2001-10-23 00:42:15 +00:00
Dag-Erling Smørgrav
7c62990641 Move procfs_* from procfs_machdep.c into sys_process.c, and rename them to
proc_* in the process; procfs_machdep.c is no longer needed.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 23:57:24 +00:00
Dag-Erling Smørgrav
1f04261973 [partially forced commit due to pilot error in earlier commit attempt]
{set,fill}_{,fp,db}regs() fixup:

 - Add dummy {set,fill}_dbregs() on architectures that don't have them.

 - KSEfy the powerpc versions (struct proc -> struct thread).

 - Some architectures had the prototypes in md_var.h, some in reg.h, and
   some in both; for consistency, move them to reg.h on all platforms.

These functions aren't really MD (the implementation is MD, but the interface
is MI), so they should move to an MI header, but I haven't figured out which
one yet.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 22:16:48 +00:00
Dag-Erling Smørgrav
ef394d81ad {set,fill}_{,fp,db}regs() fixup:
- Add dummy {set,fill}_dbregs() on architectures that don't have them.

 - KSEfy the powerpc versions (struct proc -> struct thread).

 - Some architectures had the prototypes in md_var.h, some in reg.h, and
   some in both; for consistency, move them to reg.h on all platforms.

These functions aren't really MD (the implementation is MD, but the interface
is MI), so they should move to an MI header, but I haven't figured out which
{set,fill}_{,fp,db}regs() fixup:

 - Add dummy {set,fill}_dbregs() on architectures that don't have them.

 - KSEfy the powerpc versions (struct proc -> struct thread).

 - Some architectures had the prototypes in md_var.h, some in reg.h, and
   some in both; for consistency, move them to reg.h on all platforms.

These functions aren't really MD (the implementation is MD, but the interface
is MI), so they should move to an MI header, but I haven't figured out which
one yet.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 22:14:00 +00:00
Andrew Gallatin
e47b20bee2 - splhigh()/splx() -> critical_enter()/critical_exit()
- fix KV macro in t2_pci.c to include the sable_lynx_base variable
so that the T2 CSRs can be found on lynxes.   Current should be
bootable on lynxes now.
2001-10-20 21:05:14 +00:00
Matt Jacob
8c7c272c5a Remove wx. 2001-10-20 18:50:31 +00:00
Andrew Gallatin
dd79258102 apparently EV5 2x00s have their t2 CSRs where I'd expect to find
them on a  2100A

Thanks to Tyler Willingham <ze_willow@yahoo.com> for letting me
test this on his AS2000
2001-10-20 01:27:23 +00:00
David E. O'Brien
9f9bd82e15 Try two on the preprocessing logic.
Reviewed by:	ru
2001-10-19 20:01:01 +00:00
John Baldwin
e37d2a8c82 Remove unneeded sys/mutex.h includes. 2001-10-19 19:23:32 +00:00
John Baldwin
d6e19ad10e Move sys/mutex.h include after sys/lock.h to ensure we use the proper
versions of the mutex operations.
2001-10-19 19:22:04 +00:00
David E. O'Brien
4b16cf4f8a Blah, fix braino where ru had to remind me of proper preprocessor syntax.
Bad fingers, no cookie.
2001-10-19 19:17:11 +00:00
Marcel Moolenaar
5983000903 After removing the bogus differences, any real incompatibilities
have been merged into /sys/compat/linux/linux_ioctl.h. This file
is now unused.
2001-10-19 08:20:15 +00:00
David E. O'Brien
e3ddd70789 My attempts at minimizing the number of #def's got me in trouble. 2001-10-18 16:07:21 +00:00
David E. O'Brien
4a3391b5a1 Add support for "__gnuc_va_list". Some overly "smart" libraries assume
the existence of the __gnuc_va_list type[*] because our compiler is GCC.

[*] __gnuc_va_list is defined in the GCC ginclude/stdarg.h replacement
headerwhich we don't use.
2001-10-18 00:27:39 +00:00
David E. O'Brien
a3fc3de448 Sync comments with i386. 2001-10-18 00:00:31 +00:00