Commit a6640c8c authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

Pull objtool updates from Ingo Molnar:

 - Introduce the generic section-based annotation infrastructure a.k.a.
   ASM_ANNOTATE/ANNOTATE (Peter Zijlstra)

 - Convert various facilities to ASM_ANNOTATE/ANNOTATE: (Peter Zijlstra)
    - ANNOTATE_NOENDBR
    - ANNOTATE_RETPOLINE_SAFE
    - instrumentation_{begin,end}()
    - VALIDATE_UNRET_BEGIN
    - ANNOTATE_IGNORE_ALTERNATIVE
    - ANNOTATE_INTRA_FUNCTION_CALL
    - {.UN}REACHABLE

 - Optimize the annotation-sections parsing code (Peter Zijlstra)

 - Centralize annotation definitions in <linux/objtool.h>

 - Unify & simplify the barrier_before_unreachable()/unreachable()
   definitions (Peter Zijlstra)

 - Convert unreachable() calls to BUG() in x86 code, as unreachable()
   has unreliable code generation (Peter Zijlstra)

 - Remove annotate_reachable() and annotate_unreachable(), as it's
   unreliable against compiler optimizations (Peter Zijlstra)

 - Fix non-standard ANNOTATE_REACHABLE annotation order (Peter Zijlstra)

 - Robustify the annotation code by warning about unknown annotation
   types (Peter Zijlstra)

 - Allow arch code to discover jump table size, in preparation of
   annotated jump table support (Ard Biesheuvel)

* tag 'objtool-core-2025-01-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/mm: Convert unreachable() to BUG()
  objtool: Allow arch code to discover jump table size
  objtool: Warn about unknown annotation types
  objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
  objtool: Convert {.UN}REACHABLE to ANNOTATE
  objtool: Remove annotate_{,un}reachable()
  loongarch: Use ASM_REACHABLE
  x86: Convert unreachable() to BUG()
  unreachable: Unify
  objtool: Collect more annotations in objtool.h
  objtool: Collapse annotate sequences
  objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL to ANNOTATE
  objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE to ANNOTATE
  objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE
  objtool: Convert instrumentation_{begin,end}() to ANNOTATE
  objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATE
  objtool: Convert ANNOTATE_NOENDBR to ANNOTATE
  objtool: Generic annotation infrastructure
parents 8838a1a2 41a1e976
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

#include <asm/break.h>
#include <linux/stringify.h>
#include <linux/objtool.h>

#ifndef CONFIG_DEBUG_BUGVERBOSE
#define _BUGVERBOSE_LOCATION(file, line)
@@ -33,25 +34,25 @@

#define ASM_BUG_FLAGS(flags)					\
	__BUG_ENTRY(flags)					\
	break		BRK_BUG
	break		BRK_BUG;

#define ASM_BUG()	ASM_BUG_FLAGS(0)

#define __BUG_FLAGS(flags)					\
	asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)));
#define __BUG_FLAGS(flags, extra)					\
	asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags))		\
			     extra);

#define __WARN_FLAGS(flags)					\
do {								\
	instrumentation_begin();				\
	__BUG_FLAGS(BUGFLAG_WARNING|(flags));			\
	annotate_reachable();					\
	__BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
	instrumentation_end();					\
} while (0)

#define BUG()							\
do {								\
	instrumentation_begin();				\
	__BUG_FLAGS(0);						\
	__BUG_FLAGS(0, "");					\
	unreachable();						\
} while (0)

+4 −5
Original line number Diff line number Diff line
@@ -308,10 +308,9 @@ SYM_CODE_END(xen_error_entry)
		movq	$-1, ORIG_RAX(%rsp)	/* no syscall to restart */
	.endif

	call	\cfunc

	/* For some configurations \cfunc ends up being a noreturn. */
	REACHABLE
	ANNOTATE_REACHABLE
	call	\cfunc

	jmp	error_return
.endm
@@ -529,10 +528,10 @@ SYM_CODE_START(\asmsym)
	movq	%rsp, %rdi		/* pt_regs pointer into first argument */
	movq	ORIG_RAX(%rsp), %rsi	/* get error code into 2nd argument*/
	movq	$-1, ORIG_RAX(%rsp)	/* no syscall to restart */
	call	\cfunc

	/* For some configurations \cfunc ends up being a noreturn. */
	REACHABLE
	ANNOTATE_REACHABLE
	call	\cfunc

	jmp	paranoid_exit

+1 −21
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

#include <linux/types.h>
#include <linux/stringify.h>
#include <linux/objtool.h>
#include <asm/asm.h>

#define ALT_FLAGS_SHIFT		16
@@ -54,16 +55,6 @@
#define LOCK_PREFIX ""
#endif

/*
 * objtool annotation to ignore the alternatives and only consider the original
 * instruction(s).
 */
#define ANNOTATE_IGNORE_ALTERNATIVE				\
	"999:\n\t"						\
	".pushsection .discard.ignore_alts\n\t"			\
	".long 999b\n\t"					\
	".popsection\n\t"

/*
 * The patching flags are part of the upper bits of the @ft_flags parameter when
 * specifying them. The split is currently like this:
@@ -310,17 +301,6 @@ void nop_func(void);
	.endm
#endif

/*
 * objtool annotation to ignore the alternatives and only consider the original
 * instruction(s).
 */
.macro ANNOTATE_IGNORE_ALTERNATIVE
	.Lannotate_\@:
	.pushsection .discard.ignore_alts
	.long .Lannotate_\@
	.popsection
.endm

/*
 * Issue one struct alt_instr descriptor entry (need to put it into
 * the section .altinstructions, see below). This entry contains
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ do { \
do {								\
	__auto_type __flags = BUGFLAG_WARNING|(flags);		\
	instrumentation_begin();				\
	_BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE);		\
	_BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b));	\
	instrumentation_end();					\
} while (0)

+2 −2
Original line number Diff line number Diff line
@@ -100,8 +100,8 @@
}

#define ASM_CALL_ARG0							\
	"call %c[__func]				\n"		\
	ASM_REACHABLE
	"1: call %c[__func]				\n"		\
	ANNOTATE_REACHABLE(1b)

#define ASM_CALL_ARG1							\
	"movq	%[arg1], %%rdi				\n"		\
Loading