From nobody Sat Sep 26 20:31:24 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 F10E03B4E9B; Mon, 31 Aug 2026 04:32:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788150749; cv=none; b=dltjnDBMcMO+svt0PjmktBYqfuccNQG3RVaKoqi4hBKxSVmLMTYZgYZb5amaJjiQDqW3AIEpSPEh8JP0nF/LjEmsfkezcFQ1rkze6HKmPe3hd1xwxjjO+HO8XSVnYeBtXFxVWJsSJgY1s8uR8bwJpw/WYRZh0nlBnUGq+Oyl7fQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788150749; c=relaxed/simple; bh=oizJKRTqyDh/VbZUTBgNcKUXsdPManz6vBIVNJXSxME=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=cQ7SIEc3DFXozPaT6eW0ntzL20EDNoJlxeuySggsO472QlkIl3jqrLxlh59QsuuvdnQzO3CL9gvvZ3ZoIyVAc4cFUZBONN0uynToonJGHGIz7Tk5CDdxmORd+LZEylcDqDkMH/EybaBKK+t+eyPX45JIYX0SKn+HZYo2BjDtWws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=EtXQrxcE; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="EtXQrxcE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1788150737; bh=oizJKRTqyDh/VbZUTBgNcKUXsdPManz6vBIVNJXSxME=; h=From:Date:Subject:To:Cc:From; b=EtXQrxcE6F4N0n/2vipf/0Fpgfoc83jnzsCBcYj7UdA61sPh7r28mWIuddVqWMLQa +b0VsXskkZYS9bmrYy7BfNHCAiJMpvbKJ+x1qbYXOvV5dIv1HDQmCIcwzGiFN1dqil ntY56RcpdkTZdo46QrFaDf6h9FtsnvX9aKp31M00= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 31 Aug 2026 06:32:13 +0200 Subject: [PATCH v2] tools/nolibc: add 64-bit parisc support 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: <20260831-nolibc-parisc64-v2-1-022f9beff7a6@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/2WOQQ6CMBBFr0K6tqZUpOjKexgWbR3sGFOwU1BDu LsFTFy4fJP//5uREQQEYsdsZAEGJGx9ArnJmHXaX4HjJTGTQpaiEIr79o7G8k4HJFsWfGe12Bf KSt0cWGp1ARp8LYvnemXqzQ1snGe+iQCPPqniL+aQYhveyx9DPl9XZSXFn3LIec5FqcCAshU05 vQEJCLrerf1EFk9TdMH7ocm+NoAAAA= X-Change-ID: 20260407-nolibc-parisc64-3ca0547c2af9 To: Willy Tarreau , Shuah Khan , "James E.J. Bottomley" , Helge Deller Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-parisc@vger.kernel.org, David Laight , Rolf Eike Beer , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788150738; l=7161; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=oizJKRTqyDh/VbZUTBgNcKUXsdPManz6vBIVNJXSxME=; b=OcFARBw3I+rBUtDzAIwbI3xthnUKWY+y3RppF3LtyOrAgnuD42ZlqjFqs7fslXQWu5d+w7kYg f5HgRZ10gdPC6pCzFF7Gh5viGIIsahv4oas6cO2OoQDTzRseVoIheRo X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Extend the existing parisc support to also handle 64-bit mode. Some peculiarities: * The nonstandard ftruncate64 system call requires a workaround. * The linker defaults to main() as entry point, which needs to be switched to _start() explicitly. * The linker defaults to dynamic linking, which needs to be disabled explicitly. * With the default -Os, gcc does not use 64-bit multiplication instructions, requiring libgcc. Use -O2 instead. * There is no qemu-user available. * CONFIG_COMPAT needs to be disabled to avoid build errors due to a missing 32-bit vDSO compiler. Signed-off-by: Thomas Wei=C3=9Fschuh --- Changes in v2: - Rebase on latest nolibc/for-next. - Fix typo in comment. - Reorder conditions in run-tests.sh. - Fix llvm=3D1 check in run-tests.sh. - Link to v1: https://patch.msgid.link/20260820-nolibc-parisc64-v1-1-067ebe= 7c8efb@weissschuh.net --- tools/include/nolibc/arch-parisc.h | 26 ++++++++++++++++++++++= +--- tools/include/nolibc/stdlib.h | 2 +- tools/testing/selftests/nolibc/Makefile.nolibc | 5 +++++ tools/testing/selftests/nolibc/run-tests.sh | 10 +++++++--- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/tools/include/nolibc/arch-parisc.h b/tools/include/nolibc/arch= -parisc.h index 417043ecbc53..5c595ef88a62 100644 --- a/tools/include/nolibc/arch-parisc.h +++ b/tools/include/nolibc/arch-parisc.h @@ -7,9 +7,7 @@ #ifndef _NOLIBC_ARCH_PARISC_H #define _NOLIBC_ARCH_PARISC_H =20 -#if defined(__LP64__) -#error 64-bit not supported -#endif +#include =20 #include "compiler.h" #include "crt.h" @@ -167,9 +165,15 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __nolibc_no_stack= _protector _start(void) { __asm__ volatile ( +#ifdef __LP64__ + ".import __gp\n" /* Set up the dp register */ + "ldil L%__gp, %dp\n" + "ldo R%__gp(%r27), %dp\n" +#else ".import $global$\n" /* Set up the dp register */ "ldil L%$global$, %dp\n" "ldo R%$global$(%r27), %dp\n" +#endif =20 "b _start_c\n" /* Call _start_c, the load below is execu= ted first */ =20 @@ -182,4 +186,20 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoi= nt __nolibc_no_stack_prote } #endif /* NOLIBC_NO_RUNTIME */ =20 +#ifdef __LP64__ +/* + * This override is normally only meant for 32-bit architectures. + * But parisc 64-bit has __NR_ftruncate64, so this path is taken. + * Add an unused second argument to satisfy the calling convention. + */ +static __attribute__((unused)) +int _sys_ftruncate64(int fd, uint64_t length, uint64_t unused) +{ + (void)unused; + + return __nolibc_syscall2(__NR_ftruncate64, fd, length); +} +#define _sys_ftruncate64 _sys_ftruncate64 +#endif + #endif /* _NOLIBC_ARCH_PARISC_H */ diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 1816c2368b68..6c3c620a04cf 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -230,7 +230,7 @@ int _nolibc_u64toa_base(uint64_t in, char *buffer, unsi= gned int base, uint64_t r =20 /* Generate least significant digit first */ do { -#if defined(__SIZEOF_INT128__) && !defined(__mips__) && !defined(__sparc__) +#if defined(__SIZEOF_INT128__) && !defined(__mips__) && !defined(__sparc__= ) && !defined(__hppa__) q =3D ((unsigned __int128)in * recip) >> 64; #else uint64_t p =3D (uint32_t)in * (recip >> 32); diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing= /selftests/nolibc/Makefile.nolibc index d8b71cbfc173..3ca473ec35ef 100644 --- a/tools/testing/selftests/nolibc/Makefile.nolibc +++ b/tools/testing/selftests/nolibc/Makefile.nolibc @@ -65,6 +65,7 @@ ARCH_sparc32 =3D sparc ARCH_sparc64 =3D sparc ARCH_sh4 =3D sh ARCH_parisc32 =3D parisc +ARCH_parisc64 =3D parisc64 ARCH :=3D $(or $(ARCH_$(XARCH)),$(XARCH)) =20 # kernel image names by architecture @@ -113,6 +114,7 @@ EXTRACONFIG_sparc32 =3D -e CONFIG_TMPFS EXTRACONFIG_m68k =3D -e CONFIG_BLK_DEV_INITRD EXTRACONFIG_sh4 =3D -e CONFIG_BLK_DEV_INITRD -e CONFIG_CMDLINE_FROM_= BOOTLOADER EXTRACONFIG_alpha =3D -e CONFIG_BLK_DEV_INITRD +EXTRACONFIG_parisc64 =3D -d CONFIG_COMPAT EXTRACONFIG =3D $(EXTRACONFIG_$(XARCH)) =20 # optional tests to run (default =3D all) @@ -134,6 +136,7 @@ QEMU_ARCH_loongarch =3D loongarch64 QEMU_ARCH_sparc32 =3D sparc QEMU_ARCH_openrisc =3D or1k QEMU_ARCH_parisc32 =3D hppa +QEMU_ARCH_parisc64 =3D hppa QEMU_ARCH =3D $(or $(QEMU_ARCH_$(XARCH)),$(XARCH)) =20 QEMU_ARCH_USER_ppc64le =3D ppc64le @@ -175,6 +178,7 @@ QEMU_ARGS_m68k =3D -M virt -append "console=3Dtty= GF0,115200 panic=3D-1 $(TEST:%=3D QEMU_ARGS_sh4 =3D -M r2d -serial file:/dev/stdout -append "console= =3DttySC1,115200 panic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" QEMU_ARGS_openrisc =3D -M virt -m 512M -append "console=3DttyS0 panic=3D= -1 $(TEST:%=3DNOLIBC_TEST=3D%)" QEMU_ARGS_parisc32 =3D -M B160L -append "console=3DttyS0 panic=3D-1 $(TE= ST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_parisc64 =3D -M C3700 -append "console=3DttyS0 panic=3D-1 $(TE= ST:%=3DNOLIBC_TEST=3D%)" QEMU_ARGS_alpha =3D -M clipper -append "console=3DttyS0 panic=3D-1 $(= TEST:%=3DNOLIBC_TEST=3D%)" QEMU_ARGS =3D -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(Q= EMU_ARGS_EXTRA) =20 @@ -193,6 +197,7 @@ CFLAGS_x32 =3D -mx32 CFLAGS_arm =3D -marm CFLAGS_armthumb =3D -mthumb -march=3Darmv6t2 CFLAGS_parisc32 =3D -mfast-indirect-calls +CFLAGS_parisc64 =3D -Wl,--no-dynamic-linker -Wl,--entry=3D_start -O2 CFLAGS_ppc =3D -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64 =3D -m64 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64le =3D -m64 -mlittle-endian -mno-vsx $(call cc-option,-mabi=3D= elfv2) diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/se= lftests/nolibc/run-tests.sh index af2a6f510d1d..2844fed26df1 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -29,7 +29,7 @@ all_archs=3D( sparc32 sparc64 m68k sh4 - parisc32 + parisc32 parisc64 alpha hexagon ) @@ -122,6 +122,7 @@ crosstool_arch() { sparc*) echo sparc64;; x32*) echo x86_64;; parisc32) echo hppa;; + parisc64) echo hppa64;; *) echo "$1";; esac } @@ -206,11 +207,14 @@ test_arch() { exit 1 esac printf '%-15s' "$arch:" - if [ "$llvm" =3D "1" ] && [ "$arch" =3D "m68k" -o "$arch" =3D "sh4" -o "$= arch" =3D "openrisc" -o "$arch" =3D "parisc32" -o "$arch" =3D "alpha" ]; th= en + if [ "$llvm" =3D "1" ] && \ + [ "$arch" =3D "m68k" -o "$arch" =3D "sh4" -o "$arch" =3D "openrisc" \ + -o "$arch" =3D=3D "parisc32" -o "$arch" =3D=3D "parisc64" -o "$arch"= =3D "alpha" \ + ]; then echo "Unsupported configuration" return fi - if [ "$test_mode" =3D "user" ] && [ "$arch" =3D "x32" ]; then + if [ "$test_mode" =3D "user" ] && [ "$arch" =3D "x32" -o "$arch" =3D "par= isc64" ]; then echo "Unsupported configuration" return fi --- base-commit: 9c47af906bc655c8f45aaf1f156656239c2c5073 change-id: 20260407-nolibc-parisc64-3ca0547c2af9 Best regards, -- =20 Thomas Wei=C3=9Fschuh