On Mon, Jun 08, 2026 at 06:08:44PM +0800, George Guo wrote:
> This series adds LoongArch support for the klp-build livepatch tooling,
> enabling automated livepatch module generation using objtool on
> LoongArch.
>
> It is based on Josh Poimboeuf's klp-build series [1] (see base-commit
> below) and extends it with the LoongArch-specific objtool and build
> pieces, plus a few LoongArch toolchain/relocation fixes required to make
> livepatch modules load and run correctly.
>
Ok, what am I doing wrong here:
- Git tree is jpoimboe/klp-build-arm64 + this patchset
- Using clang v21.1.8 and a defconfig + CONFIG_LIVEPATCH requirements
- A simple patch to net/core/dev.c :: netif_rx_internal()
$ clang --version
clang version 21.1.8 (Fedora 21.1.8-4.fc43)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
Setup and build the reference kernel:
$ ARCH=loongarch LLVM=1 make defconfig
$ ./scripts/config --file .config \
--set-val CONFIG_FTRACE y \
--set-val CONFIG_KALLSYMS_ALL y \
--set-val CONFIG_FUNCTION_TRACER y \
--set-val CONFIG_DYNAMIC_FTRACE y \
--set-val CONFIG_DYNAMIC_DEBUG y \
--set-val CONFIG_LIVEPATCH y
$ ARCH=loongarch LLVM=1 make olddefconfig
$ grep LIVEPATCH .config
CONFIG_HAVE_LIVEPATCH=y
CONFIG_LIVEPATCH=y
$ ARCH=loongarch LLVM=1 make -j$(nproc)
...
Then provide this small patch:
$ cat test.patch
diff --git a/net/core/dev.c b/net/core/dev.c
index 06c195906231..14fd3d5f351a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5717,6 +5717,7 @@ static int netif_rx_internal(struct sk_buff *skb)
unsigned int qtail;
ret = enqueue_to_backlog(skb, smp_processor_id(), &qtail);
+ pr_info("test");
}
return ret;
}
to klp-build:
$ ARCH=loongarch LLVM=1 ./scripts/livepatch/klp-build -T test.patch
Validating patch(es)
Building original kernel
LoongArch detected: adding -fno-direct-access-external-data to
KBUILD_CFLAGS_KERNEL
Cannot find symbol for section 5: .text.sched_clock.
kernel/sched/build_utility.o: failed
The "Cannot find symbol for section" error message comes out of the
recordmcount script.
What's strange is that arch/loongarch/Makefile wants to use patchable
function entry:
ifdef CONFIG_DYNAMIC_FTRACE
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
CC_FLAGS_FTRACE := -fpatchable-function-entry=2
endif
but Kconfig doesn't set it up for LoongArch. If I select when
DYNAMIC_FTRACE is turned on, like:
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
index 1dbf51ba9d6a..6d9bc4a580d9 100644
--- a/arch/loongarch/Kconfig
+++ b/arch/loongarch/Kconfig
@@ -139,6 +139,7 @@ config LOONGARCH
select HAVE_DMA_CONTIGUOUS
select HAVE_DYNAMIC_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_ARGS
+ select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
select HAVE_FTRACE_REGS_HAVING_PT_REGS
select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
select HAVE_DYNAMIC_FTRACE_WITH_REGS
then rebuild the kernel and retry klp-build, it at least completes the
original and patched kernel builds:
$ ARCH=loongarch LLVM=1 ./scripts/livepatch/klp-build -T test.patch
Validating patch(es)
Building original kernel
LoongArch detected: adding -fno-direct-access-external-data to
KBUILD_CFLAGS_KERNEL
vmlinux.o: warning: objtool: __efistub_efi_boot_kernel(): unexpected end of
section .init.text.efi_boot_kernel
Copying original object files
Fixing patch(es)
Building patched kernel
LoongArch detected: adding -fno-direct-access-external-data to
KBUILD_CFLAGS_KERNEL
vmlinux.o: warning: objtool: __efistub_efi_boot_kernel(): unexpected end of
section .init.text.efi_boot_kernel
Copying patched object files
Generating original checksums
Generating patched checksums
Diffing objects
vmlinux.o: changed function: netif_rx_internal
vmlinux.o: error: objtool: __jump_table_23683+0x8: duplicate reloc
error: klp-build: objtool klp diff failed
error: klp-build: line 829: '( cd "$ORIG_CSUM_DIR"; [[ -v VERBOSE ]] && echo
"cd $ORIG_CSUM_DIR && ${cmd[*]}"; "${cmd[@]}" > >(tee -a "$log") 2> >(tee -a
"$log" | "${filter[@]}" 1>&2) || die "objtool klp diff failed" )'
but ends with a new error on "duplicate reloc" out of klp-build.
What compiler / kernel config should I be trying with this patchset?
Thanks,
--
Joe