1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
2 | /* |
3 | * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com> |
4 | */ |
5 | |
6 | #ifndef _ORC_TYPES_H |
7 | #define _ORC_TYPES_H |
8 | |
9 | #include <linux/types.h> |
10 | #include <linux/compiler.h> |
11 | |
12 | /* |
13 | * The ORC_REG_* registers are base registers which are used to find other |
14 | * registers on the stack. |
15 | * |
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 |
18 | * function. |
19 | * |
20 | * ORC_REG_UNDEFINED means the corresponding register's value didn't change in |
21 | * the current frame. |
22 | * |
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 |
25 | * usually based on. |
26 | * |
27 | * The rest of the base registers are needed for special cases like entry code |
28 | * and GCC realigned stacks. |
29 | */ |
30 | #define ORC_REG_UNDEFINED 0 |
31 | #define ORC_REG_PREV_SP 1 |
32 | #define ORC_REG_DX 2 |
33 | #define ORC_REG_DI 3 |
34 | #define ORC_REG_BP 4 |
35 | #define ORC_REG_SP 5 |
36 | #define ORC_REG_R10 6 |
37 | #define ORC_REG_R13 7 |
38 | #define ORC_REG_BP_INDIRECT 8 |
39 | #define ORC_REG_SP_INDIRECT 9 |
40 | #define ORC_REG_MAX 15 |
41 | |
42 | #define ORC_TYPE_UNDEFINED 0 |
43 | #define ORC_TYPE_END_OF_STACK 1 |
44 | #define ORC_TYPE_CALL 2 |
45 | #define ORC_TYPE_REGS 3 |
46 | #define ORC_TYPE_REGS_PARTIAL 4 |
47 | |
48 | #ifndef __ASSEMBLY__ |
49 | #include <asm/byteorder.h> |
50 | |
51 | /* |
52 | * This struct is more or less a vastly simplified version of the DWARF Call |
53 | * Frame Information standard. It contains only the necessary parts of DWARF |
54 | * CFI, simplified for ease of access by the in-kernel unwinder. It tells the |
55 | * unwinder how to find the previous SP and BP (and sometimes entry regs) on |
56 | * the stack for a given code address. Each instance of the struct corresponds |
57 | * to one or more code locations. |
58 | */ |
59 | struct orc_entry { |
60 | s16 sp_offset; |
61 | s16 bp_offset; |
62 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
63 | unsigned sp_reg:4; |
64 | unsigned bp_reg:4; |
65 | unsigned type:3; |
66 | unsigned signal:1; |
67 | #elif defined(__BIG_ENDIAN_BITFIELD) |
68 | unsigned bp_reg:4; |
69 | unsigned sp_reg:4; |
70 | unsigned unused:4; |
71 | unsigned signal:1; |
72 | unsigned type:3; |
73 | #endif |
74 | } __packed; |
75 | |
76 | #endif /* __ASSEMBLY__ */ |
77 | |
78 | #endif /* _ORC_TYPES_H */ |
79 | |