From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2319D10399 for ; Wed, 26 Nov 2025 09:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mn1Oy7BS+vUARQ5+U6QlnQ1YLI5Zm6ocBPF7+1S1XwY=; b=Ozm18gntxjnP4E jdPzs1dI2lHpcTXqyB4j02kKcn0GC5fOunIsM1VykXqtL4RTX9l9N3+SoCfj4gvJibTh59K73Whuz SchYFPtn5HSXYosh829RHL8tbtCkth5ijS71H21OBhHiRrN7nCp4ov/mlIC/tdQECK1Jtej96GcFn QTDGEDpAGtjYLFQPlo0Xq6QtdIe35F6uSxmsldPAfXKCnxJUcPEYBdhuDBREx4b9Ju1DLMgyEXQh6 +pdSkFKFoWHQhRJD0oS6GlsohK290TGJ0P4DdrEOVtu/4WiW0nklNrz/pVy4ywNJMsaUydirYN/wm GicKHlRJIt2zbRn46QkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vOBkt-0000000Ehgx-1jef; Wed, 26 Nov 2025 09:24:07 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vOBkq-0000000EhgK-3ohX for linux-riscv@lists.infradead.org; Wed, 26 Nov 2025 09:24:06 +0000 From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1764149040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7FqM5Wnnl94ag6oBJ+M9iRWwcQjsCvnH0zYX9MIORQ4=; b=rfQ1HFBpIxiilHt+KLt5NN4gD2z77WVeUtbZBGYvWOPZw92ny4Y2YgqSHbbWdE5R9+OM/h YVhadbJqtRrsluhHci9BZxNR4bLgYlzSIR9UpXYUxCTEL4fYeVWygi9sPcodFXI0RUBqGT 4UPcW/Bu0hvSfsf1JHUaobeuCRRGZT9YqNH+1hqo2v+eamUOrnaCjX83EHs0N9zeZ5RdpM rZ320K4UmFF9YS7Th2L1I3QbFeYT2omORhHa+Uh6RnJBj7TQ5zgwYOZI+kFGKSkrxgZ03+ ngF2UTjJLTf1gx5IJQAEOxSHB9dWZEd8FYzz18WQfa9WyjeDWQPh7i35fbk4hQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1764149040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7FqM5Wnnl94ag6oBJ+M9iRWwcQjsCvnH0zYX9MIORQ4=; b=4ivR1zZoMegPK/lIsjIvbmYCvwob9gmJbbA4PW9nvwTHOrYhNgjPt4DNAuI7JYzhVoOQ3U kr4Qzd1+tL1KkyBw== To: =?utf-8?B?6K645L2z5Yev?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti Subject: Re: [PATCH] riscv: fix KUnit test_kprobes crash when building with Clang In-Reply-To: <738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn> References: <738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn> Date: Wed, 26 Nov 2025 10:23:59 +0100 Message-ID: <875xax5eq8.fsf@yellow.woof> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251126_012405_091121_03FBA2CE X-CRM114-Status: UNSURE ( 6.97 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 6K645L2z5YevIDx4dWppYWthaTIwMjVAaXNjYXMuYWMuY24+IHdyaXRlczoKPiBDbGFuZyBtaXNh bGlnbnMgdGhlIHRlc3Rfa3Byb2Jlc19hZGRyZXNzZXMgYW5kIHRlc3Rfa3Byb2Jlc19mdW5jdGlv bnMKPiBhcnJheXMsIG9yIGRvZXMgbm90IGV4cG9ydCBsb2NhbCBsYWJlbHMgYnkgZGVmYXVsdC4g Qm90aCBjYW4gY2F1c2UKPiBrbWFsbG9jX2FycmF5KCkgYWxsb2NhdGlvbiBlcnJvcnMgYW5kIEtV bml0IGZhaWx1cmVzLgo+Cj4gVGhpcyBwYXRjaCBmaXhlcyB0aGUgaXNzdWUgYnk6Cj4gLSBBZGRp bmcgLnNlY3Rpb24gLnJvZGF0YSB0byBleHBsaWNpdGx5IHBsYWNlIGFycmF5cyBpbiB0aGUgcmVh ZC1vbmx5IGRhdGEgc2VnbWVudC4KPiAtIEFkZGluZyAuYWxpZ24gMyB0byBhbGlnbiBhcnJheXMg dG8gOCBieXRlcy4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 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B8C3A2F6560 for ; Wed, 26 Nov 2025 09:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764149045; cv=none; b=nVy6ayctw8m7et4MVRUAgvQNBoviyCme1+NktbzW5NxsD+gliXb7bpI1wlTFKzrKSGW3GnpFGoRN6IXFiogJaklGQpXtFy54BCe3auU53KLuFBk2YRsSw8587wkqI9UbkuE0AuYUX5bS/tXvpCxwHiHivNYJ4wbQdGV5svXZqAI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764149045; c=relaxed/simple; bh=7FqM5Wnnl94ag6oBJ+M9iRWwcQjsCvnH0zYX9MIORQ4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=bIQP1CMN43yWAVP+jnc58aEXJj5IbAWO4Fwq8Hhm+GUjDh4wtFTLuGOwI9hw4XknsJuN8YQlCLEpwdWamciNKTpF+oQysPNZJx/dCaBRVQPzj3i0C8XlYEAgXt6OQCJEGhr2MNFoN6RNgKFx7wAKQls6DITJXzixiQ4vLZmeyZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rfQ1HFBp; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4ivR1zZo; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rfQ1HFBp"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4ivR1zZo" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1764149040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7FqM5Wnnl94ag6oBJ+M9iRWwcQjsCvnH0zYX9MIORQ4=; b=rfQ1HFBpIxiilHt+KLt5NN4gD2z77WVeUtbZBGYvWOPZw92ny4Y2YgqSHbbWdE5R9+OM/h YVhadbJqtRrsluhHci9BZxNR4bLgYlzSIR9UpXYUxCTEL4fYeVWygi9sPcodFXI0RUBqGT 4UPcW/Bu0hvSfsf1JHUaobeuCRRGZT9YqNH+1hqo2v+eamUOrnaCjX83EHs0N9zeZ5RdpM rZ320K4UmFF9YS7Th2L1I3QbFeYT2omORhHa+Uh6RnJBj7TQ5zgwYOZI+kFGKSkrxgZ03+ ngF2UTjJLTf1gx5IJQAEOxSHB9dWZEd8FYzz18WQfa9WyjeDWQPh7i35fbk4hQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1764149040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7FqM5Wnnl94ag6oBJ+M9iRWwcQjsCvnH0zYX9MIORQ4=; b=4ivR1zZoMegPK/lIsjIvbmYCvwob9gmJbbA4PW9nvwTHOrYhNgjPt4DNAuI7JYzhVoOQ3U kr4Qzd1+tL1KkyBw== To: =?utf-8?B?6K645L2z5Yev?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti Subject: Re: [PATCH] riscv: fix KUnit test_kprobes crash when building with Clang In-Reply-To: <738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn> References: <738dd4e2.ff73.19a7cd7b4d5.Coremail.xujiakai2025@iscas.ac.cn> Date: Wed, 26 Nov 2025 10:23:59 +0100 Message-ID: <875xax5eq8.fsf@yellow.woof> 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 =E8=AE=B8=E4=BD=B3=E5=87=AF 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 dat= a 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=3Dy, 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