--- //depot/projects/ia64/sys/alpha/alpha/machdep.c 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/alpha/alpha/machdep.c 2002/04/04 18:04:48 @@ -1204,21 +1204,6 @@ sip = (osiginfo_t *)(alpha_pal_rdusp() - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sip); - if (!useracc((caddr_t)sip, fsize, VM_PROT_WRITE)) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - PROC_LOCK(p); - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(p->p_sigmask, SIGILL); - psignal(p, SIGILL); - return; - } - /* * Build the signal context to be used by sigreturn. */ @@ -1255,7 +1240,19 @@ /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&ksi, (caddr_t)sip, fsize); + if (copyout((caddr_t)&ksi, (caddr_t)sip, fsize) != 0) { + /* + * Process has trashed its stack; give it an illegal + * instruction to halt it in its tracks. + */ + PROC_LOCK(p); + SIGACTION(p, SIGILL) = SIG_DFL; + SIGDELSET(p->p_sigignore, SIGILL); + SIGDELSET(p->p_sigcatch, SIGILL); + SIGDELSET(p->p_sigmask, SIGILL); + psignal(p, SIGILL); + return; + } /* * Set up the registers to return to sigcode. @@ -1338,31 +1335,11 @@ sfp = (struct sigframe *)(alpha_pal_rdusp() - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sfp); #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d ssp %p usp %p\n", p->p_pid, sig, &sf, sfp); #endif - if (!useracc((caddr_t)sfp, sizeof(sf), VM_PROT_WRITE)) { -#ifdef DEBUG - if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sendsig(%d): useracc failed on sig %d\n", - p->p_pid, sig); -#endif - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - PROC_LOCK(p); - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(p->p_sigmask, SIGILL); - psignal(p, SIGILL); - return; - } - /* save the floating-point state, if necessary, then copy it. */ alpha_fpstate_save(td, 1); sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED; @@ -1380,7 +1357,24 @@ /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)); + if (copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)) != 0) { +#ifdef DEBUG + if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) + printf("sendsig(%d): copyout failed on sig %d\n", + p->p_pid, sig); +#endif + /* + * Process has trashed its stack; give it an illegal + * instruction to halt it in its tracks. + */ + PROC_LOCK(p); + SIGACTION(p, SIGILL) = SIG_DFL; + SIGDELSET(p->p_sigignore, SIGILL); + SIGDELSET(p->p_sigcatch, SIGILL); + SIGDELSET(p->p_sigmask, SIGILL); + psignal(p, SIGILL); + return; + } #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): sig %d sfp %p code %lx\n", p->p_pid, sig, @@ -1471,6 +1465,7 @@ */ SIGSETOLD(p->p_sigmask, ksc.sc_mask); SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); set_regs(td, (struct reg *)ksc.sc_regs); @@ -1553,6 +1548,7 @@ p->p_sigmask = uc.uc_sigmask; SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); /* XXX ksc.sc_ownedfp ? */ --- //depot/projects/ia64/sys/alpha/alpha/vm_machdep.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/alpha/alpha/vm_machdep.c 2002/04/04 18:04:48 @@ -352,21 +352,6 @@ prom_halt(0); } -int -grow_stack(p, sp) - struct proc *p; - size_t sp; -{ - int rv; - - rv = vm_map_growstack (p, sp); - if (rv != KERN_SUCCESS) - return (0); - - return (1); -} - - /* * Software interrupt handler for queued VM system processing. */ --- //depot/projects/ia64/sys/alpha/osf1/osf1_signal.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/alpha/osf1/osf1_signal.c 2002/04/04 18:04:48 @@ -491,11 +491,13 @@ case OSF1_SIG_UNBLOCK: SIGSETNAND(p->p_sigmask, bss); + signotify(p); break; case OSF1_SIG_SETMASK: p->p_sigmask = bss; SIG_CANTMASK(p->p_sigmask); + signotify(p); break; default: @@ -614,21 +616,6 @@ sip = (osiginfo_t *)(alpha_pal_rdusp() - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sip); - if (useracc((caddr_t)sip, fsize, VM_PROT_WRITE) == 0) { - /* - * Process has trashed its stack; give it an illegal - * instruction to halt it in its tracks. - */ - PROC_LOCK(p); - SIGACTION(p, SIGILL) = SIG_DFL; - SIGDELSET(p->p_sigignore, SIGILL); - SIGDELSET(p->p_sigcatch, SIGILL); - SIGDELSET(p->p_sigmask, SIGILL); - psignal(p, SIGILL); - return; - } - /* * Build the signal context to be used by sigreturn. */ @@ -665,7 +652,19 @@ /* * copy the frame out to userland. */ - (void) copyout((caddr_t)&ksi, (caddr_t)sip, fsize); + if (copyout((caddr_t)&ksi, (caddr_t)sip, fsize) != 0) { + /* + * Process has trashed its stack; give it an illegal + * instruction to halt it in its tracks. + */ + PROC_LOCK(p); + SIGACTION(p, SIGILL) = SIG_DFL; + SIGDELSET(p->p_sigignore, SIGILL); + SIGDELSET(p->p_sigcatch, SIGILL); + SIGDELSET(p->p_sigmask, SIGILL); + psignal(p, SIGILL); + return; + } /* * Set up the registers to return to sigcode. @@ -729,6 +728,7 @@ */ osf1_to_bsd_sigset(&ksc.sc_mask, &p->p_sigmask); SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); set_regs(td, (struct reg *)ksc.sc_regs); --- //depot/projects/ia64/sys/coda/coda_psdev.c 2001/12/14 18:25:58 +++ //depot/projects/ia64/sys/coda/coda_psdev.c 2002/04/04 18:04:48 @@ -602,6 +602,7 @@ } } while (error && i++ < 128 && VC_OPEN(vcp)); p->p_sigmask = psig_omask; + signotify(p); PROC_UNLOCK(p); #else (void) tsleep(&vmp->vm_sleep, coda_call_sleep, "coda_call", 0); --- //depot/projects/ia64/sys/compat/linux/linux_signal.c 2001/11/01 19:58:25 +++ //depot/projects/ia64/sys/compat/linux/linux_signal.c 2002/04/04 18:04:48 @@ -256,10 +256,12 @@ break; case LINUX_SIG_UNBLOCK: SIGSETNAND(p->p_sigmask, mask); + signotify(p); break; case LINUX_SIG_SETMASK: p->p_sigmask = mask; SIG_CANTMASK(p->p_sigmask); + signotify(p); break; default: error = EINVAL; @@ -377,6 +379,7 @@ linux_to_bsd_sigset(&lset, &bset); p->p_sigmask = bset; SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); return (0); } --- //depot/projects/ia64/sys/compat/svr4/svr4_signal.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/compat/svr4/svr4_signal.c 2002/04/04 18:04:48 @@ -531,11 +531,13 @@ case SVR4_SIG_UNBLOCK: SIGSETNAND(td->td_proc->p_sigmask, bss); + signotify(td->td_proc); break; case SVR4_SIG_SETMASK: td->td_proc->p_sigmask = bss; SIG_CANTMASK(td->td_proc->p_sigmask); + signotify(td->td_proc); break; default: --- //depot/projects/ia64/sys/i386/i386/machdep.c 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/i386/i386/machdep.c 2002/04/04 18:04:48 @@ -649,6 +649,7 @@ SIGSETOLD(p->p_sigmask, scp->sc_mask); SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); regs->tf_ebp = scp->sc_fp; regs->tf_esp = scp->sc_sp; @@ -758,6 +759,7 @@ p->p_sigmask = ucp->uc_sigmask; SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); return (EJUSTRETURN); } --- //depot/projects/ia64/sys/i386/ibcs2/ibcs2_signal.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/i386/ibcs2/ibcs2_signal.c 2002/04/04 18:04:48 @@ -328,6 +328,7 @@ /* return SIG_HOLD and unblock signal*/ td->td_retval[0] = (int)IBCS2_SIG_HOLD; SIGDELSET(p->p_sigmask, signum); + signotify(p); } PROC_UNLOCK(p); } @@ -426,11 +427,13 @@ case IBCS2_SIG_UNBLOCK: SIGSETNAND(p->p_sigmask, bss); + signotify(p); break; case IBCS2_SIG_SETMASK: p->p_sigmask = bss; SIG_CANTMASK(p->p_sigmask); + signotify(p); break; default: --- //depot/projects/ia64/sys/i386/linux/linux_sysvec.c 2002/03/26 21:26:48 +++ //depot/projects/ia64/sys/i386/linux/linux_sysvec.c 2002/04/04 18:04:48 @@ -555,6 +555,7 @@ PROC_LOCK(p); linux_to_bsd_sigset(&lmask, &p->p_sigmask); SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); /* @@ -654,6 +655,7 @@ PROC_LOCK(p); linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask); SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); /* --- //depot/projects/ia64/sys/i386/svr4/svr4_machdep.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/i386/svr4/svr4_machdep.c 2002/04/04 18:04:48 @@ -294,6 +294,7 @@ svr4_to_bsd_sigset(&uc->uc_sigmask, &mask); SIG_CANTMASK(mask); p->p_sigmask = mask; + signotify(p); } PROC_UNLOCK(p); --- //depot/projects/ia64/sys/ia64/ia64/machdep.c 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/ia64/ia64/machdep.c 2002/04/04 18:04:48 @@ -864,16 +864,29 @@ sfp = (struct sigframe *)(frame->tf_r[FRAME_SP] - rndfsize); PROC_UNLOCK(p); - (void)grow_stack(p, (u_long)sfp); #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d ssp %p usp %p\n", p->p_pid, sig, &sf, sfp); #endif - if (!useracc((caddr_t)sfp, sizeof(sf), VM_PROT_WRITE)) { + +#if 0 + /* save the floating-point state, if necessary, then copy it. */ + ia64_fpstate_save(td, 1); + sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED; + bcopy(&td->td_pcb->pcb_fp, + (struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs, + sizeof(struct fpreg)); + sf.sf_uc.uc_mcontext.mc_fp_control = td->td_pcb.pcb_fp_control; +#endif + + /* + * copy the frame out to userland. + */ + if (copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)) != 0) { #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) - printf("sendsig(%d): useracc failed on sig %d\n", + printf("sendsig(%d): copyout failed on sig %d\n", p->p_pid, sig); #endif /* @@ -888,21 +901,6 @@ psignal(p, SIGILL); return; } - -#if 0 - /* save the floating-point state, if necessary, then copy it. */ - ia64_fpstate_save(td, 1); - sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDP_FPUSED; - bcopy(&td->td_pcb->pcb_fp, - (struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs, - sizeof(struct fpreg)); - sf.sf_uc.uc_mcontext.mc_fp_control = td->td_pcb.pcb_fp_control; -#endif - - /* - * copy the frame out to userland. - */ - (void) copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)); #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): sig %d sfp %p code %lx\n", p->p_pid, sig, @@ -1043,6 +1041,7 @@ p->p_sigmask = uc.uc_sigmask; SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); /* XXX ksc.sc_ownedfp ? */ --- //depot/projects/ia64/sys/ia64/ia64/trap.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/ia64/ia64/trap.c 2002/04/04 18:04:48 @@ -587,13 +587,13 @@ /* * Grow the stack if necessary */ - /* grow_stack returns false only if va falls into + /* vm_map_growstack fails only if va falls into * a growable stack region and the stack growth - * fails. It returns true if va was not within + * fails. It succeeds if va was not within * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) + if (vm_map_growstack(p, va) != KERN_SUCCESS) rv = KERN_FAILURE; else /* Fault in the user page: */ --- //depot/projects/ia64/sys/ia64/ia64/vm_machdep.c 2002/03/20 19:26:31 +++ //depot/projects/ia64/sys/ia64/ia64/vm_machdep.c 2002/04/04 18:04:48 @@ -418,20 +418,6 @@ cpu_boot(0); } -int -grow_stack(p, sp) - struct proc *p; - size_t sp; -{ - int rv; - - rv = vm_map_growstack (p, sp); - if (rv != KERN_SUCCESS) - return (0); - - return (1); -} - /* * Software interrupt handler for queued VM system processing. */ --- //depot/projects/ia64/sys/kern/kern_sig.c 2002/03/26 21:26:48 +++ //depot/projects/ia64/sys/kern/kern_sig.c 2002/04/04 18:04:48 @@ -174,16 +174,29 @@ int CURSIG(struct proc *p) { - sigset_t tmpset; + + PROC_LOCK_ASSERT(p, MA_OWNED); + mtx_assert(&sched_lock, MA_NOTOWNED); + return (SIGPENDING(p) ? issignal(p) : 0); +} + +/* + * Arrange for ast() to handle unmasked pending signals on return to user + * mode. This must be called whenever a signal is added to p_siglist or + * unmasked in p_sigmask. + */ +void +signotify(struct proc *p) +{ PROC_LOCK_ASSERT(p, MA_OWNED); - if (SIGISEMPTY(p->p_siglist)) - return (0); - tmpset = p->p_siglist; - SIGSETNAND(tmpset, p->p_sigmask); - if (SIGISEMPTY(tmpset) && (p->p_flag & P_TRACED) == 0) - return (0); - return (issignal(p)); + mtx_assert(&sched_lock, MA_NOTOWNED); + mtx_lock_spin(&sched_lock); + if (SIGPENDING(p)) { + p->p_sflag |= PS_NEEDSIGCHK; + p->p_kse.ke_flags |= KEF_ASTPENDING; /* XXXKSE */ + } + mtx_unlock_spin(&sched_lock); } static __inline int @@ -520,6 +533,7 @@ break; case SIG_UNBLOCK: SIGSETNAND(p->p_sigmask, *set); + signotify(p); break; case SIG_SETMASK: SIG_CANTMASK(*set); @@ -527,6 +541,7 @@ SIGSETLO(p->p_sigmask, *set); else p->p_sigmask = *set; + signotify(p); break; default: error = EINVAL; @@ -759,6 +774,7 @@ PROC_LOCK(p); SIG2OSIG(p->p_sigmask, td->td_retval[0]); SIGSETLO(p->p_sigmask, set); + signotify(p); PROC_UNLOCK(p); mtx_unlock(&Giant); return (0); @@ -811,6 +827,7 @@ SIG_CANTMASK(mask); p->p_sigmask = mask; + signotify(p); while (msleep((caddr_t) ps, &p->p_mtx, PPAUSE|PCATCH, "pause", 0) == 0) /* void */; PROC_UNLOCK(p); @@ -846,6 +863,7 @@ OSIG2SIG(uap->mask, mask); SIG_CANTMASK(mask); SIGSETLO(p->p_sigmask, mask); + signotify(p); while (msleep((caddr_t) ps, &p->p_mtx, PPAUSE|PCATCH, "opause", 0) == 0) /* void */; PROC_UNLOCK(p); @@ -1309,6 +1327,7 @@ SIG_CONTSIGMASK(p->p_siglist); } SIGADDSET(p->p_siglist, sig); + signotify(p); /* * Defer further processing for signals which are held, @@ -1481,7 +1500,6 @@ #ifdef SMP struct kse *ke; struct thread *td = curthread; - signotify(&p->p_kse); /* XXXKSE */ /* we should only deliver to one thread.. but which one? */ FOREACH_KSEGRP_IN_PROC(p, kg) { FOREACH_KSE_IN_GROUP(kg, ke) { @@ -1491,8 +1509,6 @@ forward_signal(ke->ke_thread); } } -#else - signotify(&p->p_kse); /* XXXKSE */ #endif } mtx_unlock_spin(&sched_lock); --- //depot/projects/ia64/sys/kern/subr_trap.c 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/kern/subr_trap.c 2002/04/04 18:04:48 @@ -70,44 +70,49 @@ struct proc *p = td->td_proc; struct kse *ke = td->td_kse; struct ksegrp *kg = td->td_ksegrp; - int sig; +#ifdef INVARIANTS + /* Check that we called signotify() enough. */ mtx_lock(&Giant); PROC_LOCK(p); - while ((sig = CURSIG(p)) != 0) - postsig(sig); + mtx_lock_spin(&sched_lock); + if (SIGPENDING(p) && ((p->p_sflag & PS_NEEDSIGCHK) == 0 || + (p->p_kse.ke_flags & KEF_ASTPENDING) == 0)) + printf("failed to set signal flags proprly for ast()\n"); + mtx_unlock_spin(&sched_lock); PROC_UNLOCK(p); mtx_unlock(&Giant); +#endif - mtx_lock_spin(&sched_lock); - td->td_priority = kg->kg_user_pri; - if (ke->ke_flags & KEF_NEEDRESCHED) { - DROP_GIANT(); - setrunqueue(td); - p->p_stats->p_ru.ru_nivcsw++; - mi_switch(); + /* + * XXX we cheat slightly on the locking here to avoid locking in + * the usual case. Setting td_priority here is essentially an + * incomplete workaround for not setting it properly elsewhere. + * Now that some interrupt handlers are threads, not setting it + * properly elsewhere can clobber it in the window between setting + * it here and returning to user mode, so don't waste time setting + * it perfectly here. + */ + if (td->td_priority != kg->kg_user_pri) { + mtx_lock_spin(&sched_lock); + td->td_priority = kg->kg_user_pri; mtx_unlock_spin(&sched_lock); - PICKUP_GIANT(); - mtx_lock(&Giant); - PROC_LOCK(p); - while ((sig = CURSIG(p)) != 0) - postsig(sig); - mtx_unlock(&Giant); - PROC_UNLOCK(p); - mtx_lock_spin(&sched_lock); } /* * Charge system time if profiling. + * + * XXX should move PS_PROFIL to a place that can obviously be + * accessed safely without sched_lock. */ if (p->p_sflag & PS_PROFIL) { quad_t ticks; + mtx_lock_spin(&sched_lock); ticks = ke->ke_sticks - oticks; mtx_unlock_spin(&sched_lock); addupc_task(ke, TRAPF_PC(frame), (u_int)ticks * psratio); - } else - mtx_unlock_spin(&sched_lock); + } } /* @@ -122,9 +127,11 @@ struct thread *td = curthread; struct proc *p = td->td_proc; struct kse *ke = td->td_kse; + struct ksegrp *kg = td->td_ksegrp; u_int prticks, sticks; int sflag; int flags; + int sig; #if defined(DEV_NPX) && !defined(SMP) int ucode; #endif @@ -135,6 +142,7 @@ panic("Returning to user mode with mutex(s) held"); #endif mtx_assert(&Giant, MA_NOTOWNED); + mtx_assert(&sched_lock, MA_NOTOWNED); prticks = 0; /* XXX: Quiet warning. */ td->td_frame = framep; /* @@ -148,8 +156,8 @@ sticks = ke->ke_sticks; sflag = p->p_sflag; flags = ke->ke_flags; - p->p_sflag &= ~(PS_PROFPEND | PS_ALRMPEND); - ke->ke_flags &= ~(KEF_OWEUPC | KEF_ASTPENDING); + p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND); + ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED | KEF_OWEUPC); cnt.v_soft++; if (flags & KEF_OWEUPC && sflag & PS_PROFIL) { prticks = p->p_stats->p_prof.pr_ticks; @@ -181,6 +189,22 @@ psignal(p, SIGPROF); PROC_UNLOCK(p); } + if (flags & KEF_NEEDRESCHED) { + mtx_lock_spin(&sched_lock); + td->td_priority = kg->kg_user_pri; + setrunqueue(td); + p->p_stats->p_ru.ru_nivcsw++; + mi_switch(); + mtx_unlock_spin(&sched_lock); + } + if (sflag & PS_NEEDSIGCHK) { + mtx_lock(&Giant); + PROC_LOCK(p); + while ((sig = CURSIG(p)) != 0) + postsig(sig); + PROC_UNLOCK(p); + mtx_unlock(&Giant); + } userret(td, framep, sticks); #ifdef DIAGNOSTIC --- //depot/projects/ia64/sys/pc98/i386/machdep.c 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/pc98/i386/machdep.c 2002/04/04 18:04:48 @@ -662,6 +662,7 @@ SIGSETOLD(p->p_sigmask, scp->sc_mask); SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); regs->tf_ebp = scp->sc_fp; regs->tf_esp = scp->sc_sp; @@ -771,6 +772,7 @@ p->p_sigmask = ucp->uc_sigmask; SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); return (EJUSTRETURN); } --- //depot/projects/ia64/sys/sparc64/sparc64/machdep.c 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/sparc64/sparc64/machdep.c 2002/04/04 18:04:48 @@ -508,6 +508,7 @@ p->p_sigmask = uc.uc_sigmask; SIG_CANTMASK(p->p_sigmask); + signotify(p); PROC_UNLOCK(p); CTR4(KTR_SIG, "sigreturn: return td=%p pc=%#lx sp=%#lx tstate=%#lx", td, tf->tf_tpc, tf->tf_sp, tf->tf_tstate); --- //depot/projects/ia64/sys/sys/proc.h 2002/04/03 19:52:29 +++ //depot/projects/ia64/sys/sys/proc.h 2002/04/04 18:04:48 @@ -503,6 +503,7 @@ #define PS_PROFPEND 0x00040 /* Pending SIGPROF needs to be posted. */ #define PS_SWAPINREQ 0x00100 /* Swapin request due to wakeup. */ #define PS_SWAPPING 0x00200 /* Process is being swapped. */ +#define PS_NEEDSIGCHK 0x02000 /* Process may need signal delivery. */ /* flags kept in td_flags */ #define TDF_ONRUNQ 0x00001 /* This KE is on a run queue */ @@ -565,15 +566,6 @@ : 0); } -/* - * Notify the current process (p) that it has a signal pending, - * process as soon as possible. - */ -#define signotify(ke) do { \ - mtx_assert(&sched_lock, MA_OWNED); \ - (ke)->ke_flags |= KEF_ASTPENDING; \ -} while (0) - /* Handy macro to determine if p1 can mangle p2. */ #define PRISON_CHECK(p1, p2) \ ((p1)->p_prison == NULL || (p1)->p_prison == (p2)->p_prison) --- //depot/projects/ia64/sys/sys/signalvar.h 2002/03/19 14:31:39 +++ //depot/projects/ia64/sys/sys/signalvar.h 2002/04/04 18:04:48 @@ -189,6 +189,29 @@ #ifdef _KERNEL +/* Return nonzero if process p has an unmasked pending signal. */ +#define SIGPENDING(p) \ + (!SIGISEMPTY((p)->p_siglist) && \ + (!sigsetmasked(&(p)->p_siglist, &(p)->p_sigmask) || \ + (p)->p_flag & P_TRACED)) + +/* + * Return the value of the pseudo-expression ((*set & ~*mask) != 0). This + * is an optimized version of SIGISEMPTY() on a temporary variable + * containing SIGSETNAND(*set, *mask). + */ +static __inline int +sigsetmasked(sigset_t *set, sigset_t *mask) +{ + int i; + + for (i = 0; i < _SIG_WORDS; i++) { + if (set->__bits[i] & ~mask->__bits[i]) + return (0); + } + return (1); +} + struct pgrp; struct thread; struct proc; @@ -210,6 +233,7 @@ void psignal(struct proc *p, int sig); void sigexit(struct thread *td, int signum) __dead2; void siginit(struct proc *p); +void signotify(struct proc *p); void trapsignal(struct proc *p, int sig, u_long code); /*