Commit 92b71bef authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'objtool-urgent-2025-04-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fixes from Ingo Molnar:
 "These are objtool fixes and updates by Josh Poimboeuf, centered around
  the fallout from the new CONFIG_OBJTOOL_WERROR=y feature, which,
  despite its default-off nature, increased the profile/impact of
  objtool warnings:

   - Improve error handling and the presentation of warnings/errors

   - Revert the new summary warning line that some test-bot tools
     interpreted as new regressions

   - Fix a number of objtool warnings in various drivers, core kernel
     code and architecture code. About half of them are potential
     problems related to out-of-bounds accesses or potential undefined
     behavior, the other half are additional objtool annotations

   - Update objtool to latest (known) compiler quirks and objtool bugs
     triggered by compiler code generation

   - Misc fixes"

* tag 'objtool-urgent-2025-04-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits)
  objtool/loongarch: Add unwind hints in prepare_frametrace()
  rcu-tasks: Always inline rcu_irq_work_resched()
  context_tracking: Always inline ct_{nmi,irq}_{enter,exit}()
  sched/smt: Always inline sched_smt_active()
  objtool: Fix verbose disassembly if CROSS_COMPILE isn't set
  objtool: Change "warning:" to "error: " for fatal errors
  objtool: Always fail on fatal errors
  Revert "objtool: Increase per-function WARN_FUNC() rate limit"
  objtool: Append "()" to function name in "unexpected end of section" warning
  objtool: Ignore end-of-section jumps for KCOV/GCOV
  objtool: Silence more KCOV warnings, part 2
  objtool, drm/vmwgfx: Don't ignore vmw_send_msg() for ORC
  objtool: Fix STACK_FRAME_NON_STANDARD for cold subfunctions
  objtool: Fix segfault in ignore_unreachable_insn()
  objtool: Fix NULL printf() '%s' argument in builtin-check.c:save_argv()
  objtool, lkdtm: Obfuscate the do_nothing() pointer
  objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc()
  objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler()
  objtool, Input: cyapa - Remove undefined behavior in cyapa_update_fw_store()
  objtool, panic: Disable SMAP in __stack_chk_fail()
  ...
parents af54a3a1 7c977393
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <asm/asm.h>
#include <asm/ptrace.h>
#include <asm/loongarch.h>
#include <asm/unwind_hints.h>
#include <linux/stringify.h>

enum stack_type {
@@ -43,6 +44,7 @@ int get_stack_info(unsigned long stack, struct task_struct *task, struct stack_i
static __always_inline void prepare_frametrace(struct pt_regs *regs)
{
	__asm__ __volatile__(
		UNWIND_HINT_SAVE
		/* Save $ra */
		STORE_ONE_REG(1)
		/* Use $ra to save PC */
@@ -80,6 +82,7 @@ static __always_inline void prepare_frametrace(struct pt_regs *regs)
		STORE_ONE_REG(29)
		STORE_ONE_REG(30)
		STORE_ONE_REG(31)
		UNWIND_HINT_RESTORE
		: "=m" (regs->csr_era)
		: "r" (regs->regs)
		: "memory");
+9 −1
Original line number Diff line number Diff line
@@ -23,6 +23,14 @@
	UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_CALL
.endm

#endif /* __ASSEMBLY__ */
#else /* !__ASSEMBLY__ */

#define UNWIND_HINT_SAVE \
	UNWIND_HINT(UNWIND_HINT_TYPE_SAVE, 0, 0, 0)

#define UNWIND_HINT_RESTORE \
	UNWIND_HINT(UNWIND_HINT_TYPE_RESTORE, 0, 0, 0)

#endif /* !__ASSEMBLY__ */

#endif /* _ASM_LOONGARCH_UNWIND_HINTS_H */
+4 −2
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@ static __always_inline unsigned int __arch_hweight32(unsigned int w)
{
	unsigned int res;

	asm_inline (ALTERNATIVE("call __sw_hweight32",
	asm_inline (ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
				"call __sw_hweight32",
				"popcntl %[val], %[cnt]", X86_FEATURE_POPCNT)
			 : [cnt] "=" REG_OUT (res), ASM_CALL_CONSTRAINT
			 : [val] REG_IN (w));
@@ -45,7 +46,8 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
{
	unsigned long res;

	asm_inline (ALTERNATIVE("call __sw_hweight64",
	asm_inline (ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
				"call __sw_hweight64",
				"popcntq %[val], %[cnt]", X86_FEATURE_POPCNT)
			 : [cnt] "=" REG_OUT (res), ASM_CALL_CONSTRAINT
			 : [val] REG_IN (w));
+15 −8
Original line number Diff line number Diff line
@@ -16,23 +16,23 @@
#ifdef __ASSEMBLER__

#define ASM_CLAC \
	ALTERNATIVE "", "clac", X86_FEATURE_SMAP
	ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "clac", X86_FEATURE_SMAP

#define ASM_STAC \
	ALTERNATIVE "", "stac", X86_FEATURE_SMAP
	ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "stac", X86_FEATURE_SMAP

#else /* __ASSEMBLER__ */

static __always_inline void clac(void)
{
	/* Note: a barrier is implicit in alternative() */
	alternative("", "clac", X86_FEATURE_SMAP);
	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
}

static __always_inline void stac(void)
{
	/* Note: a barrier is implicit in alternative() */
	alternative("", "stac", X86_FEATURE_SMAP);
	alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
}

static __always_inline unsigned long smap_save(void)
@@ -40,7 +40,8 @@ static __always_inline unsigned long smap_save(void)
	unsigned long flags;

	asm volatile ("# smap_save\n\t"
		      ALTERNATIVE("", "pushf; pop %0; " "clac" "\n\t",
		      ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
				  "", "pushf; pop %0; clac",
				  X86_FEATURE_SMAP)
		      : "=rm" (flags) : : "memory", "cc");

@@ -50,16 +51,22 @@ static __always_inline unsigned long smap_save(void)
static __always_inline void smap_restore(unsigned long flags)
{
	asm volatile ("# smap_restore\n\t"
		      ALTERNATIVE("", "push %0; popf\n\t",
		      ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
				  "", "push %0; popf",
				  X86_FEATURE_SMAP)
		      : : "g" (flags) : "memory", "cc");
}

/* These macros can be used in asm() statements */
#define ASM_CLAC \
	ALTERNATIVE("", "clac", X86_FEATURE_SMAP)
	ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP)
#define ASM_STAC \
	ALTERNATIVE("", "stac", X86_FEATURE_SMAP)
	ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP)

#define ASM_CLAC_UNSAFE \
	ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP)
#define ASM_STAC_UNSAFE \
	ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "stac", X86_FEATURE_SMAP)

#endif /* __ASSEMBLER__ */

+2 −4
Original line number Diff line number Diff line
@@ -231,14 +231,12 @@ static __always_inline void __xen_stac(void)
	 * Suppress objtool seeing the STAC/CLAC and getting confused about it
	 * calling random code with AC=1.
	 */
	asm volatile(ANNOTATE_IGNORE_ALTERNATIVE
		     ASM_STAC ::: "memory", "flags");
	asm volatile(ASM_STAC_UNSAFE ::: "memory", "flags");
}

static __always_inline void __xen_clac(void)
{
	asm volatile(ANNOTATE_IGNORE_ALTERNATIVE
		     ASM_CLAC ::: "memory", "flags");
	asm volatile(ASM_CLAC_UNSAFE ::: "memory", "flags");
}

static inline long
Loading