summaryrefslogtreecommitdiffstats
path: root/sys/kern
Commit message (Collapse)AuthorAgeFilesLines
* Add a new per-thread private flag: TDP_GEOM.phk2004-10-231-0/+7
| | | | | | | | | | | | | | This flag gets set whenever the thread posts an event on the GEOM event queue, and if the flag is set when the thread is prepared to return to userland from the kernel, g_waitidle() will be called to make sure that the posted events have completed. This can replace an insufficient number of g_waitidle() calls in various other places, and has the advantage of being failsafe: Any system call which does a VOP_OPEN()/VOP_CLOSE will now correctly wait for any geom events it posted as part of spoils or tastes. Assert that topology and Giant is not held in g_waitidle().
* Drop Giant around the call to g_waitidle().phk2004-10-231-0/+2
| | | | This is necessary to allow any geom events which need it to pick up Giant.
* Rebuild from syscalls.master:1.178.rwatson2004-10-232-2/+20
|
* Add system call place-holders for the following system callsrwatson2004-10-231-0/+11
| | | | | | | | | | | | | | | | | implementing Sun's BSM Audit API on FreeBSD: audit() auditon() getauid() setauid() getaudit() setaudit() getaudit_addr() setaudit_addr() auditctl() Submitted by: Wayne Salamon <wsalamon at computer dot org> Obtained from: TrustedBSD Project
* socreate() does an early abort if either the protocol cannot be found,andre2004-10-231-1/+2
| | | | | | | | | | | | or pru_attach is NULL. With loadable protocols the SPACER dummy protocols have valid function pointers for all methods to functions returning just EOPNOTSUPP. Thus the early abort check would not detect immediately that attach is not supported for this protocol. Instead it would correctly get the EOPNOTSUPP error later on when it calls the protocol specific attach function. Add testing against the pru_attach_notsupp() function pointer to the early abort check as well.
* Aquire GIANT in pf_proto_[un]register() before manipulating the protosw.andre2004-10-231-5/+27
|
* Remove P_STOPPED_TRACE bit if debugger dies without a chance todavidxu2004-10-231-1/+1
| | | | detach debugged process.
* Add an annotation to the comment for sysv_ipc.c to indicate that therwatson2004-10-221-2/+6
| | | | | | MAC Framework doesn't require checks in ipcperm() because checks relating to System V IPC will be performed in individual IPC implementations.
* In osethostname(), don't need to call suser() directly asrwatson2004-10-221-4/+2
| | | | | userland_sysctl() will perform all necessary privilege checks for the caller.
* When MAC is enabled, warn if getnewvnode() is asked to produce a vnoderwatson2004-10-221-0/+2
| | | | | | without a mountpoint. In this scenario, there's no useful source for a label on the vnode, since we can't query the mountpoint for the labeling strategy or default label.
* Alas, poor SPECFS! -- I knew him, Horatio; A filesystem of infinitephk2004-10-221-3/+3
| | | | | | | | | | | jest, of most excellent fancy: he hath taught me lessons a thousand times; and now, how abhorred in my imagination it is! my gorge rises at it. Here were those hacks that I have curs'd I know not how oft. Where be your kludges now? your workarounds? your layering violations, that were wont to set the table on a roar? Move the skeleton of specfs into devfs where it now belongs and bury the rest.
* Add b_bufobj to struct buf which eventually will eliminate the need for b_vp.phk2004-10-223-147/+135
| | | | | | | | | | | | | | | | | | Initialize b_bufobj for all buffers. Make incore() and gbincore() take a bufobj instead of a vnode. Make inmem() local to vfs_bio.c Change a lot of VI_[UN]LOCK(bp->b_vp) to BO_[UN]LOCK(bp->b_bufobj) also VI_MTX() to BO_MTX(), Make buf_vlist_add() take a bufobj instead of a vnode. Eliminate other uses of bp->b_vp where bp->b_bufobj will do. Various minor polishing: remove "register", turn panic into KASSERT, use new function declarations, TAILQ_FOREACH_SAFE() etc.
* Move the VI_BWAIT flag into no bo_flag element of bufobj and call it BO_WWAITphk2004-10-214-75/+96
| | | | | | | | | | Add bufobj_wref(), bufobj_wdrop() and bufobj_wwait() to handle the write count on a bufobj. Bufobj_wdrop() replaces vwakeup(). Use these functions all relevant places except in ffs_softdep.c where the use if interlocked_sleep() makes this impossible. Rename b_vnbufs to b_bobufs now that we touch all the relevant files anyway.
* Add BO_* macros parallel to VI_* macros for manipulating the bo_mtx.phk2004-10-211-7/+11
| | | | | | | | | Initialize the bo_mtx when we allocate a vnode i getnewvnode() For now we point to the vnodes interlock mutex, that retains the exact same locking sematics. Move v_numoutput from vnode to bufobj. Add renaming macro to postpone code sweep.
* Polish vtruncbuf() to improve readability and style a bit.phk2004-10-211-49/+42
|
* Simplify buf_vlist_remove().phk2004-10-211-34/+16
| | | | | Now that we have encapsulated the splaytree related information into a structure we can eliminate the half of this function.
* Zero terminate empty sting in kdb_sysctl_available.ups2004-10-211-0/+2
| | | | | Approved by: sam (mentor) MFC after: 1 week
* Modify the vm object locking in do_sendfile() so that the containing objectalc2004-10-201-2/+3
| | | | | | | | | | is locked when vm_page_io_finish() is called on a page. This is to satisfy a new, post-RELENG_5 assertion in vm_page_io_finish(). (I am in the process of transitioning the responsibility for synchronizing access to various fields/flags on the page from the global page queues lock to the per-object lock.) Tripped over by: obrien@
* Support for dynamically loadable and unloadable protocols within existing ↵andre2004-10-193-4/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | protocol families. The protosw[] array of any particular protocol family ("domain") is of fixed size defined at compile time. This made it impossible to dynamically add or remove any protocols to or from it. We work around this by introducing so called SPACER's which are embedded into the protosw[] array at compile time. The SPACER's have a special protocol number (32767) to indicate the fact that they are SPACER's but are otherwise NULL. Only as many protocols can be dynamically loaded as SPACER's are provided in the protosw[] structure. The pr_usrreqs structure is treated more special and contains pointers to dummy functions only returning EOPNOTSUPP. This is needed because the use of those functions pointers is usually not checked within the kernel because until now it was assumed to be a valid function pointer. Instead of fixing all potential callers we just return a proper error code. Two new functions provide a clean API to register and unregister a protocol. The register function expects a pointer to a valid and complete struct protosw including a pointer to struct pru_usrreqs provided by the caller. Upon successful registration the pr_init() function will be called to finish initialization of the protocol. The unregister function restores the SPACER in place of the protocol again. It is the responseability of the caller to ensure proper closing of all sockets and freeing of memory allocation by the unloading protocol. sys/protosw.h o Define generic PROTO_SPACER to be 32767 o Prototypes for all pru_*_notsupp() functions o Prototypes for pf_proto_[un]register() functions kern/uipc_domain.c o Global struct pr_usrreqs nousrreqs containing valid pointers to the pru_*_notsupp() functions o New functions pf_proto_[un]register() kern/uipc_socket2.c o New functions bodies for all pru_*_notsupp() functions
* Push acquisition of the accept mutex out of sofree() into the callerrwatson2004-10-183-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (sorele()/sotryfree()): - This permits the caller to acquire the accept mutex before the socket mutex, avoiding sofree() having to drop the socket mutex and re-order, which could lead to races permitting more than one thread to enter sofree() after a socket is ready to be free'd. - This also covers clearing of the so_pcb weak socket reference from the protocol to the socket, preventing races in clearing and evaluation of the reference such that sofree() might be called more than once on the same socket. This appears to close a race I was able to easily trigger by repeatedly opening and resetting TCP connections to a host, in which the tcp_close() code called as a result of the RST raced with the close() of the accepted socket in the user process resulting in simultaneous attempts to de-allocate the same socket. The new locking increases the overhead for operations that may potentially free the socket, so we will want to revise the synchronization strategy here as we normalize the reference counting model for sockets. The use of the accept mutex in freeing of sockets that are not listen sockets is primarily motivated by the potential need to remove the socket from the incomplete connection queue on its parent (listen) socket, so cleaning up the reference model here may allow us to substantially weaken the synchronization requirements. RELENG_5_3 candidate. MFC after: 3 days Reviewed by: dwhite Discussed with: gnn, dwhite, green Reported by: Marc UBM Bocklet <ubm at u-boot-man dot de> Reported by: Vlad <marchenko at gmail dot com>
* Add new function ttyinitmode() which sets our systemwide defaultphk2004-10-182-18/+30
| | | | | | | | | | | | | | modes on a tty structure. Both the ".init" and the current settings are initialized allowing the function to be used both at attach and open time. The function takes an argument to decide if echoing should be enabled. Echoing should not be enabled for regular physical serial ports unless they are consoles, in which case they should be configured by ttyconsolemode() instead. Use the new function throughout.
* If a process needs to be swapped in, wakeup the swapper from withinscottl2004-10-162-5/+9
| | | | | | | | | critical_exit as the process is getting scheduled to run. This is subotimal but for now avoid the LOR between the scheduler and the sleepq systems. This is a 5.3 candidate. Submitted by: davidxu MFC After: 3 days
* Make pty's always come up in echo mode.phk2004-10-152-2/+2
|
* Add missing chunk of code to enforce the lock-bits of termios.phk2004-10-141-1/+26
| | | | | | | This solves the problem where serial consoles suddenly required DCD to be asserted. Reported by: Randy Bush <randy@psg.com>
* Update flags patch for the !ISA case.njl2004-10-141-5/+14
| | | | | | | | | | | | * Get flags first, in case there is no devclass. * Reset flags after each probe in case the next driver has no hints so it doesn't inherit the old ones. * Set them again before the winning probe. Tested ok both with and without ACPI for ISA device flags. Reviewed by: imp MFC after: 1 day
* /me gets the wrong patch out of the pr :(jmg2004-10-141-2/+2
| | | | | | | /me had the write patch w/o comments on his test system. Pointed out by: kuriyama and ache Pointy hat to: jmg
* Fix maybe_preempt_in_ksegrp for !SMP.ups2004-10-131-7/+33
| | | | | | | Tested by: tegge Reviewed by: julian Approved by: sam (mentor) MFC after: 3 days
* fix a bug where signal events didn't set the flags for attach/detach..jmg2004-10-131-0/+2
| | | | | PR: 72234 MFC after: 2 days
* Set flags for devices before probing them. In the non-ISA case, flags setnjl2004-10-131-1/+5
| | | | | | | via hints were not getting passed to the child. PR: kern/72489 MFC after: 1 day
* Don't call driver close unless we have one.phk2004-10-121-2/+4
|
* Make !SMP kernels compile, and as far as I can tell, work again.phk2004-10-121-1/+2
|
* Whitespace fix.jhb2004-10-121-1/+1
|
* Refine the turnstile and sleep queue interfaces just a bit:jhb2004-10-125-49/+89
| | | | | | | | | | | | | | | | | | | | | | | | | - Add a new _lock() call to each API that locks the associated chain lock for a lock_object pointer or wait channel. The _lookup() functions now require that the chain lock be locked via _lock() when they are called. - Change sleepq_add(), turnstile_wait() and turnstile_claim() to lookup the associated queue structure internally via _lookup() rather than accepting a pointer from the caller. For turnstiles, this means that the actual lookup of the turnstile in the hash table is only done when the thread actually blocks rather than being done on each loop iteration in _mtx_lock_sleep(). For sleep queues, this means that sleepq_lookup() is no longer used outside of the sleep queue code except to implement an assertion in cv_destroy(). - Change sleepq_broadcast() and sleepq_signal() to require that the chain lock is already required. For condition variables, this lets the cv_broadcast() and cv_signal() functions lock the sleep queue chain lock while testing the waiters count. This means that the waiters count internal to condition variables is no longer protected by the interlock mutex and cv_broadcast() and cv_signal() now no longer require that the interlock be held when they are called. This lets consumers of condition variables drop the lock before waking other threads which can result in fewer context switches. MFC after: 1 month
* Add a WITNESS_WARN() to uiomove() to whine if locks are held when thisjhb2004-10-121-0/+2
| | | | | | function is called. MFC after: 1 month
* Directly modifying the priority of a thread that may be on the runqueueups2004-10-121-1/+1
| | | | | | | | | can break the sorting order of the ksegp run queue. Tested by: pho Reviewed by: jhb, julian Approved by: sam (mentor) MFC: ASAP
* Prevent preemption in slot_fill.ups2004-10-121-1/+110
| | | | | | | | | | Implement preemption between threads in the same ksegp in out of slot situations to prevent priority inversion. Tested by: pho Reviewed by: jhb, julian Approved by: sam (mentor) MFC: ASAP
* Force MUTEX_WAKE_ALL.ups2004-10-121-0/+9
| | | | | | | | | A race condition in single thread wakeup may break priority inheritance. Tested by: pho Reviewed by: jhb,julian Approved by: sam (mentor) MFC: ASAP
* Add missing zero flag arguments to calls to userland_sysctl()phk2004-10-122-9/+10
|
* Put on my peril sensitive sunglasses and add a flags field to the internalpeter2004-10-114-21/+54
| | | | | | | | | | | | | | | | sysctl routines and state. Add some code to use it for signalling the need to downconvert a data structure to 32 bits on a 64 bit OS when requested by a 32 bit app. I tried to do this in a generic abi wrapper that intercepted the sysctl oid's, or looked up the format string etc, but it was a real can of worms that turned into a fragile mess before I even got it partially working. With this, we can now run 'sysctl -a' on a 32 bit sysctl binary and have it not abort. Things like netstat, ps, etc have a long way to go. This also fixes a bug in the kern.ps_strings and kern.usrstack hacks. These do matter very much because they are used by libc_r and other things.
* Rename _m_tag_free() to m_tag_free_default() and make it non-static.glebius2004-10-111-3/+3
| | | | Approved by: sam
* Add entropy harvest mutex to hard-coded spin lock witness lock order,rwatson2004-10-111-2/+1
| | | | | | | | remove previous entropy harvesting mutex names as they are no longer present. Commit to this file was ommitted when randomdev_soft.c:1.5 was made. Feet shot: Robert Huff <roberthuff at rcn dot com>
* Rework sofree() logic to take into account a possible race with accept().rwatson2004-10-111-5/+19
| | | | | | | | | | | | | | | | | | | | | | Sockets in the listen queues have reference counts of 0, so if the protocol decides to disconnect the pcb and try to free the socket, this triggered a race with accept() wherein accept() would bump the reference count before sofree() had removed the socket from the listen queues, resulting in a panic in sofree() when it discovered it was freeing a referenced socket. This might happen if a RST came in prior to accept() on a TCP connection. The fix is two-fold: to expand the coverage of the accept mutex earlier in sofree() to prevent accept() from grabbing the socket after the "is it really safe to free" tests, and to expand the logic of the "is it really safe to free" tests to check that the refcount is still 0 (i.e., we didn't race). RELENG_5 candidate. Much discussion with and work by: green Reported by: Marc UBM Bocklet <ubm at u-boot-man dot de> Reported by: Vlad <marchenko at gmail dot com>
* Revert last commit since it breaks API.glebius2004-10-101-10/+5
| | | | Requested by: sam
* Don't release the slot twice.. sched_rem() has already done it.julian2004-10-101-1/+0
| | | | | Submitted by: stephan uphoff (ups at tree dot com) MFC after: 3 days
* Remove duplicate line.julian2004-10-101-1/+0
|
* Remove inlined m_tag_free(). Rename _m_tag_free() to m_tag_free()glebius2004-10-091-6/+11
| | | | | | | | | | | | and make it visible (same way as in OpenBSD). Describe usage in manpage. This change is useful for creating custom free methods, which call default free method at their end. While here, make malloc declaration for mbuf tags more informative. Approved by: julian (mentor), sam MFC after: 1 month
* Don't "implicitly order all sleep locks before spin locks" in witnessgreen2004-10-091-1/+1
| | | | | | when the spin lock in question isn't -- it's the critical_enter() that KDB set. No more panic in DDB for console -> syscons -> tty -> knote operations.
* Add an execve command for kse_thr_interrupt to allow libpthread todavidxu2004-10-072-3/+19
| | | | | | restore signal mask correctly, this is required by POSIX. Reviewed by: deischen
* Regen to unbreak world.davidxu2004-10-072-2/+2
| | | | Pointy hat to: mtm
* Back out rev 1.240; it is unnecessary. In particular,das2004-10-061-8/+3
| | | | | | | p1 == curthread, so _PHOLD(p1) will not have to block to swap in p1. Noticed by: jhb
OpenPOWER on IntegriCloud