1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _ASM_POWERPC_PTRACE_H
24#define _ASM_POWERPC_PTRACE_H
25
26#include <uapi/asm/ptrace.h>
27
28
29#ifdef __powerpc64__
30
31
32
33
34
35
36
37
38
39
40#define USER_REDZONE_SIZE 512
41#define KERNEL_REDZONE_SIZE 288
42
43#define STACK_FRAME_OVERHEAD 112
44#define STACK_FRAME_LR_SAVE 2
45#define STACK_FRAME_REGS_MARKER ASM_CONST(0x7265677368657265)
46#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + \
47 STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE)
48#define STACK_FRAME_MARKER 12
49
50#if defined(_CALL_ELF) && _CALL_ELF == 2
51#define STACK_FRAME_MIN_SIZE 32
52#else
53#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
54#endif
55
56
57#define __SIGNAL_FRAMESIZE 128
58#define __SIGNAL_FRAMESIZE32 64
59
60#else
61
62#define USER_REDZONE_SIZE 0
63#define KERNEL_REDZONE_SIZE 0
64#define STACK_FRAME_OVERHEAD 16
65#define STACK_FRAME_LR_SAVE 1
66#define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
67#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
68#define STACK_FRAME_MARKER 2
69#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
70
71
72#define __SIGNAL_FRAMESIZE 64
73
74#endif
75
76#ifndef __ASSEMBLY__
77
78#define GET_IP(regs) ((regs)->nip)
79#define GET_USP(regs) ((regs)->gpr[1])
80#define GET_FP(regs) (0)
81#define SET_FP(regs, val)
82
83#ifdef CONFIG_SMP
84extern unsigned long profile_pc(struct pt_regs *regs);
85#define profile_pc profile_pc
86#endif
87
88#include <asm-generic/ptrace.h>
89
90#define kernel_stack_pointer(regs) ((regs)->gpr[1])
91static inline int is_syscall_success(struct pt_regs *regs)
92{
93 return !(regs->ccr & 0x10000000);
94}
95
96static inline long regs_return_value(struct pt_regs *regs)
97{
98 if (is_syscall_success(regs))
99 return regs->gpr[3];
100 else
101 return -regs->gpr[3];
102}
103
104#ifdef __powerpc64__
105#define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)
106#else
107#define user_mode(regs) (((regs)->msr & MSR_PR) != 0)
108#endif
109
110#define force_successful_syscall_return() \
111 do { \
112 set_thread_flag(TIF_NOERROR); \
113 } while(0)
114
115struct task_struct;
116extern int ptrace_get_reg(struct task_struct *task, int regno,
117 unsigned long *data);
118extern int ptrace_put_reg(struct task_struct *task, int regno,
119 unsigned long data);
120
121#define current_pt_regs() \
122 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
123
124
125
126
127
128
129
130#define FULL_REGS(regs) (((regs)->trap & 1) == 0)
131#ifndef __powerpc64__
132#define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0)
133#define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0)
134#define IS_DEBUG_EXC(regs) (((regs)->trap & 8) != 0)
135#endif
136#define TRAP(regs) ((regs)->trap & ~0xF)
137#ifdef __powerpc64__
138#define NV_REG_POISON 0xdeadbeefdeadbeefUL
139#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
140#else
141#define NV_REG_POISON 0xdeadbeef
142#define CHECK_FULL_REGS(regs) \
143do { \
144 if ((regs)->trap & 1) \
145 printk(KERN_CRIT "%s: partial register set\n", __func__); \
146} while (0)
147#endif
148
149#define arch_has_single_step() (1)
150#define arch_has_block_step() (!cpu_has_feature(CPU_FTR_601))
151#define ARCH_HAS_USER_SINGLE_STEP_INFO
152
153
154
155
156
157#include <linux/stddef.h>
158#include <linux/thread_info.h>
159extern int regs_query_register_offset(const char *name);
160extern const char *regs_query_register_name(unsigned int offset);
161#define MAX_REG_OFFSET (offsetof(struct pt_regs, dsisr))
162
163
164
165
166
167
168
169
170
171
172static inline unsigned long regs_get_register(struct pt_regs *regs,
173 unsigned int offset)
174{
175 if (unlikely(offset > MAX_REG_OFFSET))
176 return 0;
177 return *(unsigned long *)((unsigned long)regs + offset);
178}
179
180
181
182
183
184
185
186
187
188
189static inline bool regs_within_kernel_stack(struct pt_regs *regs,
190 unsigned long addr)
191{
192 return ((addr & ~(THREAD_SIZE - 1)) ==
193 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
194}
195
196
197
198
199
200
201
202
203
204
205static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
206 unsigned int n)
207{
208 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
209 addr += n;
210 if (regs_within_kernel_stack(regs, (unsigned long)addr))
211 return *addr;
212 else
213 return 0;
214}
215
216#endif
217
218#ifndef __powerpc64__
219#else
220#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1)
221#define PT_VR0_32 164
222#define PT_VSCR_32 (PT_VR0 + 32*4 + 3)
223#define PT_VRSAVE_32 (PT_VR0 + 33*4)
224#define PT_VSR0_32 300
225#endif
226#endif
227