^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Signal support for Hexagon processor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/registers.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/thread_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/ucontext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/cacheflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <asm/vdso.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct rt_sigframe {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned long tramp[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct siginfo info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct ucontext uc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) size_t frame_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) unsigned long sp = sigsp(regs->r29, ksig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return (void __user *)((sp - frame_size) & ~(sizeof(long long) - 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned long tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) err |= copy_to_user(&sc->sc_regs.r0, ®s->r00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 32*sizeof(unsigned long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) err |= __put_user(regs->sa0, &sc->sc_regs.sa0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) err |= __put_user(regs->lc0, &sc->sc_regs.lc0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) err |= __put_user(regs->sa1, &sc->sc_regs.sa1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) err |= __put_user(regs->lc1, &sc->sc_regs.lc1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) err |= __put_user(regs->m0, &sc->sc_regs.m0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) err |= __put_user(regs->m1, &sc->sc_regs.m1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) err |= __put_user(regs->usr, &sc->sc_regs.usr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) err |= __put_user(regs->preds, &sc->sc_regs.p3_0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) err |= __put_user(regs->gp, &sc->sc_regs.gp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) err |= __put_user(regs->ugp, &sc->sc_regs.ugp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #if CONFIG_HEXAGON_ARCH_VERSION >= 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) err |= __put_user(regs->cs0, &sc->sc_regs.cs0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) err |= __put_user(regs->cs1, &sc->sc_regs.cs1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) tmp = pt_elr(regs); err |= __put_user(tmp, &sc->sc_regs.pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) tmp = pt_cause(regs); err |= __put_user(tmp, &sc->sc_regs.cause);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) tmp = pt_badva(regs); err |= __put_user(tmp, &sc->sc_regs.badva);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static int restore_sigcontext(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct sigcontext __user *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned long tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) err |= copy_from_user(®s->r00, &sc->sc_regs.r0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 32 * sizeof(unsigned long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) err |= __get_user(regs->sa0, &sc->sc_regs.sa0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) err |= __get_user(regs->lc0, &sc->sc_regs.lc0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) err |= __get_user(regs->sa1, &sc->sc_regs.sa1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) err |= __get_user(regs->lc1, &sc->sc_regs.lc1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) err |= __get_user(regs->m0, &sc->sc_regs.m0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) err |= __get_user(regs->m1, &sc->sc_regs.m1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) err |= __get_user(regs->usr, &sc->sc_regs.usr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) err |= __get_user(regs->preds, &sc->sc_regs.p3_0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) err |= __get_user(regs->gp, &sc->sc_regs.gp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) err |= __get_user(regs->ugp, &sc->sc_regs.ugp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #if CONFIG_HEXAGON_ARCH_VERSION >= 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) err |= __get_user(regs->cs0, &sc->sc_regs.cs0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) err |= __get_user(regs->cs1, &sc->sc_regs.cs1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) err |= __get_user(tmp, &sc->sc_regs.pc); pt_set_elr(regs, tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * Setup signal stack frame with siginfo structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct rt_sigframe __user *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct hexagon_vdso *vdso = current->mm->context.vdso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) frame = get_sigframe(ksig, regs, sizeof(struct rt_sigframe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (!access_ok(frame, sizeof(struct rt_sigframe)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) if (copy_siginfo_to_user(&frame->info, &ksig->info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /* The on-stack signal trampoline is no longer executed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * however, the libgcc signal frame unwinding code checks for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * the presence of these two numeric magic values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) err |= __put_user(0x7800d166, &frame->tramp[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) err |= __put_user(0x5400c004, &frame->tramp[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) err |= setup_sigcontext(regs, &frame->uc.uc_mcontext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) err |= __save_altstack(&frame->uc.uc_stack, user_stack_pointer(regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* Load r0/r1 pair with signumber/siginfo pointer... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) regs->r0100 = ((unsigned long long)((unsigned long)&frame->info) << 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) | (unsigned long long)ksig->sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) regs->r02 = (unsigned long) &frame->uc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) regs->r31 = (unsigned long) vdso->rt_signal_trampoline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) pt_psp(regs) = (unsigned long) frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) pt_set_elr(regs, (unsigned long)ksig->ka.sa.sa_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * Setup invocation of signal handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * If we're handling a signal that aborted a system call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * set up the error return value before adding the signal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * frame to the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (regs->syscall_nr >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) switch (regs->r00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) case -ERESTART_RESTARTBLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) case -ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) regs->r00 = -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) regs->r00 = -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) case -ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) regs->r06 = regs->syscall_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) pt_set_elr(regs, pt_elr(regs) - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) regs->r00 = regs->restart_r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * Set up the stack frame; not doing the SA_SIGINFO thing. We
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * only set up the rt_frame flavor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* If there was an error on setup, no signal was delivered. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ret = setup_rt_frame(ksig, sigmask_to_save(), regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * Called from return-from-event code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) void do_signal(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct ksignal ksig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (!user_mode(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) if (get_signal(&ksig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) handle_signal(&ksig, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * No (more) signals; if we came from a system call, handle the restart.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (regs->syscall_nr >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) switch (regs->r00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) case -ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) case -ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) regs->r06 = regs->syscall_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) case -ERESTART_RESTARTBLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) regs->r06 = __NR_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) goto no_restart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) pt_set_elr(regs, pt_elr(regs) - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) regs->r00 = regs->restart_r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) no_restart:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /* If there's no signal to deliver, put the saved sigmask back */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) restore_saved_sigmask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * Architecture-specific wrappers for signal-related system calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) asmlinkage int sys_rt_sigreturn(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct pt_regs *regs = current_pt_regs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct rt_sigframe __user *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) sigset_t blocked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* Always make any pending restarted system calls return -EINTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) current->restart_block.fn = do_no_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) frame = (struct rt_sigframe __user *)pt_psp(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (!access_ok(frame, sizeof(*frame)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (__copy_from_user(&blocked, &frame->uc.uc_sigmask, sizeof(blocked)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) set_current_blocked(&blocked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* Restore the user's stack as well */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) pt_psp(regs) = regs->r29;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) regs->syscall_nr = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (restore_altstack(&frame->uc.uc_stack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return regs->r00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) badframe:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) force_sig(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }