Skip to content

Commit 6873139

Browse files
committed
Merge tag 'objtool-core-2020-10-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: "Most of the changes are cleanups and reorganization to make the objtool code more arch-agnostic. This is in preparation for non-x86 support. Other changes: - KASAN fixes - Handle unreachable trap after call to noreturn functions better - Ignore unreachable fake jumps - Misc smaller fixes & cleanups" * tag 'objtool-core-2020-10-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits) perf build: Allow nested externs to enable BUILD_BUG() usage objtool: Allow nested externs to enable BUILD_BUG() objtool: Permit __kasan_check_{read,write} under UACCESS objtool: Ignore unreachable trap after call to noreturn functions objtool: Handle calling non-function symbols in other sections objtool: Ignore unreachable fake jumps objtool: Remove useless tests before save_reg() objtool: Decode unwind hint register depending on architecture objtool: Make unwind hint definitions available to other architectures objtool: Only include valid definitions depending on source file type objtool: Rename frame.h -> objtool.h objtool: Refactor jump table code to support other architectures objtool: Make relocation in alternative handling arch dependent objtool: Abstract alternative special case handling objtool: Move macros describing structures to arch-dependent code objtool: Make sync-check consider the target architecture objtool: Group headers to check in a single list objtool: Define 'struct orc_entry' only when needed objtool: Skip ORC entry creation for non-text sections objtool: Move ORC logic out of check() ...
2 parents d5660df + ab0a40e commit 6873139

38 files changed

Lines changed: 686 additions & 411 deletions

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12515,6 +12515,7 @@ M: Josh Poimboeuf <jpoimboe@redhat.com>
1251512515
M: Peter Zijlstra <peterz@infradead.org>
1251612516
S: Supported
1251712517
F: tools/objtool/
12518+
F: include/linux/objtool.h
1251812519

1251912520
OCELOT ETHERNET SWITCH DRIVER
1252012521
M: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>

arch/x86/include/asm/nospec-branch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define _ASM_X86_NOSPEC_BRANCH_H_
55

66
#include <linux/static_key.h>
7-
#include <linux/frame.h>
7+
#include <linux/objtool.h>
88

99
#include <asm/alternative.h>
1010
#include <asm/alternative-asm.h>

arch/x86/include/asm/orc_types.h

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

42-
/*
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.
46-
*
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.
49-
*
50-
* ORC_TYPE_REGS_IRET: Used in entry code to indicate that sp_reg+sp_offset
51-
* points to the iret return frame.
52-
*
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
56-
* entries.
57-
*/
58-
#define ORC_TYPE_CALL 0
59-
#define ORC_TYPE_REGS 1
60-
#define ORC_TYPE_REGS_IRET 2
61-
#define UNWIND_HINT_TYPE_RET_OFFSET 3
62-
6342
#ifndef __ASSEMBLY__
6443
/*
6544
* This struct is more or less a vastly simplified version of the DWARF Call
@@ -78,19 +57,6 @@ struct orc_entry {
7857
unsigned end:1;
7958
} __packed;
8059

81-
/*
82-
* This struct is used by asm and inline asm code to manually annotate the
83-
* location of registers on the stack for the ORC unwinder.
84-
*
85-
* Type can be either ORC_TYPE_* or UNWIND_HINT_TYPE_*.
86-
*/
87-
struct unwind_hint {
88-
u32 ip;
89-
s16 sp_offset;
90-
u8 sp_reg;
91-
u8 type;
92-
u8 end;
93-
};
9460
#endif /* __ASSEMBLY__ */
9561

9662
#endif /* _ORC_TYPES_H */

arch/x86/include/asm/unwind_hints.h

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,17 @@
11
#ifndef _ASM_X86_UNWIND_HINTS_H
22
#define _ASM_X86_UNWIND_HINTS_H
33

4+
#include <linux/objtool.h>
5+
46
#include "orc_types.h"
57

68
#ifdef __ASSEMBLY__
79

8-
/*
9-
* In asm, there are two kinds of code: normal C-type callable functions and
10-
* the rest. The normal callable functions can be called by other code, and
11-
* don't do anything unusual with the stack. Such normal callable functions
12-
* are annotated with the ENTRY/ENDPROC macros. Most asm code falls in this
13-
* category. In this case, no special debugging annotations are needed because
14-
* objtool can automatically generate the ORC data for the ORC unwinder to read
15-
* at runtime.
16-
*
17-
* Anything which doesn't fall into the above category, such as syscall and
18-
* interrupt handlers, tends to not be called directly by other functions, and
19-
* often does unusual non-C-function-type things with the stack pointer. Such
20-
* code needs to be annotated such that objtool can understand it. The
21-
* following CFI hint macros are for this type of code.
22-
*
23-
* These macros provide hints to objtool about the state of the stack at each
24-
* instruction. Objtool starts from the hints and follows the code flow,
25-
* making automatic CFI adjustments when it sees pushes and pops, filling out
26-
* the debuginfo as necessary. It will also warn if it sees any
27-
* inconsistencies.
28-
*/
29-
.macro UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=0 type=ORC_TYPE_CALL end=0
30-
#ifdef CONFIG_STACK_VALIDATION
31-
.Lunwind_hint_ip_\@:
32-
.pushsection .discard.unwind_hints
33-
/* struct unwind_hint */
34-
.long .Lunwind_hint_ip_\@ - .
35-
.short \sp_offset
36-
.byte \sp_reg
37-
.byte \type
38-
.byte \end
39-
.balign 4
40-
.popsection
41-
#endif
42-
.endm
43-
4410
.macro UNWIND_HINT_EMPTY
45-
UNWIND_HINT sp_reg=ORC_REG_UNDEFINED end=1
11+
UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_CALL end=1
4612
.endm
4713

48-
.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 iret=0
14+
.macro UNWIND_HINT_REGS base=%rsp offset=0 indirect=0 extra=1 partial=0
4915
.if \base == %rsp
5016
.if \indirect
5117
.set sp_reg, ORC_REG_SP_INDIRECT
@@ -66,24 +32,24 @@
6632

6733
.set sp_offset, \offset
6834

69-
.if \iret
70-
.set type, ORC_TYPE_REGS_IRET
35+
.if \partial
36+
.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
7137
.elseif \extra == 0
72-
.set type, ORC_TYPE_REGS_IRET
38+
.set type, UNWIND_HINT_TYPE_REGS_PARTIAL
7339
.set sp_offset, \offset + (16*8)
7440
.else
75-
.set type, ORC_TYPE_REGS
41+
.set type, UNWIND_HINT_TYPE_REGS
7642
.endif
7743

7844
UNWIND_HINT sp_reg=sp_reg sp_offset=sp_offset type=type
7945
.endm
8046

8147
.macro UNWIND_HINT_IRET_REGS base=%rsp offset=0
82-
UNWIND_HINT_REGS base=\base offset=\offset iret=1
48+
UNWIND_HINT_REGS base=\base offset=\offset partial=1
8349
.endm
8450

8551
.macro UNWIND_HINT_FUNC sp_offset=8
86-
UNWIND_HINT sp_offset=\sp_offset
52+
UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=\sp_offset type=UNWIND_HINT_TYPE_CALL
8753
.endm
8854

8955
/*
@@ -92,7 +58,7 @@
9258
* initial_func_cfi.
9359
*/
9460
.macro UNWIND_HINT_RET_OFFSET sp_offset=8
95-
UNWIND_HINT type=UNWIND_HINT_TYPE_RET_OFFSET sp_offset=\sp_offset
61+
UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_RET_OFFSET sp_offset=\sp_offset
9662
.endm
9763

9864
#endif /* __ASSEMBLY__ */

arch/x86/kernel/kprobes/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
#include <linux/kdebug.h>
3939
#include <linux/kallsyms.h>
4040
#include <linux/ftrace.h>
41-
#include <linux/frame.h>
4241
#include <linux/kasan.h>
4342
#include <linux/moduleloader.h>
43+
#include <linux/objtool.h>
4444
#include <linux/vmalloc.h>
4545
#include <linux/pgtable.h>
4646

arch/x86/kernel/kprobes/opt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <linux/kdebug.h>
1717
#include <linux/kallsyms.h>
1818
#include <linux/ftrace.h>
19-
#include <linux/frame.h>
19+
#include <linux/objtool.h>
2020
#include <linux/pgtable.h>
2121
#include <linux/static_call.h>
2222

arch/x86/kernel/reboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <linux/sched.h>
1111
#include <linux/tboot.h>
1212
#include <linux/delay.h>
13-
#include <linux/frame.h>
13+
#include <linux/objtool.h>
1414
#include <linux/pgtable.h>
1515
#include <acpi/reboot.h>
1616
#include <asm/io.h>

arch/x86/kernel/unwind_orc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2+
#include <linux/objtool.h>
23
#include <linux/module.h>
34
#include <linux/sort.h>
45
#include <asm/ptrace.h>
@@ -127,12 +128,12 @@ static struct orc_entry null_orc_entry = {
127128
.sp_offset = sizeof(long),
128129
.sp_reg = ORC_REG_SP,
129130
.bp_reg = ORC_REG_UNDEFINED,
130-
.type = ORC_TYPE_CALL
131+
.type = UNWIND_HINT_TYPE_CALL
131132
};
132133

133134
/* Fake frame pointer entry -- used as a fallback for generated code */
134135
static struct orc_entry orc_fp_entry = {
135-
.type = ORC_TYPE_CALL,
136+
.type = UNWIND_HINT_TYPE_CALL,
136137
.sp_reg = ORC_REG_BP,
137138
.sp_offset = 16,
138139
.bp_reg = ORC_REG_PREV_SP,
@@ -531,7 +532,7 @@ bool unwind_next_frame(struct unwind_state *state)
531532

532533
/* Find IP, SP and possibly regs: */
533534
switch (orc->type) {
534-
case ORC_TYPE_CALL:
535+
case UNWIND_HINT_TYPE_CALL:
535536
ip_p = sp - sizeof(long);
536537

537538
if (!deref_stack_reg(state, ip_p, &state->ip))
@@ -546,7 +547,7 @@ bool unwind_next_frame(struct unwind_state *state)
546547
state->signal = false;
547548
break;
548549

549-
case ORC_TYPE_REGS:
550+
case UNWIND_HINT_TYPE_REGS:
550551
if (!deref_stack_regs(state, sp, &state->ip, &state->sp)) {
551552
orc_warn_current("can't access registers at %pB\n",
552553
(void *)orig_ip);
@@ -559,7 +560,7 @@ bool unwind_next_frame(struct unwind_state *state)
559560
state->signal = true;
560561
break;
561562

562-
case ORC_TYPE_REGS_IRET:
563+
case UNWIND_HINT_TYPE_REGS_PARTIAL:
563564
if (!deref_stack_iret_regs(state, sp, &state->ip, &state->sp)) {
564565
orc_warn_current("can't access iret registers at %pB\n",
565566
(void *)orig_ip);

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/trace_events.h>
2020
#include <linux/slab.h>
2121
#include <linux/hashtable.h>
22-
#include <linux/frame.h>
22+
#include <linux/objtool.h>
2323
#include <linux/psp-sev.h>
2424
#include <linux/file.h>
2525
#include <linux/pagemap.h>

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
#include <linux/frame.h>
3+
#include <linux/objtool.h>
44
#include <linux/percpu.h>
55

66
#include <asm/debugreg.h>

0 commit comments

Comments
 (0)