xref: /linux/arch/x86/include/asm/unwind_hints.h (revision 4708ea14bef314fc901857eefd65678236a9f2d9)
1 #ifndef _ASM_X86_UNWIND_HINTS_H
2 #define _ASM_X86_UNWIND_HINTS_H
3 
4 #include <linux/objtool.h>
5 
6 #include "orc_types.h"
7 
8 #ifdef __ASSEMBLY__
9 
10 .macro UNWIND_HINT_EMPTY
11 	UNWIND_HINT type=UNWIND_HINT_TYPE_CALL end=1
12 .endm
13 
14 .macro UNWIND_HINT_ENTRY
15 	VALIDATE_UNRET_BEGIN
16 	UNWIND_HINT_EMPTY
17 .endm
18 
19 .macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0 signal=1
20 	.if \base == %rsp
21 		.if \indirect
22 			.set sp_reg, ORC_REG_SP_INDIRECT
23 		.else
24 			.set sp_reg, ORC_REG_SP
25 		.endif
26 	.elseif \base == %rbp
27 		.set sp_reg, ORC_REG_BP
28 	.elseif \base == %rdi
29 		.set sp_reg, ORC_REG_DI
30 	.elseif \base == %rdx
31 		.set sp_reg, ORC_REG_DX
32 	.elseif \base == %r10
33 		.set sp_reg, ORC_REG_R10
34 	.else
35 		.error "UNWIND_HINT_REGS: bad base register"
36 	.endif
37 
38 	.set sp_offset, \offset
39 
40 	.if \partial
41 		.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
42 	.elseif \extra == 0
43 		.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
44 		.set sp_offset, \offset + (16*8)
45 	.else
46 		.set type, UNWIND_HINT_TYPE_REGS
47 	.endif
48 
49 	UNWIND_HINT sp_reg=sp_reg sp_offset=sp_offset type=type signal=\signal
50 .endm
51 
52 .macro UNWIND_HINT_IRET_REGS base=%rsp offset=0 signal=1
53 	UNWIND_HINT_REGS base=\base offset=\offset partial=1 signal=\signal
54 .endm
55 
56 .macro UNWIND_HINT_IRET_ENTRY base=%rsp offset=0 signal=1
57 	VALIDATE_UNRET_BEGIN
58 	UNWIND_HINT_IRET_REGS base=\base offset=\offset signal=\signal
59 .endm
60 
61 .macro UNWIND_HINT_FUNC
62 	UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=8 type=UNWIND_HINT_TYPE_FUNC
63 .endm
64 
65 .macro UNWIND_HINT_SAVE
66 	UNWIND_HINT type=UNWIND_HINT_TYPE_SAVE
67 .endm
68 
69 .macro UNWIND_HINT_RESTORE
70 	UNWIND_HINT type=UNWIND_HINT_TYPE_RESTORE
71 .endm
72 
73 #else
74 
75 #define UNWIND_HINT_FUNC \
76 	UNWIND_HINT(UNWIND_HINT_TYPE_FUNC, ORC_REG_SP, 8, 0, 0)
77 
78 #endif /* __ASSEMBLY__ */
79 
80 #endif /* _ASM_X86_UNWIND_HINTS_H */
81