diff options
author | Sergey Matyukevich <sergey.matyukevich@synopsys.com> | 2022-04-14 10:17:21 +0200 |
---|---|---|
committer | Vineet Gupta <vgupta@kernel.org> | 2022-04-25 22:09:47 +0200 |
commit | b3bbf6a70ba0f827938525e285cd2be6c76a6a00 (patch) | |
tree | 344978308a2c43c32d66c519a8a9ece0f0b6a8f9 /arch/arc/include | |
parent | Linux 5.18-rc4 (diff) | |
download | linux-b3bbf6a70ba0f827938525e285cd2be6c76a6a00.tar.xz linux-b3bbf6a70ba0f827938525e285cd2be6c76a6a00.zip |
ARC: enable HAVE_REGS_AND_STACK_ACCESS_API feature
Enable HAVE_REGS_AND_STACK_ACCESS_API feature for ARC architecture,
including ARCcompact and ARCv2 flavors. Add supporting functions
and defines.
Signed-off-by: Sergey Matyukevich <sergey.matyukevich@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@kernel.org>
Diffstat (limited to 'arch/arc/include')
-rw-r--r-- | arch/arc/include/asm/ptrace.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index cca8d6583e31..5869a74c0db2 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -8,6 +8,7 @@ #define __ASM_ARC_PTRACE_H #include <uapi/asm/ptrace.h> +#include <linux/compiler.h> #ifndef __ASSEMBLY__ @@ -54,6 +55,9 @@ struct pt_regs { unsigned long user_r25; }; + +#define MAX_REG_OFFSET offsetof(struct pt_regs, user_r25) + #else struct pt_regs { @@ -102,6 +106,8 @@ struct pt_regs { unsigned long status32; }; +#define MAX_REG_OFFSET offsetof(struct pt_regs, status32) + #endif /* Callee saved registers - need to be saved only when you are scheduled out */ @@ -154,6 +160,27 @@ static inline void instruction_pointer_set(struct pt_regs *regs, { instruction_pointer(regs) = val; } + +static inline unsigned long kernel_stack_pointer(struct pt_regs *regs) +{ + return regs->sp; +} + +extern int regs_query_register_offset(const char *name); +extern const char *regs_query_register_name(unsigned int offset); +extern bool regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr); +extern unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, + unsigned int n); + +static inline unsigned long regs_get_register(struct pt_regs *regs, + unsigned int offset) +{ + if (unlikely(offset > MAX_REG_OFFSET)) + return 0; + + return *(unsigned long *)((unsigned long)regs + offset); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PTRACE_H */ |