X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fparisc%2Fkernel%2Fsignal.c;h=05767e83cf2dd38f3aaacebd9e61e56349d0088c;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=b220bb22f79cfc78ed5e89e6da5b123ecb331edf;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index b220bb22f..05767e83c 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef CONFIG_COMPAT #include @@ -69,7 +70,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall); #endif asmlinkage int -sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, struct pt_regs *regs) +sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize, struct pt_regs *regs) { sigset_t saveset, newset; #ifdef __LP64__ @@ -79,7 +80,7 @@ sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, struct pt_regs *regs) /* XXX: Don't preclude handling different sized sigset_t's. */ if (sigsetsize != sizeof(compat_sigset_t)) return -EINVAL; - if (copy_from_user(&newset32, (compat_sigset_t *)unewset, sizeof(newset32))) + if (copy_from_user(&newset32, (compat_sigset_t __user *)unewset, sizeof(newset32))) return -EFAULT; sigset_32to64(&newset,&newset32); @@ -125,7 +126,7 @@ sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, struct pt_regs *regs) #define INSN_DIE_HORRIBLY 0x68000ccc /* stw %r0,0x666(%sr0,%r0) */ static long -restore_sigcontext(struct sigcontext *sc, struct pt_regs *regs) +restore_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs) { long err = 0; @@ -143,14 +144,14 @@ restore_sigcontext(struct sigcontext *sc, struct pt_regs *regs) void sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) { - struct rt_sigframe *frame; + struct rt_sigframe __user *frame; struct siginfo si; sigset_t set; unsigned long usp = (regs->gr[30] & ~(0x01UL)); unsigned long sigframe_size = PARISC_RT_SIGFRAME_SIZE; #ifdef __LP64__ compat_sigset_t compat_set; - struct compat_rt_sigframe * compat_frame; + struct compat_rt_sigframe __user * compat_frame; if(personality(current->personality) == PER_LINUX32) sigframe_size = PARISC_RT_SIGFRAME_SIZE32; @@ -158,12 +159,12 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) /* Unwind the user stack to get the rt_sigframe structure. */ - frame = (struct rt_sigframe *) + frame = (struct rt_sigframe __user *) (usp - sigframe_size); DBG(2,"sys_rt_sigreturn: frame is %p\n", frame); #ifdef __LP64__ - compat_frame = (struct compat_rt_sigframe *)frame; + compat_frame = (struct compat_rt_sigframe __user *)frame; if(personality(current->personality) == PER_LINUX32){ DBG(2,"sys_rt_sigreturn: ELF32 process.\n"); @@ -238,7 +239,7 @@ give_sigsegv: * Set up a signal frame. */ -static inline void * +static inline void __user * get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size) { /*FIXME: ELF32 vs. ELF64 has different frame_size, but since we @@ -251,11 +252,11 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size) sp = current->sas_ss_sp; /* Stacks grow up! */ DBG(1,"get_sigframe: Returning sp = %#lx\n", (unsigned long)sp); - return (void *) sp; /* Stacks grow up. Fun. */ + return (void __user *) sp; /* Stacks grow up. Fun. */ } static long -setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, int in_syscall) +setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, int in_syscall) { unsigned long flags = 0; @@ -292,14 +293,13 @@ static long setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set, struct pt_regs *regs, int in_syscall) { - struct rt_sigframe *frame; + struct rt_sigframe __user *frame; unsigned long rp, usp; unsigned long haddr, sigframe_size; - struct siginfo si; int err = 0; #ifdef __LP64__ compat_int_t compat_val; - struct compat_rt_sigframe * compat_frame; + struct compat_rt_sigframe __user * compat_frame; compat_sigset_t compat_set; #endif @@ -313,11 +313,11 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, #ifdef __LP64__ - compat_frame = (struct compat_rt_sigframe *)frame; + compat_frame = (struct compat_rt_sigframe __user *)frame; if(personality(current->personality) == PER_LINUX32) { DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); - err |= compat_copy_siginfo_to_user(&compat_frame->info, info); + err |= copy_siginfo_to_user32(&compat_frame->info, info); DBG(1,"SETUP_RT_FRAME: 1\n"); compat_val = (compat_int_t)current->sas_ss_sp; err |= __put_user(compat_val, &compat_frame->uc.uc_stack.ss_sp); @@ -396,7 +396,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, #endif if (haddr & PA_PLABEL_FDESC) { Elf32_Fdesc fdesc; - Elf32_Fdesc *ufdesc = (Elf32_Fdesc *)A(haddr & ~3); + Elf32_Fdesc __user *ufdesc = (Elf32_Fdesc __user *)A(haddr & ~3); err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc)); @@ -409,7 +409,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, #ifdef __LP64__ } else { Elf64_Fdesc fdesc; - Elf64_Fdesc *ufdesc = (Elf64_Fdesc *)A(haddr & ~3); + Elf64_Fdesc __user *ufdesc = (Elf64_Fdesc __user *)A(haddr & ~3); err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc)); @@ -443,6 +443,18 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, psw |= PSW_W; #endif + /* If we are singlestepping, arrange a trap to be delivered + when we return to userspace. Note the semantics -- we + should trap before the first insn in the handler is + executed. Ref: + http://sources.redhat.com/ml/gdb/2004-11/msg00245.html + */ + if (pa_psw(current)->r) { + pa_psw(current)->r = 0; + psw |= PSW_R; + mtctl(-1, 0); + } + regs->gr[0] = psw; regs->iaoq[0] = haddr | 3; regs->iaoq[1] = regs->iaoq[0] + 4; @@ -477,15 +489,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, give_sigsegv: DBG(1,"setup_rt_frame: sending SIGSEGV\n"); - if (sig == SIGSEGV) - ka->sa.sa_handler = SIG_DFL; - si.si_signo = SIGSEGV; - si.si_errno = 0; - si.si_code = SI_KERNEL; - si.si_pid = current->pid; - si.si_uid = current->uid; - si.si_addr = frame; - force_sig_info(SIGSEGV, &si, current); + force_sigsegv(sig, current); return 0; } @@ -494,11 +498,9 @@ give_sigsegv: */ static long -handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset, - struct pt_regs *regs, int in_syscall) +handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, + sigset_t *oldset, struct pt_regs *regs, int in_syscall) { - struct k_sigaction *ka = ¤t->sighand->action[sig-1]; - DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n", sig, ka, info, oldset, regs); @@ -506,16 +508,12 @@ handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset, if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall)) return 0; - if (ka->sa.sa_flags & SA_ONESHOT) - ka->sa.sa_handler = SIG_DFL; - - if (!(ka->sa.sa_flags & SA_NODEFER)) { - spin_lock_irq(¤t->sighand->siglock); - sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); + spin_lock_irq(¤t->sighand->siglock); + sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask); + if (!(ka->sa.sa_flags & SA_NODEFER)) sigaddset(¤t->blocked,sig); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); - } + recalc_sigpending(); + spin_unlock_irq(¤t->sighand->siglock); return 1; } @@ -535,7 +533,7 @@ asmlinkage int do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall) { siginfo_t info; - struct k_sigaction *ka; + struct k_sigaction ka; int signr; DBG(1,"\ndo_signal: oldset=0x%p, regs=0x%p, sr7 %#lx, in_syscall=%d\n", @@ -553,10 +551,15 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall) oldset->sig[0], oldset->sig[1]); - signr = get_signal_to_deliver(&info, regs, NULL); - DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); + /* May need to force signal if handle_signal failed to deliver */ + while (1) { + + signr = get_signal_to_deliver(&info, &ka, regs, NULL); + DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); - if (signr > 0) { + if (signr <= 0) + break; + /* Restart a system call if necessary. */ if (in_syscall) { /* Check the return code */ @@ -569,8 +572,7 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall) break; case -ERESTARTSYS: - ka = ¤t->sighand->action[signr-1]; - if (!(ka->sa.sa_flags & SA_RESTART)) { + if (!(ka.sa.sa_flags & SA_RESTART)) { DBG(1,"ERESTARTSYS: putting -EINTR\n"); regs->gr[28] = -EINTR; break; @@ -578,8 +580,7 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall) /* fallthrough */ case -ERESTARTNOINTR: /* A syscall is just a branch, so all - we have to do is fiddle the return - pointer. */ + we have to do is fiddle the return pointer. */ regs->gr[31] -= 8; /* delayed branching */ /* Preserve original r28. */ regs->gr[28] = regs->orig_r28; @@ -589,12 +590,13 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall) /* Whee! Actually deliver the signal. If the delivery failed, we need to continue to iterate in this loop so we can deliver the SIGSEGV... */ - if (handle_signal(signr, &info, oldset, regs, in_syscall)) { + if (handle_signal(signr, &info, &ka, oldset, regs, in_syscall)) { DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n", regs->gr[28]); return 1; } } + /* end of while(1) looping forever if we can't force a signal */ /* Did we come from a system call? */ if (in_syscall) { @@ -622,10 +624,14 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall) put_user(0xe0008200, &usp[3]); put_user(0x34140000, &usp[4]); - /* Stack is 64-byte aligned, and we only - * need to flush 1 cache line */ - asm("fdc 0(%%sr3, %0)\n" - "fic 0(%%sr3, %0)\n" + /* Stack is 64-byte aligned, and we only need + * to flush 1 cache line. + * Flushing one cacheline is cheap. + * "sync" on bigger (> 4 way) boxes is not. + */ + asm("fdc %%r0(%%sr3, %0)\n" + "sync\n" + "fic %%r0(%%sr3, %0)\n" "sync\n" : : "r"(regs->gr[30]));