Skip to content

Commit f902cfd

Browse files
jpoimboePeter Zijlstra
authored andcommitted
x86,objtool: Introduce ORC_TYPE_*
Unwind hints and ORC entry types are two distinct things. Separate them out more explicitly. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/cc879d38fff8a43f8f7beb2fd56e35a5a384d7cd.1677683419.git.jpoimboe@kernel.org
1 parent d88ebba commit f902cfd

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

arch/x86/include/asm/orc_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#define ORC_REG_SP_INDIRECT 9
4040
#define ORC_REG_MAX 15
4141

42+
#define ORC_TYPE_CALL 0
43+
#define ORC_TYPE_REGS 1
44+
#define ORC_TYPE_REGS_PARTIAL 2
45+
4246
#ifndef __ASSEMBLY__
4347
#include <asm/byteorder.h>
4448

arch/x86/kernel/unwind_orc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static struct orc_entry null_orc_entry = {
133133
.sp_offset = sizeof(long),
134134
.sp_reg = ORC_REG_SP,
135135
.bp_reg = ORC_REG_UNDEFINED,
136-
.type = UNWIND_HINT_TYPE_CALL
136+
.type = ORC_TYPE_CALL
137137
};
138138

139139
#ifdef CONFIG_CALL_THUNKS
@@ -153,7 +153,7 @@ static struct orc_entry *orc_callthunk_find(unsigned long ip)
153153

154154
/* Fake frame pointer entry -- used as a fallback for generated code */
155155
static struct orc_entry orc_fp_entry = {
156-
.type = UNWIND_HINT_TYPE_CALL,
156+
.type = ORC_TYPE_CALL,
157157
.sp_reg = ORC_REG_BP,
158158
.sp_offset = 16,
159159
.bp_reg = ORC_REG_PREV_SP,
@@ -554,7 +554,7 @@ bool unwind_next_frame(struct unwind_state *state)
554554

555555
/* Find IP, SP and possibly regs: */
556556
switch (orc->type) {
557-
case UNWIND_HINT_TYPE_CALL:
557+
case ORC_TYPE_CALL:
558558
ip_p = sp - sizeof(long);
559559

560560
if (!deref_stack_reg(state, ip_p, &state->ip))
@@ -567,7 +567,7 @@ bool unwind_next_frame(struct unwind_state *state)
567567
state->prev_regs = NULL;
568568
break;
569569

570-
case UNWIND_HINT_TYPE_REGS:
570+
case ORC_TYPE_REGS:
571571
if (!deref_stack_regs(state, sp, &state->ip, &state->sp)) {
572572
orc_warn_current("can't access registers at %pB\n",
573573
(void *)orig_ip);
@@ -590,13 +590,13 @@ bool unwind_next_frame(struct unwind_state *state)
590590
state->full_regs = true;
591591
break;
592592

593-
case UNWIND_HINT_TYPE_REGS_PARTIAL:
593+
case ORC_TYPE_REGS_PARTIAL:
594594
if (!deref_stack_iret_regs(state, sp, &state->ip, &state->sp)) {
595595
orc_warn_current("can't access iret registers at %pB\n",
596596
(void *)orig_ip);
597597
goto err;
598598
}
599-
/* See UNWIND_HINT_TYPE_REGS case comment. */
599+
/* See ORC_TYPE_REGS case comment. */
600600
state->ip = unwind_recover_rethook(state, state->ip,
601601
(unsigned long *)(state->sp - sizeof(long)));
602602

include/linux/objtool_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct unwind_hint {
4040
#define UNWIND_HINT_TYPE_CALL 0
4141
#define UNWIND_HINT_TYPE_REGS 1
4242
#define UNWIND_HINT_TYPE_REGS_PARTIAL 2
43+
/* The below hint types don't have corresponding ORC types */
4344
#define UNWIND_HINT_TYPE_FUNC 3
4445
#define UNWIND_HINT_TYPE_ENTRY 4
4546
#define UNWIND_HINT_TYPE_SAVE 5

tools/arch/x86/include/asm/orc_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#define ORC_REG_SP_INDIRECT 9
4040
#define ORC_REG_MAX 15
4141

42+
#define ORC_TYPE_CALL 0
43+
#define ORC_TYPE_REGS 1
44+
#define ORC_TYPE_REGS_PARTIAL 2
45+
4246
#ifndef __ASSEMBLY__
4347
#include <asm/byteorder.h>
4448

tools/include/linux/objtool_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct unwind_hint {
4040
#define UNWIND_HINT_TYPE_CALL 0
4141
#define UNWIND_HINT_TYPE_REGS 1
4242
#define UNWIND_HINT_TYPE_REGS_PARTIAL 2
43+
/* The below hint types don't have corresponding ORC types */
4344
#define UNWIND_HINT_TYPE_FUNC 3
4445
#define UNWIND_HINT_TYPE_ENTRY 4
4546
#define UNWIND_HINT_TYPE_SAVE 5

tools/objtool/orc_dump.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include <unistd.h>
7-
#include <linux/objtool_types.h>
87
#include <asm/orc_types.h>
98
#include <objtool/objtool.h>
109
#include <objtool/warn.h>
@@ -39,11 +38,11 @@ static const char *reg_name(unsigned int reg)
3938
static const char *orc_type_name(unsigned int type)
4039
{
4140
switch (type) {
42-
case UNWIND_HINT_TYPE_CALL:
41+
case ORC_TYPE_CALL:
4342
return "call";
44-
case UNWIND_HINT_TYPE_REGS:
43+
case ORC_TYPE_REGS:
4544
return "regs";
46-
case UNWIND_HINT_TYPE_REGS_PARTIAL:
45+
case ORC_TYPE_REGS_PARTIAL:
4746
return "regs (partial)";
4847
default:
4948
return "?";

tools/objtool/orc_gen.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
2626
return 0;
2727
}
2828

29+
switch (cfi->type) {
30+
case UNWIND_HINT_TYPE_CALL:
31+
orc->type = ORC_TYPE_CALL;
32+
break;
33+
case UNWIND_HINT_TYPE_REGS:
34+
orc->type = ORC_TYPE_REGS;
35+
break;
36+
case UNWIND_HINT_TYPE_REGS_PARTIAL:
37+
orc->type = ORC_TYPE_REGS_PARTIAL;
38+
break;
39+
default:
40+
WARN_FUNC("unknown unwind hint type %d",
41+
insn->sec, insn->offset, cfi->type);
42+
return -1;
43+
}
44+
2945
orc->end = cfi->end;
3046
orc->signal = cfi->signal;
3147

@@ -83,7 +99,6 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
8399

84100
orc->sp_offset = cfi->cfa.offset;
85101
orc->bp_offset = bp->offset;
86-
orc->type = cfi->type;
87102

88103
return 0;
89104
}
@@ -151,7 +166,7 @@ int orc_create(struct objtool_file *file)
151166
struct orc_entry null = {
152167
.sp_reg = ORC_REG_UNDEFINED,
153168
.bp_reg = ORC_REG_UNDEFINED,
154-
.type = UNWIND_HINT_TYPE_CALL,
169+
.type = ORC_TYPE_CALL,
155170
};
156171

157172
/* Build a deduplicated list of ORC entries: */

0 commit comments

Comments
 (0)