diff options
author | Ingo Molnar <mingo@kernel.org> | 2021-12-21 12:12:52 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2022-03-15 12:57:40 +0100 |
commit | 5bded806a16bf211296e23217514ababf3ea3b32 (patch) | |
tree | 848ebb5d0a0ef569ebe7420765923439e4e83014 | |
parent | d790a8cd9b5b99e1da473d5ca30d62a93fb08b0e (diff) | |
download | tip-5bded806a16bf211296e23217514ababf3ea3b32.tar.gz |
headers/deps: x86/stacktrace: Move various unwind APIs from <asm/stacktrace.h> to <asm/unwind.h>
This helps decouple <asm/stacktrace.h> from <asm/switch_to.h> details.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/stacktrace.h | 42 | ||||
-rw-r--r-- | arch/x86/include/asm/unwind.h | 43 |
2 files changed, 43 insertions, 42 deletions
diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h index e6377d568cd299..13169ba98e53ca 100644 --- a/arch/x86/include/asm/stacktrace.h +++ b/arch/x86/include/asm/stacktrace.h @@ -38,16 +38,6 @@ int get_stack_info(unsigned long *stack, struct task_struct *task, bool get_stack_info_noinstr(unsigned long *stack, struct task_struct *task, struct stack_info *info); -static __always_inline -bool get_stack_guard_info(unsigned long *stack, struct stack_info *info) -{ - /* make sure it's not in the stack proper */ - if (get_stack_info_noinstr(stack, current, info)) - return false; - /* but if it is in the page below it, we hit a guard */ - return get_stack_info_noinstr((void *)stack + PAGE_SIZE, current, info); -} - const char *stack_type_name(enum stack_type type); static inline bool on_stack(struct stack_info *info, void *addr, size_t len) @@ -66,38 +56,6 @@ static inline bool on_stack(struct stack_info *info, void *addr, size_t len) #define STACKSLOTS_PER_LINE 4 #endif -#ifdef CONFIG_FRAME_POINTER -static inline unsigned long * -get_frame_pointer(struct task_struct *task, struct pt_regs *regs) -{ - if (regs) - return (unsigned long *)regs->bp; - - if (task == current) - return __builtin_frame_address(0); - - return &((struct inactive_task_frame *)task_thread(task).sp)->bp; -} -#else -static inline unsigned long * -get_frame_pointer(struct task_struct *task, struct pt_regs *regs) -{ - return NULL; -} -#endif /* CONFIG_FRAME_POINTER */ - -static inline unsigned long * -get_stack_pointer(struct task_struct *task, struct pt_regs *regs) -{ - if (regs) - return (unsigned long *)regs->sp; - - if (task == current) - return __builtin_frame_address(0); - - return (unsigned long *)task_thread(task).sp; -} - /* The form of the top of the frame on the stack */ struct stack_frame { struct stack_frame *next_frame; diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h index 59c73d9ce98176..fc251e91dba54b 100644 --- a/arch/x86/include/asm/unwind.h +++ b/arch/x86/include/asm/unwind.h @@ -6,6 +6,19 @@ #include <linux/kprobes.h> #include <asm/ptrace.h> #include <asm/stacktrace.h> +#include <asm/switch_to.h> + +static inline unsigned long * +get_stack_pointer(struct task_struct *task, struct pt_regs *regs) +{ + if (regs) + return (unsigned long *)regs->sp; + + if (task == current) + return __builtin_frame_address(0); + + return (unsigned long *)task_thread(task).sp; +} #define IRET_FRAME_OFFSET (offsetof(struct pt_regs, ip)) #define IRET_FRAME_SIZE (sizeof(struct pt_regs) - IRET_FRAME_OFFSET) @@ -142,4 +155,34 @@ unsigned long unwind_recover_ret_addr(struct unwind_state *state, val; \ }) +#ifdef CONFIG_FRAME_POINTER +static inline unsigned long * +get_frame_pointer(struct task_struct *task, struct pt_regs *regs) +{ + if (regs) + return (unsigned long *)regs->bp; + + if (task == current) + return __builtin_frame_address(0); + + return &((struct inactive_task_frame *)task_thread(task).sp)->bp; +} +#else +static inline unsigned long * +get_frame_pointer(struct task_struct *task, struct pt_regs *regs) +{ + return NULL; +} +#endif /* CONFIG_FRAME_POINTER */ + +static __always_inline +bool get_stack_guard_info(unsigned long *stack, struct stack_info *info) +{ + /* make sure it's not in the stack proper */ + if (get_stack_info_noinstr(stack, current, info)) + return false; + /* but if it is in the page below it, we hit a guard */ + return get_stack_info_noinstr((void *)stack + PAGE_SIZE, current, info); +} + #endif /* _ASM_X86_UNWIND_H */ |