From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66F69C76195 for ; Tue, 21 Mar 2023 01:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230323AbjCUBNW (ORCPT ); Mon, 20 Mar 2023 21:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbjCUBNR (ORCPT ); Mon, 20 Mar 2023 21:13:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C7849E3 for ; Mon, 20 Mar 2023 18:12:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1787618F5 for ; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A788C433EF; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=ODNl9OOZ7GRaMqnxRe71E34bayxsvyWE18W1XmyJcUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCpVW8xXtAjiy+lHjQ8vuRPOTZ6Yswb3wmiJ6C1gOxD4PPs80PDCRTfEjwJ7js0Fx YlJ7JABUz9owixjvDI1eym+GF2gY/WYQ1VIwnCV/j6YwfG/T1LzwsNWEwup4LMn17d ahpVCvWGsRuQpJsP8Go6DW81OsM+fcJm+lh2orRphAb/ylMtiZWexMO3iON4J8ffjI zMVGVNPfNz9g7zFgYw/AZ8znVaGfNSj8AbX9L+5lMrxiMG7tF/A7AtE6sDKqK/UQnY jHklFRT7jj9ePANeT0WFgv+tdHbSd1BrpERZNt0M7KVZcD6tqQR18KGgVqJvIRAdyk ZMnFfZR4RqYwQ== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id D1C8B1540395; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 01/14] tools/nolibc: always disable stack protector for tests Date: Mon, 20 Mar 2023 18:11:24 -0700 Message-Id: <20230321011137.51837-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Wei=C3=9Fschuh Stack protectors need support from libc. This support is not provided by nolibc which leads to compiler errors when stack protectors are enabled by default in a compiler: CC nolibc-test /usr/bin/ld: /tmp/ccqbHEPk.o: in function `stat': nolibc-test.c:(.text+0x1d1): undefined reference to `__stack_chk_fail' /usr/bin/ld: /tmp/ccqbHEPk.o: in function `poll.constprop.0': nolibc-test.c:(.text+0x37b): undefined reference to `__stack_chk_fail' /usr/bin/ld: /tmp/ccqbHEPk.o: in function `vfprintf.constprop.0': nolibc-test.c:(.text+0x712): undefined reference to `__stack_chk_fail' /usr/bin/ld: /tmp/ccqbHEPk.o: in function `pad_spc.constprop.0': nolibc-test.c:(.text+0x80d): undefined reference to `__stack_chk_fail' /usr/bin/ld: /tmp/ccqbHEPk.o: in function `printf': nolibc-test.c:(.text+0x8c4): undefined reference to `__stack_chk_fail' /usr/bin/ld: /tmp/ccqbHEPk.o:nolibc-test.c:(.text+0x12d4): more undefin= ed references to `__stack_chk_fail' follow collect2: error: ld returned 1 exit status Signed-off-by: Thomas Wei=C3=9Fschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 8fe61d3e3cce..874d141da8c4 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for nolibc tests include ../../../scripts/Makefile.include +# We need this for the "cc-option" macro. +include ../../../build/Build.include =20 # we're in ".../tools/testing/selftests/nolibc" ifeq ($(srctree),) @@ -72,6 +74,7 @@ endif =20 CFLAGS_s390 =3D -m64 CFLAGS ?=3D -Os -fno-ident -fno-asynchronous-unwind-tables $(CFLAGS_$(ARC= H)) +CFLAGS +=3D $(call cc-option,-fno-stack-protector) LDFLAGS :=3D -s =20 help: --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5997C76195 for ; Tue, 21 Mar 2023 01:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbjCUBZF (ORCPT ); Mon, 20 Mar 2023 21:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbjCUBZC (ORCPT ); Mon, 20 Mar 2023 21:25:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 247291A97C for ; Mon, 20 Mar 2023 18:24:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8F64DB81193 for ; Tue, 21 Mar 2023 01:11:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36366C433D2; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=lUIoRgu7u8AVYczSe4iE5SbypLoTY7zfMu5B7qh6z9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E93DxFEBEbwJNzCqr0N2ssfljAmbsiRWfeg7u79DiIqpyO90jiIaP39qwQZPWgpo3 B3EMyY73nB+Khhlwvg4365YWqxwjKjdM0IHdRWSXfTPkBsUldzAAUiPoFP+Y03C9KO FP0g/CSET+5MTef5j+cxbabkuzoBk0602qaH4V5HBGNZRlx9TMvAv4ngHuZ9BT2BUY dm3SKoHNdyUTBbwINx2L0xGODQxunNKNHBL0gqJuHKml6Y4gbiqN1h+DllqgfcSzeS g6y2jA03blQUCpAidNzQHzuG2qslaoCwY/D+YKgwAHY0/0LwvP2abyUeM9cJPl9m5b NeOjb7HAyv4GQ== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id D6E7A154039A; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, "Paul E. McKenney" , Willy Tarreau , Ammar Faizi , Sven Schnelle Subject: [PATCH nolibc 02/14] tools/nolibc: Add gitignore to avoid git complaints about sysroot Date: Mon, 20 Mar 2023 18:11:25 -0700 Message-Id: <20230321011137.51837-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Testing of nolibc can produce a tools/include/nolibc/sysroot file, which is not known to git. Because it is automatically generated, there is no reason for it to be known to git. Therefore, add a .gitignore to remove it from git's field of view. Signed-off-by: Paul E. McKenney Cc: Willy Tarreau Cc: Ammar Faizi Cc: Sven Schnelle --- tools/include/nolibc/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/include/nolibc/.gitignore diff --git a/tools/include/nolibc/.gitignore b/tools/include/nolibc/.gitign= ore new file mode 100644 index 000000000000..dea22eaaed2b --- /dev/null +++ b/tools/include/nolibc/.gitignore @@ -0,0 +1 @@ +sysroot --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E580C6FD1D for ; Tue, 21 Mar 2023 01:27:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229939AbjCUB1f (ORCPT ); Mon, 20 Mar 2023 21:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbjCUB1d (ORCPT ); Mon, 20 Mar 2023 21:27:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F61A10F1 for ; Mon, 20 Mar 2023 18:27:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DED9D618FA for ; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47C98C4339B; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=XGdz+sHye8/feWnNVQxyzEvBR9Xb7ks24e30cvZCpAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujOcALg/qWjsikMv5fDyavRGNNjO00WeYB0/NIyne1+Z1+aN+1ifgOUHPFQ370zKk iHEv/zoXP8b3Y+vRAeBgq1s7ARhjIQtUW6hRpUOdpChNAHS/aQL8zwMg8WjMn33HPC S2rybzeTsb6s0pVSywN7F/ZxBgfdMVDAOlpqSuK0y5+JYNHg/Ni125mp/t18FSR+HF uQJqhZF95slY7ze9lrXBa0xwvavrn53IF8crfxW6ubTW0vnmIPSJ6CNsO0eoQaEkbh gGphvHv7f7n+86Ynql++fEK1sneHQSsRULKPA+R62C3bE2HKOZB2CrxrtQPo8PakiG mw8U4oKovfk0w== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id DA983154039B; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Vincent Dagonneau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 03/14] tools/nolibc: add stdint.h Date: Mon, 20 Mar 2023 18:11:26 -0700 Message-Id: <20230321011137.51837-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Dagonneau Nolibc works fine for small and limited program however most program expect integer types to be defined in stdint.h rather than std.h. This is a quick fix that moves the existing integer definitions in std.h to stdint.h. Signed-off-by: Vincent Dagonneau Reviewed-by: Thomas Wei=C3=9Fschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/Makefile | 4 ++-- tools/include/nolibc/std.h | 15 +-------------- tools/include/nolibc/stdint.h | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 tools/include/nolibc/stdint.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index cfd06764b5ae..ec57d3932506 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -25,8 +25,8 @@ endif =20 nolibc_arch :=3D $(patsubst arm64,aarch64,$(ARCH)) arch_file :=3D arch-$(nolibc_arch).h -all_files :=3D ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h st= ring.h \ - sys.h time.h types.h unistd.h +all_files :=3D ctype.h errno.h nolibc.h signal.h std.h stdint.h stdio.h st= dlib.h \ + string.h sys.h time.h types.h unistd.h =20 # install all headers needed to support a bare-metal compiler all: headers diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 1747ae125392..933bc0be7e1c 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -18,20 +18,7 @@ #define NULL ((void *)0) #endif =20 -/* stdint types */ -typedef unsigned char uint8_t; -typedef signed char int8_t; -typedef unsigned short uint16_t; -typedef signed short int16_t; -typedef unsigned int uint32_t; -typedef signed int int32_t; -typedef unsigned long long uint64_t; -typedef signed long long int64_t; -typedef unsigned long size_t; -typedef signed long ssize_t; -typedef unsigned long uintptr_t; -typedef signed long intptr_t; -typedef signed long ptrdiff_t; +#include "stdint.h" =20 /* those are commonly provided by sys/types.h */ typedef unsigned int dev_t; diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h new file mode 100644 index 000000000000..4ba264031df9 --- /dev/null +++ b/tools/include/nolibc/stdint.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Standard definitions and types for NOLIBC + * Copyright (C) 2023 Vincent Dagonneau + */ + +#ifndef _NOLIBC_STDINT_H +#define _NOLIBC_STDINT_H + +typedef unsigned char uint8_t; +typedef signed char int8_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned int uint32_t; +typedef signed int int32_t; +typedef unsigned long long uint64_t; +typedef signed long long int64_t; +typedef unsigned long size_t; +typedef signed long ssize_t; +typedef unsigned long uintptr_t; +typedef signed long intptr_t; +typedef signed long ptrdiff_t; + +#endif /* _NOLIBC_STDINT_H */ --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 012A4C6FD1C for ; Tue, 21 Mar 2023 01:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229473AbjCUBXR (ORCPT ); Mon, 20 Mar 2023 21:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbjCUBXN (ORCPT ); Mon, 20 Mar 2023 21:23:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19B7B19C52 for ; Mon, 20 Mar 2023 18:22:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC88D618FE for ; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A8A0C4339C; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=xmxCrxSFeJnV6Vi+d9+/0Z1rnOxtf2t94FrsrC3fsdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nSQPTzD0cZEcfhHAvEiQdzRB6JofW7+4FLVzBb9BHhMNbqKOe/XB94DVmgvzdy9cR w97p4f4Wfn7q7Kb6TUS3+M/29W+xA3pTjzKkpMxPJu3lwnN8BtXuZVsyrhRrOLy1w6 dGU4h2vdPPvHeURDx4YKyxCJsfacQcukH/nXofU/0RG1oEIK417U8fL/vl+tHDFvN6 cshDMZCt9MisYOrwyEu7bL35l6cUr8L1N5wIJtuvOYL3dMPDzijpFUc/VX+2J6VJpc j0MDsol8zTdvPOcNgodNHSoJow3SMH5ZOJUtGggyHRWp3KNZCHlkZ7ZU/S1pG3FNbJ XZFq7hyP6OPVA== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id DE9A9154039C; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Vincent Dagonneau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 04/14] tools/nolibc: add integer types and integer limit macros Date: Mon, 20 Mar 2023 18:11:27 -0700 Message-Id: <20230321011137.51837-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Dagonneau This commit adds some of the missing integer types to stdint.h and adds limit macros (e.g. INTN_{MIN,MAX}). The reference used for adding these types is https://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html. We rely on the compiler-defined __LONG_MAX__ to get the right limits for size_t, intptr_t, uintptr_t and ptrdiff_t. This compiler constant seem to have been defined at least since GCC 4.1.2 and clang 3.0.0 on x86_64. It is also defined on ARM (32&64), mips and RISC-V. Note that the maximum size of size_t is implementation-defined (>65535), in this case I chose to go with unsigned long on all platforms since unsigned long =3D=3D unsigned int on all the platforms we care about. Note that the kernel uses either unsigned int or unsigned long in linux/include/uapi/asm-generic/posix_types.h. These should be equivalent for the plaforms we are targeting. Also note that the 'fast*' flavor of the types have been chosen to be always 1 byte for '*fast8*' and always long (a.k.a. intptr_t/uintptr_t) for the other variants. I have never seen the 'fast*' types in use in the wild but that seems to be what glibc does. Signed-off-by: Vincent Dagonneau Reviewed-by: Thomas Wei=C3=9Fschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/stdint.h | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h index 4ba264031df9..c1ce4f5e0603 100644 --- a/tools/include/nolibc/stdint.h +++ b/tools/include/nolibc/stdint.h @@ -21,4 +21,79 @@ typedef unsigned long uintptr_t; typedef signed long intptr_t; typedef signed long ptrdiff_t; =20 +typedef int8_t int_least8_t; +typedef uint8_t uint_least8_t; +typedef int16_t int_least16_t; +typedef uint16_t uint_least16_t; +typedef int32_t int_least32_t; +typedef uint32_t uint_least32_t; +typedef int64_t int_least64_t; +typedef uint64_t uint_least64_t; + +typedef int8_t int_fast8_t; +typedef uint8_t uint_fast8_t; +typedef ssize_t int_fast16_t; +typedef size_t uint_fast16_t; +typedef ssize_t int_fast32_t; +typedef size_t uint_fast32_t; +typedef ssize_t int_fast64_t; +typedef size_t uint_fast64_t; + +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + +/* limits of integral types */ + +#define INT8_MIN (-128) +#define INT16_MIN (-32767-1) +#define INT32_MIN (-2147483647-1) +#define INT64_MIN (-9223372036854775807LL-1) + +#define INT8_MAX (127) +#define INT16_MAX (32767) +#define INT32_MAX (2147483647) +#define INT64_MAX (9223372036854775807LL) + +#define UINT8_MAX (255) +#define UINT16_MAX (65535) +#define UINT32_MAX (4294967295U) +#define UINT64_MAX (18446744073709551615ULL) + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MAX INT64_MAX + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +#define SIZE_MAX ((size_t)(__LONG_MAX__) * 2 + 1) +#define INTPTR_MIN (-__LONG_MAX__ - 1) +#define INTPTR_MAX __LONG_MAX__ +#define PTRDIFF_MIN INTPTR_MIN +#define PTRDIFF_MAX INTPTR_MAX +#define UINTPTR_MAX SIZE_MAX + +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST16_MIN INTPTR_MIN +#define INT_FAST32_MIN INTPTR_MIN +#define INT_FAST64_MIN INTPTR_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MAX INTPTR_MAX +#define INT_FAST32_MAX INTPTR_MAX +#define INT_FAST64_MAX INTPTR_MAX + +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX SIZE_MAX +#define UINT_FAST32_MAX SIZE_MAX +#define UINT_FAST64_MAX SIZE_MAX + #endif /* _NOLIBC_STDINT_H */ --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64BB6C6FD1D for ; Tue, 21 Mar 2023 01:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230494AbjCUBOA (ORCPT ); Mon, 20 Mar 2023 21:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbjCUBNp (ORCPT ); Mon, 20 Mar 2023 21:13:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81E1AC16E for ; Mon, 20 Mar 2023 18:13:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 06535618FB for ; Tue, 21 Mar 2023 01:11:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64C0FC433A0; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=3esUPPj3SC/R9/XnsmVoNoexBtUzL/3RokgXql8P5bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ObyQDCwd9sD1wMFwwmEPq990/5gdfr7iZdSdol/KkHd9hmhBoit2p9ancVvbGMLD1 MOARP/5M0rKmkJxxDJLFZeZevbhCMyn9NB8tetSJa6ELUiy8COGcsmwrYYJlx56p31 islm7ekngx144HpLWV8z5KI2QGEei12BHZpC2ljKO8SV82aurbAKa29pZQE4zphhtk VJVTqbqXfiZRxfn3bx+4vF6YGc9D22TB/Xjt+dr8mqEYYSlhZ8MRUc5WVr/AB19A/e 1wN43R/YRgGmhV8fYKMaonOy8MQ1TJEBOPKIe2acGkP6LDcE2otRPj/NvxuD8RY3oH pPaEielfwg12w== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id E276D154039D; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Vincent Dagonneau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 05/14] tools/nolibc: enlarge column width of tests Date: Mon, 20 Mar 2023 18:11:28 -0700 Message-Id: <20230321011137.51837-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Dagonneau This commit enlarges the column width from 40 to 64 characters to make room for longer tests Signed-off-by: Vincent Dagonneau Reviewed-by: Thomas Wei=C3=9Fschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 96 ++++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index c4a0c915139c..882140508d56 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -130,111 +130,111 @@ static int pad_spc(int llen, int cnt, const char *f= mt, ...) */ =20 #define EXPECT_ZR(cond, expr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_zr= (expr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_zr= (expr, llen); } while (0) =20 static int expect_zr(int expr, int llen) { int ret =3D !(expr =3D=3D 0); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_NZ(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_nz= (expr, llen; } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_nz= (expr, llen; } while (0) =20 static int expect_nz(int expr, int llen) { int ret =3D !(expr !=3D 0); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_EQ(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_eq= (expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_eq= (expr, llen, val); } while (0) =20 -static int expect_eq(int expr, int llen, int val) +static int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret =3D !(expr =3D=3D val); =20 - llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + llen +=3D printf(" =3D %lld ", expr); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_NE(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_ne= (expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_ne= (expr, llen, val); } while (0) =20 static int expect_ne(int expr, int llen, int val) { int ret =3D !(expr !=3D val); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_GE(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_ge= (expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_ge= (expr, llen, val); } while (0) =20 static int expect_ge(int expr, int llen, int val) { int ret =3D !(expr >=3D val); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_GT(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_gt= (expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_gt= (expr, llen, val); } while (0) =20 static int expect_gt(int expr, int llen, int val) { int ret =3D !(expr > val); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_LE(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_le= (expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_le= (expr, llen, val); } while (0) =20 static int expect_le(int expr, int llen, int val) { int ret =3D !(expr <=3D val); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_LT(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_lt= (expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_lt= (expr, llen, val); } while (0) =20 static int expect_lt(int expr, int llen, int val) { int ret =3D !(expr < val); =20 llen +=3D printf(" =3D %d ", expr); - pad_spc(llen, 40, ret ? "[FAIL]\n" : " [OK]\n"); + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } =20 =20 #define EXPECT_SYSZR(cond, expr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= szr(expr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_sy= szr(expr, llen); } while (0) =20 static int expect_syszr(int expr, int llen) { @@ -243,17 +243,17 @@ static int expect_syszr(int expr, int llen) if (expr) { ret =3D 1; llen +=3D printf(" =3D %d %s ", expr, errorname(errno)); - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { llen +=3D printf(" =3D %d ", expr); - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_SYSEQ(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= seq(expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_sy= seq(expr, llen, val); } while (0) =20 static int expect_syseq(int expr, int llen, int val) { @@ -262,17 +262,17 @@ static int expect_syseq(int expr, int llen, int val) if (expr !=3D val) { ret =3D 1; llen +=3D printf(" =3D %d %s ", expr, errorname(errno)); - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { llen +=3D printf(" =3D %d ", expr); - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_SYSNE(cond, expr, val) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= sne(expr, llen, val); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_sy= sne(expr, llen, val); } while (0) =20 static int expect_sysne(int expr, int llen, int val) { @@ -281,17 +281,17 @@ static int expect_sysne(int expr, int llen, int val) if (expr =3D=3D val) { ret =3D 1; llen +=3D printf(" =3D %d %s ", expr, errorname(errno)); - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { llen +=3D printf(" =3D %d ", expr); - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_SYSER(cond, expr, expret, experr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_sy= serr(expr, expret, experr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_sy= serr(expr, expret, experr, llen); } while (0) =20 static int expect_syserr(int expr, int expret, int experr, int llen) { @@ -302,16 +302,16 @@ static int expect_syserr(int expr, int expret, int ex= perr, int llen) if (expr !=3D expret || _errno !=3D experr) { ret =3D 1; llen +=3D printf(" !=3D (%d %s) ", expret, errorname(experr)); - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_PTRZR(cond, expr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_pt= rzr(expr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_pt= rzr(expr, llen); } while (0) =20 static int expect_ptrzr(const void *expr, int llen) { @@ -320,16 +320,16 @@ static int expect_ptrzr(const void *expr, int llen) llen +=3D printf(" =3D <%p> ", expr); if (expr) { ret =3D 1; - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_PTRNZ(cond, expr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_pt= rnz(expr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_pt= rnz(expr, llen); } while (0) =20 static int expect_ptrnz(const void *expr, int llen) { @@ -338,16 +338,16 @@ static int expect_ptrnz(const void *expr, int llen) llen +=3D printf(" =3D <%p> ", expr); if (!expr) { ret =3D 1; - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_STRZR(cond, expr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= rzr(expr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_st= rzr(expr, llen); } while (0) =20 static int expect_strzr(const char *expr, int llen) { @@ -356,16 +356,16 @@ static int expect_strzr(const char *expr, int llen) llen +=3D printf(" =3D <%s> ", expr); if (expr) { ret =3D 1; - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_STRNZ(cond, expr) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= rnz(expr, llen); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_st= rnz(expr, llen); } while (0) =20 static int expect_strnz(const char *expr, int llen) { @@ -374,16 +374,16 @@ static int expect_strnz(const char *expr, int llen) llen +=3D printf(" =3D <%s> ", expr); if (!expr) { ret =3D 1; - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_STREQ(cond, expr, cmp) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= req(expr, llen, cmp); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_st= req(expr, llen, cmp); } while (0) =20 static int expect_streq(const char *expr, int llen, const char *cmp) { @@ -392,16 +392,16 @@ static int expect_streq(const char *expr, int llen, c= onst char *cmp) llen +=3D printf(" =3D <%s> ", expr); if (strcmp(expr, cmp) !=3D 0) { ret =3D 1; - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } =20 =20 #define EXPECT_STRNE(cond, expr, cmp) \ - do { if (!cond) pad_spc(llen, 40, "[SKIPPED]\n"); else ret +=3D expect_st= rne(expr, llen, cmp); } while (0) + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret +=3D expect_st= rne(expr, llen, cmp); } while (0) =20 static int expect_strne(const char *expr, int llen, const char *cmp) { @@ -410,9 +410,9 @@ static int expect_strne(const char *expr, int llen, con= st char *cmp) llen +=3D printf(" =3D <%s> ", expr); if (strcmp(expr, cmp) =3D=3D 0) { ret =3D 1; - llen +=3D pad_spc(llen, 40, "[FAIL]\n"); + llen +=3D pad_spc(llen, 64, "[FAIL]\n"); } else { - llen +=3D pad_spc(llen, 40, " [OK]\n"); + llen +=3D pad_spc(llen, 64, " [OK]\n"); } return ret; } --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51177C76195 for ; Tue, 21 Mar 2023 01:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbjCUBP2 (ORCPT ); Mon, 20 Mar 2023 21:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbjCUBPW (ORCPT ); Mon, 20 Mar 2023 21:15:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D991168B0 for ; Mon, 20 Mar 2023 18:14:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6D24E61909 for ; Tue, 21 Mar 2023 01:11:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91244C433A7; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=MvoE3j0/B5YfmH7lXwF096efn6M6Cl/YT8i4+BMOerc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1sENs/XU5K5PoInjpwUdvGnbccJP1SJxh2ljIvc9WaIzL/TwtycyCHM+u0Sz3Ta2 v8ob9PeBMXAkzafmCPp/GomAdjTS6tN3XIyIvvIGakuLrIN3pLSI1rTJy1hO0WBe4k Krj4ukpu3WfPj1UhhiXnaswLWxQyj2OyVjtVYNClDEGGkUPBJibL+MJ8NA3iK0WqbG rT2M0YhuD0lzyLSCEh536QVKueHPr2tE7QRSj7NDvfKmKPNiH5z8SJv7OHtEivveRy f+A2U4hVvvoWEDLx4FC/7spQz03Ih6oTv/R4U0K2nhFLXl08ik3lopmB0gvjS/AUMz 2UBu2ejAQFtUA== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id E5F56154039E; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Vincent Dagonneau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 06/14] tools/nolibc: add tests for the integer limits in stdint.h Date: Mon, 20 Mar 2023 18:11:29 -0700 Message-Id: <20230321011137.51837-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Dagonneau This commit adds tests for the limits added in a previous commit. The limits are defined in decimal in stdint.h and as hexadecimal in the tests (e.g. 0x7f =3D 127 or 0x80 =3D -128). Hopefully it catches some of the most egregious mistakes. As we rely on the compiler to provide __SIZEOF_LONG__, we also test whether it is defined. Signed-off-by: Vincent Dagonneau Reviewed-by: Thomas Wei=C3=9Fschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 882140508d56..772f88bda0f1 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -602,6 +602,59 @@ int run_stdlib(int min, int max) CASE_TEST(memcmp_e0_20); EXPECT_GT(1, memcmp("aaa\xe0", "aaa\x20",= 4), 0); break; CASE_TEST(memcmp_80_e0); EXPECT_LT(1, memcmp("aaa\x80", "aaa\xe0",= 4), 0); break; CASE_TEST(memcmp_e0_80); EXPECT_GT(1, memcmp("aaa\xe0", "aaa\x80",= 4), 0); break; + CASE_TEST(limit_int8_max); EXPECT_EQ(1, INT8_MAX, (int8= _t) 0x7f); break; + CASE_TEST(limit_int8_min); EXPECT_EQ(1, INT8_MIN, (int8= _t) 0x80); break; + CASE_TEST(limit_uint8_max); EXPECT_EQ(1, UINT8_MAX, (uint= 8_t) 0xff); break; + CASE_TEST(limit_int16_max); EXPECT_EQ(1, INT16_MAX, (int1= 6_t) 0x7fff); break; + CASE_TEST(limit_int16_min); EXPECT_EQ(1, INT16_MIN, (int1= 6_t) 0x8000); break; + CASE_TEST(limit_uint16_max); EXPECT_EQ(1, UINT16_MAX, (uint= 16_t) 0xffff); break; + CASE_TEST(limit_int32_max); EXPECT_EQ(1, INT32_MAX, (int3= 2_t) 0x7fffffff); break; + CASE_TEST(limit_int32_min); EXPECT_EQ(1, INT32_MIN, (int3= 2_t) 0x80000000); break; + CASE_TEST(limit_uint32_max); EXPECT_EQ(1, UINT32_MAX, (uint= 32_t) 0xffffffff); break; + CASE_TEST(limit_int64_max); EXPECT_EQ(1, INT64_MAX, (int6= 4_t) 0x7fffffffffffffff); break; + CASE_TEST(limit_int64_min); EXPECT_EQ(1, INT64_MIN, (int6= 4_t) 0x8000000000000000); break; + CASE_TEST(limit_uint64_max); EXPECT_EQ(1, UINT64_MAX, (uint= 64_t) 0xffffffffffffffff); break; + CASE_TEST(limit_int_least8_max); EXPECT_EQ(1, INT_LEAST8_MAX, (int_= least8_t) 0x7f); break; + CASE_TEST(limit_int_least8_min); EXPECT_EQ(1, INT_LEAST8_MIN, (int_= least8_t) 0x80); break; + CASE_TEST(limit_uint_least8_max); EXPECT_EQ(1, UINT_LEAST8_MAX, (uint= _least8_t) 0xff); break; + CASE_TEST(limit_int_least16_max); EXPECT_EQ(1, INT_LEAST16_MAX, (int_= least16_t) 0x7fff); break; + CASE_TEST(limit_int_least16_min); EXPECT_EQ(1, INT_LEAST16_MIN, (int_= least16_t) 0x8000); break; + CASE_TEST(limit_uint_least16_max); EXPECT_EQ(1, UINT_LEAST16_MAX, (uint= _least16_t) 0xffff); break; + CASE_TEST(limit_int_least32_max); EXPECT_EQ(1, INT_LEAST32_MAX, (int_= least32_t) 0x7fffffff); break; + CASE_TEST(limit_int_least32_min); EXPECT_EQ(1, INT_LEAST32_MIN, (int_= least32_t) 0x80000000); break; + CASE_TEST(limit_uint_least32_max); EXPECT_EQ(1, UINT_LEAST32_MAX, (uint= _least32_t) 0xffffffffU); break; + CASE_TEST(limit_int_least64_min); EXPECT_EQ(1, INT_LEAST64_MIN, (int_= least64_t) 0x8000000000000000LL); break; + CASE_TEST(limit_int_least64_max); EXPECT_EQ(1, INT_LEAST64_MAX, (int_= least64_t) 0x7fffffffffffffffLL); break; + CASE_TEST(limit_uint_least64_max); EXPECT_EQ(1, UINT_LEAST64_MAX, (uint= _least64_t) 0xffffffffffffffffULL); break; + CASE_TEST(limit_int_fast8_max); EXPECT_EQ(1, INT_FAST8_MAX, (int_= fast8_t) 0x7f); break; + CASE_TEST(limit_int_fast8_min); EXPECT_EQ(1, INT_FAST8_MIN, (int_= fast8_t) 0x80); break; + CASE_TEST(limit_uint_fast8_max); EXPECT_EQ(1, UINT_FAST8_MAX, (uint= _fast8_t) 0xff); break; + CASE_TEST(limit_int_fast16_min); EXPECT_EQ(1, INT_FAST16_MIN, (int_= fast16_t) INTPTR_MIN); break; + CASE_TEST(limit_int_fast16_max); EXPECT_EQ(1, INT_FAST16_MAX, (int_= fast16_t) INTPTR_MAX); break; + CASE_TEST(limit_uint_fast16_max); EXPECT_EQ(1, UINT_FAST16_MAX, (uint= _fast16_t) UINTPTR_MAX); break; + CASE_TEST(limit_int_fast32_min); EXPECT_EQ(1, INT_FAST32_MIN, (int_= fast32_t) INTPTR_MIN); break; + CASE_TEST(limit_int_fast32_max); EXPECT_EQ(1, INT_FAST32_MAX, (int_= fast32_t) INTPTR_MAX); break; + CASE_TEST(limit_uint_fast32_max); EXPECT_EQ(1, UINT_FAST32_MAX, (uint= _fast32_t) UINTPTR_MAX); break; + CASE_TEST(limit_int_fast64_min); EXPECT_EQ(1, INT_FAST64_MIN, (int_= fast64_t) INTPTR_MIN); break; + CASE_TEST(limit_int_fast64_max); EXPECT_EQ(1, INT_FAST64_MAX, (int_= fast64_t) INTPTR_MAX); break; + CASE_TEST(limit_uint_fast64_max); EXPECT_EQ(1, UINT_FAST64_MAX, (uint= _fast64_t) UINTPTR_MAX); break; +#if __SIZEOF_LONG__ =3D=3D 8 + CASE_TEST(limit_intptr_min); EXPECT_EQ(1, INTPTR_MIN, (intp= tr_t) 0x8000000000000000LL); break; + CASE_TEST(limit_intptr_max); EXPECT_EQ(1, INTPTR_MAX, (intp= tr_t) 0x7fffffffffffffffLL); break; + CASE_TEST(limit_uintptr_max); EXPECT_EQ(1, UINTPTR_MAX, (uint= ptr_t) 0xffffffffffffffffULL); break; + CASE_TEST(limit_ptrdiff_min); EXPECT_EQ(1, PTRDIFF_MIN, (ptrd= iff_t) 0x8000000000000000LL); break; + CASE_TEST(limit_ptrdiff_max); EXPECT_EQ(1, PTRDIFF_MAX, (ptrd= iff_t) 0x7fffffffffffffffLL); break; + CASE_TEST(limit_size_max); EXPECT_EQ(1, SIZE_MAX, (size= _t) 0xffffffffffffffffULL); break; +#elif __SIZEOF_LONG__ =3D=3D 4 + CASE_TEST(limit_intptr_min); EXPECT_EQ(1, INTPTR_MIN, (intp= tr_t) 0x80000000); break; + CASE_TEST(limit_intptr_max); EXPECT_EQ(1, INTPTR_MAX, (intp= tr_t) 0x7fffffff); break; + CASE_TEST(limit_uintptr_max); EXPECT_EQ(1, UINTPTR_MAX, (uint= ptr_t) 0xffffffffU); break; + CASE_TEST(limit_ptrdiff_min); EXPECT_EQ(1, PTRDIFF_MIN, (ptrd= iff_t) 0x80000000); break; + CASE_TEST(limit_ptrdiff_max); EXPECT_EQ(1, PTRDIFF_MAX, (ptrd= iff_t) 0x7fffffff); break; + CASE_TEST(limit_size_max); EXPECT_EQ(1, SIZE_MAX, (size= _t) 0xffffffffU); break; +#else +# warning "__SIZEOF_LONG__ is undefined" +#endif /* __SIZEOF_LONG__ */ case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D244C6FD1C for ; Tue, 21 Mar 2023 01:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbjCUBOj (ORCPT ); Mon, 20 Mar 2023 21:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbjCUBOV (ORCPT ); Mon, 20 Mar 2023 21:14:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A52EF1FE3 for ; Mon, 20 Mar 2023 18:13:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 30001B811C2 for ; Tue, 21 Mar 2023 01:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 911A2C433A1; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=TtxwyZ2yyBdV44Bz3Oj230Ni7X2FI+pFx4BXXurJI4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mj3U2cHM9CdZOnyGRS+2vZ70cuWOXcFb7SjpFE5x/bitMYYONegiZpty1MCYenuHd aTtJ/eFoAL5naFO24Dq2q+gJA0A26POMqlCuLubkKpW8DOQ0Lc2XmnxJBGt1BncJSr w9F8u8BuKWo/9kl13ZquH412PM/JQBIzx3YdX9AC0LYHAWQnXlKRo+Pm1rvF9TUYhM aAcnLR7usFuQoYyEhnoX5gWsEOaXegRZAZXcXT0f7/HXqJKgo93YCUtBn1jJp5sVi1 y3ahVFvC9OXn0VeFStya0K/y4a1Ru1pgL8ozyKEYbvWtJroUM5MOn5SaBt8Eeq6wP/ GpiZMru7Uo0ug== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id E9670154039F; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 07/14] tools/nolibc: add getuid() and geteuid() Date: Mon, 20 Mar 2023 18:11:30 -0700 Message-Id: <20230321011137.51837-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau This can be useful to avoid attempting some privileged operations, starting from the nolibc-test tool that gets two failures when not privileged. We call getuid32() and geteuid32() when they are defined, and fall back to getuid() and geteuid() otherwise. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index b5f8cd35c03b..115579e7f1db 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -410,6 +410,27 @@ int getdents64(int fd, struct linux_dirent64 *dirp, in= t count) } =20 =20 +/* + * uid_t geteuid(void); + */ + +static __attribute__((unused)) +uid_t sys_geteuid(void) +{ +#ifdef __NR_geteuid32 + return my_syscall0(__NR_geteuid32); +#else + return my_syscall0(__NR_geteuid); +#endif +} + +static __attribute__((unused)) +uid_t geteuid(void) +{ + return sys_geteuid(); +} + + /* * pid_t getpgid(pid_t pid); */ @@ -544,6 +565,27 @@ int gettimeofday(struct timeval *tv, struct timezone *= tz) } =20 =20 +/* + * uid_t getuid(void); + */ + +static __attribute__((unused)) +uid_t sys_getuid(void) +{ +#ifdef __NR_getuid32 + return my_syscall0(__NR_getuid32); +#else + return my_syscall0(__NR_getuid); +#endif +} + +static __attribute__((unused)) +uid_t getuid(void) +{ + return sys_getuid(); +} + + /* * int ioctl(int fd, unsigned long req, void *value); */ --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 291BEC6FD1C for ; Tue, 21 Mar 2023 01:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbjCUBYv (ORCPT ); Mon, 20 Mar 2023 21:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbjCUBYs (ORCPT ); Mon, 20 Mar 2023 21:24:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A592728E98 for ; Mon, 20 Mar 2023 18:24:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 33BD9B811C3 for ; Tue, 21 Mar 2023 01:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DBA6C4339E; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=tdYkPh59mpPBLtefCTS0P4bFAwFRVtfHKbi4mc8Dr4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nccVPcKqXasqtjfsvpZHJs5MhCoy2mT7q4zuGQ1iW/syWQKgFNqRkMQtQVcZ3wY9N fy9v+rEhD6/OgK6TELyMBy9rImlvThdq4GBHxcI9nZQSwPBMDhBJWvtDN9z6Jf6XsK z4kHgGo2aVcbMO9zNp8VJUyctEDQto3seZPqiwiOaKHXEjo7sJaf/bl5S1TcrQPiEY ZZlOgPSnmCVqE1gSH50iebMYRbwmDG2pbfMhQHa7Hu0d3gqVzykhRF+GiWTS/Y5NlP 7nz4t0AiW6opzYHAgvAVCtJM4O3jqqTPx9Aq2eLYxX9eDY03N/TDaXRKio0U94TOHV GdZ7Mstu2wd/g== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id ECD2115403A0; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 08/14] selftests/nolibc: skip the chroot_root and link_dir tests when not privileged Date: Mon, 20 Mar 2023 18:11:31 -0700 Message-Id: <20230321011137.51837-8-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau These two tests always fail when the program is started natively as an unprivileged user, and require the user to carefully check the output of "make run-user" and ignore them. Let's add an euid check and condition these two tests to euid=3D=3D0. Now the test case stops needlessly reporting failures. E.g.: $ make -C tools/testing/selftests/nolibc run-user ... CC nolibc-test 123 test(s) passed. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 772f88bda0f1..6a7c13f0cd61 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -477,6 +477,7 @@ static int test_getpagesize(void) int run_syscall(int min, int max) { struct stat stat_buf; + int euid0; int proc; int test; int tmp; @@ -486,6 +487,9 @@ int run_syscall(int min, int max) /* indicates whether or not /proc is mounted */ proc =3D stat("/proc", &stat_buf) =3D=3D 0; =20 + /* this will be used to skip certain tests that can't be run unprivileged= */ + euid0 =3D geteuid() =3D=3D 0; + for (test =3D min; test >=3D 0 && test <=3D max; test++) { int llen =3D 0; // line length =20 @@ -511,7 +515,7 @@ int run_syscall(int min, int max) CASE_TEST(chmod_net); EXPECT_SYSZR(proc, chmod("/proc/self/net",= 0555)); break; CASE_TEST(chmod_self); EXPECT_SYSER(proc, chmod("/proc/self", 055= 5), -1, EPERM); break; CASE_TEST(chown_self); EXPECT_SYSER(proc, chown("/proc/self", 0, = 0), -1, EPERM); break; - CASE_TEST(chroot_root); EXPECT_SYSZR(1, chroot("/")); break; + CASE_TEST(chroot_root); EXPECT_SYSZR(euid0, chroot("/")); break; CASE_TEST(chroot_blah); EXPECT_SYSER(1, chroot("/proc/self/blah"),= -1, ENOENT); break; CASE_TEST(chroot_exe); EXPECT_SYSER(proc, chroot("/proc/self/exe"= ), -1, ENOTDIR); break; CASE_TEST(close_m1); EXPECT_SYSER(1, close(-1), -1, EBADF); bre= ak; @@ -536,7 +540,7 @@ int run_syscall(int min, int max) CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); = break; CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST= ); break; CASE_TEST(link_blah); EXPECT_SYSER(1, link("/proc/self/blah", "/= blah"), -1, ENOENT); break; - CASE_TEST(link_dir); EXPECT_SYSER(1, link("/", "/blah"), -1, EP= ERM); break; + CASE_TEST(link_dir); EXPECT_SYSER(euid0, link("/", "/blah"), -1= , EPERM); break; CASE_TEST(link_cross); EXPECT_SYSER(proc, link("/proc/self/net", = "/blah"), -1, EXDEV); break; CASE_TEST(lseek_m1); EXPECT_SYSER(1, lseek(-1, 0, SEEK_SET), -1= , EBADF); break; CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1,= ESPIPE); break; --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F6D2C6FD1D for ; Tue, 21 Mar 2023 01:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbjCUBOe (ORCPT ); Mon, 20 Mar 2023 21:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230403AbjCUBOQ (ORCPT ); Mon, 20 Mar 2023 21:14:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ADD11A65C for ; Mon, 20 Mar 2023 18:13:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 21035B811C0 for ; Tue, 21 Mar 2023 01:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A55CFC433A8; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=dUA8VXr/zwZtcB1ONG//cuti16k8LCic/nbXiNW74pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEqjYdqj/0mVhZ/fu931k9kn+s9h2DjuQLdamLgus1f/aLmdScrkUBc5eq+m+sEfa 23y4WMWBegRXPlugzy/lwNhO5IcUdhhLfeM2YAD/ap/LV7mwFH7MHv2ThzV/oJ9D3g MCFPZFYMstr5Tn4SlnH11/pGU8cgYGZayUMdtYzKho2KZqGeEum2kMYfcmJ0Icux+O 4r8OSjSMWOk1ec18p1dA51wo8M6BPkYnvxfx8HSZEPlq9tbiyByAQU/hI45tNJJMbZ 1xCgqcxLqa+EUEPWFtlmQKtPuHywFmLoAxAD3GLppNc3HudEOdYA4We9WH2KVGiRZK +sFe2UvemZeHw== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id EFFCB15403A1; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Willy Tarreau , Feiyang Chen , "Paul E . McKenney" Subject: [PATCH nolibc 09/14] tools/nolibc: check for S_I* macros before defining them Date: Mon, 20 Mar 2023 18:11:32 -0700 Message-Id: <20230321011137.51837-9-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Willy Tarreau Defining S_I* flags in types.h can cause some build failures if linux/stat.h is included prior to it. But if not defined, some toolchains that include some glibc parts will in turn fail because linux/stat.h already takes care of avoiding these definitions when glibc is present. Let's preserve the macros here but first include linux/stat.h and check for their definition before doing so. We also define the previously missing permission macros so that we don't get a different behavior depending on the first include found. Cc: Feiyang Chen Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/types.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index fbbc0e68c001..47a0997d2d74 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -9,6 +9,7 @@ =20 #include "std.h" #include +#include =20 =20 /* Only the generic macros and types may be defined here. The arch-specific @@ -16,7 +17,11 @@ * the layout of sys_stat_struct must not be defined here. */ =20 -/* stat flags (WARNING, octal here) */ +/* stat flags (WARNING, octal here). We need to check for an existing + * definition because linux/stat.h may omit to define those if it finds + * that any glibc header was already included. + */ +#if !defined(S_IFMT) #define S_IFDIR 0040000 #define S_IFCHR 0020000 #define S_IFBLK 0060000 @@ -34,6 +39,22 @@ #define S_ISLNK(mode) (((mode) & S_IFMT) =3D=3D S_IFLNK) #define S_ISSOCK(mode) (((mode) & S_IFMT) =3D=3D S_IFSOCK) =20 +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 +#endif + /* dirent types */ #define DT_UNKNOWN 0x0 #define DT_FIFO 0x1 --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A575EC6FD1C for ; Tue, 21 Mar 2023 01:15:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbjCUBPf (ORCPT ); Mon, 20 Mar 2023 21:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231143AbjCUBOw (ORCPT ); Mon, 20 Mar 2023 21:14:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 461B8A25B for ; Mon, 20 Mar 2023 18:14:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F1126190D for ; Tue, 21 Mar 2023 01:11:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF668C433AC; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=itvMBi7pFpfn0c4qRiVR8pvpX/hmzHY5DmYgarYKaSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8BJx1+AEBiHc0wfeKuAUlx3OngTqlX0g/MaHyny/AlE1iY2Dp1PKx1gxo3l9RoZV aHGvhbJo5yMZPISC/y2wU6A7gT1T2BKXVBLJf+5OIk3SpQGJjaUcyyt5fbvc0SlZxw iolVyajuIqPUIUXo2s8wO7IrFGruD29UKDtuxeBaT3+zvrh+D45Gc0AS7++6nxuHos f64IWQD5xLoVDfSIGHDm7n3QdYUr+YmVkWwEqlcXQ7O5HuBEhiU7rLXa5tALj3gO0h Dg99tU6yWh1CIz799dnj/WWr96vTHEjQThXJu8XEvW7xS48eY4mc6tR3RK7i8wmNpz 0yNGHH/uc+vSw== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id F358A15403A2; Mon, 20 Mar 2023 18:11:38 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Feiyang Chen , Huacai Chen , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 10/14] tools/nolibc: Include linux/fcntl.h and remove duplicate code Date: Mon, 20 Mar 2023 18:11:33 -0700 Message-Id: <20230321011137.51837-10-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Feiyang Chen Include linux/fcntl.h for O_* and AT_*. asm/fcntl.h is included by linux/fcntl.h, so it can be safely removed. Signed-off-by: Feiyang Chen Acked-by: Huacai Chen Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 2 +- tools/include/nolibc/types.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 115579e7f1db..41cad6d6137e 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -11,7 +11,6 @@ #include "std.h" =20 /* system includes */ -#include // for O_* #include #include // for SIGCHLD #include @@ -20,6 +19,7 @@ #include #include #include +#include // for O_* and AT_* =20 #include "arch.h" #include "errno.h" diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 47a0997d2d74..10823e5ac44b 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -81,11 +81,6 @@ #define MAXPATHLEN (PATH_MAX) #endif =20 -/* Special FD used by all the *at functions */ -#ifndef AT_FDCWD -#define AT_FDCWD (-100) -#endif - /* whence values for lseek() */ #define SEEK_SET 0 #define SEEK_CUR 1 --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5EC9C6FD1D for ; Tue, 21 Mar 2023 01:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbjCUBOH (ORCPT ); Mon, 20 Mar 2023 21:14:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbjCUBNp (ORCPT ); Mon, 20 Mar 2023 21:13:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D30EC93E4 for ; Mon, 20 Mar 2023 18:13:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 49E5FB811C1 for ; Tue, 21 Mar 2023 01:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEF05C433AA; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=I6L9I5YvKU2tMz08JBH9lvplcZ5ve+HKcUuODuR8ErU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nprVU0QzWFuNAOMQuLfo+eot0Hp8a7bk5UFqGP8XKSNY0Gvt58aeqoZPLo8mHXBZw SIG3O4dQUzrnd3mU+X+8k1giibuJ7+t4NfeG6oj4rBrJ8Em4bkQBh7LVdEUqC+Dmis uaP5itq/GaA2AU/rLXXm+O2Xy6H1S64GukDc8AGS+GpCMHT/b8QUqd3TFKf0R/0yGY nM7zcpTyVifs3ivbUDiE/iTKpVd9qbPNGdJWFeJemzqhaFJmMR/FNpk7f+uW7pkbSJ cwzWRoDP2nzqzprNGQb5J0Fqqf/lbryqogB6uWfL4ppV/G8f44c6a7VuIrdobMyVDg qKrwbM8ojWC3w== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 02A6415403A3; Mon, 20 Mar 2023 18:11:39 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Feiyang Chen , Huacai Chen , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 11/14] tools/nolibc: Add statx() and make stat() rely on statx() if necessary Date: Mon, 20 Mar 2023 18:11:34 -0700 Message-Id: <20230321011137.51837-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Feiyang Chen LoongArch and RISC-V 32-bit only have statx(). ARC, Hexagon, Nios2 and OpenRISC have statx() and stat64() but not stat() or newstat(). Add statx() and make stat() rely on statx() if necessary to make them happy. We may just use statx() for all architectures in the future. Signed-off-by: Feiyang Chen Acked-by: Huacai Chen Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 41cad6d6137e..5d624dc63a42 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -20,6 +20,7 @@ #include #include #include // for O_* and AT_* +#include // for statx() =20 #include "arch.h" #include "errno.h" @@ -1090,12 +1091,66 @@ pid_t setsid(void) return ret; } =20 +#if defined(__NR_statx) +/* + * int statx(int fd, const char *path, int flags, unsigned int mask, struc= t statx *buf); + */ + +static __attribute__((unused)) +int sys_statx(int fd, const char *path, int flags, unsigned int mask, stru= ct statx *buf) +{ + return my_syscall5(__NR_statx, fd, path, flags, mask, buf); +} + +static __attribute__((unused)) +int statx(int fd, const char *path, int flags, unsigned int mask, struct s= tatx *buf) +{ + int ret =3D sys_statx(fd, path, flags, mask, buf); + + if (ret < 0) { + SET_ERRNO(-ret); + ret =3D -1; + } + return ret; +} +#endif =20 /* * int stat(const char *path, struct stat *buf); * Warning: the struct stat's layout is arch-dependent. */ =20 +#if defined(__NR_statx) && !defined(__NR_newfstatat) && !defined(__NR_stat) +/* + * Maybe we can just use statx() when available for all architectures? + */ +static __attribute__((unused)) +int sys_stat(const char *path, struct stat *buf) +{ + struct statx statx; + long ret; + + ret =3D sys_statx(AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &st= atx); + buf->st_dev =3D ((statx.stx_dev_minor & 0xff) + | (statx.stx_dev_major << 8) + | ((statx.stx_dev_minor & ~0xff) << 12)); + buf->st_ino =3D statx.stx_ino; + buf->st_mode =3D statx.stx_mode; + buf->st_nlink =3D statx.stx_nlink; + buf->st_uid =3D statx.stx_uid; + buf->st_gid =3D statx.stx_gid; + buf->st_rdev =3D ((statx.stx_rdev_minor & 0xff) + | (statx.stx_rdev_major << 8) + | ((statx.stx_rdev_minor & ~0xff) << 12)); + buf->st_size =3D statx.stx_size; + buf->st_blksize =3D statx.stx_blksize; + buf->st_blocks =3D statx.stx_blocks; + buf->st_atime =3D statx.stx_atime.tv_sec; + buf->st_mtime =3D statx.stx_mtime.tv_sec; + buf->st_ctime =3D statx.stx_ctime.tv_sec; + return ret; +} +#else static __attribute__((unused)) int sys_stat(const char *path, struct stat *buf) { @@ -1125,6 +1180,7 @@ int sys_stat(const char *path, struct stat *buf) buf->st_ctime =3D stat.st_ctime; return ret; } +#endif =20 static __attribute__((unused)) int stat(const char *path, struct stat *buf) --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5566CC6FD1C for ; Tue, 21 Mar 2023 01:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbjCUBV2 (ORCPT ); Mon, 20 Mar 2023 21:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229901AbjCUBVZ (ORCPT ); Mon, 20 Mar 2023 21:21:25 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C872125A4 for ; Mon, 20 Mar 2023 18:20:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id BEC8BCE172D for ; Tue, 21 Mar 2023 01:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFABAC433B0; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=0tnH+PV473Tm6iVXAJx7Tp9q1rEWeuiB5k/lIQjGGho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9A5bQTnBwsvTjjQvz11pI1Y5IyAm9UQpZsrVFzL2KMxFnsS/j+JT2qJZSbJeRp6H 8nCHGRcT+kUPqC/hk453RD8PpFmHeSg1TEivThL1jZDdn8DegoqMOdr1DWqnefC2nr Dv0vsqd1GSg39YcZxx4WfyX8Y//eonScyBjB/ioCZgSxzQXtDjfLz+/c4TsRqPNa13 VFsGvpuOfMf8BpCY4q2SROamqnavnh1zKe4UQAX1aKvvp2ZcCy6mYlqPYYhVJ4Qt9p Y7tXpiJ1J1+EoYu4EoH3S6aX8AAM79zUVTapV9w8X2EVUkFVbLLTEPM41CcjBpM4ZP S0f7a/Dwv8bBw== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 0642415403A4; Mon, 20 Mar 2023 18:11:39 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Feiyang Chen , Huacai Chen , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 12/14] tools/nolibc: Add support for LoongArch Date: Mon, 20 Mar 2023 18:11:35 -0700 Message-Id: <20230321011137.51837-12-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Feiyang Chen Add support for LoongArch (32 and 64 bit) to nolibc. Signed-off-by: Feiyang Chen Acked-by: Huacai Chen Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-loongarch.h | 200 ++++++++++++++++++++++++++ tools/include/nolibc/arch.h | 2 + 2 files changed, 202 insertions(+) create mode 100644 tools/include/nolibc/arch-loongarch.h diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/a= rch-loongarch.h new file mode 100644 index 000000000000..029ee3cd6baf --- /dev/null +++ b/tools/include/nolibc/arch-loongarch.h @@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * LoongArch specific definitions for NOLIBC + * Copyright (C) 2023 Loongson Technology Corporation Limited + */ + +#ifndef _NOLIBC_ARCH_LOONGARCH_H +#define _NOLIBC_ARCH_LOONGARCH_H + +/* Syscalls for LoongArch : + * - stack is 16-byte aligned + * - syscall number is passed in a7 + * - arguments are in a0, a1, a2, a3, a4, a5 + * - the system call is performed by calling "syscall 0" + * - syscall return comes in a0 + * - the arguments are cast to long and assigned into the target + * registers which are then simply passed as registers to the asm code, + * so that we don't have to experience issues with register constraint= s. + * + * On LoongArch, select() is not implemented so we have to use pselect6(). + */ +#define __ARCH_WANT_SYS_PSELECT6 + +#define my_syscall0(num) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0"); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "=3Dr"(_arg1) \ + : "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +#define my_syscall1(num, arg1) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0") =3D (long)(arg1); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "+r"(_arg1) \ + : "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +#define my_syscall2(num, arg1, arg2) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("a1") =3D (long)(arg2); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), \ + "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +#define my_syscall3(num, arg1, arg2, arg3) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("a1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("a2") =3D (long)(arg3); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), \ + "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +#define my_syscall4(num, arg1, arg2, arg3, arg4) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("a1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("a2") =3D (long)(arg3); \ + register long _arg4 __asm__ ("a3") =3D (long)(arg4); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), "r"(_arg4), \ + "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("a1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("a2") =3D (long)(arg3); \ + register long _arg4 __asm__ ("a3") =3D (long)(arg4); \ + register long _arg5 __asm__ ("a4") =3D (long)(arg5); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \ + "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) = \ +({ = \ + register long _num __asm__ ("a7") =3D (num); \ + register long _arg1 __asm__ ("a0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("a1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("a2") =3D (long)(arg3); \ + register long _arg4 __asm__ ("a3") =3D (long)(arg4); \ + register long _arg5 __asm__ ("a4") =3D (long)(arg5); \ + register long _arg6 __asm__ ("a5") =3D (long)(arg6); \ + \ + __asm__ volatile ( \ + "syscall 0\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), "r"(_arg6), \ + "r"(_num) \ + : "memory", "$t0", "$t1", "$t2", "$t3", \ + "$t4", "$t5", "$t6", "$t7", "$t8" \ + ); \ + _arg1; \ +}) + +char **environ __attribute__((weak)); +const unsigned long *_auxv __attribute__((weak)); + +#if __loongarch_grlen =3D=3D 32 +#define LONGLOG "2" +#define SZREG "4" +#define REG_L "ld.w" +#define LONG_S "st.w" +#define LONG_ADD "add.w" +#define LONG_ADDI "addi.w" +#define LONG_SLL "slli.w" +#define LONG_BSTRINS "bstrins.w" +#else // __loongarch_grlen =3D=3D 64 +#define LONGLOG "3" +#define SZREG "8" +#define REG_L "ld.d" +#define LONG_S "st.d" +#define LONG_ADD "add.d" +#define LONG_ADDI "addi.d" +#define LONG_SLL "slli.d" +#define LONG_BSTRINS "bstrins.d" +#endif + +/* startup code */ +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(= void) +{ + __asm__ volatile ( + REG_L " $a0, $sp, 0\n" // argc (a0) was in the stack + LONG_ADDI " $a1, $sp, "SZREG"\n" // argv (a1) =3D sp + SZREG + LONG_SLL " $a2, $a0, "LONGLOG"\n" // envp (a2) =3D SZREG*argc ... + LONG_ADDI " $a2, $a2, "SZREG"\n" // + SZREG (skip null) + LONG_ADD " $a2, $a2, $a1\n" // + argv + + "move $a3, $a2\n" // iterate a3 over envp to find au= xv (after NULL) + "0:\n" // do { + REG_L " $a4, $a3, 0\n" // a4 =3D *a3; + LONG_ADDI " $a3, $a3, "SZREG"\n" // a3 +=3D sizeof(void*); + "bne $a4, $zero, 0b\n" // } while (a4); + "la.pcrel $a4, _auxv\n" // a4 =3D &_auxv + LONG_S " $a3, $a4, 0\n" // store a3 into _auxv + + "la.pcrel $a3, environ\n" // a3 =3D &environ + LONG_S " $a2, $a3, 0\n" // store envp(a2) into environ + LONG_BSTRINS " $sp, $zero, 3, 0\n" // sp must be 16-byte aligned + "bl main\n" // main() returns the status code,= we'll exit with it. + "li.w $a7, 93\n" // NR_exit =3D=3D 93 + "syscall 0\n" + ); + __builtin_unreachable(); +} + +#endif // _NOLIBC_ARCH_LOONGARCH_H diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h index 78b067a4fa47..2d5386a8d6aa 100644 --- a/tools/include/nolibc/arch.h +++ b/tools/include/nolibc/arch.h @@ -29,6 +29,8 @@ #include "arch-riscv.h" #elif defined(__s390x__) #include "arch-s390.h" +#elif defined(__loongarch__) +#include "arch-loongarch.h" #endif =20 #endif /* _NOLIBC_ARCH_H */ --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E1DC6FD1C for ; Tue, 21 Mar 2023 01:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbjCUBPy (ORCPT ); Mon, 20 Mar 2023 21:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbjCUBPg (ORCPT ); Mon, 20 Mar 2023 21:15:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A81419743 for ; Mon, 20 Mar 2023 18:14:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 60679B811C5 for ; Tue, 21 Mar 2023 01:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9323C433AE; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=XbcHM5o/5dF7rnFY9neqUQfFJg26hV1YxFH7UsKvUsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRxvUzUr3JN0DcNA/rF1jnadkMVsngxlcoGo47G/nq842oFpK6kI5zX+6tvSNpiyo KpSu7KBZ2BYtXVma3nRs54gZ0dBTqPMrLoHgJ092/SFvl/uLNzwRE9IkL4fKLDzVbY KbdCg+diQOWuAA7mQZJVUJSTfkf25IaQ5V2fZdB/HgZDRgehP6gVvNFUmgp5+gKDjF JiRN6UMyzfzxukyu8ru+Qq3VmkdUkwSq2dNkP/u69EM/0GGchMZM0Mi7Wz7vjAUqVt zla29/K7bEniIVy2RVMnzuZU8QvCT6b1vZWO8IxHgXDXYXTR23uPtDJ4e3DjFMwPGD q8ObVQzEjUltA== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 09B7B15403A5; Mon, 20 Mar 2023 18:11:39 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Feiyang Chen , Huacai Chen , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 13/14] selftests/nolibc: Add support for LoongArch Date: Mon, 20 Mar 2023 18:11:36 -0700 Message-Id: <20230321011137.51837-13-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Feiyang Chen Add support for LoongArch (64 bit) to nolibc selftest. Signed-off-by: Feiyang Chen Acked-by: Huacai Chen Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 874d141da8c4..7992287ebbbd 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -23,6 +23,7 @@ IMAGE_arm =3D arch/arm/boot/zImage IMAGE_mips =3D vmlinuz IMAGE_riscv =3D arch/riscv/boot/Image IMAGE_s390 =3D arch/s390/boot/bzImage +IMAGE_loongarch =3D arch/loongarch/boot/vmlinuz.efi IMAGE =3D $(IMAGE_$(ARCH)) IMAGE_NAME =3D $(notdir $(IMAGE)) =20 @@ -35,6 +36,7 @@ DEFCONFIG_arm =3D multi_v7_defconfig DEFCONFIG_mips =3D malta_defconfig DEFCONFIG_riscv =3D defconfig DEFCONFIG_s390 =3D defconfig +DEFCONFIG_loongarch =3D defconfig DEFCONFIG =3D $(DEFCONFIG_$(ARCH)) =20 # optional tests to run (default =3D all) @@ -49,6 +51,7 @@ QEMU_ARCH_arm =3D arm QEMU_ARCH_mips =3D mipsel # works with malta_defconfig QEMU_ARCH_riscv =3D riscv64 QEMU_ARCH_s390 =3D s390x +QEMU_ARCH_loongarch =3D loongarch64 QEMU_ARCH =3D $(QEMU_ARCH_$(ARCH)) =20 # QEMU_ARGS : some arch-specific args to pass to qemu @@ -60,6 +63,7 @@ QEMU_ARGS_arm =3D -M virt -append "panic=3D-1 $(TEST:= %=3DNOLIBC_TEST=3D%)" QEMU_ARGS_mips =3D -M malta -append "panic=3D-1 $(TEST:%=3DNOLIBC_TEST= =3D%)" QEMU_ARGS_riscv =3D -M virt -append "console=3DttyS0 panic=3D-1 $(TEST:%= =3DNOLIBC_TEST=3D%)" QEMU_ARGS_s390 =3D -M s390-ccw-virtio -m 1G -append "console=3DttyS0 pa= nic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_loongarch =3D -M virt -append "console=3DttyS0,115200 panic=3D-= 1 $(TEST:%=3DNOLIBC_TEST=3D%)" QEMU_ARGS =3D $(QEMU_ARGS_$(ARCH)) =20 # OUTPUT is only set when run from the main makefile, otherwise --=20 2.40.0.rc2 From nobody Sun Feb 8 11:41:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60E1DC6FD1D for ; Tue, 21 Mar 2023 01:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbjCUBPY (ORCPT ); Mon, 20 Mar 2023 21:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbjCUBOx (ORCPT ); Mon, 20 Mar 2023 21:14:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A141D8A56 for ; Mon, 20 Mar 2023 18:14:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A1126190F for ; Tue, 21 Mar 2023 01:11:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF885C433AF; Tue, 21 Mar 2023 01:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679361099; bh=Dvb+nls10nlu3/tC3IQjY+h1oSyhXOEz0IHnIhupkMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WbYKXtFL2c1p1MEHyUMJbNQw/n4ms5od1hYj0wyszW0ry+NDYIZnviLgbmB0sqS8J 7CpD1F1H6ty94zBxHppkWKO7BwoVzdRNsMIR4xwFJHkIEr56mx0O6x/UET7fGyC/Uj Dh8name5kDbfaIKvKIz4GVXXJmm3DKhS7dCTWlND+PF8Y9ENhkukRVSMo5qiWFQnY1 qEJjOTQsa8wI6M3Wo5D5C22HB6/V8kzn7DDoIm+J/3DXy2SfJP1nPQzjBl4io2mPez Sgm/H59LGYP7VtEncqCsMFpUnlFyLrmihEBE5HSCtEDGACLvVg4vMpd5Q+iU11ucJ5 IjrKcaoQvL91g== Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 0D46C15403A6; Mon, 20 Mar 2023 18:11:39 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Feiyang Chen , Huacai Chen , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 14/14] selftests/nolibc: Adjust indentation for Makefile Date: Mon, 20 Mar 2023 18:11:37 -0700 Message-Id: <20230321011137.51837-14-paulmck@kernel.org> X-Mailer: git-send-email 2.40.0.rc2 In-Reply-To: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> References: <6a3206d0-e5cd-4990-9604-444a24a8207c@paulmck-laptop> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Feiyang Chen Reindent only, no functional changes. Signed-off-by: Feiyang Chen Acked-by: Huacai Chen Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 74 ++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 7992287ebbbd..c99bbcda7495 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -15,56 +15,56 @@ ARCH =3D $(SUBARCH) endif =20 # kernel image names by architecture -IMAGE_i386 =3D arch/x86/boot/bzImage -IMAGE_x86_64 =3D arch/x86/boot/bzImage -IMAGE_x86 =3D arch/x86/boot/bzImage -IMAGE_arm64 =3D arch/arm64/boot/Image -IMAGE_arm =3D arch/arm/boot/zImage -IMAGE_mips =3D vmlinuz -IMAGE_riscv =3D arch/riscv/boot/Image -IMAGE_s390 =3D arch/s390/boot/bzImage +IMAGE_i386 =3D arch/x86/boot/bzImage +IMAGE_x86_64 =3D arch/x86/boot/bzImage +IMAGE_x86 =3D arch/x86/boot/bzImage +IMAGE_arm64 =3D arch/arm64/boot/Image +IMAGE_arm =3D arch/arm/boot/zImage +IMAGE_mips =3D vmlinuz +IMAGE_riscv =3D arch/riscv/boot/Image +IMAGE_s390 =3D arch/s390/boot/bzImage IMAGE_loongarch =3D arch/loongarch/boot/vmlinuz.efi -IMAGE =3D $(IMAGE_$(ARCH)) -IMAGE_NAME =3D $(notdir $(IMAGE)) +IMAGE =3D $(IMAGE_$(ARCH)) +IMAGE_NAME =3D $(notdir $(IMAGE)) =20 # default kernel configurations that appear to be usable -DEFCONFIG_i386 =3D defconfig -DEFCONFIG_x86_64 =3D defconfig -DEFCONFIG_x86 =3D defconfig -DEFCONFIG_arm64 =3D defconfig -DEFCONFIG_arm =3D multi_v7_defconfig -DEFCONFIG_mips =3D malta_defconfig -DEFCONFIG_riscv =3D defconfig -DEFCONFIG_s390 =3D defconfig +DEFCONFIG_i386 =3D defconfig +DEFCONFIG_x86_64 =3D defconfig +DEFCONFIG_x86 =3D defconfig +DEFCONFIG_arm64 =3D defconfig +DEFCONFIG_arm =3D multi_v7_defconfig +DEFCONFIG_mips =3D malta_defconfig +DEFCONFIG_riscv =3D defconfig +DEFCONFIG_s390 =3D defconfig DEFCONFIG_loongarch =3D defconfig -DEFCONFIG =3D $(DEFCONFIG_$(ARCH)) +DEFCONFIG =3D $(DEFCONFIG_$(ARCH)) =20 # optional tests to run (default =3D all) TEST =3D =20 # QEMU_ARCH: arch names used by qemu -QEMU_ARCH_i386 =3D i386 -QEMU_ARCH_x86_64 =3D x86_64 -QEMU_ARCH_x86 =3D x86_64 -QEMU_ARCH_arm64 =3D aarch64 -QEMU_ARCH_arm =3D arm -QEMU_ARCH_mips =3D mipsel # works with malta_defconfig -QEMU_ARCH_riscv =3D riscv64 -QEMU_ARCH_s390 =3D s390x +QEMU_ARCH_i386 =3D i386 +QEMU_ARCH_x86_64 =3D x86_64 +QEMU_ARCH_x86 =3D x86_64 +QEMU_ARCH_arm64 =3D aarch64 +QEMU_ARCH_arm =3D arm +QEMU_ARCH_mips =3D mipsel # works with malta_defconfig +QEMU_ARCH_riscv =3D riscv64 +QEMU_ARCH_s390 =3D s390x QEMU_ARCH_loongarch =3D loongarch64 -QEMU_ARCH =3D $(QEMU_ARCH_$(ARCH)) +QEMU_ARCH =3D $(QEMU_ARCH_$(ARCH)) =20 # QEMU_ARGS : some arch-specific args to pass to qemu -QEMU_ARGS_i386 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux pani= c=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" -QEMU_ARGS_x86_64 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux pani= c=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" -QEMU_ARGS_x86 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux pani= c=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" -QEMU_ARGS_arm64 =3D -M virt -cpu cortex-a53 -append "panic=3D-1 $(TEST:%= =3DNOLIBC_TEST=3D%)" -QEMU_ARGS_arm =3D -M virt -append "panic=3D-1 $(TEST:%=3DNOLIBC_TEST= =3D%)" -QEMU_ARGS_mips =3D -M malta -append "panic=3D-1 $(TEST:%=3DNOLIBC_TEST= =3D%)" -QEMU_ARGS_riscv =3D -M virt -append "console=3DttyS0 panic=3D-1 $(TEST:%= =3DNOLIBC_TEST=3D%)" -QEMU_ARGS_s390 =3D -M s390-ccw-virtio -m 1G -append "console=3DttyS0 pa= nic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_i386 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux p= anic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_x86_64 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux p= anic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_x86 =3D -M pc -append "console=3DttyS0,9600 i8042.noaux p= anic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_arm64 =3D -M virt -cpu cortex-a53 -append "panic=3D-1 $(TES= T:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_arm =3D -M virt -append "panic=3D-1 $(TEST:%=3DNOLIBC_TES= T=3D%)" +QEMU_ARGS_mips =3D -M malta -append "panic=3D-1 $(TEST:%=3DNOLIBC_TE= ST=3D%)" +QEMU_ARGS_riscv =3D -M virt -append "console=3DttyS0 panic=3D-1 $(TES= T:%=3DNOLIBC_TEST=3D%)" +QEMU_ARGS_s390 =3D -M s390-ccw-virtio -m 1G -append "console=3DttyS0= panic=3D-1 $(TEST:%=3DNOLIBC_TEST=3D%)" QEMU_ARGS_loongarch =3D -M virt -append "console=3DttyS0,115200 panic=3D-= 1 $(TEST:%=3DNOLIBC_TEST=3D%)" -QEMU_ARGS =3D $(QEMU_ARGS_$(ARCH)) +QEMU_ARGS =3D $(QEMU_ARGS_$(ARCH)) =20 # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. --=20 2.40.0.rc2