/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2001 PPC64 Team, IBM Corp * * This struct defines the way the registers are stored on the * kernel stack during a system call or other kernel entry. * * this should only contain volatile regs * since we can keep non-volatile in the thread_struct * should set this up when only volatiles are saved * by intr code. * * Since this is going on the stack, *CARE MUST BE TAKEN* to insure * that the overall structure is a multiple of 16 bytes in length. * * Note that the offsets of the fields in this struct correspond with * the PT_* values below. This simplifies arch/powerpc/kernel/ptrace.c.
*/ #ifndef _ASM_POWERPC_PTRACE_H #define _ASM_POWERPC_PTRACE_H
// Always displays as "REGS" in memory dumps #ifdef CONFIG_CPU_BIG_ENDIAN #define STACK_FRAME_REGS_MARKER ASM_CONST(0x52454753) #else #define STACK_FRAME_REGS_MARKER ASM_CONST(0x53474552) #endif
#ifdef __powerpc64__
/* * Size of redzone that userspace is allowed to use below the stack * pointer. This is 288 in the 64-bit big-endian ELF ABI, and 512 in * the new ELFv2 little-endian ABI, so we allow the larger amount. * * For kernel code we allow a 288-byte redzone, in order to conserve * kernel stack space; gcc currently only uses 288 bytes, and will * hopefully allow explicit control of the redzone size in future.
*/ #define USER_REDZONE_SIZE 512 #define KERNEL_REDZONE_SIZE 288
#define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */
#ifdef CONFIG_PPC64_ELF_ABI_V2 #define STACK_FRAME_MIN_SIZE 32 #define STACK_USER_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_MIN_SIZE + 16) #define STACK_INT_FRAME_REGS (STACK_FRAME_MIN_SIZE + 16) #define STACK_INT_FRAME_MARKER STACK_FRAME_MIN_SIZE #define STACK_SWITCH_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_MIN_SIZE + 16) #define STACK_SWITCH_FRAME_REGS (STACK_FRAME_MIN_SIZE + 16) #else /* * The ELFv1 ABI specifies 48 bytes plus a minimum 64 byte parameter save * area. This parameter area is not used by calls to C from interrupt entry, * so the second from last one of those is used for the frame marker.
*/ #define STACK_FRAME_MIN_SIZE 112 #define STACK_USER_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_MIN_SIZE) #define STACK_INT_FRAME_REGS STACK_FRAME_MIN_SIZE #define STACK_INT_FRAME_MARKER (STACK_FRAME_MIN_SIZE - 16) #define STACK_SWITCH_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_MIN_SIZE) #define STACK_SWITCH_FRAME_REGS STACK_FRAME_MIN_SIZE #endif
/* Size of dummy stack frame allocated when calling signal handler. */ #define __SIGNAL_FRAMESIZE 128 #define __SIGNAL_FRAMESIZE32 64
/* * The 4 low bits (0xf) are available as flags to overload the trap word, * because interrupt vectors have minimum alignment of 0x10. TRAP_FLAGS_MASK * must cover the bits used as flags, including bit 0 which is used as the * "norestart" bit.
*/ #ifdef __powerpc64__ #define TRAP_FLAGS_MASK 0x1 #else /* * On 4xx we use bit 1 in the trap word to indicate whether the exception * is a critical exception (1 means it is).
*/ #define TRAP_FLAGS_MASK 0xf #define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0) #define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0) #define IS_DEBUG_EXC(regs) (((regs)->trap & 8) != 0) #endif/* __powerpc64__ */ #define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK)
/** * regs_get_register() - get register value from its offset * @regs: pt_regs from which register value is gotten * @offset: offset number of the register. * * regs_get_register returns the value of a register whose offset from @regs. * The @offset is the offset of the register in struct pt_regs. * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
*/ staticinlineunsignedlong regs_get_register(struct pt_regs *regs, unsignedint offset)
{ if (unlikely(offset > MAX_REG_OFFSET)) return 0; return *(unsignedlong *)((unsignedlong)regs + offset);
}
/** * regs_within_kernel_stack() - check the address in the stack * @regs: pt_regs which contains kernel stack pointer. * @addr: address which is checked. * * regs_within_kernel_stack() checks @addr is within the kernel stack page(s). * If @addr is within the kernel stack, it returns true. If not, returns false.
*/
/** * regs_get_kernel_stack_nth() - get Nth entry of the stack * @regs: pt_regs which contains kernel stack pointer. * @n: stack entry number. * * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which * is specified by @regs. If the @n th entry is NOT in the kernel stack, * this returns 0.
*/ staticinlineunsignedlong regs_get_kernel_stack_nth(struct pt_regs *regs, unsignedint n)
{ unsignedlong *addr = (unsignedlong *)kernel_stack_pointer(regs);
addr += n; if (regs_within_kernel_stack(regs, (unsignedlong)addr)) return *addr; else return 0;
}
/** * regs_get_kernel_argument() - get Nth function argument in kernel * @regs: pt_regs of that context * @n: function argument number (start from 0) * * We support up to 8 arguments and assume they are sent in through the GPRs. * This will fail for fp/vector arguments, but those aren't usually found in * kernel code. This is expected to be called from kprobes or ftrace with regs.
*/ staticinlineunsignedlong regs_get_kernel_argument(struct pt_regs *regs, unsignedint n)
{ #define NR_REG_ARGUMENTS 8 if (n < NR_REG_ARGUMENTS) return regs_get_register(regs, offsetof(struct pt_regs, gpr[3 + n])); return 0;
}
#endif/* __ASSEMBLY__ */
#ifndef __powerpc64__ /* We need PT_SOFTE defined at all time to avoid #ifdefs */ #define PT_SOFTE PT_MQ #else/* __powerpc64__ */ #define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */ #define PT_VR0_32 164 /* each Vector reg occupies 4 slots in 32-bit */ #define PT_VSCR_32 (PT_VR0 + 32*4 + 3) #define PT_VRSAVE_32 (PT_VR0 + 33*4) #define PT_VSR0_32 300 /* each VSR reg occupies 4 slots in 32-bit */ #endif/* __powerpc64__ */ #endif/* _ASM_POWERPC_PTRACE_H */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.