| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This file is subject to the terms and conditions of the GNU General Public | 
					
						
							|  |  |  |  * License.  See the file "COPYING" in the main directory of this archive | 
					
						
							|  |  |  |  * for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle | 
					
						
							|  |  |  |  * Copyright (C) 1999, 2000 Silicon Graphics, Inc. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifndef _ASM_PTRACE_H
 | 
					
						
							|  |  |  | #define _ASM_PTRACE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-23 00:11:26 -07:00
										 |  |  | #include <linux/compiler.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #include <linux/linkage.h>
 | 
					
						
							| 
									
										
										
										
											2008-10-25 17:30:35 +09:00
										 |  |  | #include <linux/types.h>
 | 
					
						
							| 
									
										
										
										
											2006-09-07 01:00:22 +09:00
										 |  |  | #include <asm/isadep.h>
 | 
					
						
							| 
									
										
										
										
											2012-10-09 09:47:14 +01:00
										 |  |  | #include <uapi/asm/ptrace.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-22 22:35:56 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This struct defines the way the registers are stored on the stack during a | 
					
						
							|  |  |  |  * system call/exception. As usual the registers k0/k1 aren't being saved. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | struct pt_regs { | 
					
						
							|  |  |  | #ifdef CONFIG_32BIT
 | 
					
						
							|  |  |  | 	/* Pad bytes for argument save space on the stack. */ | 
					
						
							|  |  |  | 	unsigned long pad0[6]; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Saved main processor registers. */ | 
					
						
							|  |  |  | 	unsigned long regs[32]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Saved special registers. */ | 
					
						
							|  |  |  | 	unsigned long cp0_status; | 
					
						
							|  |  |  | 	unsigned long hi; | 
					
						
							|  |  |  | 	unsigned long lo; | 
					
						
							|  |  |  | #ifdef CONFIG_CPU_HAS_SMARTMIPS
 | 
					
						
							|  |  |  | 	unsigned long acx; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	unsigned long cp0_badvaddr; | 
					
						
							|  |  |  | 	unsigned long cp0_cause; | 
					
						
							|  |  |  | 	unsigned long cp0_epc; | 
					
						
							|  |  |  | #ifdef CONFIG_MIPS_MT_SMTC
 | 
					
						
							|  |  |  | 	unsigned long cp0_tcstatus; | 
					
						
							|  |  |  | #endif /* CONFIG_MIPS_MT_SMTC */
 | 
					
						
							|  |  |  | #ifdef CONFIG_CPU_CAVIUM_OCTEON
 | 
					
						
							|  |  |  | 	unsigned long long mpl[3];	  /* MTM{0,1,2} */ | 
					
						
							|  |  |  | 	unsigned long long mtp[3];	  /* MTP{0,1,2} */ | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } __aligned(8); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-23 00:11:26 -07:00
										 |  |  | struct task_struct; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-10-11 16:18:57 +01:00
										 |  |  | extern int ptrace_getregs(struct task_struct *child, __s64 __user *data); | 
					
						
							|  |  |  | extern int ptrace_setregs(struct task_struct *child, __s64 __user *data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int ptrace_getfpregs(struct task_struct *child, __u32 __user *data); | 
					
						
							|  |  |  | extern int ptrace_setfpregs(struct task_struct *child, __u32 __user *data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-23 00:11:26 -07:00
										 |  |  | extern int ptrace_get_watch_regs(struct task_struct *child, | 
					
						
							|  |  |  | 	struct pt_watch_regs __user *addr); | 
					
						
							|  |  |  | extern int ptrace_set_watch_regs(struct task_struct *child, | 
					
						
							|  |  |  | 	struct pt_watch_regs __user *addr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Does the process account for user or for system time? | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-03 14:23:06 -05:00
										 |  |  | static inline int is_syscall_success(struct pt_regs *regs) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return !regs->regs[7]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline long regs_return_value(struct pt_regs *regs) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (is_syscall_success(regs)) | 
					
						
							|  |  |  | 		return regs->regs[2]; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return -regs->regs[2]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #define instruction_pointer(regs) ((regs)->cp0_epc)
 | 
					
						
							|  |  |  | #define profile_pc(regs) instruction_pointer(regs)
 | 
					
						
							| 
									
										
										
										
											2012-12-14 01:50:19 -05:00
										 |  |  | #define user_stack_pointer(r) ((r)->regs[29])
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-19 09:21:29 +01:00
										 |  |  | extern asmlinkage void syscall_trace_enter(struct pt_regs *regs); | 
					
						
							|  |  |  | extern asmlinkage void syscall_trace_leave(struct pt_regs *regs); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-12 17:17:21 -08:00
										 |  |  | extern void die(const char *, struct pt_regs *) __noreturn; | 
					
						
							| 
									
										
										
										
											2006-12-10 15:02:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-26 00:53:10 -04:00
										 |  |  | static inline void die_if_kernel(const char *str, struct pt_regs *regs) | 
					
						
							| 
									
										
										
										
											2006-12-10 15:02:17 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (unlikely(!user_mode(regs))) | 
					
						
							|  |  |  | 		die(str, regs); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-09 21:16:07 +02:00
										 |  |  | #define current_pt_regs()						\
 | 
					
						
							|  |  |  | ({									\ | 
					
						
							|  |  |  | 	unsigned long sp = (unsigned long)__builtin_frame_address(0);	\ | 
					
						
							|  |  |  | 	(struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1;	\ | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif /* _ASM_PTRACE_H */
 |