xref: /linux/arch/x86/include/asm/unwind_user.h (revision 6f7e6393d1ce636bb7ec77a7fe7b77458fddf701)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_UNWIND_USER_H
3 #define _ASM_X86_UNWIND_USER_H
4 
5 #ifdef CONFIG_UNWIND_USER
6 
7 #include <asm/ptrace.h>
8 #include <asm/uprobes.h>
9 
10 static inline int unwind_user_word_size(struct pt_regs *regs)
11 {
12 	/* We can't unwind VM86 stacks */
13 	if (regs->flags & X86_VM_MASK)
14 		return 0;
15 	return user_64bit_mode(regs) ? 8 : 4;
16 }
17 
18 #endif /* CONFIG_UNWIND_USER */
19 
20 #ifdef CONFIG_HAVE_UNWIND_USER_FP
21 
22 #define ARCH_INIT_USER_FP_FRAME(ws)			\
23 	.cfa_off	=  2*(ws),			\
24 	.ra_off		= -1*(ws),			\
25 	.fp_off		= -2*(ws),			\
26 	.use_fp		= true,
27 
28 #define ARCH_INIT_USER_FP_ENTRY_FRAME(ws)		\
29 	.cfa_off	=  1*(ws),			\
30 	.ra_off		= -1*(ws),			\
31 	.fp_off		= 0,				\
32 	.use_fp		= false,
33 
34 static inline bool unwind_user_at_function_start(struct pt_regs *regs)
35 {
36 	return is_uprobe_at_func_entry(regs);
37 }
38 #define unwind_user_at_function_start unwind_user_at_function_start
39 
40 #endif /* CONFIG_HAVE_UNWIND_USER_FP */
41 
42 #endif /* _ASM_X86_UNWIND_USER_H */
43