Commit Graph

155 Commits

Author SHA1 Message Date
wrstuden 27724c38ae Adjust locking on the sadata::sa_vps list. The main time we
walk the list, we're looking for a vp to do something with. We do
this in the signal code and in the timer code. The signal code already
runs with proc::p_lock held, so it's a very natural lock to use. The
timer code, however, calls into the sa timer code with a spinlock held.
Since proc::p_lock is an adaptable mutex, we can sleep to get it. Sleeping
with a spinlock is BAD. So proc::p_lock is _not_ the right lock there,
and something like sadata::sa_mutex would be best.

Address this difficulty by noting that both uses actually just read
the list. Changing the list of VPs is rare - once one's added, it stays
until the process ends. So make the locking protocol that to write the
list you have to hold both proc::p_lock and sadata::sa_mutex (taken
in that order). Thus holding either one individually grants read access.

This removes a case where we could sleep with timer_lock, a spinlock at
IPL_SCHED (!!), while trying to get p_lock. If that ever happened, we'd
pretty much be dead. So don't do that!

This fixes a merge botch from how I handled our gaining p_lock - p_lock
should not have simply replaced p_smutex.

While here, tweak the sa_unblock_userret() code for the case
when the blessed vp is actually running (on another CPU). Make its
resched RESCHED_IMMED so we whack the CPU. Addresses a hang I've
observed in starting firefox on occasion when I see one thread running
in userland and another thread sitting in lwpublk, which means it's on
the list of threads for which we need an unblocked upcall. This list is
one on which things should NOT linger.
2008-10-16 18:21:45 +00:00
wrstuden fc7511b00e Merge wrstuden-revivesa into HEAD. 2008-10-15 06:51:17 +00:00
pooka 44367b7199 Split rate-checking routines into their own module for easier reuse. 2008-09-25 17:17:10 +00:00
christos 93aed8f8e3 fix half-assed change usec -> nsec that broke non-real timers. 2008-09-23 16:44:49 +00:00
christos f6e1114503 Fix broken setitimer(). (Sverre Froyen) 2008-08-08 16:44:52 +00:00
christos aa389c698d Use more timespecs internally. From Alexander Shishkin and me.
Welcome to 4.99.70, 30 more to go for 100.
2008-07-15 16:18:08 +00:00
christos 7f6e74c46e Fix to bug reported and tested by Alexander Shishkin. struct ptimer has
a union that contains either a callout [for CLOCK_REALTIME] or a flag
and a list [for other clock types]. Make sure we perform the right actions
on the right union member depending on the clock type. Otherwise this would
result in crashes.
2008-07-08 20:53:02 +00:00
joerg 157262cae8 Explicitly compute the next interval using 64bit arithmetic, if the time
was either stepped backwards or the timer has overflown. This fixes
PR 26470.
2008-05-29 15:27:51 +00:00
ad 541e4662f9 - Add tc_gonebad(): allows timecounter to be flagged as bad and removed at
the next clock tick.
- Remove time_lock, which is no longer required.
2008-05-08 18:56:58 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
ad 43d8bae932 Give callout_halt() an additional 'kmutex_t *interlock' argument. If there
is a need to block and wait for the callout to complete, and there is an
interlock, it will be dropped while waiting and reacquired before return.
2008-04-22 12:04:22 +00:00
ad a2249ef75c Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE. 2008-04-21 12:56:30 +00:00
ad 08b44dd8b9 timer fixes for PR 37093:
- Fix serious concurrency problems, making the code MT and MP safe in
  the process.
- Don't allocate memory or inspect process state from hardclock().
2008-04-21 00:13:46 +00:00
yamt 8b793ad476 nanosleep1: handle kpause spontaneous wakeups. 2008-02-25 12:25:03 +00:00
yamt 63e70ec982 wrap long lines. no functional change. 2008-02-19 14:21:56 +00:00
yamt 60b5013421 nanosleep1: whitespace. no functional change. 2008-02-19 14:17:39 +00:00
joerg 3615cf7715 Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
2008-01-20 18:09:03 +00:00
yamt 949e16d902 use binuptime for l_stime/l_rtime. 2007-12-22 01:14:53 +00:00
yamt ad5800688c reduce #ifdef __HAVE_TIMECOUNTER. 2007-12-22 00:35:32 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
elad 51fe5bc63c Replace usage of p_cred in kauth(9) call with kauth_cred_get().
okay yamt@.
2007-12-08 13:31:03 +00:00
elad c1ae8fe49c Kill a KAUTH_REQ_SYSTEM_TIME_SYSTEM request that's no longer needed. 2007-11-25 08:43:11 +00:00
elad abb7851f4d Refactor time modification checks and place them in the secmodel code.
okay christos@
2007-11-25 00:35:26 +00:00
ad 0239b151ae Add a bit of locking around timecounter attachment / selection. 2007-11-15 20:12:04 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
ad 36a1712707 Merge run time accounting changes from the vmlocking branch. These make
the LWP "start time" per-thread instead of per-CPU.
2007-10-08 20:06:17 +00:00
pooka 5fbd525b19 Shuffle routines which just roll values around from kern_clock.c
and kern_time.c to subr_time.c.
2007-08-09 07:36:18 +00:00
ad c1bc924601 No reason not to make itimespecfix() generally available.. 2007-08-07 11:43:35 +00:00
ad 4a8903393a Export itimespecfix() until itimerfix() dies. 2007-08-07 11:39:18 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
christos c61eed39a8 rename si_sigval -> si_value to match POSIX RTS. 2007-05-21 15:35:47 +00:00
dsl 9bdbb03424 nanosleep1() shouldn't try to get the current time into a NULL address. 2007-05-13 19:51:35 +00:00
dsl f23edc42dd Instead of the #define versions of tc_getfrequency() and nanouptime(), use
the function ones in kern_kern_clock.c (adding tc_getfrequency).
Adjust includes so this builds.
2007-05-13 14:43:52 +00:00
dsl 88e6c5604d Add a #define for nanouptime() in the !__HAVE_TIMECOUNTERS case. 2007-05-13 10:58:50 +00:00
dsl 1c85a3efd8 Split sys_nanosleep(). 2007-05-13 10:34:25 +00:00
dsl ef3fdc4a07 Change interface to settimeofday1() so that it can also be used from
compat code in order to avoid the stackgap.
2007-05-12 20:27:13 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
ad c147748d84 - Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.
2007-03-09 14:11:22 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
thorpej 4f3d5a9cc0 TRUE -> true, FALSE -> false 2007-02-22 06:34:42 +00:00
ad 3363855a4a Remove spllowersoftclock() and CLKF_BASEPRI(), and always dispatch callouts
via a soft interrupt. In the near future, softclock will be run from process
context.
2007-02-16 02:53:43 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
yamt ccfd2c0df0 remove nqnfs. 2006-12-27 12:10:09 +00:00
yamt a575dafacc use KSI_INIT rather than memset. no functional changes. 2006-12-06 10:02:22 +00:00
yamt 1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
elad a5d447aee5 Add an XXX to remind me why it's there when grepping. (securelevel ref) 2006-10-20 22:22:48 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos 1a9beba1e6 PR/34612: Bucky Katz: SA returns from sleep do not set the signal flags
Patch applied, many thanks for the example!
2006-09-25 18:28:56 +00:00
elad 5f7169ccb1 First take at security model abstraction.
- Add a few scopes to the kernel: system, network, and machdep.

- Add a few more actions/sub-actions (requests), and start using them as
  opposed to the KAUTH_GENERIC_ISSUSER place-holders.

- Introduce a basic set of listeners that implement our "traditional"
  security model, called "bsd44". This is the default (and only) model we
  have at the moment.

- Update all relevant documentation.

- Add some code and docs to help folks who want to actually use this stuff:

  * There's a sample overlay model, sitting on-top of "bsd44", for
    fast experimenting with tweaking just a subset of an existing model.

    This is pretty cool because it's *really* straightforward to do stuff
    you had to use ugly hacks for until now...

  * And of course, documentation describing how to do the above for quick
    reference, including code samples.

All of these changes were tested for regressions using a Python-based
testsuite that will be (I hope) available soon via pkgsrc. Information
about the tests, and how to write new ones, can be found on:

	http://kauth.linbsd.org/kauthwiki

NOTE FOR DEVELOPERS: *PLEASE* don't add any code that does any of the
following:

  - Uses a KAUTH_GENERIC_ISSUSER kauth(9) request,
  - Checks 'securelevel' directly,
  - Checks a uid/gid directly.

(or if you feel you have to, contact me first)

This is still work in progress; It's far from being done, but now it'll
be a lot easier.

Relevant mailing list threads:

http://mail-index.netbsd.org/tech-security/2006/01/25/0011.html
http://mail-index.netbsd.org/tech-security/2006/03/24/0001.html
http://mail-index.netbsd.org/tech-security/2006/04/18/0000.html
http://mail-index.netbsd.org/tech-security/2006/05/15/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/01/0000.html
http://mail-index.netbsd.org/tech-security/2006/08/25/0000.html

Many thanks to YAMAMOTO Takashi, Matt Thomas, and Christos Zoulas for help
stablizing kauth(9).

Full credit for the regression tests, making sure these changes didn't break
anything, goes to Matt Fleming and Jaime Fournier.

Happy birthday Randi! :)
2006-09-08 20:58:56 +00:00