Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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 Handling for ARC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * vineetg: Jan 2010 (Restarting of timer related syscalls)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * vineetg: Nov 2009 (Everything needed for TIF_RESTORE_SIGMASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *  -do_signal() supports TIF_RESTORE_SIGMASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  -do_signal() no loner needs oldset, required by OLD sys_sigsuspend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  -sys_rt_sigsuspend() now comes from generic code, so discard arch implemen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *  -sys_sigsuspend() no longer needs to fudge ptregs, hence that arg removed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  -sys_sigsuspend() no longer loops for do_signal(), sets TIF_xxx and leaves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *   the job to do_signal()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * vineetg: July 2009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  -Modified Code to support the uClibc provided userland sigreturn stub
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *   to avoid kernel synthesing it on user stack at runtime, costing TLB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *   probes and Cache line flushes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * vineetg: July 2009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *  -In stash_usr_regs( ) and restore_usr_regs( ), save/restore of user regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *   in done in block copy rather than one word at a time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *   This saves around 2K of code and improves LMBench lat_sig <catch>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * rajeshwarr: Feb 2009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *  - Support for Realtime Signals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * vineetg: Aug 11th 2008: Bug #94183
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *  -ViXS were still seeing crashes when using insmod to load drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *   It turned out that the code to change Execute permssions for TLB entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *   of user was not guarded for interrupts (mod_tlb_permission)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *   This was causing TLB entries to be overwritten on unrelated indexes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Vineetg: July 15th 2008: Bug #94183
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *  -Exception happens in Delay slot of a JMP, and before user space resumes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *   Signal is delivered (Ctrl + C) = >SIGINT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *   setup_frame( ) sets up PC,SP,BLINK to enable user space signal handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *   to run, but doesn't clear the Delay slot bit from status32. As a result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *   on resuming user mode, signal handler branches off to BTA of orig JMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *  -FIX: clear the DE bit from status32 in setup_frame( )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * Rahul Trivedi, Kanika Nema: Codito Technologies 2004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #include <linux/personality.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #include <asm/ucontext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) struct rt_sigframe {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct siginfo info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct ucontext uc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define MAGIC_SIGALTSTK		0x07302004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	unsigned int sigret_magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #ifndef CONFIG_ISA_ARCOMPACT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct user_regs_arcv2 v2abi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	v2abi.r30 = regs->r30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #ifdef CONFIG_ARC_HAS_ACCL_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	v2abi.r58 = regs->r58;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	v2abi.r59 = regs->r59;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	v2abi.r58 = v2abi.r59 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #ifndef CONFIG_ISA_ARCOMPACT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct user_regs_arcv2 v2abi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	regs->r30 = v2abi.r30;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #ifdef CONFIG_ARC_HAS_ACCL_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	regs->r58 = v2abi.r58;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	regs->r59 = v2abi.r59;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	       sigset_t *set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct user_regs_struct uregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	uregs.scratch.bta	= regs->bta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	uregs.scratch.lp_start	= regs->lp_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	uregs.scratch.lp_end	= regs->lp_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	uregs.scratch.lp_count	= regs->lp_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	uregs.scratch.status32	= regs->status32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	uregs.scratch.ret	= regs->ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	uregs.scratch.blink	= regs->blink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	uregs.scratch.fp	= regs->fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	uregs.scratch.gp	= regs->r26;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	uregs.scratch.r12	= regs->r12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	uregs.scratch.r11	= regs->r11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	uregs.scratch.r10	= regs->r10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	uregs.scratch.r9	= regs->r9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	uregs.scratch.r8	= regs->r8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	uregs.scratch.r7	= regs->r7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	uregs.scratch.r6	= regs->r6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	uregs.scratch.r5	= regs->r5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	uregs.scratch.r4	= regs->r4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	uregs.scratch.r3	= regs->r3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	uregs.scratch.r2	= regs->r2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	uregs.scratch.r1	= regs->r1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	uregs.scratch.r0	= regs->r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	uregs.scratch.sp	= regs->sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			     sizeof(sf->uc.uc_mcontext.regs.scratch));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (is_isa_arcv2())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return err ? -EFAULT : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	sigset_t set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct user_regs_struct uregs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	err |= __copy_from_user(&uregs.scratch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 				&(sf->uc.uc_mcontext.regs.scratch),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				sizeof(sf->uc.uc_mcontext.regs.scratch));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (is_isa_arcv2())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		err |= restore_arcv2_regs(&(sf->uc.uc_mcontext), regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^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_current_blocked(&set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	regs->bta	= uregs.scratch.bta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	regs->lp_start	= uregs.scratch.lp_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	regs->lp_end	= uregs.scratch.lp_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	regs->lp_count	= uregs.scratch.lp_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	regs->status32	= uregs.scratch.status32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	regs->ret	= uregs.scratch.ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	regs->blink	= uregs.scratch.blink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	regs->fp	= uregs.scratch.fp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	regs->r26	= uregs.scratch.gp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	regs->r12	= uregs.scratch.r12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	regs->r11	= uregs.scratch.r11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	regs->r10	= uregs.scratch.r10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	regs->r9	= uregs.scratch.r9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	regs->r8	= uregs.scratch.r8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	regs->r7	= uregs.scratch.r7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	regs->r6	= uregs.scratch.r6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	regs->r5	= uregs.scratch.r5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	regs->r4	= uregs.scratch.r4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	regs->r3	= uregs.scratch.r3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	regs->r2	= uregs.scratch.r2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	regs->r1	= uregs.scratch.r1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	regs->r0	= uregs.scratch.r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	regs->sp	= uregs.scratch.sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static inline int is_do_ss_needed(unsigned int magic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (MAGIC_SIGALTSTK == magic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		return 0;
^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) SYSCALL_DEFINE0(rt_sigreturn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	struct rt_sigframe __user *sf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	unsigned int magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	struct pt_regs *regs = current_pt_regs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	/* Always make any pending restarted system calls return -EINTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	current->restart_block.fn = do_no_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	/* Since we stacked the signal on a word boundary,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	 * then 'sp' should be word aligned here.  If it's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	 * not, then the user is trying to mess with us.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	if (regs->sp & 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	sf = (struct rt_sigframe __force __user *)(regs->sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	if (!access_ok(sf, sizeof(*sf)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (__get_user(magic, &sf->sigret_magic))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (unlikely(is_do_ss_needed(magic)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		if (restore_altstack(&sf->uc.uc_stack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (restore_usr_regs(regs, sf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		goto badframe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	/* Don't restart from sigreturn */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	syscall_wont_restart(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	 * Ensure that sigreturn always returns to user mode (in case the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	 * regs saved on user stack got fudged between save and sigreturn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	 * Otherwise it is easy to panic the kernel with a custom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	 * signal handler and/or restorer which clobberes the status32/ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	 * to return to a bogus location in kernel mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	regs->status32 |= STATUS_U_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	return regs->r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) badframe:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	force_sig(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^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)  * Determine which stack to use..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static inline void __user *get_sigframe(struct ksignal *ksig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 					struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 					unsigned long framesize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	unsigned long sp = sigsp(regs->sp, ksig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	void __user *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	/* No matter what happens, 'sp' must be word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	 * aligned otherwise nasty things could happen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	/* ATPCS B01 mandates 8-byte alignment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	frame = (void __user *)((sp - framesize) & ~7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	/* Check that we can actually write to the signal frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	if (!access_ok(frame, framesize))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		frame = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	return frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	struct rt_sigframe __user *sf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	unsigned int magic = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	sf = get_sigframe(ksig, regs, sizeof(struct rt_sigframe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	if (!sf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	 * w/o SA_SIGINFO, struct ucontext is partially populated (only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	 * uc_mcontext/uc_sigmask) for kernel's normal user state preservation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	 * during signal handler execution. This works for SA_SIGINFO as well
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	 * although the semantics are now overloaded (the same reg state can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * inspected by userland: but are they allowed to fiddle with it ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	err |= stash_usr_regs(sf, regs, set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	 * SA_SIGINFO requires 3 args to signal handler:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	 *  #1: sig-no (common to any handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	 *  #2: struct siginfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	 *  #3: struct ucontext (completely populated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (unlikely(ksig->ka.sa.sa_flags & SA_SIGINFO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		err |= copy_siginfo_to_user(&sf->info, &ksig->info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		err |= __put_user(0, &sf->uc.uc_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		err |= __put_user(NULL, &sf->uc.uc_link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		err |= __save_altstack(&sf->uc.uc_stack, regs->sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		/* setup args 2 and 3 for user mode handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		regs->r1 = (unsigned long)&sf->info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 		regs->r2 = (unsigned long)&sf->uc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		 * small optim to avoid unconditonally calling do_sigaltstack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		 * in sigreturn path, now that we only have rt_sigreturn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		magic = MAGIC_SIGALTSTK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	err |= __put_user(magic, &sf->sigret_magic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	/* #1 arg to the user Signal handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	regs->r0 = ksig->sig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	/* setup PC of user space signal handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	regs->ret = (unsigned long)ksig->ka.sa.sa_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	 * handler returns using sigreturn stub provided already by userpsace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	 * If not, nuke the process right away
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	if(!(ksig->ka.sa.sa_flags & SA_RESTORER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	regs->blink = (unsigned long)ksig->ka.sa.sa_restorer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	/* User Stack for signal handler will be above the frame just carved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	regs->sp = (unsigned long)sf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	 * Bug 94183, Clear the DE bit, so that when signal handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	 * starts to run, it doesn't use BTA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	regs->status32 &= ~STATUS_DE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	regs->status32 |= STATUS_L_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static void arc_restart_syscall(struct k_sigaction *ka, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	switch (regs->r0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	case -ERESTART_RESTARTBLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	case -ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		 * ERESTARTNOHAND means that the syscall should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		 * only be restarted if there was no handler for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		 * the signal, and since we only get here if there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		 * is a handler, we don't restart
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		regs->r0 = -EINTR;   /* ERESTART_xxx is internal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	case -ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		 * ERESTARTSYS means to restart the syscall if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		 * there is no handler or the handler was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		 * registered with SA_RESTART
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		if (!(ka->sa.sa_flags & SA_RESTART)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 			regs->r0 = -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	case -ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		 * ERESTARTNOINTR means that the syscall should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		 * be called again after the signal handler returns.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		 * Setup reg state just as it was before doing the trap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		 * r0 has been clobbered with sys call ret code thus it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		 * needs to be reloaded with orig first arg to syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		 * in orig_r0. Rest of relevant reg-file:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		 * r8 (syscall num) and (r1 - r7) will be reset to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		 * their orig user space value when we ret from kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		regs->r0 = regs->orig_r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		regs->ret -= is_isa_arcv2() ? 2 : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)  * OK, we're invoking a handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) handle_signal(struct ksignal *ksig, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	sigset_t *oldset = sigmask_to_save();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	int failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	/* Set up the stack frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	failed = setup_rt_frame(ksig, oldset, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	signal_setup_done(failed, ksig, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) void do_signal(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	struct ksignal ksig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	int restart_scall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	restart_scall = in_syscall(regs) && syscall_restartable(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	if (get_signal(&ksig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		if (restart_scall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 			arc_restart_syscall(&ksig.ka, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 			syscall_wont_restart(regs);	/* No more restarts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		handle_signal(&ksig, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	if (restart_scall) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		/* No handler for syscall: restart it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		if (regs->r0 == -ERESTARTNOHAND ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		    regs->r0 == -ERESTARTSYS || regs->r0 == -ERESTARTNOINTR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			regs->r0 = regs->orig_r0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			regs->ret -= is_isa_arcv2() ? 2 : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		} else if (regs->r0 == -ERESTART_RESTARTBLOCK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 			regs->r8 = __NR_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			regs->ret -= is_isa_arcv2() ? 2 : 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 		syscall_wont_restart(regs);	/* No more restarts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	/* If there's no signal to deliver, restore the saved sigmask back */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	restore_saved_sigmask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) void do_notify_resume(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	 * ASM glue gaurantees that this is only called when returning to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	 * user mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	if (test_thread_flag(TIF_NOTIFY_RESUME))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		tracehook_notify_resume(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }