]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/asm: Annotate special section entries
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 17 Sep 2025 16:03:55 +0000 (09:03 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 14 Oct 2025 21:50:17 +0000 (14:50 -0700)
In preparation for the objtool klp diff subcommand, add annotations for
special section entries.  This will enable objtool to determine the size
and location of the entries and to extract them when needed.

Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
arch/x86/include/asm/alternative.h
arch/x86/include/asm/asm.h
arch/x86/include/asm/bug.h
arch/x86/include/asm/cpufeature.h
arch/x86/include/asm/jump_label.h
include/linux/objtool.h

index 15bc07a5ebb395da0d053ef4163e1c43be3c1cf1..b14c045679e16041e1dbb2dd2ff560224befc8cc 100644 (file)
@@ -198,6 +198,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
 
 #define ALTINSTR_ENTRY(ft_flags)                                             \
        ".pushsection .altinstructions,\"a\"\n"                               \
+       ANNOTATE_DATA_SPECIAL                                                 \
        " .long 771b - .\n"                             /* label           */ \
        " .long 774f - .\n"                             /* new instruction */ \
        " .4byte " __stringify(ft_flags) "\n"           /* feature + flags */ \
@@ -207,6 +208,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
 
 #define ALTINSTR_REPLACEMENT(newinstr)         /* replacement */       \
        ".pushsection .altinstr_replacement, \"ax\"\n"                  \
+       ANNOTATE_DATA_SPECIAL                                           \
        "# ALT: replacement\n"                                          \
        "774:\n\t" newinstr "\n775:\n"                                  \
        ".popsection\n"
@@ -337,6 +339,7 @@ void nop_func(void);
  * instruction. See apply_alternatives().
  */
 .macro altinstr_entry orig alt ft_flags orig_len alt_len
+       ANNOTATE_DATA_SPECIAL
        .long \orig - .
        .long \alt - .
        .4byte \ft_flags
@@ -365,6 +368,7 @@ void nop_func(void);
        .popsection ;                                                   \
        .pushsection .altinstr_replacement,"ax" ;                       \
 743:                                                                   \
+       ANNOTATE_DATA_SPECIAL ;                                         \
        newinst ;                                                       \
 744:                                                                   \
        .popsection ;
index d5c8d3afe19648e93954588e5189d227c1a71c46..bd62bd87a841e33f1dc29b3d09108aa8009cb072 100644 (file)
@@ -2,6 +2,8 @@
 #ifndef _ASM_X86_ASM_H
 #define _ASM_X86_ASM_H
 
+#include <linux/annotate.h>
+
 #ifdef __ASSEMBLER__
 # define __ASM_FORM(x, ...)            x,## __VA_ARGS__
 # define __ASM_FORM_RAW(x, ...)                x,## __VA_ARGS__
@@ -132,6 +134,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
 # define _ASM_EXTABLE_TYPE(from, to, type)                     \
        .pushsection "__ex_table","a" ;                         \
        .balign 4 ;                                             \
+       ANNOTATE_DATA_SPECIAL ;                                 \
        .long (from) - . ;                                      \
        .long (to) - . ;                                        \
        .long type ;                                            \
@@ -179,6 +182,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
 # define _ASM_EXTABLE_TYPE(from, to, type)                     \
        " .pushsection \"__ex_table\",\"a\"\n"                  \
        " .balign 4\n"                                          \
+       ANNOTATE_DATA_SPECIAL                                   \
        " .long (" #from ") - .\n"                              \
        " .long (" #to ") - .\n"                                \
        " .long " __stringify(type) " \n"                       \
@@ -187,6 +191,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
 # define _ASM_EXTABLE_TYPE_REG(from, to, type, reg)                            \
        " .pushsection \"__ex_table\",\"a\"\n"                                  \
        " .balign 4\n"                                                          \
+       ANNOTATE_DATA_SPECIAL                                                   \
        " .long (" #from ") - .\n"                                              \
        " .long (" #to ") - .\n"                                                \
        DEFINE_EXTABLE_TYPE_REG                                                 \
index 880ca15073ed12641b6a231fef0d553c3bce52e4..372f4018880ccff82e31f85346c92f54be68e11b 100644 (file)
@@ -57,6 +57,7 @@
 #define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra)            \
        "1:\t" ins "\n"                                                 \
        ".pushsection __bug_table,\"aw\"\n"                             \
+       ANNOTATE_DATA_SPECIAL                                           \
        __BUG_ENTRY(file, line, flags)                                  \
        "\t.org 2b + " size "\n"                                        \
        ".popsection\n"                                                 \
index 893cbca37fe99b5cad305acaa95e233b52b8e7ea..fc5f32d4da6e1164c4aff92fae7e056e9d0dd97c 100644 (file)
@@ -101,6 +101,7 @@ static __always_inline bool _static_cpu_has(u16 bit)
        asm goto(ALTERNATIVE_TERNARY("jmp 6f", %c[feature], "", "jmp %l[t_no]")
                ".pushsection .altinstr_aux,\"ax\"\n"
                "6:\n"
+               ANNOTATE_DATA_SPECIAL
                " testb %[bitnum], %a[cap_byte]\n"
                " jnz %l[t_yes]\n"
                " jmp %l[t_no]\n"
index 61dd1dee7812e75b72e6a5bccaacbafebbae8911..e0a6930a4029aa0bb894c5edc32f2dae1c268e53 100644 (file)
@@ -15,6 +15,7 @@
 #define JUMP_TABLE_ENTRY(key, label)                   \
        ".pushsection __jump_table,  \"aw\" \n\t"       \
        _ASM_ALIGN "\n\t"                               \
+       ANNOTATE_DATA_SPECIAL                           \
        ".long 1b - . \n\t"                             \
        ".long " label " - . \n\t"                      \
        _ASM_PTR " " key " - . \n\t"                    \
index 1973e9f14bf952ca976a2547d4505807ee431e86..4fea6a042b28f214173a65f125ad8482043f7181 100644 (file)
@@ -9,9 +9,10 @@
 
 #ifndef __ASSEMBLY__
 
-#define UNWIND_HINT(type, sp_reg, sp_offset, signal)   \
+#define UNWIND_HINT(type, sp_reg, sp_offset, signal)           \
        "987: \n\t"                                             \
        ".pushsection .discard.unwind_hints\n\t"                \
+       ANNOTATE_DATA_SPECIAL                                   \
        /* struct unwind_hint */                                \
        ".long 987b - .\n\t"                                    \
        ".short " __stringify(sp_offset) "\n\t"                 \
@@ -78,6 +79,7 @@
 .macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0
 .Lhere_\@:
        .pushsection .discard.unwind_hints
+               ANNOTATE_DATA_SPECIAL
                /* struct unwind_hint */
                .long .Lhere_\@ - .
                .short \sp_offset