fc5cf6cffd9abbbe3238152984b662f39ca32b75
[platform/kernel/linux-rpi.git] / tools / objtool / orc_types.h
1 /*
2  * Copyright (C) 2017 Josh Poimboeuf <jpoimboe@redhat.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef _ORC_TYPES_H
19 #define _ORC_TYPES_H
20
21 #include <linux/types.h>
22 #include <linux/compiler.h>
23
24 /*
25  * The ORC_REG_* registers are base registers which are used to find other
26  * registers on the stack.
27  *
28  * ORC_REG_PREV_SP, also known as DWARF Call Frame Address (CFA), is the
29  * address of the previous frame: the caller's SP before it called the current
30  * function.
31  *
32  * ORC_REG_UNDEFINED means the corresponding register's value didn't change in
33  * the current frame.
34  *
35  * The most commonly used base registers are SP and BP -- which the previous SP
36  * is usually based on -- and PREV_SP and UNDEFINED -- which the previous BP is
37  * usually based on.
38  *
39  * The rest of the base registers are needed for special cases like entry code
40  * and GCC realigned stacks.
41  */
42 #define ORC_REG_UNDEFINED               0
43 #define ORC_REG_PREV_SP                 1
44 #define ORC_REG_DX                      2
45 #define ORC_REG_DI                      3
46 #define ORC_REG_BP                      4
47 #define ORC_REG_SP                      5
48 #define ORC_REG_R10                     6
49 #define ORC_REG_R13                     7
50 #define ORC_REG_BP_INDIRECT             8
51 #define ORC_REG_SP_INDIRECT             9
52 #define ORC_REG_MAX                     15
53
54 /*
55  * ORC_TYPE_CALL: Indicates that sp_reg+sp_offset resolves to PREV_SP (the
56  * caller's SP right before it made the call).  Used for all callable
57  * functions, i.e. all C code and all callable asm functions.
58  *
59  * ORC_TYPE_REGS: Used in entry code to indicate that sp_reg+sp_offset points
60  * to a fully populated pt_regs from a syscall, interrupt, or exception.
61  *
62  * ORC_TYPE_REGS_IRET: Used in entry code to indicate that sp_reg+sp_offset
63  * points to the iret return frame.
64  */
65 #define ORC_TYPE_CALL                   0
66 #define ORC_TYPE_REGS                   1
67 #define ORC_TYPE_REGS_IRET              2
68
69 /*
70  * This struct is more or less a vastly simplified version of the DWARF Call
71  * Frame Information standard.  It contains only the necessary parts of DWARF
72  * CFI, simplified for ease of access by the in-kernel unwinder.  It tells the
73  * unwinder how to find the previous SP and BP (and sometimes entry regs) on
74  * the stack for a given code address.  Each instance of the struct corresponds
75  * to one or more code locations.
76  */
77 struct orc_entry {
78         s16             sp_offset;
79         s16             bp_offset;
80         unsigned        sp_reg:4;
81         unsigned        bp_reg:4;
82         unsigned        type:2;
83 } __packed;
84
85 #endif /* _ORC_TYPES_H */