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

+3
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

+5-1
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

+4
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

-2
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

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Copyright (C) 2000 Andrea Arcangeli <[email protected]> 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

+17-1
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

-1
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

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* Author: Tom Lendacky <[email protected]>
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

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* Author: Tom Lendacky <[email protected]>
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

+4
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
#

drivers/cpuidle/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Makefile for cpuidle.
44
#
55

6+
# Branch profiling isn't noinstr-safe
7+
ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING
8+
69
obj-y += cpuidle.o driver.o governor.o sysfs.o governors/
710
obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
811
obj-$(CONFIG_DT_IDLE_STATES) += dt_idle_states.o

drivers/idle/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-$(CONFIG_INTEL_IDLE) += intel_idle.o
32

3+
# Branch profiling isn't noinstr-safe
4+
ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING
5+
6+
obj-$(CONFIG_INTEL_IDLE) += intel_idle.o

kernel/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ ifdef CONFIG_FUNCTION_TRACER
2121
CFLAGS_REMOVE_irq_work.o = $(CC_FLAGS_FTRACE)
2222
endif
2323

24+
# Branch profiling isn't noinstr-safe
25+
ifdef CONFIG_TRACE_BRANCH_PROFILING
26+
CFLAGS_context_tracking.o += -DDISABLE_BRANCH_PROFILING
27+
endif
28+
2429
# Prevents flicker of uninteresting __do_softirq()/__local_bh_disable_ip()
2530
# in coverage traces.
2631
KCOV_INSTRUMENT_softirq.o := n

kernel/entry/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ KASAN_SANITIZE := n
66
UBSAN_SANITIZE := n
77
KCOV_INSTRUMENT := n
88

9+
# Branch profiling isn't noinstr-safe
10+
ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING
11+
912
CFLAGS_REMOVE_common.o = -fstack-protector -fstack-protector-strong
1013
CFLAGS_common.o += -fno-stack-protector
1114

kernel/sched/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
2222
CFLAGS_core.o := $(PROFILING) -fno-omit-frame-pointer
2323
endif
2424

25+
# Branch profiling isn't noinstr-safe
26+
ifdef CONFIG_TRACE_BRANCH_PROFILING
27+
CFLAGS_build_policy.o += -DDISABLE_BRANCH_PROFILING
28+
CFLAGS_build_utility.o += -DDISABLE_BRANCH_PROFILING
29+
endif
2530
#
2631
# Build efficiency:
2732
#

kernel/time/Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
3+
# Branch profiling isn't noinstr-safe
4+
ifdef CONFIG_TRACE_BRANCH_PROFILING
5+
CFLAGS_sched_clock.o += -DDISABLE_BRANCH_PROFILING
6+
endif
7+
28
obj-y += time.o timer.o hrtimer.o sleep_timeout.o
39
obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o
410
obj-y += timeconv.o timecounter.o alarmtimer.o

lib/Kconfig.debug

+11
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,17 @@ config FRAME_POINTER
545545
config OBJTOOL
546546
bool
547547

548+
config OBJTOOL_WERROR
549+
bool "Upgrade objtool warnings to errors"
550+
depends on OBJTOOL && !COMPILE_TEST
551+
help
552+
Fail the build on objtool warnings.
553+
554+
Objtool warnings can indicate kernel instability, including boot
555+
failures. This option is highly recommended.
556+
557+
If unsure, say Y.
558+
548559
config STACK_VALIDATION
549560
bool "Compile-time stack metadata validation"
550561
depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER

lib/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
77

8+
# Branch profiling isn't noinstr-safe
9+
ifdef CONFIG_TRACE_BRANCH_PROFILING
10+
CFLAGS_smp_processor_id.o += -DDISABLE_BRANCH_PROFILING
11+
endif
12+
813
# These files are disabled because they produce lots of non-interesting and/or
914
# flaky coverage that is not a function of syscall inputs. For example,
1015
# rbtree can be global and individual rotations don't correlate with inputs.

scripts/Makefile.lib

+1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call
277277
objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess
278278
objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable
279279
objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES)
280+
objtool-args-$(CONFIG_OBJTOOL_WERROR) += --Werror --backtrace
280281

281282
objtool-args = $(objtool-args-y) \
282283
$(if $(delay-objtool), --link) \

0 commit comments

Comments
 (0)