]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
21 years agoAdd a trailing '\n' character if none is found in the information
lioux [Mon, 26 May 2003 17:06:05 +0000 (17:06 +0000)]
Add a trailing '\n' character if none is found in the information
obtained from a package. Patch show_file() [1] and show_index() [2]
functions.

PR: 52097
Reviewed by: bento, kris,
portmgr, re,
Michael Nottebrock <michaelnottebrock@gmx.net>,
Martin Horcicka <horcicka@FreeBSD.cz>
Approved by: re (scottl)
Obtained from: NetBSD [1],
OpenBSD [2]
MFC after: 1 week

21 years agoFix two typos from the last commit
scottl [Mon, 26 May 2003 16:59:00 +0000 (16:59 +0000)]
Fix two typos from the last commit

21 years agoMerge the following from the English version:
rushani [Mon, 26 May 2003 15:32:34 +0000 (15:32 +0000)]
Merge the following from the English version:

1.12  -> 1.15 early-adopter/article.sgml
1.143 -> 1.155 hardware/common/dev.sgml
1.5   -> 1.6 hardware/common/intro.sgml
1.9   -> 1.11 hardware/i386/proc-i386.sgml
1.2   -> 1.3 hardware/ia64/article.sgml
1.3   -> 1.7 hardware/ia64/proc-ia64.sgml
1.6   -> 1.7 share/sgml/release.dsl

Approved by: re (blanket)

21 years agoDe-orbit bus_dmamem_alloc_size from here too.
scottl [Mon, 26 May 2003 14:38:48 +0000 (14:38 +0000)]
De-orbit bus_dmamem_alloc_size from here too.

Pointed out by: des
Pointy hat to: me

21 years agoRemember to close the read end of the pipe.
des [Mon, 26 May 2003 12:12:45 +0000 (12:12 +0000)]
Remember to close the read end of the pipe.

21 years agoRemove uninitialized local variable in favor of global.
mdodd [Mon, 26 May 2003 04:58:26 +0000 (04:58 +0000)]
Remove uninitialized local variable in favor of global.

PR:  bin/52685
Submitted by:  Alexander Nedotsukov <bland@mail.ru>
Approved by:  re (scottl)

21 years agoDe-orbit bus_dmamem_alloc_size(). It's a hack and was never used anyways.
scottl [Mon, 26 May 2003 04:00:52 +0000 (04:00 +0000)]
De-orbit bus_dmamem_alloc_size().  It's a hack and was never used anyways.
No need for it to pollute the 5.x API any further.

Approved by: re (bmah)

21 years agoDecouple the thread stack [de]allocating functions from the 'dead threads list'
mtm [Mon, 26 May 2003 00:37:07 +0000 (00:37 +0000)]
Decouple the thread stack [de]allocating functions from the 'dead threads list'
lock. It's not really necessary and we don't need the added complexity
or potential for deadlocks.

Approved by: re/blanket libthr

21 years agoRevise the unlock order in _pthread_join(). Also, if the joined
mtm [Mon, 26 May 2003 00:28:49 +0000 (00:28 +0000)]
Revise the unlock order in _pthread_join(). Also, if the joined
thread is not dead, the join loop is guaranteed to execute at least
once, so there is no need to pick up the thread list lock after
we return from suspenstion only to release it after the loop.

Approved by: re/blanket libthr

21 years agoReturn gracefully, rather than aborting, when the maximum concurrent
mtm [Sun, 25 May 2003 22:40:57 +0000 (22:40 +0000)]
Return gracefully, rather than aborting,  when the maximum concurrent
threads per process has been reached. Return EAGAIN, as per spec.

Approved by: re/blanket libthr

21 years agoCopy the va_list in sbuf_vprintf() before passing it to vsnprintf(),
peter [Sun, 25 May 2003 19:03:08 +0000 (19:03 +0000)]
Copy the va_list in sbuf_vprintf() before passing it to vsnprintf(),
because we could fail due to a small buffer and loop and rerun.  If this
happens, then the vsnprintf() will have already taken the arguments off
the va_list.  For i386 and others, this doesn't matter because the
va_list type is a passed as a copy.  But on powerpc and amd64, this is
fatal because the va_list is a reference to an external structure that
keeps the vararg state due to the more complicated argument passing system.
On amd64, arguments can be passed as follows:
First 6 int/pointer type arguments go in registers, the rest go on
  the memory stack.
Float and double are similar, except using SSE registers.
long double (80 bit precision) are similar except using the x87 stack.
Where the 'next argument' comes from depends on how many have been
processed so far and what type it is.  For amd64, gcc keeps this state
somewhere that is referenced by the va_list.

I found a description that showed the va_copy was required here:
http://mirrors.ccs.neu.edu/cgi-bin/unixhelp/man-cgi?va_end+9
The single unix spec doesn't mention va_copy() at all.

Anyway, the problem was that the sysctl kern.geom.conf* nodes would panic
due to walking off the end of the va_arg lists in vsnprintf.  A better fix
would be to have sbuf_vprintf() use a single pass and call kvprintf()
with a callback function that stored the results and grew the buffer
as needed.

Approved by: re (scottl)

21 years ago - Create a new lock, umtx_lock, for use instead of the proc lock for
jeff [Sun, 25 May 2003 18:18:32 +0000 (18:18 +0000)]
 - Create a new lock, umtx_lock, for use instead of the proc lock for
   protecting the umtx queues.  We can't use the proc lock because we need
   to hold the lock across calls to casuptr, which can fault.

Approved by: re

21 years agoDon't do silly thing if the disk_create() event gets canceled.
phk [Sun, 25 May 2003 16:57:10 +0000 (16:57 +0000)]
Don't do silly thing if the disk_create() event gets canceled.

Approved by: re/scottl

21 years ago - Reset the free ent to NULL if we have consumed the last free entry. This
jeff [Sun, 25 May 2003 08:48:42 +0000 (08:48 +0000)]
 - Reset the free ent to NULL if we have consumed the last free entry.  This
   fixes a problem where we would overwrite old data if we ran out of free
   entries.

Submitted by: sam
Approved by: re (scottl)

21 years ago_pthread_cancel() breaks the normal lock order of first locking the
mtm [Sun, 25 May 2003 08:48:11 +0000 (08:48 +0000)]
_pthread_cancel() breaks the normal lock order of first locking the
joined and then the joiner thread. There isn't an easy (sane?) way
to make it use the correct order without introducing races involving
the target thread and finding which (active or dead) list it is on. So,
after locking the canceled thread it will try to lock the joined thread
and if it fails release the first lock and try again from the top.

Introduce a new function, _spintrylock, which is simply a wrapper arround
umtx_trylock(), to help accomplish this.

Approved by: re/blanket libthr

21 years agoPart of the last patch.
mtm [Sun, 25 May 2003 08:35:37 +0000 (08:35 +0000)]
Part of the last patch.
Modify the thread creation and thread searching routine
to lock the thread lists with the new locks instead of GIANT_LOCK.

Approved by: re/blanket libthr

21 years agoStart locking up the active and dead threads lists. The active threads
mtm [Sun, 25 May 2003 08:31:33 +0000 (08:31 +0000)]
Start locking up the active and dead threads lists. The active threads
list is protected by a spinlock_t, but the dead list uses a pthread_mutex
because it is necessary to synchronize other threads with the garbage
collector thread. Lock/Unlock macros are used so it's easier to make
changes to the locks in the future.

The 'dead thread list' lock is intended to replace the gc mutex.
This doesn't have any practical ramifications. It simply makes it
clearer what the purpose of the lock is. The gc will use this lock,
instead of the gc mutex, to synchronize access to the dead list with
other threads.

Modify _pthread_exit() to use these two new locks instead of GIANT_LOCK,
and also to properly lock and protect thread state changes,
especially with respect to a joining thread.

The gc thread was also re-arranged to be more organized and less nested.

_pthread_join() was also modified to use the thread list locks. However,
locking and unlocking here needs special care because a thread could find
itself in a position where it's joining an exiting thread that is
waiting on the dead list lock, which this thread (joiner) holds. If the
joiner doesn't take care to lock *and* unlock in the same order they
(the joiner and the joinee) could deadlock against each other.

Approved by: re/blanket libthr

21 years agoThe libthr code makes use of higher-level primitives (pthread_mutex_t and
mtm [Sun, 25 May 2003 07:58:22 +0000 (07:58 +0000)]
The libthr code makes use of higher-level primitives (pthread_mutex_t and
pthread_cond_t) internaly in addition to the low-level spinlock_t. The
garbage collector mutex and condition variable are two such examples. This
might lead to critical sections nested within critical sections. Implement
a reference counting mechanism so that signals are masked only on the first
entry and unmasked on the last exit.

I'm not sure I like the idea of nested critical sections, but if
the library is going to use the pthread primitives it might be necessary.

Approved by: re/blanket libthr

21 years agoAdd a pretty cheesy hack to avoid a gcc-3.2.2 ICE (internal compiler
peter [Sun, 25 May 2003 07:39:06 +0000 (07:39 +0000)]
Add a pretty cheesy hack to avoid a gcc-3.2.2 ICE (internal compiler
error) on amd64 when doing pointer subtraction.  This bug is already
fixed in gcc-3.3 (waiting for after the branch), and the hack will be
backed out at the first opportunity.  This is in the ipv6 code path.

Approved by:  re (scottl)

21 years agoThe struct mcontext has changed. It's using the register sets. Bring
marcel [Sun, 25 May 2003 06:49:19 +0000 (06:49 +0000)]
The struct mcontext has changed. It's using the register sets. Bring
this in line.

21 years agoBeat vnode locking in the NFS server code into submission. This change
truckman [Sun, 25 May 2003 06:17:33 +0000 (06:17 +0000)]
Beat vnode locking in the NFS server code into submission.  This change
is not pretty, but it fixes the code so that it no longer violates the
vnode locking rules in the VFS API and doesn't trip any of the locking
assertions enabled by the DEBUG_VFS_LOCKS kernel configuration option.
There is one report that this patch fixed a "locking against myself"
panic on an NFS server that was tripped by a diskless client.

Approved by: re (scottl)

21 years agoAlways set the hardware parse bit in the IPCB structure when this
truckman [Sun, 25 May 2003 05:04:26 +0000 (05:04 +0000)]
Always set the hardware parse bit in the IPCB structure when this
structure, which is new to the 82550 and 82551, is used to transmit
a packet.  This appears to fix the packet truncation problem that was
observed when using 82550-based fxp cards to transmit ICMP or fragmented
UDP packets of certain lengths which only had one to three bytes in the
second and final mbuf of the packet.  This matches a note in the "Intel
8255x 10/100 Mbps Ethernet Controller Family Open Source Software Developer
Manual", which says that the hardware parse bit should be set when sending
these types of packets.

There have also been unconfirmed reports of similar problems when
transmitting TCP packets, which should not be affected by the above
mentioned change because the hardware parse bit was already being set
if the stack requested hardware checksumming of the packet.  If the
problem remains, the use of the IPCB structure can be disabled to
cause the driver to fall back to using the older 82559 interface with
82550-based cards by setting
        hint.fxp.UNIT_NUMBER.ipcbxmit_disable
to a non-zero value at boot time, or using kenv to set this variable
before using kldload to load the fxp driver.

Approved by: re (jhb)

21 years agoAdd textproc/opensp into $MINIMALDOCPORTS when openjade is used.
kuriyama [Sun, 25 May 2003 03:41:41 +0000 (03:41 +0000)]
Add textproc/opensp into $MINIMALDOCPORTS when openjade is used.

Reported by: scottl (by alpha building breakage)
Approved by: re (scottl)

21 years agoNow that we define user mode as any IP address that isn't in the
marcel [Sun, 25 May 2003 01:01:28 +0000 (01:01 +0000)]
Now that we define user mode as any IP address that isn't in the
kernel's VA regions, we cannot limit the use of break-based
syscalls to user mode only. The signal trampolines are in the
gateway page, which is mapped into the process address space in
region 5 and thus is kernel space.

We don't special case the gateway page here. Allow break-based
syscalls from anywhere in the kernel VA space.

Approved by: re@ (blanket)

21 years agoIgnore the 'must allocate below 1MB' flag for the TPL_BAR_REG. It is
imp [Sat, 24 May 2003 23:23:41 +0000 (23:23 +0000)]
Ignore the 'must allocate below 1MB' flag for the TPL_BAR_REG.  It is
set on realtek cards, but they work without it (and don't work with
it).  The standard seems to imply that this is just a hint anyway, so
this should be harmless.  It doesn't appear to be set on any other
cardbus cards that I have (or have seen).

This should make the rl based CardBus cards work again.  I've been
running it for about a month now.

Approved by: re@ (jhb)

21 years agoFix a source of instability specific to an EPC userland. We return
marcel [Sat, 24 May 2003 22:53:10 +0000 (22:53 +0000)]
Fix a source of instability specific to an EPC userland. We return
to userland with interrupts disabled until we restore PSR. However,
it has been observed that interrupts do actually happen before they
are enabled again. This is a bit surprising and I don't know yet
what's going on exactly. Nevertheless, the code was not crafted
carefully enough to allow interrupts to happen and we could
clobber the kernel stack of another thread when interrupts did
happen.

This is what happens: we restore the (memory) stack pointer (sp)
and the register stack base prior to restoring ar.k6 and ar.k7.
This is not a problem if interrupts don't happen between setting
sp/ar.bspstore and ar.k6/ar.k7. Alas, interrupts can happen.
Since sp/ar.bspstore already point to the userland stacks, we
need to switch to the kernel stack in interrupt. However, ar.k6
and ar.k7 have not been set, which means that we were switching
to some unrelated kstack and happily clobbered the trapframe
present there if the thread to which the kstack belonged was
in kernel mode or otherwise we could have our trapframe clobbered
if that other thread enters the kernel. Nasty either way.

We now carefully restore ar.k6 prior to restoring ar.bspstore and
likewise for ar.k7 and sp. All we need is the guarantee that an
interrupt does not clobber ar.k6 or ar.k7 before we're back in
userland. That has been achieved by restoring ar.k6/ar.k7
unconditionally (see exception.s)

While here, remove the disabling of interrupts on EPC entry. It
was added as a way to "resolve" the crashes until it was understood
what was going on. I think I achieved the latter, so we can remove
the patch. Note that setting up a trapframe with interrupts
enabled has it's own share of corner cases, but it's better to
properly fixed those than to keep a mostly wrong patch around
because we're afraid to remove it...

Approved by: re@ (blanket)

21 years agoBe more careful how we restore interrupts. Don't rewrite most of the
marcel [Sat, 24 May 2003 21:44:24 +0000 (21:44 +0000)]
Be more careful how we restore interrupts. Don't rewrite most of the
PSR only to achieve setting PSR.i back to it's previous value. It
makes it impossible to change any of the 30+ other unrelated bits
when done between intr_disable() and intr_restore(). That's bad.

Instead have intr_disable() return 1 when interrupts were previously
enabled and 0 otherwise and only enable interrupts in intr_restore()
when given a non-0 value.

This change specifically disallows using intr_restore() to disable
interrupts. The reason is simple: interrupts only need to be restored
after they are being disabled, which means that intr_restore() is
called with interrupts disabled and we only need to enable them if
they were previously enabled.

This change does not fix any bugs, other than that it bugged me...

Approved by: re@ (blanket)

21 years agoConsistently us the same metric to differentiate between kernel mode
marcel [Sat, 24 May 2003 21:16:19 +0000 (21:16 +0000)]
Consistently us the same metric to differentiate between kernel mode
and user mode. We need to take into account that the EPC syscall path
introduces a grey area in which one can argue either way, including a
third: neither.

We now use the region in which the IP address lies. Regions 5, 6 and 7
are kernel VA regions and if the IP lies any any of those regions we
assume we're in kernel mode. Hence, we can be in kernel mode even if
we're not on the kernel stack and/or have user privileges. There're
gremlins living in the twilight zone :-)

For the EPC syscall path this particularly means that the process
leaves user mode the moment it calls into the gateway page. This
makes the most sense because from a process' point of view the call
represents a request to the kernel for some service and that service
has been performed if the call returns. With the metric we picked,
this also means that we're back in user mode IFF the call returns.

Approved by: re@ (blanket)

21 years agoAdd __amd64__ ifdefs to enable the bootblock handling code, slices, etc.
peter [Sat, 24 May 2003 21:12:14 +0000 (21:12 +0000)]
Add __amd64__ ifdefs to enable the bootblock handling code, slices, etc.

Approved by: re (murray)
Obtained from: obrien

21 years agoAdd a temporary indirect patch for gcc when targeting amd64. This is to
peter [Sat, 24 May 2003 20:58:47 +0000 (20:58 +0000)]
Add a temporary indirect patch for gcc when targeting amd64.  This is to
give the cvs tree a surviving a 'make world'.  One of the two diff chunks
is already in gcc-3.3, the other has been committed to gcc's HEAD and
is in the pipeline for gcc-3.3.1 (but has not been committed yet).

The first chunk simplifies an excessively complex assembler statement
when generating switch jump tables.  The use of '.' causes as(1) to choke
on big files.  Use a simpler form instead.  This is only an issue for
TARGET_64BIT mode.

The second chunk fixes an internal compiler error when compiling
libc/stdio/vfprinf.c.  While this is supposedly only an issue for
64 bit mode, it does touch the 32 bit i386 code paths, so this patch
is only applied for TARGET_ARCH == amd64 to keep the risks down.
Breaking gcc at the 11th hour would suck.

This will be removed when it is time to import gcc-3.3.

Discussed with: kan
Approved by: re (jhb)

21 years agoUnconditionally restore ar.k7 (memory stack) and ar.k6 (register stack)
marcel [Sat, 24 May 2003 20:51:55 +0000 (20:51 +0000)]
Unconditionally restore ar.k7 (memory stack) and ar.k6 (register stack)
when returning from an interrupt. Both registers are used on interrupt
to switch to the right kernel stack, but other than that they are not
used. This means we only have to make sure they contain proper values
while in user mode. As such, we conditionally restored these registers
based on whether we returned to userland or not. A nice property of
conditionally restoring ar.k6 and ar.k7 is that it introduces two
invariants: ar.k6 always points to the bottom of the kernel stack and
ar.k7 always points to the top of the kernel stack (immediately below
the PCB we have there).

However, the EPC syscall path introduces an irregularity: there's no
"thin red line" between user and kernel. There's a grey area that's a
couple of instructions wide. Any interruption in that grey area is
bound to see an inconsistent state. One such state is that we're in
kernel space for all practical purposes, but we still need to have
ar.k6 and ar.k7 restored as if we're in userland.

Thus: restore ar.k6 and ar.k7 unconditionally at the cost of losing
a valuable invariant. Both registers now hold the extend of the
usable portion of the kernel stack at any interrupt nesting, which
when in userland mean the bottom and the top of the kstack.

21 years agomdoc(7) fixes.
ru [Sat, 24 May 2003 19:53:08 +0000 (19:53 +0000)]
mdoc(7) fixes.

Approved by: re (blanket)

21 years agolibstdc++.so breaks on amd64 due to bogons in our build, so prevent the
peter [Sat, 24 May 2003 19:38:18 +0000 (19:38 +0000)]
libstdc++.so breaks on amd64 due to bogons in our build, so prevent the
shared library being built for amd64.  The problem is that libstdc++.so
is produced with 'cc -shared'.  This has an internal -lgcc, which is
not PIC.  libstdc++.so uses exceptions and the dwarf2 unwinder, which
are in libgcc.a.  As a result, non-PIC code gets pulled into libstdc++.so.
This is fatal on amd64 when certain relocation types cannot be used in
PIC mode.  The official FSF solution to this is to have libgcc.so with
internal ELF symbol versioning to solve the ABI problem, but I dont want
to fight that battle yet.  I tried making libgcc_pic.a (which worked
fine), but thats not something for the 11th hour before a release.

Approved by:  re (amd64 "safe" stuff)

21 years agono libc_r on amd64 yet -> no pppctl.
peter [Sat, 24 May 2003 19:23:05 +0000 (19:23 +0000)]
no libc_r on amd64 yet -> no pppctl.

Approved by: re (safe amd64 changes)

21 years agoMerge some entries from maho's USB device compatibility list.
hrs [Sat, 24 May 2003 18:50:20 +0000 (18:50 +0000)]
Merge some entries from maho's USB device compatibility list.

Approved by: re (bmah)
Obtained from: http://people.FreeBSD.org/~maho/USB/

21 years agoGet usb(4) manual page closer to reality:
hmp [Sat, 24 May 2003 18:28:18 +0000 (18:28 +0000)]
Get usb(4) manual page closer to reality:

- update ``struct usb_device_info''
- add information about new fields in about struct
- document USB_EVENT_IS_ATTACH() and USB_EVENT_IS_DETACH()
- update URL of the USB.ORG developer documentation

PR:      docs/41580 (original patch)
Reviewed by: n_hibma
Approved by: des (mentor), re (bmah)

21 years agoStop profiled libc from exploding, matching gcc's generated code.
peter [Sat, 24 May 2003 18:24:03 +0000 (18:24 +0000)]
Stop profiled libc from exploding, matching gcc's generated code.

Approved by: re (amd64/* blanket)

21 years agoBring vnode(9) man page to its senses:
hmp [Sat, 24 May 2003 18:19:11 +0000 (18:19 +0000)]
Bring vnode(9) man page to its senses:

- remove '-*- nroff -*-'
- bump the date

- nuke outdated ``struct vnode''
  (it is just better to lookup the struct in the header)

- nuke ``enum vtype'' and related junk
- add a one line about ``struct vnode''
- use .Va instead of .Dv for vnode struct fields

Approved by: des (mentor), re (bmah)
Reviewed by: arch@, mentor

21 years agoDo not exclude amd64 from rtld-elf builds.
peter [Sat, 24 May 2003 17:38:45 +0000 (17:38 +0000)]
Do not exclude amd64 from rtld-elf builds.

Approved by:  re  (safe amd64 support commits)

21 years agoInitial pass at supporting shared libraries on amd64. There are still
peter [Sat, 24 May 2003 17:37:51 +0000 (17:37 +0000)]
Initial pass at supporting shared libraries on amd64.  There are still
a few missing relocation types in amd64/reloc.c, but I have not found
any of them in use yet. :-)

Approved by:  re (amd64/* blanket)

21 years agoRepair PIC mode. It seems I was a bit too excited about the
peter [Sat, 24 May 2003 17:35:23 +0000 (17:35 +0000)]
Repair PIC mode.  It seems I was a bit too excited about the
implications of native PC relative addressing.

21 years agoChange low-level locking a bit so that we can tell if
deischen [Sat, 24 May 2003 02:29:25 +0000 (02:29 +0000)]
Change low-level locking a bit so that we can tell if
a lock is being waitied on.

Fix a races in join and cancellation.

When trying to wait on a CV and the library is not yet
threaded, make it threaded so that waiting actually works.

When trying to nanosleep() and we're not threaded, just
call the system call nanosleep instead of adding the thread
to the wait queue.

Clean up adding/removing new threads to the "all threads queue",
assigning them unique ids, and tracking how many active threads
there are.  Do it all when the thread is added to the scheduling
queue instead of making pthread_create() know how to do it.

Fix a race where a thread could be marked for signal delivery
but it could be exited before we actually add the signal to it.

Other minor cleanups and bug fixes.

Submitted by: davidxu
Approved by: re@ (blanket for libpthread)

21 years agoLock the cond queue (condition variables):
mtm [Sat, 24 May 2003 01:02:16 +0000 (01:02 +0000)]
Lock the cond queue (condition variables):
Access to the thread's flags and state is protected by
_thread_critical_enter/exit(). When a thread is signaled with a condition
its state must be protected by locking it and disabling
signals before it is taken of the waiters' queue.

Move the implementation of pthread_cond_signal() and pthread_cond_broadcast()
into one function, cond_signal(). Its behaviour is determined by the
last argument, int broadcast. If this is set to 1 it will remove all
waiters, otherwise it will wake up only the first waiter thread.

Remove an extraneous call to pthread_testcancel().

Approved by: re/blanket libthr

21 years agoFix an alpha inheritance bug:
marcel [Sat, 24 May 2003 00:17:34 +0000 (00:17 +0000)]
Fix an alpha inheritance bug:

On alpha, PAL is involved in context management and after wiring
the CPU (in alpha_init()) a context switch was performed to tell
PAL about the context. This was bogusly brought over to ia64
where it introduced bugs, because we restored the context from
a mostly uninitialized PCB.

The cleanup constitutes:
o  Remove the unused arguments from ia64_init().
o  Don't return from ia64_init(), but instead call mi_startup()
   directly. This reduces the amount of muckery in assembly and
   also allows for the next bullet:
o  Save our currect context prior to calling mi_startup(). The
   reason for this is that many threads are created from thread0
   by cloning the PCB. By saving our context in the PCB, we have
   something sane to clone. It also ensures that a cloned thread
   that does not alter the context in any way will return to
   the saved context, where we're ready for the eventuality with
   a nice, user unfriendly panic().

The cleanup fixes at least the following bugs:
o  Entering mi_startup() with the RSE in enforced lazy mode.
o  Re-execution of ia64_init() in certain "lab" conditions.

While here, add proper unwind directives to __start() so that
the unwind knows it has reached the bottom of the (call) stack.

Approved by: re@ (blanket)

21 years agoFix a (new) source of instability:
marcel [Fri, 23 May 2003 23:55:31 +0000 (23:55 +0000)]
Fix a (new) source of instability:

When interrupting a kernel context, we don't need to switch stacks
(memory nor register). As such, we were also not restoring the
register stack pointer (ar.bspstore). This, however, fails to be
valid in 1 situation: when we interrupt a register stack switch as
is being done in restorectx(). The problem is that restorectx()
needs to have ar.bsp == ar.bspstore before it can assign the new
value to ar.bspstore. This is achieved by doing a loadrs prior to
assigning to ar.bspstore. If we take an interrupt in between the
loadrs and the assignment and we don't make sure we restore the
ar.bspstore prior to returning from the interrupt, we switch
stacks with possibly non-zero dirty registers, which means that
the new frame pointer (ar.bsp) will be invalid.

So, instead of jumping over the restoration of the register frame
pointer and related registers, we conditionalize it based on whether
we return to kernel context or user context. A future performance
tweak is possible by only restoring ar.bspstore when returning to
kernel mode *and* when the RSE is in enforced lazy mode. One cannot
assume ar.bsp == ar.bspstore if the RSE is not in enforced lazy mode
anyway.

While here (well, not quite) don't unconditionally assign to
ar.bspstore in exception_save. Only do that when we actually switch
stacks. It can only harm us to do it unconditionally.

Approved by: re@ (blanket)

21 years agoAdd two functions: _spinlock_pthread() and _spinunlock_pthread()
mtm [Fri, 23 May 2003 23:39:31 +0000 (23:39 +0000)]
Add two functions: _spinlock_pthread() and _spinunlock_pthread()
that take the address of a struct pthread as their first argument.
_spin[un]lock() just become wrappers arround these two functions.
These new functions are for use in situations where curthread can't be
used. One example is _thread_retire(), where we invalidate the array index
curthread uses to get its pointer..

Approved by: re/blanket libthr

21 years agoIn swapctx(), put the RSE in enforced lazy mode before we flush the
marcel [Fri, 23 May 2003 23:16:43 +0000 (23:16 +0000)]
In swapctx(), put the RSE in enforced lazy mode before we flush the
register stack. There's nothing really wrong with flushing before
putting the RSE in enforced lazy mode, provided you don't depend on
ar.bspstore being equal to ar.bsp when the RSE has been put in
enforced lazy more. The small window between the flush and setting
the RSE may be sufficient to have the RSE eagerly increase the dirty
region (and hence cause ar.bspstore != ar.bsp) or have an interrupt
that may even get the laziest RSE to do something.

Anyway: we don't depend on ar.bspstore being equal to ar.bsp, so
nothing was and is broken. But the code was non-intuitive and
easily confuses. This is a source of future bugs.

Note: the advantage of not depending on ar.bspstore is that there's
some recilience against an interrupted flushrs. Clobbering is limited
to stacked register contents only, not to RSE address clobbering.

Approved: re@ (blanket)

21 years agoFix a typo in rev 1.10
njl [Fri, 23 May 2003 21:40:07 +0000 (21:40 +0000)]
Fix a typo in rev 1.10

21 years agoFlesh out the libkse note a bit. Source material kindly provided by
bmah [Fri, 23 May 2003 20:10:46 +0000 (20:10 +0000)]
Flesh out the libkse note a bit.  Source material kindly provided by
deischen, any inaccuracies are mine.

Approved by: re (implicitly)

21 years agoMake the maximum number of vnodes a function of both the physical memory
alc [Fri, 23 May 2003 19:54:02 +0000 (19:54 +0000)]
Make the maximum number of vnodes a function of both the physical memory
size and the kernel's heap size, specifically, vm_kmem_size.  This
function allows a maximum of 40% of the vm_kmem_size to be used for
vnodes and vm objects.  This is a conservative bound based upon recent
problem reports.  (In other words, a slight increase in this percentage
may be safe.)

Finally, machines with less than ~3GB of RAM should be unaffected
by this change, i.e., the maximum number of vnodes should remain
the same.  If necessary, machines with 3GB or more of RAM can increase
the maximum number of vnodes by increasing vm_kmem_size.

Desired by: scottl
Tested by: jake
Approved by: re (rwatson,scottl)

21 years agoI'm lost in a maze of twisty little tunables, all different.
bmah [Fri, 23 May 2003 17:27:32 +0000 (17:27 +0000)]
I'm lost in a maze of twisty little tunables, all different.
The ACPI-disabling hint goes into device.hints, not loader.conf.

Pointed out by: njl

21 years agoAdd some hopefully helpful notes about ACPI.
bmah [Fri, 23 May 2003 16:37:23 +0000 (16:37 +0000)]
Add some hopefully helpful notes about ACPI.

Approved by: re (implicitly)
Reviewed by: imp

21 years agoMove ($create-refentry-xref-link$) to the language-neutral place
hrs [Fri, 23 May 2003 10:30:27 +0000 (10:30 +0000)]
Move ($create-refentry-xref-link$) to the language-neutral place
and add entities &release.manpath.*; for man.cgi's manpath=XXX.

Approved by: re (bmah)

21 years agoEDOOFUS
mtm [Fri, 23 May 2003 10:28:13 +0000 (10:28 +0000)]
EDOOFUS
Prevent one thread from messing up another thread's saved signal
mask by saving it in struct pthread instead of leaving it as a
global variable. D'oh!

Approved by: re/blanket libthr

21 years agoMake WARNS2 clean. The fixes mostly included:
mtm [Fri, 23 May 2003 09:48:20 +0000 (09:48 +0000)]
Make WARNS2 clean. The fixes mostly included:
o removed unused variables
o explicit inclusion of header files
o prototypes for externally defined functions

Approved by:    re/blanket libthr

21 years agonote to self: do not confuse void* with int.
mtm [Fri, 23 May 2003 08:13:24 +0000 (08:13 +0000)]
note to self: do not confuse void* with int.

Approved by: re/blanket libthr

21 years agoTypo fix. oops.
peter [Fri, 23 May 2003 06:36:46 +0000 (06:36 +0000)]
Typo fix.  oops.

Submitted by:  jmallett
Approved by:   re (blanket amd64/*)

21 years agoUpdate comments. Note that the kernel is at -1GB, not -2GB as erroniously
peter [Fri, 23 May 2003 06:35:45 +0000 (06:35 +0000)]
Update comments.  Note that the kernel is at -1GB, not -2GB as erroniously
implied by the previous commit.  KVM is still only 1GB until
pmap_growkernel() learns about the extra page table level.

Approved by:  re (blanket)

21 years agoAs suggested by the gdb folks, pad the 'struct fpreg' to a full 512 bytes
peter [Fri, 23 May 2003 06:31:56 +0000 (06:31 +0000)]
As suggested by the gdb folks, pad the 'struct fpreg' to a full 512 bytes
to match the native fxsave/fxrstor object size since thats apparently what
the Linux/NetBSD folks do.

21 years agoAdd amd64 to the MACHINE_ARCH list of systems that link bsdlabel to
peter [Fri, 23 May 2003 06:08:28 +0000 (06:08 +0000)]
Add amd64 to the MACHINE_ARCH list of systems that link bsdlabel to
disklabel.  I just got burnt again by having an old disklabel binary
kicking around.

Discussed with: phk
Approved by:    re (safe amd64 stuff)

21 years agoLow risk amd64 fix. Use a vm_offset_t for the virtual location of the
peter [Fri, 23 May 2003 05:10:49 +0000 (05:10 +0000)]
Low risk amd64 fix.  Use a vm_offset_t for the virtual location of the
buffer space instead of a u_int32_t.  Otherwise the upper 32 bits of
the address space get truncated and syscons blows up.

Approved by: re (safe, low risk amd64 fixes)

21 years agoDeal with the user VM space expanding. 32 bit applications do not like
peter [Fri, 23 May 2003 05:07:33 +0000 (05:07 +0000)]
Deal with the user VM space expanding.  32 bit applications do not like
having their stack at the 512GB mark.  Give 4GB of user VM space for 32
bit apps.  Note that this is significantly more than on i386 which gives
only about 2.9GB of user VM to a process (1GB for kernel, plus page
table pages which eat user VM space).

Approved by: re (blanket)

21 years agoMajor pmap rework to take advantage of the larger address space on amd64
peter [Fri, 23 May 2003 05:04:54 +0000 (05:04 +0000)]
Major pmap rework to take advantage of the larger address space on amd64
systems.  Of note:
- Implement a direct mapped region using 2MB pages.  This eliminates the
  need for temporary mappings when getting ptes.  This supports up to
  512GB of physical memory for now.  This should be enough for a while.
- Implement a 4-tier page table system.  Most of the infrastructure is
  there for 128TB of userland virtual address space, but only 512GB is
  presently enabled due to a mystery bug somewhere.  The design of this
  was heavily inspired by the alpha pmap.c.
- The kernel is moved into the negative address space(!).
- The kernel has 2GB of KVM available.
- Provide a uma memory allocator to use the direct map region to take
  advantage of the 2MB TLBs.
- Fixed some assumptions in the bus_space macros about the ability
  to fit virtual addresses in an 'int'.

Notable missing things:
- pmap_growkernel() should be able to grow to 512GB of KVM by expanding
  downwards below kernbase.  The kernel must be at the top 2GB of the
  negative address space because of gcc code generation strategies.
- need to fix the >512GB user vm code.

Approved by: re (blanket)

21 years agoChange the way the plex lock mutexes work. Previously they were part
grog [Fri, 23 May 2003 01:15:55 +0000 (01:15 +0000)]
Change the way the plex lock mutexes work.  Previously they were part
of the struct plex, which tore apart the mutex linked lists when the
plex table was expanded.  Now we maintain a pool of mutexes (currently
32) to be shared by all plexes.  This is still a lot better than the
splhigh() method used in other architectures.

expand_table: Add parameters file and line if we're debugging.

Approved by: re (jhb)

21 years agoChange the way the plex lock mutexes work. Previously they were part
grog [Fri, 23 May 2003 01:15:30 +0000 (01:15 +0000)]
Change the way the plex lock mutexes work.  Previously they were part
of the struct plex, which tore apart the mutex linked lists when the
plex table was expanded.  Now we maintain a pool of mutexes (currently
32) to be shared by all plexes.  This is still a lot better than the
splhigh() method used in other architectures.

Add and clarify comments.

Approved by: re (jhb)

21 years agoexpand_table: Add parameters file and line if we're debugging.
grog [Fri, 23 May 2003 01:15:01 +0000 (01:15 +0000)]
expand_table: Add parameters file and line if we're debugging.

MMalloc, vinum_meminfo: Use strlcpy to copy file name.

Approved by: re (jhb)

21 years agoChange the way the plex lock mutexes work. Previously they were part
grog [Fri, 23 May 2003 01:14:35 +0000 (01:14 +0000)]
Change the way the plex lock mutexes work.  Previously they were part
of the struct plex, which tore apart the mutex linked lists when the
plex table was expanded.  Now we maintain a pool of mutexes (currently
32) to be shared by all plexes.  This is still a lot better than the
splhigh() method used in other architectures.

Approved by: re (jhb)

21 years agodetachobject: Update volume config after detaching a plex.
grog [Fri, 23 May 2003 01:14:13 +0000 (01:14 +0000)]
detachobject: Update volume config after detaching a plex.

update_volume_config: Remove redundant diskconfig parameter.

Approved by: re (jhb)

21 years agoChange the way the plex lock mutexes work. Previously they were part
grog [Fri, 23 May 2003 01:13:43 +0000 (01:13 +0000)]
Change the way the plex lock mutexes work.  Previously they were part
of the struct plex, which tore apart the mutex linked lists when the
plex table was expanded.  Now we maintain a pool of mutexes (currently
32) to be shared by all plexes.  This is still a lot better than the
splhigh() method used in other architectures.

update_volume_config: Remove redundant diskconfig parameter.

expand_table: Add parameters file and line if we're debugging.

Approved by: re (jhb)

21 years agoChange many strcpys to strlcpys, etc.
grog [Fri, 23 May 2003 01:13:10 +0000 (01:13 +0000)]
Change many strcpys to strlcpys, etc.

Submitted by:    Ted Unangst <tedu@stanford.edu>

Correct some inaccurate and badly formatted comments.

config_subdisk: If our drive is down, ensure that the subdisk is
crashed.  Previously it was possible for the subdisk
to be up when the drive was down.

Change the way the plex lock mutexes work.  Previously they were part
of the struct plex, which tore apart the mutex linked lists when the
plex table was expanded.  Now we maintain a pool of mutexes (currently
32) to be shared by all plexes.  This is still a lot better than the
splhigh() method used in other architectures.

update_volume_config: Remove redundant diskconfig parameter.

Approved by: re (jhb)

21 years agoModified release note: Note code generation problems with the base
bmah [Fri, 23 May 2003 00:02:10 +0000 (00:02 +0000)]
Modified release note:  Note code generation problems with the base
system GCC using -march=pentium4, and the local workaround in our
Makefile infrastructure.

Approved by: re (implicitly)

21 years agoo Document the tunables that acpi allows. (mdoc gurus please comment
imp [Thu, 22 May 2003 23:58:50 +0000 (23:58 +0000)]
o Document the tunables that acpi allows. (mdoc gurus please comment
  on and fix if neceeary).
o Note that acpi is available on i386-ia32, ia64 and amd64, not just 'intel'
  platforms.  Intel has had nothing to do with amd64.

Approved by: re (scottl@)

21 years agoCorrectly tag some on-board Ethernet devices with the right
bmah [Thu, 22 May 2003 23:22:59 +0000 (23:22 +0000)]
Correctly tag some on-board Ethernet devices with the right
architecture.

Approved by: re (implicitly)

21 years agoNote a puc(4) device that works on ia64.
bmah [Thu, 22 May 2003 23:19:01 +0000 (23:19 +0000)]
Note a puc(4) device that works on ia64.

Submitted by: Jim Brown <jpb@sixshooter.v6.thrupoint.net>
Approved by: re (implicitly)

21 years agoAdd more ia64 device information, in a section similar to that for
bmah [Thu, 22 May 2003 23:14:52 +0000 (23:14 +0000)]
Add more ia64 device information, in a section similar to that for
FreeBSD/alpha.  Heavily hacked version of a diff that was...

Submitted by: Jim Brown <jpb@sixshooter.v6.thrupoint.net>
Approved by: re (implicitly)

21 years agoEnable some devices on ia64. Based on patch that was...
bmah [Thu, 22 May 2003 22:40:22 +0000 (22:40 +0000)]
Enable some devices on ia64.  Based on patch that was...

Submitted by: Jim Brown <jpb@sixshooter.v6.thrupoint.net>
Approved by: re (implicitly)

21 years agoMerge from i386/trap.c rev 1.252. Use td_critnest instead of the
peter [Thu, 22 May 2003 20:09:50 +0000 (20:09 +0000)]
Merge from i386/trap.c rev 1.252.  Use td_critnest instead of the
spinlocks count for explicitly enabling interrupts.

Approved by: re (blanket)

21 years agoThe "krb5" distribution was merged with "crypto", record the death.
ru [Thu, 22 May 2003 18:41:16 +0000 (18:41 +0000)]
The "krb5" distribution was merged with "crypto", record the death.

Reviewed by: jhb
Approved by: re (jhb)

21 years agoWhen newfs'ing a partition with UFS2 that had previously been newfs'ed
dougb [Thu, 22 May 2003 18:38:54 +0000 (18:38 +0000)]
When newfs'ing a partition with UFS2 that had previously been newfs'ed
with UFS1, the UFS1 superblocks were not deleted. This allowed any
RELENG_4 (or other non-UFS2-aware) fsck to think it knew how to "fix"
the file system, resulting in severe data scrambling.

This patch is a more advanced version than the one originally submitted.
Lukas improved it based on feedback from Kirk, and testing by me. It
blanks all UFS1 superblocks (if any) during a UFS2 newfs, thereby causing
fsck's that are not UFS2 aware to generate the "SEARCH FOR ALTERNATE
SUPER-BLOCK FAILED" message, and exit without damaging the fs.

PR: bin/51619
Submitted by: Lukas Ertl <l.ertl@univie.ac.at>
Reviewed by: kirk
Approved by: re (scottl)

21 years agoCalculate routed interrupts using the slot number from the device and
ticso [Thu, 22 May 2003 17:45:26 +0000 (17:45 +0000)]
Calculate routed interrupts using the slot number from the device and
not that of the bridge.

Approved by: re (jhb)

21 years agoMark a couple of instances of onboard NICs as i386-only.
bmah [Thu, 22 May 2003 17:25:24 +0000 (17:25 +0000)]
Mark a couple of instances of onboard NICs as i386-only.

Approved by: re (implicitly)

21 years agoFix two misuses of __BSD_VISIBLE.
mike [Thu, 22 May 2003 17:07:57 +0000 (17:07 +0000)]
Fix two misuses of __BSD_VISIBLE.

Submitted by: bde
Approved by: re

21 years agoChange -march=pentium4 to -march=pentium3 when CPUTYPE==p4, because gcc 3.2 is
anholt [Thu, 22 May 2003 16:56:46 +0000 (16:56 +0000)]
Change -march=pentium4 to -march=pentium3 when CPUTYPE==p4, because gcc 3.2 is
known to produce broken code with -march=pentium4.  Add a note explaining this.
This should be removed when we update to gcc 3.3 or the bug is otherwise fixed.

Approved by: re

21 years agoAdd a link to the FreeBSD/ia64 project. Maybe should do this for
bmah [Thu, 22 May 2003 15:51:45 +0000 (15:51 +0000)]
Add a link to the FreeBSD/ia64 project.  Maybe should do this for
other platforms that have their own project pages too?

Based on a patch that was:

Submitted by: Jim Brown <jpb@sixshooter.v6.thrupoint.net>
Approved by: re (implicitly)

21 years agoUpdate the abstract to be somewhat more helpful. Based on a patch
bmah [Thu, 22 May 2003 15:42:50 +0000 (15:42 +0000)]
Update the abstract to be somewhat more helpful.  Based on a patch
that was...

Submitted by: Jim Brown <jpb@sixshooter.v6.thrupoint.net>
Approved by: re (implicitly)

21 years agoErase whitspace at EOL.
ru [Thu, 22 May 2003 13:10:32 +0000 (13:10 +0000)]
Erase whitspace at EOL.

Approved by: re (blanket)

21 years agoAssorted mdoc(7) fixes.
ru [Thu, 22 May 2003 13:02:28 +0000 (13:02 +0000)]
Assorted mdoc(7) fixes.

Approved by: re (blanket)

21 years agoErase whitespace at EOL.
ru [Thu, 22 May 2003 11:56:41 +0000 (11:56 +0000)]
Erase whitespace at EOL.

Approved by: re (blanket)

21 years agoMoved $FreeBSD$ tag to where it belongs.
ru [Thu, 22 May 2003 11:55:26 +0000 (11:55 +0000)]
Moved $FreeBSD$ tag to where it belongs.

Approved by: re (blanket)

21 years agoNitpicking.
ru [Thu, 22 May 2003 11:54:53 +0000 (11:54 +0000)]
Nitpicking.

Approved by: re (blanket)

21 years agoAssorted mdoc(7) fixes.
ru [Thu, 22 May 2003 11:52:23 +0000 (11:52 +0000)]
Assorted mdoc(7) fixes.

Approved by: re (blanket)

21 years agoUnbreak world build if NO_OPENSSL is defined but NO_KERBEROS is not.
ru [Wed, 21 May 2003 21:47:20 +0000 (21:47 +0000)]
Unbreak world build if NO_OPENSSL is defined but NO_KERBEROS is not.

Submitted by: Marius Strobl <marius@alchemy.franken.de>
Approved by: re (jhb)

21 years agoRemove alpha-specific floppy build target for now.
obrien [Wed, 21 May 2003 21:19:54 +0000 (21:19 +0000)]
Remove alpha-specific floppy build target for now.

Approved by: re(jhb)

21 years agoMarkup bits.
ru [Wed, 21 May 2003 21:07:28 +0000 (21:07 +0000)]
Markup bits.

Approved by: re (blanket)

21 years agoRevert last delta.
ru [Wed, 21 May 2003 20:52:57 +0000 (20:52 +0000)]
Revert last delta.

The -l option is deprecated (hence undocumented in usage() and
SYNOPSIS), as was threatened in the commitlog accompanying rev.
1.10 of main.c.

Approved by: re (blanket)

21 years agoWhen we are spilling threads out of the run queue during panic, make sure we
julian [Wed, 21 May 2003 18:53:25 +0000 (18:53 +0000)]
When we are spilling threads out of the run queue during panic, make sure we
keep the thread state variable consistent with its real state.
i.e. Don't say it's on the run queue when it isn't.

Also clarify the associated comment.

Turns a double panic back to a single panic :-/

Approved by: re@ (jhb)

21 years agoReturn ENXIO if the softc pointer is NULL, in all likelyhood the
phk [Wed, 21 May 2003 18:52:29 +0000 (18:52 +0000)]
Return ENXIO if the softc pointer is NULL, in all likelyhood the
disk is in the process of disappearing.

Approved by: re/rwats*

21 years agoLink {be,le}{16,32,64}{enc,dec}.9 to byteorder.9.
ru [Wed, 21 May 2003 17:37:22 +0000 (17:37 +0000)]
Link {be,le}{16,32,64}{enc,dec}.9 to byteorder.9.

Approved by: re (blanket)

21 years agoFixed the whatis(1) entry for this manpage by using only
ru [Wed, 21 May 2003 17:32:55 +0000 (17:32 +0000)]
Fixed the whatis(1) entry for this manpage by using only
one short description (.Nd).

Submitted by: sheldonh

Added bswap*() functions to the NAME section.

Approved by: re (blanket)

21 years agoKill whitespace at EOL.
ru [Wed, 21 May 2003 15:55:40 +0000 (15:55 +0000)]
Kill whitespace at EOL.

Approved by: re (blanket)