Skip to content

Commit a818f28

Browse files
jpoimboeingomolnar
authored andcommitted
x86/alternative: Remove ANNOTATE_DATA_SPECIAL usage
Instead of manually annotating each .altinstructions entry, just make the section mergeable and store the entry size in the ELF section header. Either way works for objtool create_fake_symbols(), this way produces cleaner code generation. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://patch.msgid.link/5ac04e6db5be6453dce8003a771ebb0c47b4cd7a.1764694625.git.jpoimboe@kernel.org
1 parent 0c314a8 commit a818f28

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

arch/um/include/shared/common-offsets.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC);
1818
DEFINE(UM_KERN_GDT_ENTRY_TLS_ENTRIES, GDT_ENTRY_TLS_ENTRIES);
1919

2020
DEFINE(UM_SECCOMP_ARCH_NATIVE, SECCOMP_ARCH_NATIVE);
21+
22+
DEFINE(ALT_INSTR_SIZE, sizeof(struct alt_instr));

arch/x86/include/asm/alternative.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ static inline int alternatives_text_reserved(void *start, void *end)
197197
"773:\n"
198198

199199
#define ALTINSTR_ENTRY(ft_flags) \
200-
".pushsection .altinstructions,\"a\"\n" \
201-
ANNOTATE_DATA_SPECIAL \
200+
".pushsection .altinstructions, \"aM\", @progbits, " \
201+
__stringify(ALT_INSTR_SIZE) "\n" \
202202
" .long 771b - .\n" /* label */ \
203203
" .long 774f - .\n" /* new instruction */ \
204204
" .4byte " __stringify(ft_flags) "\n" /* feature + flags */ \
@@ -339,7 +339,6 @@ void nop_func(void);
339339
* instruction. See apply_alternatives().
340340
*/
341341
.macro altinstr_entry orig alt ft_flags orig_len alt_len
342-
ANNOTATE_DATA_SPECIAL
343342
.long \orig - .
344343
.long \alt - .
345344
.4byte \ft_flags
@@ -363,7 +362,7 @@ void nop_func(void);
363362
741: \
364363
.skip -(((744f-743f)-(741b-740b)) > 0) * ((744f-743f)-(741b-740b)),0x90 ;\
365364
742: \
366-
.pushsection .altinstructions,"a" ; \
365+
.pushsection .altinstructions, "aM", @progbits, ALT_INSTR_SIZE ;\
367366
altinstr_entry 740b,743f,flag,742b-740b,744f-743f ; \
368367
.popsection ; \
369368
.pushsection .altinstr_replacement,"ax" ; \

arch/x86/kernel/asm-offsets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,6 @@ static void __used common(void)
124124
OFFSET(ARIA_CTX_rounds, aria_ctx, rounds);
125125
#endif
126126

127+
BLANK();
128+
DEFINE(ALT_INSTR_SIZE, sizeof(struct alt_instr));
127129
}

0 commit comments

Comments
 (0)