Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/compat/linux32/arch/amd64/linux32_machdep.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/compat/linux32/arch/amd64/linux32_machdep.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.1 retrieving revision 1.1.16.4 diff -u -p -r1.1 -r1.1.16.4 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c 2006/02/09 19:18:57 1.1 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c 2007/02/26 09:09:24 1.1.16.4 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.1 2006/02/09 19:18:57 manu Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.1.16.4 2007/02/26 09:09:24 yamt Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.1 2006/02/09 19:18:57 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.1.16.4 2007/02/26 09:09:24 yamt Exp $"); #include #include @@ -51,7 +51,6 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_mach #include #include #include -#include #include #include #include @@ -116,10 +115,10 @@ linux32_old_sendsig(const ksiginfo_t *ks struct proc *p = l->l_proc; struct trapframe *tf; struct linux32_sigframe *fp, frame; - int onstack; + int onstack, error; int sig = ksi->ksi_signo; sig_t catcher = SIGACTION(p, sig).sa_handler; - struct sigaltstack *sas = &p->p_sigctx.ps_sigstk; + struct sigaltstack *sas = &l->l_sigstk; tf = l->l_md.md_regs; /* Do we need to jump onto the signal stack? */ @@ -141,7 +140,12 @@ linux32_old_sendsig(const ksiginfo_t *ks linux32_save_sigcontext(l, tf, mask, &frame.sf_sc); - if (copyout(&frame, fp, sizeof(frame)) != 0) { + sendsig_reset(l, sig); + mutex_exit(&p->p_smutex); + error = copyout(&frame, fp, sizeof(frame)); + mutex_enter(&p->p_smutex); + + if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. @@ -177,11 +181,11 @@ linux32_rt_sendsig(const ksiginfo_t *ksi struct proc *p = l->l_proc; struct trapframe *tf; struct linux32_rt_sigframe *fp, frame; - int onstack; + int onstack, error; linux32_siginfo_t *lsi; int sig = ksi->ksi_signo; sig_t catcher = SIGACTION(p, sig).sa_handler; - struct sigaltstack *sas = &p->p_sigctx.ps_sigstk; + struct sigaltstack *sas = &l->l_sigstk; tf = l->l_md.md_regs; /* Do we need to jump onto the signal stack? */ @@ -242,9 +246,13 @@ linux32_rt_sendsig(const ksiginfo_t *ksi } /* Save register context. */ + sendsig_reset(l, sig); + mutex_exit(&p->p_smutex); linux32_save_ucontext(l, tf, mask, sas, &frame.sf_uc); + error = copyout(&frame, fp, sizeof(frame)); + mutex_enter(&p->p_smutex); - if (copyout(&frame, fp, sizeof(frame)) != 0) { + if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. @@ -301,11 +309,11 @@ linux32_setregs(struct lwp *l, struct ex pcb->pcb_gs = 0; - l->l_proc->p_flag |= P_32; + p->p_flag |= PK_32; tf = l->l_md.md_regs; tf->tf_rax = 0; - tf->tf_rbx = (u_int64_t)l->l_proc->p_psstr & 0xffffffff; + tf->tf_rbx = (u_int64_t)p->p_psstr & 0xffffffff; tf->tf_rcx = pack->ep_entry & 0xffffffff; tf->tf_rdx = 0; tf->tf_rsi = 0; @@ -434,7 +442,7 @@ linux32_restore_sigcontext(l, scp, retva { struct trapframe *tf; struct proc *p = l->l_proc; - struct sigaltstack *sas = &p->p_sigctx.ps_sigstk; + struct sigaltstack *sas = &l->l_sigstk; sigset_t mask; ssize_t ss_gap; @@ -485,6 +493,8 @@ linux32_restore_sigcontext(l, scp, retva tf->tf_rsp = (register_t)scp->sc_esp_at_signal & 0xffffffff; tf->tf_ss = (register_t)scp->sc_ss & 0xffffffff; + mutex_enter(&p->p_smutex); + /* Restore signal stack. */ ss_gap = (ssize_t) ((caddr_t)NETBSD32PTR64(scp->sc_esp_at_signal) @@ -496,7 +506,10 @@ linux32_restore_sigcontext(l, scp, retva /* Restore signal mask. */ linux32_old_to_native_sigset(&mask, &scp->sc_mask); - (void) sigprocmask1(p, SIG_SETMASK, &mask, 0); + (void) sigprocmask1(l, SIG_SETMASK, &mask, 0); + + mutex_exit(&p->p_smutex); + #ifdef DEBUG_LINUX printf("linux32_sigreturn: rip = 0x%lx, rsp = 0x%lx, flags = 0x%lx\n", tf->tf_rip, tf->tf_rsp, tf->tf_rflags);