^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/ucontext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/vdso.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <abi/regdef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #ifdef CONFIG_CPU_HAS_FPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <abi/fpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static int restore_fpu_state(struct sigcontext __user *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct user_fp user_fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) err = __copy_from_user(&user_fp, &sc->sc_user_fp, sizeof(user_fp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) restore_from_user_fp(&user_fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) return err;
^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 int save_fpu_state(struct sigcontext __user *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct user_fp user_fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) save_to_user_fp(&user_fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return __copy_to_user(&sc->sc_user_fp, &user_fp, sizeof(user_fp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define restore_fpu_state(sigcontext) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define save_fpu_state(sigcontext) (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct rt_sigframe {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * pad[3] is compatible with the same struct defined in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * gcc/libgcc/config/csky/linux-unwind.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int pad[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct siginfo info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct ucontext uc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static long restore_sigcontext(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct sigcontext __user *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned long sr = regs->sr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* sc_pt_regs is structured the same as the start of pt_regs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) err |= __copy_from_user(regs, &sc->sc_pt_regs, sizeof(struct pt_regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* BIT(0) of regs->sr is Condition Code/Carry bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) regs->sr = (sr & ~1) | (regs->sr & 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* Restore the floating-point state. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) err |= restore_fpu_state(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) SYSCALL_DEFINE0(rt_sigreturn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct pt_regs *regs = current_pt_regs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct rt_sigframe __user *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) sigset_t set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* Always make any pending restarted system calls return -EINTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) current->restart_block.fn = do_no_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) frame = (struct rt_sigframe __user *)regs->usp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (!access_ok(frame, sizeof(*frame)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) set_current_blocked(&set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (restore_altstack(&frame->uc.uc_stack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return regs->a0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) badframe:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) force_sig(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static int setup_sigcontext(struct rt_sigframe __user *frame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct sigcontext __user *sc = &frame->uc.uc_mcontext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) err |= __copy_to_user(&sc->sc_pt_regs, regs, sizeof(struct pt_regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) err |= save_fpu_state(sc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline void __user *get_sigframe(struct ksignal *ksig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct pt_regs *regs, size_t framesize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) unsigned long sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /* Default to using normal stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) sp = regs->usp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * If we are on the alternate signal stack and would overflow it, don't.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * Return an always-bogus address instead so we will die with SIGSEGV.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return (void __user __force *)(-1UL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* This is the X/Open sanctioned signal stack switching. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) sp = sigsp(sp, ksig) - framesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* Align the stack frame. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) sp &= -8UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) return (void __user *)sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct rt_sigframe __user *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct csky_vdso *vdso = current->mm->context.vdso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) frame = get_sigframe(ksig, regs, sizeof(*frame));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (!access_ok(frame, sizeof(*frame)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) err |= copy_siginfo_to_user(&frame->info, &ksig->info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* Create the ucontext. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) err |= __put_user(0, &frame->uc.uc_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) err |= __put_user(NULL, &frame->uc.uc_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) err |= __save_altstack(&frame->uc.uc_stack, regs->usp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) err |= setup_sigcontext(frame, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /* Set up to return from userspace. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) regs->lr = (unsigned long)(vdso->rt_signal_retcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Set up registers for signal handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * Registers that we don't modify keep the value they had from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * user-space at the time we took the signal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * We always pass siginfo and mcontext, regardless of SA_SIGINFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * since some things rely on this (e.g. glibc's debug/segfault.c).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) regs->pc = (unsigned long)ksig->ka.sa.sa_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) regs->usp = (unsigned long)frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) regs->a0 = ksig->sig; /* a0: signal number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) regs->a1 = (unsigned long)(&(frame->info)); /* a1: siginfo pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) regs->a2 = (unsigned long)(&(frame->uc)); /* a2: ucontext pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) sigset_t *oldset = sigmask_to_save();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) rseq_signal_deliver(ksig, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /* Are we from a system call? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (in_syscall(regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /* Avoid additional syscall restarting via ret_from_exception */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) forget_syscall(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* If so, check system call restarting.. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) switch (regs->a0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) case -ERESTART_RESTARTBLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) case -ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) regs->a0 = -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) regs->a0 = -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) case -ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) regs->a0 = regs->orig_a0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) regs->pc -= TRAP0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* Set up the stack frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) ret = setup_rt_frame(ksig, oldset, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) signal_setup_done(ret, ksig, 0);
^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) static void do_signal(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct ksignal ksig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (get_signal(&ksig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* Actually deliver the signal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) handle_signal(&ksig, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* Did we come from a system call? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (in_syscall(regs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /* Avoid additional syscall restarting via ret_from_exception */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) forget_syscall(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* Restart the system call - no handlers present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) switch (regs->a0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) case -ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) case -ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) regs->a0 = regs->orig_a0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) regs->pc -= TRAP0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) case -ERESTART_RESTARTBLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) regs->a0 = regs->orig_a0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) regs_syscallid(regs) = __NR_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) regs->pc -= TRAP0_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * If there is no signal to deliver, we just put the saved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * sigmask back.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) restore_saved_sigmask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * notification of userspace execution resumption
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * - triggered by the _TIF_WORK_MASK flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) asmlinkage void do_notify_resume(struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) unsigned long thread_info_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) if (thread_info_flags & _TIF_UPROBE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) uprobe_notify_resume(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /* Handle pending signal delivery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (thread_info_flags & _TIF_SIGPENDING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) do_signal(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) if (thread_info_flags & _TIF_NOTIFY_RESUME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) tracehook_notify_resume(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) rseq_handle_notify_resume(NULL, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }