Skip to content

Commit f66c05d

Browse files
Vasily GorbikIngo Molnar
Vasily Gorbik
authored and
Ingo Molnar
committed
objtool/x86: Fix elf_add_alternative() endianness
Currently x86 kernel cross-compiled on big endian system fails at boot with: kernel BUG at arch/x86/kernel/alternative.c:258! Corresponding bug condition look like the following: BUG_ON(feature >= (NCAPINTS + NBUGINTS) * 32); Fix that by converting alternative feature/cpuid to target endianness. Fixes: 9bc0bb5 ("objtool/x86: Rewrite retpoline thunk calls") Signed-off-by: Vasily Gorbik <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/patch-2.thread-6c9df9.git-6c9df9a8098d.your-ad-here.call-01620841104-ext-2554@work.hours
1 parent 46c7405 commit f66c05d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/objtool/arch/x86/decode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <objtool/elf.h>
2020
#include <objtool/arch.h>
2121
#include <objtool/warn.h>
22+
#include <objtool/endianness.h>
2223
#include <arch/elf.h>
2324

2425
static int is_x86_64(const struct elf *elf)
@@ -725,7 +726,7 @@ static int elf_add_alternative(struct elf *elf,
725726
return -1;
726727
}
727728

728-
alt->cpuid = cpuid;
729+
alt->cpuid = bswap_if_needed(cpuid);
729730
alt->instrlen = orig_len;
730731
alt->replacementlen = repl_len;
731732

0 commit comments

Comments
 (0)