From: George Guo <redacted>
An ALTERNATIVE() emits its replacement instructions into a .subsection 1
placed after the patched function. When objtool clones the function into
a livepatch module, clone_inline_alternatives() clones that replacement
block too, but only for architectures that define ARCH_HAS_INLINE_ALTS.
LoongArch uses the same .subsection layout as arm64, and its alternative
macros now mark the replacement with ANNOTATE_DATA_SPECIAL (see "LoongArch:
Mark special sections for KLP support"). Define ARCH_HAS_INLINE_ALTS so
the replacement is cloned; otherwise a livepatch for a function containing
an ALTERNATIVE() fails to build with "can't find new instruction".
Reproduced by building a livepatch for a function containing an
ALTERNATIVE() (the base-vmlinux test).
Link: https://lore.kernel.org/all/ak7QBSm3mmDlB-4u@redhat.com (local)
Reported-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: George Guo <redacted>
---
tools/objtool/arch/loongarch/include/arch/elf.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/objtool/arch/loongarch/include/arch/elf.h b/tools/objtool/arch/loongarch/include/arch/elf.h
index 0103f27fccfc..e2843679f24e 100644
--- a/tools/objtool/arch/loongarch/include/arch/elf.h
+++ b/tools/objtool/arch/loongarch/include/arch/elf.h
@@ -46,6 +46,7 @@
#define R_TEXT32 R_LARCH_32_PCREL
#define R_TEXT64 R_LARCH_32_PCREL
+#define ARCH_HAS_INLINE_ALTS 1
#define ARCH_HAS_PAIRED_RELOCS 1
struct elf;
--
2.53.0