Lines Matching +full:big +full:- +full:endian +full:- +full:regs
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
8 * this should only contain volatile regs
9 * since we can keep non-volatile in the thread_struct
24 #include <asm/asm-const.h>
100 // Always displays as "REGS" in memory dumps
111 * pointer. This is 288 in the 64-bit big-endian ELF ABI, and 512 in
112 * the new ELFv2 little-endian ABI, so we allow the larger amount.
114 * For kernel code we allow a 288-byte redzone, in order to conserve
139 #define STACK_INT_FRAME_MARKER (STACK_FRAME_MIN_SIZE - 16)
156 #define STACK_INT_FRAME_MARKER (STACK_FRAME_MIN_SIZE - 8)
172 extern unsigned long profile_pc(struct pt_regs *regs);
174 #define profile_pc(regs) instruction_pointer(regs) argument
177 long do_syscall_trace_enter(struct pt_regs *regs);
178 void do_syscall_trace_leave(struct pt_regs *regs);
183 WRITE_ONCE(local_paca->hsrr_valid, 0); in set_return_regs_changed()
184 WRITE_ONCE(local_paca->srr_valid, 0); in set_return_regs_changed()
188 static inline void regs_set_return_ip(struct pt_regs *regs, unsigned long ip) in regs_set_return_ip() argument
190 regs->nip = ip; in regs_set_return_ip()
194 static inline void regs_set_return_msr(struct pt_regs *regs, unsigned long msr) in regs_set_return_msr() argument
196 regs->msr = msr; in regs_set_return_msr()
200 static inline void regs_add_return_ip(struct pt_regs *regs, long offset) in regs_add_return_ip() argument
202 regs_set_return_ip(regs, regs->nip + offset); in regs_add_return_ip()
205 static inline unsigned long instruction_pointer(struct pt_regs *regs) in instruction_pointer() argument
207 return regs->nip; in instruction_pointer()
210 static inline void instruction_pointer_set(struct pt_regs *regs, in instruction_pointer_set() argument
213 regs_set_return_ip(regs, val); in instruction_pointer_set()
216 static inline unsigned long user_stack_pointer(struct pt_regs *regs) in user_stack_pointer() argument
218 return regs->gpr[1]; in user_stack_pointer()
221 static inline unsigned long frame_pointer(struct pt_regs *regs) in frame_pointer() argument
226 #define user_mode(regs) (((regs)->msr & MSR_PR) != 0) argument
234 ((struct pt_regs *)((unsigned long)task_stack_page(current) + THREAD_SIZE) - 1)
250 #define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0) argument
251 #define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0) argument
252 #define IS_DEBUG_EXC(regs) (((regs)->trap & 8) != 0) argument
254 #define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK) argument
256 static __always_inline void set_trap(struct pt_regs *regs, unsigned long val) in set_trap() argument
258 regs->trap = (regs->trap & TRAP_FLAGS_MASK) | (val & ~TRAP_FLAGS_MASK); in set_trap()
261 static inline bool trap_is_scv(struct pt_regs *regs) in trap_is_scv() argument
263 return (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) == 0x3000); in trap_is_scv()
266 static inline bool trap_is_unsupported_scv(struct pt_regs *regs) in trap_is_unsupported_scv() argument
268 return IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) == 0x7ff0; in trap_is_unsupported_scv()
271 static inline bool trap_is_syscall(struct pt_regs *regs) in trap_is_syscall() argument
273 return (trap_is_scv(regs) || TRAP(regs) == 0xc00); in trap_is_syscall()
276 static inline bool trap_norestart(struct pt_regs *regs) in trap_norestart() argument
278 return regs->trap & 0x1; in trap_norestart()
281 static __always_inline void set_trap_norestart(struct pt_regs *regs) in set_trap_norestart() argument
283 regs->trap |= 0x1; in set_trap_norestart()
286 #define kernel_stack_pointer(regs) ((regs)->gpr[1]) argument
287 static inline int is_syscall_success(struct pt_regs *regs) in is_syscall_success() argument
289 if (trap_is_scv(regs)) in is_syscall_success()
290 return !IS_ERR_VALUE((unsigned long)regs->gpr[3]); in is_syscall_success()
292 return !(regs->ccr & 0x10000000); in is_syscall_success()
295 static inline long regs_return_value(struct pt_regs *regs) in regs_return_value() argument
297 if (trap_is_scv(regs)) in regs_return_value()
298 return regs->gpr[3]; in regs_return_value()
300 if (is_syscall_success(regs)) in regs_return_value()
301 return regs->gpr[3]; in regs_return_value()
303 return -regs->gpr[3]; in regs_return_value()
306 static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) in regs_set_return_value() argument
308 regs->gpr[3] = rc; in regs_set_return_value()
316 static inline bool regs_is_unrecoverable(struct pt_regs *regs) in regs_is_unrecoverable() argument
318 return unlikely(cpu_has_msr_ri() && !(regs->msr & MSR_RI)); in regs_is_unrecoverable()
321 static inline void regs_set_recoverable(struct pt_regs *regs) in regs_set_recoverable() argument
324 regs_set_return_msr(regs, regs->msr | MSR_RI); in regs_set_recoverable()
327 static inline void regs_set_unrecoverable(struct pt_regs *regs) in regs_set_unrecoverable() argument
330 regs_set_return_msr(regs, regs->msr & ~MSR_RI); in regs_set_unrecoverable()
338 * kprobe-based event tracer support
348 * regs_get_register() - get register value from its offset
349 * @regs: pt_regs from which register value is gotten
352 * regs_get_register returns the value of a register whose offset from @regs.
356 static inline unsigned long regs_get_register(struct pt_regs *regs, in regs_get_register() argument
361 return *(unsigned long *)((unsigned long)regs + offset); in regs_get_register()
365 * regs_within_kernel_stack() - check the address in the stack
366 * @regs: pt_regs which contains kernel stack pointer.
373 static inline bool regs_within_kernel_stack(struct pt_regs *regs, in regs_within_kernel_stack() argument
376 return ((addr & ~(THREAD_SIZE - 1)) == in regs_within_kernel_stack()
377 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1))); in regs_within_kernel_stack()
381 * regs_get_kernel_stack_nth() - get Nth entry of the stack
382 * @regs: pt_regs which contains kernel stack pointer.
386 * is specified by @regs. If the @n th entry is NOT in the kernel stack,
389 static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, in regs_get_kernel_stack_nth() argument
392 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs); in regs_get_kernel_stack_nth()
394 if (regs_within_kernel_stack(regs, (unsigned long)addr)) in regs_get_kernel_stack_nth()
401 * regs_get_kernel_argument() - get Nth function argument in kernel
402 * @regs: pt_regs of that context
407 * kernel code. This is expected to be called from kprobes or ftrace with regs.
409 static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, unsigned int n) in regs_get_kernel_argument() argument
413 return regs_get_register(regs, offsetof(struct pt_regs, gpr[3 + n])); in regs_get_kernel_argument()
423 #define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */
424 #define PT_VR0_32 164 /* each Vector reg occupies 4 slots in 32-bit */
427 #define PT_VSR0_32 300 /* each VSR reg occupies 4 slots in 32-bit */