From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1DCB3C0C for ; Wed, 31 Dec 2025 03:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767150930; cv=none; b=mL+wlPBHUnifvaIPVbNtEpAJFl0qPftrsOVvpOS9UzE5bHL863Y2XaqahjDnX51sY6Bx/9KVI4AEdklsHtowJgrKyFj5eJwyltsIe2bZHE0PB7RqlwLdnXtdvtDU7PnDhE7GA1AWRPmee6SP2QSKfZ0poJBwneJy051jasKpDGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767150930; c=relaxed/simple; bh=N6HFlgfL0VlBPAArfq2sVNpxf0YCgEJBIZpYYblK/AE=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=GqeeuK3YjaXJF9F2gl+CkNY/Te4Wr1gGYBzpercaL8lUvCqk29WpGMYPZHKUeinGMeKgHTiPuNkaxfQfchCe6a0q3CQgGAvYlWcK+24k4hP0bJr/lIb4zpDttDUTruTRlXN05ZV29d5oyLis0e30Snj7VTB7Nkp899At1LmTxZI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TgzO4umg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TgzO4umg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DB64C116B1; Wed, 31 Dec 2025 03:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767150930; bh=N6HFlgfL0VlBPAArfq2sVNpxf0YCgEJBIZpYYblK/AE=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=TgzO4umgcLGzUMcmIMv2OSGLrdbS7wevapcH78+Fa3HxlNbvuFoQeod1ZHOg7UlWP uBFwmhaaFjaEjtRZflAUWUJl1Z86eogvqYnwdxj9LzWEseC1ujA/PkQa3WoWWRTdoS Gp/m2NtIPK/ITnczhrq9kNDNNbODJ1EdNO9378zevAnU9xzsOj74JWGx3DYv5CkSDR pK+u+7nbiD4njHRZOBWP09jEN8k4DDChJnNBVvBkhVwFe4JQHEVfU4ZB5t8pDohdRr G58BrLp71Pj6UuJ+Ky1/PMmjOHSvdTo1sDEXXLRNZQeQc4EGTTfClsUeDQBbpPjBoN 7lvabxAopB55g== Date: Tue, 30 Dec 2025 20:15:28 -0700 (MST) From: Paul Walmsley To: Jiakai Xu cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Nam Cao , Alexandre Ghiti , Jiakai Xu Subject: Re: [PATCH v2] riscv: fix KUnit test_kprobes crash when building with Clang In-Reply-To: <20251226032317.1523764-1-jiakaiPeanut@gmail.com> Message-ID: <5cad53b9-e6f7-d8c8-8c54-c4e5af035bbf@kernel.org> References: <20251226032317.1523764-1-jiakaiPeanut@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1674692257-1767150930=:293827" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1674692257-1767150930=:293827 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Hi Jiakai Xu, thanks for updating this patch - On Fri, 26 Dec 2025, Jiakai Xu wrote: > Clang misinterprets the placement of test_kprobes_addresses and > test_kprobes_functions arrays when they are not explicitly assigned > to a data section. This can lead to kmalloc_array() allocation > errors and KUnit failures. > > When testing the Clang-compiled code in QEMU, this warning was emitted: > > WARNING: CPU: 1 PID: 3000 at mm/page_alloc.c:5159 __alloc_frozen_pages_noprof+0xe6/0x2fc mm/page_alloc.c:5159 > > Further investigation revealed that the test_kprobes_addresses array > appeared to have over 100,000 elements, including invalid addresses; > whereas, according to test-kprobes-asm.S, test_kprobes_addresses > should only have 25 elements. > > When compiling the kernel with GCC, the kernel boots correctly. > > This patch fixes the issue by adding .section .rodata to explicitly > place arrays in the read-only data segment. > > For detailed debug and analysis, see: > https://github.com/j1akai/temp/blob/main/20251113/readme.md > > Signed-off-by: Jiakai Xu > Signed-off-by: Jiakai Xu > Link: https://patch.msgid.link/738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn > Link: https://github.com/llvm/llvm-project/issues/168308 > > v1 -> v2: > - Drop changes to .align, and .globl. This should go below the --- line (or above the Signed-off-by:, Link: lines). There shouldn't be anything between the Signed-off-by:, Link: trailers and the ---. I've fixed this up locally, and queued for v6.19-rc. > > --- > arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S b/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S > index b951d0f12482..f16deee9e091 100644 > --- a/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S > +++ b/arch/riscv/kernel/tests/kprobes/test-kprobes-asm.S > @@ -181,6 +181,7 @@ SYM_FUNC_END(test_kprobes_c_bnez) > > #endif /* CONFIG_RISCV_ISA_C */ > > +.section .rodata > SYM_DATA_START(test_kprobes_addresses) > RISCV_PTR test_kprobes_add_addr1 > RISCV_PTR test_kprobes_add_addr2 > @@ -212,6 +213,7 @@ SYM_DATA_START(test_kprobes_addresses) > RISCV_PTR 0 > SYM_DATA_END(test_kprobes_addresses) > > +.section .rodata > SYM_DATA_START(test_kprobes_functions) > RISCV_PTR test_kprobes_add > RISCV_PTR test_kprobes_jal > -- > 2.34.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv > --8323329-1674692257-1767150930=:293827--