ptrace.h (28d42ea14e489047caeaa89496a3ad7e0ae6a49f) ptrace.h (3c88c692c28746473791276f8b42d2c989d6cbe6)
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_PTRACE_H
3#define _ASM_X86_PTRACE_H
4
5#include <asm/segment.h>
6#include <asm/page_types.h>
7#include <uapi/asm/ptrace.h>
8

--- 88 unchanged lines hidden (view full) ---

97struct cpuinfo_x86;
98struct task_struct;
99
100extern unsigned long profile_pc(struct pt_regs *regs);
101#define profile_pc profile_pc
102
103extern unsigned long
104convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_PTRACE_H
3#define _ASM_X86_PTRACE_H
4
5#include <asm/segment.h>
6#include <asm/page_types.h>
7#include <uapi/asm/ptrace.h>
8

--- 88 unchanged lines hidden (view full) ---

97struct cpuinfo_x86;
98struct task_struct;
99
100extern unsigned long profile_pc(struct pt_regs *regs);
101#define profile_pc profile_pc
102
103extern unsigned long
104convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
105extern void send_sigtrap(struct pt_regs *regs, int error_code, int si_code);
105extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
106 int error_code, int si_code);
106
107
108static inline unsigned long regs_return_value(struct pt_regs *regs)
109{
110 return regs->ax;
111}
112
113static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)

--- 46 unchanged lines hidden (view full) ---

160#endif
161}
162
163#ifdef CONFIG_X86_64
164#define current_user_stack_pointer() current_pt_regs()->sp
165#define compat_user_stack_pointer() current_pt_regs()->sp
166#endif
167
107
108
109static inline unsigned long regs_return_value(struct pt_regs *regs)
110{
111 return regs->ax;
112}
113
114static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)

--- 46 unchanged lines hidden (view full) ---

161#endif
162}
163
164#ifdef CONFIG_X86_64
165#define current_user_stack_pointer() current_pt_regs()->sp
166#define compat_user_stack_pointer() current_pt_regs()->sp
167#endif
168
168#ifdef CONFIG_X86_32
169extern unsigned long kernel_stack_pointer(struct pt_regs *regs);
170#else
171static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
172{
173 return regs->sp;
174}
169static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
170{
171 return regs->sp;
172}
175#endif
176
177#define GET_IP(regs) ((regs)->ip)
178#define GET_FP(regs) ((regs)->bp)
179#define GET_USP(regs) ((regs)->sp)
180
181#include <asm-generic/ptrace.h>
182
183/* Query offset/name of register from its name/offset */

--- 11 unchanged lines hidden (view full) ---

195 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
196 */
197static inline unsigned long regs_get_register(struct pt_regs *regs,
198 unsigned int offset)
199{
200 if (unlikely(offset > MAX_REG_OFFSET))
201 return 0;
202#ifdef CONFIG_X86_32
173
174#define GET_IP(regs) ((regs)->ip)
175#define GET_FP(regs) ((regs)->bp)
176#define GET_USP(regs) ((regs)->sp)
177
178#include <asm-generic/ptrace.h>
179
180/* Query offset/name of register from its name/offset */

--- 11 unchanged lines hidden (view full) ---

192 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
193 */
194static inline unsigned long regs_get_register(struct pt_regs *regs,
195 unsigned int offset)
196{
197 if (unlikely(offset > MAX_REG_OFFSET))
198 return 0;
199#ifdef CONFIG_X86_32
203 /*
204 * Traps from the kernel do not save sp and ss.
205 * Use the helper function to retrieve sp.
206 */
207 if (offset == offsetof(struct pt_regs, sp) &&
208 regs->cs == __KERNEL_CS)
209 return kernel_stack_pointer(regs);
210
211 /* The selector fields are 16-bit. */
212 if (offset == offsetof(struct pt_regs, cs) ||
213 offset == offsetof(struct pt_regs, ss) ||
214 offset == offsetof(struct pt_regs, ds) ||
215 offset == offsetof(struct pt_regs, es) ||
216 offset == offsetof(struct pt_regs, fs) ||
217 offset == offsetof(struct pt_regs, gs)) {
218 return *(u16 *)((unsigned long)regs + offset);

--- 9 unchanged lines hidden (view full) ---

228 * @addr: address which is checked.
229 *
230 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
231 * If @addr is within the kernel stack, it returns true. If not, returns false.
232 */
233static inline int regs_within_kernel_stack(struct pt_regs *regs,
234 unsigned long addr)
235{
200 /* The selector fields are 16-bit. */
201 if (offset == offsetof(struct pt_regs, cs) ||
202 offset == offsetof(struct pt_regs, ss) ||
203 offset == offsetof(struct pt_regs, ds) ||
204 offset == offsetof(struct pt_regs, es) ||
205 offset == offsetof(struct pt_regs, fs) ||
206 offset == offsetof(struct pt_regs, gs)) {
207 return *(u16 *)((unsigned long)regs + offset);

--- 9 unchanged lines hidden (view full) ---

217 * @addr: address which is checked.
218 *
219 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
220 * If @addr is within the kernel stack, it returns true. If not, returns false.
221 */
222static inline int regs_within_kernel_stack(struct pt_regs *regs,
223 unsigned long addr)
224{
236 return ((addr & ~(THREAD_SIZE - 1)) ==
237 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
225 return ((addr & ~(THREAD_SIZE - 1)) == (regs->sp & ~(THREAD_SIZE - 1)));
238}
239
240/**
241 * regs_get_kernel_stack_nth_addr() - get the address of the Nth entry on stack
242 * @regs: pt_regs which contains kernel stack pointer.
243 * @n: stack entry number.
244 *
245 * regs_get_kernel_stack_nth() returns the address of the @n th entry of the
246 * kernel stack which is specified by @regs. If the @n th entry is NOT in
247 * the kernel stack, this returns NULL.
248 */
249static inline unsigned long *regs_get_kernel_stack_nth_addr(struct pt_regs *regs, unsigned int n)
250{
226}
227
228/**
229 * regs_get_kernel_stack_nth_addr() - get the address of the Nth entry on stack
230 * @regs: pt_regs which contains kernel stack pointer.
231 * @n: stack entry number.
232 *
233 * regs_get_kernel_stack_nth() returns the address of the @n th entry of the
234 * kernel stack which is specified by @regs. If the @n th entry is NOT in
235 * the kernel stack, this returns NULL.
236 */
237static inline unsigned long *regs_get_kernel_stack_nth_addr(struct pt_regs *regs, unsigned int n)
238{
251 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
239 unsigned long *addr = (unsigned long *)regs->sp;
252
253 addr += n;
254 if (regs_within_kernel_stack(regs, (unsigned long)addr))
255 return addr;
256 else
257 return NULL;
258}
259

--- 99 unchanged lines hidden ---
240
241 addr += n;
242 if (regs_within_kernel_stack(regs, (unsigned long)addr))
243 return addr;
244 else
245 return NULL;
246}
247

--- 99 unchanged lines hidden ---