Skip to content

Commit a56ff24

Browse files
committed
Merge tag 'objtool-core-2021-02-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Thomas Gleixner: - Make objtool work for big-endian cross compiles - Make stack tracking via stack pointer memory operations match push/pop semantics to prepare for architectures w/o PUSH/POP instructions. - Add support for analyzing alternatives - Improve retpoline detection and handling - Improve assembly code coverage on x86 - Provide support for inlined stack switching * tag 'objtool-core-2021-02-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (33 commits) objtool: Support stack-swizzle objtool,x86: Additionally decode: mov %rsp, (%reg) x86/unwind/orc: Change REG_SP_INDIRECT x86/power: Support objtool validation in hibernate_asm_64.S x86/power: Move restore_registers() to top of the file x86/power: Annotate indirect branches as safe x86/acpi: Support objtool validation in wakeup_64.S x86/acpi: Annotate indirect branch as safe x86/ftrace: Support objtool vmlinux.o validation in ftrace_64.S x86/xen/pvh: Annotate indirect branch as safe x86/xen: Support objtool vmlinux.o validation in xen-head.S x86/xen: Support objtool validation in xen-asm.S objtool: Add xen_start_kernel() to noreturn list objtool: Combine UNWIND_HINT_RET_OFFSET and UNWIND_HINT_FUNC objtool: Add asm version of STACK_FRAME_NON_STANDARD objtool: Assume only ELF functions do sibling calls x86/ftrace: Add UNWIND_HINT_FUNC annotation for ftrace_stub objtool: Support retpoline jump detection for vmlinux.o objtool: Fix ".cold" section suffix check for newer versions of GCC objtool: Fix retpoline detection in asm code ...
2 parents 79db4d2 + aafeb14 commit a56ff24

49 files changed

Lines changed: 962 additions & 597 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/x86/include/asm/insn.h‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
* Copyright (C) IBM Corporation, 2009
88
*/
99

10+
#include <asm/byteorder.h>
1011
/* insn_attr_t is defined in inat.h */
1112
#include <asm/inat.h>
1213

14+
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
15+
1316
struct insn_field {
1417
union {
1518
insn_value_t value;
@@ -20,6 +23,48 @@ struct insn_field {
2023
unsigned char nbytes;
2124
};
2225

26+
static inline void insn_field_set(struct insn_field *p, insn_value_t v,
27+
unsigned char n)
28+
{
29+
p->value = v;
30+
p->nbytes = n;
31+
}
32+
33+
static inline void insn_set_byte(struct insn_field *p, unsigned char n,
34+
insn_byte_t v)
35+
{
36+
p->bytes[n] = v;
37+
}
38+
39+
#else
40+
41+
struct insn_field {
42+
insn_value_t value;
43+
union {
44+
insn_value_t little;
45+
insn_byte_t bytes[4];
46+
};
47+
/* !0 if we've run insn_get_xxx() for this field */
48+
unsigned char got;
49+
unsigned char nbytes;
50+
};
51+
52+
static inline void insn_field_set(struct insn_field *p, insn_value_t v,
53+
unsigned char n)
54+
{
55+
p->value = v;
56+
p->little = __cpu_to_le32(v);
57+
p->nbytes = n;
58+
}
59+
60+
static inline void insn_set_byte(struct insn_field *p, unsigned char n,
61+
insn_byte_t v)
62+
{
63+
p->bytes[n] = v;
64+
p->value = __le32_to_cpu(p->little);
65+
}
66+
#endif
67+
2368
struct insn {
2469
struct insn_field prefixes; /*
2570
* Prefixes

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#define ORC_REG_MAX 15
4141

4242
#ifndef __ASSEMBLY__
43+
#include <asm/byteorder.h>
44+
4345
/*
4446
* This struct is more or less a vastly simplified version of the DWARF Call
4547
* Frame Information standard. It contains only the necessary parts of DWARF
@@ -51,10 +53,18 @@
5153
struct orc_entry {
5254
s16 sp_offset;
5355
s16 bp_offset;
56+
#if defined(__LITTLE_ENDIAN_BITFIELD)
5457
unsigned sp_reg:4;
5558
unsigned bp_reg:4;
5659
unsigned type:2;
5760
unsigned end:1;
61+
#elif defined(__BIG_ENDIAN_BITFIELD)
62+
unsigned bp_reg:4;
63+
unsigned sp_reg:4;
64+
unsigned unused:5;
65+
unsigned end:1;
66+
unsigned type:2;
67+
#endif
5868
} __packed;
5969

6070
#endif /* __ASSEMBLY__ */

‎arch/x86/include/asm/unwind_hints.h‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,8 @@
4848
UNWIND_HINT_REGS base=\base offset=\offset partial=1
4949
.endm
5050

51-
.macro UNWIND_HINT_FUNC sp_offset=8
52-
UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=\sp_offset type=UNWIND_HINT_TYPE_CALL
53-
.endm
54-
55-
/*
56-
* RET_OFFSET: Used on instructions that terminate a function; mostly RETURN
57-
* and sibling calls. On these, sp_offset denotes the expected offset from
58-
* initial_func_cfi.
59-
*/
60-
.macro UNWIND_HINT_RET_OFFSET sp_offset=8
61-
UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_RET_OFFSET sp_offset=\sp_offset
51+
.macro UNWIND_HINT_FUNC
52+
UNWIND_HINT sp_reg=ORC_REG_SP sp_offset=8 type=UNWIND_HINT_TYPE_FUNC
6253
.endm
6354

6455
#endif /* __ASSEMBLY__ */

‎arch/x86/kernel/acpi/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
OBJECT_FILES_NON_STANDARD_wakeup_$(BITS).o := y
32

43
obj-$(CONFIG_ACPI) += boot.o
54
obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup_$(BITS).o

‎arch/x86/kernel/acpi/wakeup_64.S‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
.text
33
#include <linux/linkage.h>
4+
#include <linux/objtool.h>
45
#include <asm/segment.h>
56
#include <asm/pgtable_types.h>
67
#include <asm/page_types.h>
78
#include <asm/msr.h>
89
#include <asm/asm-offsets.h>
910
#include <asm/frame.h>
11+
#include <asm/nospec-branch.h>
1012

1113
# Copyright 2003 Pavel Machek <pavel@suse.cz
1214

@@ -39,6 +41,7 @@ SYM_FUNC_START(wakeup_long64)
3941
movq saved_rbp, %rbp
4042

4143
movq saved_rip, %rax
44+
ANNOTATE_RETPOLINE_SAFE
4245
jmp *%rax
4346
SYM_FUNC_END(wakeup_long64)
4447

@@ -126,6 +129,7 @@ SYM_FUNC_START(do_suspend_lowlevel)
126129
FRAME_END
127130
jmp restore_processor_state
128131
SYM_FUNC_END(do_suspend_lowlevel)
132+
STACK_FRAME_NON_STANDARD do_suspend_lowlevel
129133

130134
.data
131135
saved_rbp: .quad 0

‎arch/x86/kernel/ftrace_64.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ SYM_INNER_LABEL(ftrace_graph_call, SYM_L_GLOBAL)
184184
* It is also used to copy the retq for trampolines.
185185
*/
186186
SYM_INNER_LABEL_ALIGN(ftrace_stub, SYM_L_WEAK)
187+
UNWIND_HINT_FUNC
187188
retq
188189
SYM_FUNC_END(ftrace_epilogue)
189190

@@ -276,7 +277,7 @@ SYM_INNER_LABEL(ftrace_regs_caller_end, SYM_L_GLOBAL)
276277
restore_mcount_regs 8
277278
/* Restore flags */
278279
popfq
279-
UNWIND_HINT_RET_OFFSET
280+
UNWIND_HINT_FUNC
280281
jmp ftrace_epilogue
281282

282283
SYM_FUNC_END(ftrace_regs_caller)
@@ -333,8 +334,7 @@ SYM_FUNC_START(ftrace_graph_caller)
333334
retq
334335
SYM_FUNC_END(ftrace_graph_caller)
335336

336-
SYM_CODE_START(return_to_handler)
337-
UNWIND_HINT_EMPTY
337+
SYM_FUNC_START(return_to_handler)
338338
subq $24, %rsp
339339

340340
/* Save the return values */
@@ -349,5 +349,5 @@ SYM_CODE_START(return_to_handler)
349349
movq (%rsp), %rax
350350
addq $24, %rsp
351351
JMP_NOSPEC rdi
352-
SYM_CODE_END(return_to_handler)
352+
SYM_FUNC_END(return_to_handler)
353353
#endif

‎arch/x86/kernel/unwind_orc.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ bool unwind_next_frame(struct unwind_state *state)
471471
break;
472472

473473
case ORC_REG_SP_INDIRECT:
474-
sp = state->sp + orc->sp_offset;
474+
sp = state->sp;
475475
indirect = true;
476476
break;
477477

@@ -521,6 +521,9 @@ bool unwind_next_frame(struct unwind_state *state)
521521
if (indirect) {
522522
if (!deref_stack_reg(state, sp, &sp))
523523
goto err;
524+
525+
if (orc->sp_reg == ORC_REG_SP_INDIRECT)
526+
sp += orc->sp_offset;
524527
}
525528

526529
/* Find IP, SP and possibly regs: */

0 commit comments

Comments
 (0)