Commit Graph

69 Commits

Author SHA1 Message Date
christos 4e47272b6b Don't require a file if CLEAR is set [did not work before because we
could have the descend flag too]
2003-04-03 18:54:16 +00:00
pk 2931081a79 Make updating a file's reference and use count MP-safe. 2003-02-23 14:37:32 +00:00
thorpej e0d8d366df Merge the nathanw_sa branch. 2003-01-18 10:06:22 +00:00
manu 4a06119a9d Pass the system call table to trace_enter() and ktrsys() so that it is
possible to use alternate system call tables. This is usefull for
displaying correctly the arguments in Mach binaries traces.

If NULL is given, then the regular systam call table for the process is used.
2002-12-21 16:23:56 +00:00
gmcgarry 74da856861 yield() -> preempt(). 2002-12-20 05:06:25 +00:00
manu 5ba396cfb3 Added support for exchange of Mach messages between processes.
This does not buy us new functionnality for now, because we still have to
discover how mach_init (which acts as a name server, enabling processes to
discover each other's ports) is able to receive messages from other processes
(this is a bootstrap problem, and the bootstrap port might be the place to
search).

While we are there:
- removed a lot of debug which is now available using ktrace.
- reworked message handling to avoid mutliple copyin/copyout of the
same data. ktrace of Mach message now uses the in-kernel copy of the
message instead of copying it from userland.
- packed mach trap handlers arguments into a structure to avoid modifying
everything next time we have to add an argument.
2002-12-17 18:42:54 +00:00
christos 80564fa341 always compile in mach ktrace support; it is to small to bother. 2002-12-12 17:40:40 +00:00
manu 6492e2171f Added support for dumping mach messages in ktrace/kdump. While we are
there, KNFify a few functions.
2002-12-09 21:29:20 +00:00
manu d584ed9598 Add a realcode argument to trace_enter and ktrsyscall. realcode is the
original system call number, which can be negative for a Mach trap.
We cannot just replace code by realcode, because ktrsyscall uses it as
an index in the system call table, thus crashing the kernel when the
value is negative.
2002-11-15 20:06:00 +00:00
thorpej dccc71f1fe Fix signed/unsigned comparison warnings. 2002-11-10 03:28:59 +00:00
jdolecek e0cc03a09b merge kqueue branch into -current
kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
2002-10-23 09:10:23 +00:00
itojun 67c6a98161 disallow ktrace on P_SUGID. from openbsd 2002-06-28 01:59:36 +00:00
fvdl 87b285ba0d Repair damage done in systrace commit. Since argsize is nog longer
passed, assume it's sy_narg * sizeof (register_t). The code
made this assumption implicitly anyway. Fixes compat_*32 tracing.
2002-06-18 08:01:30 +00:00
christos acf2d4083d Niels Provos systrace work, ported to NetBSD by kittenz and reworked... 2002-06-17 16:22:50 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
thorpej 80cc38a1af Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads.  What we do is stick descriptors in the table, but
mark them as "larval".  This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again.  When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
2001-06-14 20:32:41 +00:00
jdolecek d7f811d098 utrace(2): limit size of user data to KTR_USER_MAXLEN (currently 2048); return EINVAL if 'len' is bigger 2001-01-05 22:25:26 +00:00
jdolecek fbc7e223d7 utrace(2): rename 'id' parameter to 'label' 2001-01-05 21:42:08 +00:00
jdolecek a80dee65df add utrace(2) - this syscall allows to add user ktrace entries
idea from FreeBSD, but added argument (const char *id) so that it's possible
to differentiate between entries from different sources
2000-12-28 11:10:15 +00:00
scw 96698d967e Change struct emul's "char e_name[8]" field to "const char *e_name"
to allow for emulation names >= 8 characters.
2000-12-19 22:08:36 +00:00
martin ac28b114d2 Make this compilable again on ports without __HAVE_SYSCALL_INTERN. 2000-12-11 19:53:06 +00:00
mycroft 11fcbfe7a6 Call e_syscall_intern every time ktrace flags are modified. 2000-12-11 16:39:01 +00:00
thorpej cd32ace8bb ANSI'ify. 2000-08-01 04:57:28 +00:00
thorpej 956b3ca3b3 Track which process a CPU is running/has last run on by adding a
p_cpu member to struct proc.  Use this in certain places when
accessing scheduler state, etc.  For the single-processor case,
just initialize p_cpu in fork1() to avoid having to set it in the
low-level context switch code on platforms which will never have
multiprocessing.

While I'm here, comment a few places where there are known issues
for the SMP implementation.
2000-05-31 05:02:31 +00:00
sommerfeld a3edbba355 Add null-pointer tests in ktrsamefile 2000-05-29 22:29:01 +00:00
sommerfeld 879eaa480a Fix clearing of ktrace points:
- need deep compare of open files, not a shallow pointer compare.
 - reorder fdrelease()/FILE_UNUSE() invocations so fdrelease doesn't
block waiting for something which can't happen until after it returns.
2000-05-29 22:04:11 +00:00
sommerfeld a56cb94b43 Deal with NULL file pointer for KTROP_CLEAR 2000-05-28 15:27:51 +00:00
sommerfeld 40339b39f9 Reduce use of curproc in several places:
- Change ktrace interface to pass in the current process, rather than
p->p_tracep, since the various ktr* function need curproc anyway.

 - Add curproc as a parameter to mi_switch() since all callers had it
handy anyway.

 - Add a second proc argument for inferior() since callers all had
curproc handy.

Also, miscellaneous cleanups in ktrace:

 - ktrace now always uses file-based, rather than vnode-based I/O
(simplifies, increases type safety); eliminate KTRFLAG_FD & KTRFAC_FD.
Do non-blocking I/O, and yield a finite number of times when receiving
EWOULDBLOCK before giving up.

 - move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

 - simplify interface to ktrwrite()
2000-05-27 00:40:29 +00:00
thorpej a7d0570e67 First sweep at scheduler state cleanup. Collect MI scheduler
state into global and per-CPU scheduler state:

	- Global state: sched_qs (run queues), sched_whichqs (bitmap
	  of non-empty run queues), sched_slpque (sleep queues).
	  NOTE: These may collectively move into a struct schedstate
	  at some point in the future.

	- Per-CPU state, struct schedstate_percpu: spc_runtime
	  (time process on this CPU started running), spc_flags
	  (replaces struct proc's p_schedflags), and
	  spc_curpriority (usrpri of processes on this CPU).

	- Every platform must now supply a struct cpu_info and
	  a curcpu() macro.  Simplify existing cpu_info declarations
	  where appropriate.

	- All references to per-CPU scheduler state now made through
	  curcpu().  NOTE: this will likely be adjusted in the future
	  after further changes to struct proc are made.

Tested on i386 and Alpha.  Changes are mostly mechanical, but apologies
in advance if it doesn't compile on a particular platform.
2000-05-26 21:19:19 +00:00
thorpej bc074bcbcf ktrgenio(): __predict_false() ktrwrite() failing.
ktrwrite(): __predict_true() no error occuring.
2000-05-08 20:01:05 +00:00
thorpej c6fa58a322 - Allocate the ktrace operation header on the stack rather than using
MALLOC()/FREE().
- In ktrgenio():
	- Don't allocate the entire size of the I/O for the temporary
	  buffer used to write the data to the trace file.  Instead,
	  do it in page-sized chunks.
	- As in uiomove(), preempt the process if we are hogging the CPU.
	- If writing to the trace file errors, abort rather than continuing
	  to loop through the buffer.

From Artur Grabowski <art@stacken.kth.se>, with some additional cleanup
by me.
2000-04-19 19:14:17 +00:00
darrenr 8b165c84f7 don't log an error for ktrace if it's EPIPE - an error that should be
expected with fktrace/ktruss (i.e the error is `noise').
1999-07-25 13:59:08 +00:00
thorpej ea8fb3e04a Turn the proclist lock into a read/write spinlock. Update proclist locking
calls to reflect this.  Also, block statclock rather than softclock during
in the proclist locking functions, to address a problem reported on
current-users by Sean Doran.
1999-07-25 06:30:33 +00:00
thorpej 01a8cffe77 Add a read/write lock to the proclists and PID hash table. Use the
write lock when doing PID allocation, and during the process exit path.
Use a read lock every where else, including within schedcpu() (interrupt
context).  Note that holding the write lock implies blocking schedcpu()
from running (blocks softclock).

PID allocation is now MP-safe.

Note this actually fixes a bug on single processor systems that was probably
extremely difficult to tickle; it was possible that schedcpu() would run
off a bad pointer if the right clock interrupt happened to come in the
middle of a LIST_INSERT_HEAD() or LIST_REMOVE() to/from allproc.
1999-07-22 21:08:30 +00:00
thorpej e3669c3393 Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
1999-05-05 20:01:01 +00:00
kleink bff1bef006 * Add a comment to ktrgetheader() mentioning that ktr_len and ktr_buf are
being left uninitialized intentionally; addresses PR kern/6987.
* In ktrsysret(), initialize the unused ktr_eosys to avoid writing random junk.
1999-04-11 18:44:00 +00:00
mycroft fb526e055c Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
  versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
  sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
  sys_sigpending() and sys_sigsuspend() into separate functions, and call them
  from all the emulations rather than hard-coding everything.  (Avoids uses
  the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
  pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
  bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
  in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified.  Other ports and
emulations need to be updated.
1998-09-11 12:50:05 +00:00
perry 275d1554aa Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) ->  memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
   bcmp(x, y, z) ->  memcmp(x, y, z)
  bzero(x, y)    ->  memset(x, 0, y)
1998-08-04 04:03:10 +00:00
perry 730baa7431 fix sizeofs so they comply with the KNF style guide. yes, it is pedantic. 1998-07-31 22:50:48 +00:00
thorpej a4a34ba74a Add two additional arguments to the fileops read and write calls, a
pointer to the offset to use, and a flags word.  Define a flag that
specifies whether or not to update the offset passed by reference.
1998-06-30 05:33:11 +00:00
thorpej 808867c7cf defopt KTRACE 1998-06-25 21:17:15 +00:00
christos 02cecf686a New fktrace syscall from Darren Reed [with fixes from me] 1998-05-02 18:33:19 +00:00
mycroft f327fee4ca Fix KTROP_CLEARFILE so it does the same thing as KTROP_CLEAR (i.e. vrele()
rather than vn_close()).  Fixes PR 5357.
1998-04-28 22:27:22 +00:00
mrg f0fc5e8ca7 remove register from decl. 1998-03-29 05:19:43 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
mycroft 04daee4f9c Add const where appropriate. 1997-10-19 02:00:19 +00:00
christos 09afd77655 More proto fixes 1996-02-09 18:59:18 +00:00
christos 8a5b1b92e2 First pass at prototyping 1996-02-04 02:15:01 +00:00
christos 16c4374c1f Make the ktrace code emit a record that indicates the current emulation
every time there is an attach or detach event.
1995-10-22 00:35:06 +00:00
mycroft 245f292fed Prefix names of system call implementation functions with `sys_'. 1995-10-07 06:25:19 +00:00