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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *  PowerPC version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Derived from "arch/m68k/kernel/ptrace.c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 1994 by Hamish Macdonald
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  Taken from linux/kernel/ptrace.c and modified for M680x0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Modified by Cort Dougan (cort@hq.fsmlabs.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * and Paul Mackerras (paulus@samba.org).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * This file is subject to the terms and conditions of the GNU General
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * Public License.  See the file README.legal in the main directory of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * this archive for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/regset.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/audit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/context_tracking.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <asm/switch_to.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <asm/asm-prototypes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define CREATE_TRACE_POINTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <trace/events/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "ptrace-decl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * Called by kernel/ptrace.c when detaching..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Make sure single step bits etc are not set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) void ptrace_disable(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/* make sure the single step bit is not set. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	user_disable_single_step(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) long arch_ptrace(struct task_struct *child, long request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		 unsigned long addr, unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	int ret = -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	void __user *datavp = (void __user *) data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	unsigned long __user *datalp = datavp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	switch (request) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	/* read the word at location addr in the USER area. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	case PTRACE_PEEKUSR: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		unsigned long index, tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		/* convert to index and check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #ifdef CONFIG_PPC32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		index = addr >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		if ((addr & 3) || (index > PT_FPSCR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		    || (child->thread.regs == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		index = addr >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		if ((addr & 7) || (index > PT_FPSCR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		CHECK_FULL_REGS(child->thread.regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		if (index < PT_FPR0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			ret = ptrace_get_reg(child, (int) index, &tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			unsigned int fpidx = index - PT_FPR0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			flush_fp_to_thread(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			if (fpidx < (PT_FPSCR - PT_FPR0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				memcpy(&tmp, &child->thread.TS_FPR(fpidx),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 				       sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 				tmp = child->thread.fp_state.fpscr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		ret = put_user(tmp, datalp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	/* write the word at location addr in the USER area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	case PTRACE_POKEUSR: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		unsigned long index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		/* convert to index and check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #ifdef CONFIG_PPC32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		index = addr >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		if ((addr & 3) || (index > PT_FPSCR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		    || (child->thread.regs == NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		index = addr >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		if ((addr & 7) || (index > PT_FPSCR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		CHECK_FULL_REGS(child->thread.regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		if (index < PT_FPR0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			ret = ptrace_put_reg(child, index, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			unsigned int fpidx = index - PT_FPR0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			flush_fp_to_thread(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			if (fpidx < (PT_FPSCR - PT_FPR0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 				memcpy(&child->thread.TS_FPR(fpidx), &data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 				       sizeof(long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 				child->thread.fp_state.fpscr = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 			ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	case PPC_PTRACE_GETHWDBGINFO: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		struct ppc_debug_info dbginfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		ppc_gethwdinfo(&dbginfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		if (copy_to_user(datavp, &dbginfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 				 sizeof(struct ppc_debug_info)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	case PPC_PTRACE_SETHWDEBUG: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		struct ppc_hw_breakpoint bp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		if (copy_from_user(&bp_info, datavp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 				   sizeof(struct ppc_hw_breakpoint)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		return ppc_set_hwdebug(child, &bp_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	case PPC_PTRACE_DELHWDEBUG: {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		ret = ppc_del_hwdebug(child, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	case PTRACE_GET_DEBUGREG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		ret = ptrace_get_debugreg(child, addr, datalp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	case PTRACE_SET_DEBUGREG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		ret = ptrace_set_debugreg(child, addr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	case PTRACE_GETREGS64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	case PTRACE_GETREGS:	/* Get all pt_regs from the child. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		return copy_regset_to_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 					   REGSET_GPR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 					   0, sizeof(struct user_pt_regs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 					   datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	case PTRACE_SETREGS64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	case PTRACE_SETREGS:	/* Set all gp regs in the child. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return copy_regset_from_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 					     REGSET_GPR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 					     0, sizeof(struct user_pt_regs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 					     datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		return copy_regset_to_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 					   REGSET_FPR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 					   0, sizeof(elf_fpregset_t),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 					   datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	case PTRACE_SETFPREGS: /* Set the child FPU state (FPR0...31 + FPSCR) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		return copy_regset_from_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 					     REGSET_FPR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 					     0, sizeof(elf_fpregset_t),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 					     datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #ifdef CONFIG_ALTIVEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	case PTRACE_GETVRREGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return copy_regset_to_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 					   REGSET_VMX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 					   0, (33 * sizeof(vector128) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 					       sizeof(u32)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 					   datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	case PTRACE_SETVRREGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		return copy_regset_from_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 					     REGSET_VMX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 					     0, (33 * sizeof(vector128) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 						 sizeof(u32)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 					     datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #ifdef CONFIG_VSX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	case PTRACE_GETVSRREGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		return copy_regset_to_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 					   REGSET_VSX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 					   0, 32 * sizeof(double),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 					   datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	case PTRACE_SETVSRREGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		return copy_regset_from_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 					     REGSET_VSX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 					     0, 32 * sizeof(double),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 					     datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #ifdef CONFIG_SPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	case PTRACE_GETEVRREGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		/* Get the child spe register state. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		return copy_regset_to_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					   REGSET_SPE, 0, 35 * sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 					   datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	case PTRACE_SETEVRREGS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		/* Set the child spe register state. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		return copy_regset_from_user(child, &user_ppc_native_view,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 					     REGSET_SPE, 0, 35 * sizeof(u32),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					     datavp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		ret = ptrace_request(child, request, addr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #ifdef CONFIG_SECCOMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static int do_seccomp(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	if (!test_thread_flag(TIF_SECCOMP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	 * The ABI we present to seccomp tracers is that r3 contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	 * the syscall return value and orig_gpr3 contains the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	 * syscall parameter. This is different to the ptrace ABI where
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	 * both r3 and orig_gpr3 contain the first syscall parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	regs->gpr[3] = -ENOSYS;
^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) 	 * We use the __ version here because we have already checked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	 * TIF_SECCOMP. If this fails, there is nothing left to do, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	 * have already loaded -ENOSYS into r3, or seccomp has put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	 * something else in r3 (via SECCOMP_RET_ERRNO/TRACE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	if (__secure_computing(NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	 * The syscall was allowed by seccomp, restore the register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	 * state to what audit expects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	 * Note that we use orig_gpr3, which means a seccomp tracer can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	 * modify the first syscall parameter (in orig_gpr3) and also
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	 * allow the syscall to proceed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	regs->gpr[3] = regs->orig_gpr3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) static inline int do_seccomp(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #endif /* CONFIG_SECCOMP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  * do_syscall_trace_enter() - Do syscall tracing on kernel entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  * @regs: the pt_regs of the task to trace (current)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  * Performs various types of tracing on syscall entry. This includes seccomp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * ptrace, syscall tracepoints and audit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * The pt_regs are potentially visible to userspace via ptrace, so their
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * contents is ABI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  * One or more of the tracers may modify the contents of pt_regs, in particular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  * to modify arguments or even the syscall number itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * It's also possible that a tracer can choose to reject the system call. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  * that case this function will return an illegal syscall number, and will put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)  * an appropriate return value in regs->r3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  * Return: the (possibly changed) syscall number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) long do_syscall_trace_enter(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	user_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	flags = READ_ONCE(current_thread_info()->flags) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		(_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	if (flags) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		int rc = tracehook_report_syscall_entry(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		if (unlikely(flags & _TIF_SYSCALL_EMU)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			 * A nonzero return code from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			 * tracehook_report_syscall_entry() tells us to prevent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			 * the syscall execution, but we are not going to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			 * execute it anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 			 * Returning -1 will skip the syscall execution. We want
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 			 * to avoid clobbering any registers, so we don't goto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 			 * the skip label below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			 * The tracer decided to abort the syscall. Note that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			 * the tracer may also just change regs->gpr[0] to an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			 * invalid syscall number, that is handled below on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 			 * exit path.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 			goto skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	/* Run seccomp after ptrace; allow it to set gpr[3]. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	if (do_seccomp(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	/* Avoid trace and audit when syscall is invalid. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	if (regs->gpr[0] >= NR_syscalls)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		goto skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		trace_sys_enter(regs, regs->gpr[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	if (!is_32bit_task())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		audit_syscall_entry(regs->gpr[0], regs->gpr[3], regs->gpr[4],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 				    regs->gpr[5], regs->gpr[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		audit_syscall_entry(regs->gpr[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 				    regs->gpr[3] & 0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 				    regs->gpr[4] & 0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 				    regs->gpr[5] & 0xffffffff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 				    regs->gpr[6] & 0xffffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	/* Return the possibly modified but valid syscall number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	return regs->gpr[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) skip:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	 * If we are aborting explicitly, or if the syscall number is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	 * now invalid, set the return value to -ENOSYS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	regs->gpr[3] = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void do_syscall_trace_leave(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	int step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	audit_syscall_exit(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		trace_sys_exit(regs, regs->result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	step = test_thread_flag(TIF_SINGLESTEP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		tracehook_report_syscall_exit(regs, step);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	user_enter();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) void __init pt_regs_check(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  * Dummy function, its purpose is to break the build if struct pt_regs and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  * struct user_pt_regs don't match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) void __init pt_regs_check(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		     offsetof(struct user_pt_regs, gpr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	BUILD_BUG_ON(offsetof(struct pt_regs, nip) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		     offsetof(struct user_pt_regs, nip));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	BUILD_BUG_ON(offsetof(struct pt_regs, msr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		     offsetof(struct user_pt_regs, msr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	BUILD_BUG_ON(offsetof(struct pt_regs, msr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		     offsetof(struct user_pt_regs, msr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		     offsetof(struct user_pt_regs, orig_gpr3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	BUILD_BUG_ON(offsetof(struct pt_regs, ctr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		     offsetof(struct user_pt_regs, ctr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	BUILD_BUG_ON(offsetof(struct pt_regs, link) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		     offsetof(struct user_pt_regs, link));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	BUILD_BUG_ON(offsetof(struct pt_regs, xer) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		     offsetof(struct user_pt_regs, xer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	BUILD_BUG_ON(offsetof(struct pt_regs, ccr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		     offsetof(struct user_pt_regs, ccr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) #ifdef __powerpc64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	BUILD_BUG_ON(offsetof(struct pt_regs, softe) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		     offsetof(struct user_pt_regs, softe));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	BUILD_BUG_ON(offsetof(struct pt_regs, mq) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		     offsetof(struct user_pt_regs, mq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	BUILD_BUG_ON(offsetof(struct pt_regs, trap) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		     offsetof(struct user_pt_regs, trap));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	BUILD_BUG_ON(offsetof(struct pt_regs, dar) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		     offsetof(struct user_pt_regs, dar));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	BUILD_BUG_ON(offsetof(struct pt_regs, dsisr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		     offsetof(struct user_pt_regs, dsisr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	BUILD_BUG_ON(offsetof(struct pt_regs, result) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		     offsetof(struct user_pt_regs, result));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	BUILD_BUG_ON(sizeof(struct user_pt_regs) > sizeof(struct pt_regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	// Now check that the pt_regs offsets match the uapi #defines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	#define CHECK_REG(_pt, _reg) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		BUILD_BUG_ON(_pt != (offsetof(struct user_pt_regs, _reg) / \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 				     sizeof(unsigned long)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	CHECK_REG(PT_R0,  gpr[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	CHECK_REG(PT_R1,  gpr[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	CHECK_REG(PT_R2,  gpr[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	CHECK_REG(PT_R3,  gpr[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	CHECK_REG(PT_R4,  gpr[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	CHECK_REG(PT_R5,  gpr[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	CHECK_REG(PT_R6,  gpr[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	CHECK_REG(PT_R7,  gpr[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	CHECK_REG(PT_R8,  gpr[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	CHECK_REG(PT_R9,  gpr[9]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	CHECK_REG(PT_R10, gpr[10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	CHECK_REG(PT_R11, gpr[11]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	CHECK_REG(PT_R12, gpr[12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	CHECK_REG(PT_R13, gpr[13]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	CHECK_REG(PT_R14, gpr[14]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	CHECK_REG(PT_R15, gpr[15]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	CHECK_REG(PT_R16, gpr[16]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	CHECK_REG(PT_R17, gpr[17]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	CHECK_REG(PT_R18, gpr[18]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	CHECK_REG(PT_R19, gpr[19]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	CHECK_REG(PT_R20, gpr[20]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	CHECK_REG(PT_R21, gpr[21]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	CHECK_REG(PT_R22, gpr[22]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	CHECK_REG(PT_R23, gpr[23]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	CHECK_REG(PT_R24, gpr[24]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	CHECK_REG(PT_R25, gpr[25]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	CHECK_REG(PT_R26, gpr[26]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	CHECK_REG(PT_R27, gpr[27]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	CHECK_REG(PT_R28, gpr[28]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	CHECK_REG(PT_R29, gpr[29]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	CHECK_REG(PT_R30, gpr[30]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	CHECK_REG(PT_R31, gpr[31]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	CHECK_REG(PT_NIP, nip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	CHECK_REG(PT_MSR, msr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	CHECK_REG(PT_ORIG_R3, orig_gpr3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	CHECK_REG(PT_CTR, ctr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	CHECK_REG(PT_LNK, link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	CHECK_REG(PT_XER, xer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	CHECK_REG(PT_CCR, ccr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	CHECK_REG(PT_SOFTE, softe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	CHECK_REG(PT_MQ, mq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	CHECK_REG(PT_TRAP, trap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	CHECK_REG(PT_DAR, dar);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	CHECK_REG(PT_DSISR, dsisr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	CHECK_REG(PT_RESULT, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	#undef CHECK_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	BUILD_BUG_ON(PT_REGS_COUNT != sizeof(struct user_pt_regs) / sizeof(unsigned long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	 * PT_DSCR isn't a real reg, but it's important that it doesn't overlap the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	 * real registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	BUILD_BUG_ON(PT_DSCR < sizeof(struct user_pt_regs) / sizeof(unsigned long));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }