Thread (15 messages) 15 messages, 1 author, 1d ago
DORMANTno replies
Revisions (2)
  1. v3 [diff vs current]
  2. v4 current

[PATCH v4 12/14] objtool/LoongArch: Enable inline alternative cloning for KLP

From: George Guo <hidden>
Date: 2026-07-24 11:45:49
Also in: lkml, llvm, loongarch
Subsystem: objtool, the rest · Maintainers: Josh Poimboeuf, Peter Zijlstra, Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help