2017-07-11 11:33:43 -04:00
|
|
|
#ifndef _ASM_X86_UNWIND_HINTS_H
|
|
|
|
#define _ASM_X86_UNWIND_HINTS_H
|
|
|
|
|
2020-09-04 11:30:27 -04:00
|
|
|
#include <linux/objtool.h>
|
|
|
|
|
2017-07-11 11:33:43 -04:00
|
|
|
#include "orc_types.h"
|
|
|
|
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
|
2023-03-01 10:13:12 -05:00
|
|
|
.macro UNWIND_HINT_END_OF_STACK
|
|
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_END_OF_STACK
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro UNWIND_HINT_UNDEFINED
|
|
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_UNDEFINED
|
2017-07-11 11:33:43 -04:00
|
|
|
.endm
|
|
|
|
|
2022-06-14 17:16:03 -04:00
|
|
|
.macro UNWIND_HINT_ENTRY
|
2023-03-01 10:13:11 -05:00
|
|
|
VALIDATE_UNRET_BEGIN
|
2023-03-01 10:13:12 -05:00
|
|
|
UNWIND_HINT_END_OF_STACK
|
2022-06-14 17:16:03 -04:00
|
|
|
.endm
|
|
|
|
|
2023-02-10 17:42:01 -05:00
|
|
|
.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0 signal=1
|
2017-08-07 10:38:05 -04:00
|
|
|
.if \base == %rsp
|
|
|
|
.if \indirect
|
|
|
|
.set sp_reg, ORC_REG_SP_INDIRECT
|
|
|
|
.else
|
|
|
|
.set sp_reg, ORC_REG_SP
|
|
|
|
.endif
|
2017-07-11 11:33:43 -04:00
|
|
|
.elseif \base == %rbp
|
|
|
|
.set sp_reg, ORC_REG_BP
|
|
|
|
.elseif \base == %rdi
|
|
|
|
.set sp_reg, ORC_REG_DI
|
|
|
|
.elseif \base == %rdx
|
|
|
|
.set sp_reg, ORC_REG_DX
|
|
|
|
.elseif \base == %r10
|
|
|
|
.set sp_reg, ORC_REG_R10
|
|
|
|
.else
|
|
|
|
.error "UNWIND_HINT_REGS: bad base register"
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.set sp_offset, \offset
|
|
|
|
|
2020-09-04 11:30:27 -04:00
|
|
|
.if \partial
|
|
|
|
.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
|
2017-07-11 11:33:43 -04:00
|
|
|
.elseif \extra == 0
|
2020-09-04 11:30:27 -04:00
|
|
|
.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
|
2017-07-11 11:33:43 -04:00
|
|
|
.set sp_offset, \offset + (16*8)
|
|
|
|
.else
|
2020-09-04 11:30:27 -04:00
|
|
|
.set type, UNWIND_HINT_TYPE_REGS
|
2017-07-11 11:33:43 -04:00
|
|
|
.endif
|
|
|
|
|
2023-02-10 17:42:01 -05:00
|
|
|
UNWIND_HINT sp_reg=sp_reg sp_offset=sp_offset type=type signal=\signal
|
2017-07-11 11:33:43 -04:00
|
|
|
.endm
|
|
|
|
|
2023-02-10 17:42:01 -05:00
|
|
|
.macro UNWIND_HINT_IRET_REGS base=%rsp offset=0 signal=1
|
|
|
|
UNWIND_HINT_REGS base=\base offset=\offset partial=1 signal=\signal
|
2017-07-11 11:33:43 -04:00
|
|
|
.endm
|
|
|
|
|
2023-03-01 10:13:11 -05:00
|
|
|
.macro UNWIND_HINT_IRET_ENTRY base=%rsp offset=0 signal=1
|
|
|
|
VALIDATE_UNRET_BEGIN
|
|
|
|
UNWIND_HINT_IRET_REGS base=\base offset=\offset signal=\signal
|
|
|
|
.endm
|
|
|
|
|
2021-01-21 16:29:24 -05:00
|
|
|
.macro UNWIND_HINT_FUNC
|
|
|
|
UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=8 type=UNWIND_HINT_TYPE_FUNC
|
2020-04-01 10:38:19 -04:00
|
|
|
.endm
|
|
|
|
|
2022-06-24 06:52:40 -04:00
|
|
|
.macro UNWIND_HINT_SAVE
|
|
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_SAVE
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro UNWIND_HINT_RESTORE
|
|
|
|
UNWIND_HINT type=UNWIND_HINT_TYPE_RESTORE
|
|
|
|
.endm
|
|
|
|
|
2021-09-14 10:41:32 -04:00
|
|
|
#else
|
|
|
|
|
2023-06-05 12:12:22 -04:00
|
|
|
#define UNWIND_HINT_UNDEFINED \
|
|
|
|
UNWIND_HINT(UNWIND_HINT_TYPE_UNDEFINED, 0, 0, 0)
|
|
|
|
|
2021-09-14 10:41:32 -04:00
|
|
|
#define UNWIND_HINT_FUNC \
|
2023-03-01 10:13:12 -05:00
|
|
|
UNWIND_HINT(UNWIND_HINT_TYPE_FUNC, ORC_REG_SP, 8, 0)
|
2021-09-14 10:41:32 -04:00
|
|
|
|
2023-06-05 12:12:22 -04:00
|
|
|
#define UNWIND_HINT_SAVE \
|
|
|
|
UNWIND_HINT(UNWIND_HINT_TYPE_SAVE, 0, 0, 0)
|
|
|
|
|
|
|
|
#define UNWIND_HINT_RESTORE \
|
|
|
|
UNWIND_HINT(UNWIND_HINT_TYPE_RESTORE, 0, 0, 0)
|
|
|
|
|
2017-07-11 11:33:43 -04:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif /* _ASM_X86_UNWIND_HINTS_H */
|