From nobody Sun Feb 8 13:45:29 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 242E31D5CC9 for ; Fri, 26 Dec 2025 03:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766719411; cv=none; b=hyEAK+gSxIm34houlJ2huTaxmftStDXqmgWO5d+sYpuXqZ4Nc9J0tiFsArvgj9nMN+3iax1h0zDBy834qO/ZuaqJmOFdsN4e/hXr3KqzW9Qa7g5hEMNBcgFE17l+XUO6JkU9ORXX1y8CC3wGyyxKcwbuUp4LOhSpgFofFcUwVGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766719411; c=relaxed/simple; bh=Tr/S5/jBZHb/1daoozlEOuNPR1250AWr0XeUfKyu1lE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=pfQE5qbUH4xqbV7UVEjgPitrH4Upuc6I8+qKC9O1ajJVHoxvqn+fMKNQHzvRx6STL0aUY7Cgfb96N42XgUb55rUCXqjWY87eRL26Pi/NiIxQadvR+NT0NPie2iER7rM2BvT2+ZsQi0t7W1kfwyIToJM5XwjnvoEvPxEabkobNSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mTJcrQan; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mTJcrQan" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7a9c64dfa8aso5242315b3a.3 for ; Thu, 25 Dec 2025 19:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766719409; x=1767324209; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BwFWAVw6h8Xv312S1VyjkPWwDUVKMnLN9A7mXa09Pw8=; b=mTJcrQanAsvg0knjhx+VWvQT57RDXs6SQvWCz+iISUWPSq1qHATXOg+Gj1PCaTdMhG g+w0vo/g/Om5BESl7CT0vt7i/3Z3TuIwWuFnaoqqi2WNoQR7tHx+s3JRDWNvy7qs5W5r Ppjx+kqRNNKLTT1e4H3aQKx5BBJ90ELdsPy6IXxtGWW+yqwPm/bvZQd0sVvH+OWmq06f mXMkMHqeFI5PqfWZKY6ffwLRJFeFQ4D+WrajfJFQWTvf0sr7RG5UjhMZ7fjjqu09t6af VnHg0gbsR+1AP7j2w3gTVyAqsqoNSTfmsujo6cK7DN2X64P33bhm2vQIQO/4jUS3eIHU Rjng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766719409; x=1767324209; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BwFWAVw6h8Xv312S1VyjkPWwDUVKMnLN9A7mXa09Pw8=; b=j84jvEV36j0ikkmXQ/SVDd4OFgcEmNBEoedVWSMNKG/X67Ty4jITAE0ahO4mwBsrIZ KBZvc3X/C7C8X2wRMRrpSMBnsadQGfmCxpXq8zy53+grfksZqVIbYc6NGHPUMk6VGLam 2q/nI4TrHdy5Cyei1N+BAWp+ZVlz+BKNSbnBII4TOx9SvgNvSFoBF4q5Z8oPEV1Vr5+7 LqKUcva612J5SlGIiHISIT6QmjztV4UGK4Yw6C3huqrGGD9zK2VEVH41A3U7wHPvu2sh iFRUxTSXpy2zIX7+rx0sGWCVTf398osSnO0Benb+yAWzyTvN3pZjFJzxLt8xaAgdWTdD miCA== X-Gm-Message-State: AOJu0YxDDr4/7tmKbSQ+7+gptANdQ9du8biSvqajVSuyS2UIeJkhw9ON XxPajZEe4VbJsm0ngKKfSdpsCpTa3my5QKofxev8dTpGwuMfnQCcC+bD9eQa+ZOLoDI= X-Gm-Gg: AY/fxX7Ig2A1H7BMNP1zHngdfZ+yj3sozw2sCWRyiQEoG5V4Pt8mh6LJtlF6M1T+VG7 uFkoE85ZCIKQT6ncTvazOWC+x6X39sOX+fixqpe+K1dAvBtj9yFOniwHDfZl1HNCoxQSp9DIqVs yijvGEQO1LzXy+RbZinO7TyDrdnqdnrubwikeBk80J4/oBDdMPhQu8BayR32wjQvwLWXCLqZzge qEB3FWCb25hBH4xvVsEh/VcTqKK3FWix5YziZyHgr+eWlzCJbGyhZs/cYIN21Gu/hO6McBbwj1F x+X9DtUJ3iMtV/A5A/8+vBC0S7pWWwm/SZvRsNLBp+jLNdddXnc/Y3OWbI3s0FTYXyofh51UNpn qvJLEJnCqARPnTf2p5MdjJzDOzjyYBfYEYdLBDyE/fuTD7Chzdw1FC2Jq78qXublNDZ9EEZfrja XepTNpUhHozCjjCG2A X-Google-Smtp-Source: AGHT+IE07m7Emrj+WzeP1mfMN9OpZdPRM1bkJLjkAvmxllAWcr2fU1Q4i/ulJEELcKU252kxFBcRKg== X-Received: by 2002:a05:6a21:3287:b0:366:2677:4b38 with SMTP id adf61e73a8af0-376a75e76demr22310059637.8.1766719409132; Thu, 25 Dec 2025 19:23:29 -0800 (PST) Received: from fric.. ([210.73.43.101]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c1e7a018586sm17909152a12.15.2025.12.25.19.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Dec 2025 19:23:28 -0800 (PST) From: Jiakai Xu X-Google-Original-From: Jiakai Xu To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Nam Cao , Alexandre Ghiti , Jiakai Xu , Jiakai Xu Subject: [PATCH v2] riscv: fix KUnit test_kprobes crash when building with Clang Date: Fri, 26 Dec 2025 03:23:17 +0000 Message-Id: <20251226032317.1523764-1-jiakaiPeanut@gmail.com> X-Mailer: git-send-email 2.34.1 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="utf-8" Content-Transfer-Encoding: quoted-printable Clang misinterprets the placement of test_kprobes_addresses and=20 test_kprobes_functions arrays when they are not explicitly assigned=20 to a data section. This can lead to kmalloc_array() allocation=20 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_nopr= of+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=20 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.xujiakai2= 025@iscas.ac.cn Link: https://github.com/llvm/llvm-project/issues/168308 v1 -> v2=EF=BC=9A - Drop changes to .align, and .globl. --- 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/risc= v/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) =20 #endif /* CONFIG_RISCV_ISA_C */ =20 +.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) =20 +.section .rodata SYM_DATA_START(test_kprobes_functions) RISCV_PTR test_kprobes_add RISCV_PTR test_kprobes_jal --=20 2.34.1