Commit Graph

7148 Commits

Author SHA1 Message Date
manu dd47ec7336 Back out previous change: do not skip the test on rootspec, but make it
a simple attempt instead of an authoritative answer. The failure of the
rootspec test could me machine-dependant. Thanks to martin@ for pointing
that out.
2009-08-23 12:10:50 +00:00
dyoung 210a227e29 In sysctl_realloc(), don't make 'i' act as both an child-array
iterator and the length of the old child array, but introduce a
new variable, 'olen', for the latter purpose.

In sysctl_alloc(), name a constant.

Introduce sysctl_log_print(), a handy debug routine.

No functional changes intended.
2009-08-21 22:51:00 +00:00
dyoung 5a3627a2a6 Make sure that a sysctlnode's child nodes, even nodes that are not
yet in service, have a correct pointer to their parent, sysctl_parent.
This fixes a bug where sysctl_teardown(9) could not clean up a
network interface's sysctl(9) trees when I detached it, because
the wrong log had been recorded.
2009-08-21 22:43:32 +00:00
manu 61a1c8cdd1 When netbooting, rootspec is now "md0a", and it has no chance to match
an interface name, so do not give it a try.
2009-08-21 09:20:47 +00:00
yamt f97310f398 whitespace fixes. no functional changes. 2009-08-18 02:43:49 +00:00
christos a9d1bfd0c5 provide compatibility for the older variant of kern.consdev, which used
a 32 bit dev_t. Reported by mrg.
2009-08-16 20:28:19 +00:00
yamt 273f17a18a kauth_cred_free: add an assertion. 2009-08-16 11:01:12 +00:00
yamt 77d977dcbc assertion 2009-08-16 11:00:20 +00:00
yamt d59302b0e4 struct lwp -> lwp_t for consistency 2009-08-16 10:59:25 +00:00
haad 5f6671a94a Allow undescribed, direct ioctls as used by Unix. This capability was removed in BSD, presumably because nothing used it any more.
Third party system software written for Unix (like ZFS) requires this to work without significant modifications.

Ok supremeleader@
2009-08-13 08:57:43 +00:00
haad 5200b9b492 Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions
can be called from kernel, too.

Change needed for zfs device node creation, until we have propoer devfs.

Oked by ad@.
2009-08-09 22:49:00 +00:00
dholland f821ac304a Begin splitting lookup() into more tractable pieces too. 2009-08-09 07:27:54 +00:00
dholland 40c09fbf2c Begin splitting up namei into smaller pieces. 2009-08-09 03:28:35 +00:00
dsl 3d8c11d579 ktrace the arguments to script interpreters that come from the script.
Fixes PR/33021
2009-08-06 21:33:54 +00:00
dsl 8b926bc93c Fix ktrace of data from iovec based system calls.
Fixes PR/41819
2009-08-05 19:53:42 +00:00
dsl 8129ef72eb lockf() passes its arguments through to fcntl() but is supposed to
support -ve lengths (lock area before current offset).
Nothing in libc or the kernel allowed for this, so some random part
of the file would get locked (no idea which bits).
Although this could probably be fixed in libc, the stubs for posix file
locks for emulations could easily get into the kernel with -ve lengths.
So fixing in the kernel avoids those problems.
This also fixes PR/41620 (attempting to lock negative offsets) - which
is what I was looking into!
2009-08-05 19:39:50 +00:00
bad 0152c542e8 Add a note to change_root() that the callers need to authorize the operation.
As requested by elad@.
2009-08-02 20:44:55 +00:00
christos f1cd8c73cb Don't return EWOULDBLOCK on an O_NONBLOCK tty file descriptor that has vmin > 0
and vtime > 0. It should be allowed to go to sleep for the sleep interval
indicated in vtime. Reported by der Mouse a long while ago, and this is what
other unixes do.
2009-08-01 23:07:05 +00:00
bad 02bcf17298 As discussed on tech-kern:
Factor out common code of chroot-like syscalls into change_root() and export
that function for use in other parts of the kernel.
Rename change_dir() to chdir_lookup() as the latter describes better what
the function does.  While there, move the namei_data initialisation into
chdir_lookup(), too.  And export chdir_lookup().
2009-08-01 21:17:11 +00:00
mbalmer 9d8b69b23a Do not attach gpiosim(4) at root, but make it a pseudo device.
With help from Matthias Drochner, thanks!
2009-07-27 17:40:57 +00:00
mbalmer 953ebaaf3d Allow gpiosim(4) to attach if configured in the kernel configuration. 2009-07-25 16:23:39 +00:00
christos 47736ab62e check return code from soreserve() (Sean Boudreau) 2009-07-24 01:09:49 +00:00
pooka 39de73aae0 +fhopen, +fhstatvfs1 RUMP 2009-07-21 23:59:00 +00:00
yamt 0436400c70 set LP_RUNNING when starting lwp0 and idle lwps.
add assertions.
2009-07-19 10:11:55 +00:00
rmind db98cd9499 Regen. 2009-07-19 02:54:21 +00:00
rmind 7512d1e720 Make POSIX message queues a kernel module. 2009-07-19 02:50:44 +00:00
rmind b95f99b9f9 Fix previous, so that it actually works, correctly. 2009-07-19 02:26:49 +00:00
ad 5c5bb856e1 Don't send the quiet banner to the log, since the usual noise gets dumped
there anyway.
2009-07-17 23:31:51 +00:00
dyoung b734bafe0e Fix spelling: situatations -> situations. 2009-07-17 22:17:37 +00:00
dyoung b43b2d186c A definition in aic79xxvar.h somehow shadows pci_attach_args (ctags
bug?), so leave  it out of the tags computation for now.
2009-07-16 23:53:10 +00:00
rmind 569aa0de8b Revert previous: disable direct I/O on pipe, it cought a problem with emap. 2009-07-15 21:09:41 +00:00
apb dfcfba79d8 Convert free text inside #ifdef to a proper comment.
Inspired by PR 41255 from Kurt Lidl.
2009-07-14 20:59:00 +00:00
tsutsui 46133c54ef Add a workaround for some traditional ports (amiga and atari):
- Defer callout_setfunc() call after config_init() call in configure().

Fixes silent hang before consinit() at least on atari.

These traditional ports use config(9) structures and
autoconf(9) functions to detect console devices, and
config_init() is called at very early stage at boot
where mutex(9) is not ready.

Actually config_init() has been split out from configure()
for these ports:
http://cvsweb.NetBSD.org/bsdweb.cgi/src/sys/kern/subr_autoconf.c#rev1.74
while x68k has been fixed properly:
http://mail-index.NetBSD.org/source-changes/2009/01/17/msg215673.html

See also:
http://mail-index.NetBSD.org/port-x68k/2008/12/31/msg000006.html
http://mail-index.NetBSD.org/port-atari/2009/07/03/msg000419.html
2009-07-14 13:24:00 +00:00
rmind f80b636295 Re-enable direct I/O for pipe:
- Larger writes (2 or more pages) will use emap.
- Might help to catch rare hang (some very old bug).
2009-07-13 02:49:08 +00:00
rmind 7e069f82fb - Make insertion to message queue O(1) by using bitmap and array. However,
mq_prio_max is dynamic, and sorted list is used for custom setup, when
  user manually sets higher priority range.
- Cache mq->mq_attrib in some places.  Change msg_ptr type to uint8_t.
- Update copyright, misc.
2009-07-13 02:37:12 +00:00
rmind b83b94a98e mq_send/mq_receive: while permission may allow that, return EBADF if sending
to read-only queue, or receiving from write-only queue.

From Stathis Kamperis, thanks!
2009-07-13 00:41:08 +00:00
dyoung 2261ca8c07 In lwp_create(), take a reference to l2's filedesc_t instead of
taking a reference to curlwp's by calling fd_hold().  If lwp_create()
is called from fork1(), then l2 != curlwp, but l2's and not curlwp's
filedesc_t whose reference we should take.

This change stops the problem I describe in
<http://mail-index.netbsd.org/tech-kern/2009/07/09/msg005422.html>,
where /dev/rsd0a is never properly closed after fsck / runs on it.
This change seems to quiet my USB backup drive, sd0 at scsibus0 at
umass0, which had stopped spinning down when it was not in use:
The unit probably stayed open after mount(8) tried (and failed:
errant fstab entry) to mount it.

I am confident that this change is an improvement, but I doubt that
it is the last word on the matter.  I hate to get under the filedesc_t
abstraction by fiddling with fd_refcnt, and there may be something
I have missed, so somebody with greater understanding of the file
descriptors code should have a look.
2009-07-10 23:07:54 +00:00
dyoung bfd7452af9 pmf_event_inject(9) may be called from interrupt context, so we
must not allocate a pmf_event_workitem_t using kmem_alloc(9).  Use
pool_cache(9), instead, because it is safe in interrupt context.
Thanks, rmind@, for catching the problem and suggesting the solution.
2009-07-08 18:53:36 +00:00
joerg 73df1b22f7 Remove unused include. 2009-07-06 12:37:17 +00:00
elad 518bb3e503 Message queues also use genfs_can_access() to control access. Since the
latter might lose its KAUTH_GENERIC_ISSUSER check soon, add an internal
function, mqueue_access(), and call genfs_can_access() from it instead
so we don't pollute the main code path once we need to add a special
kauth(9) check for message queues.

No functional change, error codes preserved.

Related mailing list thread:

	http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005311.html
2009-07-03 21:32:09 +00:00
pooka 1a0b832e88 expose mkdir to in-kernel consumers 2009-07-02 12:53:47 +00:00
martin 53822d1e78 Update fd_freefile when kqueue descriptors are not copied from
parent to child. From Wolfgang Solfrank in PR kern/41651.
Approved by Andrew Doran.
2009-06-30 20:32:49 +00:00
yamt 6d375e715d update a comment 2009-06-29 23:39:00 +00:00
dyoung c53d86bdf2 Fix a typo in last (coda/ exclusion). 2009-06-29 18:03:37 +00:00
dholland effcf1af5c Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 05:08:15 +00:00
dholland acfecf55d7 Add namei_simple_kernel and namei_simple_user. These provide the common
case functionality of namei in a simple package with only a couple flags.

A substantial majority of the namei call sites in the kernel can use
this interface; this will isolate those areas from the changes arising
as the internals of namei are fumigated.
2009-06-29 05:00:14 +00:00
rmind fe55ad324c panic: use MI cpu_index(), instead of cpu_number(), which could be sparse. 2009-06-28 15:30:30 +00:00
rmind 5c68e5d0ee Ephemeral mapping (emap) implementation. Concept is based on the idea that
activity of other threads will perform the TLB flush for the processes using
emap as a side effect.  To track that, global and per-CPU generation numbers
are used.  This idea was suggested by Andrew Doran; various improvements to
it by me.  Notes:

- For now, zero-copy on pipe is not yet enabled.
- TCP socket code would likely need more work.
- Additional UVM loaning improvements are needed.

Proposed on <tech-kern>, silence there.
Quickly reviewed by <ad>.
2009-06-28 15:18:50 +00:00
rmind 7b7c187a92 Amend previous. 2009-06-28 14:34:48 +00:00
rmind 39b52425ff - Convert some #ifdefs to KASSERT()s.
- KNF, style, no parameters in function declarations.
- No functional changes.
2009-06-28 14:22:11 +00:00
yamt 85542b11cd wrap a long line. 2009-06-28 11:42:07 +00:00
ad 5b4feac126 idle_loop: explicitly go to spl0() to sidestep potential MD bugs. 2009-06-28 09:25:05 +00:00
dyoung b4f24be356 sys/coda/ rudely re-#defines some kernel constants and such, so
leave it out of the tags for now.
2009-06-26 22:59:25 +00:00
dyoung 9d9978e5a5 Switch to kmem(9).
(void *)pew is one way to get a struct work *, but let's
write&pew->pew_work, instead.  It is more defensive and persuasive.

Make miscellaneous changes in support of tearing down arbitrary
stacks of filesystems and devices during shutdown:

1 Move struct shutdown_state, shutdown_first(), and shutdown_next(),
  from kern_pmf.c to subr_autoconf.c.  Rename detach_all() to
  config_detach_all(), and move it from kern_pmf.c to subr_autoconf.c.
  Export all of those routines.

2 In pmf_system_shutdown(), do not suspend user process scheduling, and
  do not detach all devices: I am going to do that in cpu_reboot(),
  instead.  (Soon I will do it in an MI cpu_reboot() routine.)  Do still
  call PMF shutdown hooks.

3 In config_detach(), add a DIAGNOSTIC assertion: if we're exiting
  config_detach() at the bottom, alldevs_nwrite had better not be 0,
  because config_detach() is a writer of the device list.

4 In deviter_release(), check to see if we're iterating the device list
  for reading, *first*, and if so, decrease the number of readers.  Used
  to be that if we happened to be reading during shutdown, we ran the
  shutdown branch.  Thus the number of writers reached 0, the number
  of readers remained > 0, and no writer could iterate again.  Under
  certain circumstances that would cause a hang during shutdown.
2009-06-26 19:30:45 +00:00
dyoung 57a3ffeae7 Cosmetic: remove #if 1 / #endif. 2009-06-26 18:58:14 +00:00
dyoung 0b429bf76a Keep a generation number, mountgen, that increases every time a
filesystem is mounted.  Synchronize access to the number with a
mutex.  When a struct mount, mp, is allocated, assign the current
generation number to mp->mnt_gen.  Introduce vfs_unmount_forceone()
that forcefully unmounts the most recently mounted filesystem.

Refactor: extract vfs_shutdown1() from vfs_shutdown().  Extract
vfs_sync_all() from vfs_shutdown1().

Print more progress indications while we're unmounting all of the
filesystems during shutdown.

We increase the reference count on mp before calling dounmount(mp),
but we do not decrease it if dounmount(mp) fails, and neither does
dounmount(mp).  So decrease the reference count if dounmount(mp)
fails.

Change the loop terminating condition in vfs_unmountall1() to (mp
!= (void *)&mountlist) from !CIRCLEQ_EMPTY(&mountlist), because we
may not ever empty the list, especially if we're not forcing the
filesystems to unmount.
2009-06-26 18:53:07 +00:00
christos 2ee7096547 magic symlink cleanup:
- use size_t for len
- don't call strlen multiple times in macro
- add gid
- off by one in bounds calculation
2009-06-26 15:49:03 +00:00
elad 55f182207a Wow... too much Python.
Fix DIAGNOSTIC build breakage: print -> printf.

Pointed out by Kurt Schreiner on current-users@:

    http://mail-index.netbsd.org/current-users/2009/06/23/msg009815.html
2009-06-23 23:04:11 +00:00
elad 870920260d Move the implementation of vaccess() to genfs_can_access(), in line with
the other routines of the same spirit.

Adjust file-system code to use it.

Keep vaccess() for KPI compatibility and to keep element of least
surprise. A "diagnostic" message warning that vaccess() is deprecated will
be printed when it's used (obviously, only in DIAGNOSTIC kernels).

No objections on tech-kern@:

	http://mail-index.netbsd.org/tech-kern/2009/06/21/msg005310.html
2009-06-23 19:36:38 +00:00
cegger 4765113ada Return type of cpu_number(9) is cpuid_t which is effectively unsigned long.
So cast return type to unsigned long.
Fixes build for alpha GENERIC kernel.
2009-06-20 11:10:40 +00:00
mrg 8520c31093 when printing a ddb stack trace when entering ddb, include the cpu number 2009-06-18 06:26:58 +00:00
dyoung 61fa5bb9be Make kobj_stat() return ENOSYS instead of panicking ("not modular")
on non-MODULAR kernels.  Make a few kobj_stat() callers check for
a non-zero return code and deal gracefully.
2009-06-17 21:04:25 +00:00
kardel a888100516 Make PPS work with fast time counters (> 2GHz)
by making the pps count time stamp and the update
time stamp u_int64.
The time delta between two PPS events can now
be correctly calculated avoiding any unaccounted
for wraps with 32-bit counters.
2009-06-14 13:16:32 +00:00
plunky 6e74f4625b Writes on the controlling tty were not being awoken from blocks,
use the correct condvar to make this happen.

this fixes PR/41566
2009-06-12 09:26:50 +00:00
yamt 1a7984dbf3 do_posix_fadvise:
- deactivate pages on POSIX_FADV_DONTNEED.
	- more sanity checks.  fix a panic in genfs_getpages
	  introduced by the previous (rev.1.15).
2009-06-10 23:48:10 +00:00
yamt 724fd50176 don't make F_GETLK or the common case of F_UNLCK fail for per-user limit. 2009-06-10 22:34:35 +00:00
yamt 5216f042b0 lf_split: cv_destroy a condvar before clobbering it. 2009-06-10 22:23:15 +00:00
yamt 1763b7795c do_posix_fadvise: on POSIX_FADV_WILLNEED, start prefeching of object's pages. 2009-06-10 01:56:34 +00:00
jnemeth cbd3656645 Add the MODCTL_NO_PROP flag to tell the kernel to ignore <module>.prop.
Add the '-P' option to modload(8) to set this flag.
2009-06-09 20:35:02 +00:00
jnemeth 32b670979a Add code to merge the modload "command line" with <module>.prop. 2009-06-09 19:09:03 +00:00
yamt 5c0faad4bd fd_free: fix posix advisory locks. PR/41549 from HITOSHI OSADA. 2009-06-08 00:19:56 +00:00
jnemeth 1bdbe18dce Read in a <module>.prop file if it exists and internalize then pass it
to the <module> being loaded.

XXX A <module>.prop file will override anything on the "command line".
This will be fixed in the next commit.
2009-06-07 09:47:31 +00:00
yamt 6f174f1311 shut up the following assertion failure and add a comment.
panic: kernel diagnostic assertion "!fd_isused(fdp, fd)" failed: file "/siro/nbsd/src/sys/kern/kern_descrip.c", line 175
2009-06-07 09:39:02 +00:00
jnemeth fa6c059bce add KASSERT(p != NULL); to kmem_free() 2009-06-03 22:54:51 +00:00
pooka 48fb37f153 opt for _KERNEL_OPT 2009-06-03 15:07:30 +00:00
pooka b89c189be7 Declare extern syscallnames in a header. 2009-06-02 23:21:37 +00:00
yamt de0c01fd1d do_posix_fadvise: turn some KASSERTs into CTASSERTs. 2009-05-31 22:15:13 +00:00
yamt 31a7ec7dc7 sched_pstats_hook: fix estcpu decay.
this makes my desktop usable when running "make -j4".
2009-05-31 04:13:33 +00:00
dyoung 2bc3b9efe1 In config_detach(9), if device deactivation fails with EOPNOTSUPP,
don't treat it as an error.  This should stop the kernel from
panicking in config_detach(9) when sd(4)/wd(4) detach.
2009-05-29 23:27:08 +00:00
yamt 75c4e4fde7 fd_free: reset fd_himap/lomap to make fd_checkmaps comfortable. PR/41487. 2009-05-29 00:10:52 +00:00
yamt 4f22237449 wrap a long line. 2009-05-28 22:17:04 +00:00
pooka 8027ac8f1f Make domaininit() take an argument which determines if it should
add the special PF_ROUTE domain or not (if available).
2009-05-27 23:44:35 +00:00
hannken 5b4e527c76 PR kern/39536: bufq related problem when writing DVDR and DVDRWs.
Remove a race where physio_done() may use memory already freed.

Observed by Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>.
2009-05-26 14:59:31 +00:00
jnemeth d73b80a12b Move all namei flags handling into kobj_load_file().
When I originally wrote this, I was going for maximum flexibility.
However, after a private discussion with dholland@, I see how this
will cause problems with the future world order of namei whenever
that might be.  At the moment, I don't need the extra flexibility,
but if something comes up this may have to be revisited.
2009-05-26 08:34:22 +00:00
elad ae660023a4 PR/41489: Stathis Kamperis: etpriority(2) returns EACCES instead of EPERM
Per discussion on the PR's audit trail, put back original checks for now.
2009-05-26 06:57:38 +00:00
ad 0913d2e2f5 PR kern/41487: kern_descrip.c assertion failure
Remove bogus assertion.
2009-05-26 00:42:33 +00:00
rmind 75f55a05eb - Slightly rework the way permissions are checked. Neither mq_receive() not
mq_send() should fail due to permissions.  Noted by Stathis Kamperis!
- Check for empty message queue name (POSIX does not allow this for regular
  files, and it's weird), check for DTYPE_MQUEUE, fix permission check in
  mq_unlink(), clean up.
2009-05-26 00:39:14 +00:00
jnemeth a15ece476a Phase 0.5 of my options MODULAR enhancements. As suggested by ad@,
these commits move all path handling into module_do_load() from
kobj_load_file().  This way the final path used to load a module
is available for loading <module>.plist, which will store parameters
for a module.  The end goal of this project is good support for
MODULAR device drivers.
2009-05-25 22:33:00 +00:00
ad d991fcb3b6 More changes to improve kern_descrip.c.
- Avoid atomics in more places.
- Remove the per-descriptor mutex, and just use filedesc_t::fd_lock.
  It was only being used to synchronize close, and in any case we needed
  to take fd_lock to free the descriptor slot.
- Optimize certain paths for the <NDFDFILE case.
- Sprinkle more comments and assertions.
- Cache more stuff in filedesc_t.
- Fix numerous minor bugs spotted along the way.
- Restructure how the open files array is maintained, for clarity and so
  that we can eliminate the membar_consumer() call in fd_getfile().  This is
  mostly syntactic sugar; the main functional change is that fd_nfiles now
  lives alongside the open file array.

Some measurements with libmicro:

- simple file syscalls are like close() are between 1 to 10% faster.
- some nice improvements, e.g. poll(1000) which is ~50% faster.
2009-05-24 21:41:25 +00:00
ad 193d553767 Split out kobj structures so crash/ddb can get at them. 2009-05-24 15:00:24 +00:00
ad 27695c89cb ddb: don't try to stat builtin modules. 2009-05-24 14:54:17 +00:00
ad 7d20bf2a9e Bus scans can make it appear as if the system has paused, so
twiddle constantly while config_interrupts() jobs are running.
2009-05-24 12:27:50 +00:00
ad 3cb7a24bec Make descriptor access and file allocation cheaper in many cases,
mostly by avoiding a bunch of atomic operations.
2009-05-23 18:28:05 +00:00
ad f0545a5e5b - Add lwp_pctr(), get an LWP's preemption/ctxsw counter.
- Fix a preemption bug in CURCPU_IDLE_P() that can lead to a bogus
  assertion failure on DEBUG kernels.
- Fix MP/preemption races with timecounter detachment.
2009-05-23 18:21:20 +00:00
ad 2fc2b08001 - Add lwp_pctr(), get an LWP's preemption/ctxsw counter.
- Fix a preemption bug in CURCPU_IDLE_P() that can lead to a bogus
  assertion failure on DEBUG kernels.
- Fix MP/preemption races with timecounter detachment.
2009-05-23 17:08:04 +00:00
ad cb95ab6e35 Fix a crash observed when trying to load a corrupted ELF image. 2009-05-23 15:13:57 +00:00
dyoung 85d8d1fcdd On second thought, let's call disk_predetach() disk_begindetach().
Verbs are good.
2009-05-20 03:26:21 +00:00
dyoung a76a7fd159 Encapsulate the checks that I do before detaching a disk(9) provider
in a pre-detachment routine, disk_predetach().
2009-05-19 23:42:05 +00:00
bouyer 8ebd73cde8 Back out rev 1.27 now that MD implementations of spl*() have been fixed
to be a memory barrier.
2009-05-18 21:31:27 +00:00
ad 77e6671be0 - Remove unneded uvm_lwp_hold(), uvm_lwp_rele().
- Make physio_concurrency tuneable via crash(8).
- Update comments.
2009-05-18 21:12:33 +00:00
ad 92ee1731b0 Updates to f_flag need to be made with atomics. 2009-05-17 10:08:38 +00:00
yamt 7e13bf31c7 remove FILE_LOCK and FILE_UNLOCK. 2009-05-17 05:54:42 +00:00
rmind ba3fa2c82f sys_mq_open: remove broken access flag check.
Noted by Stathis Kamperis.
2009-05-16 23:58:09 +00:00
yamt 5368015c69 sysctl_doeproc:
- simplify.
	- KERN_PROC: fix possible stale proc pointer dereference.
	- KERN_PROC: don't do copyout with proc_lock held.
2009-05-16 12:02:00 +00:00
yamt 805df27570 rw_vector_exit: remove a redundant condition. 2009-05-16 08:36:32 +00:00
yamt 513f4955a7 put a flag bit into v_usecount to prevent vtryget during getcleanvnode.
this fixes the following deadlock.

	a thread doing getcleanvnode:
	pick a vnode
	acqure v_interlock
	v_usecount++
	call vclean

		now, another thread doing cache_lookup:
		picks the vnode
		vtryget succeed
		vn_lock succeed

	now in vclean:
	set VI_XLOCK (too late to be noticed by the competing thread)
	wait on the vnode lock (this might violate locking order)

the use of a flag bit was suggested by Andrew Doran.  PR/41374.
2009-05-16 08:29:53 +00:00
pooka e8f5dfa79e regen: pad -> PAD 2009-05-15 15:52:39 +00:00
pooka 6c68c84345 Use argname PAD to signal that an argument is used only for padding
and not part of the C interface.  Use this information for rump
syscalls to generate syscall interfaces without the extra parameter.
2009-05-15 15:51:27 +00:00
pooka 500fdd36a7 In addition to off_t alignment, check for dev_t and time_t too
(we don't currently have any syscalls passing time_t, though)
2009-05-15 14:52:47 +00:00
yamt d4da6c3d2e don't forget to skip marker processes. 2009-05-12 11:42:12 +00:00
yamt bed2400e59 lockdebug fixes for rw_tryupgrade/rw_downgrade. 2009-05-09 03:33:10 +00:00
yamt 9031548af6 exit1: fix a race with do_sys_wait/proc_free. 2009-05-08 13:32:59 +00:00
bouyer f48b5c49cc Declare sh_flags volatile.
Without it, on ports where splhigh() is inline, the compiler will optimise
the second SOFTINT_PENDING test in softint_schedule(). A dissasembly
of softint_schedule() with and without the volatile sh_flags confirm this
on sparc.
Because of this there is a race that could lead to the softhand_t
being enqueued twice on si_q, leading to a corrupted queue and
some handler being SOFTINT_PENDING but never called.

Should fix PR kern/38637
2009-05-05 20:26:36 +00:00
yamt 183ff8793d sysctl_doeproc: fix a bug in rev.1.135.
don't forget to mark our marker process PK_MARKER.
this fixes crashes in sched_pstats, etc.
2009-05-04 14:52:33 +00:00
yamt 6f0983460b when freeing cn_pnbuf, make it NULL if DIAGNOSTIC. 2009-05-04 06:05:19 +00:00
yamt 706e6928e0 tweak some assertions on so_head to make them more meaningful. 2009-05-04 06:02:40 +00:00
elad 414eb0a314 Move dovfsusermount to secmodel_bsd44, where it really belongs.
The secmodel code now creates the same knob in two places: both under the
secmodel itself, as well as the widely known location.

Mailing list references:

    http://mail-index.netbsd.org/source-changes/2009/05/02/msg220641.html
    http://mail-index.netbsd.org/tech-kern/2009/05/03/msg005015.html
2009-05-03 21:25:44 +00:00
pooka ec3ee0abf9 Include some debug print routines if DEBUGPRINT is defined. This
way they can be included without having to include DDB.
(arguably all print routines should be behind #ifdef DEBUGPRINT
and options DDB should define that macro, but I'll tackle that later)
2009-05-03 16:52:54 +00:00
elad b1bd59c577 Fix locking around mountlist usage, as pointed out by ad@ in:
http://mail-index.netbsd.org/source-changes-d/2009/04/22/msg000322.html
  http://mail-index.netbsd.org/tech-kern/2009/04/22/msg004897.html

Use vfs_busy() and vfs_unbusy(), and properly iterate the mountlist.
2009-05-02 21:47:12 +00:00
pooka fb42667d02 Move dovfsusermount from vfs_syscalls.c to param.c: secmodel bsd44
depends on it and we can't isolate it in vfs.
(no, it doesn't really belong in param.c, but I couldn't figure out
a better place for it)
2009-05-02 14:13:28 +00:00
cegger f2c0b025dc remove useless parenthesis 2009-05-01 08:27:41 +00:00
ad 922436b4c6 PR kern/41311: Mutex error: mutex_vector_enter: locking against myself 2009-04-30 20:41:33 +00:00
dyoung 662437b2c3 Remove extraneous parentheses. Fix spelling/grammar. No functional
change intended.
2009-04-30 20:39:08 +00:00
nonaka 3c6a17f5ff include sys/lwp.h for curlwp. 2009-04-30 05:15:36 +00:00
dyoung dfec23a174 Extract vfs_unmountall1() from vfs_unmountall() for reuse. 2009-04-29 15:44:55 +00:00
dyoung 3e0a641f96 Extract common code from vfs_rootmountalloc(9) and mount_domount() into
a new struct mount-allocation routine, vfs_mountalloc(9).  Documentation
updates will follow.

Attention: Synchronization Oversight Committee!  In mount_domount(),
I postpone the call mutex_enter(&mp->mnt_updating) until right before
the VFS_MOUNT(9) call because (1) that looks to me like the earliest
possible opportunity for mp to become visible to any other LWP, because
it was just kmem_zalloc(9)'d and (2) it made extracting the common code
much easier.  Tell me if my reasoning is faulty.
2009-04-29 01:03:43 +00:00
dyoung 5c35d469c9 Cosmetic: remove unnecessary parentheses. 2009-04-28 20:56:40 +00:00
dyoung 9777865b42 Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.
2009-04-28 20:54:50 +00:00
skrll 15c5c4397e copyin the modctl_load_t for the non-x86 world. Fixes PR/41294. 2009-04-28 17:57:00 +00:00
yamt a6f64ec082 do_sys_utimes: fix a bug introduced by rev.1.367.
VA_UTIMES_NULL is in va_vaflags, not va_flags.
2009-04-28 03:01:15 +00:00
elad bab57db991 Replace a NULL check that can never fire with a KASSERT().
Okay ad@.

(this change was originally part of the following commit:
    http://mail-index.netbsd.org/source-changes/2009/04/25/msg220346.html)
2009-04-25 18:53:43 +00:00
rmind 440e5485e0 - Rearrange pg_delete() and pg_remove() (renamed pg_free), thus
proc_enterpgrp() with proc_leavepgrp() to free process group and/or
  session without proc_lock held.
- Rename SESSHOLD() and SESSRELE() to  to proc_sesshold() and
  proc_sessrele().  The later releases proc_lock now.

Quick OK by <ad>.
2009-04-25 15:06:31 +00:00
ad 9b7896c50a A workaround for a bug with some Opteron revisions where locked operations
sometimes do not serve as memory barriers, allowing memory references to
bleed outside of critical sections.  It's possible that this is the
reason for pkgbuild's longstanding crashiness.

For rwlocks, always enable the explicit membars. They were disabled only
on x86, and since they are not in the fast-path it's not a big deal.
TODO: convert these to an atomic_membar_foo() or similar that does ordering
between regular data references and atomic references.
2009-04-24 17:53:06 +00:00
elad f68b0219b0 Per discussion on tech-kern@:
- Replace use of label/goto with returns

  - Rename, change prototype of, and move functions from vfs_subr.c to
    genfs_vnops.c
2009-04-22 22:57:08 +00:00
yamt 091b54f602 fix an indentation error. no functional change. 2009-04-21 00:02:37 +00:00
elad d4cc1b437c PR/41251: YAMAMOTO Takashi: veriexec locking seems broken
Part 1: Take the mountlist_lock before traversing the mount list.
2009-04-20 22:09:54 +00:00
elad 386808d4a0 Refactor some duplicated file-system code.
Proposed and received no objections on tech-kern@:

	http://mail-index.netbsd.org/tech-kern/2009/04/18/msg004843.html
2009-04-20 18:06:26 +00:00
ad 4d8f47ae2f cpuctl:
- Add interrupt shielding (direct hardware interrupts away from the
  specified CPUs). Not documented just yet but will be soon.

- Redo /dev/cpu time_t compat so no kernel changes are needed.

x86:

- Make intr_establish, intr_disestablish safe to use when !cold.

- Distribute hardware interrupts among the CPUs, instead of directing
  everything to the boot CPU.

- Add MD code for interrupt sheilding. This works in most cases but there is
  a bug where delivery is not accepted by an LAPIC after redistribution. It
  also needs re-balancing to make things fair after interrupts are turned
  back on for a CPU.
2009-04-19 14:11:36 +00:00
ad d857e7b19e call rw_obj_init() 2009-04-19 14:04:51 +00:00
ad a8bd3c39aa Add rw_obj_*() functions to mirror the existing mutex functions.
Proposed on tech-kern quite some time ago.
2009-04-19 08:36:04 +00:00
tsutsui d779b85d3e Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
2009-04-18 14:58:02 +00:00
dyoung d2a5799226 Do not interleave device detachment with device shutdown. Instead, try
over and over to detach all of the devices.  Stop when we cannot detach
even a single device in a cycle.  Call shutdown hooks on all of the
devices that remain attached.

This is another step toward the detach/unmount cycle that will help us
tear down arbitrary stacks of filesystems, ccd(4), raid(4), and vnd(4).
2009-04-17 20:45:09 +00:00
dyoung b29e491b07 Make vfs_unmountall() return true if it was able to unmount any
filesystem at all, false otherwise.  This will support tearing down
stacks of filesystems, ccd(4), raid(4), and vnd(4).

Change the misleading variable name 'allerror' to 'any_error'.  Make it
a bool.
2009-04-17 20:22:52 +00:00
ad acf9701a7e kpreempt: fix another bug, uintptr_t -> bool truncation. 2009-04-16 21:19:23 +00:00
rmind d062d5d72b - Manage pid_table with kmem(9).
- Remove M_PROC and unused M_SESSION.
2009-04-16 14:56:41 +00:00
rmind 71923f262a Replace malloc with kmem(9). 2009-04-16 14:55:44 +00:00
skrll cc65188940 0 -> NULL 2009-04-16 07:47:16 +00:00
rmind 523acc7d68 Avoid few #ifdef KSTACK_CHECK_MAGIC. 2009-04-16 00:17:19 +00:00
elad 2d1c968399 Remove a few KAUTH_GENERIC_ISSUSER in favor of more descriptive
alternatives.

Discussed on tech-kern:

	http://mail-index.netbsd.org/tech-kern/2009/04/11/msg004798.html

Input from ad@, christos@, dyoung@, tsutsui@.

Okay ad@.
2009-04-15 20:44:24 +00:00
yamt 87984ef060 pool_cache_put_paddr: add an assertion. 2009-04-15 11:45:18 +00:00