Skip to content

Commit 5a658af

Browse files
committed
Merge tag 'objtool-core-2025-03-22' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: - The biggest change is the new option to automatically fail the build on objtool warnings: CONFIG_OBJTOOL_WERROR. While there are no currently known unfixed false positives left, such an expansion in the severity of objtool warnings inevitably creates a risk of build failures, so it's disabled by default and depends on !COMPILE_TEST, so it shouldn't be enabled on allyesconfig/allmodconfig builds and won't be forced on people who just accept build-time defaults in 'make oldconfig'. While the option is strongly recommended, only people who enable it explicitly should see it. (Josh Poimboeuf) - Disable branch profiling in noinstr code with a broad brush that includes all of arch/x86/ and kernel/sched/. (Josh Poimboeuf) - Create backup object files on objtool errors and print exact objtool arguments to make failure analysis easier (Josh Poimboeuf) - Improve noreturn handling (Josh Poimboeuf) - Improve rodata handling (Tiezhu Yang) - Support jump tables, switch tables and goto tables on LoongArch (Tiezhu Yang) - Misc cleanups and fixes (Josh Poimboeuf, David Engraf, Ingo Molnar) * tag 'objtool-core-2025-03-22' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (22 commits) tracing: Disable branch profiling in noinstr code objtool: Use O_CREAT with explicit mode mask objtool: Add CONFIG_OBJTOOL_WERROR objtool: Create backup on error and print args objtool: Change "warning:" to "error:" for --Werror objtool: Add --Werror option objtool: Add --output option objtool: Upgrade "Linked object detected" warning to error objtool: Consolidate option validation objtool: Remove --unret dependency on --rethunk objtool: Increase per-function WARN_FUNC() rate limit objtool: Update documentation objtool: Improve __noreturn annotation warning objtool: Fix error handling inconsistencies in check() x86/traps: Make exc_double_fault() consistently noreturn LoongArch: Enable jump table for objtool objtool/LoongArch: Add support for goto table objtool/LoongArch: Add support for switch table objtool: Handle PC relative relocation type objtool: Handle different entry size of rodata ...
2 parents 2360899 + 2cbb20b commit 5a658af

File tree

35 files changed

+571
-252
lines changed

35 files changed

+571
-252
lines changed

arch/loongarch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ config AS_HAS_LBT_EXTENSION
291291
config AS_HAS_LVZ_EXTENSION
292292
def_bool $(as-instr,hvcl 0)
293293

294+
config CC_HAS_ANNOTATE_TABLEJUMP
295+
def_bool $(cc-option,-mannotate-tablejump)
296+
294297
menu "Kernel type and options"
295298

296299
source "kernel/Kconfig.hz"

arch/loongarch/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ KBUILD_AFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)
101101
KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
102102

103103
ifdef CONFIG_OBJTOOL
104-
KBUILD_CFLAGS += -fno-jump-tables
104+
ifdef CONFIG_CC_HAS_ANNOTATE_TABLEJUMP
105+
KBUILD_CFLAGS += -mannotate-tablejump
106+
else
107+
KBUILD_CFLAGS += -fno-jump-tables # keep compatibility with older compilers
108+
endif
105109
endif
106110

107111
KBUILD_RUSTFLAGS += --target=loongarch64-unknown-none-softfloat -Ccode-model=small

arch/x86/Kbuild

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
3+
# Branch profiling isn't noinstr-safe. Disable it for arch/x86/*
4+
subdir-ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING
5+
26
obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += coco/
37

48
obj-y += entry/

arch/x86/coco/sev/core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#define pr_fmt(fmt) "SEV: " fmt
1111

12-
#define DISABLE_BRANCH_PROFILING
13-
1412
#include <linux/sched/debug.h> /* For show_regs() */
1513
#include <linux/percpu-defs.h>
1614
#include <linux/cc_platform.h>

arch/x86/kernel/head64.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
66
*/
77

8-
#define DISABLE_BRANCH_PROFILING
9-
108
/* cpu_feature_enabled() cannot be used this early */
119
#define USE_EARLY_PGTABLE_L5
1210

arch/x86/kernel/traps.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,21 @@ __visible void __noreturn handle_stack_overflow(struct pt_regs *regs,
379379
}
380380
#endif
381381

382+
/*
383+
* Prevent the compiler and/or objtool from marking the !CONFIG_X86_ESPFIX64
384+
* version of exc_double_fault() as noreturn. Otherwise the noreturn mismatch
385+
* between configs triggers objtool warnings.
386+
*
387+
* This is a temporary hack until we have compiler or plugin support for
388+
* annotating noreturns.
389+
*/
390+
#ifdef CONFIG_X86_ESPFIX64
391+
#define always_true() true
392+
#else
393+
bool always_true(void);
394+
bool __weak always_true(void) { return true; }
395+
#endif
396+
382397
/*
383398
* Runs on an IST stack for x86_64 and on a special task stack for x86_32.
384399
*
@@ -514,7 +529,8 @@ DEFINE_IDTENTRY_DF(exc_double_fault)
514529

515530
pr_emerg("PANIC: double fault, error_code: 0x%lx\n", error_code);
516531
die("double fault", regs, error_code);
517-
panic("Machine halted.");
532+
if (always_true())
533+
panic("Machine halted.");
518534
instrumentation_end();
519535
}
520536

arch/x86/mm/kasan_init_64.c

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-
#define DISABLE_BRANCH_PROFILING
32
#define pr_fmt(fmt) "kasan: " fmt
43

54
/* cpu_feature_enabled() cannot be used this early */

arch/x86/mm/mem_encrypt_amd.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* Author: Tom Lendacky <thomas.lendacky@amd.com>
88
*/
99

10-
#define DISABLE_BRANCH_PROFILING
11-
1210
#include <linux/linkage.h>
1311
#include <linux/init.h>
1412
#include <linux/mm.h>

arch/x86/mm/mem_encrypt_identity.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* Author: Tom Lendacky <thomas.lendacky@amd.com>
88
*/
99

10-
#define DISABLE_BRANCH_PROFILING
11-
1210
/*
1311
* Since we're dealing with identity mappings, physical and virtual
1412
* addresses are the same, so override these defines which are ultimately

drivers/acpi/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
77

8+
ifdef CONFIG_TRACE_BRANCH_PROFILING
9+
CFLAGS_processor_idle.o += -DDISABLE_BRANCH_PROFILING
10+
endif
11+
812
#
913
# ACPI Boot-Time Table Parsing
1014
#

0 commit comments

Comments
 (0)