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 8A92723C4F3 for ; Wed, 19 Nov 2025 01:38:14 +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=1763516294; cv=none; b=iDgYTnJbuF/l+maCn/eRtn44AMCLp9/RhUO3awvRVcuaUFRifO9t5qyjCEKSC8zcJ6zbE/Y427BThm8+RRKVu3qppCdbIxtEiVruLKwm0Gy01zhoNjObRIukd2X71GA99P+ywsbIwavh/5mQ7oz5gMFZaXSbraR6506Vd3QP5Xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763516294; c=relaxed/simple; bh=wGwlctlR3phb/EaWdcj3gsbtcDdcz9sjR+f8vd0Ir2U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SVy92Ctfo4WjUjXrt4H5uUNuS4fcKqvv8yWfEAYpwcQBsf1VuSR/30wrMcwYZtUwcZtw1w39xftZp6xtCDurnvVVFlzwXtPUoOiVu1rLu1E46UY7mBPsvBEs5eMyFLaDzdkrJ0bjsL96mFrDkevsza5Q4UG20ZuBXVj4v+n8kZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=phoBJz/w; 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="phoBJz/w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED477C19421; Wed, 19 Nov 2025 01:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763516293; bh=wGwlctlR3phb/EaWdcj3gsbtcDdcz9sjR+f8vd0Ir2U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=phoBJz/wW1mdB/aPVdYRHDSa4NyVz2vSvkFE1ZL80Fa0m4Jxdpt3C5aK9r1J5pjqC Mp81bE/WWvv6pcTP2aqJxoki1zwxA9DdF2BEbMClFn/UoWei5tskBiRGenWHazdcdK dgw6wUR2owco0L20XL+dZasgCrlOtO4ZiYZ3Mzts07gCSYfLZKlVk2Pe73rQrSzRP/ DC6HI6RQDeNCXCPVTImSrqKE114qmGpnzgwv638cOPZJRcbhvktSjVzLGoJ/ud/PMQ kKL7u0osMmV1lRGlOZevS16ZUtSPJOk3FZaD7+gJw3TqNNSUaIIacJ9DXRF9+f79l7 qDyRoXkF43AwQ== Date: Tue, 18 Nov 2025 18:38:08 -0700 From: Nathan Chancellor To: Paul Walmsley , Jiakai Xu Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Albert Ou , Alexandre Ghiti , namcao@linutronix.de Subject: Re: Re: [PATCH] riscv: fix KUnit test_kprobes crash when building with Clang Message-ID: <20251119013808.GA1264583@ax162> References: <738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn> <621798fc-68bc-504c-755f-0a2f1f83d1c2@kernel.org> <108ac2f0.17c6b.19a8fc4d1ca.Coremail.xujiakai2025@iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Paul and Jiakai, On Tue, Nov 18, 2025 at 01:21:50PM -0700, Paul Walmsley wrote: > Not all of it, but some edited summary is appropriate. I've queued the > following revision for v6.18-rc fixes, under the theory that it would be > good to get the test working for Clang users while the LLVM folks > investigate. Please let us know ASAP if you think anything in it should > be changed. I plan to send a PR out later this week. I spent some time today trying to minimize a small set of configurations that triggers this issue on top of defconfig since that occasionally reveals a path to head down for triage and I landed on: $ cat arch/riscv/configs/repro.config CONFIG_KPROBES=y CONFIG_KUNIT=y CONFIG_RELOCATABLE=y CONFIG_RISCV_KPROBES_KUNIT=y $ make -skj"$(nproc)" ARCH=riscv LLVM=1 clean defconfig repro.config Image $ curl -LSs https://github.com/ClangBuiltLinux/boot-utils/releases/download/20241120-044434/riscv-rootfs.cpio.zst | zstd -d >rootfs.cpio $ qemu-system-riscv64 \ -display none \ -nodefaults \ -bios default \ -M virt \ -append earlycon \ -kernel arch/riscv/boot/Image \ -initrd rootfs.cpio \ -m 512m \ -serial mon:stdio ... [ 0.000000] Booting Linux on hartid 0 [ 0.000000] Linux version 6.18.0-rc6-dirty (nathan@ax162) (ClangBuiltLinux clang version 21.1.5 (https://github.com/llvm/llvm-project.git 8e2cd28cd4ba46613a46467b0c91b1cabead26cd), ClangBuiltLinux LLD 21.1.5 (https://github.com/llvm/llvm-project.git 8e2cd28cd4ba46613a46467b0c91b1cabead26cd)) #1 SMP Tue Nov 18 17:58:23 MST 2025 ... [ 1.041311] KTAP version 1 [ 1.041433] 1..1 [ 1.042111] KTAP version 1 [ 1.042310] # Subtest: kprobes_riscv [ 1.042610] # module: kprobes_riscv_kunit [ 1.042732] 1..1 [ 1.047104] ------------[ cut here ]------------ [ 1.047293] WARNING: CPU: 0 PID: 45 at mm/page_alloc.c:5159 __alloc_frozen_pages_noprof+0x160/0x228 [ 1.047602] Modules linked in: [ 1.047851] CPU: 0 UID: 0 PID: 45 Comm: kunit_try_catch Tainted: G N 6.18.0-rc6-dirty #1 NONE [ 1.047933] Tainted: [N]=TEST [ 1.047948] Hardware name: riscv-virtio,qemu (DT) [ 1.048024] epc : __alloc_frozen_pages_noprof+0x160/0x228 [ 1.048057] ra : ___kmalloc_large_node+0x52/0x1a0 [ 1.048073] epc : ffffffff8023e2e8 ra : ffffffff80247c26 sp : ff200000001f3c10 [ 1.048086] gp : ffffffff81a25900 tp : ff600000023924c0 t0 : 00000000264163d0 [ 1.048097] t1 : 00000000264163d0 t2 : 00000000000aae60 s0 : ff200000001f3c90 [ 1.048108] s1 : 000000000a83ca20 a0 : 0000000000000001 a1 : ffffffff819e71ba [ 1.048119] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 000000003b9aca00 [ 1.048130] a5 : 0000000000016698 a6 : ff600000021480d0 a7 : 00000000000aae60 [ 1.048140] s2 : 0000000000000010 s3 : ffffffff8024857a s4 : 0000000000000dc0 [ 1.048151] s5 : ffffffff80018e20 s6 : ff2000000000bb40 s7 : 0000000000000000 [ 1.048161] s8 : 0000000000000000 s9 : 0000000000166e7c s10: 0000000000000000 [ 1.048171] s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000002 [ 1.048181] t5 : ff60000002392580 t6 : 0000000000000001 [ 1.048191] status: 0000000200000120 badaddr: ffffffff8023e2e8 cause: 0000000000000003 [ 1.048281] [] __alloc_frozen_pages_noprof+0x160/0x228 [ 1.048362] [] ___kmalloc_large_node+0x52/0x1a0 [ 1.048374] [] __kmalloc_large_node_noprof+0x1c/0x114 [ 1.048384] [] __kmalloc_noprof+0x252/0x450 [ 1.048393] [] test_kprobe_riscv+0x5a/0x210 [ 1.048406] [] kunit_try_run_case+0x5a/0x15c [ 1.048417] [] kunit_generic_run_threadfn_adapter+0x1a/0x34 [ 1.048439] [] kthread+0x178/0x1a0 [ 1.048450] [] ret_from_fork_kernel+0xe/0x48 [ 1.048464] [] ret_from_fork_kernel_asm+0x16/0x1c [ 1.048513] ---[ end trace 0000000000000000 ]--- [ 1.056832] # test_kprobe_riscv: EXPECTATION FAILED at arch/riscv/kernel/tests/kprobes/test-kprobes.c:24 [ 1.056832] Expected kp to be true, but is false [ 1.058370] not ok 1 test_kprobe_riscv [ 1.058484] not ok 1 kprobes_riscv ... This appears to happen back to LLVM 15 so I am not sure it is a recent recent regression on the toolchain side. Without CONFIG_RELOCATABLE enabled, the test passes: [ 1.049384] KTAP version 1 [ 1.049656] 1..1 [ 1.050246] KTAP version 1 [ 1.050447] # Subtest: kprobes_riscv [ 1.050760] # module: kprobes_riscv_kunit [ 1.050867] 1..1 [ 1.061790] ok 1 test_kprobe_riscv [ 1.061929] ok 1 kprobes_riscv Interestingly, if I enable CONFIG_RISCV_KPROBES_KUNIT as a module, I get a failure when trying to load it in QEMU: ~ # modprobe kprobes_riscv_kunit [ 42.214642] kprobes_riscv_kunit: The unexpected relocation type 'R_RISCV_ALIGN' from PC = 00000000abb84ce7 [ 42.222778] kprobes_riscv_kunit: The unexpected relocation type 'R_RISCV_ALIGN' from PC = 00000000abb84ce7 modprobe: can't load module kprobes_riscv_kunit (kernel/arch/riscv/kernel/tests/kprobes/kprobes_riscv_kunit.ko): Invalid argument which is probably unrelated but I figured it was worth mentioning, as it does not allow me to see if this has something to do with the flags added to LDFLAGS_vmlinux. Maybe this is useful for the upstream report and further triage. Cheers, Nathan