From mboxrd@z Thu Jan 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