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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Architecture-specific signal handling support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1999-2004 Hewlett-Packard Co
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	David Mosberger-Tang <davidm@hpl.hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Derived from i386 and Alpha versions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/binfmts.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <asm/intrinsics.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <asm/rse.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <asm/sigcontext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "sigframe.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define DEBUG_SIG	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define STACK_ALIGN	16		/* minimal alignment for stack pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #if _NSIG_WORDS > 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) # define PUT_SIGSET(k,u)	__copy_to_user((u)->sig, (k)->sig, sizeof(sigset_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) # define GET_SIGSET(k,u)	__copy_from_user((k)->sig, (u)->sig, sizeof(sigset_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) # define PUT_SIGSET(k,u)	__put_user((k)->sig[0], &(u)->sig[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) # define GET_SIGSET(k,u)	__get_user((k)->sig[0], &(u)->sig[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) restore_sigcontext (struct sigcontext __user *sc, struct sigscratch *scr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	unsigned long ip, flags, nat, um, cfm, rsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	long err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	/* Always make any pending restarted system calls return -EINTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	current->restart_block.fn = do_no_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	/* restore scratch that always needs gets updated during signal delivery: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	err  = __get_user(flags, &sc->sc_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	err |= __get_user(nat, &sc->sc_nat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	err |= __get_user(ip, &sc->sc_ip);			/* instruction pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	err |= __get_user(cfm, &sc->sc_cfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	err |= __get_user(um, &sc->sc_um);			/* user mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	err |= __get_user(rsc, &sc->sc_ar_rsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	err |= __get_user(scr->pt.ar_unat, &sc->sc_ar_unat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	err |= __get_user(scr->pt.ar_fpsr, &sc->sc_ar_fpsr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	err |= __get_user(scr->pt.ar_pfs, &sc->sc_ar_pfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	err |= __get_user(scr->pt.pr, &sc->sc_pr);		/* predicates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	err |= __get_user(scr->pt.b0, &sc->sc_br[0]);		/* b0 (rp) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	err |= __get_user(scr->pt.b6, &sc->sc_br[6]);		/* b6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	err |= __copy_from_user(&scr->pt.r1, &sc->sc_gr[1], 8);	/* r1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	err |= __copy_from_user(&scr->pt.r8, &sc->sc_gr[8], 4*8);	/* r8-r11 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	err |= __copy_from_user(&scr->pt.r12, &sc->sc_gr[12], 2*8);	/* r12-r13 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	err |= __copy_from_user(&scr->pt.r15, &sc->sc_gr[15], 8);	/* r15 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	scr->pt.cr_ifs = cfm | (1UL << 63);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	scr->pt.ar_rsc = rsc | (3 << 2); /* force PL3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	/* establish new instruction pointer: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	scr->pt.cr_iip = ip & ~0x3UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	ia64_psr(&scr->pt)->ri = ip & 0x3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	scr->pt.cr_ipsr = (scr->pt.cr_ipsr & ~IA64_PSR_UM) | (um & IA64_PSR_UM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	scr->scratch_unat = ia64_put_scratch_nat_bits(&scr->pt, nat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	if (!(flags & IA64_SC_FLAG_IN_SYSCALL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		/* Restore most scratch-state only when not in syscall. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		err |= __get_user(scr->pt.ar_ccv, &sc->sc_ar_ccv);		/* ar.ccv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		err |= __get_user(scr->pt.b7, &sc->sc_br[7]);			/* b7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		err |= __get_user(scr->pt.r14, &sc->sc_gr[14]);			/* r14 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		err |= __copy_from_user(&scr->pt.ar_csd, &sc->sc_ar25, 2*8); /* ar.csd & ar.ssd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		err |= __copy_from_user(&scr->pt.r2, &sc->sc_gr[2], 2*8);	/* r2-r3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		err |= __copy_from_user(&scr->pt.r16, &sc->sc_gr[16], 16*8);	/* r16-r31 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	if ((flags & IA64_SC_FLAG_FPH_VALID) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		struct ia64_psr *psr = ia64_psr(&scr->pt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		err |= __copy_from_user(current->thread.fph, &sc->sc_fr[32], 96*16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		psr->mfh = 0;	/* drop signal handler's fph contents... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		preempt_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		if (psr->dfh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			ia64_drop_fpu(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			/* We already own the local fph, otherwise psr->dfh wouldn't be 0.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			__ia64_load_fpu(current->thread.fph);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			ia64_set_local_fpu_owner(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		preempt_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ia64_rt_sigreturn (struct sigscratch *scr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	extern char ia64_strace_leave_kernel, ia64_leave_kernel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct sigcontext __user *sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	sigset_t set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	long retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	sc = &((struct sigframe __user *) (scr->pt.r12 + 16))->sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	 * When we return to the previously executing context, r8 and r10 have already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	 * been setup the way we want them.  Indeed, if the signal wasn't delivered while
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 * in a system call, we must not touch r8 or r10 as otherwise user-level state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 * could be corrupted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	retval = (long) &ia64_leave_kernel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if (test_thread_flag(TIF_SYSCALL_TRACE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	    || test_thread_flag(TIF_SYSCALL_AUDIT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		 * strace expects to be notified after sigreturn returns even though the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		 * context to which we return may not be in the middle of a syscall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		 * Thus, the return-value that strace displays for sigreturn is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		 * meaningless.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		retval = (long) &ia64_strace_leave_kernel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (!access_ok(sc, sizeof(*sc)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		goto give_sigsegv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	if (GET_SIGSET(&set, &sc->sc_mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		goto give_sigsegv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	set_current_blocked(&set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (restore_sigcontext(sc, scr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		goto give_sigsegv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #if DEBUG_SIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	printk("SIG return (%s:%d): sp=%lx ip=%lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	       current->comm, current->pid, scr->pt.r12, scr->pt.cr_iip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	if (restore_altstack(&sc->sc_stack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		goto give_sigsegv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)   give_sigsegv:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	force_sig(SIGSEGV);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * This does just the minimum required setup of sigcontext.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * Specifically, it only installs data that is either not knowable at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * the user-level or that gets modified before execution in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * trampoline starts.  Everything else is done at the user-level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) setup_sigcontext (struct sigcontext __user *sc, sigset_t *mask, struct sigscratch *scr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	unsigned long flags = 0, ifs, cfm, nat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	long err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ifs = scr->pt.cr_ifs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (on_sig_stack((unsigned long) sc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		flags |= IA64_SC_FLAG_ONSTACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	if ((ifs & (1UL << 63)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		/* if cr_ifs doesn't have the valid bit set, we got here through a syscall */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		flags |= IA64_SC_FLAG_IN_SYSCALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	cfm = ifs & ((1UL << 38) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	ia64_flush_fph(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	if ((current->thread.flags & IA64_THREAD_FPH_VALID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		flags |= IA64_SC_FLAG_FPH_VALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		err = __copy_to_user(&sc->sc_fr[32], current->thread.fph, 96*16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	nat = ia64_get_scratch_nat_bits(&scr->pt, scr->scratch_unat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	err |= __put_user(flags, &sc->sc_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	err |= __put_user(nat, &sc->sc_nat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	err |= PUT_SIGSET(mask, &sc->sc_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	err |= __put_user(cfm, &sc->sc_cfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	err |= __put_user(scr->pt.cr_ipsr & IA64_PSR_UM, &sc->sc_um);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	err |= __put_user(scr->pt.ar_rsc, &sc->sc_ar_rsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	err |= __put_user(scr->pt.ar_unat, &sc->sc_ar_unat);		/* ar.unat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	err |= __put_user(scr->pt.ar_fpsr, &sc->sc_ar_fpsr);		/* ar.fpsr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	err |= __put_user(scr->pt.ar_pfs, &sc->sc_ar_pfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	err |= __put_user(scr->pt.pr, &sc->sc_pr);			/* predicates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	err |= __put_user(scr->pt.b0, &sc->sc_br[0]);			/* b0 (rp) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	err |= __put_user(scr->pt.b6, &sc->sc_br[6]);			/* b6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	err |= __copy_to_user(&sc->sc_gr[1], &scr->pt.r1, 8);		/* r1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	err |= __copy_to_user(&sc->sc_gr[8], &scr->pt.r8, 4*8);		/* r8-r11 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	err |= __copy_to_user(&sc->sc_gr[12], &scr->pt.r12, 2*8);	/* r12-r13 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	err |= __copy_to_user(&sc->sc_gr[15], &scr->pt.r15, 8);		/* r15 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	err |= __put_user(scr->pt.cr_iip + ia64_psr(&scr->pt)->ri, &sc->sc_ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (!(flags & IA64_SC_FLAG_IN_SYSCALL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		/* Copy scratch regs to sigcontext if the signal didn't interrupt a syscall. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		err |= __put_user(scr->pt.ar_ccv, &sc->sc_ar_ccv);		/* ar.ccv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		err |= __put_user(scr->pt.b7, &sc->sc_br[7]);			/* b7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		err |= __put_user(scr->pt.r14, &sc->sc_gr[14]);			/* r14 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		err |= __copy_to_user(&sc->sc_ar25, &scr->pt.ar_csd, 2*8); /* ar.csd & ar.ssd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		err |= __copy_to_user(&sc->sc_gr[2], &scr->pt.r2, 2*8);		/* r2-r3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		err |= __copy_to_user(&sc->sc_gr[16], &scr->pt.r16, 16*8);	/* r16-r31 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * Check whether the register-backing store is already on the signal stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) rbs_on_sig_stack (unsigned long bsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return (bsp - current->sas_ss_sp < current->sas_ss_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) setup_frame(struct ksignal *ksig, sigset_t *set, struct sigscratch *scr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	extern char __kernel_sigtramp[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	unsigned long tramp_addr, new_rbs = 0, new_sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct sigframe __user *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	long err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	new_sp = scr->pt.r12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	tramp_addr = (unsigned long) __kernel_sigtramp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (ksig->ka.sa.sa_flags & SA_ONSTACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		int onstack = sas_ss_flags(new_sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		if (onstack == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			new_sp = current->sas_ss_sp + current->sas_ss_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			 * We need to check for the register stack being on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			 * signal stack separately, because it's switched
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			 * separately (memory stack is switched in the kernel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			 * register stack is switched in the signal trampoline).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			if (!rbs_on_sig_stack(scr->pt.ar_bspstore))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				new_rbs = ALIGN(current->sas_ss_sp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 						sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		} else if (onstack == SS_ONSTACK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			unsigned long check_sp;
^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) 			 * If we are on the alternate signal stack and would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			 * overflow it, don't. Return an always-bogus address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			 * instead so we will die with SIGSEGV.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			check_sp = (new_sp - sizeof(*frame)) & -STACK_ALIGN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			if (!likely(on_sig_stack(check_sp))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 				force_sigsegv(ksig->sig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 				return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	frame = (void __user *) ((new_sp - sizeof(*frame)) & -STACK_ALIGN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (!access_ok(frame, sizeof(*frame))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		force_sigsegv(ksig->sig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	err  = __put_user(ksig->sig, &frame->arg0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	err |= __put_user(&frame->info, &frame->arg1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	err |= __put_user(&frame->sc, &frame->arg2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	err |= __put_user(new_rbs, &frame->sc.sc_rbs_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	err |= __put_user(0, &frame->sc.sc_loadrs);	/* initialize to zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	err |= __put_user(ksig->ka.sa.sa_handler, &frame->handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	err |= copy_siginfo_to_user(&frame->info, &ksig->info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	err |= __save_altstack(&frame->sc.sc_stack, scr->pt.r12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	err |= setup_sigcontext(&frame->sc, set, scr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	if (unlikely(err)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		force_sigsegv(ksig->sig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		return 1;
^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) 	scr->pt.r12 = (unsigned long) frame - 16;	/* new stack pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	scr->pt.ar_fpsr = FPSR_DEFAULT;			/* reset fpsr for signal handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	scr->pt.cr_iip = tramp_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	ia64_psr(&scr->pt)->ri = 0;			/* start executing in first slot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	ia64_psr(&scr->pt)->be = 0;			/* force little-endian byte-order */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	 * Force the interruption function mask to zero.  This has no effect when a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	 * system-call got interrupted by a signal (since, in that case, scr->pt_cr_ifs is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	 * ignored), but it has the desirable effect of making it possible to deliver a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	 * signal with an incomplete register frame (which happens when a mandatory RSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	 * load faults).  Furthermore, it has no negative effect on the getting the user's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	 * dirty partition preserved, because that's governed by scr->pt.loadrs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	scr->pt.cr_ifs = (1UL << 63);
^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) 	 * Note: this affects only the NaT bits of the scratch regs (the ones saved in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	 * pt_regs), which is exactly what we want.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	scr->scratch_unat = 0; /* ensure NaT bits of r12 is clear */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #if DEBUG_SIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	printk("SIG deliver (%s:%d): sig=%d sp=%lx ip=%lx handler=%p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	       current->comm, current->pid, ksig->sig, scr->pt.r12, frame->sc.sc_ip, frame->handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) static long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) handle_signal (struct ksignal *ksig, struct sigscratch *scr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	int ret = setup_frame(ksig, sigmask_to_save(), scr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		signal_setup_done(ret, ksig, test_thread_flag(TIF_SINGLESTEP));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * Note that `init' is a special process: it doesn't get signals it doesn't want to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  * handle.  Thus you cannot kill init even with a SIGKILL even by mistake.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) ia64_do_signal (struct sigscratch *scr, long in_syscall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	long restart = in_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	long errno = scr->pt.r8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	struct ksignal ksig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	 * This only loops in the rare cases of handle_signal() failing, in which case we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	 * need to push through a forced SIGSEGV.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		get_signal(&ksig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		 * get_signal() may have run a debugger (via notify_parent())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		 * and the debugger may have modified the state (e.g., to arrange for an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		 * inferior call), thus it's important to check for restarting _after_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		 * get_signal().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		if ((long) scr->pt.r10 != -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			 * A system calls has to be restarted only if one of the error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 			 * ERESTARTNOHAND, ERESTARTSYS, or ERESTARTNOINTR is returned.  If r10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			 * isn't -1 then r8 doesn't hold an error code and we don't need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 			 * restart the syscall, so we can clear the "restart" flag here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 			restart = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		if (ksig.sig <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		if (unlikely(restart)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 			switch (errno) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 			case ERESTART_RESTARTBLOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			case ERESTARTNOHAND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 				scr->pt.r8 = EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 				/* note: scr->pt.r10 is already -1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 			case ERESTARTSYS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 				if ((ksig.ka.sa.sa_flags & SA_RESTART) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 					scr->pt.r8 = EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 					/* note: scr->pt.r10 is already -1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 				fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 			case ERESTARTNOINTR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 				ia64_decrement_ip(&scr->pt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 				restart = 0; /* don't restart twice if handle_signal() fails... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		}
^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) 		 * Whee!  Actually deliver the signal.  If the delivery failed, we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		 * continue to iterate in this loop so we can deliver the SIGSEGV...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		if (handle_signal(&ksig, scr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	/* Did we come from a system call? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	if (restart) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		/* Restart the system call - no handlers present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		if (errno == ERESTARTNOHAND || errno == ERESTARTSYS || errno == ERESTARTNOINTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		    || errno == ERESTART_RESTARTBLOCK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			 * Note: the syscall number is in r15 which is saved in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 			 * pt_regs so all we need to do here is adjust ip so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 			 * the "break" instruction gets re-executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 			ia64_decrement_ip(&scr->pt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			if (errno == ERESTART_RESTARTBLOCK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 				scr->pt.r15 = __NR_restart_syscall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	/* if there's no signal to deliver, we just put the saved sigmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	 * back */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	restore_saved_sigmask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) }