Commit Graph

207 Commits

Author SHA1 Message Date
pooka 7ea24651a7 Move routines related to syscall establishment from kern_subr.c and
kern_stub.c to kern_syscall.c.
2010-04-14 14:46:59 +00:00
pooka 04b824ef52 Place *hook implementations in kern_hook.c instead of them floating
around in the kern_subr.c gruel.  Arrrrr.
2010-01-31 01:38:48 +00:00
pooka 3b780690a4 Use proper static initializers for *hooklist (currently they happened
to work accidentally anyway since the initializer is 0).
2010-01-31 00:48:07 +00:00
pooka 92394bf5f3 Trade 200-something bytes for the death of an ifdef. 2010-01-30 23:19:55 +00:00
dyoung fbe2bb0ace Use deviter(9) instead of accessing alldevs directly. 2009-11-05 18:07:19 +00:00
pooka fcc20a4ba1 Split uiomove() and high-level copy routines out of the crowded
kern_subr and into their own cozy home in subr_copy.
2009-11-04 16:54:00 +00:00
pooka 68f37adaa6 Give humanize_number & format_bytes their own spots in the sun and move
from kern_subr to subr_humanize.
2009-10-02 15:48:41 +00:00
dyoung 7e8a3f8dc1 Replace 'struct device *' with 'device_t', throughout. No functional
change intended.
2009-09-25 19:21:09 +00:00
drochner eb4f9278bc In humanize_number(), avoid an integer overflow if the buffer
provided is "too large" (log10(2^64) = 19).
(It can still overflow if the input value is close to 2^64 but I don't
consider this a problem.)
fixes nonsense displayed as "total memory" on boot
2009-04-02 17:25:24 +00:00
christos 461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
pgoyette 9c68331911 Store config(1)'s root filesystem type as a text string rather than
embedding the address of its xxx_mountroot() in swapnetbsd.c.  This
permits booting of kernels with hard-wired filesystem type even if the
filesystem is in a loadable module (ie, not linked into the kernel
image).

Discussed on current-users.  Tested on amd64 and i386 with both hard-
wired and '?' filesystem times, and on both modular and monolithic
kernels.

Thanks to pooka@ for code review and suggestions.

Addresses my PR kern/40167
2008-12-19 17:11:57 +00:00
christos 78d77f514f better error messages, and more messages for DIAGNOSTIC. 2008-11-27 21:36:51 +00:00
ad 8fe49e035f PR kern/39913 exec, fork, exit hooks need locking
Acquire exec_lock where needed.
2008-11-14 13:01:18 +00:00
ad 119366618e Atomic insertion/removal of groups of system call vectors at runtime with
a basic facility for rollback.

Proposed on tech-kern@.
2008-11-12 14:29:31 +00:00
dyoung 94d985722a It is not appropriate to call pmf_system_shutdown(9) from
doshutdownhooks(9): shutdown hooks registered by shutdownhook_establish(9)
expect to be called with interrupts disabled, but shutdown hooks
registered with pmf_device_register1(9) expect to be called with
interrupts enabled.  So I have made two changes:

1 Do not call pmf_system_shutdown() from doshutdownhooks().  Instead,
change every call to doshutdownhooks() to a call to doshutdownhooks()
followed by a call to pmf_system_shutdown().  No functional change
is intended by this change.

2 Make i386 re-enable interrupts briefly while it calls
pmf_system_shutdown().  I leave it to others either to fix the
other ports, or to factor out some MI shutdown code, as joerg@
suggests, and fix that.  Note that a functional change *is* intended
by this change.

I hope that this patch will stop us from flip-flopping between
calling doshutdownhooks() and pmf_system_shutdown() sometimes with
and sometimes without interrupts enabled.
2008-11-11 06:46:40 +00:00
pooka a44cdde52c M_IOV is used all over the place, so stuff it in with malloc_stdtypes 2008-10-14 14:17:49 +00:00
rmind ffb8ec88e1 Replace intptr_t with uintptr_t in few more places.
OK by <matt>.
2008-09-15 18:12:56 +00:00
drochner 520a61068b remove the hacks around fakemdrootdev[] which should be unnecessary now
that "md" devices show up in the "alldevs" list
2008-06-11 10:40:21 +00:00
dyoung 801c395b47 Run shutdown hooks whether or not the kernel has panicked. Restores
NetBSD's shutdown behavior of more than 6 years before rev 1.176.
Ok joerg@.

It is essential that we restore some hardware to initial conditions
before rebooting, in order to avoid interfering with the BIOS
bootstrap.  For example, if NetBSD gives control back to the Soekris
comBIOS while the kernel text is write-protected, the BIOS bootstrap
hangs during the power-on self-test, "POST: 0123456789bcefghip".
In principle, bus masters can also interfere with BIOS boot.
2008-05-28 15:40:58 +00:00
christos 2847938186 Coverity CID 5019: Check before deref. 2008-05-24 16:49:30 +00:00
ad 1253c2cad4 Allow md_root_setconf() to set in a miniroot as the root file system
even if MEMORY_DISK_IS_ROOT is not defined (a runtime override).
2008-05-02 13:02:31 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 27168d9d58 - Rename crit_enter/crit_exit to kpreempt_disable/kpreempt_enable.
DragonflyBSD uses the crit names for something quite different.
- Add a kpreempt_disabled function for diagnostic assertions.
- Add inline versions of kpreempt_enable/kpreempt_disable for primitives.
- Make some more changes for preemption safety to the x86 pmap.
2008-04-27 11:37:48 +00:00
cegger 224670ae98 use device_xname() where appropriate
OK martin
2008-04-04 20:13:18 +00:00
yamt a67bae0b7b - simplify ASSERT_SLEEPABLE.
- move it from proc.h to systm.h.
- add some more checks.
- make it a little more lkm friendly.
2008-03-17 08:27:50 +00:00
drochner 0e748e633e Extend the pmf suspend/resume hooks by a shutdown method, so drivers
can register a shutdown handler explicitely.
Install a pci bus shutdown handler which disables bus master accesses
for all childs, so the drivers don't need to care.
This will hopefully be sufficient to replace the shutdownhooks
(together with the powerhooks). (It has been suggested to use some
general event notification framework for shutdown handlers, but there
might be cases where shutdown handlers must be run in an order following
the device hierarchy, which wouldn't be easy with event handlers
not tied to drivers.)
approved by David Young
2008-02-28 14:25:12 +00:00
drochner d22ab0209e Don't call pmf_system_shutdown() from doshutdownhooks() -- it does way
too much in the RB_HALT case, making the "press a key to reboot" prompt
a bad joke. doshutdownhooks() should do shutdownhooks, not more.
Since it is md code which decides about halt/poweroff etc,
pmf_system_shutdown() should be called from there if appropriate.
2008-02-20 23:30:13 +00:00
njoly a10d333001 Make cnt of type size_t, to avoid uiomove() overrun its iovecs.
This makes write(2) works with large buffers (>=4GB).

Fix from pooka, tested by myself.
2008-02-20 15:08:14 +00:00
joerg e69482d49d Introduce device_find_by_xname and device_find_by_driver_unit to replace
alldevs iterations all over src.

Patch discussed with and improved on suggestioned from cube@.
2008-02-12 17:30:57 +00:00
dyoung 7afb2e620f Use LIST_FOREACH(). Join lines. 2008-02-11 22:20:11 +00:00
dsl c2a8c787c3 Remove the 'args' parameter to 'trace_exit()' it is no longer used.
Instead of passing the (un)real system call code and syscall table pointer,
just pass the number of arguments - which is what ktrace really wants.
Ride forthcoming 4.99.53
2008-02-06 22:12:39 +00:00
joerg 04eaea3b16 Short cut doshutdownhooks on panic. The system is wedged and so avoid
anything that could make the status worse.
2008-01-18 01:22:18 +00:00
ad 73e694f404 Don't use the block device to read crashdumps, if possible. 2008-01-15 14:26:41 +00:00
ad 9dc48ffbf6 uiomove: don't bother with kernel_lock any more. 2008-01-10 16:29:17 +00:00
dsl b8bcdbe9e6 Don't pass 'curlwp' into trace_enter() and trace_exit(). 2008-01-05 12:53:52 +00:00
dsl 463af8509e Don't pass curlwp into process_stoptrace() 2008-01-05 12:41:43 +00:00
dsl c9848793d9 Don't pass l (== curlwp) into the system call trace code.
Delete inclusion of opt_syscall_debug.h into systm.h, every kernel object
file doesn't need to depend on opt_syscall_debug.h!
2008-01-05 12:30:47 +00:00
ad 2ecdf58c2c Remove systrace. Ok core@. 2007-12-31 15:31:24 +00:00
dsl 44a023c35b Further constification of the syscall args buffer.
It will get __UNCONST() applied in the systrace code if/when systrace tries
to change the arguments.  This sucks since the syscall args might be in
the trap frame, and the syscall might return ERESTART so the restarted call
would use the wrong arguments.
OTOH systrace() (as a security measure) is almost impossible to implement
for a threaded app (validated filenames can be changed before namei() reads
them into memory).
The current code is just plain broken for threaded apps - data that needs
to be lwp-specified is proc-specific.
I believe ad is planning to nuke systrace ...
2007-12-22 16:19:34 +00:00
dsl 43e74e4cc8 Add a few buckets of 'const' and 'static' to the system call trace code.
sys_trace() still needs to be able to update the syscall args.
2007-12-22 11:38:54 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
pooka 61e8303e9d Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start.  In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
2007-11-26 19:01:26 +00:00
ad 78e4c5b083 Merge from vmlocking:
- uiomove: don't bother dropping kernel_lock if moving less than 1k.
- Catch up with vfsops reference counting changes (for LKMs).
- Add crit_enter()/crit_exit(). These bound critical sections in which
  kernel preemption is to be disabled. Better names welcome.
2007-10-12 13:00:18 +00:00
ad 63c4506184 Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
2007-08-15 12:07:23 +00:00
degroote 0a057fefdd Fix compilation in the POWERHOOK_DEBUG case 2007-08-01 19:50:24 +00:00
christos fbce1923d7 improve on poerhooks debugging. from Anon Ymous 2007-08-01 10:57:07 +00:00
pooka 0a0815b77e Move hashinit() & hashdone() from kern_subr.c to subr_hash.c to
permit standalone compilation.  No functional change.
2007-07-28 12:53:52 +00:00
christos e0e4b56127 autoconfigure dump partition for wedges. 2007-06-24 20:12:34 +00:00
dyoung 1ee8f4a418 Extract common code from i386, xen, and sparc64, creating
config_handle_wedges() and read_disk_sectors().  On x86, handle_wedges()
is a thin wrapper for config_handle_wedges().  Share opendisk()
across architectures.

Add kernel code in support of specifying a root partition by wedge
name.  E.g., root specifications "wedge:wd0a", "wedge:David's Root
Volume" are possible.  (Patches for config(1) coming soon.)

In support of moving disks between architectures (esp. i386 <->
evbmips), I've written a routine convertdisklabel() that ensures
that the raw partition is at RAW_DISK by following these steps:

        0 If we have read a disklabel that has a RAW_PART with
          p_offset == 0 and p_size != 0, then use that raw partition.

        1 If we have read a disklabel that has both partitions 'c'
          and 'd', and RAW_PART has p_offset != 0 or p_size == 0,
          but the other partition is suitable for a raw partition
          (p_offset == 0, p_size != 0), then swap the two partitions
          and use the new raw partition.

        2 If the architecture's raw partition is 'd', and if there
          is no partition 'd', but there is a partition 'c' that
          is suitable for a raw partition, then copy partition 'c'
          to partition 'd'.

        3 Determine the drive's last sector, using either the
          d_secperunit the drive reported, or by guessing (0x1fffffff).
          If we cannot read the drive's last sector, then fail.

        4 If we have read a disklabel that has no partition slot
          RAW_PART, then create a partition RAW_PART.  Make it span
          the whole drive.

        5 If there are fewer than MAXPARTITIONS partitions,
          then "slide" the unsuitable raw partition RAW_PART, and
          subsequent partitions, into partition slots RAW_PART+1
          and subsequent slots.  Create a raw partition at RAW_PART.
          Make it span the whole drive.

The convertdisklabel() procedure can probably stand to be simplified,
but it ought to deal with all but an extraordinarily broken disklabel,
now.

i386: compiled and tested, sparc64: compiled, evbmips: compiled.
2007-06-24 01:43:34 +00:00
dsl b38af594ea Move the #if at the top of trace_enter/exit back above the declaration of 'p'
(where it used to be in rev 1.147) so that this code compiles when none of
the trace options are in use.
Fixes PR kern/36431
2007-06-03 07:47:50 +00:00