public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: 许佳凯 <xujiakai2025@iscas.ac.cn>,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>
Subject: Re: [PATCH] riscv: fix KUnit test_kprobes crash when building with Clang
Date: Wed, 26 Nov 2025 10:23:59 +0100	[thread overview]
Message-ID: <875xax5eq8.fsf@yellow.woof> (raw)
In-Reply-To: <738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn>

许佳凯 <xujiakai2025@iscas.ac.cn> writes:
> Clang misaligns the test_kprobes_addresses and test_kprobes_functions
> arrays, or does not export local labels by default. Both can cause
> kmalloc_array() allocation errors and KUnit failures.
>
> This patch fixes the issue by:
> - Adding .section .rodata to explicitly place arrays in the read-only data segment.
> - Adding .align 3 to align arrays to 8 bytes.
> - Adding .globl to probe labels to ensure symbols are visible.

We do not have to make it exactly the same as building with GCC, right?
Only moving the arrays to .rodata seems sufficient to fix the issue, but
I cannot explain why yet.

What I observed is that with CONFIG_RELOCATABLE=y, the kernel's
.rela.dyn section, which holds the relocation entries for the two
arrays, have incorrect addresses (they are all incorrectly offset by 6
bytes for my build). The kernel uses these relocation information to
fill the arrays during boot, and fill them at wrong addresses.

I smell a linker problem, but more investigation needed...

Nam

  parent reply	other threads:[~2025-11-26  9:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 10:51 [PATCH] riscv: fix KUnit test_kprobes crash when building with Clang 许佳凯
2025-11-16  5:15 ` Paul Walmsley
2025-11-17  3:03   ` Jiakai Xu
2025-11-18 20:21     ` Paul Walmsley
2025-11-19  1:38       ` Nathan Chancellor
2025-11-19  3:33         ` Jiakai Xu
2025-11-19  3:01       ` Jiakai Xu
2025-11-22  1:10         ` Paul Walmsley
2025-12-26  3:31           ` Jiakai Xu
2025-11-18 21:10 ` patchwork-bot+linux-riscv
2025-11-26  9:23 ` Nam Cao [this message]
2025-11-26 18:08   ` Nam Cao

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=875xax5eq8.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=xujiakai2025@iscas.ac.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