1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
9 #include <linux/types.h>
10 #include <linux/compiler.h>
13 * The ORC_REG_* registers are base registers which are used to find other
14 * registers on the stack.
16 * ORC_REG_PREV_SP, also known as DWARF Call Frame Address (CFA), is the
17 * address of the previous frame: the caller's SP before it called the current
20 * ORC_REG_UNDEFINED means the corresponding register's value didn't change in
23 * The most commonly used base registers are SP and BP -- which the previous SP
24 * is usually based on -- and PREV_SP and UNDEFINED -- which the previous BP is
27 * The rest of the base registers are needed for special cases like entry code
28 * and GCC realigned stacks.
30 #define ORC_REG_UNDEFINED 0
31 #define ORC_REG_PREV_SP 1
38 #define ORC_REG_BP_INDIRECT 8
39 #define ORC_REG_SP_INDIRECT 9
40 #define ORC_REG_MAX 15
43 * ORC_TYPE_CALL: Indicates that sp_reg+sp_offset resolves to PREV_SP (the
44 * caller's SP right before it made the call). Used for all callable
45 * functions, i.e. all C code and all callable asm functions.
47 * ORC_TYPE_REGS: Used in entry code to indicate that sp_reg+sp_offset points
48 * to a fully populated pt_regs from a syscall, interrupt, or exception.
50 * ORC_TYPE_REGS_IRET: Used in entry code to indicate that sp_reg+sp_offset
51 * points to the iret return frame.
53 * The UNWIND_HINT macros are used only for the unwind_hint struct. They
54 * aren't used in struct orc_entry due to size and complexity constraints.
55 * Objtool converts them to real types when it converts the hints to orc
58 #define ORC_TYPE_CALL 0
59 #define ORC_TYPE_REGS 1
60 #define ORC_TYPE_REGS_IRET 2
61 #define UNWIND_HINT_TYPE_SAVE 3
62 #define UNWIND_HINT_TYPE_RESTORE 4
66 * This struct is more or less a vastly simplified version of the DWARF Call
67 * Frame Information standard. It contains only the necessary parts of DWARF
68 * CFI, simplified for ease of access by the in-kernel unwinder. It tells the
69 * unwinder how to find the previous SP and BP (and sometimes entry regs) on
70 * the stack for a given code address. Each instance of the struct corresponds
71 * to one or more code locations.
83 * This struct is used by asm and inline asm code to manually annotate the
84 * location of registers on the stack for the ORC unwinder.
86 * Type can be either ORC_TYPE_* or UNWIND_HINT_TYPE_*.
95 #endif /* __ASSEMBLY__ */
97 #endif /* _ORC_TYPES_H */