summaryrefslogtreecommitdiffstats
path: root/sys/kern/init_main.c
Commit message (Collapse)AuthorAgeFilesLines
* Release Giant before starting up init.jhb2000-09-151-1/+3
| | | | Submitted by: jake
* Move the include of <sys/systm.h> so that KTR gets a declaration fordfr2000-09-101-1/+1
| | | | snprintf().
* Major update to the way synchronization is done in the kernel. Highlightsjasone2000-09-071-8/+25
| | | | | | | | | | | | | | | include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh
* Remove uidinfo hash table lookup and maintenance out of chgproccnt() andtruckman2000-09-051-1/+3
| | | | | | | | | | | | | | chgsbsize(), which are called rather frequently and may be called from an interrupt context in the case of chgsbsize(). Instead, do the hash table lookup and maintenance when credentials are changed, which is a lot less frequent. Add pointers to the uidinfo structures to the ucred and pcred structures for fast access. Pass a pointer to the credential to chgproccnt() and chgsbsize() instead of passing the uid. Add a reference count to the uidinfo structure and use it to decide when to free the structure rather than freeing the structure when the resource consumption drops to zero. Move the resource tracking code from kern_proc.c to kern_resource.c. Move some duplicate code sequences in kern_prot.c to separate helper functions. Change KASSERTs in this code to unconditional tests and calls to panic().
* Avoid the modules madness I inadvertently introduced by making thephk2000-09-021-5/+6
| | | | | | | | | | | | | | | | | | cloning infrastructure standard in kern_conf. Modules are now the same with or without devfs support. If you need to detect if devfs is present, in modules or elsewhere, check the integer variable "devfs_present". This happily removes an ugly hack from kern/vfs_conf.c. This forces a rename of the eventhandler and the standard clone helper function. Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include like <sys/queue.h> Remove all #includes of opt_devfs.h they no longer matter.
* Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)phk2000-08-201-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove old DEVFS support fields from dev_t. Make uid, gid & mode members of dev_t and set them in make_dev(). Use correct uid, gid & mode in make_dev in disk minilayer. Add support for registering alias names for a dev_t using the new function make_dev_alias(). These will show up as symlinks in DEVFS. Use makedev() rather than make_dev() for MFSs magic devices to prevent DEVFS from noticing this abuse. Add a field for DEVFS inode number in dev_t. Add new DEVFS in fs/devfs. Add devfs cloning to: disk minilayer (ie: ad(4), sd(4), cd(4) etc etc) md(4), tun(4), bpf(4), fd(4) If DEVFS add -d flag to /sbin/inits args to make it mount devfs. Add commented out DEVFS to GENERIC
* Clean up some low level bootstrap code:peter2000-08-111-97/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - stop using the evil 'struct trapframe' argument for mi_startup() (formerly main()). There are much better ways of doing it. - do not use prepare_usermode() - setregs() in execve() will do it all for us as long as the p_md.md_regs pointer is set. (which is now done in machdep.c rather than init_main.c. The Alpha port did it this way all along and is much cleaner). - collect all the magic %cr0 etc register settings into one place and have the AP's call that instead of using magic numbers (!!) that keep changing over and over again. - Make it safe to call kthread_create() earlier, including during the device probe sequence. It doesn't need the callback mechanism that NetBSD's version uses. - kthreads created this way are root-less as they exist before the root filesystem is mounted. init(1) is set up so that it aquires the root pointers prior to running. If other kthreads want filesystem acccess we can make this code more generic. - set all threads start times once we have decided what time it is. - init uses a trampoline rather than the evil prepare_usermode() hack. - kern_descrip.c has a couple of tweaks to deal with forking when there is no rootdir or cwd etc. - adjust the early SYSINIT() sequence so that a few prereqisites are in place. eg: make sure the run queue is initialized before doing forks. With this, the USB code can easily create a kthread to do the device tree discovery. (I have tested it, it works nicely). There are still some open issues before this is truely useful. - tsleep() does not like working before the clock is running. It sort-of tries to spin wait, but it can do more useful things now. - stopping a kthread in kld code at unload time is "interesting" but we have a solution for that. The Alpha code needs no changes for this. It already uses pretty much the same strategies, but a little cleaner.
* Fix the SYSINIT() bubble sort. This was fixed in kern_linker.c already.peter2000-08-021-1/+1
|
* Remove no-longer-relevant comment.markm2000-06-251-1/+0
|
* fix races in the uidinfo subsystem, several problems existed:alfred2000-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 1) while allocating a uidinfo struct malloc is called with M_WAITOK, it's possible that while asleep another process by the same user could have woken up earlier and inserted an entry into the uid hash table. Having redundant entries causes inconsistancies that we can't handle. fix: do a non-waiting malloc, and if that fails then do a blocking malloc, after waking up check that no one else has inserted an entry for us already. 2) Because many checks for sbsize were done as "test then set" in a non atomic manner it was possible to exceed the limits put up via races. fix: instead of querying the count then setting, we just attempt to set the count and leave it up to the function to return success or failure. 3) The uidinfo code was inlining and repeating, lookups and insertions and deletions needed to be in their own functions for clarity. Reviewed by: green
* Add new oid, debug.boothowto. This allows userland apps to seejkh2000-02-251-0/+1
| | | | | | | | | how the kernel was booted and perhaps do conditional things based upon it (sysinstall, for example, will now turn Debug mode on automatically if boot -v was done). Submitted by: msmith Suggested by: ulf
* If we fail to find init, print out the search path used. This helpsgrog1999-12-201-1/+1
| | | | | | | | | | differentiate between one of three different scenarios: 1. No init. 2. Path to init munged by an incorrect loader configuration. 3. Root file system not mounted. Reviewed-by: billf
* struct mountlist and struct mount.mnt_list have no business beingphk1999-11-201-1/+1
| | | | | | | | | | a CIRCLEQ. Change them to TAILQ_HEAD and TAILQ_ENTRY respectively. This removes ugly mp != (void*)&mountlist comparisons. Requested by: phk Submitted by: Jake Burkholder jake@checker.org PR: 14967
* This is a partial commit of the patch from PR 14914:phk1999-11-161-1/+1
| | | | | | | | | | | | | Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY structures for list operations. This patch makes all list operations in sys/kern use the queue(3) macros, rather than directly accessing the *Q_{HEAD,ENTRY} structures. This batch of changes compile to the same object files. Reviewed by: phk Submitted by: Jake Burkholder <jake@checker.org> PR: 14914
* swapinit isn't called from vfs_mountroot, so don't complain about it inmsmith1999-11-011-18/+0
| | | | | | | a #if 0'ed comment. Call the machine-dependant cpu_rootconf functions from sysinits in their respective areas, don't do it from a stub here.
* useracc() the prequel:phk1999-10-291-1/+0
| | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument.
* Trim unused options (or #ifdef for undoc options).peter1999-10-111-1/+0
| | | | Submitted by: phk
* Moved the definition of `boottime' and its sysctl to the correct file.bde1999-09-131-4/+0
|
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Convert DEVFS hooks in (most) drivers to make_dev().phk1999-08-231-2/+1
| | | | | | | | | | | | | | | | Diskslice/label code not yet handled. Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers) Add the correct hook for devfs to kern_conf.c The net result of this excercise is that a lot less files depends on DEVFS, and devtoname() gets more sensible output in many cases. A few drivers had minor additional cleanups performed relating to cdevsw registration. A few drivers don't register a cdevsw{} anymore, but only use make_dev().
* Slight reorganization of kernel thread/process creation. Instead of usingpeter1999-07-011-83/+27
| | | | | | | | | | | | | | | SYSINIT_KT() etc (which is a static, compile-time procedure), use a NetBSD-style kthread_create() interface. kproc_start is still available as a SYSINIT() hook. This allowed simplification of chunks of the sysinit code in the process. This kthread_create() is our old kproc_start internals, with the SYSINIT_KT fork hooks grafted in and tweaked to work the same as the NetBSD one. One thing I'd like to do shortly is get rid of nfsiod as a user initiated process. It makes sense for the nfs client code to create them on the fly as needed up to a user settable limit. This means that nfsiod doesn't need to be in /sbin and is always "available". This is a fair bit easier to do outside of the SYSINIT_KT() framework.
* Slight tweak to fork1() calling conventions. Add a third argument sopeter1999-06-301-7/+6
| | | | | | | | the caller can easily find the child proc struct. fork(), rfork() etc syscalls set p->p_retval[] themselves. Simplify the SYSINIT_KT() code and other kernel thread creators to not need to use pfind() to find the child based on the pid. While here, partly tidy up some of the fork1() code for RF_SIGSHARE etc.
* Use colons instead of semi-colons to behave like UNIX instead of DOS.jb1999-05-111-4/+4
| | | | Suggested by: bde
* Lites2 seems to have pretty much disappeared from the radar, and I suspectpeter1999-05-091-5/+2
| | | | far more than this hack would be needed now..
* s/main/mi_startup/ for the kernel entry point so that egcs doesn't getpeter1999-05-091-13/+6
| | | | | | | | upset about it (and generate things like __main() calls that are reserved for main()). Renaming was phk's suggestion, but I'd already thought about it too. (phk liked my suggested name tada() but I decided against it :-) Reviewed by: phk
* Nit fix.des1999-05-071-2/+2
|
* Allow the init_path to be customised in an embedded system using thejb1999-05-051-3/+8
| | | | | | | INIT_PATH config option. Also fix two bugs which caused an infinite loop in none of the programs in the init_path were found. That code was obviously not tested!
* Add sysctl descriptions to many SYSCTL_XXXsbillf1999-05-031-3/+3
| | | | | | | PR: kern/11197 Submitted by: Adrian Chadd <adrian@FreeBSD.org> Reviewed by: billf(spelling/style/minor nits) Looked at by: bde(style)
* Set curproc at the end of proc0_init().dt1999-04-291-7/+4
| | | | | | | | | | | This patch also moves the bogus comment (the comment is still not quite right) and (as a side effect) removes some verbose initialisations (we depend on static initialisation to 0 for almost everything in proc0). The alpha kernels are bootable again. The change won't affect i386's until machdep.c is changed. Submitted by: bde
* This Implements the mumbled about "Jail" feature.phk1999-04-281-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a seriously beefed up chroot kind of thing. The process is jailed along the same lines as a chroot does it, but with additional tough restrictions imposed on what the superuser can do. For all I know, it is safe to hand over the root bit inside a prison to the customer living in that prison, this is what it was developed for in fact: "real virtual servers". Each prison has an ip number associated with it, which all IP communications will be coerced to use and each prison has its own hostname. Needless to say, you need more RAM this way, but the advantage is that each customer can run their own particular version of apache and not stomp on the toes of their neighbors. It generally does what one would expect, but setting up a jail still takes a little knowledge. A few notes: I have no scripts for setting up a jail, don't ask me for them. The IP number should be an alias on one of the interfaces. mount a /proc in each jail, it will make ps more useable. /proc/<pid>/status tells the hostname of the prison for jailed processes. Quotas are only sensible if you have a mountpoint per prison. There are no privisions for stopping resource-hogging. Some "#ifdef INET" and similar may be missing (send patches!) If somebody wants to take it from here and develop it into more of a "virtual machine" they should be most welcome! Tools, comments, patches & documentation most welcome. Have fun... Sponsored by: http://www.rndassociates.com/ Run for almost a year by: http://www.servetheweb.com/
* Enable vmspace sharing on SMP. Major changes are,luoqi1999-04-281-4/+1
| | | | | | | | | | | | | | | | | - %fs register is added to trapframe and saved/restored upon kernel entry/exit. - Per-cpu pages are no longer mapped at the same virtual address. - Each cpu now has a separate gdt selector table. A new segment selector is added to point to per-cpu pages, per-cpu global variables are now accessed through this new selector (%fs). The selectors in gdt table are rearranged for cache line optimization. - fask_vfork is now on as default for both UP and SMP. - Some aio code cleanup. Reviewed by: Alan Cox <alc@cs.rice.edu> John Dyson <dyson@iquest.net> Julian Elischer <julian@whistel.com> Bruce Evans <bde@zeta.org.au> David Greenman <dg@root.com>
* Fixed printf format errors on alpha.dt1999-04-241-3/+5
|
* Make the location of init(8) tunable at boot time.des1999-04-201-16/+29
|
* Removed all traces of `p_switchtime'. The relevant timestamp is per-cpu,bde1999-02-281-2/+2
| | | | | | | | | | | | | not per-process. Keep it in `switchtime' consistently. It is now clear that the timestamp is always valid in fork_trampoline() except when the child is running on a previously idle cpu, which can only happen if there are multiple cpus, so don't check or set the timestamp in fork_trampoline except in the (i386) SMP case. Just remove the alpha code for setting it unconditionally, since there is no SMP case for alpha and the code had rotted. Parts reviewed by: dfr, phk
* Don't forget to update `switchticks' in corner cases (except forbde1999-02-251-5/+4
| | | | | the alpha fork_trampoline(), forget it because it I believe it is only necessary for the unsupported SMP case).
* Hide access to vmspace:vm_pmap with inline function vmspace_pmap(). Thisluoqi1999-02-191-3/+3
| | | | | | | is the preparation step for moving pmap storage out of vmspace proper. Reviewed by: Alan Cox <alc@cs.rice.edu> Matthew Dillion <dillon@apollo.backplane.com>
* Initialize procsig0.ps_refcnt to 1 (instead of 2), this would silenceluoqi1999-02-171-2/+2
| | | | | | | | complaints about ps_refcnt greater than two when we try to fork() a kthread from proc0 with RFSIGSHARE flag set. Noticed by: Tor Egge <tegge@fast.no> Reviewed by: Richard Seaman, Jr. <dick@tar.com>
* Remove unused "kern.shutdown_timeout" sysctl node.msmith1999-01-301-5/+1
|
* More const fixes for -Wall, -Wcast-qualdillon1999-01-291-3/+3
|
* More -Wall / -Wcast-qual cleanup. Also, EXEC_SET can't usedillon1999-01-291-3/+3
| | | | | C_DECLARE_MODULE due to the linker_file_sysinit() function making modifications to the data.
* Enable Linux threads support by default.julian1999-01-261-5/+1
| | | | | | | | | This takes the conditionals out of the code that has been tested by various people for a while. ps and friends (libkvm) will need a recompile as some proc structure changes are made. Submitted by: "Richard Seaman, Jr." <dick@tar.com>
* Changes to the LINUX_THREADS support to only allocate extra memory forjulian1999-01-071-11/+1
| | | | | | | | | | | | | | | | | | | | | | shared signal handling when there is shared signal handling being used. This removes the main objection to making the shared signal handling a standard ability in rfork() and friends and 'unconditionalising' this code. (i.e. the allocation of an extra 328 bytes per process). Signal handling information remains in the U area until such a time as it's reference count would be incremented to > 1. At that point a new struct is malloc'd and maintained in KVM so that it can be shared between the processes (threads) using it. A function to check the reference count and move the struct back to the U area when it drops back to 1 is also supplied. Signal information is therefore now swapable for all processes that are not sharing that information with other processes. THis should addres the concerns raised by Garrett and others. Submitted by: "Richard Seaman, Jr." <dick@tar.com>
* Various changes to support OSF1 emulation:dfr1998-12-301-2/+2
| | | | | | | | | | | * Move the user stack from VM_MAXUSER_ADDRESS to a place below the 32bit boundary (needed to support 32bit OSF programs). This should also save one pagetable per process. * Add cvtqlsv to the set of instructions handled by the floating point software completion code. * Disable all floating point exceptions by default. * A minor change to execve to allow the OSF1 image activator to support dynamic loading.
* Fix two bogons created by 'patch(1)' in my last commit.julian1998-12-191-2/+3
|
* Reviewed by: Luoqi Chen, Jordan Hubbardjulian1998-12-191-1/+19
| | | | | | | | | | | | Submitted by: "Richard Seaman, Jr." <lists@tar.com> Obtained from: linux :-) Code to allow Linux Threads to run under FreeBSD. By default not enabled This code is dependent on the conditional COMPAT_LINUX_THREADS (suggested by Garret) This is not yet a 'real' option but will be within some number of hours.
* Fix sysinit_add().peter1998-10-151-13/+17
| | | | | - Don't include multiple copies of the previous sysinit in the new one. - Leave space for and explicitly null terminate the new list.
* Implement merging SYSINIT's from preloaded KLD modules. This means wepeter1998-10-091-12/+68
| | | | | | | | | | | check off SYSINIT entries as they are run, and when more arrive, we re-sort and restart (skipping the already-run entries). This can *only* be done after KMEM (and malloc) is up and running - this is fine because KLD is the only consumer of this and it's done after that. The nice thing about this is that the SYSINIT's within preloaded KLD modules are executed in their natural order. It should be possible to register devices for the probes which follow, etc. (soon.. several key things prevent this, such as use of linker sets for things like pci devices).
* Make sure that the argv pointers for init are aligned to the correctdfr1998-10-061-2/+2
| | | | boundary on the alpha.
* Remove the SLICE code.sos1998-09-141-6/+1
| | | | | This clearly needs alot more thought, and we dont need this to hunt us down in 3.0-RELEASE.
* Cast pointers to intptr_t instead of or before casting to long.bde1998-07-151-5/+5
| | | | | | | | | | | | Fixed bitrot in K&R support (suword() now takes a long word). Didn't fix corresponding bitrot in store.9 and fetch.9. The correct types for the store and fetch families are problematic. The `word' functions are unfortunately named and need to be split to handle ints/longs/object pointers/function pointers. Storing argv[] as longs is quite broken when longs are longer than pointers, but usually works because it clobbers variables that will soon be reinitialized.
OpenPOWER on IntegriCloud