Commit Graph

186 Commits

Author SHA1 Message Date
christos 7bd0e983e2 PR/24750: Frank Kardel: panic when process is signalled during
proc initialization.
2004-03-11 22:34:26 +00:00
matt 1b4f540b78 Look at _UC_STACK to decide whether the process' SS_ONSTACK state needs to
be updated.  (This is needed to be compatible with how pre-SIGINFO signals
operated.  If you siglongjmp out of a signal handler, the SS_ONSTACK state
needs to be cleared.  This commit restores that functionality).
2004-03-04 00:05:58 +00:00
manu ffb3de5522 Move the sigfilter hook to a more adequate location, and rename it to better
fit what it does.

The softsignal feature is used in Darwin to trace processes. When the
traced process gets a signal, this raises an exception. The debugger will
receive the exception message, use ptrace with PT_THUPDATE to pass the
signal to the child or discard it, and then it will send a reply to the
exception message, to resume the child.

With the hook at the beginnng of kpsignal2, we are in the context of the
signal sender, which can be the kill(1) command, for instance. We cannot
afford to sleep until the debugger tells us if the signal should be
delivered or not.

Therefore, the hook to generate the Mach exception must be in the traced
process context. That was we can sleep awaiting for the debugger opinion
about the signal, this is not a problem. The hook is hence located into
issignal, at the place where normally SIGCHILD is sent to the debugger,
whereas the traced process is stopped. If the hook returns 0, we bypass
thoses operations, the Mach exception mecanism will take care of notifying
the debugger (through a Mach exception), and stop the faulting thread.
2003-12-24 22:53:59 +00:00
fvdl d99705e941 Put back Emmanuel's sigfilter hooks, as decided by Core. 2003-12-20 19:01:29 +00:00
jdolecek 0e253cf5f5 back the sigfilter emulation hook change off 2003-12-05 21:12:42 +00:00
manu 18e13eee35 Add a sigfilter emulation hook. It is used at the beginning of kpsignal2()
so that a specific emulation has the oportunity to filter out some signals.

if sigfilter returns 0, then no signal is sent by kpsignal2().

There is another place where signals can be generated: trapsignal. Since this
function is already an emulation hook, no call to the sigfilter hook was
introduced in trapsignal.

This is needed to emulate the softsignal feature in COMPAT_DARWIN (signals
sent as Mach exception messages)
2003-12-03 20:24:51 +00:00
manu d662d7555d Make the wakeup optionnal in proc_stop, so that it is possible to stop a
process without waking up its parent.
2003-11-27 23:16:47 +00:00
christos d0d2881501 expose proc_stop; needed by mach/darwin emulation 2003-11-17 19:21:56 +00:00
dsl 0342c9586a - Count number of zombies and stopped children and requeue them at the top
of the sibling list so that find_stopped_child can be optimised to avoid
  traversing the entire sibling list - helps when a process has a lot of
  children.
- Modify locking in pfind() and pgfind() to that the caller can rely on the
  result being valid, allow caller to request that zombies be findable.
- Rename pfind() to p_find() to ensure we break binary compatibility.
- Remove svr4_pfind since p_find willnow do the job.
- Modify some of the SMP locking of the proc lists - signals are still stuffed.

Welcome to 1.6ZF
2003-11-12 21:07:37 +00:00
cl 66c8bc7693 Reimplement VP donation such that multiple unblocked upcalls can be
combined.  Also prepare for adding VP repossession later.

- kern_sa.c: sa_yield/sa_switch: detect if there are pending unblocked
  upcalls.
- kern_sa.c: sa_unblock_userret/sa_setwoken: queue LWPs about to invoke
  an unblocked upcall on the sa_wokenq.  put queued LWPs in a state where
  they can be put in the cache.  notify LWP on the VP about pending
  upcalls.
- kern_sa.c: sa_upcall_userret: check sa_wokenq for pending upcalls,
  generate unblocked upcalls with multiple event sas
- kern_sa.c: sa_vp_repossess/sa_vp_donate: g/c, restore original
  sa_vp_repossess
2003-11-03 22:34:51 +00:00
cl 763d8350f0 perform indention change left out of previous commit 2003-11-02 16:30:55 +00:00
cl 350dd95eff Cleanup signal delivery for SA processes:
General idea:  only consider the LWP on the VP for signal delivery, all
other LWPs are either asleep or running from waking up until repossessing
the VP.

- in kern_sig.c:kpsignal2: handle all states the LWP on the VP can be in
- in kern_sig.c:proc_stop: only try to stop the LWP on the VP.  All other
  LWPs will suspend in sa_vp_repossess() until the VP-LWP donates the VP.
  Restore original behaviour (before SA-specific hacks were added) for
  non-SA processes.
- in kern_sig.c:proc_unstop: only return the LWP on the VP
- handle sa_yield as case 0 in sa_switch instead of clearing L_SA, add an
  L_SA_YIELD flag
- replace sa_idle by L_SA_IDLE flag since it was either NULL or == sa_vp

Also don't output itimerfire overrun warning if the process is already
exiting.
Also g/c sa_woken because it's not used.
Also g/c some #if 0 code.
2003-11-02 16:26:10 +00:00
jdolecek 8f8952e2b1 add a macro to copy ksiginfo_t, and use it in kern_sig.c:ksiginfo_put()
change suggested by Christian Limpach
2003-11-01 17:59:57 +00:00
jdolecek 0b33ae64cb in sigtimedwait(), use malloc(9)ed (and thus wired) memory for the waitset
we pass via sigctx, so that it guaranteed that the memory wouldn't be
paged out at the time the signal arrives

potential problem pointed out by YAMAMOTO Takashi
2003-11-01 07:44:14 +00:00
jdolecek 5a9f1cf173 ksiginfo_put(): only copy what's needed of ksiginfo_t, to slightly optimize
the operation, and improve code readability at the same time
2003-10-30 16:32:58 +00:00
jdolecek 0c303462c5 modify sigtimedwait(2) to return full siginfo if available, and pass the wait
set using a pointer, to save couple bytes in struct sigctx

also fix fallout from recent lwp_wakeup() change, where we failed to properly
detect if tsleep() returned as result of lwp_wakeup() or signal outside
our wait set; could have caused problems for threaded apps using sigwait(2)
et.al.
2003-10-25 16:50:37 +00:00
christos cb02efca51 fix uninitialized variable 2003-10-25 09:06:51 +00:00
hannken a3a898ff0f Add the gating of system calls that cause modifications to the underlying
file system.
The function vfs_write_suspend stops all new write operations to a file
system, allows any file system modifying system calls already in progress
to complete, then sync's the file system to disk and returns. The
function vfs_write_resume allows the suspended write operations to
complete.

From FreeBSD with slight modifications.

Approved by: Frank van der Linden <fvdl@netbsd.org>
2003-10-15 11:28:59 +00:00
pk db855cea5a ksiginfo_get/exit hook: protect queue operations with splsoftclock() (noted
by Christos).
2003-10-12 20:09:50 +00:00
pk a749472593 ksiginfo_put: protect queue operation with splsoftclock(), since it can
be called from timer interrupts.
2003-10-12 14:32:05 +00:00
thorpej 68723a995b * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
  result of a trap.  Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap.  Expands to 0 if the ksiginfo_t was
  not the result of a trap.  This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
  Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
  the case of non-trap-generated signals that have a > 0 si_code.

This patch fixes a signal delivery problem with threaded programs noted by
Matthias Drochner on tech-kern.

As discussed on tech-kern.  Reviewed and OK's by Christos.
2003-10-08 00:28:40 +00:00
thorpej bcf389773b Whitespace nits. 2003-10-07 00:23:17 +00:00
christos e59ff2cb68 Don't look for file descriptor matches when a process is exiting. From
Andrey Petrov.
2003-10-04 03:45:49 +00:00
christos 754bffb7e7 Fix problem with signal trampoline version checking that did not take into
account that emulations usually use version 0 and provide their own in kernel
trampolines.
2003-10-03 17:51:13 +00:00
matt 3ce59aebf3 Deal with signal trampoline being const. 2003-09-27 00:57:45 +00:00
matt 6986092cfe Add a machine-dependent SIGTRAMP_VALID macro which is used to test whether
a trampoline version is valid or not.
2003-09-26 22:14:19 +00:00
christos b2ceab3824 constify sendsig/trapsignal 2003-09-25 21:59:18 +00:00
nathanw b1a13994b7 When the syscall was made a compat syscall and the function name
changed to compat_16_sys___sigaction14, the name of the _args
structure chaged as well.
2003-09-23 17:59:48 +00:00
christos b601ca6ba8 __sigaction14 should have been COMPAT_16 a while ago. GC it now. 2003-09-23 14:34:07 +00:00
christos 8cf3af3092 - support for siginfo_t in ktrace
- make sure allocation for ksiginfo_t worked
2003-09-19 22:51:31 +00:00
christos 59294d6a54 fix typo (ktr -> ksi) 2003-09-16 15:59:28 +00:00
christos 1f73cefd27 - convert to circleq
- add simple lock for the list
- make get function remove the item from the list
- eliminate superfluous functions
thanks to enami and matt for the feedback.
2003-09-16 12:07:11 +00:00
christos cc39a7a050 remove variable name from prototype. 2003-09-14 23:45:53 +00:00
christos ab8558b680 - don't trash the linked list pointers in the ksiginfo_t reuse case
[thanks enami]
- fix uninitialized variable in the exit hook.
  [thanks yamt]
2003-09-14 17:39:03 +00:00
christos 9970fc6a83 handle siginfo for deferred signals. Allocate a ksiginfo pool, and store
the information there.
TODO:
1. since timer stuff gets called from an interrupt context, we could
   preallocate ksiginfo_t's from the pool, so we don't need a kmem
   pool.
2. probably the sa signal delivery syscall can be changed to take
   a ksiginfo_t so we can use only one pool.
3. maybe when we add realtime signal support, add a resource limit
   on the number of ksiginfo_t's a process can allocate.
2003-09-14 06:59:13 +00:00
christos 4148967f74 provide siginfo_t in for SIGCHLD 2003-09-13 15:32:40 +00:00
cl 96b4f15141 KNF and use f instead of s to temporarily save l_flag 2003-09-11 01:32:09 +00:00
kleink 5c5edae988 sigaction1(): if SA_SIGINFO is set but not supported, fail early.
As discussed with Christos.
2003-09-10 16:41:26 +00:00
christos 1dc335c017 SA_SIGINFO changes. 2003-09-06 22:03:09 +00:00
fvdl 8655b27bf5 SA fixes from Stephan Uphoff. Quoting him:
The patch below (hopefully) improves some signaling problems
found by Nathan.

It also contains some cleanup of the sa_upcall_userret() function
removing any sleep calls using PCATCH.

Unblocked threads now only use an upcall stack after they
acquire the virtual CPU.
This prevents unblocked threads from stealing all available
upcall stacks.


Tested by Nick Hudson.
2003-08-11 21:18:18 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
nathanw 6b22e87c69 Whitespace. 2003-07-21 22:57:46 +00:00
fvdl 4bd1a8dcf8 Changes from Stephan Uphoff to patch problems with LWPs blocking when they
shouldn't, and MP.
2003-07-17 18:16:58 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
nathanw 8e02eedcdf Track the LWP ID of a synchronous (trap) signal, and report it in core dumps. 2003-05-20 17:42:51 +00:00
nathanw 68b16f8c13 Patch from Nick Hudson to clean up a couple of cases in proc_unstop(),
as well as improving the comments a bit. Addresses PR kern/20159.
2003-04-23 21:32:10 +00:00
skrll ab7df78c6d ANSIfy proc_unstop 2003-04-15 12:11:25 +00:00
wiz 0acfa3bb9e Consistently spell occurrence with two rs. 2003-03-29 22:48:37 +00:00
darrenr bacf7b9b2b When unblocking threads, do not call setrunnable() on the thread we will
be returning because the code path that calls is will very likely call
setrunnable() again on the returned thread, leading to a panic because
the thread returned is already at LSRUN.  This fixes a problem where netbsd
would panic when using gdb (5.3) on a process with multiple lwp's like this:
% gdb program
(gdb) run
^C
(gdb) quit
2003-03-06 15:31:14 +00:00