|
1 | 1 | #ifndef _ASM_X86_UNWIND_HINTS_H |
2 | 2 | #define _ASM_X86_UNWIND_HINTS_H |
3 | 3 |
|
| 4 | +#include <linux/objtool.h> |
| 5 | + |
4 | 6 | #include "orc_types.h" |
5 | 7 |
|
6 | 8 | #ifdef __ASSEMBLY__ |
7 | 9 |
|
8 | | -/* |
9 | | - * In asm, there are two kinds of code: normal C-type callable functions and |
10 | | - * the rest. The normal callable functions can be called by other code, and |
11 | | - * don't do anything unusual with the stack. Such normal callable functions |
12 | | - * are annotated with the ENTRY/ENDPROC macros. Most asm code falls in this |
13 | | - * category. In this case, no special debugging annotations are needed because |
14 | | - * objtool can automatically generate the ORC data for the ORC unwinder to read |
15 | | - * at runtime. |
16 | | - * |
17 | | - * Anything which doesn't fall into the above category, such as syscall and |
18 | | - * interrupt handlers, tends to not be called directly by other functions, and |
19 | | - * often does unusual non-C-function-type things with the stack pointer. Such |
20 | | - * code needs to be annotated such that objtool can understand it. The |
21 | | - * following CFI hint macros are for this type of code. |
22 | | - * |
23 | | - * These macros provide hints to objtool about the state of the stack at each |
24 | | - * instruction. Objtool starts from the hints and follows the code flow, |
25 | | - * making automatic CFI adjustments when it sees pushes and pops, filling out |
26 | | - * the debuginfo as necessary. It will also warn if it sees any |
27 | | - * inconsistencies. |
28 | | - */ |
29 | | -.macro UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=0 type=ORC_TYPE_CALL end=0 |
30 | | -#ifdef CONFIG_STACK_VALIDATION |
31 | | -.Lunwind_hint_ip_\@: |
32 | | - .pushsection .discard.unwind_hints |
33 | | - /* struct unwind_hint */ |
34 | | - .long .Lunwind_hint_ip_\@ - . |
35 | | - .short \sp_offset |
36 | | - .byte \sp_reg |
37 | | - .byte \type |
38 | | - .byte \end |
39 | | - .balign 4 |
40 | | - .popsection |
41 | | -#endif |
42 | | -.endm |
43 | | - |
44 | 10 | .macro UNWIND_HINT_EMPTY |
45 | | - UNWIND_HINT sp_reg=ORC_REG_UNDEFINED end=1 |
| 11 | + UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_CALL end=1 |
46 | 12 | .endm |
47 | 13 |
|
48 | | -.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 iret=0 |
| 14 | +.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0 |
49 | 15 | .if \base == %rsp |
50 | 16 | .if \indirect |
51 | 17 | .set sp_reg, ORC_REG_SP_INDIRECT |
|
66 | 32 |
|
67 | 33 | .set sp_offset, \offset |
68 | 34 |
|
69 | | - .if \iret |
70 | | - .set type, ORC_TYPE_REGS_IRET |
| 35 | + .if \partial |
| 36 | + .set type, UNWIND_HINT_TYPE_REGS_PARTIAL |
71 | 37 | .elseif \extra == 0 |
72 | | - .set type, ORC_TYPE_REGS_IRET |
| 38 | + .set type, UNWIND_HINT_TYPE_REGS_PARTIAL |
73 | 39 | .set sp_offset, \offset + (16*8) |
74 | 40 | .else |
75 | | - .set type, ORC_TYPE_REGS |
| 41 | + .set type, UNWIND_HINT_TYPE_REGS |
76 | 42 | .endif |
77 | 43 |
|
78 | 44 | UNWIND_HINT sp_reg=sp_reg sp_offset=sp_offset type=type |
79 | 45 | .endm |
80 | 46 |
|
81 | 47 | .macro UNWIND_HINT_IRET_REGS base=%rsp offset=0 |
82 | | - UNWIND_HINT_REGS base=\base offset=\offset iret=1 |
| 48 | + UNWIND_HINT_REGS base=\base offset=\offset partial=1 |
83 | 49 | .endm |
84 | 50 |
|
85 | 51 | .macro UNWIND_HINT_FUNC sp_offset=8 |
86 | | - UNWIND_HINT sp_offset=\sp_offset |
| 52 | + UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=\sp_offset type=UNWIND_HINT_TYPE_CALL |
87 | 53 | .endm |
88 | 54 |
|
89 | 55 | /* |
|
92 | 58 | * initial_func_cfi. |
93 | 59 | */ |
94 | 60 | .macro UNWIND_HINT_RET_OFFSET sp_offset=8 |
95 | | - UNWIND_HINT type=UNWIND_HINT_TYPE_RET_OFFSET sp_offset=\sp_offset |
| 61 | + UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_RET_OFFSET sp_offset=\sp_offset |
96 | 62 | .endm |
97 | 63 |
|
98 | 64 | #endif /* __ASSEMBLY__ */ |
|
0 commit comments