The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Joe Lawrence <joe.lawrence@redhat.com>
To: George Guo <dongtai.guo@linux.dev>
Cc: chenhuacai@kernel.org, jpoimboe@kernel.org, peterz@infradead.org,
	jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com,
	kernel@xen0n.name, rostedt@goodmis.org, ardb@kernel.org,
	nathan@kernel.org, nick.desaulniers+lkml@gmail.com,
	yangtiezhu@loongson.cn, jiaxun.yang@flygoat.com,
	liukexin@kylinos.cn, guodongtai@kylinos.cn, xry111@xry111.site,
	wangyuli@aosc.io, loongarch@lists.linux.dev,
	live-patching@vger.kernel.org, llvm@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/8] LoongArch: Add livepatch build (KLP) support
Date: Thu, 2 Jul 2026 16:00:04 -0400	[thread overview]
Message-ID: <akbDROiVKjbkqMZL@redhat.com> (raw)
In-Reply-To: <20260608100852.325413-1-dongtai.guo@linux.dev>

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


      parent reply	other threads:[~2026-07-02 20:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 10:08 [PATCH v2 0/8] LoongArch: Add livepatch build (KLP) support George Guo
2026-06-08 10:08 ` [PATCH v2 1/8] objtool/LoongArch: Add arch_adjusted_addend() for KLP support George Guo
2026-06-08 10:08 ` [PATCH v2 2/8] LoongArch: Mark special sections " George Guo
2026-07-01 23:06   ` Joe Lawrence
2026-06-08 10:08 ` [PATCH v2 3/8] livepatch/klp-build: disable direct-extern-access for LoongArch to fix kernel panic George Guo
2026-06-08 10:08 ` [PATCH v2 4/8] livepatch/klp-build: build LoongArch with -fPIC to keep GOT-indirect symbol references George Guo
2026-06-08 10:08 ` [PATCH v2 5/8] LoongArch: Fix EFI linking with -fdata-sections George Guo
2026-06-08 10:08 ` [PATCH v2 6/8] objtool/klp: Add LoongArch jump opcode bytes support George Guo
2026-06-08 10:08 ` [PATCH v2 7/8] klp-build: Add LoongArch syscall patching macro George Guo
2026-06-08 10:08 ` [PATCH v2 8/8] LoongArch: Add livepatch build (KLP) support George Guo
2026-07-02 20:00 ` Joe Lawrence [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=akbDROiVKjbkqMZL@redhat.com \
    --to=joe.lawrence@redhat.com \
    --cc=ardb@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=dongtai.guo@linux.dev \
    --cc=guodongtai@kylinos.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=jikos@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liukexin@kylinos.cn \
    --cc=live-patching@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=loongarch@lists.linux.dev \
    --cc=mbenes@suse.cz \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=wangyuli@aosc.io \
    --cc=xry111@xry111.site \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox