From nobody Sun Apr 5 13:09:10 2026 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 AA1F638F234 for ; Tue, 17 Mar 2026 08:40:44 +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=1773736846; cv=none; b=b8oLM0cDI0dL3KUM9o67xbl1OkzHnwGOlpYDlYde6YXrs7Ld9FEeficQ9ZCIXDpbl7Frk3BJk8eh/DFt29ehDf9zeOCFQV4OWpU0MSX/LmuMxSYUS86VNYpTCliYH5nUZDfSFM3y6z+KMTQsmbjhOTr769UkEG3J6urhCA6SigM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773736846; c=relaxed/simple; bh=5ZDPuKGpLnCYW6/n4FiLI5Qe6NCU73OKO+UJqG9XuSE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=s1+gEXx9DcQeZ83w+TCdE9fZfqJRYuKAhALZ3X/rH1JBqjymnn1er0HY61X/FxQvnyy/a6ndU4CmTryK5lgtK1F3RMfDYPX8dPuoFP81n85A1TXwtZRLQabW3nMASPVhUMCv+P8PGzDHEjEg5pb8pw6qUu0Tc9pVCphAYwS8CJM= 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=297SYdrb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=R6Pi8esC; 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="297SYdrb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="R6Pi8esC" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773736842; 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; bh=m6VjOkKecfE9AV5psRtJpImvn/qoRKlvV1X+i6dxDDY=; b=297SYdrb0XOGVieYESLXsrEEsuwS9wDLsxqXm0c/TjKyvfXI7cQ2L7Z8hIPUBOfwprhQMb lzvrfSCcGCW+6mRB/7HkZFNNyIL/v9ufvelAJe6xh4Sv8/JK3yfKFEW3RSnundkVJfojkm C6/XZ4diEcXgBBjZHSDGtcfGEduoI/uTHwE32pysOP/ooE/3DMJiaNSZzxG4IQxdepme5W YpIFY4MAoF9wMmgwSh7pOHH1fSH7cQNhIPkyiq32UVTyCIdMhH3jwbBLoyAOfHs7/+TNZ5 F28CsGhZkJO6oy8wSE8EZhIXsstxzZwUJcLvt/Xt4Wzq5hSnjHtgzFIjbJ14kw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773736842; 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; bh=m6VjOkKecfE9AV5psRtJpImvn/qoRKlvV1X+i6dxDDY=; b=R6Pi8esCuZ4+KTmY6IiksD90hR5qtOopAOViHMnNzynHMo63KSX/64iKTo6Wf5m/FfUDnh S9xKXwRtToj0vQDA== Date: Tue, 17 Mar 2026 09:40:36 +0100 Subject: [PATCH v2] tools/nolibc: MIPS: fix clobbers of 'lo' and 'hi' registers on different ISAs 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 Message-Id: <20260317-nolibc-mips-clobber-v2-1-5b9a97761a9e@linutronix.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/32NTQ6CMBBGr0Jm7Zhp419dcQ/DgpapTIItaZFgC He3cgCX7yXf+1bInIQz3KsVEs+SJYYC+lCB69vwZJSuMGjSF9LqhiEOYh2+ZMzohmgtJzwZw8b bzp6th7IcE3tZ9uqjKdxLnmL67Cez+tn/vVmhQn9VRKYlcobqQcJ7SjHIcuwYmm3bvgHj0Li6A AAA X-Change-ID: 20260218-nolibc-mips-clobber-499e9fbdb5bf To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Cc: linux-kernel@vger.kernel.org, "Maciej W. Rozycki" , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1773736837; l=2472; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=5ZDPuKGpLnCYW6/n4FiLI5Qe6NCU73OKO+UJqG9XuSE=; b=jxuiZGjKQjG4Ple6+0mt5yVVRHUtaxbIu0pGAfAC473zx/JEwBleYU0/wothJlvMR46BiJZQ5 u3e+xqYTerICcyevt4pCPxbMw6MnSvp4pTCFTBsiO5NyfBB8vukD9D8 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= All MIPS ISAs before r6 use the 'lo' and 'hi' special registers. These are clobbered by system calls and need to be marked as such to avoid miscompilations. Currently nolibc ties the clobbers to the ABI. But this is wrong and leads to ISA<->ABI combinations which are not handled correctly, leading to compiler errors or miscompilations. Handle all different combinations of ABI and ISA. Fixes: a6a2a8a42972 ("tools/nolibc: MIPS: add support for N64 and N32 ABIs") Fixes: 66b6f755ad45 ("rcutorture: Import a copy of nolibc") Suggested-by: Maciej W. Rozycki Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2603141744240.55200@angi= e.orcam.me.uk/ Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- Changes in v2: - Reword commit message. - Simplify the logic. - Link to v1: https://lore.kernel.org/r/20260218-nolibc-mips-clobber-v1-1-f= 71009a00c90@linutronix.de --- tools/include/nolibc/arch-mips.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-m= ips.h index a72506ceec6b..f8fcd58658d5 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -39,11 +39,19 @@ * - stack is 16-byte aligned */ =20 +#if __mips_isa_rev < 6 +#define _NOLIBC_SYSCALL_CLOBBER_HI_LO "hi", "lo" +#else +#define _NOLIBC_SYSCALL_CLOBBER_HI_LO "$0" +#endif + #if defined(_ABIO32) =20 #define _NOLIBC_SYSCALL_CLOBBERLIST \ - "memory", "cc", "at", "v1", "hi", "lo", \ - "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9" + "memory", "cc", "at", "v1", \ + "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", \ + _NOLIBC_SYSCALL_CLOBBER_HI_LO + #define _NOLIBC_SYSCALL_STACK_RESERVE "addiu $sp, $sp, -32\n" #define _NOLIBC_SYSCALL_STACK_UNRESERVE "addiu $sp, $sp, 32\n" =20 @@ -52,7 +60,8 @@ /* binutils, GCC and clang disagree about register aliases, use numbers in= stead. */ #define _NOLIBC_SYSCALL_CLOBBERLIST \ "memory", "cc", "at", "v1", \ - "10", "11", "12", "13", "14", "15", "24", "25" + "10", "11", "12", "13", "14", "15", "24", "25", \ + _NOLIBC_SYSCALL_CLOBBER_HI_LO =20 #define _NOLIBC_SYSCALL_STACK_RESERVE #define _NOLIBC_SYSCALL_STACK_UNRESERVE --- base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f change-id: 20260218-nolibc-mips-clobber-499e9fbdb5bf Best regards, --=20 Thomas Wei=C3=9Fschuh