···23232424/* This struct is saved by setup_frame in signal.c, to keep the current2525 context while a signal handler is executed. It's restored by sys_sigreturn.2626-2727- To keep things simple, we use pt_regs here even though normally you just2828- specify the list of regs to save. Then we can use copy_from_user on the2929- entire regs instead of a bunch of get_user's as well...3026*/31273228struct sigcontext {3333- struct pt_regs regs; /* needs to be first */2929+ struct user_regs_struct regs; /* needs to be first */3430 unsigned long oldmask;3535- unsigned long usp; /* usp before stacking this gunk on it */3631};37323833#endif /* __ASM_OPENRISC_SIGCONTEXT_H */
···5252static int restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc)5353{5454 unsigned int err = 0;5555- unsigned long old_usp;56555756 /* Alwys make any pending restarted system call return -EINTR */5857 current_thread_info()->restart_block.fn = do_no_restart_syscall;59586060- /* restore the regs from &sc->regs (same as sc, since regs is first)5959+ /*6060+ * Restore the regs from &sc->regs.6161 * (sc is already checked for VERIFY_READ since the sigframe was6262 * checked in sys_sigreturn previously)6363 */6464-6565- if (__copy_from_user(regs, sc, sizeof(struct pt_regs)))6464+ if (__copy_from_user(regs, sc->regs.gpr, 32 * sizeof(unsigned long)))6565+ goto badframe;6666+ if (__copy_from_user(®s->pc, &sc->regs.pc, sizeof(unsigned long)))6767+ goto badframe;6868+ if (__copy_from_user(®s->sr, &sc->regs.sr, sizeof(unsigned long)))6669 goto badframe;67706871 /* make sure the SM-bit is cleared so user-mode cannot fool us */6972 regs->sr &= ~SPR_SR_SM;7070-7171- /* restore the old USP as it was before we stacked the sc etc.7272- * (we cannot just pop the sigcontext since we aligned the sp and7373- * stuff after pushing it)7474- */7575-7676- err |= __get_user(old_usp, &sc->usp);7777-7878- regs->sp = old_usp;79738074 /* TODO: the other ports use regs->orig_XX to disable syscall checks8175 * after this completes, but we don't use that mechanism. maybe we can···131137 unsigned long mask)132138{133139 int err = 0;134134- unsigned long usp = regs->sp;135140136136- /* copy the regs. they are first in sc so we can use sc directly */141141+ /* copy the regs */137142138138- err |= __copy_to_user(sc, regs, sizeof(struct pt_regs));143143+ err |= __copy_to_user(sc->regs.gpr, regs, 32 * sizeof(unsigned long));144144+ err |= __copy_to_user(&sc->regs.pc, ®s->pc, sizeof(unsigned long));145145+ err |= __copy_to_user(&sc->regs.sr, ®s->sr, sizeof(unsigned long));139146140147 /* then some other stuff */141148142149 err |= __put_user(mask, &sc->oldmask);143143-144144- err |= __put_user(usp, &sc->usp);145150146151 return err;147152}