Skip to content

Commit d937a6d

Browse files
committed
Merge branch 'core-objtool-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: "The biggest changes in this cycle were the vmlinux.o optimizations by Peter Zijlstra, which are preparatory and optimization work to run objtool against the much richer vmlinux.o object file, to perform new, whole-program section based logic. That work exposed a handful of problems with the existing code, which fixes and optimizations are merged here. The complete 'vmlinux.o and noinstr' work is still work in progress, targeted for v5.8. There's also assorted fixes and enhancements from Josh Poimboeuf. In particular I'd like to draw attention to commit 644592d, which turns fatal objtool errors into failed kernel builds. This behavior is IMO now justified on multiple grounds (it's easy currently to not notice an essentially corrupted kernel build), and the commit has been in -next testing for several weeks, but there could still be build failures with old or weird toolchains. Should that be widespread or high profile enough then I'd suggest a quick revert, to not hold up the merge window" * 'core-objtool-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (22 commits) objtool: Re-arrange validate_functions() objtool: Optimize find_rela_by_dest_range() objtool: Delete cleanup() objtool: Optimize read_sections() objtool: Optimize find_symbol_by_name() objtool: Resize insn_hash objtool: Rename find_containing_func() objtool: Optimize find_symbol_*() and read_symbols() objtool: Optimize find_section_by_name() objtool: Optimize find_section_by_index() objtool: Add a statistics mode objtool: Optimize find_symbol_by_index() x86/kexec: Make relocate_kernel_64.S objtool clean x86/kexec: Use RIP relative addressing objtool: Rename func_for_each_insn_all() objtool: Rename func_for_each_insn() objtool: Introduce validate_return() objtool: Improve call destination function detection objtool: Fix clang switch table edge case objtool: Add relocation check for alternative sections ...
2 parents 2ce94bc + 350994b commit d937a6d

File tree

12 files changed

+429
-211
lines changed

12 files changed

+429
-211
lines changed

arch/x86/kernel/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ KASAN_SANITIZE_dumpstack_$(BITS).o := n
2828
KASAN_SANITIZE_stacktrace.o := n
2929
KASAN_SANITIZE_paravirt.o := n
3030

31-
OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y
3231
OBJECT_FILES_NON_STANDARD_test_nx.o := y
3332
OBJECT_FILES_NON_STANDARD_paravirt_patch.o := y
3433

arch/x86/kernel/relocate_kernel_64.S

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <asm/kexec.h>
1010
#include <asm/processor-flags.h>
1111
#include <asm/pgtable_types.h>
12+
#include <asm/nospec-branch.h>
13+
#include <asm/unwind_hints.h>
1214

1315
/*
1416
* Must be relocatable PIC code callable as a C function
@@ -39,6 +41,7 @@
3941
.align PAGE_SIZE
4042
.code64
4143
SYM_CODE_START_NOALIGN(relocate_kernel)
44+
UNWIND_HINT_EMPTY
4245
/*
4346
* %rdi indirection_page
4447
* %rsi page_list
@@ -105,6 +108,7 @@ SYM_CODE_START_NOALIGN(relocate_kernel)
105108
SYM_CODE_END(relocate_kernel)
106109

107110
SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
111+
UNWIND_HINT_EMPTY
108112
/* set return address to 0 if not preserving context */
109113
pushq $0
110114
/* store the start address on the stack */
@@ -192,14 +196,12 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
192196
1:
193197
popq %rdx
194198
leaq PAGE_SIZE(%r10), %rsp
199+
ANNOTATE_RETPOLINE_SAFE
195200
call *%rdx
196201

197202
/* get the re-entry point of the peer system */
198203
movq 0(%rsp), %rbp
199-
call 1f
200-
1:
201-
popq %r8
202-
subq $(1b - relocate_kernel), %r8
204+
leaq relocate_kernel(%rip), %r8
203205
movq CP_PA_SWAP_PAGE(%r8), %r10
204206
movq CP_PA_BACKUP_PAGES_MAP(%r8), %rdi
205207
movq CP_PA_TABLE_PAGE(%r8), %rax
@@ -212,6 +214,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
212214
SYM_CODE_END(identity_mapped)
213215

214216
SYM_CODE_START_LOCAL_NOALIGN(virtual_mapped)
217+
UNWIND_HINT_EMPTY
215218
movq RSP(%r8), %rsp
216219
movq CR4(%r8), %rax
217220
movq %rax, %cr4
@@ -233,6 +236,7 @@ SYM_CODE_END(virtual_mapped)
233236

234237
/* Do the copies */
235238
SYM_CODE_START_LOCAL_NOALIGN(swap_pages)
239+
UNWIND_HINT_EMPTY
236240
movq %rdi, %rcx /* Put the page_list in %rcx */
237241
xorl %edi, %edi
238242
xorl %esi, %esi

tools/objtool/Build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ objtool-y += objtool.o
1111
objtool-y += libstring.o
1212
objtool-y += libctype.o
1313
objtool-y += str_error_r.o
14+
objtool-y += librbtree.o
1415

1516
CFLAGS += -I$(srctree)/tools/lib
1617

@@ -25,3 +26,7 @@ $(OUTPUT)libctype.o: ../lib/ctype.c FORCE
2526
$(OUTPUT)str_error_r.o: ../lib/str_error_r.c FORCE
2627
$(call rule_mkdir)
2728
$(call if_changed_dep,cc_o_c)
29+
30+
$(OUTPUT)librbtree.o: ../lib/rbtree.c FORCE
31+
$(call rule_mkdir)
32+
$(call if_changed_dep,cc_o_c)

tools/objtool/builtin-check.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "builtin.h"
1818
#include "check.h"
1919

20-
bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess;
20+
bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats;
2121

2222
static const char * const check_usage[] = {
2323
"objtool check [<options>] file.o",
@@ -31,6 +31,7 @@ const struct option check_options[] = {
3131
OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"),
3232
OPT_BOOLEAN('b', "backtrace", &backtrace, "unwind on error"),
3333
OPT_BOOLEAN('a', "uaccess", &uaccess, "enable uaccess checking"),
34+
OPT_BOOLEAN('s', "stats", &stats, "print statistics"),
3435
OPT_END(),
3536
};
3637

tools/objtool/builtin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <subcmd/parse-options.h>
99

1010
extern const struct option check_options[];
11-
extern bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess;
11+
extern bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats;
1212

1313
extern int cmd_check(int argc, const char **argv);
1414
extern int cmd_orc(int argc, const char **argv);

0 commit comments

Comments
 (0)