Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / powerpc / include / asm / ptrace.h
blob279b80f3bb293d0bceceecb9eb38ff344e26b8fb
1 /*
2 * Copyright (C) 2001 PPC64 Team, IBM Corp
4 * This struct defines the way the registers are stored on the
5 * kernel stack during a system call or other kernel entry.
7 * this should only contain volatile regs
8 * since we can keep non-volatile in the thread_struct
9 * should set this up when only volatiles are saved
10 * by intr code.
12 * Since this is going on the stack, *CARE MUST BE TAKEN* to insure
13 * that the overall structure is a multiple of 16 bytes in length.
15 * Note that the offsets of the fields in this struct correspond with
16 * the PT_* values below. This simplifies arch/powerpc/kernel/ptrace.c.
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version
21 * 2 of the License, or (at your option) any later version.
23 #ifndef _ASM_POWERPC_PTRACE_H
24 #define _ASM_POWERPC_PTRACE_H
26 #include <uapi/asm/ptrace.h>
29 #ifdef __powerpc64__
32 * Size of redzone that userspace is allowed to use below the stack
33 * pointer. This is 288 in the 64-bit big-endian ELF ABI, and 512 in
34 * the new ELFv2 little-endian ABI, so we allow the larger amount.
36 * For kernel code we allow a 288-byte redzone, in order to conserve
37 * kernel stack space; gcc currently only uses 288 bytes, and will
38 * hopefully allow explicit control of the redzone size in future.
40 #define USER_REDZONE_SIZE 512
41 #define KERNEL_REDZONE_SIZE 288
43 #define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
44 #define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */
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
50 /* Size of dummy stack frame allocated when calling signal handler. */
51 #define __SIGNAL_FRAMESIZE 128
52 #define __SIGNAL_FRAMESIZE32 64
54 #else /* __powerpc64__ */
56 #define USER_REDZONE_SIZE 0
57 #define KERNEL_REDZONE_SIZE 0
58 #define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */
59 #define STACK_FRAME_LR_SAVE 1 /* Location of LR in stack frame */
60 #define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
61 #define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
62 #define STACK_FRAME_MARKER 2
64 /* Size of stack frame allocated when calling signal handler. */
65 #define __SIGNAL_FRAMESIZE 64
67 #endif /* __powerpc64__ */
69 #ifndef __ASSEMBLY__
71 #define GET_IP(regs) ((regs)->nip)
72 #define GET_USP(regs) ((regs)->gpr[1])
73 #define GET_FP(regs) (0)
74 #define SET_FP(regs, val)
76 #ifdef CONFIG_SMP
77 extern unsigned long profile_pc(struct pt_regs *regs);
78 #define profile_pc profile_pc
79 #endif
81 #include <asm-generic/ptrace.h>
83 #define kernel_stack_pointer(regs) ((regs)->gpr[1])
84 static inline int is_syscall_success(struct pt_regs *regs)
86 return !(regs->ccr & 0x10000000);
89 static inline long regs_return_value(struct pt_regs *regs)
91 if (is_syscall_success(regs))
92 return regs->gpr[3];
93 else
94 return -regs->gpr[3];
97 #ifdef __powerpc64__
98 #define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)
99 #else
100 #define user_mode(regs) (((regs)->msr & MSR_PR) != 0)
101 #endif
103 #define force_successful_syscall_return() \
104 do { \
105 set_thread_flag(TIF_NOERROR); \
106 } while(0)
108 struct task_struct;
109 extern int ptrace_get_reg(struct task_struct *task, int regno,
110 unsigned long *data);
111 extern int ptrace_put_reg(struct task_struct *task, int regno,
112 unsigned long data);
114 #define current_pt_regs() \
115 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
117 * We use the least-significant bit of the trap field to indicate
118 * whether we have saved the full set of registers, or only a
119 * partial set. A 1 there means the partial set.
120 * On 4xx we use the next bit to indicate whether the exception
121 * is a critical exception (1 means it is).
123 #define FULL_REGS(regs) (((regs)->trap & 1) == 0)
124 #ifndef __powerpc64__
125 #define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0)
126 #define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0)
127 #define IS_DEBUG_EXC(regs) (((regs)->trap & 8) != 0)
128 #endif /* ! __powerpc64__ */
129 #define TRAP(regs) ((regs)->trap & ~0xF)
130 #ifdef __powerpc64__
131 #define NV_REG_POISON 0xdeadbeefdeadbeefUL
132 #define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
133 #else
134 #define NV_REG_POISON 0xdeadbeef
135 #define CHECK_FULL_REGS(regs) \
136 do { \
137 if ((regs)->trap & 1) \
138 printk(KERN_CRIT "%s: partial register set\n", __func__); \
139 } while (0)
140 #endif /* __powerpc64__ */
142 #define arch_has_single_step() (1)
143 #define arch_has_block_step() (!cpu_has_feature(CPU_FTR_601))
144 #define ARCH_HAS_USER_SINGLE_STEP_INFO
147 * kprobe-based event tracer support
150 #include <linux/stddef.h>
151 #include <linux/thread_info.h>
152 extern int regs_query_register_offset(const char *name);
153 extern const char *regs_query_register_name(unsigned int offset);
154 #define MAX_REG_OFFSET (offsetof(struct pt_regs, dsisr))
157 * regs_get_register() - get register value from its offset
158 * @regs: pt_regs from which register value is gotten
159 * @offset: offset number of the register.
161 * regs_get_register returns the value of a register whose offset from @regs.
162 * The @offset is the offset of the register in struct pt_regs.
163 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
165 static inline unsigned long regs_get_register(struct pt_regs *regs,
166 unsigned int offset)
168 if (unlikely(offset > MAX_REG_OFFSET))
169 return 0;
170 return *(unsigned long *)((unsigned long)regs + offset);
174 * regs_within_kernel_stack() - check the address in the stack
175 * @regs: pt_regs which contains kernel stack pointer.
176 * @addr: address which is checked.
178 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
179 * If @addr is within the kernel stack, it returns true. If not, returns false.
182 static inline bool regs_within_kernel_stack(struct pt_regs *regs,
183 unsigned long addr)
185 return ((addr & ~(THREAD_SIZE - 1)) ==
186 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
190 * regs_get_kernel_stack_nth() - get Nth entry of the stack
191 * @regs: pt_regs which contains kernel stack pointer.
192 * @n: stack entry number.
194 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
195 * is specified by @regs. If the @n th entry is NOT in the kernel stack,
196 * this returns 0.
198 static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
199 unsigned int n)
201 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
202 addr += n;
203 if (regs_within_kernel_stack(regs, (unsigned long)addr))
204 return *addr;
205 else
206 return 0;
209 #endif /* __ASSEMBLY__ */
211 #ifndef __powerpc64__
212 #else /* __powerpc64__ */
213 #define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */
214 #define PT_VR0_32 164 /* each Vector reg occupies 4 slots in 32-bit */
215 #define PT_VSCR_32 (PT_VR0 + 32*4 + 3)
216 #define PT_VRSAVE_32 (PT_VR0 + 33*4)
217 #define PT_VSR0_32 300 /* each VSR reg occupies 4 slots in 32-bit */
218 #endif /* __powerpc64__ */
219 #endif /* _ASM_POWERPC_PTRACE_H */