From patchwork Mon Jun 12 20:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134022vqr; Mon, 12 Jun 2023 14:09:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yeKSOxCLY7E+uD8EqeHydft6CK9eoH4pZkgzlwyvVWtji0AASMr+gI3VObc4ZhXdiLEwz X-Received: by 2002:a17:907:986:b0:971:1717:207b with SMTP id bf6-20020a170907098600b009711717207bmr12771879ejc.35.1686604156468; Mon, 12 Jun 2023 14:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604156; cv=none; d=google.com; s=arc-20160816; b=fupt9GqfOV5NysUNp3pxzXfAdD6iGmFO/+VRC+3PAss/IaXtapwz1itDYtg4c6HGGk kh0bvr4Z5+VaBgtemtCWIy0sNZxpEyp8XavmA/Slcqq0nyNkcEjyTh5DQjI1Njr79/6T uTqQIDOQGfzOYFjLAwyyGwZM692PPk534q2BoFBubwap3UWPb+0Hou3NfHm/8d58xyvt OVNmH8vIKVHKbLLTk7m0f5o/8ImbTvNnGQ1U73KoYxdlTshJtjN4duw64BybGRyw5CL9 pHAcJXqpJGlxvCOm+6gx8U9fFIaaUV5m6hhax+tpwjo7Ib9+IYxriJGzPR/wttL4ytwB x2WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MmpPXr1RwOA0FjpGc1hNuQMgpq9idDkjFV9mSTYrDD0=; b=pWic3Go0OazFKudNjl1ZipM4Aaxhw5+ACNqMgR7LP8rqrtscwAq/zBB5QXNa6gPGiC 8Y8lzeRCcMd/Xo4zBcC5qZJ14wjKwfnen4f4MZ/TOPAoawvOKnsUGjb1JKvgHp2L2wzB fSk9GEI6A3zToDqhxNebGWO4b0l6TBGIrBo3Te6FncNfm4hfecq2M4fq0lbei+F7bt/2 JYNTWwQYTFhkI6Z+7WO5lQKR7UXUpiRyCaEX49e/3IakSz3qAySrItsIAfx1gKe5poZF ZR3zy9nQVhcUp9vvXH+hNI4Qb98Bya1dEJKLUilpiv395221agHX0aOpMKq375SPJFQX lpvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LE1LcIYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id aj18-20020a1709069a5200b00977dd154710si5990301ejc.992.2023.06.12.14.08.50; Mon, 12 Jun 2023 14:09:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LE1LcIYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233386AbjFLUr1 (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232473AbjFLUqv (ORCPT ); Mon, 12 Jun 2023 16:46:51 -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 8C8281BE8 for ; Mon, 12 Jun 2023 13:46:24 -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 9C60C62953 for ; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B93CC433EF; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=zEjOj9DdUomfDLsrKXBstSrS7dzFFqc89ym3/GOXT1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LE1LcIYwMJvI71eAa4GoeB4kWpGGfgWaTbiAYVXU0qUoCLzO5MmgqhfKK7P2GCkGC btl1nZaTARSST2jONdpLc4gyzl0eUp+GU+Bs6A04MhrE11HlApUNBKRYiCiH0J+etB dQ6SYNKsnA/8IKz+AsgVaDo8/NHDJqe5B1M7PVoW/xyA23SZ50QvTlDxbl1a5R+nCa YSOluy0GD5XhknNvzSU9rzNX0ydf4jSe/qv0wjeeDRXD8EtZzbjcZTlZbhFBLqOOJQ 1xfrhDRt/REVx1PmbXambLE7+1qCS9RI0uJmi3FYgVK0BgERrdYSqcmZtxwJrD3HO/ lvsDqhtAqjGtw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AA609CE09E7; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Alexey Dobriyan , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 01/53] tools/nolibc: tests: use volatile to force stack smashing Date: Mon, 12 Jun 2023 13:44:22 -0700 Message-Id: <20230612204514.292087-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532640021358179?= X-GMAIL-MSGID: =?utf-8?q?1768532640021358179?= From: Thomas Weißschuh Use a volatile pointer to write outside the buffer so the compiler can't optimize it away. Reported-by: Alexey Dobriyan Link: https://lore.kernel.org/lkml/c0584807-511c-4496-b062-1263ea38f349@p183/ Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 21bacc928bf7..47013b78972e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -667,17 +667,13 @@ int run_stdlib(int min, int max) return ret; } -#if defined(__clang__) -__attribute__((optnone)) -#elif defined(__GNUC__) -__attribute__((optimize("O0"))) -#endif static int smash_stack(void) { char buf[100]; + volatile char *ptr = buf; for (size_t i = 0; i < 200; i++) - buf[i] = 'P'; + ptr[i] = 'P'; return 1; } From patchwork Mon Jun 12 20:44:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133636vqr; Mon, 12 Jun 2023 14:08:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5luXDNJ+QG1u3We80JX3hAmy3Foi1n9rf8O3g26ZK8T7vWP/yZxu5oBvtOaeS3anapuyk5 X-Received: by 2002:aa7:c586:0:b0:514:9284:2380 with SMTP id g6-20020aa7c586000000b0051492842380mr5653538edq.19.1686604118379; Mon, 12 Jun 2023 14:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604118; cv=none; d=google.com; s=arc-20160816; b=cLZpk2SpG7XaoTxlImsGUxbAiL36S8MZvlYeBEMb0KqAjhKpRHESwmRBf+tUkoYw1P 1HEIwu4WnO5iVIsT3d9sdzQ57/5nkRoO/U/nf1zlMw5RdzrM3aTbSgLX/ji1yEERylBT f3JOXo4dB80s+YtsVxFRGfgrRt4+VjJ5o/7Q9lXO04Jx5QhNGK6aSas4xO2v2W5zQfAw jX79jyT8Ug0qNbnjRMpWwmB50fdmAsMxX9bIMSrkmj39jAYEZwB920hAi+Y+9LdYrp5u jcs40OXolkomKPWbl+mT0inc75FaKiA119VWD2VutXmkHv7AjqJCWi0SOodWB/lgdjka CXRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1o59O+9Ej8aW4nujuOX3uB/Xm7vXtKmaNIi6I5lai48=; b=Dl7vKI02Ge8mpz/2RWCFRh+nsbGXx9Qn4U3KoNG4nW7z4d1ss1XZ0jdpLW77e2Fefb K/7Bi1JRmXY2FRo/XhbDL34QkjI8x0oeU4bWIh5n1chsP5sHuGHYzEE/Jk0QDgJEwgFT Dor39a7Q25ZyGezGHPIAeUS3F5xL3WyKUCm9byDuU488788TiX19AS/aTSP59clQOLc/ 2OS2jpe7fhdeH/B9MGYC0SkWdCwyijocqV7W/ZljuDfQr34NTsAPK+oFxtkJOMA2Iijd kIobp4NyhDW+APAyFsem60ni95XcBFHFAkDAe4jSjUBeoQiuJR3AEMJu7xkcjrBG4T/w QcKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qKsK0qas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020aa7c646000000b005186bbbc652si587930edr.126.2023.06.12.14.08.14; Mon, 12 Jun 2023 14:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qKsK0qas; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237380AbjFLUra (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbjFLUqx (ORCPT ); Mon, 12 Jun 2023 16:46:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6809A211C for ; Mon, 12 Jun 2023 13:46:25 -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 ABCF0628F5 for ; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 143D4C4339B; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=Ks2BcB2HxSbBY7mPbJIjN33LPo2/4OOsJWgK+op14zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qKsK0qaswOjIPy/bfoiU2TOM1/2acMdTaVJYOdvnom0Yvol6riU4QsLoeVugqdzJd ytjj4vt8Zs/NSkQUQZ0cqq8s2ugQCzt0I02kbarHRczMelvrtC5C00E1Dh+S4sadFj loHr247JnuzICjBnjykJCDoYd/c1P0uUeA/BiuDfVufh1s1YbKL/nqCeU3sldQXakf HjpT3AJDXX44dDApGiDiSW7oQZUFZG+JoT1NTJROAmgJWAHftzC6+BUk60qN065crr yUacKFoSUeA5PETCpDvGWv98FFZXWYTzSNXeCgedrfEabEngh29Gbit/FY/OQsN4l8 61Kx7OOKqbAww== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id ACF14CE0563; Mon, 12 Jun 2023 13:45:15 -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 , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Paul E . McKenney" Subject: [PATCH v2 nolibc 02/53] tools/nolibc: tests: fix build on non-c99 compliant compilers Date: Mon, 12 Jun 2023 13:44:23 -0700 Message-Id: <20230612204514.292087-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532600175130039?= X-GMAIL-MSGID: =?utf-8?q?1768532600175130039?= From: Willy Tarreau Commit 9735716830f2 ("tools/nolibc: tests: add test for -fstack-protector") brought a declaration inside the initialization statement of a for loop, which breaks the build on compilers that do not default to c99 compatibility, making it more difficult to validate that the lib still builds on such compilers. The fix is trivial, so let's move the declaration to the variables block of the function instead. No backport is needed. Cc: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 47013b78972e..6f2f109569a3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -671,8 +671,9 @@ static int smash_stack(void) { char buf[100]; volatile char *ptr = buf; + size_t i; - for (size_t i = 0; i < 200; i++) + for (i = 0; i < 200; i++) ptr[i] = 'P'; return 1; From patchwork Mon Jun 12 20:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133716vqr; Mon, 12 Jun 2023 14:08:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lpUw2/yNNkdZo8fZN6QXm+gWLi3TJplGgjGoNjvFx1irUTQXrhHg1ouNVfGBfgovhsfny X-Received: by 2002:a17:907:a411:b0:96f:2315:29fe with SMTP id sg17-20020a170907a41100b0096f231529femr11400714ejc.0.1686604125564; Mon, 12 Jun 2023 14:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604125; cv=none; d=google.com; s=arc-20160816; b=tYOY6gf4I9A7TdYe1mP8sF7LumMnCvf7HLOh/pwJwaj+iwh8eN1PeaqB+0ERGOjt26 CJVg5Ap6vUCrxuwNQtR9ZBGvC7syUsJYbeXJNUQkejrQ7x1heZj/KoK6U45kDjalYsg3 XDrtVWPqzghZlaALwtFVOrBx4f+tUAgwLFxD80lNc7dlHKSitMJe3azqUoNhEJQBvbI8 NuPsPOS477ZQJZHRWE8Q3kwgwKRzR4luouNeG7oskQfDj1P6Ixm1xyi+bf87rnwcGWGN LObzKpnMgLWRxYxQeiYmt4J8Oh9PcRE6RzNkfqg54PMyBIfzCokqOPLKrYJrBk+iPNAZ QJ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OHT241zvkOlutA6+KSFghNG1/fK6MWuUr0tRcHACxo8=; b=wiVScU4SzsGkgrjMZXaUkYVUu7Mtp/jCGWZLCEh/srhsg5LFjxfPh9HkW23rm6m4ge EO9gPqLxi8ydBtodM9Oi9SJ3+nGQvVIwWdgTh/HF2h/SIQ/cpDaO0x5jT57AgKUG4nBt hLj9bdb8jHStdcQAI78bW7Zf43raEmlCvikl0TpwGGvybLbl2eLOgGtXEOm/NgHfy9hx jsbKXvw+xptkGvQdz7ZhwmN2EeZxS2vXqTQGFqK0v92WSfTGS5YusY0ipcZvZ+QeoIgT DB2cQNZFuJB1JONozmrMtFG1tJKAgeUfAQfjamCgUuVi14qoWj7WGG3AMQ9p1xvP2zmd r4lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqJAR6cT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a1709066b8700b00977e93c4e56si4518138ejr.684.2023.06.12.14.08.20; Mon, 12 Jun 2023 14:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqJAR6cT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjFLUre (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231896AbjFLUqy (ORCPT ); Mon, 12 Jun 2023 16:46:54 -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 73D651FC1 for ; Mon, 12 Jun 2023 13:46:26 -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 BD9CF62B14 for ; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22CFBC433D2; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=cN3q9iCF/gJ/uPtCwHUQPd6CHzRDYrNdYVOXcOrOK64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqJAR6cT6U5vORSu/lKpIHbxnWn4m/pIWbHlkeNzpTBxTFkJdovV1JOPilMWiMl1O duTEq89VRWTqGgBqAzCoFJo1UgJbtf91SlxQEzdtovckvGef3UrLFwxvnahYMEoBSo iCrWvfz0/pYDNZPsd7PvU40VZFk0bIOD0vdFTXz1/zcoUtF5+pY4EyrB9FkYSZAcTm jqjliWWDhhGei8kCVo27MVfhFfbBL1SCFi7/l6a0ttVs6eKb5VwMBD7qosMpjRB+MR f0NulZoYA2TplRnke1eXxQO7oUOUTfqzeDJDLpUDNledJVtK/FZvR7avJKgPirB7zu pZiuw0zReKz4w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AF9C3CE3A1D; Mon, 12 Jun 2023 13:45:15 -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 , Vincent Dagonneau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 03/53] tools/nolibc: fix build of the test case using glibc Date: Mon, 12 Jun 2023 13:44:24 -0700 Message-Id: <20230612204514.292087-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532607256202467?= X-GMAIL-MSGID: =?utf-8?q?1768532607256202467?= From: Willy Tarreau Some extra tests for various integer types and limits were added by commit d1209597ff00 ("tools/nolibc: add tests for the integer limits in stdint.h"), but we forgot to retest with glibc. Stddef and stdint are now needed for the program to build there. Cc: Vincent Dagonneau Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 6f2f109569a3..1bafbd8da6af 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #endif #endif From patchwork Mon Jun 12 20:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134356vqr; Mon, 12 Jun 2023 14:09:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ474TqDdLsZNC8ZbZiTZ+raR5rfgksAsPafdD5amalBpSiPG7/zgO7MWqyBt5czdlvb/xjL X-Received: by 2002:a17:907:25c8:b0:978:4d7c:1db9 with SMTP id ae8-20020a17090725c800b009784d7c1db9mr10388623ejc.39.1686604194007; Mon, 12 Jun 2023 14:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604193; cv=none; d=google.com; s=arc-20160816; b=Ha4BEUMRUOvOt3EKbQ8Twf+HK9cDYBiScl1cISKPr4yucXZm5/95Wz1e2HIdtXxCdr 7amlL9C7Whb5fC2UWP94KBO1K8iLQIa/5j8ijhVQ+YBbY+E+ajpVbXEVgaLkWqP/S61W QZFxpoa9XABk7NHSAh4iiCVP4WkY21zWvXCn1rHpiuL8qWrz1h/8i36e9+WcPJoG5EKR Xjgwct1s1Srfls3NFqnatdMvLSU2G28b9QqGWlcfl7P2fz2glz7WTYHvQGX7f7aba9Gg FlYAOZb6ZlxNaFVVdnU+1FSBGD/03Y6TCE5gcdcYWB6tkOn61XpG0VLQnJtifGtTaO9L e+6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qtX82d1rJQnhMsYGPeR74hOitr4ivHlngK9QrIw5Qtg=; b=wdHzwfEbO9YxbcP6r7X3GaqQhbupDHPoEYTgd6tjTXLBnol7KTjzuuPtITIpQLPFm9 fQXNvsJaY91gtQ4Zy5BgtA/32v2CF12C4GRHN1sPsIht0+DrLL19Jjl6TEHqz82HtGMb Tmor9hyWz2O9O4ZQoVRP+K9VW5RuCNvykoTjjqY5wVwuzTdTz0gyDXtcUBoFXZIl16z7 ubsLZX/Ur7oVB3CrE9eFR8FXm9vOLYiK9bZdeK7eIHMFbTSrcEEptqC8JhACzRV9D4UP zqsznIpMTLssiiTn+j/1GjymVWOTXhNG6+MrXk0UyZyb1ydosUVyqS6AxaicZhEhCFm1 BFLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a6fYIoJG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020aa7c991000000b00514bdde913csi6329182edt.215.2023.06.12.14.09.28; Mon, 12 Jun 2023 14:09:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a6fYIoJG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237269AbjFLUrh (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234860AbjFLUqz (ORCPT ); Mon, 12 Jun 2023 16:46:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9651FC3 for ; Mon, 12 Jun 2023 13:46:26 -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 D3D2C62B22 for ; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39158C4339C; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=C0Q9VdND465nWzuW7Df4EbGHS4KOUK1apvejVVAdFFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a6fYIoJGMAm3UTo2yCUg3fgy7OIk/4lbO/m4uQ+SBzI55BlWwzUSeTUQ+cGFjMAdj 44ZI6dKQ65olNT7ZqX4pTfbluehPWrbtlYjrRsei2mKkt9RctqwK4TD/vH51IYjBV2 BHPQiBJgrzivsCMsyrT5XyaJuBT2f2wAHec/mtlLxd4/awVHi4aXr3TdqzFJdqnAIq SF9WmLkwiIJcB8ubljzjIKj5Dos88OKP62o5nH1sC5IlgTmPxyk0fylzuVIytR3dIU mx/2S1gM5enhpoUd7TNnCTa7UNdVtgrmJ5GpBn0VcFPPOR0DhqUS2CLQv10yJPp/Ag cMiEj+pPyq9vw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B1F69CE3A1E; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 04/53] tools/nolibc: add libc-test binary Date: Mon, 12 Jun 2023 13:44:25 -0700 Message-Id: <20230612204514.292087-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532679401473608?= X-GMAIL-MSGID: =?utf-8?q?1768532679401473608?= From: Thomas Weißschuh This can be used to easily compare the behavior of nolibc to the system libc. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/.gitignore | 1 + tools/testing/selftests/nolibc/Makefile | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tools/testing/selftests/nolibc/.gitignore b/tools/testing/selftests/nolibc/.gitignore index 4696df589d68..52f613cdad54 100644 --- a/tools/testing/selftests/nolibc/.gitignore +++ b/tools/testing/selftests/nolibc/.gitignore @@ -1,4 +1,5 @@ /initramfs/ +/libc-test /nolibc-test /run.out /sysroot/ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index bbce57420465..0cbe13809b37 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -94,6 +94,7 @@ help: @echo " help this help" @echo " sysroot create the nolibc sysroot here (uses \$$ARCH)" @echo " nolibc-test build the executable (uses \$$CC and \$$CROSS_COMPILE)" + @echo " libc-test build an executable using the compiler's default libc instead" @echo " run-user runs the executable under QEMU (uses \$$ARCH, \$$TEST)" @echo " initramfs prepare the initramfs with nolibc-test" @echo " defconfig create a fresh new default config (uses \$$ARCH)" @@ -128,6 +129,9 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ -nostdlib -static -Isysroot/$(ARCH)/include $< -lgcc +libc-test: nolibc-test.c + $(QUIET_CC)$(CC) -o $@ $< + # qemu user-land test run-user: nolibc-test $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : @@ -159,6 +163,8 @@ clean: $(Q)rm -rf sysroot $(call QUIET_CLEAN, nolibc-test) $(Q)rm -f nolibc-test + $(call QUIET_CLEAN, libc-test) + $(Q)rm -f libc-test $(call QUIET_CLEAN, initramfs) $(Q)rm -rf initramfs $(call QUIET_CLEAN, run.out) From patchwork Mon Jun 12 20:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp127994vqr; Mon, 12 Jun 2023 13:58:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PfE0FvlZdkRNIAiBenWvRJu/vEJo0XocwxABlz2t6bHy6CL5SukEfHs8vNYyw7mMCMWso X-Received: by 2002:a17:907:d26:b0:978:8afb:d44c with SMTP id gn38-20020a1709070d2600b009788afbd44cmr11437743ejc.60.1686603482488; Mon, 12 Jun 2023 13:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603482; cv=none; d=google.com; s=arc-20160816; b=OBu0SdDJgi6t9ZyCyMfBUv/TpCPx0ejq3PqR8oiA3aKarZt+qBUSN3M0ftDbXmHvda BQfE5AcqdhLO38UnR64nsysqj2nvUY4qo2nnelp9hFeylltxeZ9ZRlSktQ8wVRQ1hNLJ 95RCgxFDe09OGioweaCFPze8HRD3F0/sgtPNQWoDnGbJ6zZdC+E2c4kBG8G2ZNssu0nO bdsNX1yStdYU2fhq9Dq0gOY4r8i8lzO3h9se4cL9TvDq+iA5OZM5L6nLhLyf2Zq7Z3ia Q3z/1ePd9CI82duY4Ivvt4/xDicXzra8cQKkXYshYaZPilQVewChud4xZuph8z3K2sm/ VniA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Qg5hqnmrujkQwO1a6DYPNVUEUnm/D9meTahyHyDFLbg=; b=XaFsi13C5xWpKrr0QQqsQGu58Gdu9EAiURmW0j/2qetTvvb28HaAyoxfvlipE+QRH9 uOY+YYL6orOxVbgut5FxK8Y9nlhVTd/rlfukYEZ25xftF2AFVbw5UycbakDxiNsnXTp/ o0vhQr+q0BsAT2UEGrV0LPeG0fq+RIDAfB5ceKZRJjnQnbubqNAMrMOp3IYXoO3uD2Xx 1HXgqrChpa0kJCLUSAQNoxhhY+cdpEx13vq5ZpioBJJ9gGYJKoe9mW4p8IyJMVEz/H7P 60S/sLc93tox3dn0Bw+nH7UaIqOQKznV9p+/s8a/hzkWGCu2B7tr9JQJMNv/Zuu3cMjx HqtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IIyRNxNo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020a1709060e8900b00977b1ea9134si5723609ejf.106.2023.06.12.13.57.39; Mon, 12 Jun 2023 13:58:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IIyRNxNo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237659AbjFLUrp (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:45 -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 S236764AbjFLUqz (ORCPT ); Mon, 12 Jun 2023 16:46:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BA202127 for ; Mon, 12 Jun 2023 13:46:27 -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 D954B62B2F for ; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43409C433A0; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=thHRx3gNkEts77+ULbTuRFI/XccuwcFtR++swDbxeA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIyRNxNo1pgSe1Dn8b4snZ4lkloc99dpMH5LjxJD09XIZhMLinvsM6aCNqRkPudK9 iDAHvmG/6AKVDvCEEaoOihPjy7/15YbJKo4UJZPLk7qLz+EiR8cQPCqWNhs9VJNq+M DyC7HuB7mg4tENGb/XCHuiAB+yKXtEqsEZQWHFlX5zivcdMriGnVO38bKHjKAsLIx+ e79wp1RiRUOc06c36NOCJQ2nwemqKeTseG/dIYgsTkeYKnFuEGNW2iSm/HGVqP5Jbi a0JhheIZMYY77d+ZPR6ysl8Z43aBXyTMPusrR4QclpuA9gvqlDq7ydPOiWtvdQmID4 wFvHN6MFlWm0g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B4267CE3A22; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 05/53] tools/nolibc: add wrapper for memfd_create Date: Mon, 12 Jun 2023 13:44:26 -0700 Message-Id: <20230612204514.292087-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531933345847352?= X-GMAIL-MSGID: =?utf-8?q?1768531933345847352?= From: Thomas Weißschuh This is useful for users and will also be used by a future testcase. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 5d624dc63a42..bea9760dbd16 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1365,6 +1365,29 @@ ssize_t write(int fd, const void *buf, size_t count) return ret; } + +/* + * int memfd_create(const char *name, unsigned int flags); + */ + +static __attribute__((unused)) +int sys_memfd_create(const char *name, unsigned int flags) +{ + return my_syscall2(__NR_memfd_create, name, flags); +} + +static __attribute__((unused)) +int memfd_create(const char *name, unsigned int flags) +{ + ssize_t ret = sys_memfd_create(name, flags); + + if (ret < 0) { + SET_ERRNO(-ret); + ret = -1; + } + return ret; +} + /* make sure to include all global symbols */ #include "nolibc.h" From patchwork Mon Jun 12 20:44:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133634vqr; Mon, 12 Jun 2023 14:08:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7GAQAmA4Ydm2WxR4HJSkkELKsz0vwH2tKRXkxKyUwYkEG2ArIgJjpBedcW6dEjRTZJiBTe X-Received: by 2002:adf:f347:0:b0:30a:f17e:e02e with SMTP id e7-20020adff347000000b0030af17ee02emr5068891wrp.12.1686604118203; Mon, 12 Jun 2023 14:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604118; cv=none; d=google.com; s=arc-20160816; b=GMZDV9yHOr6okgGPknc5HQTvvAWRR94uEfEJGTbFy+gbXdXN0re3kpZK6kk0TMML23 GxbeAGOF/jGpw+qF+LNd3VZtdr0MNlZ12q/SVhlmEXdbiAhFqaXaL7oJecb55WFw411J ui5P05MIJLti72JIyxHisP/1Dv3YTlZy8UeO0comhOx5tNiezASfdG+jsb5Bl42bJYa4 4wQZiS7Z5mrhxaSu8ZRVHRrdDAYQQaE9qn3jFym02QMlu0+1mVgfQS+x9d2bgDdLFhiO VvtxaJJ4vFiaGhYFP5pWp/6LqYOjN/WL0KpJK51XkesOr7PQIE6AanYUGthKitr8bR+x u0pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MBDyH0avwN7cugGG//zPsiBIWcnRsnySk+LTa7PXW5g=; b=LMxNBz1YYxL5cieja60unpTSdfGaeAv+dfKL2CIYsI7/uMgbWPcbHq6/A0x3nHtyw7 hw13d6mN/VjDY3IKJuc1CQpXC9tYDvy9JV2P6Ga3oUy8yuTFgmke/H3LRRx61WGEhZSA YAjou0MJ1qkLeBH7OrqLfEVwa1M2scHZRAqG4bdKsJcLZwZxyXwMIX0KjJLWw8oFMiLm Jnev6MD3/5Il/9F7HCr5leRxfOZEhZaVGEfXZrYjbAAgkFo68VL3kUGMuCsEwkNU/EUW ImuhpOxF8nnNPkjbELFRR3GHkryocCskxv5KFBIkllc8oVopmBaP/KNS5omvRvXDNjYr GR0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PmeopVKP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020aa7c983000000b0050b3832871csi2024268edt.200.2023.06.12.14.08.14; Mon, 12 Jun 2023 14:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PmeopVKP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237611AbjFLUrl (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236810AbjFLUq4 (ORCPT ); Mon, 12 Jun 2023 16:46:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC8D2212D for ; Mon, 12 Jun 2023 13:46:27 -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 3A5D862BE6 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66E8EC4339E; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=fkkJpit5a3ZlIC5i/D5UeQi47Yy3csUMhtA5gdos6Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmeopVKP2WJ1NEq6kcgJClk7k0JMV+ne7n8eOyk24uxhoBlYQ6lwWJyLOvbrsm/91 cnNp9KRqzC7cWHAldCR8BbCGoFTukelLxJ8Em6+4Z8pshSIbpXYAYaXW6anrqAuPo/ GbDgEF7AvgY0ufDwZ+UEhqf3ks2Qo9Ws8yNnb+VL2Sc6EndEHEuywqDCGfeUJdMBpc 6B32RYs+Qe+8rp5cQCUHzlcRzzQVlvAG2qxC9q2/f/HHGfg+tETPFqyeBKhe9f2vvL EA+osJnQcCeSSUdqEXgXVCnFPH5/fjIJRdLo3kRs0zGKJLcnu94qklxGvJ4zSyntcT jUTR6N2nvuCrg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B65BECE3A3B; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 06/53] tools/nolibc: implement fd-based FILE streams Date: Mon, 12 Jun 2023 13:44:27 -0700 Message-Id: <20230612204514.292087-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532599807624968?= X-GMAIL-MSGID: =?utf-8?q?1768532599807624968?= From: Thomas Weißschuh This enables the usage of the stream APIs with arbitrary filedescriptors. It will be used by a future testcase. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/stdio.h | 95 ++++++++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 27 deletions(-) diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index 6cbbb52836a0..0eef91daf289 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -21,17 +21,75 @@ #define EOF (-1) #endif -/* just define FILE as a non-empty type */ +/* just define FILE as a non-empty type. The value of the pointer gives + * the FD: FILE=~fd for fd>=0 or NULL for fd<0. This way positive FILE + * are immediately identified as abnormal entries (i.e. possible copies + * of valid pointers to something else). + */ typedef struct FILE { char dummy[1]; } FILE; -/* We define the 3 common stdio files as constant invalid pointers that - * are easily recognized. - */ -static __attribute__((unused)) FILE* const stdin = (FILE*)-3; -static __attribute__((unused)) FILE* const stdout = (FILE*)-2; -static __attribute__((unused)) FILE* const stderr = (FILE*)-1; +static __attribute__((unused)) FILE* const stdin = (FILE*)(intptr_t)~STDIN_FILENO; +static __attribute__((unused)) FILE* const stdout = (FILE*)(intptr_t)~STDOUT_FILENO; +static __attribute__((unused)) FILE* const stderr = (FILE*)(intptr_t)~STDERR_FILENO; + +/* provides a FILE* equivalent of fd. The mode is ignored. */ +static __attribute__((unused)) +FILE *fdopen(int fd, const char *mode __attribute__((unused))) +{ + if (fd < 0) { + SET_ERRNO(EBADF); + return NULL; + } + return (FILE*)(intptr_t)~fd; +} + +/* provides the fd of stream. */ +static __attribute__((unused)) +int fileno(FILE *stream) +{ + intptr_t i = (intptr_t)stream; + + if (i >= 0) { + SET_ERRNO(EBADF); + return -1; + } + return ~i; +} + +/* flush a stream. */ +static __attribute__((unused)) +int fflush(FILE *stream) +{ + intptr_t i = (intptr_t)stream; + + /* NULL is valid here. */ + if (i > 0) { + SET_ERRNO(EBADF); + return -1; + } + + /* Don't do anything, nolibc does not support buffering. */ + return 0; +} + +/* flush a stream. */ +static __attribute__((unused)) +int fclose(FILE *stream) +{ + intptr_t i = (intptr_t)stream; + + if (i >= 0) { + SET_ERRNO(EBADF); + return -1; + } + + if (close(~i)) + return EOF; + + return 0; +} /* getc(), fgetc(), getchar() */ @@ -41,14 +99,8 @@ static __attribute__((unused)) int fgetc(FILE* stream) { unsigned char ch; - int fd; - if (stream < stdin || stream > stderr) - return EOF; - - fd = 3 + (long)stream; - - if (read(fd, &ch, 1) <= 0) + if (read(fileno(stream), &ch, 1) <= 0) return EOF; return ch; } @@ -68,14 +120,8 @@ static __attribute__((unused)) int fputc(int c, FILE* stream) { unsigned char ch = c; - int fd; - - if (stream < stdin || stream > stderr) - return EOF; - - fd = 3 + (long)stream; - if (write(fd, &ch, 1) <= 0) + if (write(fileno(stream), &ch, 1) <= 0) return EOF; return ch; } @@ -96,12 +142,7 @@ static __attribute__((unused)) int _fwrite(const void *buf, size_t size, FILE *stream) { ssize_t ret; - int fd; - - if (stream < stdin || stream > stderr) - return EOF; - - fd = 3 + (long)stream; + int fd = fileno(stream); while (size) { ret = write(fd, buf, size); From patchwork Mon Jun 12 20:44:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp125108vqr; Mon, 12 Jun 2023 13:50:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qs5L09Ww6LUsB+iQtwKK8Qz7phmOwAusVA77SGJYlr7v0Hijev6HX1RWAkiV7LmVWK5wF X-Received: by 2002:a17:907:9496:b0:96f:ab92:aed2 with SMTP id dm22-20020a170907949600b0096fab92aed2mr9825133ejc.58.1686603008067; Mon, 12 Jun 2023 13:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603008; cv=none; d=google.com; s=arc-20160816; b=MzQ83XcAFsnnFZ0WXzMOM41zMTFFAZyUmrRQnpZcTrZ/fa+WGVwx6zHIBmNRLGoW89 VESj1es3UrQkpAbnYCBOHABxTVi5uAaZncM1d3J15qhTX2t2OEBYhkxmuZf/egXFLXmz GCa7+r+TmkVMzYa3nX7UjvgloLCh1q8rG2Y4WUe4UUY3mmiG4TwlftbGZBrsc8fr/fdW 9X11xAxItxg6tleV8Isg/WWgVSOGMnp2D2gcnFohLaLUrifn7LFPBBfX0AqNvhc8FzX1 a9P6Ou7cFxvgGym2Z4dDK4fKnEPRitEJlnlqDdcsmkcosFCsnRZ+rsgQIX/a0zN9s2Ht kf5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MjOYl2zEtcL5/OiYzzz0OaFOmscGAYNCUZZLv9wU5J4=; b=dIX19cF1hAH7wMbJ0WGUtOBJPwbnEYVI9TuUNd7A6/EFIOMfqlra9YTx2WUGPxIuQu GV4JNELVb8HJTKqQg+3h+xqT3pvnitP6mcTD55X/IA44E84fD6SJ0FPuDZGF+HiMZWaR FjFIf+EVevAD6R5gaJZl4N8hrIccWqWziPENlrVs+GyA/8JXsnKIJfW8XzUzztv2D0Pv sWxKwfblO6lr7vab/HYgpFU8nT59QzQG1S0rOggP5u22qXw81pUss+9Ov4SOhZQpTv7S AMq3oHKydDFijlqBkzf/MBp/zURqbmGIJajdZ5BuA4Aqvc+r8LUZwiUM8i6vePYcBpc0 J19w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UKi7Ip0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020aa7d981000000b00514a451f868si6515700eds.251.2023.06.12.13.49.44; Mon, 12 Jun 2023 13:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UKi7Ip0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236860AbjFLUrx (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbjFLUq5 (ORCPT ); Mon, 12 Jun 2023 16:46:57 -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 96125268A for ; Mon, 12 Jun 2023 13:46:28 -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 4C19662E51 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B0AAC433A7; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=gpgpcEtunmdu9Bwe6EgvPNpLf5lDxIDNN1gL/ShrEz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UKi7Ip0YKj3ZCMbDJ6qFgh7yQ1pabyK6igSPYEUX1TvERq8WM1fdqzMMVZobOyU4W qFVLkTH7HZv/uhFztJitULPsa5203YsV3xYKJD5pq35Xsz0g58cRcY+J3kBL37Q9gp WgjpUd2Xj57QjBvbhfFDDyOxSe+EksgLdYBus8NJQk4giUqyuisKnZIzzmiJhh3/DT rK9tIJ2+I072wuaJHeVsG6S9d7G+R8wPk7Sqks86CKMGjLBvKvYhGdW5IGR53mOb23 asYAXtlqBP++m/fjkA76taODg0ObJehQ3PVOrUqiW5gtKWIRedwVmE0FbtIMIQ4bnn RzGPZIDjuV+Iw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B888ACE3A41; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 07/53] tools/nolibc: add testcases for vfprintf Date: Mon, 12 Jun 2023 13:44:28 -0700 Message-Id: <20230612204514.292087-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531435770538626?= X-GMAIL-MSGID: =?utf-8?q?1768531435770538626?= From: Thomas Weißschuh vfprintf() is complex and so far did not have proper tests. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 86 ++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 1bafbd8da6af..888da60eb5ba 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -669,6 +670,90 @@ int run_stdlib(int min, int max) return ret; } +#define EXPECT_VFPRINTF(c, expected, fmt, ...) \ + ret += expect_vfprintf(llen, c, expected, fmt, ##__VA_ARGS__) + +static int expect_vfprintf(int llen, size_t c, const char *expected, const char *fmt, ...) +{ + int ret, fd, w, r; + char buf[100]; + FILE *memfile; + va_list args; + + fd = memfd_create("vfprintf", 0); + if (fd == -1) { + pad_spc(llen, 64, "[FAIL]\n"); + return 1; + } + + memfile = fdopen(fd, "w+"); + if (!memfile) { + pad_spc(llen, 64, "[FAIL]\n"); + return 1; + } + + va_start(args, fmt); + w = vfprintf(memfile, fmt, args); + va_end(args); + + if (w != c) { + llen += printf(" written(%d) != %d", w, (int) c); + pad_spc(llen, 64, "[FAIL]\n"); + return 1; + } + + fflush(memfile); + lseek(fd, 0, SEEK_SET); + + r = read(fd, buf, sizeof(buf) - 1); + buf[r] = '\0'; + + fclose(memfile); + + if (r != w) { + llen += printf(" written(%d) != read(%d)", w, r); + pad_spc(llen, 64, "[FAIL]\n"); + return 1; + } + + llen += printf(" \"%s\" = \"%s\"", expected, buf); + ret = strncmp(expected, buf, c); + + pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); + return ret; +} + +static int run_vfprintf(int min, int max) +{ + int test; + int tmp; + int ret = 0; + void *p1, *p2; + + for (test = min; test >= 0 && test <= max; test++) { + int llen = 0; // line length + + /* avoid leaving empty lines below, this will insert holes into + * test numbers. + */ + switch (test + __LINE__ + 1) { + CASE_TEST(empty); EXPECT_VFPRINTF(0, "", ""); break; + CASE_TEST(simple); EXPECT_VFPRINTF(3, "foo", "foo"); break; + CASE_TEST(string); EXPECT_VFPRINTF(3, "foo", "%s", "foo"); break; + CASE_TEST(number); EXPECT_VFPRINTF(4, "1234", "%d", 1234); break; + CASE_TEST(negnumber); EXPECT_VFPRINTF(5, "-1234", "%d", -1234); break; + CASE_TEST(unsigned); EXPECT_VFPRINTF(5, "12345", "%u", 12345); break; + CASE_TEST(char); EXPECT_VFPRINTF(1, "c", "%c", 'c'); break; + CASE_TEST(hex); EXPECT_VFPRINTF(1, "f", "%x", 0xf); break; + CASE_TEST(pointer); EXPECT_VFPRINTF(3, "0x1", "%p", (void *) 0x1); break; + case __LINE__: + return ret; /* must be last */ + /* note: do not set any defaults so as to permit holes above */ + } + } + return ret; +} + static int smash_stack(void) { char buf[100]; @@ -777,6 +862,7 @@ static const struct test test_names[] = { /* add new tests here */ { .name = "syscall", .func = run_syscall }, { .name = "stdlib", .func = run_stdlib }, + { .name = "vfprintf", .func = run_vfprintf }, { .name = "protection", .func = run_protection }, { 0 } }; From patchwork Mon Jun 12 20:44:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp125110vqr; Mon, 12 Jun 2023 13:50:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45YZe6o3/loAQvuPQlYOhs6IKDig1mCGc4hfE3N06Ga7PF5s7Rp3iQEdADwjdgvtFeSv3S X-Received: by 2002:a17:906:da87:b0:96f:6a03:eca with SMTP id xh7-20020a170906da8700b0096f6a030ecamr9884171ejb.48.1686603008426; Mon, 12 Jun 2023 13:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603008; cv=none; d=google.com; s=arc-20160816; b=oCmWe9/43x9LokkbbU52Wj+XiFXIFZAvBtc8NOQXzzLKF2MFSOuXoPvqoDaNRbIUJP ztZIUmUF/5aHuWeXBmZp4z3LnIQVcGD9Eu9icbMTCsPp7S4hbg2gxDvQP93oUHkZ4PmG b+SGIgfwxEcE/IyXLY2OzwItiI6JwVuo/1MjrknK8HgpPOcna2vw8uLM0kXhq+yCeF/p xAiMikjQZljv0e7nLlgcChuKpVMOGlgvdjTd5VuZvfmf57Olh4z/cegH/M+sRbuNIYaQ 5Q2ER5I98QhSMENwemj51FU3Ku9bUsKspjRxmNaNbsnooIW2wJiLJuTJnI3KFF0nbrZZ yjiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lA3naiIT1jaezK3UWGwsoluPd+OQ/o8fYh4ENuDdSCc=; b=Jbtsafq2QIG5WjNYsEMhg7+2bCiPZuNj20Uy0dOLTIgSjIn49aH2W3q5mlTd2K67ZV bQBJd4XciVfRzuMjuo8bO5tAzNdyM9kXZIrVNlIP+ml7xwtjgDtpcRoIsQpWre5JOkU8 B2C+4+KlGNgNmWxMIWErpjKXDYxNQo0rugC784+XwHsbgSxupRhXx7CRr9LP2mVFQAGJ qp+SOGm2QK6hHdzb5epO66uHrVoP/0WjmYbktXsqHB5gzBpRwYo1nBoxJ1voxrxxE6ts 52g6ooWDFStG5LuUZIJ+gA52CCj6+xHOXk139xDOF16R5868/ax88AYrQOGm8dzG8DIo /ctQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U9vW3AFR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170906a09100b0096f4deef5basi5999008ejy.649.2023.06.12.13.49.43; Mon, 12 Jun 2023 13:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U9vW3AFR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232667AbjFLUrt (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235728AbjFLUq5 (ORCPT ); Mon, 12 Jun 2023 16:46:57 -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 339642136 for ; Mon, 12 Jun 2023 13:46:28 -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 488AF62BE7 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B055C433A4; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=jzpYLjEQ1FslRejmeBHfDXFdJyRjrM8plGg590LqYRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9vW3AFRclszObUvNLAm+ePi9P+liWKoXayNX7uV/LvNTgdPic7sz0zzwoKP3V9I9 tBJE2YMEPnZoXJ2VrFlmmxhqYHX1ZQ7BtLnmAyOxDDquFieMvXFhmkTRaZdtCH1P/2 fNnd5K2xvnS9tN3y17DR893eJ5t1ZnaHvWfh4/8tA9ielv3sAwgvEj6L8VMIVU4dKp Vl72HWnUiz5nyD8gH+Zm4idD5T7jmDhEtsj1yvvtVu2JiqQeELU4qvn1s4ptWEz+gE dMsd9dstt9OT8p3CrM5L3C3CAZQMEMJmCHe7fHcDgqrfZLiPGsHHlfLYoidMtD2HMC e8N4f5Sj7g6JQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BAB9ACE3A42; Mon, 12 Jun 2023 13:45:15 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Mark Brown , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 08/53] tools/nolibc: Fix build of stdio.h due to header ordering Date: Mon, 12 Jun 2023 13:44:29 -0700 Message-Id: <20230612204514.292087-8-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531435889470000?= X-GMAIL-MSGID: =?utf-8?q?1768531435889470000?= From: Mark Brown When we added fd based file streams we created references to STx_FILENO in stdio.h but these constants are declared in unistd.h which is the last file included by the top level nolibc.h meaning those constants are not defined when we try to build stdio.h. This causes programs using nolibc.h to fail to build. Reorder the headers to avoid this issue. Fixes: d449546c957f ("tools/nolibc: implement fd-based FILE streams") Signed-off-by: Mark Brown Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/nolibc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 04739a6293c4..05a228a6ee78 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -99,11 +99,11 @@ #include "sys.h" #include "ctype.h" #include "signal.h" +#include "unistd.h" #include "stdio.h" #include "stdlib.h" #include "string.h" #include "time.h" -#include "unistd.h" #include "stackprotector.h" /* Used by programs to avoid std includes */ From patchwork Mon Jun 12 20:44:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp125119vqr; Mon, 12 Jun 2023 13:50:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KCIW7m5cEsCGVeXgMEK/9Xm7knef4GEfma4UnI/huWVjI2rXGHhlLGo9PjSCux6gBdLxw X-Received: by 2002:a05:6402:44d:b0:510:f462:fc47 with SMTP id p13-20020a056402044d00b00510f462fc47mr5880014edw.7.1686603009688; Mon, 12 Jun 2023 13:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603009; cv=none; d=google.com; s=arc-20160816; b=yHg2v22QUX5UD/gQ8CPHo8LNGoA4x0ysNwS+aXGZ5hQ7uoUNq/yPxZmkpRhPExk9x8 9fBtRR55xEuKNp5ZymeTpcaI/9Ac6TDgCSv81MzZzal406MWITHgFOJ/20ukSec3ShJO DjbUf1OF+Aj0s4ApmTkgRDZFiUytLlHJgDsQX0eBwXA2XBVhqIipgnB3ybX4OMHBEsgy QNt7qV26HIJfneW9osAWcaZxPXu2kxPGpi2rv8PV+IUO+OPVPayQiIkLxwsIJKGbmmgQ Km6/YhCfpX9wXFEj7nfkuvnT4u6OYukVPC+ZOadlqzsyuXluqtTHS7bEOn1y8M5vWDWs yl3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Peq3hixOqMcxkMOcrbfoNUG6Iq6VZyfPpUX85pucqBw=; b=nWyEMDt3J9m0fDieBEd8W2IMfWNqsKtJ4GpiFNSuoC8vXJ/YoZaBGc8i6s0ZaTrOrF PUQ4Rs6T3vRcWqdWVtsXhEA+Wyj5cvluye28Q9G5Cd5Y99JjE5hAIbcnRKXjkcRizLKG DmErz8S6xRFplcSfpKvM/qgII2tgNF+M22XtzINBQb38QO3bQm305mMpGwWwtf+cBbSC KLfIN1KBi4Vno9+/WERBRw6TZD0eN3eceznCUJViuOgoh5gFNLCSKoBG9Kuy+YTSn5qe qx+8gKdoJnoeODk2yqzlSsEo/tuCv9tUuILQDuPgcsOvk35KkrqLyffiVZZZv8/LcFWt /wfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iVs7ROr0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a50e603000000b005186d996d0bsi417463edm.376.2023.06.12.13.49.45; Mon, 12 Jun 2023 13:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iVs7ROr0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237769AbjFLUr6 (ORCPT + 99 others); Mon, 12 Jun 2023 16:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236284AbjFLUq5 (ORCPT ); Mon, 12 Jun 2023 16:46:57 -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 A1B5B26AD for ; Mon, 12 Jun 2023 13:46:28 -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 5155462E42 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D848C433A8; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=gd5sfN1vi5rnkiQ19By4Dp4+vXMweeEIcbPWx+T5fUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iVs7ROr0TZZJk5hr4p7bgRe7Ixi61cLbu+KRjwMiHHTow/NC+eOTRiyA8L5Jt/Wl7 b16b2/iOAaHRDgCCRdAwcJ3fObzTGPrkJX5QugC2mQ8XHdvXGw5oVm5DPfy7/W/WqO nBM2PR0TFpfs35JkZvRYTijzun9NnHmKTScDWeuldOVRecI1Y9uCYmOAJ3JI/OlJgW TzQuYe3l7iG9fUrnGVr/inL+csVTq6ixmZhCKaOzl5E5B1cJDWv+hhv7gcNv8lSAdi MvjBDBqSYW6ZTj+AFRZ+vB0pKWIO9hDRZPeoeStrFEMHilbHEtgG3C8GhEefLxHZtE oACspl2wu0gsw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BCFA9CE3A49; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 09/53] tools/nolibc: use standard __asm__ statements Date: Mon, 12 Jun 2023 13:44:30 -0700 Message-Id: <20230612204514.292087-9-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531437468660799?= X-GMAIL-MSGID: =?utf-8?q?1768531437468660799?= From: Thomas Weißschuh Most of the code was migrated to C99-conformant __asm__ statements before. It seems string.h was missed. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/string.h | 4 ++-- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index fffdaf6ff467..0c2e06c7c477 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -90,7 +90,7 @@ void *memset(void *dst, int b, size_t len) while (len--) { /* prevent gcc from recognizing memset() here */ - asm volatile(""); + __asm__ volatile(""); *(p++) = b; } return dst; @@ -139,7 +139,7 @@ size_t strlen(const char *str) size_t len; for (len = 0; str[len]; len++) - asm(""); + __asm__(""); return len; } diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 888da60eb5ba..e692be98973a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -984,7 +984,7 @@ int main(int argc, char **argv, char **envp) #else else if (ioperm(0x501, 1, 1) == 0) #endif - asm volatile ("outb %%al, %%dx" :: "d"(0x501), "a"(0)); + __asm__ volatile ("outb %%al, %%dx" :: "d"(0x501), "a"(0)); /* if it does nothing, fall back to the regular panic */ #endif } From patchwork Mon Jun 12 20:44:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133583vqr; Mon, 12 Jun 2023 14:08:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4lMMlb3chiKGhMkdr8nUwPdSFBXORJ6QyCr1dezN/V+Wqs22eXkyxCAS1pA5DnNqWQyfc/ X-Received: by 2002:a17:907:36ca:b0:978:6b18:e935 with SMTP id bj10-20020a17090736ca00b009786b18e935mr9351277ejc.23.1686604111644; Mon, 12 Jun 2023 14:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604111; cv=none; d=google.com; s=arc-20160816; b=VlHwUZRd8+4YkihwPXeViin9QYAGDRiTAgRmcOinV2wqVMseN2ntvhXs6MXl3tDi6S EdTu6aLuZFXhLNebqES3Kjomikk+8nJMlnDomWrIYtEx6X2D8S35+BxXjiobU/pW0xtH mCR4rE1/1+sSlp7EfwgELlqq0qqp3Kn9Vhf6kutcGpEtmIdhqerldozwez3903d7QsgD 4ilGhnjJRdU5pAO8pQVyKrZHAnMhGQR5TptamWLUKjKMsw6V5AscYMLiWQFDYmbQj2SX KfiTQ6gExkrLYuhOzXfUC0LY3IUJIOVnbuQcYf+0eNeDcIDmJiTRRmPCwpuzr8cmE7js W3Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+M6xhIg80P+7up9n7ifgblJD/7YwijlTtK4fmxb6qjs=; b=qrBPuSltgME3TNfrMCrXUqvvftZDpfQrJnjQAwDoW+4nvx13zJuw3o5AguWmpp/mTL 4zuqadOpBlXI491Ay6E+eTUGTBSogw1m1wPOiQSA6/Tk1nyDB2OBlrmVUKqii+dn1/qt kKOnVJlngv2M7eoRpRR0PX97wJcHH+B0DXcdMgRwZOKPih6bDHjtFwRLFsDSEB38qh8l 7eYD9fNxOUiTxpX6v2Q+O3qkqyz/ZzJKKHABDIisu46RDLBM6RYaDUhez05JxuySK8w3 AUVkbAAiSHvBfYklQZ7ojay/DToHil2Qlb5p7/R78B+OT95+d4395lL8B5jFsf1ev7WF l1Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZ+mTlhm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a1709061cc300b0096f57693a81si5696251ejh.566.2023.06.12.14.08.07; Mon, 12 Jun 2023 14:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZ+mTlhm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237776AbjFLUsB (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235868AbjFLUq6 (ORCPT ); Mon, 12 Jun 2023 16:46:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E823426B0 for ; Mon, 12 Jun 2023 13:46:28 -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 5D72B62ED6 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86B58C433AC; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=rJ8Zak39w7CtOYLtgafcmk/YeBO+i/iIqJ6y3UtNwdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rZ+mTlhmRBd5hNyKaf7X0M7PtkE9osT1W3pDsVzygd+Y85/ftwauPhtnHoEPchJ23 BkGL6D2G/c93qHi1+iP5M5Lcq9dBmlqwS9YgyX3wT14sitm4sLLF+zdzntyjKUdkmu a4DHtrvFaGCJub0ze1hqiwDnmFphwxRuvLTKQ0F+r3/6WT6uV+7sNms5K2fri1M8FI rZP97iDAR9LsYNQ0tDjExteIbyoktZSH3v7kVwCZZ+cpfJAoDK9aHVqedsMsIf74Bp dUEUBHrUg4Goe4rpw+R0Y0qB6oikvybpC1QwDjk9dTgyGL4K9+EJJzKkqrbyXcNtUW CjRNae30NWuyg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id BF3B6CE3A4B; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 10/53] tools/nolibc: use __inline__ syntax Date: Mon, 12 Jun 2023 13:44:31 -0700 Message-Id: <20230612204514.292087-10-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532592935674094?= X-GMAIL-MSGID: =?utf-8?q?1768532592935674094?= From: Thomas Weißschuh When building in strict C89 mode the "inline" keyword is unknown. While "__inline__" is non-standard it is used by the kernel headers themselves. So the used compilers would have to support it or the users shim it with a #define. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/stdlib.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 894c955d027e..902162f80337 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -102,7 +102,7 @@ char *_getenv(const char *name, char **environ) return NULL; } -static inline __attribute__((unused,always_inline)) +static __inline__ __attribute__((unused,always_inline)) char *getenv(const char *name) { extern char **environ; @@ -231,7 +231,7 @@ int utoh_r(unsigned long in, char *buffer) /* converts unsigned long to an hex string using the static itoa_buffer * and returns the pointer to that string. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *utoh(unsigned long in) { utoh_r(in, itoa_buffer); @@ -293,7 +293,7 @@ int itoa_r(long in, char *buffer) /* for historical compatibility, same as above but returns the pointer to the * buffer. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *ltoa_r(long in, char *buffer) { itoa_r(in, buffer); @@ -303,7 +303,7 @@ char *ltoa_r(long in, char *buffer) /* converts long integer to a string using the static itoa_buffer and * returns the pointer to that string. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *itoa(long in) { itoa_r(in, itoa_buffer); @@ -313,7 +313,7 @@ char *itoa(long in) /* converts long integer to a string using the static itoa_buffer and * returns the pointer to that string. Same as above, for compatibility. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *ltoa(long in) { itoa_r(in, itoa_buffer); @@ -323,7 +323,7 @@ char *ltoa(long in) /* converts unsigned long integer to a string using the static itoa_buffer * and returns the pointer to that string. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *utoa(unsigned long in) { utoa_r(in, itoa_buffer); @@ -367,7 +367,7 @@ int u64toh_r(uint64_t in, char *buffer) /* converts uint64_t to an hex string using the static itoa_buffer and * returns the pointer to that string. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *u64toh(uint64_t in) { u64toh_r(in, itoa_buffer); @@ -429,7 +429,7 @@ int i64toa_r(int64_t in, char *buffer) /* converts int64_t to a string using the static itoa_buffer and returns * the pointer to that string. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *i64toa(int64_t in) { i64toa_r(in, itoa_buffer); @@ -439,7 +439,7 @@ char *i64toa(int64_t in) /* converts uint64_t to a string using the static itoa_buffer and returns * the pointer to that string. */ -static inline __attribute__((unused)) +static __inline__ __attribute__((unused)) char *u64toa(uint64_t in) { u64toa_r(in, itoa_buffer); From patchwork Mon Jun 12 20:44:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp125197vqr; Mon, 12 Jun 2023 13:50:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VI9rTxM0HuiD9jRiycCRFUMhizA+rDLy4ecEpk0pQdG4peCbsnEYIuXm+kn3PknOfaEq9 X-Received: by 2002:adf:f782:0:b0:30f:bdac:4447 with SMTP id q2-20020adff782000000b0030fbdac4447mr4001595wrp.47.1686603020783; Mon, 12 Jun 2023 13:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603020; cv=none; d=google.com; s=arc-20160816; b=W8M2xiclKF4QL8UnDC5zEllIRLJtvcFCnX7wL6es9Lzoyp6ku0EAGksOn6r14lx2Wg r9is4jVJ9ML1xwGS5xoY2stWllZ/lCs9pQrtyIXiXg340iaA02cpZ2CQtZ4kHQrXtr+u ROqWrQ/5XLUMWZXvr5iL08TgFb5Nu9p4u0PkA3JnZTocTZV5Jmq3Ldv6ACW5I70lSAeo ClqIL3RgDbRlFPSASZvlVbuU48cxhF/vdmVirJL30f9ohC96gFO70p2FN99vP8QidBHe 8VupGe7v+AbRjPRMkRpJmeXsEjPGlxMaf4jfFa0iActNqxxB2iOhU8uAFJsKmWO2fG05 CN/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lN9bcksUKqsPPSLazzZrq1EQtNTuSGE+cKg6z4wUjj0=; b=HD5sR0lnTCftNFDjuBb/V/h85H744wxEVLsCtmczLTZK7meLjFsUFSdds1WaIjjN7l K6tVP7W9u0WpGthvvol+5hQgCrUEzyppqzNNKEsW9T+HNrsfJnjCxZAr//o3MvDd3t+N B6+YhADEVu1/zxUpdomFN11xQh2ULqm+jySeNxVgvcw7kOPMvvWOCkEHFvet/jxTVITC THsyaN4myKKDMx53oxdojssEhs9RWfYXEwjPLXV9kXIUINuv8MnUVzolwRC/Wf3Ws/i3 yJUck05glwxHhksoUQN/XGZXOxqn422Xvc03e2kCiGGLGcu5d+1EN80YgYPzQ773E8Gh jq9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lBdMI4IE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020aa7c646000000b005186bbbc652si566872edr.126.2023.06.12.13.49.55; Mon, 12 Jun 2023 13:50:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lBdMI4IE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237637AbjFLUsI (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236849AbjFLUrA (ORCPT ); Mon, 12 Jun 2023 16:47:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2875F26B1 for ; Mon, 12 Jun 2023 13:46:29 -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 6315662ED7 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AD54C433AE; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=EWN17qREk8YC1MUcrW1F8VdO7n3Z0vTPmJeNoge1tUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lBdMI4IEsReS6lw0j9yEgZ4SBNdenZo/YroqOKNKNDmqz5iUI8RDgcy3chvgHp8i9 RNch6iHYgBEMvvLioOldc8oVprZ1AVBuEbq8cIsq+boishEIPvTIXdK53vHCsWq5gG lWDyQoeGfdpYHIkmPK2Fhx/lAfNFpEzH0IH0k8z4jOmGR0tWsE9+HRhcNfp2l9LxAj Uz06gU/hXS8p7x2xFeCqZczng23rlND0E1PyqTcuUP1y+dxC2+FcUAGtqyA6W24dbe aVBw8mgrd3Fb5bSNPjIid1wlwPvh3RyhmTZPfVYQzA/njeiWYQt1IRdJR2qsWgNKeR 8vTaLDXMJUxEg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C1EDFCE3A4F; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 11/53] tools/nolibc: use C89 comment syntax Date: Mon, 12 Jun 2023 13:44:32 -0700 Message-Id: <20230612204514.292087-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531448735558272?= X-GMAIL-MSGID: =?utf-8?q?1768531448735558272?= From: Thomas Weißschuh Most of nolibc is already using C89 comments. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-aarch64.h | 32 +++++------ tools/include/nolibc/arch-arm.h | 44 +++++++-------- tools/include/nolibc/arch-i386.h | 40 +++++++------- tools/include/nolibc/arch-loongarch.h | 38 ++++++------- tools/include/nolibc/arch-mips.h | 56 ++++++++++---------- tools/include/nolibc/arch-riscv.h | 40 +++++++------- tools/include/nolibc/arch-s390.h | 2 +- tools/include/nolibc/arch-x86_64.h | 34 ++++++------ tools/include/nolibc/stackprotector.h | 4 +- tools/include/nolibc/sys.h | 8 +-- tools/testing/selftests/nolibc/nolibc-test.c | 12 ++--- 11 files changed, 155 insertions(+), 155 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 383baddef701..76ef26520c85 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -176,24 +176,24 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) { __asm__ volatile ( - "ldr x0, [sp]\n" // argc (x0) was in the stack - "add x1, sp, 8\n" // argv (x1) = sp - "lsl x2, x0, 3\n" // envp (x2) = 8*argc ... - "add x2, x2, 8\n" // + 8 (skip null) - "add x2, x2, x1\n" // + argv - "adrp x3, environ\n" // x3 = &environ (high bits) - "str x2, [x3, #:lo12:environ]\n" // store envp into environ - "mov x4, x2\n" // search for auxv (follows NULL after last env) + "ldr x0, [sp]\n" /* argc (x0) was in the stack */ + "add x1, sp, 8\n" /* argv (x1) = sp */ + "lsl x2, x0, 3\n" /* envp (x2) = 8*argc ... */ + "add x2, x2, 8\n" /* + 8 (skip null) */ + "add x2, x2, x1\n" /* + argv */ + "adrp x3, environ\n" /* x3 = &environ (high bits) */ + "str x2, [x3, #:lo12:environ]\n" /* store envp into environ */ + "mov x4, x2\n" /* search for auxv (follows NULL after last env) */ "0:\n" - "ldr x5, [x4], 8\n" // x5 = *x4; x4 += 8 - "cbnz x5, 0b\n" // and stop at NULL after last env - "adrp x3, _auxv\n" // x3 = &_auxv (high bits) - "str x4, [x3, #:lo12:_auxv]\n" // store x4 into _auxv - "and sp, x1, -16\n" // sp must be 16-byte aligned in the callee - "bl main\n" // main() returns the status code, we'll exit with it. - "mov x8, 93\n" // NR_exit == 93 + "ldr x5, [x4], 8\n" /* x5 = *x4; x4 += 8 */ + "cbnz x5, 0b\n" /* and stop at NULL after last env */ + "adrp x3, _auxv\n" /* x3 = &_auxv (high bits) */ + "str x4, [x3, #:lo12:_auxv]\n" /* store x4 into _auxv */ + "and sp, x1, -16\n" /* sp must be 16-byte aligned in the callee */ + "bl main\n" /* main() returns the status code, we'll exit with it. */ + "mov x8, 93\n" /* NR_exit == 93 */ "svc #0\n" ); __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_AARCH64_H +#endif /* _NOLIBC_ARCH_AARCH64_H */ diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 42499f23e73c..2eab1aef321b 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -203,34 +203,34 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) { __asm__ volatile ( - "pop {%r0}\n" // argc was in the stack - "mov %r1, %sp\n" // argv = sp + "pop {%r0}\n" /* argc was in the stack */ + "mov %r1, %sp\n" /* argv = sp */ - "add %r2, %r0, $1\n" // envp = (argc + 1) ... - "lsl %r2, %r2, $2\n" // * 4 ... - "add %r2, %r2, %r1\n" // + argv - "ldr %r3, 1f\n" // r3 = &environ (see below) - "str %r2, [r3]\n" // store envp into environ + "add %r2, %r0, $1\n" /* envp = (argc + 1) ... */ + "lsl %r2, %r2, $2\n" /* * 4 ... */ + "add %r2, %r2, %r1\n" /* + argv */ + "ldr %r3, 1f\n" /* r3 = &environ (see below) */ + "str %r2, [r3]\n" /* store envp into environ */ - "mov r4, r2\n" // search for auxv (follows NULL after last env) + "mov r4, r2\n" /* search for auxv (follows NULL after last env) */ "0:\n" - "mov r5, r4\n" // r5 = r4 - "add r4, r4, #4\n" // r4 += 4 - "ldr r5,[r5]\n" // r5 = *r5 = *(r4-4) - "cmp r5, #0\n" // and stop at NULL after last env + "mov r5, r4\n" /* r5 = r4 */ + "add r4, r4, #4\n" /* r4 += 4 */ + "ldr r5,[r5]\n" /* r5 = *r5 = *(r4-4) */ + "cmp r5, #0\n" /* and stop at NULL after last env */ "bne 0b\n" - "ldr %r3, 2f\n" // r3 = &_auxv (low bits) - "str r4, [r3]\n" // store r4 into _auxv + "ldr %r3, 2f\n" /* r3 = &_auxv (low bits) */ + "str r4, [r3]\n" /* store r4 into _auxv */ - "mov %r3, $8\n" // AAPCS : sp must be 8-byte aligned in the - "neg %r3, %r3\n" // callee, and bl doesn't push (lr=pc) - "and %r3, %r3, %r1\n" // so we do sp = r1(=sp) & r3(=-8); - "mov %sp, %r3\n" // + "mov %r3, $8\n" /* AAPCS : sp must be 8-byte aligned in the */ + "neg %r3, %r3\n" /* callee, and bl doesn't push (lr=pc) */ + "and %r3, %r3, %r1\n" /* so we do sp = r1(=sp) & r3(=-8); */ + "mov %sp, %r3\n" - "bl main\n" // main() returns the status code, we'll exit with it. - "movs r7, $1\n" // NR_exit == 1 + "bl main\n" /* main() returns the status code, we'll exit with it. */ + "movs r7, $1\n" /* NR_exit == 1 */ "svc $0x00\n" - ".align 2\n" // below are the pointers to a few variables + ".align 2\n" /* below are the pointers to a few variables */ "1:\n" ".word environ\n" "2:\n" @@ -239,4 +239,4 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_ARM_H +#endif /* _NOLIBC_ARCH_ARM_H */ diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index 2d98d78fd3f3..7c41897a08ce 100644 --- a/tools/include/nolibc/arch-i386.h +++ b/tools/include/nolibc/arch-i386.h @@ -194,31 +194,31 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protec { __asm__ volatile ( #ifdef NOLIBC_STACKPROTECTOR - "call __stack_chk_init\n" // initialize stack protector + "call __stack_chk_init\n" /* initialize stack protector */ #endif - "pop %eax\n" // argc (first arg, %eax) - "mov %esp, %ebx\n" // argv[] (second arg, %ebx) - "lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx) - "mov %ecx, environ\n" // save environ - "xor %ebp, %ebp\n" // zero the stack frame - "mov %ecx, %edx\n" // search for auxv (follows NULL after last env) + "pop %eax\n" /* argc (first arg, %eax) */ + "mov %esp, %ebx\n" /* argv[] (second arg, %ebx) */ + "lea 4(%ebx,%eax,4),%ecx\n" /* then a NULL then envp (third arg, %ecx) */ + "mov %ecx, environ\n" /* save environ */ + "xor %ebp, %ebp\n" /* zero the stack frame */ + "mov %ecx, %edx\n" /* search for auxv (follows NULL after last env) */ "0:\n" - "add $4, %edx\n" // search for auxv using edx, it follows the - "cmp -4(%edx), %ebp\n" // ... NULL after last env (ebp is zero here) + "add $4, %edx\n" /* search for auxv using edx, it follows the */ + "cmp -4(%edx), %ebp\n" /* ... NULL after last env (ebp is zero here) */ "jnz 0b\n" - "mov %edx, _auxv\n" // save it into _auxv - "and $-16, %esp\n" // x86 ABI : esp must be 16-byte aligned before - "sub $4, %esp\n" // the call instruction (args are aligned) - "push %ecx\n" // push all registers on the stack so that we - "push %ebx\n" // support both regparm and plain stack modes + "mov %edx, _auxv\n" /* save it into _auxv */ + "and $-16, %esp\n" /* x86 ABI : esp must be 16-byte aligned before */ + "sub $4, %esp\n" /* the call instruction (args are aligned) */ + "push %ecx\n" /* push all registers on the stack so that we */ + "push %ebx\n" /* support both regparm and plain stack modes */ "push %eax\n" - "call main\n" // main() returns the status code in %eax - "mov %eax, %ebx\n" // retrieve exit code (32-bit int) - "movl $1, %eax\n" // NR_exit == 1 - "int $0x80\n" // exit now - "hlt\n" // ensure it does not + "call main\n" /* main() returns the status code in %eax */ + "mov %eax, %ebx\n" /* retrieve exit code (32-bit int) */ + "movl $1, %eax\n" /* NR_exit == 1 */ + "int $0x80\n" /* exit now */ + "hlt\n" /* ensure it does not */ ); __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_I386_H +#endif /* _NOLIBC_ARCH_I386_H */ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index 029ee3cd6baf..ec3b46a991a9 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -158,7 +158,7 @@ const unsigned long *_auxv __attribute__((weak)); #define LONG_ADDI "addi.w" #define LONG_SLL "slli.w" #define LONG_BSTRINS "bstrins.w" -#else // __loongarch_grlen == 64 +#else /* __loongarch_grlen == 64 */ #define LONGLOG "3" #define SZREG "8" #define REG_L "ld.d" @@ -173,28 +173,28 @@ const unsigned long *_auxv __attribute__((weak)); 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) = sp + SZREG - LONG_SLL " $a2, $a0, "LONGLOG"\n" // envp (a2) = SZREG*argc ... - LONG_ADDI " $a2, $a2, "SZREG"\n" // + SZREG (skip null) - LONG_ADD " $a2, $a2, $a1\n" // + argv + REG_L " $a0, $sp, 0\n" /* argc (a0) was in the stack */ + LONG_ADDI " $a1, $sp, "SZREG"\n" /* argv (a1) = sp + SZREG */ + LONG_SLL " $a2, $a0, "LONGLOG"\n" /* envp (a2) = 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 auxv (after NULL) - "0:\n" // do { - REG_L " $a4, $a3, 0\n" // a4 = *a3; - LONG_ADDI " $a3, $a3, "SZREG"\n" // a3 += sizeof(void*); - "bne $a4, $zero, 0b\n" // } while (a4); - "la.pcrel $a4, _auxv\n" // a4 = &_auxv - LONG_S " $a3, $a4, 0\n" // store a3 into _auxv + "move $a3, $a2\n" /* iterate a3 over envp to find auxv (after NULL) */ + "0:\n" /* do { */ + REG_L " $a4, $a3, 0\n" /* a4 = *a3; */ + LONG_ADDI " $a3, $a3, "SZREG"\n" /* a3 += sizeof(void*); */ + "bne $a4, $zero, 0b\n" /* } while (a4); */ + "la.pcrel $a4, _auxv\n" /* a4 = &_auxv */ + LONG_S " $a3, $a4, 0\n" /* store a3 into _auxv */ - "la.pcrel $a3, environ\n" // a3 = &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 == 93 + "la.pcrel $a3, environ\n" /* a3 = &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 == 93 */ "syscall 0\n" ); __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_LOONGARCH_H +#endif /* _NOLIBC_ARCH_LOONGARCH_H */ diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index bf83432d23ed..8822f150e72f 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -183,42 +183,42 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __start(void) { __asm__ volatile ( - //".set nomips16\n" + /*".set nomips16\n"*/ ".set push\n" ".set noreorder\n" ".option pic0\n" - //".ent __start\n" - //"__start:\n" - "lw $a0,($sp)\n" // argc was in the stack - "addiu $a1, $sp, 4\n" // argv = sp + 4 - "sll $a2, $a0, 2\n" // a2 = argc * 4 - "add $a2, $a2, $a1\n" // envp = argv + 4*argc ... - "addiu $a2, $a2, 4\n" // ... + 4 - "lui $a3, %hi(environ)\n" // load environ into a3 (hi) - "addiu $a3, %lo(environ)\n" // load environ into a3 (lo) - "sw $a2,($a3)\n" // store envp(a2) into environ - - "move $t0, $a2\n" // iterate t0 over envp, look for NULL - "0:" // do { - "lw $a3, ($t0)\n" // a3=*(t0); - "bne $a3, $0, 0b\n" // } while (a3); - "addiu $t0, $t0, 4\n" // delayed slot: t0+=4; - "lui $a3, %hi(_auxv)\n" // load _auxv into a3 (hi) - "addiu $a3, %lo(_auxv)\n" // load _auxv into a3 (lo) - "sw $t0, ($a3)\n" // store t0 into _auxv + /*".ent __start\n"*/ + /*"__start:\n"*/ + "lw $a0,($sp)\n" /* argc was in the stack */ + "addiu $a1, $sp, 4\n" /* argv = sp + 4 */ + "sll $a2, $a0, 2\n" /* a2 = argc * 4 */ + "add $a2, $a2, $a1\n" /* envp = argv + 4*argc ... */ + "addiu $a2, $a2, 4\n" /* ... + 4 */ + "lui $a3, %hi(environ)\n" /* load environ into a3 (hi) */ + "addiu $a3, %lo(environ)\n" /* load environ into a3 (lo) */ + "sw $a2,($a3)\n" /* store envp(a2) into environ */ + + "move $t0, $a2\n" /* iterate t0 over envp, look for NULL */ + "0:" /* do { */ + "lw $a3, ($t0)\n" /* a3=*(t0); */ + "bne $a3, $0, 0b\n" /* } while (a3); */ + "addiu $t0, $t0, 4\n" /* delayed slot: t0+=4; */ + "lui $a3, %hi(_auxv)\n" /* load _auxv into a3 (hi) */ + "addiu $a3, %lo(_auxv)\n" /* load _auxv into a3 (lo) */ + "sw $t0, ($a3)\n" /* store t0 into _auxv */ "li $t0, -8\n" - "and $sp, $sp, $t0\n" // sp must be 8-byte aligned - "addiu $sp,$sp,-16\n" // the callee expects to save a0..a3 there! - "jal main\n" // main() returns the status code, we'll exit with it. - "nop\n" // delayed slot - "move $a0, $v0\n" // retrieve 32-bit exit code from v0 - "li $v0, 4001\n" // NR_exit == 4001 + "and $sp, $sp, $t0\n" /* sp must be 8-byte aligned */ + "addiu $sp,$sp,-16\n" /* the callee expects to save a0..a3 there! */ + "jal main\n" /* main() returns the status code, we'll exit with it. */ + "nop\n" /* delayed slot */ + "move $a0, $v0\n" /* retrieve 32-bit exit code from v0 */ + "li $v0, 4001\n" /* NR_exit == 4001 */ "syscall\n" - //".end __start\n" + /*".end __start\n"*/ ".set pop\n" ); __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_MIPS_H +#endif /* _NOLIBC_ARCH_MIPS_H */ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index e197fcb10ac0..0d5f15fdedc4 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -181,28 +181,28 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) ".option norelax\n" "lla gp, __global_pointer$\n" ".option pop\n" - "lw a0, 0(sp)\n" // argc (a0) was in the stack - "add a1, sp, "SZREG"\n" // argv (a1) = sp - "slli a2, a0, "PTRLOG"\n" // envp (a2) = SZREG*argc ... - "add a2, a2, "SZREG"\n" // + SZREG (skip null) - "add a2,a2,a1\n" // + argv - - "add a3, a2, zero\n" // iterate a3 over envp to find auxv (after NULL) - "0:\n" // do { - "ld a4, 0(a3)\n" // a4 = *a3; - "add a3, a3, "SZREG"\n" // a3 += sizeof(void*); - "bne a4, zero, 0b\n" // } while (a4); - "lui a4, %hi(_auxv)\n" // a4 = &_auxv (high bits) - "sd a3, %lo(_auxv)(a4)\n" // store a3 into _auxv - - "lui a3, %hi(environ)\n" // a3 = &environ (high bits) - "sd a2,%lo(environ)(a3)\n" // store envp(a2) into environ - "andi sp,a1,-16\n" // sp must be 16-byte aligned - "call main\n" // main() returns the status code, we'll exit with it. - "li a7, 93\n" // NR_exit == 93 + "lw a0, 0(sp)\n" /* argc (a0) was in the stack */ + "add a1, sp, "SZREG"\n" /* argv (a1) = sp */ + "slli a2, a0, "PTRLOG"\n" /* envp (a2) = SZREG*argc ... */ + "add a2, a2, "SZREG"\n" /* + SZREG (skip null) */ + "add a2,a2,a1\n" /* + argv */ + + "add a3, a2, zero\n" /* iterate a3 over envp to find auxv (after NULL) */ + "0:\n" /* do { */ + "ld a4, 0(a3)\n" /* a4 = *a3; */ + "add a3, a3, "SZREG"\n" /* a3 += sizeof(void*); */ + "bne a4, zero, 0b\n" /* } while (a4); */ + "lui a4, %hi(_auxv)\n" /* a4 = &_auxv (high bits) */ + "sd a3, %lo(_auxv)(a4)\n" /* store a3 into _auxv */ + + "lui a3, %hi(environ)\n" /* a3 = &environ (high bits) */ + "sd a2,%lo(environ)(a3)\n" /* store envp(a2) into environ */ + "andi sp,a1,-16\n" /* sp must be 16-byte aligned */ + "call main\n" /* main() returns the status code, we'll exit with it. */ + "li a7, 93\n" /* NR_exit == 93 */ "ecall\n" ); __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_RISCV_H +#endif /* _NOLIBC_ARCH_RISCV_H */ diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index 6b0e54ed543d..c62ee2472407 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -223,4 +223,4 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, return (void *)my_syscall1(__NR_mmap, &args); } #define sys_mmap sys_mmap -#endif // _NOLIBC_ARCH_S390_H +#endif /* _NOLIBC_ARCH_S390_H */ diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index f7f2a11d4c3b..d98f6c89d143 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.h @@ -194,27 +194,27 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) { __asm__ volatile ( #ifdef NOLIBC_STACKPROTECTOR - "call __stack_chk_init\n" // initialize stack protector + "call __stack_chk_init\n" /* initialize stack protector */ #endif - "pop %rdi\n" // argc (first arg, %rdi) - "mov %rsp, %rsi\n" // argv[] (second arg, %rsi) - "lea 8(%rsi,%rdi,8),%rdx\n" // then a NULL then envp (third arg, %rdx) - "mov %rdx, environ\n" // save environ - "xor %ebp, %ebp\n" // zero the stack frame - "mov %rdx, %rax\n" // search for auxv (follows NULL after last env) + "pop %rdi\n" /* argc (first arg, %rdi) */ + "mov %rsp, %rsi\n" /* argv[] (second arg, %rsi) */ + "lea 8(%rsi,%rdi,8),%rdx\n" /* then a NULL then envp (third arg, %rdx) */ + "mov %rdx, environ\n" /* save environ */ + "xor %ebp, %ebp\n" /* zero the stack frame */ + "mov %rdx, %rax\n" /* search for auxv (follows NULL after last env) */ "0:\n" - "add $8, %rax\n" // search for auxv using rax, it follows the - "cmp -8(%rax), %rbp\n" // ... NULL after last env (rbp is zero here) + "add $8, %rax\n" /* search for auxv using rax, it follows the */ + "cmp -8(%rax), %rbp\n" /* ... NULL after last env (rbp is zero here) */ "jnz 0b\n" - "mov %rax, _auxv\n" // save it into _auxv - "and $-16, %rsp\n" // x86 ABI : esp must be 16-byte aligned before call - "call main\n" // main() returns the status code, we'll exit with it. - "mov %eax, %edi\n" // retrieve exit code (32 bit) - "mov $60, %eax\n" // NR_exit == 60 - "syscall\n" // really exit - "hlt\n" // ensure it does not return + "mov %rax, _auxv\n" /* save it into _auxv */ + "and $-16, %rsp\n" /* x86 ABI : esp must be 16-byte aligned before call */ + "call main\n" /* main() returns the status code, we'll exit with it. */ + "mov %eax, %edi\n" /* retrieve exit code (32 bit) */ + "mov $60, %eax\n" /* NR_exit == 60 */ + "syscall\n" /* really exit */ + "hlt\n" /* ensure it does not return */ ); __builtin_unreachable(); } -#endif // _NOLIBC_ARCH_X86_64_H +#endif /* _NOLIBC_ARCH_X86_64_H */ diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index d119cbbbc256..77e5251c4490 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -48,6 +48,6 @@ void __stack_chk_init(void) /* a bit more randomness in case getrandom() fails */ __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; } -#endif // defined(NOLIBC_STACKPROTECTOR) +#endif /* defined(NOLIBC_STACKPROTECTOR) */ -#endif // _NOLIBC_STACKPROTECTOR_H +#endif /* _NOLIBC_STACKPROTECTOR_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index bea9760dbd16..1b9b91cd8b57 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -12,15 +12,15 @@ /* system includes */ #include -#include // for SIGCHLD +#include /* for SIGCHLD */ #include #include #include #include #include #include -#include // for O_* and AT_* -#include // for statx() +#include /* for O_* and AT_* */ +#include /* for statx() */ #include "arch.h" #include "errno.h" @@ -322,7 +322,7 @@ static __attribute__((noreturn,unused)) void sys_exit(int status) { my_syscall1(__NR_exit, status & 255); - while(1); // shut the "noreturn" warnings. + while(1); /* shut the "noreturn" warnings. */ } static __attribute__((noreturn,unused)) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index e692be98973a..f06b38cfe38a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ #define _GNU_SOURCE @@ -46,8 +46,8 @@ char **environ; /* definition of a series of tests */ struct test { - const char *name; // test name - int (*func)(int min, int max); // handler + const char *name; /* test name */ + int (*func)(int min, int max); /* handler */ }; #ifndef _NOLIBC_STDLIB_H @@ -494,7 +494,7 @@ int run_syscall(int min, int max) euid0 = geteuid() == 0; for (test = min; test >= 0 && test <= max; test++) { - int llen = 0; // line length + int llen = 0; /* line length */ /* avoid leaving empty lines below, this will insert holes into * test numbers. @@ -584,7 +584,7 @@ int run_stdlib(int min, int max) void *p1, *p2; for (test = min; test >= 0 && test <= max; test++) { - int llen = 0; // line length + int llen = 0; /* line length */ /* avoid leaving empty lines below, this will insert holes into * test numbers. @@ -731,7 +731,7 @@ static int run_vfprintf(int min, int max) void *p1, *p2; for (test = min; test >= 0 && test <= max; test++) { - int llen = 0; // line length + int llen = 0; /* line length */ /* avoid leaving empty lines below, this will insert holes into * test numbers. From patchwork Mon Jun 12 20:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp125170vqr; Mon, 12 Jun 2023 13:50:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4oHcKLYj0xJR+CSZnG03uBwjtFyAyozmVRsxqQzOsQqDEd+3nJFy66j1afE/Fit5epTOTd X-Received: by 2002:a17:907:36c7:b0:973:e69d:c720 with SMTP id bj7-20020a17090736c700b00973e69dc720mr10959372ejc.51.1686603017026; Mon, 12 Jun 2023 13:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603017; cv=none; d=google.com; s=arc-20160816; b=YMQvYMMQVqhlPo06N53eeNareBbVy4NCUkxdgU46Pv/u6iFyVWhtGsbhU/S1gVIVsT vDXyyHH22GfOIIS70RdsfuW2VtfTfZcoLZlXe6mL+EnPDhH2PQIVg0Qvf4xP4s1VF2kv PL1UqgGdHKLO3mFQgoym+/hXw8+6P9r5/Zs8ScwgDZrFBOw5JdTHdL0XxxIsU/pWNY40 1Xaz6bUC9JNlVT3wul6SmWaGtNri9pw2rUA/tRP2D4f45Xx3KO0uPf60Y1yC2s9Gl0di NHHk2zcxuZRupPbzytw6orqbnF3a6/eDcvLuBCzdmCPctS0F9IVGh2wFIFM5Cv8UiNRk scyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l8swfxNOqYMpoKFlWpksQ9ShhQIPhQf692BTAiUNRxk=; b=xrKJkGCbj8V/MrJx/9RsZPzFDrK9RiJvLZ1o80FswYd/pkDrA+SEw3BmwwRBiQ4v4E EOabvYPibH1xx0B5fQ7QEkBUgA34O2g0IianVzxqNvcIVZPVjNTGz9k8BRI7bnV8+kxG +NKFD11Q0HhZ9ffMjBGzSOQQIhN08W8IYRg8U4KlU6YrmhcAbo1vgOqcwxRDh5Vu65ze U6/UL4IWhjL3Mmmrx1LRBkISBM4Pmwoh6VUk4epH6xKVfE/OoD2cyxg/2xrM/NRuJCQO kL0/x8kIbTqerkYZBLjtL2aMBL/E/TnxG2Niqi+lgcod7sNH56jDJhDNaEZaWbPorcM2 23Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BcCBXjUc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k19-20020a170906159300b0096f86bd395dsi5482074ejd.281.2023.06.12.13.49.52; Mon, 12 Jun 2023 13:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BcCBXjUc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbjFLUsE (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236337AbjFLUq6 (ORCPT ); Mon, 12 Jun 2023 16:46:58 -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 1BB232717 for ; Mon, 12 Jun 2023 13:46:29 -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 73C4762EFA for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AD2AC433AA; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=qXNtbl8qeb3lbiMWDYS0tmfhxByKNfAQg29LsRRZRZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BcCBXjUcDQw7GvBvkqk0czuJCHO1gukX0JAC3d/WjGUujdUEvo+WDUTQo5twRklUw szkNyVBvvA4QJI6yyxu6qBZoW1Env4oGVEzi1U4Ruh5uGbvhLiYe8uasqLHWDa0gBu Bj/VEHxQXlZeE/pTmjjvru76AxG4n3a8P9fHl/je5VYCCOvwo9m8R09RfLXq9nVSAJ 2YhMfzLuGe4mfdc3igIJ7W23UzwVR0kVre9jXcAQK5tKbSr+Z28y0KDNzaqQEFTsiZ BzPfa9nOr6mgYY/f6e0Y5f69lbem0B9GMuEwLS6JImoL6tmkgqOabmqPbNZoKIcECL GnjPYOlViTD7A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C416ECE3A51; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 12/53] tools/nolibc: validate C89 compatibility Date: Mon, 12 Jun 2023 13:44:33 -0700 Message-Id: <20230612204514.292087-12-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531445000014859?= X-GMAIL-MSGID: =?utf-8?q?1768531445000014859?= From: Thomas Weißschuh To make sure no non-compatible changes are introduced accidentally validate the language standard when building the tests. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 0cbe13809b37..423d22f353a0 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -83,7 +83,7 @@ CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 -CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables \ +CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ $(CFLAGS_STKP_$(ARCH)) $(CFLAGS_$(ARCH)) LDFLAGS := -s From patchwork Mon Jun 12 20:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp125168vqr; Mon, 12 Jun 2023 13:50:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zqVkpA+rxHXT3/5VB3JzD4wcycZoYwbW/ALZoDOU3eFM4+Rneaa1/XtW8hLr3tdXjcBo9 X-Received: by 2002:a17:907:7291:b0:973:7096:60c2 with SMTP id dt17-20020a170907729100b00973709660c2mr9949192ejc.20.1686603016917; Mon, 12 Jun 2023 13:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603016; cv=none; d=google.com; s=arc-20160816; b=0UXaKR4HHYF4kag0Lum5ij1hPuQsoFpdp+sNeNoegBPBLV/HX4XWFsVBv2YIH90daj S8SL6kid96V/RPZEvtE8LItdBD8kA1thm5bjPz+cA+1Q+72TNNiaFcHFVVd7qqGfbr4t XyTD+EtI/yfEZnQz4LQUWUFbQN36Z3rJSjJiElWqf4cTd/UxII4ypR2a7JCaXjj2T9hq 8j8ia52mrQtrHiARjUPm1fJ3XK7b1t3osZM39G1fYKL+8Jq8b9Kjj7G4mOKMWhFwJwmI bUrEdCQ51E/LJiHcvgdipvoYwbXjzuE0EZVK5Tr7zMqlax+2OOsWDSlNhNf0K9Q/DlYY oDag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UnRj4vWba3of/uBczgcxZ/yV4uPC4g/tNJ89oZJL1BA=; b=wJHvlh0PozT5IEsW6hYEhccFuI3Bii+2kaWKuE4GnsKm2DyZYE9snM3OZ/Ggb72bUR eaU8DEVfefM+56pi7I8pzxlT+1Z20QyW26u0BDvEDJPDvxi1K7j1Bk1px1VbJSFivXoi 7CBLNikVd3KVzilbAVgw+qwnRxE9qVe8jwVpE4Fbnqrgqe5sI8NhObNHTVbWWp0b3AR5 xf9GkoqsYU1GW6ERy8Wj539sexkWnw+kIyQ5DnYmnZ+RrhFhN0KjZDeev3TC3YyZOS+S I9qU4iXnUla5YYrEhPzC4p5Fp4EJmVPazf024OhCCS/ZjcTNFz0hod30yFnFc0bdvIjv yhOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rp57k+kr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a170906171300b00977eb8d769bsi5406504eje.289.2023.06.12.13.49.52; Mon, 12 Jun 2023 13:50:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Rp57k+kr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237863AbjFLUsG (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235960AbjFLUrA (ORCPT ); Mon, 12 Jun 2023 16:47:00 -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 B0FE42943 for ; Mon, 12 Jun 2023 13:46:30 -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 76B8E62EFB for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9696CC433AF; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=oC2jzfNDP3qXofDBVXlAqaNEq75nX/bGi7jR4v97zaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rp57k+kruEmbcOONSC0w6AF6KVWffRId/t95pE3udygnwZ5N50WYldwWdIBSJkpWD lTwzdRlcY02MhuwOah7Da+oDyOVilf+uasSrQMjnF/3FCmqAWFm0AJ+OeO8xFwymG6 AcZXbmflqTQl5W9sGG7um/Lgq2UdQlKIG8Ktbw5OtNUNfWNVsCCP0PXNBtmYHXbUr6 hwuiqPFxXiDuKZbqhn94XvSt241uYv6dSoPpb4IcIg5G68Ig/kh1aJePhdJbvotND/ pMZaeNpnSxbOSO1si3aZL3Opx3I1pHpfZYSvfZ4A3QDKt7z/d0Ts+r1BPl9OAxSk9X 9H0CsrT9ix0Pw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C637DCE3A53; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Sven Schnelle , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 13/53] tools/nolibc: s390: provide custom implementation for sys_fork Date: Mon, 12 Jun 2023 13:44:34 -0700 Message-Id: <20230612204514.292087-13-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531445036430497?= X-GMAIL-MSGID: =?utf-8?q?1768531445036430497?= From: Thomas Weißschuh On s390 the first two arguments to the clone() syscall are swapped, as documented in clone(2). Signed-off-by: Thomas Weißschuh Cc: Sven Schnelle Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-s390.h | 9 +++++++++ tools/include/nolibc/sys.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index c62ee2472407..a738e7f3f8e8 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -5,6 +5,7 @@ #ifndef _NOLIBC_ARCH_S390_H #define _NOLIBC_ARCH_S390_H +#include #include /* The struct returned by the stat() syscall, equivalent to stat64(). The @@ -223,4 +224,12 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, return (void *)my_syscall1(__NR_mmap, &args); } #define sys_mmap sys_mmap + +static __attribute__((unused)) +pid_t sys_fork(void) +{ + return my_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0); +} +#define sys_fork sys_fork + #endif /* _NOLIBC_ARCH_S390_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 1b9b91cd8b57..60dffb1cbf96 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -336,6 +336,7 @@ void exit(int status) * pid_t fork(void); */ +#ifndef sys_fork static __attribute__((unused)) pid_t sys_fork(void) { @@ -351,6 +352,7 @@ pid_t sys_fork(void) #error Neither __NR_clone nor __NR_fork defined, cannot implement sys_fork() #endif } +#endif static __attribute__((unused)) pid_t fork(void) From patchwork Mon Jun 12 20:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp127833vqr; Mon, 12 Jun 2023 13:57:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Gk9DEg3JqHKB9Z1PPliJJ2JIKHSPoaoihehUmDoN+VjuULTL3SXBxSxZOBtp2YCPNZjYz X-Received: by 2002:a17:907:318e:b0:978:6a95:512d with SMTP id xe14-20020a170907318e00b009786a95512dmr10221554ejb.11.1686603455245; Mon, 12 Jun 2023 13:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603455; cv=none; d=google.com; s=arc-20160816; b=BLidlIGHlYGW26oZOg11GFm6mRfKJBy6cJjU8g1WYFdtKUrVdvsjdCti/7+voHcli/ NFN7kX7YfkOi5ncTzVHBF6o/3nobhUWuUpkAMmroCYcQ1ZK1mJefGDedodbyQRskSakS IXjtuwTUBO2KST1ayhulz9g3AQ+kMEXWN4WoHWcOo5LYySk2e41pCwbfCp6htMl+eWDy WnvkMAuDtd7EKIPRy6efEgXLd7wFc8J1qanUcHGTKERcJioXSe0QLtF5uOktoLHkerJD BzEo1KaczqkYtyPjcwqFzhraCKCJpzu+YOBq0TxqTNfcOSWHdGWqpj5P3WA3qur+0Zla /fvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+ZonSiidB6UCMuPN1gP+PAa2wlMByf9ASWe7cGDyb9Y=; b=xE/qrQOKgW/YgCUOH4L8pNRAHTIOjVorH1se32A0oegheD4WxkLpoMiTHQbZ2eIkCD tOacE/JZzQMjYGjco6f4JQUF4MtswbqZUYq5plUXdanwiVRPn+gf6DRgUrUuSzeCmAwi qkSi+75XPNMWaD6DqAcGiggtL6bPkyopJhds5zNqE2YSCqJTltkc+znTSSQPy374I89E 4LaIb5XsGeTlJxEzO1pRmstRcDpg4LZ0NbOhXIuiygwrxgVq9FJaDblyvnijXzUhPOG7 EfeFvYIF6E2fZCa68DETRmkOoA19hnSyLrA/ZbrI+7BHEfdlSFpKovKrygpFheJuVarq 2fiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u15Yhmho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gg17-20020a170906e29100b0094f697070f6si6075973ejb.56.2023.06.12.13.57.11; Mon, 12 Jun 2023 13:57:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u15Yhmho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237905AbjFLUsQ (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237076AbjFLUrC (ORCPT ); Mon, 12 Jun 2023 16:47:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0FB2949 for ; Mon, 12 Jun 2023 13:46:31 -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 786E962EF7 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADF81C433A1; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=UfezgJW4qV6A3Fx5ZwnvEgO/thFwlCGX/qvaitn6eGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u15Yhmho/ODVrrDCvteOLPvwc4BoC7BhZuidW45OCP0Ox8Qcc0UnW89wIiPTVmhS+ E06JhpTd0YLubxzyAcTmWxeb3LAzZ85q70nNN6gvFor/kZ96/0YXPX4lWiZurjsAyd akUsvrdWBpMHiLCOnthz07eHsYPU6IFBymefVkJHzhInWyE56KXdTd/QOOwWqBLBar gjSihqsRW15ZNowwcOdI8bprRNm1f7gH7qIdb/gSnNPtxozISUYB8LiPEtxtedpt/k 6LvEuQ4cxEKEfusaWM+gdo3ncIhz0S9ZkgGTT+yvgiKVqNHHEP1M1FiLH9XlbSgxjf OMz1fX0AEAF+A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id C88CBCE3A55; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 14/53] tools/nolibc: add testcase for fork()/waitpid() Date: Mon, 12 Jun 2023 13:44:35 -0700 Message-Id: <20230612204514.292087-14-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531904642018404?= X-GMAIL-MSGID: =?utf-8?q?1768531904642018404?= From: Thomas Weißschuh On s390 the arguments to clone() which is used by fork() are different than other archs. Make sure everything works correctly. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index f06b38cfe38a..f042a6436b6b 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -474,6 +474,25 @@ static int test_getpagesize(void) return !c; } +static int test_fork(void) +{ + int status; + pid_t pid = fork(); + + switch (pid) { + case -1: + return 1; + + case 0: + exit(123); + + default: + pid = waitpid(pid, &status, 0); + + return pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 123; + } +} + /* Run syscall tests between IDs and . * Return 0 on success, non-zero on failure. */ @@ -530,6 +549,7 @@ int run_syscall(int min, int max) CASE_TEST(dup3_0); tmp = dup3(0, 100, 0); EXPECT_SYSNE(1, tmp, -1); close(tmp); break; CASE_TEST(dup3_m1); tmp = dup3(-1, 100, 0); EXPECT_SYSER(1, tmp, -1, EBADF); if (tmp != -1) close(tmp); break; CASE_TEST(execve_root); EXPECT_SYSER(1, execve("/", (char*[]){ [0] = "/", [1] = NULL }, NULL), -1, EACCES); break; + CASE_TEST(fork); EXPECT_SYSZR(1, test_fork()); break; CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; From patchwork Mon Jun 12 20:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133604vqr; Mon, 12 Jun 2023 14:08:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4suqXWG9/NFlqNd6nEWn4lCaQ0kVx942cJ33qEwK8OTDeoUIGpXuU5F7Rw9zk9pFmGBv9M X-Received: by 2002:a19:7909:0:b0:4ec:a19c:32b0 with SMTP id u9-20020a197909000000b004eca19c32b0mr3962601lfc.5.1686604113065; Mon, 12 Jun 2023 14:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604113; cv=none; d=google.com; s=arc-20160816; b=D3vFkx4NKYI03/uENtYrBpcbY/5uBjorZJzcj5MHfPtMXYSU/wGpqkYLVzWlzi+WeA ntYXNEQSc8JQYIDZkrJVLthuCcCBfGxLQR0Fu0YL4XH0V0mn0i0zWXLRmJHl6WekFiD9 YsJBJVHeEExAksQPx8CTH9NKcKCas1LXszbZyxvRZVQDDFTE3+VXlAPQs8UKsqARQHYC RIuTCJQSr2oFbFDTmh4SYqthYNOwPCBEuzTo2O6R53v3EQ7CZUzr4/w1BQWWg6y1DpTi pX19GsTIBZdRua9CviBKeFOYJV7g79ZCWh4LbBz+FmXvcWht3xyDB0wVeK1pr6JW0Ee7 WDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/QUsyDbN1wwtKQKu1kUZsfJXnPvAbvtgpkbkg0reZJE=; b=ejrAfU8C5uuQbnAq7CpgcZdIgt/DyXoRlp8Fz0MzjQr3QxNWVV34riuTiiGCCxiXom HrGW9G/gdFShIrUEpeozK2YV6SgPB0lr4ML1zjouh+PO4q3jUwxCdLEWKlBRmtDZQMxs HWSdqEGtXDnzk5M/mVGmuk0dL64vyejvOsSazU538/qTbRXQIu62aStKq+MNxA4RnrHf ZQYiNPj/Fb8fZxHewMvUN0XHxXh2LYKGIMjua19rYRA/bx22Jgz1Ah1lQpX/U6oQ9KX0 LyZQO2SwhE5y5i+x9BTzXHhyi/eTO2HqrxqyC3WNexBgopphjaMYMD/OrnTSPChcxa+9 g6dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=agyfhPJY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020aa7d50a000000b00514a670c046si2436998edq.533.2023.06.12.14.08.09; Mon, 12 Jun 2023 14:08:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=agyfhPJY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236078AbjFLUs1 (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237100AbjFLUr0 (ORCPT ); Mon, 12 Jun 2023 16:47:26 -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 EC9072956 for ; Mon, 12 Jun 2023 13:46:36 -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 7D7CB62F02 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3993C433B0; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=aYadX67GYiG+Nuff8Hdg1wAWmzTfTdurTxNUVvBVt1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agyfhPJYVc0kbRjDsZN7YsXptG8VkUsAwx0AOQgpsw68zsjgDkvW/O/PHyC8v73zP Mv7zeQ8mtAtabnhDqyZHb/tO4A0ckb6YbsJHih2kZH0O60Aoj/SqWFWJbqTCNmmtgR IwkAOjwkOUtQ1+eL2Mh7f7rOD87s0nTgbCnPBhqYZYKomZtgDyklK+K5jNPM6NQfDo P7sz9BR/HKOsjpSX1HNu+xoY7TxJFc7xSXr3T/T9TdhZaYuwjedjnen4UKD3hvu6iU xxnoAaF6Ijd0Wqf4ga7PSs6N/igt1FCcRwM8QBSIOCDjXGKel01BI6OKz513fMvvik jXx3PrvcOZu8A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CAE30CE3A56; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 15/53] tools/nolibc: remove LINUX_REBOOT_ constants Date: Mon, 12 Jun 2023 13:44:36 -0700 Message-Id: <20230612204514.292087-15-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532594329402118?= X-GMAIL-MSGID: =?utf-8?q?1768532594329402118?= From: Thomas Weißschuh The same constants and some more have been exposed to userspace via linux/reboot.h for a long time. To avoid conflicts and trim down nolibc a bit drop the custom definitions. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 1 + tools/include/nolibc/types.h | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 60dffb1cbf96..d5792a5de70b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -21,6 +21,7 @@ #include #include /* for O_* and AT_* */ #include /* for statx() */ +#include /* for LINUX_REBOOT_* */ #include "arch.h" #include "errno.h" diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index aedd7d9e3f64..15b0baffd336 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -86,14 +86,6 @@ #define SEEK_CUR 1 #define SEEK_END 2 -/* cmd for reboot() */ -#define LINUX_REBOOT_MAGIC1 0xfee1dead -#define LINUX_REBOOT_MAGIC2 0x28121969 -#define LINUX_REBOOT_CMD_HALT 0xcdef0123 -#define LINUX_REBOOT_CMD_POWER_OFF 0x4321fedc -#define LINUX_REBOOT_CMD_RESTART 0x01234567 -#define LINUX_REBOOT_CMD_SW_SUSPEND 0xd000fce2 - /* Macros used on waitpid()'s return status */ #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) #define WIFEXITED(status) (((status) & 0x7f) == 0) From patchwork Mon Jun 12 20:44:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133623vqr; Mon, 12 Jun 2023 14:08:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79y5mTONzWRtm6IeVXhwwCv35vN33QAKLfPogDasHsYmb9TqMJo2XxHDgzgqG2f7yPKMHV X-Received: by 2002:a17:907:608a:b0:968:c3b5:8b92 with SMTP id ht10-20020a170907608a00b00968c3b58b92mr10710993ejc.57.1686604116719; Mon, 12 Jun 2023 14:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604116; cv=none; d=google.com; s=arc-20160816; b=B4p+Y1E3UQKJCvMN5CVUGWGrSD0MLMG3xTlqLV0D9VYJmU5pwvVarSHSgQq3sgpqHB zqpSBWtBY5zXIi3yz8GaBNH9zt6pROW4tDddiWQMDR0bE/D/uEqlBX+J1PJqtcBSQKeD f0a4RuCSbb2998TBRrqDM8a3bpRFkV3fL1C1Kbd36zuUIGKpBKpy6xDlAYFe0yz0shkI VxhU6R3KVJMU1C36h5lpywtpxSO3/4qqk8TA6jL7D81IQ2Cmc/DQqumm0gz2/4Spy5yn xoZdsXGuQREN01SxB0k1MyRjtYBeMIUqJCmKQp1hyUl9dDf93zwZUK+nO/ep1W1d5rPi EJrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2sVXO0AYushz+bPrm9q66U9zeaKSJy2OJ9RKHS91Mik=; b=voL6LEi/VjnrfyqDc5/BshWYjvDr11sZGjTjOATZfWL0WERLtfPqVWjvMnaBXF8V3D ZVXeRNhQ+JMjN3OJbsvv9bCUqtDnB/LqGuToxXm8Y95OHDNldHZUr4mTMzNgbdeGTcIs cYNb/H8F2FLbBgpI/yzmEN/MaW65xESWC1a9D6qrxQfCOysNeLFRWj8z3pBGtgo+2tEO 9ztmFqC6Zaylza8B9Iqyho7x2LdhmwO1AvfsPstIwX6yCb1S22Me0TRyNzEK27V+bYTu Gxoi+DXN5Dmfz8nXeHlOrahj4AfPmzxbOP8O/velnc7tj4RjfzvCJItPDyWt2iA47+cN e81Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jkSeDAma; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170906c30900b00974c32aa1c8si5360484ejz.112.2023.06.12.14.08.12; Mon, 12 Jun 2023 14:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jkSeDAma; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237885AbjFLUsL (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236971AbjFLUrC (ORCPT ); Mon, 12 Jun 2023 16:47:02 -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 A9BD12947 for ; Mon, 12 Jun 2023 13:46:31 -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 7891762EFF for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0971C433B4; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=fq9Novytq9EKJSJOpiX99BQ9yCRZSIhHk3PPBCKpdpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jkSeDAmaew4avDeeKGbVMWmJIg8UX9nNJdjMiuk1Fx30gwqYD40eUrLLhLve/qfB9 7i2b265TDipJXOgn8Rj/LCefmQvvlQ3AchyTC5SunbYhD68VLY5FVWQW1M9EWPMPF9 CeR4dNYL/T6pui29UWb+t6/tuTJ3JYNLY5Az3PuIZBoQJTAZMTF2z0cbJQ1kJPKL0y bvmTbiwEOMiXA0amQ7pF6nM0n1mAR/4RqbiUFmR57OhPaspoGTbzF4hCBC3p1ln+8k o5Kj8ZrxrCagR1EpTlkINX2wzXYgS9ygFYQrua/8MkpELY6oT/R5vv/lQ3i7xQ96E7 kvr+uOK0xhMNw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CD581CE3A57; Mon, 12 Jun 2023 13:45:15 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 16/53] tools/nolibc: riscv: Fix up load/store instructions for rv32 Date: Mon, 12 Jun 2023 13:44:37 -0700 Message-Id: <20230612204514.292087-16-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532598268131165?= X-GMAIL-MSGID: =?utf-8?q?1768532598268131165?= From: Zhangjin Wu When compile nolibc application for rv32, we got such errors: nolibc/sysroot/riscv/include/arch.h:190: Error: unrecognized opcode `ld a4,0(a3)' nolibc/sysroot/riscv/include/arch.h:194: Error: unrecognized opcode `sd a3,%lo(_auxv)(a4)' nolibc/sysroot/riscv/include/arch.h:196: Error: unrecognized opcode `sd a2,%lo(environ)(a3)' Refer to arch/riscv/include/asm/asm.h and add REG_L/REG_S macros here to let rv32 uses its own lw/sw instructions. Signed-off-by: Zhangjin Wu Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-riscv.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 0d5f15fdedc4..992a1739dd9c 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -33,9 +33,13 @@ struct sys_stat_struct { #if __riscv_xlen == 64 #define PTRLOG "3" #define SZREG "8" +#define REG_L "ld" +#define REG_S "sd" #elif __riscv_xlen == 32 #define PTRLOG "2" #define SZREG "4" +#define REG_L "lw" +#define REG_S "sw" #endif /* Syscalls for RISCV : @@ -181,7 +185,7 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) ".option norelax\n" "lla gp, __global_pointer$\n" ".option pop\n" - "lw a0, 0(sp)\n" /* argc (a0) was in the stack */ + REG_L" a0, 0(sp)\n" /* argc (a0) was in the stack */ "add a1, sp, "SZREG"\n" /* argv (a1) = sp */ "slli a2, a0, "PTRLOG"\n" /* envp (a2) = SZREG*argc ... */ "add a2, a2, "SZREG"\n" /* + SZREG (skip null) */ @@ -189,14 +193,14 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) "add a3, a2, zero\n" /* iterate a3 over envp to find auxv (after NULL) */ "0:\n" /* do { */ - "ld a4, 0(a3)\n" /* a4 = *a3; */ + REG_L" a4, 0(a3)\n" /* a4 = *a3; */ "add a3, a3, "SZREG"\n" /* a3 += sizeof(void*); */ "bne a4, zero, 0b\n" /* } while (a4); */ "lui a4, %hi(_auxv)\n" /* a4 = &_auxv (high bits) */ - "sd a3, %lo(_auxv)(a4)\n" /* store a3 into _auxv */ + REG_S" a3, %lo(_auxv)(a4)\n" /* store a3 into _auxv */ - "lui a3, %hi(environ)\n" /* a3 = &environ (high bits) */ - "sd a2,%lo(environ)(a3)\n" /* store envp(a2) into environ */ + "lui a3, %hi(environ)\n" /* a3 = &environ (high bits) */ + REG_S" a2,%lo(environ)(a3)\n"/* store envp(a2) into environ */ "andi sp,a1,-16\n" /* sp must be 16-byte aligned */ "call main\n" /* main() returns the status code, we'll exit with it. */ "li a7, 93\n" /* NR_exit == 93 */ From patchwork Mon Jun 12 20:44:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134048vqr; Mon, 12 Jun 2023 14:09:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HF2jzssomkjHUKuhnz4Wdd1nli7hjqzx+bB2V8b9vsphotD4ag6mT8CQGJ1ruML+KSlEn X-Received: by 2002:a05:6402:517b:b0:50d:8d42:a454 with SMTP id d27-20020a056402517b00b0050d8d42a454mr6701842ede.21.1686604159674; Mon, 12 Jun 2023 14:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604159; cv=none; d=google.com; s=arc-20160816; b=NXveRF0Q3dWEYYkT7Keap+c22cTaJ9t4Qz5IG1nDpKgFL+Vv5dUXIVGjONVllFsPwe ayXLOesZGhg5g1pennjCjEUOoDMGtadJXaMsxNvalvGTly00wX19XLljTjJ86ADn0YYz 6CNTJ2AKq7ifaZXfaI0gOFhAfR8YmF1HfbM/Rqd0zO3A2noUYQ3+hktUawpj6Tq5FhS1 P7b1SNP51NPCHqwq7GNolKe57SGvlOmM88oWgiBgL70s9dF395pBP9fG93biorfrAwZs XSFPxyZlhUqnV/OpY3oGMN7oRZJFN201lnYwxOZQVodsqloyPlQWWcq8HRrM032n2Wza NeQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1eVoNmiUbG/dYrhYiZF2B8A1MAhXDo95V99VL9MEr7c=; b=xPjr3Gr74Kb2cdZ3wKPP6hjZgt9hrehVry8+i1qi4EfW6ZpJmia0wmTO5vmR6JqCsI ZgMsD3z8lBck1uvZYKrqkd/hqPddnj2o820Tte4Ec2NV8pdDF6SOPzZoQVIwgNi3uV9l Pvz4OB54zo1LxcF9i4SVZvElFyaXV5TGIAKWM9NRUkc3Dn2FBhySWu+wyx/CocyvRi2s JfOy86aDhBzCDWcRMqyxAvDqX/T3gJ2AWOriqt2jhK1d8hSIuMBEUg+cI+cfq1fIAH6s EtePR8RzaqQw7zCthlXCuFcSu2Z3lqvWnCRs4wOZpw0zgP/R3n+KJceIlN1VDMFWS3M5 vMNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z4tZYLuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a50fa91000000b005148ea2f07asi6462117edr.153.2023.06.12.14.08.53; Mon, 12 Jun 2023 14:09:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z4tZYLuG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232956AbjFLUsY (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232236AbjFLUrR (ORCPT ); Mon, 12 Jun 2023 16:47:17 -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 3EFE8198E for ; Mon, 12 Jun 2023 13:46:33 -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 7B56B62F01 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8314C433EF; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=gQgf+u3NBWRBckdfBH59WpO3TYAdJrxhNyjBgomyf/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z4tZYLuGu9qQc2msHRhMR2GA/ycznYe5DLVs0YBXqDL+91RFnKWySPRk4Uy59aGTn ee0mJ4EU6Iutt+Msxb7t1LwiLP9NLeauzS81LAUKJjL+hdQ3M2ei3ryIr7RulwmiqQ X3hmBvpGVi+OhtkBxPyw5+0cOgjINMWRz1O+kmmaQrBiGvCX9WSBs2DCMlv1lV8E5t ZfUhPazdoTmtFCv6U9EdUDo0dYY58ni+tj14U/8C4URTPZ7Umu3MFkE8mKR51iHGjj q/MXI3FP7s3SKNykmPVSIvqwCrkrshSAl73DmBfcYcxodpBNnsAJLnjh6ryOXyeXYR fcQrhr1hpGT1A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id CF971CE3A59; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 17/53] tools/nolibc/unistd: add syscall() Date: Mon, 12 Jun 2023 13:44:38 -0700 Message-Id: <20230612204514.292087-17-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532643656653775?= X-GMAIL-MSGID: =?utf-8?q?1768532643656653775?= From: Thomas Weißschuh syscall() is used by "normal" libcs to allow users to directly call syscalls. By having the same syntax inside nolibc users can more easily write code that works with different libcs. The macro logic is adapted from systemtaps STAP_PROBEV() macro that is released in the public domain / CC0. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/unistd.h | 15 +++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h index ac7d53d986cd..0e832e10a0b2 100644 --- a/tools/include/nolibc/unistd.h +++ b/tools/include/nolibc/unistd.h @@ -56,6 +56,21 @@ int tcsetpgrp(int fd, pid_t pid) return ioctl(fd, TIOCSPGRP, &pid); } +#define _syscall(N, ...) \ +({ \ + long _ret = my_syscall##N(__VA_ARGS__); \ + if (_ret < 0) { \ + SET_ERRNO(-_ret); \ + _ret = -1; \ + } \ + _ret; \ +}) + +#define _syscall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0) +#define __syscall_narg(_0, _1, _2, _3, _4, _5, _6, N, ...) N +#define _syscall_n(N, ...) _syscall(N, __VA_ARGS__) +#define syscall(...) _syscall_n(_syscall_narg(__VA_ARGS__), ##__VA_ARGS__) + /* make sure to include all global symbols */ #include "nolibc.h" diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index f042a6436b6b..54bf91847af3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -588,6 +588,8 @@ int run_syscall(int min, int max) CASE_TEST(waitpid_child); EXPECT_SYSER(1, waitpid(getpid(), &tmp, WNOHANG), -1, ECHILD); break; CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; + CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getpid()); break; + CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ From patchwork Mon Jun 12 20:44:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133468vqr; Mon, 12 Jun 2023 14:08:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68XzFb/UN2mQe8UEm5F1y4a04EIKhXOpkPbOer9obDxDI2c+/RO7uPAgfALp7YvTpcYcxp X-Received: by 2002:aa7:c50b:0:b0:50c:4b9:1483 with SMTP id o11-20020aa7c50b000000b0050c04b91483mr5328456edq.37.1686604100053; Mon, 12 Jun 2023 14:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604100; cv=none; d=google.com; s=arc-20160816; b=GjvW1hBpp1SVewYnC0RIsIlyF7Nh9WZXk9jdY9Z465zpVku0pSwlq0tTe1WMFM4fBU Cr1VjPDRC6nSIj340QK6UiMHXKUjuTCg/tbdGFmmzN9uBtmwpENs6AaBXmKqwsQJh2AW i+kRq4IHw5UjRCCT1hPw+SSaSODzinUikjFwCs1WeF41QFvm0BtSlPVEKP49ODMajQgy yXxp8/mcEPCk/l0341J3TOWN26DofLNBSV5D4MuUciwFI44NNPq0oca9eEwe+kL/9V3G aBW/NSaaY5dGlCQOG5+qYwm25msOBjD7OvnpgeqC2C3MU/YhczWEa9eX2RN+JmPTjTwA 4cVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gLpCto7bgGmBlfSdxv/v2lA43Lerxv0GqrCDptUhcCY=; b=ObCSz3owAy9G2za1ZRg8rs2FOSrGBNNoxMsyssb1gKIayjID/OR9X61GObN9LRDtRg IhFKs1PRWd68RsaMOhW+UfO8C2q/dKCBjHQjfosEUYQyIw31HBvCKYYFhk7p1JN17BE9 Qr4Y/rQ9lnkOpFBQH1vEYHlWHXTpBKFHVh+ehImJdHOosTbp3K9O7lf12PCXqv4CVvMG HkiuDejiYf/SUCL+2UzgHblBaLZgN2kLcfMnl4Wj2fzMABa6JGnWKzT5c5ugZq5ZyfbF z768L0EKCZRtQTQsMF1H/CPN0SCymjOcKzn3tTYPFnQYTWGOIzjWP5wScrw665rn5s3H MpYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N54+BxjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a05640208d100b005163b432853si6704291edz.487.2023.06.12.14.07.55; Mon, 12 Jun 2023 14:08:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N54+BxjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237099AbjFLUsT (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237084AbjFLUrD (ORCPT ); Mon, 12 Jun 2023 16:47:03 -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 D35A3294B for ; Mon, 12 Jun 2023 13:46:31 -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 7A6A162F00 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE4F2C433B3; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=TZGVRE+NeaqSEa0Q3SOYtOQ0/O9QiuguihBm45XSgyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N54+BxjFof+z3ODfbDdCCogqYrE3BfP1vvgBz7JnqzXFxwuyL2klOYH45hsWYn6+J VMT97KD1wDUgEJ8d2jDg64jUnEjDoPJWByJ54BJ5uLKYtGCV9lVVaU+NKgpgv9WSTK uTVJ9U//hB8I04iGw/WAdr2lJbKWmIzYmz/zs4fnJYcVQN9ZAr2gjQv/feuVM+y45U asAYZ2/0nRh0tUONSoaqjnbC9fcVpumNx/G2u15nWX9g/8d9Hldh0znMA4CT5vH3qS a5Z42qJp6LcOQqGYC2pu/lBVAjIw4ChRLC1Zqb3ulR7RlO8U/edXDQ+LJbowM/XgVL 907PHrbgSLI+w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D2092CE3A5B; Mon, 12 Jun 2023 13:45:15 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Arnd Bergmann , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 18/53] selftests/nolibc: syscall_args: use generic __NR_statx Date: Mon, 12 Jun 2023 13:44:39 -0700 Message-Id: <20230612204514.292087-18-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532580749736031?= X-GMAIL-MSGID: =?utf-8?q?1768532580749736031?= From: Zhangjin Wu Compiling nolibc-test.c for rv32 got such error: tools/testing/selftests/nolibc/nolibc-test.c:599:57: error: ‘__NR_fstat’ undeclared (first use in this function) 599 | CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; The generic include/uapi/asm-generic/unistd.h used by rv32 doesn't support __NR_fstat, use the more generic __NR_statx instead: Running test 'syscall' 69 syscall_noargs = 1 [OK] 70 syscall_args = -1 EFAULT [OK] __NR_statx has been added from v4.10: commit a528d35e8bfc ("statx: Add a system call to make enhanced file info available") It has been supported by all of the platforms since at least from v4.20. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/ee8b1f02-ded1-488b-a3a5-68774f0349b5@app.fastmail.com/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 54bf91847af3..0e2ee513b273 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -589,7 +589,7 @@ int run_syscall(int min, int max) CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getpid()); break; - CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; + CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_statx, 0, NULL, 0, 0, NULL), -1, EFAULT); break; case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ From patchwork Mon Jun 12 20:44:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106863 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133710vqr; Mon, 12 Jun 2023 14:08:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5k3ScSMdl8WqiDnByeceGtQYYJ4tcrCu9vf1m985alDTcExoMjmPmW7hy2InmnwcnphVdo X-Received: by 2002:aa7:db94:0:b0:518:3102:9363 with SMTP id u20-20020aa7db94000000b0051831029363mr3905879edt.40.1686604125087; Mon, 12 Jun 2023 14:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604125; cv=none; d=google.com; s=arc-20160816; b=WWxlI0YWSVvmA5HYdW6rUpAYlPns7Yyan7+RQTnYt5aHVC6Rhlsfq2iuyvG58LYAYZ aNAuVTKsI1YNFhxcTiF+McGYJFv8Ff742JH38Tdzabc+btui/KcBzQTzEgwsueZKcxlG CtRlI+V2n87NKARnMoTQakoqm7rNiqOdkFKeVte8JRv+eYLCihVbL0ZhDvOazFLjbyL8 9SIZISTh90D0ljGh24BUsZ/sKUUFRIjpeRx7K+/bBrv9mXdP7Rf7iQuDydzUJluqxJy/ 8xstUFJuuLgwlp3Wd4yRvOP+NnZErhdIX31nHKFUmu59/DVH6zHH7X/RZyldnOkGv5YV APTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/0bhJWxsxOq+rMC6datk17KvxUG/BMNIbEkNgHUGYrc=; b=icuJUIRDkBWeH0PcVMFQKIUNT6kHpep67nbp6btQIjieSg5WsgCrtJDn2t0Os3tbvw Q3LJv9vkdiebNRk12PHqG3rN0rt7+EUWeXcJUQzUP5YaqymvKCmBgwjOjuClFD7b4rF/ exsJbsGs/pFMxjftgUfZDdQC8tbd2CMDd4MZMKl29XwPYuolYAy8x90W/yOpIvhGqY/S c0Wk4NLWfnlmoEkfZu386izVEAabtknyiaXVqyQqQZ0YM6MOcSdcgQWdXgDDanbqW87P K+DoBbZxcGghEqUn6gOIFhYo/gYgGVXuBNP3pz0+w8bRIjaHD2E8cvWEH/ZT2KHNwbgF dzqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cynU8Xf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020aa7d7c7000000b00514a4d26539si6483723eds.458.2023.06.12.14.08.20; Mon, 12 Jun 2023 14:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cynU8Xf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238444AbjFLUvU (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238036AbjFLUsc (ORCPT ); Mon, 12 Jun 2023 16:48:32 -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 C43811994 for ; Mon, 12 Jun 2023 13:46:54 -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 E295562F21 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D24D3C4339B; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=0qJdSevT2VoXww6IrwA93sMpGwJeGq5YXuzo0c9WoWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cynU8Xf5FJnDfOAnabitMNyvFJkhhcCXHGbcwxntjMwhbsKshbGgNoH6S6n1gP6xl 2CEU0PsJNg2qXIAHRRyrtYLFch/0YwNigLS/6IjQdmdi6kb6mWC/41AhG+zTD6iTe3 Ixc7CdRDTH/5abH3RDFKoY9KTjzhmGOU3s12ZqYkfwBmu3/MuUSz+C7rAeOF7L0oKP w2eT32B/0NNyTloYi7f+oCv2VvLfqylDGnY0SJJCpEUZR8BAjeiYoLEMhkXzq+I+kx TS4EoDAoBI8M3vdVmpC5t5XvPaWiUcfvoK5Kt369lCYpNE2VVIxAB6d+s77KPcTXj2 QEy8hQ149y68g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D42B3CE3A5C; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 19/53] selftests/nolibc: reduce syscalls during space padding Date: Mon, 12 Jun 2023 13:44:40 -0700 Message-Id: <20230612204514.292087-19-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532607022819545?= X-GMAIL-MSGID: =?utf-8?q?1768532607022819545?= From: Thomas Weißschuh Previously each space character used for alignment during test execution was written in a single write() call. This would make the output from strace fairly unreadable. Coalesce all spaces into a single call to write(). Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 0e2ee513b273..d5d4dea63cd6 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -111,19 +111,26 @@ const char *errorname(int err) } } +static void putcharn(char c, size_t n) +{ + char buf[64]; + + memset(buf, c, n); + buf[n] = '\0'; + fputs(buf, stdout); +} + static int pad_spc(int llen, int cnt, const char *fmt, ...) { va_list args; - int len; int ret; - for (len = 0; len < cnt - llen; len++) - putchar(' '); + putcharn(' ', cnt - llen); va_start(args, fmt); ret = vfprintf(stdout, fmt, args); va_end(args); - return ret < 0 ? ret : ret + len; + return ret < 0 ? ret : ret + cnt - llen; } /* The tests below are intended to be used by the macroes, which evaluate From patchwork Mon Jun 12 20:44:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133773vqr; Mon, 12 Jun 2023 14:08:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55DiLQqC79US4MoIIcVKabtsGGjvqvI4tvNDs1RhN1y/W+dUwtZQZZJdcM4vBXw6/raPVE X-Received: by 2002:a17:907:7f21:b0:97b:e0bb:8c2f with SMTP id qf33-20020a1709077f2100b0097be0bb8c2fmr8965161ejc.4.1686604132172; Mon, 12 Jun 2023 14:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604132; cv=none; d=google.com; s=arc-20160816; b=Mq888CIWwbHmrg5Zg0tKgsHiS16YhBUb1FU2WKoBQdFZxdYljLp3AK9DCAkOscoR4N eN8JzsCtgJjJB7gWLXJbrF0rzm088i1uvQkIW/sTZxAo6fB7X5b5fi/eQ1lhSLdfus9p /igxqZnKgeQiJ88Z/Vb8rCDK/A7kc5qSqzJD7w39IBTO/UodAPQStDrKr8K37ENheepz JrctgkX0or5bFYJo98ufVjM+7+mAbVc0gh0AyPFbsshAR7v+deQmeNCFO4k6C9lT4EY2 2zF5WFPf/PcyNmJtsyZFNYlHhV1I0fZhu2iza7zyYPF5Js7yAdRM6spontpPjB+N4vat HgiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L8vG03HGS/vNhM6rJN9ceTx5vQw9tsgW5Ao0+gwCT1Y=; b=f9Lwl6QXiF4mZ4eDVuJw9sdl4KhO97reQwoWNakK2pnLxyfhgfqmXVgkm/S6Yk6twV eXcxK/7dzYjYrqYyhvlvWpZehTGoY/qGGyEqTC33InpfNGd476pfnSEZAJuY9lo62Ply tshLgoQRoitjqs2899TYhx6Hwf5lRFMg4FdkgyZOZVPho/qrBoRZbOvF8jMBLx18BHya tiea0hhu25boAYf70NlkXt1aZB3Kp/4XpGgu71+fOUSd9fstmMlIuitV9H84FHZfvbPL K8IzZhuI6BYTdQWQEtTRY+wO4qTPjTJa73ErZq+cV3bt9A2HX4fNhM6LakdXPAZ3YqXm eCNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RK8MCXjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a1709062b8900b0096628b28a04si5626232ejg.780.2023.06.12.14.08.26; Mon, 12 Jun 2023 14:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RK8MCXjU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238523AbjFLUve (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238119AbjFLUtI (ORCPT ); Mon, 12 Jun 2023 16:49:08 -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 B8F13170C for ; Mon, 12 Jun 2023 13:46: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 dfw.source.kernel.org (Postfix) with ESMTPS id F068E62F28 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D86F5C43442; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=Z+V/mSZIwxrjw/qqhnVpPLMMERUm+X+LueBoG1mUtCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RK8MCXjUF86Tz9XjkMAPMucGpoVut1ztAAj5YLlv4KxmkwZAm8IU12lTlY9PRfqsA SEq2+yngy61rZNNWtPUk1WJ8dyMr0wHd+VLOKdxspoKLNtKOLD1H4IbfRFlGrs8tUA EBjjdVzsK32ZaLquy5p/99FwSgFfoa/V/pUcTqSSEreiXTfRLz3omhxegdooi5uDKD dE0jkahXPzuNWYl2fpPN7MKMHSi9zsqQixE8YnHBK4z0xGQF+duuURF8lUHl5ueQj+ lkBDj2aMKu6h9Zai8NO7RmAfC+gNdPqj7b2LAdb8L+THa6mycBCzS/jat1N0HK1Lpo JM5pn/FLaj8RQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D64D0CE3A5E; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 20/53] tools/nolibc: aarch64: add stackprotector support Date: Mon, 12 Jun 2023 13:44:41 -0700 Message-Id: <20230612204514.292087-20-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532614247659540?= X-GMAIL-MSGID: =?utf-8?q?1768532614247659540?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-aarch64.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 76ef26520c85..6a859131c530 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -172,10 +172,15 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( +#ifdef NOLIBC_STACKPROTECTOR + "bl __stack_chk_init\n" /* initialize stack protector */ +#endif "ldr x0, [sp]\n" /* argc (x0) was in the stack */ "add x1, sp, 8\n" /* argv (x1) = sp */ "lsl x2, x0, 3\n" /* envp (x2) = 8*argc ... */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 423d22f353a0..fa0075479a26 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -82,6 +82,7 @@ CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ From patchwork Mon Jun 12 20:44:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133661vqr; Mon, 12 Jun 2023 14:08:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ782JGCnmsGVkrQw5fZt3euOTWmdkNbdaWnyuPa3Z6r5F5gtpE18+sOhnFkbB+k8Pq/l6oc X-Received: by 2002:a05:6402:14d3:b0:516:4394:243d with SMTP id f19-20020a05640214d300b005164394243dmr6014667edx.34.1686604120662; Mon, 12 Jun 2023 14:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604120; cv=none; d=google.com; s=arc-20160816; b=g3luhS1yk7/cdKY59u4V/k7vyst8Yx+2sp3to0kn1ZM3cjnLYfZY12Xs1tykJJ/8k3 Uu1WBNNH4zvnTyzE8M3fT1ww2ZpWolChZZAIzCcinxs8QS1U4r3EOZB+po0DlHH798DA C6+jivWCZxDXKheEGmuagQuR6yU8kK0d1N0Fl6iCG7zcwZPvaE0K8Eemb30vRXBjjp8P g3euUbT7HPkE655Nc48lOnQD8oKgmm2B976UlZAfBwFhlXEyrJbmqB7zehPOSDSG3etB H17JJrOztzHhNWzF1w5gNY9s8E+VlYOLUSPV6zHTDhCuTpKmZu4k7Wy2Nbh05riZwO10 f19Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pJOIh0ONCAztZTAN/acOxH2UDu2W4MafXZTG/Ir1nSQ=; b=GlEWPdIOfymEUS3KYuYpzrJ5BLMkZC1vC9/JjDAUTXMKyxtTMu6LMlWS43A2CBAws/ lDi0GKzNztI/EsyU9GK2lvVHbWRy4XStgxmPDhhr9eTzJEkQsdeBUlmbgA2Ui4Cwl+PZ dWjdYEQubHjXyQyMe+syBlqU7oPAjSHMGjPpKVTxQh83gIN6yQr6XRifvQAr4ftlp87N M5BVqSPW3D+5UJJLGM5y40KOU3PBq6tggY+pVxkKC5ZdP+4af/1qgnTM2I15Z14wOG/f nCKKxY97oxCj1xqtrsnyLvBfoQxRT0MVDHqCDbPKrncjsgxl7eR5qEseQRqQfXNMTIv0 a2nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FO82VxxS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x20-20020aa7dad4000000b005022d0268f3si6462845eds.669.2023.06.12.14.08.16; Mon, 12 Jun 2023 14:08:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FO82VxxS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238088AbjFLUtB (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237397AbjFLUra (ORCPT ); Mon, 12 Jun 2023 16:47:30 -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 8ADE2295D for ; Mon, 12 Jun 2023 13:46: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 897D1628DD for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB265C433D2; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=EDCKj1t3cMrbH8q5QIPGb5JPV2twW1putED5vpkf138=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FO82VxxSEFUyIv6IbL2j/ZwF7wqdxAxZCuySjIOEYZpFm+iRPSQqlVhd7cK1iLu9z PUtQOtQ5+xf3gQ1ueYU/aEfYEcgOoi6b8DpNVWv19fjjaWvjHU4udUOj315FB9sFvU cTY0UT2JC76ydSvsX7GtX6MGSp4TeaRUiWSJZCiSbD+/cdUkkbJxuhu2mGtfXyf6Kj o8f76w7/xcrkM4Ei+e/yrMAvzGAinWrUxxA73tyXl4K4604fZlMfKhC5cJc8NXuwEf tZ8ZyM66Aq7yun6zbn+QpU0VzT1B+yz+489IdHkesRAZrKz7UQae91TpS82ad1ppGl F/F0LCEohcKTA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id D8799CE3A64; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 21/53] tools/nolibc: arm: add stackprotector support Date: Mon, 12 Jun 2023 13:44:42 -0700 Message-Id: <20230612204514.292087-21-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532602598485356?= X-GMAIL-MSGID: =?utf-8?q?1768532602598485356?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-arm.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 2eab1aef321b..202e64f537dc 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -199,10 +199,15 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( +#ifdef NOLIBC_STACKPROTECTOR + "bl __stack_chk_init\n" /* initialize stack protector */ +#endif "pop {%r0}\n" /* argc was in the stack */ "mov %r1, %sp\n" /* argv = sp */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index fa0075479a26..7585035cbb0d 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -83,6 +83,7 @@ CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ From patchwork Mon Jun 12 20:44:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134069vqr; Mon, 12 Jun 2023 14:09:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ExgFQrvt5VdGH/nrkBRLVSW3Tv9b4BvOUUOB40puiyMgreL40lxkyKosxrMXfo8ZnHqiK X-Received: by 2002:a17:907:d2a:b0:97d:cda7:f0c4 with SMTP id gn42-20020a1709070d2a00b0097dcda7f0c4mr10256628ejc.61.1686604162283; Mon, 12 Jun 2023 14:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604162; cv=none; d=google.com; s=arc-20160816; b=w1bZfzYzyl8d8nVf5fvchFwBD0esC6vcQyzLY5JM7hRv0jet7+Hn/cDY+WwYNip1NG 6oeWU/VyQ+Xk1gKFRE1uD//0OEJ1RXbjS6X/Xi04YO4GuDWbAy8Hnz7GHcN3aq4n0gvi hKlpczUyXBhhnAMlQ6ZQSujhBh+BNwAB2XilKs/qqWsHzs0MHEPKAYj2OMS/hyF904wf vZtcxKw3RHYnwCKxwnG3FMyyMvRUnlX3Elo7C446ie+XojNLpXoJI/s0GKBHpFcJJKyv JzOu4Lm3izphyj7fCbdwqyOc3i66D1RHgbF17GlX9Uz5F9ZbJFqEmtPIC4neEL3EPz9P 9OUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9lHx1WijCPG0yUBn1kqHn3u/XLFPDQiani9s1uz0B14=; b=QE6MhP1fKXcRp0tMyDNEjuDoaYbk2iUN4M1rBP/VP6sEzfhVYB7Cmr2Ke0moDmmoFo 23ESF9Aho4rp3kKkgWsIgNIBsaMUk1D3uNPnJAzpFjLg5dgS4kTlz4GnChh6EMAfKBKn 7fydJPtbtLSptZy/MKMoVqkXtbRo0xCgypALNarRRuEnkSSY4YlWWmO2zPdsQG0psq1k pt21ZrUAMQJvNT0fAuAl9AlZm8IjXJ8sETTYVsKIK2FmFuEsqzmyPo0cOjTrhBtJcphf acFlZN3HfYs3LBegEWaeqy1NaurZhFGmZf8keWVk0KV1rYznWRk3HGmGgux5r3P1vNc9 3V8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sepdplrR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a170906130f00b00977cc47e626si5274806ejb.107.2023.06.12.14.08.57; Mon, 12 Jun 2023 14:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sepdplrR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238507AbjFLUvb (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238186AbjFLUtX (ORCPT ); Mon, 12 Jun 2023 16:49:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FE531BCA for ; Mon, 12 Jun 2023 13:46:57 -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 0043A62F2A for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB36DC43446; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=I2MKwbUvzTuvTg2VmUjHO7LHWoQiT/tq3IBYoDNtSDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sepdplrRhQWPURYc5Eqxn1hVYV8IEGy/GYobS/5P/D2fHijzw8lby2q0YTYxZpYzo GZ7SWBWY8UUB4tkTStczqsAssWZQuy7j698x1Nk57vNGcwMx6NuT7jZKWKIOfYPRC6 5O/ik1/GEeLjn4G+JRPnr8JwvcuGTw8dombfevh2SJUl09C/0yFB3iSBDuK+OdutPk cyN5dOTO5P4yg2hSOoH0oYGKgwUDl9XLrn4NL9UcojSCGSktvSE+7E3uqv6+L6Am99 cf3FJ2fL0sJIJiCt5XGaE3YdPhNr+VBggsVzmMFx2fo2fG/e0fJDPxgZnwm8y/IPw2 s7Jd4pMZ8hEng== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DA96DCE3A66; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 22/53] tools/nolibc: loongarch: add stackprotector support Date: Mon, 12 Jun 2023 13:44:43 -0700 Message-Id: <20230612204514.292087-22-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532646282661751?= X-GMAIL-MSGID: =?utf-8?q?1768532646282661751?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-loongarch.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index ec3b46a991a9..07e3b1fd7262 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -149,6 +149,8 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + #if __loongarch_grlen == 32 #define LONGLOG "2" #define SZREG "4" @@ -170,9 +172,12 @@ const unsigned long *_auxv __attribute__((weak)); #endif /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( +#ifdef NOLIBC_STACKPROTECTOR + "bl __stack_chk_init\n" /* initialize stack protector */ +#endif REG_L " $a0, $sp, 0\n" /* argc (a0) was in the stack */ LONG_ADDI " $a1, $sp, "SZREG"\n" /* argv (a1) = sp + SZREG */ LONG_SLL " $a2, $a0, "LONGLOG"\n" /* envp (a2) = SZREG*argc ... */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 7585035cbb0d..ab6e7c0c2494 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -84,6 +84,7 @@ CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ From patchwork Mon Jun 12 20:44:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106855 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133617vqr; Mon, 12 Jun 2023 14:08:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MQPsFp0AmXqNj2B3J7fid30xsz6Tzc4BOJ75gp/Zw5vrCeI6FG7eS/Bs5/m3tkhHn5qRi X-Received: by 2002:aa7:d518:0:b0:515:4043:4771 with SMTP id y24-20020aa7d518000000b0051540434771mr4709922edq.42.1686604114563; Mon, 12 Jun 2023 14:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604114; cv=none; d=google.com; s=arc-20160816; b=RwxEkHKwYP0sqb3aptuQA+4XFRGmylSzoxZFe7aKQQrTQEb5eqXZwTCQ+RRo7fL2Ct mY8zD24hCLBRFASA2DFB9FUX0K92B3vfrUEyFRHYlWg4T9CWAFXzsobsMqBXkOmzt4F4 F+pbgsaFnyYyqrFh2mmY9yEX8rrh7fRt/9Q3aWCS0TyK/ELyFlooxfUsiqhx5nrKxVyO wmK0BBePdH6QjaEsCa/W/MP4pZOQW5Fk3GHXAor+COp/iViTdC97DztTIn7ricjg4Nsq xo9V5SbAGJG4eRrH7biCnZrE5TSvHN9RHUAoDcjkc7Tl+hqD+kjZUjtxvoCYZYpE2nD8 eW4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uC89yjat/oW3A+F9zMnUu8H1kTobr3xcMmKfZU4gA08=; b=OnKUKaGYy3JpcGMZOvj4bpzYMHchy9t41ruHSSMioG2QwBT9v1qwQWXjC/n8ttOPY5 3OQV5dHEL+mK8S1cydBWktI6LghIoifSuqz9/W7OLuu5YT2kABOtAGq/gqxNf6Q1ToV6 /9dcu+8CXbCSpNA9L/JFtr5XssFVnAAXl+J3Z98LYWqm/cmotQItRiNnVP33CLyR73Dx ard/eyjDGL7IdSUXltMtxihuaKjbC3URf1MDqaCL+mkPbMt8VTfzy4RrlibDNCFowJ1P KfVVpnt5hn7J7LZEXY1HqhVoG3tY98Cq/am5nIFGLi4hvXvr5R7w+Tb3l/mVnkcJPx+e cIJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZNnxDU1T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k22-20020a056402049600b005182dc07707si3402753edv.10.2023.06.12.14.08.10; Mon, 12 Jun 2023 14:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZNnxDU1T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236755AbjFLUsv (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbjFLUra (ORCPT ); Mon, 12 Jun 2023 16:47:30 -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 2394F295A for ; Mon, 12 Jun 2023 13:46:37 -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 8517262F03 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8AFBC43443; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=tOuRtkHYs9MNwpbcUTDT/8K9pnXHgkjL97lAfJJGhgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZNnxDU1TXOuRT3FMSlYGWrX0TkT4AnPHvMcSbWXHi5JWoxLutDnUjo15h76iV4cKW qslqvv7be++VpA8Zr3gwFpBBSiOqQblpmO5Zmed38F94zw01qMYj0ShI3GVKjca1Uk zMSSY+BHp81+3g7VxTFbVp3LEZibSYBeoubXkpLFBZsLnQ/vyPASWFl/ljpH0kHC2P SMu+jlclqrf6MsdDE++4fzt0ZmYc4NGhtLSfb3xf+CTQmSlcZdk3CGDz9cV8NKfnBd f/WP4YI79WjskRDkr5yz6J2y2Ir5xmayucKTJbE2o5qjFNuBT2bW7C/V9MSnNTMuT8 xOoUzA2A1ILZA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DD080CE3A68; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 23/53] tools/nolibc: mips: add stackprotector support Date: Mon, 12 Jun 2023 13:44:44 -0700 Message-Id: <20230612204514.292087-23-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532596268642124?= X-GMAIL-MSGID: =?utf-8?q?1768532596268642124?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-mips.h | 8 +++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 8822f150e72f..65c19ccc7f9d 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -179,14 +179,20 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code, note that it's called __start on MIPS */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) __start(void) { __asm__ volatile ( /*".set nomips16\n"*/ ".set push\n" ".set noreorder\n" ".option pic0\n" +#ifdef NOLIBC_STACKPROTECTOR + "jal __stack_chk_init\n" /* initialize stack protector */ + "nop\n" /* delayed slot */ +#endif /*".ent __start\n"*/ /*"__start:\n"*/ "lw $a0,($sp)\n" /* argc was in the stack */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index ab6e7c0c2494..6d660d922240 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -84,6 +84,7 @@ CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_mips = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ From patchwork Mon Jun 12 20:44:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp130149vqr; Mon, 12 Jun 2023 14:02:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fPsg47n+75nTrqsHhJc2Co0//B63CdALEkf5qWjEwrRfhelSuB7jmlBfCIEHndPeymeN4 X-Received: by 2002:a05:6a00:a01:b0:636:f899:46a0 with SMTP id p1-20020a056a000a0100b00636f89946a0mr15423325pfh.15.1686603740520; Mon, 12 Jun 2023 14:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603740; cv=none; d=google.com; s=arc-20160816; b=eSvjV0IcylNkkns4UaLw4+u8E3kl1KWrwyzBDexX3q6NqNOOx6DYFLPzax8CS5pVbJ G0vPufaURGS5UmKCaoQE2E5fFDeW0uMyIJnXSBaIq9FHg8MnPUdMy8KhaQrcRMoLlDdR Cacy4FXp9Up//gMlJVuC2CnY5M3GbjxyZj/vLBbOVnALB+jJseyYzjM9kJU2+rCiJJGb FMvVbwGo+G0cjrdUlP9wX/mJ89HvvjRjciyaY59nqGQ3B5K947+KTbf9fhHMYNI0TUwf 0tDNpalgn4eS8jgZYWPI6EKBksOe3tv2rQLRoerbgBqBvRGEZzquWMFVMsOJg2flFpK2 u65Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZUzTwmpp3dEPaayz4bS/3wGTXDvztziEbihneUCoVoI=; b=S3EzxgFd7Z0JdisEmlvEmC68mh+4TGqZXO+URFiY2WNf3ED1HpCvxX10Bz3ccANtv7 TJ1180D2ciuT6rBH8PSrLFlvhw/NAxfFL/LIUoKF/S370i4rsS45lxr40ZZAKw44NPYF eRpqA+3l7BE4aXs1une3iR6n9VG8BhH6o0tfxQWoVv40ptBYNT/jjait67IyVFNSw1SG 5wuqdICSCb99NBAkjHO5WUMLOJrUrflP9knholAUGQ4wNCHIziW3inOLtSFfc8fwTGXD FLRSM0YQlt4zSFwYpSQHJx4cI2AT7KIVEqp4BKx2+mqVntywPDVblP/CHb1adAsUmmB+ QaPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hlX9DSde; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a621c04000000b00664ee1c22basi3398244pfc.208.2023.06.12.14.02.08; Mon, 12 Jun 2023 14:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hlX9DSde; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238478AbjFLUvZ (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238095AbjFLUtC (ORCPT ); Mon, 12 Jun 2023 16:49:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCB6296B for ; Mon, 12 Jun 2023 13:46:55 -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 EEDDF62F26 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFB9DC43444; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602716; bh=GOuO4QtR996HCmcdYQAWMIyqhycVTQWVHdyq4/4h32g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hlX9DSdeVteob3wFd4346DXdfp9KfFrfNJiGAadHUIRiM6b+gRTHNEz55OCXoCxeu wcmoVXHUN/Rm6bbMMhM6nv2BgUopEg1fxrK0EwG6Qfsv524xW7vZR32zJvrsb8zDX1 S8Kct9/+0fmKNRLv2YDiwFcTcb9SCf/7yo6HKe8os/YoFWVDuwi6vTCTfRAK7ToMxu gzxchzk2GJFjeehNtu691BdXiQTsE+u4Y5NRS2nrvXgt+j7MqGtNdR/YHsRVlZiF3p thnz5Qdwc0gC3C1nxga7E+bdlSOGiRDL+LpnoNNv6T+9VKLsj3vIysP4BCnl7B97d2 T/jxKSuR7M0Eg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DF9B1CE3A6A; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Palmer Dabbelt , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 24/53] tools/nolibc: riscv: add stackprotector support Date: Mon, 12 Jun 2023 13:44:45 -0700 Message-Id: <20230612204514.292087-24-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532203731156042?= X-GMAIL-MSGID: =?utf-8?q?1768532203731156042?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Acked-by: Palmer Dabbelt Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-riscv.h | 7 ++++++- tools/testing/selftests/nolibc/Makefile | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 992a1739dd9c..d0439249c9c9 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -177,14 +177,19 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); +#define __ARCH_SUPPORTS_STACK_PROTECTOR + /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( ".option push\n" ".option norelax\n" "lla gp, __global_pointer$\n" ".option pop\n" +#ifdef NOLIBC_STACKPROTECTOR + "call __stack_chk_init\n" /* initialize stack protector */ +#endif REG_L" a0, 0(sp)\n" /* argc (a0) was in the stack */ "add a1, sp, "SZREG"\n" /* argv (a1) = sp */ "slli a2, a0, "PTRLOG"\n" /* envp (a2) = SZREG*argc ... */ diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 6d660d922240..bd41102ea299 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -85,6 +85,7 @@ CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_mips = $(CFLAGS_STACKPROTECTOR) +CFLAGS_STKP_riscv = $(CFLAGS_STACKPROTECTOR) CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ From patchwork Mon Jun 12 20:44:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133973vqr; Mon, 12 Jun 2023 14:09:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7JnxdX6c0DV44d9aXzy5Gui5CHjEWGh4w/7F9ai9SWA32Eq3fSR9sAXRd2lE3/nYBapXAJ X-Received: by 2002:aa7:d9c1:0:b0:518:6e09:425c with SMTP id v1-20020aa7d9c1000000b005186e09425cmr594080eds.9.1686604151737; Mon, 12 Jun 2023 14:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604151; cv=none; d=google.com; s=arc-20160816; b=fgif5eBeFacxgPJthp4yGaD6BuJVaQMQAEKgh/rdwwkMlS6Nfti6Gy3B4D2ojszvOr vfEr6vT5G75mll8TZ04TBQ+dYss6buuHGvScE50m/TnAUJOGN+xv9no6A/cyQ27bV+2M 9VVqpT9NNKi0Nzwohdx0PTQ8P4FRNllaFla2U3lV6M0q5imFw/b1SpIf/06OgQbS2wj/ DtCidvU/bIAGAmoPwy5J9+Ld3y7NscVL4i3MbmhfJmSbHMkGdyKUuSKce5tS72p79kE6 kwBZC07CqARqFYo/CgWitiRVqLOZ713FVeKIVGlfh+C0O0v530xFrBBiCov3SzIIAevj OPYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X8Wdo6FqwZTFlZ8DrLIM0waihXufR5p1+atg8pb6zTY=; b=Dk1He2HjEr0iF40rCWsaaNZf2IaNv8KJD3jXBKZ+nC8/m5H/3NLMCYo9d/Korxgh7p Ok5ZqS9voiicOPE48bP063P4V/xK+xMrTYANwmRMeiiqamgtNI2hlLYbJ4DhOf7kq06t NhUmEjSQMKuuvyqVXURBPK6BESJczq2f1DudtaOWLTqM6RuUrQ3zSeKEfU9bS3MDNfJF kEW+9SYV3bAuPFu6rJ4fOrcgNGpQz2MGSG1QwCQc0QPghhFVzTetqtlZKJp18SAYqqxq zdNIWVbPV0+PIeOjJYbjn/kuk+5QsWDbfKfAXtBnVKRoBNCpwnpNUj4Nq6ZIDbJukFdN azaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=spOZrdvF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d22-20020a056402079600b00510d8a8acc8si6686811edy.397.2023.06.12.14.08.45; Mon, 12 Jun 2023 14:09:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=spOZrdvF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238565AbjFLUvk (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238220AbjFLUtZ (ORCPT ); Mon, 12 Jun 2023 16:49:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69C5E170E for ; Mon, 12 Jun 2023 13:46:58 -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 02CD862F2B for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2696C4339C; Mon, 12 Jun 2023 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=m54V3BXYYYooIJldJgkaYR8kVbGMqD7cVsRVfWDay0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spOZrdvFz0K6d+kGIjeQcrpII7KW8yKKYd3Eil3uZOUEzveFbILDXlD5w5K7Lg8Bq hRdvCF0ixWbdTjOmrpX38iUzhYwOvHj+9uput8ThlpyvdH66IIii+s37IhvOqvTEDH JnOdBnoOhwrfO4THp0cLeteQ6cpE8Wc/O5Bu/L527m/5eU61ujDV7JU3S885blSJFj lGgORVDdTGgEbx736hhMrtT0SXyeVWaV0buRAYW8glK2Cmml7FpCK/d8/98MIY56Cm +06vGQ87LDWghnGzILPya3Kt2waQ7KvmRx7ONWHeREkEVVYDqRSJ+AzTtePfv2tpDL gwqY5RIq1PtPw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E1C2DCE3A6B; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 25/53] tools/nolibc: fix typo pint -> point Date: Mon, 12 Jun 2023 13:44:46 -0700 Message-Id: <20230612204514.292087-25-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532634818248963?= X-GMAIL-MSGID: =?utf-8?q?1768532634818248963?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h index 2d5386a8d6aa..82b43935650f 100644 --- a/tools/include/nolibc/arch.h +++ b/tools/include/nolibc/arch.h @@ -7,7 +7,7 @@ * the syscall declarations and the _start code definition. This is the only * global part. On all architectures the kernel puts everything in the stack * before jumping to _start just above us, without any return address (_start - * is not a function but an entry pint). So at the stack pointer we find argc. + * is not a function but an entry point). So at the stack pointer we find argc. * Then argv[] begins, and ends at the first NULL. Then we have envp which * starts and ends with a NULL as well. So envp=argv+argc+1. */ From patchwork Mon Jun 12 20:44:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134629vqr; Mon, 12 Jun 2023 14:10:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UI2imy1vvndVeA8O9Eksv92Qoq1hpH57vtz5dQYZoQtAZfMGXwjzmQtDAztvFetY6YVRS X-Received: by 2002:a17:906:6a29:b0:97c:b6e6:f36a with SMTP id qw41-20020a1709066a2900b0097cb6e6f36amr7813128ejc.62.1686604227369; Mon, 12 Jun 2023 14:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604227; cv=none; d=google.com; s=arc-20160816; b=EvdaPhDBWi30QSC98t7LSEYd5xnCD1JxhpE5Jbl5FjL6LudkkOhfh2x17hcoeqxxBX ygUL7VZUB9Vn51CXaiUZoB09LZ6+CboUhrZBT+LOde3DRjzoJ8VO+hnVpma70jXoVF2X vWc16KRhGFp9m6zgX3d9eYkdmok0mMvmguvBdTOpvRJfys+AKN7cfbMG5eGPU7w8/mRu NrjUGEbYQGCwpiEknmsencOw8/XGkxq1ShqVxg+jAPuRccOiq7MTzKHaka4Qifr9Wry3 Flv1GcSJI6lwvciSSUZBcJQyu1S6n0R6si0CG/vMhWEbUb940dwbE7ic5mmMQ5sSDF6Q 6xZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e7OywNO6woX8jazxoF3DRue88w4LKUCvmyGMABiSr+E=; b=eK1EqW3vBX56tHeNonwk7Nr1tQBXdzkV5GvdY7t2hevmiE3YjUSHk8oCbka3oI4MNj LjzFyaUUaYdqnv1OHwmc2zOXXAVg3Hry0ytCey6RH/b+2T8mgTLFvQijM8Sa5tKDF53p IvQKCmGVgOwtg9JBWbeY3PQDnSphaaKxs5tuDNIehLkOiO7co7L60kS49a7lhZ8WBHZJ m3/rpkFoUr1AF5376iPONMnc5deMzsylw3AxFYYUbgL/sEsurYp0s7/1LZpfmbRMDcb6 UsA0Bk9Os1kx9IwF89Nx5DR3LFhyiBdY/49plCtv3Dr5XhTjriTEHu1VZloYaC8NEMiY GF0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T6chP21R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a1709064f0a00b0096f7c8c215bsi5557302eju.874.2023.06.12.14.10.00; Mon, 12 Jun 2023 14:10:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T6chP21R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238050AbjFLUsd (ORCPT + 99 others); Mon, 12 Jun 2023 16:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237384AbjFLUra (ORCPT ); Mon, 12 Jun 2023 16:47:30 -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 8A710295C for ; Mon, 12 Jun 2023 13:46: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 9E46062F0B for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03E8FC433A0; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=XFbVAoZliJCAsIZtC3pxKZbS9h6xeSTohI3SMPpRFt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T6chP21R/i3XiGgRmPpX4CX4ZHFRyynO1aN1tCDAHDWdODS/Js2M72FfrxexZqBso QRBqdL9SShZFknnwRIWjCoyKVDy5e2sQPVBWViDoK1zIcgEFsCj6PyzmoE6syLm9Kv 8nroR2RR9jbX7Q63pxcYbmSqHhtht01/wi6xutzJmA37TmjYt6yCUpXCleG3Ir8HKE yfugWe9O8lnJwAxLEdGpxj7WdWbRXKR5u0wnqhqCDHVoTGg+DrFrXX4TUBYyWLQRf7 YJWLOLq5hSW37D8CZPhRAUOQqglKKLTcr8pFZ1tCzUwgrMCs+d6K05/QNNX7xWA0XT dxBrYLAJ5mGpA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E40AACE3A6C; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 26/53] tools/nolibc: x86_64: disable stack protector for _start Date: Mon, 12 Jun 2023 13:44:47 -0700 Message-Id: <20230612204514.292087-26-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532714192351290?= X-GMAIL-MSGID: =?utf-8?q?1768532714192351290?= From: Thomas Weißschuh This was forgotten in the original submission. It is unknown why it worked for x86_64 on some compiler without this attribute. Reported-by: Willy Tarreau Closes: https://lore.kernel.org/lkml/20230520133237.GA27501@1wt.eu/ Fixes: 0d8c461adbc4 ("tools/nolibc: x86_64: add stackprotector support") Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-x86_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index d98f6c89d143..e201af15e142 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.h @@ -190,7 +190,7 @@ const unsigned long *_auxv __attribute__((weak)); * 2) The deepest stack frame should be zero (the %rbp). * */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( #ifdef NOLIBC_STACKPROTECTOR From patchwork Mon Jun 12 20:44:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134236vqr; Mon, 12 Jun 2023 14:09:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56uAoXzwpTnwux3ZbpqmmJqd1DNCxTF35/Ueg7ZLzmG6K9QpjazaCYGOJtKHoLex+wDa8n X-Received: by 2002:a17:907:2d29:b0:94a:74c9:3611 with SMTP id gs41-20020a1709072d2900b0094a74c93611mr10664873ejc.35.1686604182036; Mon, 12 Jun 2023 14:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604182; cv=none; d=google.com; s=arc-20160816; b=XQa94nZV6yizPqXExsbCI+XaRCL0jrqx9ysqAywOZ/8iBdXzMeUo9IVV0XRsn4/7wp BnShFO9ejHKOqzp+4DR5zRij/g9WXNTD+nIyTtWcB0XjVD4zyHxS09z9nTz2sCCPbcuq 9hAauMnLstg+RcM4jJQfa/FVCfwUJg3JDmGB8XwnJvEdHSuhGFkYkUodLVEmlDv4zhJt hUhhqf03B4U5D0M9jU9v2mMx85rNpu7doeruZYFqzLJvBhDTMTLVD4GnhbA+YchadUhj gbvgOh0AHwuSyq4avOkMuwpapM6Qfe1s2kLKpdZwyIOsGWGdX2VFYKFWmto3mPjisyPL /PuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5Rg/PfxzArA5bo4KUvvS36kuhNsUQ9UFFVzIapUsmHI=; b=Dck3fMWrRbvoKFeQOj2iGmwtTynd2B5ogz6ckwLFtqrYnI+x5ooelmV7GNlwu9OPDD zHr+2NzN4/HecNBeofRgPPlPi/ALic7uGga8YifviNmNjQOSM2DUCVJq93NLemvlDwYW zeUOe35ACQCnpOqm+nYxvH4OS8cpoqfR2Jb9mqcGhPKr1QCaxkuLzFPE+y/MDQoUii6J F1fRTpTetja6s56wNupU9lV5shhDgy069xc0jE3CrRgJJKQtUmTxRbpIen+cjYEdgr28 w1j52xVIp0VTkrxOLBg1abvVG3U68CwwSkREs7XMZsy8QeWd20goDM9NZ22ve9jtf/Pc R7SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p0Ohgdl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a1709064f0a00b0096f7c8c215bsi5557302eju.874.2023.06.12.14.09.16; Mon, 12 Jun 2023 14:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p0Ohgdl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238635AbjFLUvt (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238233AbjFLUt2 (ORCPT ); Mon, 12 Jun 2023 16:49:28 -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 358B31BFB for ; Mon, 12 Jun 2023 13:47:03 -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 1125062F2D for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AFE2C43445; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=m6VW9L1DfLWVSVi0RNl6hit3N3enOx/+urG9Qu9XTN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p0Ohgdl5koVAi4NEWD3gyKQla9v1Znt/dlMhMqbKNxXuOrDZyMlTGgp2OhL4j31H7 DdLqVvl+gc1fSiIiLDYbCL95Clf3cwRZHI40wnNnURs3TQQjPOA366vHS51bY1+V09 u3CbgcCz1kVQfKkkSkOaHn9vku+k2BWUT1ZQl16sEZXSzoUaJEAyymSmvdOhMhJfo6 HJ6dtFzW3PKq3wMkZsPUy37BJXepc8L+fkb7B90ABwOwKgSpEYvdPfTZ0IWUfzGvN9 G1Vv332VaM6wGTw+jY4jgG+571m9h+7N6yT5CFPzLVDDSd1NH0ZHgsSkmNVk3SjhTH xXSq+V8IpCQkg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E6798CE3A6F; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 27/53] tools/nolibc: ensure stack protector guard is never zero Date: Mon, 12 Jun 2023 13:44:48 -0700 Message-Id: <20230612204514.292087-27-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532667131095215?= X-GMAIL-MSGID: =?utf-8?q?1768532667131095215?= From: Thomas Weißschuh The all-zero pattern is one of the more probable out-of-bound writes so add a special case to not accidentally accept it. Also it enables the reliable detection of stack protector initialization during testing. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/stackprotector.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index 77e5251c4490..b0156fc077a0 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -45,8 +45,9 @@ __attribute__((weak,no_stack_protector,section(".text.nolibc_stack_chk"))) void __stack_chk_init(void) { my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); - /* a bit more randomness in case getrandom() fails */ - __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; + /* a bit more randomness in case getrandom() fails, ensure the guard is never 0 */ + if (__stack_chk_guard != (uintptr_t) &__stack_chk_guard) + __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; } #endif /* defined(NOLIBC_STACKPROTECTOR) */ From patchwork Mon Jun 12 20:44:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133867vqr; Mon, 12 Jun 2023 14:09:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tCLQ4FE9LgfgouwcGFTUTvAsfPhBCVYMBggr+Wc0D+lqOjvxMtrsE3lsducnTG6lTMWEE X-Received: by 2002:a17:907:96aa:b0:96f:d8a9:d045 with SMTP id hd42-20020a17090796aa00b0096fd8a9d045mr12374603ejc.59.1686604141841; Mon, 12 Jun 2023 14:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604141; cv=none; d=google.com; s=arc-20160816; b=m7yCkC9Ix8Xvmjnz98Tb0xahT8e7zB+PkJJFZl0QQ09D9eG4Tone4/b9usGkIM26+x BKwZ7nAehqac5Fgg2cFI9ZuX9ow6FSVprVev6JVPPcOwzExTHCgNSJh4dgK8fX2epg19 Cv2vc/F6TuQ5WOUohx+A+f6j+LZWrROMiASywVSo0MfJXigWl0rsI3D5Yd+g7chMdhLS LJwxWNweewSsYPHifSDVwTiHisV8Mtpfy4S6U+ibPfUZcVCVLaAblhGj24lAbhTb/0+j ysl99IvL87PBvwPBbv+ut/RJ1bW9P5sPwItMxhd2GuqX5mjFSxcGLq4SkXOrAXH6URNr LbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q/jKbBAagPcqKM1C/Uoudv2X+CxcCPOt0UMDg7rZIkk=; b=Vzybpne5f2p/Dk4Vc7HwNO6t/Y4aLhgVJlQbe2WcL/eJoxVkJhkScKYVnMklTcbuGX Bk3h7hAIwix+RzU/u/EGhb2Xqzh7xHNJLTmE7Q9NCJ/4q4SBrdkEszvQPenDz7FbAekd IFoUJ+JsGicIQA5P65H9Gi+rofxkMH8NTWAeuCSfKBwnJZebymbkWPFpm0ZqqvdNJgFd EMQebfHogqREzRJi9jM3VirtPb2tZlT/B2rjkUSgQrSiktuMa7wmVq+N+tFLXpwLgwjk dqxWH+AC474swLYBsZMvuxvhCzo6NOv9+/zJHkm142Sc09ljn/BR/PkHydoQiplrSeOA QH4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qdpXve/Z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a170906840300b00977cc7bae82si5751623ejx.365.2023.06.12.14.08.35; Mon, 12 Jun 2023 14:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qdpXve/Z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237568AbjFLUtF (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbjFLUrd (ORCPT ); Mon, 12 Jun 2023 16:47:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C074919A7 for ; Mon, 12 Jun 2023 13:46: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 dfw.source.kernel.org (Postfix) with ESMTPS id A38D062F0F for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E9BFC4331E; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=NIJsLUCkPm+SlEyAKKZ+JWMSEL2gT9Xxru+zz8R8kig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qdpXve/ZQctJnAKEwXta+3CR84M0ydiwRgzAwsMvH+1IVHWwYSAf8I9HzbiRvUT6W nEL3XqqPScLydNBucfB4/Cb4mpR/g1Y7Vtna80a8ClLUjqDHRezODsChULKNiX/6ei luDd3+JfPrEVZx35Vol9KWiwWvMGJQyvjjiweLJtztuodVVrYaLIMO51atRhVQHFkK qFpZ5OnQPZ7rbvCIAgYjoeeAHPrbiLeftANE8uGxkAbFZoM4PJPF5b7a9jekXnMmyq uEVUTxmMD17Xrm85eTlMWXeDc0vigOnVMnGYXpA/FtSVSUaG9/jJqfCit1c3KMqxKo 9f0Tw0/Q+ABew== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E89F0CE3A70; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 28/53] tools/nolibc: add test for __stack_chk_guard initialization Date: Mon, 12 Jun 2023 13:44:49 -0700 Message-Id: <20230612204514.292087-28-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532624430966044?= X-GMAIL-MSGID: =?utf-8?q?1768532624430966044?= From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index d5d4dea63cd6..861b9a74b71f 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -808,6 +808,14 @@ static int run_protection(int min, int max) return 0; #endif +#if defined(NOLIBC_STACKPROTECTOR) + if (!__stack_chk_guard) { + llen += printf("__stack_chk_guard not initialized"); + pad_spc(llen, 64, "[FAIL]\n"); + return 1; + } +#endif + pid = -1; pid = fork(); From patchwork Mon Jun 12 20:44:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp131355vqr; Mon, 12 Jun 2023 14:04:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7vUAikujfuYQ3qxccsxSv2F6tV0f03E4ionj6FLmmcd+v0B6Z1YiEcdrTWSVKSvl3EbArz X-Received: by 2002:aa7:88ce:0:b0:663:ba2c:2381 with SMTP id k14-20020aa788ce000000b00663ba2c2381mr9511954pff.12.1686603875034; Mon, 12 Jun 2023 14:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603875; cv=none; d=google.com; s=arc-20160816; b=sFUhWU4kGDwKuRHEODLng3w4WDKMIa3crYnp8Uppts/IhkmDQ9Zyj+eJdcxmdl2D6Z XpypqipP/RcscRhEU7gc6RvWHIp+CmMMzw7ZpTWIqEctLdfPRzxNFB4ep91aGVdnp8qe Bd7cOU1w0CYGIm5u8ET+NWdn0OMFEx4p16gG+ScJ2Hu5Vn21TKOFWJJ31pT/5qKv7je0 Hq91DX4jyNr9hMPNQQT7j7r8imkVW/L9zVAadKKs23kgtejItwxa/K9YnlCLhxjgPey3 C3G1F6uaaYiNUdN0Sh25H1AS6SITlw2i34jDLsNnIgIFN2dgL7peLo3kFBWTN3PKz/p3 qFfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hYKnSYcTusoqoV8CqknwseC6SKBvBYEzYivPmyMzVAI=; b=XZEISP1tCfEAWVYaVTuZHbLkdYswCh1hNo+z3nx3o9YgTFcKyMbVIsOhiPiEIOzeao 875fWxI1Jq3Q0JM/rB7znMT7eAT+H3odwwW9dypetxpE/S2th1ppdcEFpLY8oZlsxaee FNAB58VcVqgTZ8jDrqM+uIBiUmLrBRUDgVtd+xDGf/GrN3dqglOPKN+spEWaNpITXJh6 QTOJvGbpr5fQbnX/Uwpi3BYFGBBPsHGpig5M+1Bmw1F0MKrAQZ/WG03aphOzmpqCHFGZ 9EEoTib8cRfdSwT2v30/vyyvISsrne49ElJ6s6W3lVCuWmdW299FFSJXBzvvhoJ20ln/ 34mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H0l6AqtO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f64-20020a625143000000b0063b356e36fesi7361213pfb.372.2023.06.12.14.04.22; Mon, 12 Jun 2023 14:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H0l6AqtO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238124AbjFLUtK (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235028AbjFLUrf (ORCPT ); Mon, 12 Jun 2023 16:47:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1E9E1FE0 for ; Mon, 12 Jun 2023 13:46:42 -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 A5D2D62F0C for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 155F6C4331D; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=gUcb6xxKECKBFd/6RrJssqZdkk+hQheiI8GLvg8JYiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H0l6AqtOGHF0a1f6kc2WjhvUoZDmzs9x4t6FUnGRMy/hJj7F0i/T9ht6bsJzUByR2 3wHFaIry48mj1NL1QU0cQWu7t8j7fAA6EGG6XomAO1UgKCm7IkeUAzqIa1cdHlyhpT S+GQcQDCPZYyOkhNMmRPYTD3WC9Ndd5JhjoE7GYvzw5Y1TE4rhIW69H1QJ0RvuwSbw 1pjL1Hyxlvd0qSlO1KcN/6oE3H1yorCuipKjXlCdj3HRJbuZILl5h0JWgMg1YMkjfD juODaxffU2TKdSEdiiV5mCbrw6R1Kv6AtMDr63Gged8vbzcw9PSsRUa5q/D+3CmB/x PdFlxh+d+JF5w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id EAD18CE3A78; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 29/53] tools/nolibc: reformat list of headers to be installed Date: Mon, 12 Jun 2023 13:44:50 -0700 Message-Id: <20230612204514.292087-29-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532344835823719?= X-GMAIL-MSGID: =?utf-8?q?1768532344835823719?= From: Thomas Weißschuh This makes it easier to add and remove more entries in the future without creating spurious diff hunks. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/Makefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 9839feafd38a..e37c3ac86e23 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -25,8 +25,22 @@ endif nolibc_arch := $(patsubst arm64,aarch64,$(ARCH)) arch_file := arch-$(nolibc_arch).h -all_files := ctype.h errno.h nolibc.h signal.h stackprotector.h std.h stdint.h \ - stdio.h stdlib.h string.h sys.h time.h types.h unistd.h +all_files := \ + ctype.h \ + errno.h \ + nolibc.h \ + signal.h \ + stackprotector.h \ + std.h \ + stdint.h \ + stdlib.h \ + string.h \ + sys.h \ + time.h \ + types.h \ + unistd.h \ + stdio.h \ + # install all headers needed to support a bare-metal compiler all: headers From patchwork Mon Jun 12 20:44:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133832vqr; Mon, 12 Jun 2023 14:08:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ltl97Ai1MVLYHoVewQqPhSPvQtipnv4rMkCupk54yrn+1rvVUHTQy2WS/1w81n9o5iRrH X-Received: by 2002:a17:907:2d91:b0:97d:cc56:d9bc with SMTP id gt17-20020a1709072d9100b0097dcc56d9bcmr8548998ejc.51.1686604137961; Mon, 12 Jun 2023 14:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604137; cv=none; d=google.com; s=arc-20160816; b=Gi3zFAKMoxAXbIAE3LivvzN2Vz7a/L2I30sUUVjet+YKYf3kJJZD0nsvrB/cUSuCLS ffTZS4AVxpfS1OXqXmdZRNQtBc5XUIiehnn4YAr7gxkFLCVgmiJ/4uQIhmqJWHSVmQ1J LUv83Rj/MwFz2KyKowbfelq3Cp+oQEINAyQFL+nkl0lrzpwV2buAKbTTcQPbMdKoamaC vN63exbkKfZqHAN15E/2KDHpy6PyFe6QTFOv6AYMtyAAm/sq5UgSs2gHDxO+hwSsDoG+ 2rOfcXSHCTPACn9Ma/++QpL5A09lBh8JTvcEqxWvLLe+f7FTHJYFBr0tvzMhpjNQK8fg NqXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tENiERPbXGCJM4u1ZToW89CaKRziA7wQJmBN/Tob8RU=; b=WypdW9Dc45nPN3QMPlZv/Md7V+a1dY47OTjdnLI86OxeNp/vruIO6fNmXHLS91gWXI uK9y9Sonzm2q4gvcOuvawPysDshYH/UDS8dOXipgyr1ux0tLHRWdB3mi8EtCzCFfd50b jJEOTC2F+QAsF0dZ5q4uTdZrkdZuIGtk8D2OzoWMgHM+e+rzAoPEvsRuiWDcKTNRGbza m7/vBKUHD3uIoRr6OnRigqfXlGag2A4ImkdCuSncycVTMg+TQzZZ33vYBpGT/szMmNGh GlDMXJcI61mEGBskpUTcnIRDYpqZziiX4fLRng0++RqhL3SH70F5qiOsGBH0SURFRR5W jZog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gocSLvBA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a1709063b8300b0096b5c43d44csi4688167ejf.833.2023.06.12.14.08.33; Mon, 12 Jun 2023 14:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gocSLvBA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238257AbjFLUtj (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236417AbjFLUrs (ORCPT ); Mon, 12 Jun 2023 16:47:48 -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 5C3D72962 for ; Mon, 12 Jun 2023 13:46: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 A5F2862F13 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1806DC43321; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=Mw35BFUR7+ZznSmU98NqwI0YjsJ69pjYjKZIJHsUNFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gocSLvBAODbkBcNotQbuYpw/q2jI3zbOB3NP3dScshtfaldm2FnQ0oOtHZUWOEQHn fsoPqwLPOQVmE1R6sdPkY653AuD6K6faZ4Dx9zDky63p98U6AkM+TWdQqnKsUipVtu 9zo41kijZOQFC6Hvg5AwM3PbBIfaM+BSv+vjv/eT9/LKe3vQLfWb9C5PU5WaCGHRV2 0YFZ+FJymFxZITVYkvE4hw/BWHqmgWaq752rDEggTXsiLJRtF7LBNugAgABUTbK21d QxtnTcM8wfu43iCMrw3N9yfV1TExIwqbMqNEbi57KXTxWwSBtcma87oOMBbptDgx83 kjiP37OUltaRQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id ED2B9CE3A79; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 30/53] tools/nolibc: add autodetection for stackprotector support Date: Mon, 12 Jun 2023 13:44:51 -0700 Message-Id: <20230612204514.292087-30-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532620397385460?= X-GMAIL-MSGID: =?utf-8?q?1768532620397385460?= From: Thomas Weißschuh The stackprotector support in nolibc should be enabled iff it is also enabled in the compiler. Use the preprocessor defines added by gcc and clang if stackprotector support is enable to automatically do so in nolibc. This completely removes the need for any user-visible API. To avoid inlining the lengthy preprocessor check into every user introduce a new header compiler.h that abstracts the logic away. As the define NOLIBC_STACKPROTECTOR is now not user-relevant anymore prefix it with an underscore. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/20230520133237.GA27501@1wt.eu/ Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/arch-aarch64.h | 6 +++--- tools/include/nolibc/arch-arm.h | 6 +++--- tools/include/nolibc/arch-i386.h | 6 +++--- tools/include/nolibc/arch-loongarch.h | 6 +++--- tools/include/nolibc/arch-mips.h | 6 +++--- tools/include/nolibc/arch-riscv.h | 6 +++--- tools/include/nolibc/arch-x86_64.h | 6 +++--- tools/include/nolibc/compiler.h | 15 +++++++++++++++ tools/include/nolibc/stackprotector.h | 10 +++------- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- 11 files changed, 42 insertions(+), 30 deletions(-) create mode 100644 tools/include/nolibc/compiler.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index e37c3ac86e23..64d67b080744 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -26,6 +26,7 @@ endif nolibc_arch := $(patsubst arm64,aarch64,$(ARCH)) arch_file := arch-$(nolibc_arch).h all_files := \ + compiler.h \ ctype.h \ errno.h \ nolibc.h \ diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 6a859131c530..64ec65b4ee38 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_AARCH64_H #define _NOLIBC_ARCH_AARCH64_H +#include "compiler.h" + /* The struct returned by the newfstatat() syscall. Differs slightly from the * x86_64's stat one by field ordering, so be careful. */ @@ -172,13 +174,11 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - /* startup code */ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "bl __stack_chk_init\n" /* initialize stack protector */ #endif "ldr x0, [sp]\n" /* argc (x0) was in the stack */ diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 202e64f537dc..924169522cf7 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_ARM_H #define _NOLIBC_ARCH_ARM_H +#include "compiler.h" + /* The struct returned by the stat() syscall, 32-bit only, the syscall returns * exactly 56 bytes (stops before the unused array). In big endian, the format * differs as devices are returned as short only. @@ -199,13 +201,11 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - /* startup code */ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "bl __stack_chk_init\n" /* initialize stack protector */ #endif "pop {%r0}\n" /* argc was in the stack */ diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index 7c41897a08ce..37f813912957 100644 --- a/tools/include/nolibc/arch-i386.h +++ b/tools/include/nolibc/arch-i386.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_I386_H #define _NOLIBC_ARCH_I386_H +#include "compiler.h" + /* The struct returned by the stat() syscall, 32-bit only, the syscall returns * exactly 56 bytes (stops before the unused array). */ @@ -181,8 +183,6 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - /* startup code */ /* * i386 System V ABI mandates: @@ -193,7 +193,7 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "call __stack_chk_init\n" /* initialize stack protector */ #endif "pop %eax\n" /* argc (first arg, %eax) */ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index 07e3b1fd7262..d8ea7e787df4 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_LOONGARCH_H #define _NOLIBC_ARCH_LOONGARCH_H +#include "compiler.h" + /* Syscalls for LoongArch : * - stack is 16-byte aligned * - syscall number is passed in a7 @@ -149,8 +151,6 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - #if __loongarch_grlen == 32 #define LONGLOG "2" #define SZREG "4" @@ -175,7 +175,7 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "bl __stack_chk_init\n" /* initialize stack protector */ #endif REG_L " $a0, $sp, 0\n" /* argc (a0) was in the stack */ diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 65c19ccc7f9d..9860236e5340 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_MIPS_H #define _NOLIBC_ARCH_MIPS_H +#include "compiler.h" + /* The struct returned by the stat() syscall. 88 bytes are returned by the * syscall. */ @@ -179,8 +181,6 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - /* startup code, note that it's called __start on MIPS */ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) __start(void) { @@ -189,7 +189,7 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protec ".set push\n" ".set noreorder\n" ".option pic0\n" -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "jal __stack_chk_init\n" /* initialize stack protector */ "nop\n" /* delayed slot */ #endif diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index d0439249c9c9..86616aeb77a0 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_RISCV_H #define _NOLIBC_ARCH_RISCV_H +#include "compiler.h" + struct sys_stat_struct { unsigned long st_dev; /* Device. */ unsigned long st_ino; /* File serial number. */ @@ -177,8 +179,6 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - /* startup code */ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { @@ -187,7 +187,7 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protec ".option norelax\n" "lla gp, __global_pointer$\n" ".option pop\n" -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "call __stack_chk_init\n" /* initialize stack protector */ #endif REG_L" a0, 0(sp)\n" /* argc (a0) was in the stack */ diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index e201af15e142..485a7ff72a87 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_ARCH_X86_64_H #define _NOLIBC_ARCH_X86_64_H +#include "compiler.h" + /* The struct returned by the stat() syscall, equivalent to stat64(). The * syscall returns 116 bytes and stops in the middle of __unused. */ @@ -181,8 +183,6 @@ struct sys_stat_struct { char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); -#define __ARCH_SUPPORTS_STACK_PROTECTOR - /* startup code */ /* * x86-64 System V ABI mandates: @@ -193,7 +193,7 @@ const unsigned long *_auxv __attribute__((weak)); void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) { __asm__ volatile ( -#ifdef NOLIBC_STACKPROTECTOR +#ifdef _NOLIBC_STACKPROTECTOR "call __stack_chk_init\n" /* initialize stack protector */ #endif "pop %rdi\n" /* argc (first arg, %rdi) */ diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h new file mode 100644 index 000000000000..57da75cea799 --- /dev/null +++ b/tools/include/nolibc/compiler.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * NOLIBC compiler support header + * Copyright (C) 2023 Thomas Weißschuh + */ +#ifndef _NOLIBC_COMPILER_H +#define _NOLIBC_COMPILER_H + +#if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__) + +#define _NOLIBC_STACKPROTECTOR + +#endif /* defined(__SSP__) ... */ + +#endif /* _NOLIBC_COMPILER_H */ diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index b0156fc077a0..0a89e2b89ca6 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -7,13 +7,9 @@ #ifndef _NOLIBC_STACKPROTECTOR_H #define _NOLIBC_STACKPROTECTOR_H -#include "arch.h" +#include "compiler.h" -#if defined(NOLIBC_STACKPROTECTOR) - -#if !defined(__ARCH_SUPPORTS_STACK_PROTECTOR) -#error "nolibc does not support stack protectors on this arch" -#endif +#if defined(_NOLIBC_STACKPROTECTOR) #include "sys.h" #include "stdlib.h" @@ -49,6 +45,6 @@ void __stack_chk_init(void) if (__stack_chk_guard != (uintptr_t) &__stack_chk_guard) __stack_chk_guard ^= (uintptr_t) &__stack_chk_guard; } -#endif /* defined(NOLIBC_STACKPROTECTOR) */ +#endif /* defined(_NOLIBC_STACKPROTECTOR) */ #endif /* _NOLIBC_STACKPROTECTOR_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 861b9a74b71f..b50b5a8bcc90 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -802,13 +802,13 @@ static int run_protection(int min, int max) llen += printf("0 -fstackprotector "); -#if !defined(NOLIBC_STACKPROTECTOR) +#if !defined(_NOLIBC_STACKPROTECTOR) llen += printf("not supported"); pad_spc(llen, 64, "[SKIPPED]\n"); return 0; #endif -#if defined(NOLIBC_STACKPROTECTOR) +#if defined(_NOLIBC_STACKPROTECTOR) if (!__stack_chk_guard) { llen += printf("__stack_chk_guard not initialized"); pad_spc(llen, 64, "[FAIL]\n"); From patchwork Mon Jun 12 20:44:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133620vqr; Mon, 12 Jun 2023 14:08:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75tggDfQM6cEiW0hE11tl5OsBYWf/xTVvbCWj/mdsfe9SpEOC+VBqKHDtP6mIgGTOrYD/t X-Received: by 2002:a17:907:6e15:b0:96a:649b:3972 with SMTP id sd21-20020a1709076e1500b0096a649b3972mr10119596ejc.0.1686604115002; Mon, 12 Jun 2023 14:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604114; cv=none; d=google.com; s=arc-20160816; b=IsQfY2k+qGpeHHTE83JqxBwMkdsZmkfkF3b85AzYg/1Yf73RwgPxVtkHDkFwasZgeU NuVw0ka01aUYpnkH0W2nMnJMbtHJxWBbz5GgQM0YbI3dM6hc4VaQIegNNpB1oTKmfA2a G4lYtJMlrZEFE4tIGBYlIt8016fSryf5+Ioyny5f4p038lnB60NFqZpiuMNQCaepGqnB DtYDj/gb4yW5NudoX7a/qmTAwstNpIp7IzWY/oNzBQgEar/D586GaQL3LvVJyPyA4OE2 vO5z4BJrDP6GK3VfMdOQ9DzyVBhktOuKmTaelrCe5T8suUGZJZvbYbFpHccrkLj/2Cq5 IbQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GdP0HnIPHyDPRfEeSoWBU/Y8RTmAqqKrjm/oTTVOpqU=; b=0rV1+Kf+YDEHB5ZZ+72zsvBJ4XLFNtebP1Bkb8BsU1NAWLnPKELRM2JZ6LVioZuHBB x9qLmXf05xQ2V6jofTgbY4QR2XRl3bylGekY+6roNhZp81ra6thsrXQEv83XIZjiazd0 2dk+71wEjJJc/1oRwTSRidU3V1GxWAfgBiTmfyg6O9m5waYynmkGzbKA5zKHAjFhdZ19 SnaAT+UbZTJNlUyoSy2SwhoBr1lGg1hJcTYuoCXIyCcTckXJM5gy3gjf0mgAiKyYfDF+ DZAEm4pmQTkUnj9ss8wdoyLIqr7+0Ecjf6MCeKeB+AP94P/Bvat8VkoaJ0a6QGc6WTg1 LAIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gdmqTYvS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a170906345500b0097886880ff2si5509572ejb.959.2023.06.12.14.08.10; Mon, 12 Jun 2023 14:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gdmqTYvS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238138AbjFLUtO (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjFLUrf (ORCPT ); Mon, 12 Jun 2023 16:47:35 -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 5783B1FDD for ; Mon, 12 Jun 2023 13:46:42 -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 A4FB662F10 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F55AC4331F; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=RJIxQIPv98cFdGnQ5M/j79pA+ccw3K7v8tVhytUfcWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdmqTYvSUtUw3pB9G4iaZtzICMezEbOlxH6Bnzksv0VfFchRRj6VfiF/CoPMuMR98 lhrv+xcBc/gDnBOkPiJiO1fs1PAaxSWIt+/VmMeW9EgqxRCX6868XqlxwjdwXRnZ4k AnLMDQkh/kdSjsYmlXySZJNsLPlTT15DdZo57zw7smoZLkSH5yM14WUdDGYxHrm4rD wxmmJ/dUSVvPQBM7afo4CT4t1MAdIpLs9GSR7qg6xXabsiVmazTOVKNHsJv1UbqJMB 9DFApRo9x5zixvARzzF6lK9ukRWqzWHbl8kpPKwJ1GR956dOSuRHUtwmkoIxvDEahT x+LP+fsFUurhA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id EF55FCE3A7A; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 31/53] tools/nolibc: simplify stackprotector compiler flags Date: Mon, 12 Jun 2023 13:44:52 -0700 Message-Id: <20230612204514.292087-31-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532596626540040?= X-GMAIL-MSGID: =?utf-8?q?1768532596626540040?= From: Thomas Weißschuh Now that nolibc enable stackprotector support automatically when the compiler enables it we only have to get the -fstack-protector flags correct. The cc-options are structured so that -fstack-protector-all is only enabled if -mstack-protector=guard works, as that is the only mode supported by nolibc. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index bd41102ea299..47c3c89092e4 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -76,21 +76,11 @@ else Q=@ endif -CFLAGS_STACKPROTECTOR = -DNOLIBC_STACKPROTECTOR \ - $(call cc-option,-mstack-protector-guard=global) \ - $(call cc-option,-fstack-protector-all) -CFLAGS_STKP_i386 = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_mips = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_riscv = $(CFLAGS_STACKPROTECTOR) -CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR) CFLAGS_s390 = -m64 +CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ - $(CFLAGS_STKP_$(ARCH)) $(CFLAGS_$(ARCH)) + $(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR) LDFLAGS := -s help: From patchwork Mon Jun 12 20:44:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133996vqr; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7y2517Qo1WueNcTy+KuQR1T4hIoCIV6hNJszifhwmaim2vB4TUz6wMgbrQyybv3gsjDv1r X-Received: by 2002:a05:6402:5155:b0:514:7a67:44dc with SMTP id n21-20020a056402515500b005147a6744dcmr5425330edd.19.1686604153597; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604153; cv=none; d=google.com; s=arc-20160816; b=bHvenkZds7z6hK/IG935neU4n1l08lnOOUUWUbr5Dpuh3kKRjWpHHmCzbGK5OMGGHV 83KoP4QYr0zHT12keDSnHR92VSfILnSyE0Tf9snlG3cAua5f0oChrEVWn3toY5Js8NPU zb683RlLEnPDL5YJYtQWFDsgaKc9rXQezu3fU80e2lUgX5fQlV+dQZRK2r8CH+ISGtl5 tSyVhrLlQKQgYLZUuikgJYFl9x1qdKpzDc7sE2gMKmsP0C3kT7A0f6i6ZS3pXOP/vR2I TEpmPHAAgh8FjYuKd4cYU6OMDwiw4O1mmfXKzlMlZPJuSDOKtABDttSdyuKqLKW/deQn scqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AR4PJ2Fdx+izDcFv5V7vXTnTu3QdL4KxB4LxaU3x/kk=; b=g4yu9wHQyGgjKf6Oe6Oo7Vuvz353Uh54EtaBCUTMDTrDtHysCB7oTcAei954waYyQy skLGxGE4HeUWNrp/2Tn1fUeqUFb7x0zdjt0jWT51eFa5WvlBrs9PNYKcq5MWPvuGW6bY S0pgv7hgLMx4/ZWOYSi/HAxvESobfq1/KMBypRpE7CX3f6bvMo6XAL6bwaOVvCAYLcxF raA3JpFmLupgfEFpHCAxs2OYn1Y1RfUxhhXTwK4dqZCOPXClrBX725MqKz0Jx6H7oAdV TVwpXwtz7jqhxbQzxZr1TxilcjkJN4fz0NAefxuBQBHZkfxIG4x9dQDO+QrqIlZWDpz5 +WvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gvuc8+uY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020aa7df86000000b00514924b0f6asi6076934edy.268.2023.06.12.14.08.48; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gvuc8+uY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238647AbjFLUvz (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238348AbjFLUtt (ORCPT ); Mon, 12 Jun 2023 16:49:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270461FF9 for ; Mon, 12 Jun 2023 13:47:04 -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 17C8362F2F for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 222A1C43322; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=bQS8cm6R4ZJj57jb4seR4/kdTmFK/qogLto2vrQ2RK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gvuc8+uYT+WCMgiB9xsi9XD7tpYo8Zq6fFhBt/EZw2SAoh8Ol5VXxiF1htD3HsNAh eJezIx3fKjwXlVsowJhWJPGhFua79KnPlRTK6pb+8lBPZ3+OMobgL2NUWJpLVzU5cv hcIYxaB4njxK6k8SX6RM9f/flHgseejA/rqyMZxcY/dKbdHl90+o46a5SX8irQj98Z oP0wRyHKAXnxkCw69P72lqI2eGtZ7aT71nA+3HQPHZUK9x0y+q/tzsXj/1Uy135SFj jFz58wjWAMBWP8dfU9Xe4jf44GbonmDGIU+VrEfJSQ5BqU7gmZYm+q7FBIuijy8oX7 6RvLz+1g7HxMA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F1AD2CE3A7B; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 32/53] tools/nolibc: fix segfaults on compilers without attribute no_stack_protector Date: Mon, 12 Jun 2023 13:44:53 -0700 Message-Id: <20230612204514.292087-32-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532636896529803?= X-GMAIL-MSGID: =?utf-8?q?1768532636896529803?= From: Thomas Weißschuh Not all compilers, notably GCC < 10, have support for __attribute__((no_stack_protector)). Fall back to a mechanism that also works there. Tested with GCC 9.5.0 from kernel.org crosstools. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-aarch64.h | 2 +- tools/include/nolibc/arch-arm.h | 2 +- tools/include/nolibc/arch-i386.h | 2 +- tools/include/nolibc/arch-loongarch.h | 2 +- tools/include/nolibc/arch-mips.h | 2 +- tools/include/nolibc/arch-riscv.h | 2 +- tools/include/nolibc/arch-x86_64.h | 2 +- tools/include/nolibc/compiler.h | 10 ++++++++++ tools/include/nolibc/stackprotector.h | 2 +- 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 64ec65b4ee38..11f294a406b7 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -175,7 +175,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( #ifdef _NOLIBC_STACKPROTECTOR diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 924169522cf7..45b89ffe8247 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -202,7 +202,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( #ifdef _NOLIBC_STACKPROTECTOR diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h index 37f813912957..3d672d925e9e 100644 --- a/tools/include/nolibc/arch-i386.h +++ b/tools/include/nolibc/arch-i386.h @@ -190,7 +190,7 @@ const unsigned long *_auxv __attribute__((weak)); * 2) The deepest stack frame should be set to zero * */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( #ifdef _NOLIBC_STACKPROTECTOR diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index d8ea7e787df4..ad3f266e7093 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -172,7 +172,7 @@ const unsigned long *_auxv __attribute__((weak)); #endif /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( #ifdef _NOLIBC_STACKPROTECTOR diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 9860236e5340..db24e0837a39 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -182,7 +182,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); /* startup code, note that it's called __start on MIPS */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) __start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector __start(void) { __asm__ volatile ( /*".set nomips16\n"*/ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 86616aeb77a0..a2e8564e66d6 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -180,7 +180,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( ".option push\n" diff --git a/tools/include/nolibc/arch-x86_64.h b/tools/include/nolibc/arch-x86_64.h index 485a7ff72a87..6fc4d8392742 100644 --- a/tools/include/nolibc/arch-x86_64.h +++ b/tools/include/nolibc/arch-x86_64.h @@ -190,7 +190,7 @@ const unsigned long *_auxv __attribute__((weak)); * 2) The deepest stack frame should be zero (the %rbp). * */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( #ifdef _NOLIBC_STACKPROTECTOR diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h index 57da75cea799..beddc3665d69 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -12,4 +12,14 @@ #endif /* defined(__SSP__) ... */ +#if defined(__has_attribute) +# if __has_attribute(no_stack_protector) +# define __no_stack_protector __attribute__((no_stack_protector)) +# else +# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector"))) +# endif +#else +# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector"))) +#endif /* defined(__has_attribute) */ + #endif /* _NOLIBC_COMPILER_H */ diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/stackprotector.h index 0a89e2b89ca6..88f7b2d098ff 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -37,7 +37,7 @@ void __stack_chk_fail_local(void) __attribute__((weak,section(".data.nolibc_stack_chk"))) uintptr_t __stack_chk_guard; -__attribute__((weak,no_stack_protector,section(".text.nolibc_stack_chk"))) +__attribute__((weak,section(".text.nolibc_stack_chk"))) __no_stack_protector void __stack_chk_init(void) { my_syscall3(__NR_getrandom, &__stack_chk_guard, sizeof(__stack_chk_guard), 0); From patchwork Mon Jun 12 20:44:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp132653vqr; Mon, 12 Jun 2023 14:06:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ObIlyLRdI2+O0ZB6aJICuy3n8dMSBU5cITM7qPP7e0tNwOc1b1zTKWiZ4Gm16wfSeHlcn X-Received: by 2002:a05:6808:1411:b0:39a:7830:f252 with SMTP id w17-20020a056808141100b0039a7830f252mr6518081oiv.1.1686604005243; Mon, 12 Jun 2023 14:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604005; cv=none; d=google.com; s=arc-20160816; b=fkrcV+IwtBooyrFyb3Sg8YS9XLJafwUh2VMHneOk8el2pyJa2PeUxz7aUBO2Qe2U2Y U+d9Aviewet83XDWyfql0JN6cgGuIO140IdOIy3bkjd+ZXBuArMpHoYMLiJ+FvZyBAY+ zvQ0ax28Av9AjszoHJRh/u6GKWlup2iPXZ9EVnnXuDKwfgoSU2IGgksvugpeJTi8U7AR cxtJHzcA7Dvnnzm4Jw3sd3YoT53K+UTCkozRPGEuYGo/7AwonT9AdRbZIdr9MI/c5amT 1z95Y0dPbkCRG+KiWmM+UKNoYQ8EY+hO91yCqaKkVwBnJBuvVU9B8Gz6kRPEKcEpZzXK amsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5BluykOX8hya/xEIJPI89ySw4O8mxJM4gQpVreiOq9o=; b=GjY96tV37dKHkP1uoy/QNgX1N2XbF2+mscTp9QW/DP/I1QqSKlJe7rUQFkl91cgcnD 919WHS/YNfrasoJXKr/pOqAoC97vfyuojcWyOiQBGkoWyTdQ9du6aJ3Ug8Y3MsGedyzr wkcV8bGdj3MYyAL0eIcf8F/WcXumjL+jQW5+itzULC0KPnsyp8+zt1vEjBsbxPgGw4oG cYcTjbDsqTX2lGwg2BfpCPsejDVYRcxut7E5NqZmgFHall+z/Nz/fjJDT9K7rAiSMuu0 5g8O6TmnLo2ykl2zE+Js8OX4O1w73FUrqhlHCUduzihbrcRtBCDeWfKGCTD1p68yjNJN ulVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a82OsQVl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a637552000000b0053fb3bdd2fesi7333506pgn.506.2023.06.12.14.06.31; Mon, 12 Jun 2023 14:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a82OsQVl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238146AbjFLUtQ (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235962AbjFLUrh (ORCPT ); Mon, 12 Jun 2023 16:47:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83A201981 for ; Mon, 12 Jun 2023 13:46:43 -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 A91AD62F14 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2284FC43324; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=651zibUdG42x8RfDbrif5fkpzpSwW8yz5Rd3sGWo/wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a82OsQVlu7us9TzK3FQuGOYW/U69y0waSi8CHJl+1cQ/k8Zrh2qSO6nyHbJbtGOo/ U738RkKgw7v9ZZlrNS+SDLTXUZ0TB8/KqSDtfoQxK0hPrtyyFDULmNCtmKD4WtqAQL Akg0Sg4YXl6jaMbbLkFs9iLuw+vo+VkCnknM+Z6KagWZpn+bfkjnRd+vB7jEyB0Yks xc1l1aB3YpbB1pjK6UVysvg4CautgASiGi5Ym7FByQf/X+Ttb9EordiGoJz8hLiE40 CIn0GU7VNKfudSq4tbFS7ujQokszZK+F2zYTSiq/VZR5ER//IVK+Q6OVIJVtA+tWq7 sBo+bB2MYKaFw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id F3E23CE3A7C; Mon, 12 Jun 2023 13:45:15 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 33/53] tools/nolibc: s390: disable stackprotector in _start Date: Mon, 12 Jun 2023 13:44:54 -0700 Message-Id: <20230612204514.292087-33-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532481460368088?= X-GMAIL-MSGID: =?utf-8?q?1768532481460368088?= From: Thomas Weißschuh s390 does not support the "global" stack protector mode that is implemented in nolibc. Now that nolibc detects if stack protectors are enabled at runtime it could happen that a future compiler does indeed use global mode on and nolibc would compile but segfault at runtime. To avoid this hypothetic case and to align s390 with the other architectures disable stack protectors when compiling _start(). Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-s390.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index a738e7f3f8e8..516dff5bff8b 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -8,6 +8,8 @@ #include #include +#include "compiler.h" + /* The struct returned by the stat() syscall, equivalent to stat64(). The * syscall returns 116 bytes and stops in the middle of __unused. */ @@ -164,7 +166,7 @@ char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); /* startup code */ -void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void) +void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void) { __asm__ volatile ( "lg %r2,0(%r15)\n" /* argument count */ From patchwork Mon Jun 12 20:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp127494vqr; Mon, 12 Jun 2023 13:56:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6V2nK70+jB2DROtiC6QXzOUkb4eBbzY6yxVbl+zpkVZhhP7XX/qQxT2JJEpqethdOL/ECx X-Received: by 2002:a05:6402:550:b0:514:8d90:5eae with SMTP id i16-20020a056402055000b005148d905eaemr6205180edx.10.1686603402282; Mon, 12 Jun 2023 13:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603402; cv=none; d=google.com; s=arc-20160816; b=zs6iaP7/1TZrL2NHkGIN4KP1tydlnV/IHFnrskXybwt8BcO1vPU8sr3S5sybkibR6G LNkOgI7Uz4kP7qdCShkqmqc6h3L9Pc1Zu87GhP8A0gKZGiT0G4naRJgzx19az24/RTeC sua8PgmHMPDvTFNzGl+XBQG90/DOt0M4af753NfFk/vkHJpounP7o4WQO1b5kxqYbFqG SVl7Lyx2RdGHjM2e5UDl2n+QtFu7cajLWQ3n6fQHXMQCE4xaRZ98/l7UlU6GH/7nrUx2 MzeNov/IqfyzXvkevHgWL5qhF8bMuG7pP76mwxqtIUKmg8xj9bEwbWGvsWEMegUGc2/f 4uHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CH/CNfh38h8US5uvxhMb2yCuhKNQAfxSrJD4k7JUA8o=; b=0vgOgrtU3baiFIzEDJyTmOCU8NQwDAxp0IGcEin8Nmm3wksTd3yU1SJDmu/G5GwGO1 8uncULQ0eoiaVYU7i8ArjOcHFr5qCUJBDxiyg3+Hn1L9LOzvJqfKelD5cKHZ3AdmlhC3 XfT+OQSNz++xJJ3cXtgxBxnWhYZhSOfcs2ZtxZNTOo4eX8rJtmzGHF0pGnW3Xo30+jNk dwr99FtLY+PvLkKQMJc/7qbztDs3Ybz7YTX45JHJ0OxfhPLWSq8QYYzbWfS5oNvYMsnb PkbrcoPLT2kOX1Czi3UJOkVjHvQY684q+pCfev6Uw2BxT/yek18NdepVcc3h1BbYYeht jr2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iBqkFKk3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c26-20020aa7d61a000000b0050bc397bba5si6496371edr.499.2023.06.12.13.56.18; Mon, 12 Jun 2023 13:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iBqkFKk3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238171AbjFLUtT (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237673AbjFLUrq (ORCPT ); Mon, 12 Jun 2023 16:47:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D52C1BE5 for ; Mon, 12 Jun 2023 13:46:44 -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 A99C062F16 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BDEBC43325; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=N9vHg92hQf/Gt8IdTsnnfWQj4zqBnDUs4128W6vih/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBqkFKk36EhtaWtPZU3rgUuxmTtfv97JaYZTgokAM7xcRt/22Jd6rGrNGFPWOBG63 xO4W8Cww3Yh5hfTupDtDNm0birqBzS4PNmnAtJpZnPST7SAICqEIZPgQO6HIoAp0qG H2F2Yt6Ef/HxDEyry02VutbT0YRSKV1RnwldHrd+caLpGfUxGTULdxUZUtbDHZF0WU +Z7ltdnbFdZvH7aPjVONZJQVNBWSg1QqWspwR+//JJQSslcD1lklBs/5DpQ0ZNQ4G7 TjlsYXhWa3n0PN1oLzbza6wdU3Z8zjZVYgai71XbHhyAiUQUfyhAHYpeilM1hrOhSj uNLF9+M2qEsCA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 01E0ACE3A7D; Mon, 12 Jun 2023 13:45:16 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 34/53] tools/nolibc: add support for prctl() Date: Mon, 12 Jun 2023 13:44:55 -0700 Message-Id: <20230612204514.292087-34-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531849499907114?= X-GMAIL-MSGID: =?utf-8?q?1768531849499907114?= From: Thomas Weißschuh It will be used to disable core dumps from the child spawned to validate the stack protector functionality. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 27 ++++++++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 2 ++ 2 files changed, 29 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index d5792a5de70b..c688b410f9e4 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -22,6 +22,7 @@ #include /* for O_* and AT_* */ #include /* for statx() */ #include /* for LINUX_REBOOT_* */ +#include #include "arch.h" #include "errno.h" @@ -875,6 +876,32 @@ int open(const char *path, int flags, ...) } +/* + * int prctl(int option, unsigned long arg2, unsigned long arg3, + * unsigned long arg4, unsigned long arg5); + */ + +static __attribute__((unused)) +int sys_prctl(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + return my_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5); +} + +static __attribute__((unused)) +int prctl(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + int ret = sys_prctl(option, arg2, arg3, arg4, arg5); + + if (ret < 0) { + SET_ERRNO(-ret); + ret = -1; + } + return ret; +} + + /* * int pivot_root(const char *new, const char *old); */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index b50b5a8bcc90..6db788603a34 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -580,6 +581,7 @@ int run_syscall(int min, int max) CASE_TEST(poll_null); EXPECT_SYSZR(1, poll(NULL, 0, 0)); break; CASE_TEST(poll_stdout); EXPECT_SYSNE(1, ({ struct pollfd fds = { 1, POLLOUT, 0}; poll(&fds, 1, 0); }), -1); break; CASE_TEST(poll_fault); EXPECT_SYSER(1, poll((void *)1, 1, 0), -1, EFAULT); break; + CASE_TEST(prctl); EXPECT_SYSER(1, prctl(PR_SET_NAME, (unsigned long)NULL, 0, 0, 0), -1, EFAULT); break; CASE_TEST(read_badf); EXPECT_SYSER(1, read(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(sched_yield); EXPECT_SYSZR(1, sched_yield()); break; CASE_TEST(select_null); EXPECT_SYSZR(1, ({ struct timeval tv = { 0 }; select(0, NULL, NULL, NULL, &tv); })); break; From patchwork Mon Jun 12 20:44:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133997vqr; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MKWPgw4BuIoZrZLEoh0u2vDIpzD9B60tt3ppjkcdKgxNTK/2lWfrxuhYl2vRKxjz0VV/e X-Received: by 2002:a17:907:a40d:b0:94f:1c90:cb71 with SMTP id sg13-20020a170907a40d00b0094f1c90cb71mr12553409ejc.65.1686604153663; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604153; cv=none; d=google.com; s=arc-20160816; b=h/buBv5qEbLTuuWfRLi1FVGWAmkFndriaOjzMPnCEnrvPj8eKXdYJel87FJtLUf5XB ZJc2piFFAFC8BcEQ19y91TZIMq34n/edu7dCrVyWZcEimD8MrPWYt8dxeVZGVotAT/Va ikrziEDhFKYtQQ2BXkwk1BOCS5kJOY0aZ0MABhRJPRF1Lh8fo4+3VmoZQqAltpL2BFc2 YlsJ90RPspWM9dJFveb93AjJ79vA2yMBiNqFmqBL8zgIn1jAWFFcB+5nQx05z//doxXH xu6G5KaqCGn5Llo4wyxRqs2Xt2wdM+7MRCn9iMdmZl+sdSHpNFJT9JYrGAKaJ8ln/Oe0 DFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m8jaKRUw7wPV0JcA1JrchxHPBPmx1j+oSv0/+XLxllI=; b=jQWga18RKZHSgIF0A7lDBVMssfTM954/ZB9RTR2iTsk/5pHGO9W2RuT+xA6GnWDeNM r+Yt8r4MzpqIuxK43oVYF5I4WwAD64nDzOFeQVGkYNTOdHrl/e4X2ZY7KNI7xRNgb5QB n31LGsqsoxf+VYNWuRX/23pt66XNgXCeL7wMbEUpv3tPTPgRRKrOtmOy0LR+UzgFlu8T /X/H3toMJEbU4fTQnqtNm/yn9096sWQgyaD+HOxmPmM/TC+aEH3RMkwVwM5lr83LoLM1 3G7tKRFnIp9dIM4CUvf3kAVVTe8z1dTZdMsv1wZ59mak1ckWVjucp1IwCV/zxOgjc9og 9W3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqPbOGEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x9-20020a170906296900b00977ebc42984si5723244ejd.575.2023.06.12.14.08.48; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jqPbOGEx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235903AbjFLUvv (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238368AbjFLUtu (ORCPT ); Mon, 12 Jun 2023 16:49:50 -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 500482106 for ; Mon, 12 Jun 2023 13:47:06 -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 1E5E262BED for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E690C43323; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=YSnDd8eIZWAVVkXrAR2iFLMVAjImLZBexFy3GV2smU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqPbOGExUPnvOck2RN1WO9wxecIiO7nVEipYAmWrLM6powvhfty5dd2arfDL8o8MK +rnU6nV/FKY19zKCzDsWkSXE6UYVNpsn6S7qpgOF8tmC2zYLG1iainbN3FyMQm2+GQ swvICHPmRQp/6/PWmXyRORqLAO/z97YwdosPE6+0ippOcXn3wfmL/2RniVpZurM0Yk GUzVjbI/A5s6waLiD7OXvNYdy8Fdh9dSRtJSyaqU5Q7pVkFfB03vmEETUyG8GzYxEK 3pC5b7u8lReTcOx2+b0rqrvkoFUDwip9ZwcxnDGnC9eWQYQq8O5dvmejxGTmVW5X6I meIOnIg89Zmrw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0423DCE3A7E; Mon, 12 Jun 2023 13:45:16 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 35/53] selftests/nolibc: prevent coredumps during test execution Date: Mon, 12 Jun 2023 13:44:56 -0700 Message-Id: <20230612204514.292087-35-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532636759889842?= X-GMAIL-MSGID: =?utf-8?q?1768532636759889842?= From: Thomas Weißschuh The child process forked during stackprotector tests intentionally gets killed with SIGABRT. By default this will trigger writing a coredump. The writing of the coredump can spam the systems coredump machinery and take some time. Timings for the full run of nolibc-test: Before: 200ms After: 20ms This is on a desktop x86 system with systemd-coredumpd enabled. Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 6db788603a34..84a1b02eb6f9 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -831,6 +831,7 @@ static int run_protection(int min, int max) close(STDOUT_FILENO); close(STDERR_FILENO); + prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); smash_stack(); return 1; From patchwork Mon Jun 12 20:44:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133698vqr; Mon, 12 Jun 2023 14:08:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xfRhgez/sTPsjyNnIkGTJX5+/M2dS8ZbF/LgewvD2OEGctaY2dEO0IUYw+oknIjj6vHID X-Received: by 2002:a17:907:8694:b0:977:d468:827 with SMTP id qa20-20020a170907869400b00977d4680827mr11293370ejc.17.1686604124460; Mon, 12 Jun 2023 14:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604124; cv=none; d=google.com; s=arc-20160816; b=V4iV+1R9p9oT1oXBQ+oDy50koxmWHWF33Vxg8hlrkQfOLhNK8u6NcB+G/gxfN/l85I AHpWB8VhUXQwGCF7+5kkMR/Z/ETxNXHpVregybSKdhCkuJvs7LVD4Sn4/e7rOtZL3bW5 gMupv1DpLXD9IeRIt3B/gSz/IWYblNxVLu9b+D040Mt3NlzbSRxljV1NH2SskGlUHGCo 1R0P5Ud5u3bDGOtUHFdc1QJ1ANaOwkE7mzGF37VlGmE6YZY/frg3P2x8rkOkQit0fJWM i9yLXz8d7+Ld789jSnbC1NSmOXiIgenMM+QleoSCbVkaci+oL94u+VOapAyPCRuY2W4G qFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QOzc9W495dpYZJVnoOA/zqPhtTPGpGNsJ0drG4GV2uo=; b=pfo6Nc+OIdeEkPJ7IteiX9tFZcfDmUa7Cy3Fe5USHZ5g0orb7HvKWZXsaIMVaXHIDd k7CNB1qPKr9gncZvWMXA6Lpt02v0COlK06ysziKs5DkqYh1XM0URo5Kd0txU9Y5JYzB0 1E84mr8vvg+QVvCr2T1gkielRK5zh6l1QDpjm5Vw679S8RCWpZ0bt3SxiBMMrGWDm//Z OTDwYIYlBoYVHNwp4fue58nPwRd2tZGyBSSs4ek4ZWIM3xOxxmHy1l2sgJYxz77M37rn BTI+RFY2DWMXYWeSJ2xsr378ihhz+7HG5R6QmWqofawMFnFth2giIiRW+12VyQI426PU dLzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ray7trlh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a1709065a8e00b0097462908aa7si2427172ejq.80.2023.06.12.14.08.19; Mon, 12 Jun 2023 14:08:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ray7trlh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238239AbjFLUtb (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237701AbjFLUrs (ORCPT ); Mon, 12 Jun 2023 16:47:48 -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 33E0E2960 for ; Mon, 12 Jun 2023 13:46: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 ACDD662F12 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30C26C43327; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=3kluAJ78NXxdpTo6ccwYTg3Vy1h0KV1jojs/dLdw/p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ray7trlhxNf6u6xWdY2QyahrNaycAxH2B3GGOIJ9T/7ng6GBQXBqg+XlfB6IubxPY zoFomVawpHhbXE0PbDJXzSdBX5ZGBq1WLAigivSc7ckUSr4f41omcDrX3uXiBB2GV6 S3cDwlALZ88dbGzeTstLX2KSetup29fS867VpfcD9pUhK5oXEfWikaCQ9fx2irB8sl Y3t703NcJ6Nz5X4Kda+lEmlDviz7VoPnhtjX02nXL47fU3nFa0Xj3jysXO1jy7fuTJ 18t3MBsb+lony/zEmPGBEwVp+UbcPalcc4CgLaZCQjfSSMtU+M7gH4ibCmtkNkuhI4 +05wDlBsYi/Xg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 06B33CE3A7F; Mon, 12 Jun 2023 13:45:16 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Zhangjin Wu , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 36/53] tools/nolibc: support nanoseconds in stat() Date: Mon, 12 Jun 2023 13:44:57 -0700 Message-Id: <20230612204514.292087-36-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532606552956500?= X-GMAIL-MSGID: =?utf-8?q?1768532606552956500?= From: Thomas Weißschuh Keep backwards compatibility through unions. The compatibility macros like #define st_atime st_atim.tv_sec as documented in stat(3type) don't work for nolibc because it would break with other stat-like structures that contain the field st_atime. The stx_atime, stx_mtime, stx_ctime are in type of 'struct statx_timestamp', which is incompatible with 'struct timespec', should be converted explicitly. /* include/uapi/linux/stat.h */ struct statx_timestamp { __s64 tv_sec; __u32 tv_nsec; __s32 __reserved; }; /* include/uapi/linux/time.h */ struct timespec { __kernel_old_time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; Signed-off-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/3a3edd48-1ace-4c89-89e8-9c594dd1b3c9@t-8ch.de/ Co-authored-by: Zhangjin Wu Signed-off-by: Zhangjin Wu [wt: squashed Zhangjin & Thomas' patches into one to preserve "bisectability"] Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 66 +++++++++++--------- tools/include/nolibc/types.h | 6 +- tools/testing/selftests/nolibc/nolibc-test.c | 23 +++++++ 3 files changed, 62 insertions(+), 33 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index c688b410f9e4..7836d7e7760d 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1161,23 +1161,26 @@ int sys_stat(const char *path, struct stat *buf) long ret; ret = sys_statx(AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &statx); - buf->st_dev = ((statx.stx_dev_minor & 0xff) - | (statx.stx_dev_major << 8) - | ((statx.stx_dev_minor & ~0xff) << 12)); - buf->st_ino = statx.stx_ino; - buf->st_mode = statx.stx_mode; - buf->st_nlink = statx.stx_nlink; - buf->st_uid = statx.stx_uid; - buf->st_gid = statx.stx_gid; - buf->st_rdev = ((statx.stx_rdev_minor & 0xff) - | (statx.stx_rdev_major << 8) - | ((statx.stx_rdev_minor & ~0xff) << 12)); - buf->st_size = statx.stx_size; - buf->st_blksize = statx.stx_blksize; - buf->st_blocks = statx.stx_blocks; - buf->st_atime = statx.stx_atime.tv_sec; - buf->st_mtime = statx.stx_mtime.tv_sec; - buf->st_ctime = statx.stx_ctime.tv_sec; + buf->st_dev = ((statx.stx_dev_minor & 0xff) + | (statx.stx_dev_major << 8) + | ((statx.stx_dev_minor & ~0xff) << 12)); + buf->st_ino = statx.stx_ino; + buf->st_mode = statx.stx_mode; + buf->st_nlink = statx.stx_nlink; + buf->st_uid = statx.stx_uid; + buf->st_gid = statx.stx_gid; + buf->st_rdev = ((statx.stx_rdev_minor & 0xff) + | (statx.stx_rdev_major << 8) + | ((statx.stx_rdev_minor & ~0xff) << 12)); + buf->st_size = statx.stx_size; + buf->st_blksize = statx.stx_blksize; + buf->st_blocks = statx.stx_blocks; + buf->st_atim.tv_sec = statx.stx_atime.tv_sec; + buf->st_atim.tv_nsec = statx.stx_atime.tv_nsec; + buf->st_mtim.tv_sec = statx.stx_mtime.tv_sec; + buf->st_mtim.tv_nsec = statx.stx_mtime.tv_nsec; + buf->st_ctim.tv_sec = statx.stx_ctime.tv_sec; + buf->st_ctim.tv_nsec = statx.stx_ctime.tv_nsec; return ret; } #else @@ -1195,19 +1198,22 @@ int sys_stat(const char *path, struct stat *buf) #else #error Neither __NR_newfstatat nor __NR_stat defined, cannot implement sys_stat() #endif - buf->st_dev = stat.st_dev; - buf->st_ino = stat.st_ino; - buf->st_mode = stat.st_mode; - buf->st_nlink = stat.st_nlink; - buf->st_uid = stat.st_uid; - buf->st_gid = stat.st_gid; - buf->st_rdev = stat.st_rdev; - buf->st_size = stat.st_size; - buf->st_blksize = stat.st_blksize; - buf->st_blocks = stat.st_blocks; - buf->st_atime = stat.st_atime; - buf->st_mtime = stat.st_mtime; - buf->st_ctime = stat.st_ctime; + buf->st_dev = stat.st_dev; + buf->st_ino = stat.st_ino; + buf->st_mode = stat.st_mode; + buf->st_nlink = stat.st_nlink; + buf->st_uid = stat.st_uid; + buf->st_gid = stat.st_gid; + buf->st_rdev = stat.st_rdev; + buf->st_size = stat.st_size; + buf->st_blksize = stat.st_blksize; + buf->st_blocks = stat.st_blocks; + buf->st_atim.tv_sec = stat.st_atime; + buf->st_atim.tv_nsec = stat.st_atime_nsec; + buf->st_mtim.tv_sec = stat.st_mtime; + buf->st_mtim.tv_nsec = stat.st_mtime_nsec; + buf->st_ctim.tv_sec = stat.st_ctime; + buf->st_ctim.tv_nsec = stat.st_ctime_nsec; return ret; } #endif diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 15b0baffd336..f96e28bff4ba 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -198,9 +198,9 @@ struct stat { off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t st_blocks; /* number of 512B blocks allocated */ - time_t st_atime; /* time of last access */ - time_t st_mtime; /* time of last modification */ - time_t st_ctime; /* time of last status change */ + union { time_t st_atime; struct timespec st_atim; }; /* time of last access */ + union { time_t st_mtime; struct timespec st_mtim; }; /* time of last modification */ + union { time_t st_ctime; struct timespec st_ctim; }; /* time of last status change */ }; /* WARNING, it only deals with the 4096 first majors and 256 first minors */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 84a1b02eb6f9..0d76790ffb0d 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -501,6 +501,28 @@ static int test_fork(void) } } +static int test_stat_timestamps(void) +{ + struct stat st; + + if (sizeof(st.st_atim.tv_sec) != sizeof(st.st_atime)) + return 1; + + if (stat("/proc/self/", &st)) + return 1; + + if (st.st_atim.tv_sec != st.st_atime || st.st_atim.tv_nsec > 1000000000) + return 1; + + if (st.st_mtim.tv_sec != st.st_mtime || st.st_mtim.tv_nsec > 1000000000) + return 1; + + if (st.st_ctim.tv_sec != st.st_ctime || st.st_ctim.tv_nsec > 1000000000) + return 1; + + return 0; +} + /* Run syscall tests between IDs and . * Return 0 on success, non-zero on failure. */ @@ -589,6 +611,7 @@ int run_syscall(int min, int max) CASE_TEST(select_fault); EXPECT_SYSER(1, select(1, (void *)1, NULL, NULL, 0), -1, EFAULT); break; CASE_TEST(stat_blah); EXPECT_SYSER(1, stat("/proc/self/blah", &stat_buf), -1, ENOENT); break; CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; + CASE_TEST(stat_timestamps); EXPECT_SYSZR(1, test_stat_timestamps()); break; CASE_TEST(symlink_root); EXPECT_SYSER(1, symlink("/", "/"), -1, EEXIST); break; CASE_TEST(unlink_root); EXPECT_SYSER(1, unlink("/"), -1, EISDIR); break; CASE_TEST(unlink_blah); EXPECT_SYSER(1, unlink("/proc/self/blah"), -1, ENOENT); break; From patchwork Mon Jun 12 20:44:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134699vqr; Mon, 12 Jun 2023 14:10:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5QBgc8xsT0qPX5RPpgcMpGmBwJq7+e7GXdFD7SUweGkxXT29qGDHdT3DjxYIEVYxAjCRUH X-Received: by 2002:a17:907:934a:b0:974:5399:c21 with SMTP id bv10-20020a170907934a00b0097453990c21mr10287095ejc.24.1686604235551; Mon, 12 Jun 2023 14:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604235; cv=none; d=google.com; s=arc-20160816; b=Ic9oqC7OZddjNCdkeDc68Llexma4GEfz8J7FbLMXnEhL1F9Ci0AUYRzCSusBaJNyek 6nz9frh3y89ZE5C6xXYeUG3+81d+xHIi2WK6PBPbHT6mKo3NuO5kS/ar4mdwAtrxgSV4 oLq7I/ngc46W/D48nv0suqLhlGBGqbvMj8Sw0TWKGgrSXNaS7k34Ihhal3Yh4D7dtADV s3QiA9Tarjy0M5UeafuMVxKO9dFQbhOa8fDiFRyXi2IIahS0DiOZlLP80rP6rPgGTQe/ 1CdjgbGlK3WRM+Yh3dST2wGWB2GTyYYvCRadrHdKi9MR6XuvRRPnEZUV26rxZWrsHcuM ajVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i+jcnYRMNS3OQ7MkSUbW14J+ZrZD0EN+ZDdFEEU2f6k=; b=CnNwyfVerKbPNVUgV+VZWmrneI84Kyj8ckeGKoBuaPBqx2glaxv0MCte6NC/5huQtY dUbrDG6Sif6QpblTk58RoShTpNGT7+/BCbXC45nJOTUv/NNFCXEQSWHI0P+eIJhFGCkq tO93G9LR2tZfMGsC3jXZ2llo+6ASHt6wgl1J7prQ1GyTbbkreBQI5+OgtQsO7WS+6fI5 i4/HBzZCep7YraOj+Oa9aLLcm8tzafKbIxC/obI9qTMLUneVylkWXH6ycNTCrhcwUhEC igMXa4QzDvswltobPcNmnJXmOuu7zVSfPYZ1PQe/cC/dfk+jyf9ZpsShF+wY7AqUILfb s9og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OrRYsNW5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e15-20020a170906504f00b009784f00c5besi5449263ejk.263.2023.06.12.14.10.09; Mon, 12 Jun 2023 14:10:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OrRYsNW5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238672AbjFLUwB (ORCPT + 99 others); Mon, 12 Jun 2023 16:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238401AbjFLUtw (ORCPT ); Mon, 12 Jun 2023 16:49:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10C92970 for ; Mon, 12 Jun 2023 13:47:08 -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 21C9E62F32 for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3604FC43326; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=9y+4Vs4tWIeKkTf1j6wqeFXVqgqDpdnK6mjpgkb8zFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OrRYsNW5i87RnzyJNUNbdbN80H+bXi6JFft5tA+X7QuwV7VwKSBcmV7H7S26d/pFU Vyx4wVzzcuWPaOvDQfAi5KXJeIWwTkoedCtRSt5SsKIAQ1+RN1dU/Se13wWW07y8hm 7q0ctKCyXYJrogFIQCt/EVmEOT9cCCKwM2REz9I8CkvR9z9WOUZcNfDQk3oCduv3xr jcSKGVgWrwdU5ZalP9I07PvQ1Qn4Q55Snzr9ckt0vQJdOyYJ92Ca9Lvwbkq2/o0Mng HVWb1Apw1iPs8AlaETBsEbdPduPGRcclmbdquSXJDi5lHHlwxM1zmHly1Cn3uZnskR XtDvwQ4S8YePQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 090E6CE3A80; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 37/53] selftests/nolibc: print name instead of number for EOVERFLOW Date: Mon, 12 Jun 2023 13:44:58 -0700 Message-Id: <20230612204514.292087-37-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532722800919579?= X-GMAIL-MSGID: =?utf-8?q?1768532722800919579?= From: Zhangjin Wu EOVERFLOW will be used in the coming time64 syscalls support. Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 0d76790ffb0d..ffdf1e8c305c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -107,6 +107,7 @@ const char *errorname(int err) CASE_ERR(EDOM); CASE_ERR(ERANGE); CASE_ERR(ENOSYS); + CASE_ERR(EOVERFLOW); default: return itoa(err); } From patchwork Mon Jun 12 20:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133998vqr; Mon, 12 Jun 2023 14:09:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7O8Q++wxJQ/o4ONP/GSYsfANihxxoga0VM9zXZM7H0ItvSgDwJwQQlEV3mvwfRLDgzXBO1 X-Received: by 2002:aa7:c643:0:b0:514:94ff:f67e with SMTP id z3-20020aa7c643000000b0051494fff67emr6753348edr.5.1686604153898; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604153; cv=none; d=google.com; s=arc-20160816; b=a3fen4LOEzHD3NAVMh+rO6zst9BSaApa+YoPbVRdelSwhzpogN6TaSZJeEU7xAqV5V 0/mM68PsBUJBBrwRYEQEwqXJns+VRGVRYxefMBhCtRTV2+HI6uBQxtHE4NN+Yuay+PRk Eej9VOIUBe+aZ1HSNYnujWctfvzEaVbAsDYfCvhheAGTnj/ySoFvGqqsNIlWqAv2P2pS 3rSnYicmuAECGzo2jdR1to6eqjmWkelQ9y5nBe12JkNQ2x71srdkAfvqkdfwBOt9SZxp 6zcGfXaenqGrVeWPDiPt1vwk/jBeSWqNNMy2iHC0BVt6o/SG6FFF3MWHnOmBxHOqiD2B Za9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bgFY5U69WpKhgOTH4I7qaMpQ0pFWPoqi8iCq5kMr9cA=; b=OHx1iHpXHtofTSsGAdCZUbdYKjBvgGtn/q71WE19JgkuTolxubu01S9h85nS6Hz2Tg ze4LSjUDr7WKJXw+iKsU4b/z7YJqK6H/tFVq29FkI/r1Hvjb1MVZk0r9beNducHdqA5N CaeM2B9qaYQN1rK5YaT+m9SqaNOcCH8W2L/+BMI0Obtqz0P4nsP0lbwxLWEy5fBL70XE EHLxo9nbjUjKcW1fQI9aIKw4LtcTtkz6GHdvtDfDxdRh93wW+Ea+ge0LF16VUkgLYz6a v1i34MqAWB2ZcEX5b+cvWSRRgE6mlpYcoMyaDlvaEM/f0fvbdh38qxikJlXm2EnmSDmO U2gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hcNK4cKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a056402180b00b005149573f64dsi4493856edy.49.2023.06.12.14.08.48; Mon, 12 Jun 2023 14:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hcNK4cKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237758AbjFLUt2 (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237693AbjFLUrs (ORCPT ); Mon, 12 Jun 2023 16:47:48 -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 4BEC02961 for ; Mon, 12 Jun 2023 13:46: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 B336362F17 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 390DEC43329; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=xokCziXLY0wg8Xt5fKYpSkuWrnPGYJ0bTQ1zvGDvk1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcNK4cKfVeMexgNye0UAvuYqAGadB2wQUEiBAVuVCQ2Ti00E1VtWUueWjjmZVJ32g Xc7gzAyo3SVELeUx5SZ+uQV5ljrYTdAq6f+IcKYkOFOTGdAxE9+AGxwb7nBVGRlq75 x/AFXKv9vN/UWtNWjzAvNJHkUzzK7MEqNnkpa6rCLZ9o8ccU6Jsjz8aZI7rkvtQM2D W12VSeTG4MyLYXQ9OnDpCTeqe3OyjJ+ifQHDZVkWOpXKqrB8zEv5EB6RvQAdpUQ2sD p4pXcRBbmxGnGGsyrGxGIy+BIt06VEarzV8jHL4uZbqtWb/h7gMl6MBofLjedLBLeR CErAd6NPDo/PQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0BAD4CE3A81; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 38/53] selftests/nolibc: remove the duplicated gettimeofday_bad2 Date: Mon, 12 Jun 2023 13:44:59 -0700 Message-Id: <20230612204514.292087-38-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532637252899384?= X-GMAIL-MSGID: =?utf-8?q?1768532637252899384?= From: Zhangjin Wu There were two exactly similar occurrences of this test. Signed-off-by: Zhangjin Wu Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index ffdf1e8c305c..d417ca5d976f 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -587,7 +587,6 @@ int run_syscall(int min, int max) #ifdef NOLIBC CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break; CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; - CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; #endif CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; From patchwork Mon Jun 12 20:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp138341vqr; Mon, 12 Jun 2023 14:18:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6InDqF3erGBUBqjy5gNLOnepqw7Bb5C++gxsWZ9GQxuw4H2jkbgejCX3ZUA1T39U2FdJZ/ X-Received: by 2002:a17:907:6e26:b0:96f:912d:7922 with SMTP id sd38-20020a1709076e2600b0096f912d7922mr12311959ejc.53.1686604681431; Mon, 12 Jun 2023 14:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604681; cv=none; d=google.com; s=arc-20160816; b=wJiQyUYUMySVZKXX5WpG2orAcmgRQJjwKA0m0DSAwnj6H19jZIPp9/xhWuDyur8eTr i/7yToRzD8G3kXkogW4WEq9SfEtDRrQz5aYZuZwe8GEwXjMZE5sjK1MNbEJ09dB1MgMN y9I+9gERjA22lc6Ov8MTZAptR5iwRMUeUTd0h5AoJuZ5CxtPPwUKFvla+Mgg8apw4AHP HRMMp4DvF6clpm0T3qvmafXIsNBQsHHpBGlLz7dqw6pqSsz59W1/NlAdGXz7CvWGEnbO mTY4UQ3rilhyEjSoXm96j/Sv0mGW1wKuJiH/9c0kKUxt6xQ+PXVMhUpjXZ02y0hUCbig LUbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5lbYzNvSB13ho4baz8lVDYwi3GzJW/A2z6Hjt2XZSek=; b=qQp2fBcNd42FmFws1KsWA25ORAKIzFFxp8gnhR8+6RACx5TEDq71lPZZQJ3n6JsWOR mw4pDHcP7hL0b4AvQcu36/+ziIhzCo3kcCHEvRiNSNgaTMGnchKaRdoF/EnnB1EFHC1Z nTJ4WtzMiQlEoz+HaCh2MxYQktqgXw6RIIDfwOOZxgyVXaSECfmgFCNqrP5/QOlnoOQ7 a7ExYnqHrZytdjjzDTXNcoQe34uTlLGNnIQjlhPDHDtGUKuC7IWPz1zRVrYveQHcwqbb /5+uQ55OQzRAIeNJIVIqw9c78VNfSaBjB8J8qFDp7CxxYIkpf63nn3lZQcR3cz84Nd/C 7QmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tihZiaNX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a1709062e8a00b00977c804675dsi5802489eji.74.2023.06.12.14.17.34; Mon, 12 Jun 2023 14:18:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tihZiaNX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238658AbjFLUv5 (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238402AbjFLUtw (ORCPT ); Mon, 12 Jun 2023 16:49: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 E170E296F for ; Mon, 12 Jun 2023 13:47:07 -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 220A162F35 for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FBCEC43328; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=/HEE7wLoU0aARylBa78hxj5pmV8p3SLHOC7ItTxKH/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tihZiaNXAFPQV8WTdLoz1e8HNDHvHyM/vmV+hRjqOcMSvSXozg1Dvc/PBJG3aQrNh EL7VCkgaO/qD379Ji2euUx5IyGyf6FcxXy9/zgmcly7JIKwsgyFs/o3tX2PtLDY6h/ Z6D6Te0V3tPh4qYsJP3DPJp4OWWLbfYqVMTqLsH2xrwblhYckqtBPeydIafUqJdLcI +4ADVLzjaw1LoPuEBMTJLKKxN0LfMUyRcCELguDn3+RbqkLI16rkiFY37HTR3nunn8 jHGVbXr/MDczb+1vXBoB0WA8K07MvowhhJfEwIxLRFIM4EB3tPJFX4Iri60T4JvEqL kGarpICXDGIzA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0DE96CE3A84; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 39/53] tools/nolibc: ppoll/ppoll_time64: add a missing argument Date: Mon, 12 Jun 2023 13:45:00 -0700 Message-Id: <20230612204514.292087-39-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768533190681951332?= X-GMAIL-MSGID: =?utf-8?q?1768533190681951332?= From: Zhangjin Wu The ppoll and ppoll_time64 syscalls have 5 arguments, but we only provide 4, align with kernel and add the missing sigsetsize argument. Because the sigmask is NULL, the last sigsetsize argument is ignored, keep it as 0 here is safe enough. Signed-off-by: Zhangjin Wu Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 7836d7e7760d..0160605444e7 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -939,7 +939,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) t.tv_sec = timeout / 1000; t.tv_nsec = (timeout % 1000) * 1000000; } - return my_syscall4(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL); + return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); #elif defined(__NR_poll) return my_syscall3(__NR_poll, fds, nfds, timeout); #else From patchwork Mon Jun 12 20:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp130147vqr; Mon, 12 Jun 2023 14:02:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Tnruk2sGPMqw/ahCYcs/ue160CLoq2dAPOrDIiPHRYeqAN/QRKDfBMhpqyyVwgzEtgtld X-Received: by 2002:a17:902:db02:b0:1b1:d6e5:3dd4 with SMTP id m2-20020a170902db0200b001b1d6e53dd4mr9684802plx.48.1686603740472; Mon, 12 Jun 2023 14:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603740; cv=none; d=google.com; s=arc-20160816; b=m2aIrDCR+RAa6lpp6gHD+1mBeIC0x2oIbqv9US8ZgQMfYyvZyIY0efHkeydsa33C3M 5sgjF0+Iz35YKmPlU0oJiWC8dayDwIjDTvyKH+SNYjqKsMGNz/9EXwoZcKePB92Vahhs T4Jnm6pibdN5210eUOwPLtuKyy9LphbHWL+AUqJ0waasEhjlE9KZ3+AoWiqXU5a8LsZl +py4iXRxJJLcOQ3NyTmqpTt3T3IrWQQ6sIa/6qVZfUARxGWvc/QylTABlDhev6k7R+H7 6CGM6KzrvYYyzld9lHrvamGxDXlgV2v8KEhR26ptB7Io+/WiSdqI3s6Kj6WnNZqL1o0C 8EPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0o51GdbAlF6Qdzjvc0QB6W7GNTeXiHLTPvpTqlFKYBI=; b=POa0tOwOelZZViKJ5aSY5W62HHuWaKuBIAnoBV9waHRmgfGm48UO+i2MX7aU/+co4P ZXjSM6cc0xprVllM13hSkLl5aTrZ6NssktdXMGES9s2vxl/ZQnv7v2a8azurUesvs6pl SmFPJNqBs/XwxSX5jGom4Fo+Gk2usrZtb3k+r1FNWp99OeMUHKkdhi1I+udkMRhqHdmd k4W56eS/9YlMebsoerzPCvbghsux3JtmC+1BKirjnXKzqgb0e4KsMV27fGU1jlHHxGvk S3iYjW/BeUbgSxlxEytV2gI8W6cJcWzplLIZpIVjrGxjndaoQCv29lyu0owKsQdw0IHg b/Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WX9V9qKL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij25-20020a170902ab5900b001b243975834si7416188plb.143.2023.06.12.14.02.06; Mon, 12 Jun 2023 14:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WX9V9qKL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238300AbjFLUtq (ORCPT + 99 others); Mon, 12 Jun 2023 16:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232598AbjFLUrs (ORCPT ); Mon, 12 Jun 2023 16:47:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 172CF2967 for ; Mon, 12 Jun 2023 13:46:46 -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 B66AB62F18 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42767C4332A; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=0zt8I95z1HUq9EJL6kDDSqhW2E6bfWG/BgIkZcsxQ8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WX9V9qKLsrktkGY0S+pZbFzmbFyCgZjOfy8DMZKbSGE+YoFb3FPDQCpbgLs+Dxyfs ATd7B767sG4SF1yANN+ZOAcNqeawVfzRtZae3RHkoTsytEbvlLurC1P6tsl28JACzW CuPsVGv1peAkwoZ1Qoy8hMk28mfZVyH6q212xIH4vAuyv9VyMIQK+4a0I6kJe7aUf2 h6Pa1HFguJCyUpstDl3nePUREzp/QG6kWfev3YWSBqJ82Kpf2T3i7nM7JhZEhAKj1K cdznNUPJxW7S2jeuqIUWJ3g2Au6A9WCCyHHtAd+NaMdRz1jbkC8KfGRHE73coZdt+u amTfMpPOlTfxg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 10216CE3A85; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 40/53] selftests/nolibc: test_fork: fix up duplicated print Date: Mon, 12 Jun 2023 13:45:01 -0700 Message-Id: <20230612204514.292087-40-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532203565758490?= X-GMAIL-MSGID: =?utf-8?q?1768532203565758490?= From: Zhangjin Wu running nolibc-test with glibc on x86_64 got such print issue: 29 execve_root = -1 EACCES [OK] 30 fork30 fork = 0 [OK] 31 getdents64_root = 712 [OK] The fork test case has three printf calls: (1) llen += printf("%d %s", test, #name); (2) llen += printf(" = %d %s ", expr, errorname(errno)); (3) llen += pad_spc(llen, 64, "[FAIL]\n"); --> vfprintf() In the following scene, the above issue happens: (a) The parent calls (1) (b) The parent calls fork() (c) The child runs and shares the print buffer of (1) (d) The child exits, flushs the print buffer and closes its own stdout/stderr * "30 fork" is printed at the first time. (e) The parent calls (2) and (3), with "\n" in (3), it flushs the whole buffer * "30 fork = 0 ..." is printed Therefore, there are two "30 fork" in the stdout. Between (a) and (b), if flush the stdout (and the sterr), the child in stage (c) will not be able to 'see' the print buffer. Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index d417ca5d976f..fa18e7dc35c8 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -486,7 +486,13 @@ static int test_getpagesize(void) static int test_fork(void) { int status; - pid_t pid = fork(); + pid_t pid; + + /* flush the printf buffer to avoid child flush it */ + fflush(stdout); + fflush(stderr); + + pid = fork(); switch (pid) { case -1: From patchwork Mon Jun 12 20:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133752vqr; Mon, 12 Jun 2023 14:08:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65muoGYOWPdE1T/qw++TWGNqYd3g+3+BCV6hIHIcWucLC/IaTckmtrR51mEGy4ZvcX1hNT X-Received: by 2002:a17:907:934a:b0:974:5399:c21 with SMTP id bv10-20020a170907934a00b0097453990c21mr10283584ejc.24.1686604129567; Mon, 12 Jun 2023 14:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604129; cv=none; d=google.com; s=arc-20160816; b=RYHV6873XxgV3q4IATTAH+aw6O3r60O0L8bdPl9M2UU/oKJwFiWWX/W6Jfmm0A2+5+ qFb5052HvmvpqQ4DQIoIvqVxQIAUXtvCoIKmdWFwsPocjaZNBqVp7xIE1k4BAPlSTiDM pQHLhiOtT4+aDtKOkY/YhRBVSupigMnQdMa9ONr/j6rPO0buf7zRvBs2dc+p4Bs8pxXz jAT9EZGDivzJesJLGfE8eGrtCwyHZH+mXcl36TMihD03rQFyFCE0z/r3Sc+hh4DaU/67 dpCv/puZsD91x5zypkvkB9PS7AzVLQLgvMQFz6S6g443XzyIYROLn/RLO61T1552SRKm UN3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iLeZE35YnUQAcJbNMDv44aRYixJBHkpGJjPhZXbX6bE=; b=nJzXoFeKcGd7NQRvXoY2UEnoyCAxLmhzASpxYJXm+go0Ddl9hVeTB7GRqvNtGMrHjK KTgrM9oPqFx1PVkeLW3R2lEuiGEjJ7N5FFMqUw+YwYLVNc5aBwbip/SSWUF0bkSBaLRz Z2L7ZAaE4b5Tt51C7D5bzcBK0YMA7qUiryt2W3G74FoG0EMvCPtwtMHpy0heL7T2uWWM UJmm5fJrg9Vi7ryvOFgCoHN6cTDWjvXBhGQPx003YAqiLdLn+b5cfSYS6Un47+/F4h1T 2ROWcS7szXKfR2dq8IJPpeTcCTGdDl8GPHWNsJH5+3bAh5CK18HB9jn+ikOudX5pG+Lw iqHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RdDvE1MH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pw20-20020a17090720b400b00977d4248993si5442484ejb.462.2023.06.12.14.08.25; Mon, 12 Jun 2023 14:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RdDvE1MH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236652AbjFLUul (ORCPT + 99 others); Mon, 12 Jun 2023 16:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237755AbjFLUrv (ORCPT ); Mon, 12 Jun 2023 16:47:51 -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 7261E173F for ; Mon, 12 Jun 2023 13:46: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 CB39362F1A for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47E32C4332C; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=cIY3z+FHEm5CXeXJFEW47PhAl46oQsi60a/jd0EmyWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdDvE1MHbzjwsOvF9ffDd4djh30bJj4Nt1XVHwaApJzI3jj+u1EVHFDuxPTG5uDgz 42XXJFBqWA54x7GAP8pY31gUSUqGC2ZQLz46cJDfj5RlcJQomu8jYwnBaDBkq/LIlz uvQH3GUYCNVZ3EVJyioBColBqkRw0xA6UVE5VvZbZ6NWfoFpTuogithxrcS7LfCM3K OL9zZ95/NdEyLwZ8M0X9yweu5IE8uP0WzsECGjgljxnkWOXLVKrMIllOYS5Rdt01ZY 3EAuI1Zk2numgEWMiZBqwLq/4MHgA0+4IFcV1NEyaN3gBjSM0bnhQkeGLnTztSLyVz 5pkzeqdqYAOOQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 12608CE3A86; Mon, 12 Jun 2023 13:45:16 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 41/53] tools/nolibc: ensure fast64 integer types have 64 bits Date: Mon, 12 Jun 2023 13:45:02 -0700 Message-Id: <20230612204514.292087-41-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532611993296392?= X-GMAIL-MSGID: =?utf-8?q?1768532611993296392?= From: Thomas Weißschuh On 32bit platforms size_t is not enough to represent [u]int_fast64_t. Fixes: 3e9fd4e9a1d5 ("tools/nolibc: add integer types and integer limit macros") Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/stdint.h | 10 +++++----- tools/testing/selftests/nolibc/nolibc-test.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h index c1ce4f5e0603..661d942862c0 100644 --- a/tools/include/nolibc/stdint.h +++ b/tools/include/nolibc/stdint.h @@ -36,8 +36,8 @@ 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 int_fast64_t; +typedef uint64_t uint_fast64_t; typedef int64_t intmax_t; typedef uint64_t uintmax_t; @@ -84,16 +84,16 @@ typedef uint64_t uintmax_t; #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_FAST64_MIN INT64_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 INT_FAST64_MAX INT64_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 +#define UINT_FAST64_MAX UINT64_MAX #endif /* _NOLIBC_STDINT_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index fa18e7dc35c8..bfcbc05e6b5b 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -702,9 +702,9 @@ int run_stdlib(int min, int max) 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; + CASE_TEST(limit_int_fast64_min); EXPECT_EQ(1, INT_FAST64_MIN, (int_fast64_t) INT64_MIN); break; + CASE_TEST(limit_int_fast64_max); EXPECT_EQ(1, INT_FAST64_MAX, (int_fast64_t) INT64_MAX); break; + CASE_TEST(limit_uint_fast64_max); EXPECT_EQ(1, UINT_FAST64_MAX, (uint_fast64_t) UINT64_MAX); break; #if __SIZEOF_LONG__ == 8 CASE_TEST(limit_intptr_min); EXPECT_EQ(1, INTPTR_MIN, (intptr_t) 0x8000000000000000LL); break; CASE_TEST(limit_intptr_max); EXPECT_EQ(1, INTPTR_MAX, (intptr_t) 0x7fffffffffffffffLL); break; From patchwork Mon Jun 12 20:45:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp127400vqr; Mon, 12 Jun 2023 13:56:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HBLvrOoRL3Fq5Lw2PySuiFKLsXWWHcKVFoCjQ7WE1jgDIh00q2UVqGezklr5ZSwPF12rO X-Received: by 2002:a17:906:58c5:b0:974:5e8b:fc28 with SMTP id e5-20020a17090658c500b009745e8bfc28mr10966967ejs.9.1686603383061; Mon, 12 Jun 2023 13:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603383; cv=none; d=google.com; s=arc-20160816; b=iGb6T94LTUGbw+cbdhpjRoaKAw8sHp7xHUcuz4hwNS21rHrQHckchwzeFjXo7aM2R9 BlNukgM8s/MhLxiu3kznNrSuiSes73K673Eorp/osxMUpQ8gjDD7TOaGkBRrjSpVBZ+6 zJvy9u2QSgYzn1tvGBBQr5bPnt7dm4f6O/vyM07Lvkj4OdkRw17PlYlBAADYOwsvghbw V2ylcX82aU9WW3K9BWrzyhYKwiYdQKgzCqJuDNpTV08rxMPWYgHiykF/PjsT1yV0tRtN JX5qX4dqwbuoBVjbMX1GKrLabWBbcANpNP4A1m4h6P6NrqmYfYClyncDu0PBluOGg+Nd TBHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4dHZu2mLKFHxC+WXarcLdg6C2QFyU1J7/OVoK4sVIc4=; b=zTwxVazztX9RVgsRuiI4E890OcSkb5fH+wpXULxf49xvJoelF9PIyuGky0iiqgZEs/ O059lnV4rgMc8b1thQbErQBlqg/MBxjqhvTtFVA2IEhRA4fp/lx0Gve+qDEtETXNc6Wz GLLV1xj4TrGAck3NW672kvGbr5c5mBsvfmvajdRGE/hq1nHfIySoIm1yK/7k+FPKl2v5 NsGcnd9ECmp1S3luY9y2XdzGGDISHnx+un5E82+gCg4G2U3ehft/vTmeI7XWp4249zqW CpJ3qHR3NX2AThRy6zsZs/K8RrbOitY8X6+CK4pg7o0gM9lafN1ulsLUPTJYs57b6AO4 zeWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/o2kExg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a1709062f8900b00965b588cc7asi5359238eji.102.2023.06.12.13.55.56; Mon, 12 Jun 2023 13:56:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/o2kExg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237807AbjFLUup (ORCPT + 99 others); Mon, 12 Jun 2023 16:50:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236908AbjFLUry (ORCPT ); Mon, 12 Jun 2023 16:47:54 -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 6A46A171E for ; Mon, 12 Jun 2023 13:46: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 dfw.source.kernel.org (Postfix) with ESMTPS id D265462F19 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E3B8C4332B; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=YVU6ViEp2LQfYkR6nErcvVF9nbi+sEIEq44A4g2Ftxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/o2kExgd26Xw+2rLZPzH96UptXHJ1CfLwRVO8+dBY+Db2nxb7NguhRpH4eZ/UB8O T7lVY1TKf5LRe3YaG41uC2bu+JSQwkd1RcBJSL9nV86eyHnexyc6QONab5DBXoBSQ2 WBioouK8JsTvLZrtJ9JIW8okCS3LdBSjovmlNtdmqrI63dQeTYVpIJebfNX1FA7laL l7Abo/Pbg6JJk7E4z7Dw3TcgYElgv2HWQbW23zJ/0m0myg6/vrOM+TghcD09QJAUaG QBLkRXWTn+Serkpnpjl0sTQRDblEsjfxo4gZ6hN041pZWquNSGQpnHTabBH0PaenbH 07YZU5m+LYmYg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 149F4CE3A87; Mon, 12 Jun 2023 13:45:16 -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_?= =?utf-8?q?Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 42/53] selftests/nolibc: remove test gettimeofday_null Date: Mon, 12 Jun 2023 13:45:03 -0700 Message-Id: <20230612204514.292087-42-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531829095342553?= X-GMAIL-MSGID: =?utf-8?q?1768531829095342553?= From: Thomas Weißschuh gettimeofday() is not guaranteed by posix to handle a NULL value as first argument gracefully. On glibc for example it crashes. (When not going through the vdso) Link: https://lore.kernel.org/lkml/96f1134d-ce6e-4d82-ae00-1cd4038809c4@t-8ch.de/ Signed-off-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index bfcbc05e6b5b..cfc7b270c397 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -589,7 +589,6 @@ int run_syscall(int min, int max) CASE_TEST(fork); EXPECT_SYSZR(1, test_fork()); break; CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; - CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; #ifdef NOLIBC CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break; CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; From patchwork Mon Jun 12 20:45:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp129265vqr; Mon, 12 Jun 2023 14:00:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IGwxyFTxzhHrGZUEwnspLkHoOJE7azYdrh51X7BgzWvpX6E8JMHKuyVHwopy0F3mX0SxA X-Received: by 2002:a17:907:7e9e:b0:96f:fc9d:6e9c with SMTP id qb30-20020a1709077e9e00b0096ffc9d6e9cmr11434704ejc.63.1686603657075; Mon, 12 Jun 2023 14:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603657; cv=none; d=google.com; s=arc-20160816; b=mhlQN/LeSXFzDHXw9dtUlgDOxA50IP+CaNZIvCQZvgRS9jjIag/n81IEfJjbOUZP2r ho1EJN/VnYaSHkaSflUEmd9wM5S5hu+b4Yoz5a14+AKmkFvYqIGsz6yBEPMnzzn7MRME FNBjvofyDHQb71OV7uwcR8B1FyhBOEvfHx7j7OhM6Vls6CyoDly2emTXvAsQd7Oe9aI/ cf2kUS6RxjxBNCzUigmXDDCLCVP4M8BDlA5cidlH27gb068bbSr2rQUlGP8Xm4HtfBVp NtL7c7xMLghJLeDnG6+bguFeuAXsa0elsK/zxLhMGyiVGKZccfcp+f1o6mCv6FzvrRvh 28xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zBTvu6NE5crB6HnYa9pqK1Ktt0Dxc1Gg4WdcJO+/ujI=; b=PlcV7s8mq5R+zFMWn8KHJ95G0KmUD6atoNTpnIqScshX3qNPDuaJOaDanlAvO1i6Mq vGjjr5H8iU2xEviiq1AhcQJ5tGUibPs9dIh7j/lZhkUVXlKvHkS1lpJiy8rKzvfgmSIe oe6Ir5Iws78mxipfp2E4qMh1Fp8mphjAx9BkcWai8gbOd+X327HsQRwZ5xPa7OQdqQQp w5E8QZu0bk9MMrA8e2dYjCTib76lYgdqvTH2+Tiew/OqE5vGKylsPnx4hdF4yCua9oT0 M0ITKzljfQ5FGZ5L27D8kTTSMmBBsnlqGg3Xk+UXdOV6yVgGK0owapk70mSEta9o4/8N qswA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M0m4+Gw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a1709066b1000b00974639040b7si5436967ejr.785.2023.06.12.14.00.32; Mon, 12 Jun 2023 14:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M0m4+Gw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238103AbjFLUuu (ORCPT + 99 others); Mon, 12 Jun 2023 16:50:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237816AbjFLUsD (ORCPT ); Mon, 12 Jun 2023 16:48:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A565119AB for ; Mon, 12 Jun 2023 13:46: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 dfw.source.kernel.org (Postfix) with ESMTPS id D2DD062F1C for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FAF5C4332E; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=aVqOtwmx537eWDCmSDJwrEESzYvq7/Do2SB85XSCprw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0m4+Gw20RtEfRWkpnsxaIZ4QVmx9svEupWtYqPIuH09CgLPYnTyS/dws3buXQOMf qEltOAQJeHpPfJtHSFVVY92O6BQ0WmyvZlr6Ln77x7o1ISW7nicsJMpGQ2EikcMqET niDWnICFABYmCvpc+VZgMZUj2ZJd+x5O+nlm07CKOz3gNdQHQywzKKfpAJTyNTQTfW mdhJJ9BwrntgNTnBkeB6q0Ed+YZetfLyFU+v1T7IoFKwpE+s84MzsDZROlVW/p1VpQ U586gEuzIL1b/3ijOLbItcXr2OyU00ja5ZhzUxqdcW4FlSIIb72oZl1RUXIlVGeWDF e8bOvRMsEG7CQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1706ECE3A8A; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 43/53] selftests/nolibc: allow specify extra arguments for qemu Date: Mon, 12 Jun 2023 13:45:04 -0700 Message-Id: <20230612204514.292087-43-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532115958635715?= X-GMAIL-MSGID: =?utf-8?q?1768532115958635715?= From: Zhangjin Wu The opensbi package from Ubuntu 20.04 only provides rv64 firmwares: $ dpkg -S opensbi | grep -E "fw_.*bin|fw_.*elf" | uniq opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.bin opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.elf opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf To run this nolibc test for rv32, users must build opensbi or download a prebuilt one from qemu repository: https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/opensbi-riscv32-generic-fw_dynamic.bin And then use -bios to tell qemu use it to avoid such failure: $ qemu-system-riscv32 -display none -no-reboot -kernel /path/to/arch/riscv/boot/Image -serial stdio -M virt -append "console=ttyS0 panic=-1" qemu-system-riscv32: Unable to load the RISC-V firmware "opensbi-riscv32-generic-fw_dynamic.bin" To run from makefile, QEMU_ARGS_EXTRA is added to allow pass extra arguments like -bios: $ make run QEMU_ARGS_EXTRA="-bios /path/to/opensbi-riscv32-generic-fw_dynamic.bin" ... Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/2ab94136-d341-4a26-964e-6d6c32e66c9b@t-8ch.de/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 47c3c89092e4..44088535682e 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -64,7 +64,7 @@ QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" -QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) +QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA) # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. From patchwork Mon Jun 12 20:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133976vqr; Mon, 12 Jun 2023 14:09:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SCdCD0KQprSiME2vHhO6up4jOzXU4UPRp+lO26Snhr7M0n04UOElAl6doqaBg5T3wIq2A X-Received: by 2002:a17:907:3f83:b0:94b:ffe9:37fd with SMTP id hr3-20020a1709073f8300b0094bffe937fdmr9656235ejc.5.1686604152158; Mon, 12 Jun 2023 14:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604152; cv=none; d=google.com; s=arc-20160816; b=whIbhpqhQosN26SRfzK4tTqktGp/apUplVd0nCoEVSyjDpuSFeKR4EkDRMADBTHX0L Tp1zE5NO3rbe9A5eA2nAs8HrIR4eyXhNXvO+Z5EfEDqfIcBSGBg8bcHyWWg3wi1B2Mkb XSN2RgD8YtVy5cd0KOS/dExbGruM9D07P5wcBB7laKicOHSb228/o07+Uc2Q/ZnV7psp +U2T4smK4vEUAtIwVbeiBSUaoDuSkMETKV51bMrDj0MRZoDV4szjD+aaqLPOBL994jkL Mq1jcS26Qyu5GXajEOr0PNdXw13SEVP9cdUGZN7ooccLDgI2y/Sk3aJmchzzWrUq2cuZ yVBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5YReEuo76+gRJ99UK6v9lm+rZl7fsJh8pJN8fVqXSkM=; b=iFyzVlRBiivAtBlHdkkhlXIu5Zt/AqFM7NYb4BaPnVEEzMWvVe8uAX8hvkS5OQUaYx pVhRRf+740QWrjRMabEUFa7FF6eLXOCK2EU5FVPbiUj7RBXrxeIr3sVtA9QlHRwJCBHg BtLbjgemqOSDNhhnHn0IzsUCcSuWEJGUbDkFJeIQqQAKLv98aJ+Y2i9cQUI/Z+qOoz+i hk8cUat8yoCPvIyx1EQoQ8CnKbRwS7VGjIyP2i3x62bBrIaR6NFFbPigwdwIS+e+WJ8H 1gm6RqnYBaPv451fus++lImT+wGu+x6UmNf+BjNAekH3CputYIEEP/EO+qNm50G9JIXV SPWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IvGcN0gx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020aa7c991000000b00514bdde913csi6329182edt.215.2023.06.12.14.08.47; Mon, 12 Jun 2023 14:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IvGcN0gx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238347AbjFLUvB (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237206AbjFLUsU (ORCPT ); Mon, 12 Jun 2023 16:48:20 -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 3F91AD3 for ; Mon, 12 Jun 2023 13:46:50 -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 D714262F1F for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 595BBC43334; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=DzYPgHEaJn6SEGOBtodqcjbqpjhlzL55/SWXEc/knwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IvGcN0gxBTT+XU2HPuSuQbXLjG+mnfG6Q2psrHCyj64CJyKcNhq3l8g7t3qrX5Trf urpV9lf7GROl1/e9QkDepjlU2BOWAFxgJDMIKjDXwKZbneGGgs5DIJkjAI49FwTf4o jBSeGtpaMmUqAUfM9nHW46ijV7OB8OKpbjpXQPwoFKzR6OUb0wAIP1DDD0bjKDA4vU oZMjP8K/MbvkJPB9XdJ95CS1swF7bZeArSWyyncVLAbKIozkSiEmAPnmnWFulrgK6d acSczQw5J0xzYsFvUtcwPFbl+/PYAnXE+D9ZrIVq6Sj5YVYqEcLfol8CX3kTW7WLD9 CfPCd+QC/EcnA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 193E9CE3A8B; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Willy Tarreau , =?utf-8?q?Thoma?= =?utf-8?q?s_Wei=C3=9Fschuh?= , "Paul E . McKenney" Subject: [PATCH v2 nolibc 44/53] selftests/nolibc: fix up compile warning with glibc on x86_64 Date: Mon, 12 Jun 2023 13:45:05 -0700 Message-Id: <20230612204514.292087-44-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532635614276242?= X-GMAIL-MSGID: =?utf-8?q?1768532635614276242?= From: Zhangjin Wu Compiling nolibc-test.c with gcc on x86_64 got such warning: tools/testing/selftests/nolibc/nolibc-test.c: In function ‘expect_eq’: tools/testing/selftests/nolibc/nolibc-test.c:177:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=] 177 | llen += printf(" = %lld ", expr); | ~~~^ ~~~~ | | | | | uint64_t {aka long unsigned int} | long long int | %ld It because that glibc defines uint64_t as "unsigned long int" when word size (means sizeof(long)) is 64bit (see include/bits/types.h), but nolibc directly use the 64bit "unsigned long long" (see tools/include/nolibc/stdint.h), which is simpler, seems kernel uses it too (include/uapi/asm-generic/int-ll64.h). use a simple conversion to solve it. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/linux-riscv/20230529130449.GA2813@1wt.eu/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index cfc7b270c397..dcb0bd079d15 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -174,7 +174,7 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret = !(expr == val); - llen += printf(" = %lld ", expr); + llen += printf(" = %lld ", (long long)expr); pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } From patchwork Mon Jun 12 20:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133594vqr; Mon, 12 Jun 2023 14:08:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XiJ7UU5A5lZaNGXL5sNS6eXLAN7iUYC6eQv9unk+0hbfFEl9tgbbPHZqLGmD3t2gliz1M X-Received: by 2002:a17:907:7207:b0:96f:d780:5734 with SMTP id dr7-20020a170907720700b0096fd7805734mr10624258ejc.65.1686604112389; Mon, 12 Jun 2023 14:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604112; cv=none; d=google.com; s=arc-20160816; b=NnJJ5qEPKVe2B8TYheTmIx8fH91oYBJMKin0lfp1b+AUgW59rLrftRuubwLg68pRvL Ngochi489eIUb3b1GiNvpNjadUo+k9vYNZHPzmuh4O050p0m1nm3+u8VZJEQJqYW3mHt 33g5EiQhzWZkcnL5keRu3dJn13VpoyKH8vNvCwE5LpBNXpdRmynAiBN7FBSej3LFLoQX t5jyipofyHTbQQWoEKS09os71d9tCvnDCN3uT2+UnhmxtnozZLNKX1tn57ZaBAxcZ0Jd /u+B0dhVqPJ+e/rIv6VBRdIbAWb06G5uWe1RNRtqT7/ARSL47d3qT3g6yy1ByIu18SWv o/qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RKAhkvg58GhU6/locKqugjrYXIP+V2E2Xpl/TqPi2Rw=; b=sRRpz1ccHujlKWTkYUuxIyDm87tcOcHxueAsgJkOq9uBxeyrxcWhrrw8XrZqAZxyXf DbtLaWwu8C1zY47C1NKhzhZPXOfB8nXtEguKHr5n6Iy4g3FTp3sSEJ8V6FLKrPQec0sI dZbukpdW0cgIvYxic4zKE4rnZw3glYCONsjazoo57vEqepk+uUEJbdvnT28NK3Rlpk91 Ic7SQ3EDXjSvn+9RvFJ6n0XVyNjXTQrgNwiT68lBYyuXsgUrTqNd2Ehek8u1o3LNKf+a 7N7INMRQODwSsuQZEI40gZq3sbOVidYoy0tNGzKh+9eDQDDIzj90Pv+6NbsBvems9EYB HFgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nypZtV0m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a1709061e0a00b0097391f75082si5682864ejj.838.2023.06.12.14.08.07; Mon, 12 Jun 2023 14:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nypZtV0m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238203AbjFLUuy (ORCPT + 99 others); Mon, 12 Jun 2023 16:50:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237907AbjFLUsR (ORCPT ); Mon, 12 Jun 2023 16:48:17 -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 ABD4419B4 for ; Mon, 12 Jun 2023 13:46:49 -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 D359862F1E for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 542E8C4332D; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=fEUn7QI6ZM1/RSV/3DLiY1bJ6vwD3honS9s4B5UVY1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nypZtV0mt3yn7CvHpsUwcJHJWaFRW4DnjvUp81bNqkgoRZ7CYwp9qjxSNxAr2l4rZ PAx+Z6ZZ4XQGoOHBvYUyTIqtpagyBS5sBQ1a/VmEQ4QPp7l95VKrMDCIXIW4w8IpkL pRYYkXyI+5Sm0Aug/Q2PuCB5J9Rz3+XaNtke5If/56SPZ8IC8O4YhpZr7lUWiIR9Oo SUkBbIFaBLezxgJu9Jq7QUgI/Pzd+JbBUDunJ4JTioRnlVXtRZgaAfc8GeWAYDduYW fpDXWOGu4MGe3ePrUnxLbGD/asj3TJVBP/2Ce2NAz1o9jYPoo55YZhX7SICjDmxsyV /NKfU+Ngxyycw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1B79DCE3A8C; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 45/53] selftests/nolibc: not include limits.h for nolibc Date: Mon, 12 Jun 2023 13:45:06 -0700 Message-Id: <20230612204514.292087-45-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532593359755027?= X-GMAIL-MSGID: =?utf-8?q?1768532593359755027?= From: Zhangjin Wu When compile nolibc-test.c with 2.31 glibc, we got such error: In file included from /usr/riscv64-linux-gnu/include/sys/cdefs.h:452, from /usr/riscv64-linux-gnu/include/features.h:461, from /usr/riscv64-linux-gnu/include/bits/libc-header-start.h:33, from /usr/riscv64-linux-gnu/include/limits.h:26, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:194, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/syslimits.h:7, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:34, from /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/nolibc-test.c:6: /usr/riscv64-linux-gnu/include/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported" 28 | # error "rv32i-based targets are not supported" Glibc (>= 2.33) commit 5b6113d62efa ("RISC-V: Support the 32-bit ABI implementation") fixed up above error. As suggested by Thomas, defining INT_MIN/INT_MAX for nolibc can remove the including of limits.h, and therefore no above error. of course, the other libcs still require limits.h, move it to the right place. The LONG_MIN/LONG_MAX are also defined too. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/09d60dc2-e298-4c22-8e2f-8375861bd9be@t-8ch.de/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/stdint.h | 14 ++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h index 661d942862c0..4b282435a59a 100644 --- a/tools/include/nolibc/stdint.h +++ b/tools/include/nolibc/stdint.h @@ -96,4 +96,18 @@ typedef uint64_t uintmax_t; #define UINT_FAST32_MAX SIZE_MAX #define UINT_FAST64_MAX UINT64_MAX +#ifndef INT_MIN +#define INT_MIN (-__INT_MAX__ - 1) +#endif +#ifndef INT_MAX +#define INT_MAX __INT_MAX__ +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-__LONG_MAX__ - 1) +#endif +#ifndef LONG_MAX +#define LONG_MAX __LONG_MAX__ +#endif + #endif /* _NOLIBC_STDINT_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index dcb0bd079d15..7d4b8d12050d 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -2,9 +2,6 @@ #define _GNU_SOURCE -/* platform-specific include files coming from the compiler */ -#include - /* libc-specific include files * The program may be built in 3 ways: * $(CC) -nostdlib -include /path/to/nolibc.h => NOLIBC already defined @@ -39,6 +36,7 @@ #include #include #include +#include #endif #endif From patchwork Mon Jun 12 20:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp127414vqr; Mon, 12 Jun 2023 13:56:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79Fsb9LlWHc1e2cn9J0owUhbviBQEfKG7AuShdJf2w9iV/6/rkXee6NMMBD74W24sb6i+x X-Received: by 2002:a17:906:6a1c:b0:978:ab6b:afe9 with SMTP id qw28-20020a1709066a1c00b00978ab6bafe9mr10074775ejc.66.1686603385708; Mon, 12 Jun 2023 13:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603385; cv=none; d=google.com; s=arc-20160816; b=XjUKhTanxBJsOQuElmwbL722xneERB97vt0GfuzgF6hVPH4P8M/UwrCiblRrJV3+2Y mL4MG5/DQVaCtcnS7dIlT5fRPYUZ6fRdne3WcFHRrqKybGEuNHG7ZjAnqrE9UzvcX6mg F1trLraVb3Q3LsZUWthlrQaXW9EJy3g0WHRKb88zpulY4dVVHvhNgt8Mrc7/KXZlTM7c kiUXXeYkdKDrSnbkMz+DJUR3A6+2ls8I0ckT/J3/Vafxhk8LXbRo8ozjiRKtfGvNG9CC eBqC7+yXwncplY3lS6JDCvV6Xx6qkT0BP98IONO7yh8zhZx4uO0xQrNsaTSmXATNREjS aTxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pelU6aDCxs8hjXquclzYPPTsYkBi8J5CLu6lZAxAWMs=; b=y1bJ0oCCqSh0GY2ajmMBaWUsBdvyEgjfNUfv1RrV9E7ByH6Pa2A0a/iY8cUP5KlB0U v8hYlngYuybVOVVGTp8iPMTGj5RLd8zIf/5v5ZsvH1rzd8NgGDSJkrVWd8XXti4C2+0i kemMdT1ZurSMI4f/KRNOsIVrTJUfna84g3A2TL3f/nwUsiJ+3Y42ZfqpvlFHghxgqzSS 5CEYuY1I6fLBcUUgilnjon7+hGan+cpNVorh6SmJQA58L2oGe2+/sj6z/U/hXzAOvzaH 6iliQ0/OeJa4gtsDW0iRin8D5g/URPHKeTGEmbYJOYeTjRvLoaNepcRFv6O13xWU3a7g WKcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lCuC8fh+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020a1709063a0d00b0097375b44ceasi6095980eje.230.2023.06.12.13.56.00; Mon, 12 Jun 2023 13:56:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lCuC8fh+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238430AbjFLUvK (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236013AbjFLUsZ (ORCPT ); Mon, 12 Jun 2023 16:48:25 -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 3B410109 for ; Mon, 12 Jun 2023 13:46:52 -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 DCB2262F1B for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A8D9C43332; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=j0LQ24TQ8hn7bjW10yO2qmeOU+M13OFAUcFTpL2cefU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCuC8fh+QlxTCY5xG4i8JuKCqO6tlVs/PbKHrohOTgt7hDdpeMUPOI/iz7Ng7D2t8 78IW6X+b+68e7mvsqzIGcxl0JheD7E0GAPAporUUanzCkR57d5jxMcigGsZr3ZZGMV 0smqwOPlKxXQv3skFuB4e5qCjSmoRxyGSsquzu5HgIQ7T/1uktnJAORlPRbHRprpg3 ABx65KvMs0jAd0Ce2AtSYrzgtMGBZY4pB++FO2LdfLyCfi2A+7/H1ANlwoaTA3PVbP Ptj0a5Hfwjco3Z0zXj5f3cnwEWbw5lxNw2yj6rJ464VPzJCpuoJTnu9vQyOak43Jmd f0vfmf9vw2NpA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1DB65CE3A8D; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 46/53] selftests/nolibc: use INT_MAX instead of __INT_MAX__ Date: Mon, 12 Jun 2023 13:45:07 -0700 Message-Id: <20230612204514.292087-46-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768531831764400346?= X-GMAIL-MSGID: =?utf-8?q?1768531831764400346?= From: Zhangjin Wu nolibc now has INT_MAX in stdint.h, so, don't mix INT_MAX and __INT_MAX__, unify them to INT_MAX. Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 7d4b8d12050d..ff3da9539809 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -936,7 +936,7 @@ static const struct test test_names[] = { int main(int argc, char **argv, char **envp) { int min = 0; - int max = __INT_MAX__; + int max = INT_MAX; int ret = 0; int err; int idx; @@ -984,7 +984,7 @@ int main(int argc, char **argv, char **envp) * here, which defaults to the full range. */ do { - min = 0; max = __INT_MAX__; + min = 0; max = INT_MAX; value = colon; if (value && *value) { colon = strchr(value, ':'); From patchwork Mon Jun 12 20:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp129528vqr; Mon, 12 Jun 2023 14:01:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wOIJQACW1C0J5R7VGunmw+c+H1vVsxTbFpsN/fcK8Gs3b4S8ca4cIFYy/Nm003OjFfIrw X-Received: by 2002:a17:902:82c4:b0:1b3:d432:3026 with SMTP id u4-20020a17090282c400b001b3d4323026mr2614606plz.15.1686603683420; Mon, 12 Jun 2023 14:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603683; cv=none; d=google.com; s=arc-20160816; b=Bf2CXpauWBywicspmNxg1Qs3+It24l3jVGd4t0ZgvUf/z0IYq3jR/8JehxqYF3iKfX HuVCiMb6mopaQkkAc2GX63FuYU1H2SXXXC9aBwhQAd/9dhSgbZUcG8LaoWLhq/lILSBF d0iWIdapwHd3rFs655zrd+vL6duS27CzfauWPrjCMQS2sjgYMdHf9fox0dN17iEUpVws b/AobwH3Oa+xWFYPEfth69cPN4aJ6NLqxCKGK+VzVyY6y15tS0CqlyXTipV+HgwgLzCG InRTikQN75bLwrm0w5y8/vFpW5Nxvf4qY0HjCtiFPvqiHUlX4hbT9XjzL3JlCYjhSNmd TkJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i+719R2BGQEvIRIM4LUKozaKQMLLSVtqLc0F6NA/dtE=; b=U0R0TCsp0ufnlGx1MZU7Zwx0volYxTSxMRRQf/Y10celKcgA6SZ0Wdk5t81qIE5EOT oS/5EoBSsiJilUFLuCrMWZ45jc6N3ctOPH7ecz1LvWlnEyjCB5FuDtpO1nM0T7tjqzhV C9Dxztigs95uiXnWw2oX8KzelYSbi/RdtQYS/h+VYgAL1O2oVlBoBUugSFiU8nqAqeor UQ7d1zJjEpF8nwPXDpqSyWFOVedhhLP7zpI02LvoZEmUJFuAMpNMi9a0BAGOeHlYTvFA CQ0VUplyYZU/7MSAqcvsHfDAgNgHwo89C1s48HfM2xQ2RCj7xiprZEl8QRKDfOcHMV9f vyqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=de0Ij0Ms; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a638c11000000b0051394ccd19csi7689083pgd.55.2023.06.12.14.01.09; Mon, 12 Jun 2023 14:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=de0Ij0Ms; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238333AbjFLUu6 (ORCPT + 99 others); Mon, 12 Jun 2023 16:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232117AbjFLUsR (ORCPT ); Mon, 12 Jun 2023 16:48:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABBF919B3 for ; Mon, 12 Jun 2023 13:46:49 -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 D792762F20 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58847C43333; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=ujkkeF6CcwcL8JLlTc5iUkI9cAxPzJGXzBROQQtoy1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=de0Ij0MsBENh8xMB3pYY6EZViEWela8BfBAsysvMNUIvg2yZhKeyFYZiEwkXrWuv8 ge54p3sKsyTZWknh/NpW1yHg1sDETCOQBOwBAg0uGI76I5P01s3iDiVJmvo35uHbYr BUHxY8RsIUEFNtb5TxIo29lr2IvvxkXad9ALk67kKZ4jxZMWjjf4JEa+VLgQ4ARP1g oISwYta3Dk97PsSA6mikU55RwTZejoLyv7KavLt2CgP7IP52bdAuaHW9u/f6hC4vfR C5xin0VMtowPRnosRed+L+rryBO7+ii5Ozt3dcriHIqL8bgWKzmUWHCdedGZUwRu4c Az5SzCrPvrIOw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 20401CE3A90; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Arnd Bergmann , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 47/53] tools/nolibc: arm: add missing my_syscall6 Date: Mon, 12 Jun 2023 13:45:08 -0700 Message-Id: <20230612204514.292087-47-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532143871290410?= X-GMAIL-MSGID: =?utf-8?q?1768532143871290410?= From: Zhangjin Wu This is required by the coming removal of the oldselect and newselect support. pselect6/pselect6_time64 will be used unconditionally, they have 6 arguments. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/bf3e07c1-75f5-425b-9124-f3f2b230e63a@app.fastmail.com/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/arch-arm.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 45b89ffe8247..ca4c66987497 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -198,6 +198,29 @@ struct sys_stat_struct { _arg1; \ }) +#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + register long _arg3 __asm__ ("r2") = (long)(arg3); \ + register long _arg4 __asm__ ("r3") = (long)(arg4); \ + register long _arg5 __asm__ ("r4") = (long)(arg5); \ + register long _arg6 __asm__ ("r5") = (long)(arg6); \ + \ + __asm__ volatile ( \ + _NOLIBC_THUMB_SET_R7 \ + "svc #0\n" \ + _NOLIBC_THUMB_RESTORE_R7 \ + : "=r"(_arg1), "=r" (_num) \ + : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \ + "r"(_arg6), "r"(_num) \ + : "memory", "cc", "lr" \ + ); \ + _arg1; \ +}) + + char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); From patchwork Mon Jun 12 20:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp132097vqr; Mon, 12 Jun 2023 14:05:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UnGlDuUrQmxW2yEB1YPbNf+sDWUuji1kOYK6VIdXlwR/WMKELUhnjL7iIImR4aLawaFjt X-Received: by 2002:a92:d486:0:b0:338:abc1:1e1d with SMTP id p6-20020a92d486000000b00338abc11e1dmr8192096ilg.4.1686603945044; Mon, 12 Jun 2023 14:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603945; cv=none; d=google.com; s=arc-20160816; b=SeHKjYTuI2XavPHRUWhA8wF4xydkIkwP8Ugq16pf22cZtvr+5eXPgahqPaxLjnUmSt 2GCZaRSeOYGdrhnPbwGKXLq6UXP4Ic681AVSKeVQibkUanl+7rr3QkLvHCCAcBIBVY61 t7IzDdX93yr/dScxy8BybSAqYZn1NKs+zPfHz+paApQikpwkK+yrSTNRj12xRl/NK2/4 uNXiA35g98+UvEWIlZ1nj4EJsgQG5Me5iJmgPUc8fQXLs6h8xiwDPS+QLIyyJZ6WDD8D DndgK6ArkSeWteRu8VYFgbJXSoS2SWpYs5F2yBCH0z9qkDVlB2XiQeh/KyjsNg+uS/wj XiXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1NptzrF1GNb8x/c21q6smfQyenfpT0qQ5uA/RMMnjG4=; b=1LHS5RWMV23y9lqGK4+Q3r/VWiEGN5rOKWvg0GrpIV85ruG/G/BK0IzByVGV7S5ijl vnbiaHlehLUhbcPLvsHBgAT2vMVpioO1CKP/I0zjJOVSdC/0zvXNnbgZxRBrXNTjnCXc HcXnCJtVPu4J826g263sN9S9cCyEDS8Hx6+tNPPU0qMPP732sgAkfK4XDxs5e3cvWMb1 CMiKoajNu4WdCpSJCfMsIL0g1/zdEnu8hFDWfiu21Vb0TOTyZW0XE6Wgj+QpsGuuypBA WdTB3hqnBCN1AklW8rlY9P2VY/BhFyC72STozD3A01fjz6WxBidmS3ru2k2OtrrMp9pG 2oow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GViwPJck; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv10-20020a632e0a000000b0054f96440ac8si1628614pgb.29.2023.06.12.14.05.31; Mon, 12 Jun 2023 14:05:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GViwPJck; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238394AbjFLUvH (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238014AbjFLUs1 (ORCPT ); Mon, 12 Jun 2023 16:48:27 -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 4622610DC for ; Mon, 12 Jun 2023 13:46:53 -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 E217E62F22 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63406C4339E; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=Ztog5VulF0m7oJUFFCX3inDjV0jHrtLC2NTdl6UI15w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GViwPJckT5wfjzpiiSHs4J+q62lMGTpuSLIgPFUTk7YT6Ps9gLKM0a583L7rwRY0V yRwERywFicxoSU0Mayl0N8XpcDEOCQZm9vE3W7mXaXTahaxKQZtuEgMPH13DFEIIzS R7a23FMC5YK5NCyKn5rqjsMS+iyO7CV77pnxteu2Xkwa+pKPr53C3PgojrGQnuxlwn QNxFm/asS5HzAH56mDqZ5fKVTTigEQyWEuGeE6y3+9cF1sR3fypWYrsKgb0iVFrHaL PkNe0ncwdXZ+C2OJvTElBGw0VLLIVnb4pIbOBE41AfnHJbCeW1hdv50dfMHL6tIz4b 6lt24zdyo5EzQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 22678CE3A91; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 48/53] tools/nolibc: open: fix up compile warning for arm Date: Mon, 12 Jun 2023 13:45:09 -0700 Message-Id: <20230612204514.292087-48-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532418350322229?= X-GMAIL-MSGID: =?utf-8?q?1768532418350322229?= From: Zhangjin Wu In function ‘open’: nolibc/sysroot/arm/include/sys.h:919:23: warning: ‘mode_t’ {aka ‘short unsigned int’} is promoted to ‘int’ when passed through ‘...’ 919 | mode = va_arg(args, mode_t); | ^ nolibc/sysroot/arm/include/sys.h:919:23: note: (so you should pass ‘int’ not ‘mode_t’ {aka ‘short unsigned int’} to ‘va_arg’) nolibc/sysroot/arm/include/sys.h:919:23: note: if this code is reached, the program will abort Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 0160605444e7..856249a11890 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -862,7 +862,7 @@ int open(const char *path, int flags, ...) va_list args; va_start(args, flags); - mode = va_arg(args, mode_t); + mode = va_arg(args, int); va_end(args); } From patchwork Mon Jun 12 20:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp133685vqr; Mon, 12 Jun 2023 14:08:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OCu/a1PiwBzeDKgf2AkriO+u2ey1uE3eF+f7ynD7U36+e6r7yECQsPea379g2XZ7P245P X-Received: by 2002:a17:907:6d24:b0:97d:cda7:f09c with SMTP id sa36-20020a1709076d2400b0097dcda7f09cmr8105904ejc.16.1686604122731; Mon, 12 Jun 2023 14:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604122; cv=none; d=google.com; s=arc-20160816; b=GSfLQblzOR9XS1dC8b2ibd2BQStYnu5Kl4xtGf/TrpBJB5U8uAaBu5Wb+XaG31REea B5MqL0DWBCnKryOBXEaHOdLZbs3lNGoogqZMO5CCx49BoCV3LNZnIdw7WzGOg7SEtuPi nF8eS4R1WYGrudRR+NGFPTOQOvCLVEu1faFfDYBRHoXotrSQ0QzcOQLRjflbMKPe5vlT G+a7p5wf2WCIeAcZTEv8+cjLG4551dmcPAZMVeVixwDYLvjDL20PIJYSGKNfTIau9174 1hQf9WIMTyNyDO05RJkhGFVULRGOsWXRpmWAEviLIRQhDGYtIR9HoXjJno6Q+tjwP0XM eJpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q9c0UGg3iulP1nr6tye+BN234KNOWUsiEWRHe3rtCYw=; b=IxCi730EPrTDJ7vgIwb5DaDIInVmZzYx/UFjVgx2bXZ/q+LP6IdO+P1ZNLJJer96Gd 3rrOtsViG0/Isa6MdynByK0OdqB10Ydt5VmjLPOY3D4V1M7om3b/7cahwRBvAkY/6mI9 l/B6B9Xn9NFO5acrBSzRV1ciAYpPBTxMUq4/B4kOqSuWwgEGMg9c5HR1COMegRVSIvly 3IN0g3seFGBbngtBhYnCs676s1n9UQt6KZvXA8Wb9K1jMbakSXL/J6XMEGK5t/v78sth CrKSzH6iIOojT5MWYLTnVZX3c98fKjBH3TLVaN8WsDiLrPiMrGxmJY/R+ugimn/5DAzI mRpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mwdZ0t0b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb14-20020a170906b88e00b00977d6723bd5si5751619ejb.264.2023.06.12.14.08.17; Mon, 12 Jun 2023 14:08:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mwdZ0t0b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238367AbjFLUvE (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237309AbjFLUs1 (ORCPT ); Mon, 12 Jun 2023 16:48:27 -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 489C61BC0 for ; Mon, 12 Jun 2023 13:46:54 -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 E30A162F25 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69403C433A7; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=3mb1rxDwK9cr6fcOzlDmnJ3xR72KXLUFJMoKYnLILJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwdZ0t0b39BPc5o50RFl54UQdD61/ytGpKB+FK1kL111Fn8m/JfAgyQvZFZxEZZQZ 7PtDNIZCqwNg5wkwkAvf1NXqBJkJuKfPw2IbFWVhkMM4yVVJrnYtgn3CrB/ZEjnx7e D4d8Uu6mnPLL8X481+fOe15uaQRiW6yfqxp1/oBPaKwLZk/CQGZWQnJ2TukfqY4LAq ZCL+j4XVrpGr9YWJ2hq4ja+GN/prKLRtX9K9iTIusOL5uhR/aNwr3rcXx8g9SwW3jQ s/aXPLp4mBSGsxNYTS4Ntn0/p10seF2hv4Vy8t3kdADhSgjT97hC4OC1dyk9qWwPU7 1BeZNP2X518Qg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 24B09CE3A1C; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Willy Tarreau , =?utf-8?q?Thoma?= =?utf-8?q?s_Wei=C3=9Fschuh?= , "Paul E . McKenney" Subject: [PATCH v2 nolibc 49/53] selftests/nolibc: support two errnos with EXPECT_SYSER2() Date: Mon, 12 Jun 2023 13:45:10 -0700 Message-Id: <20230612204514.292087-49-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532604488247220?= X-GMAIL-MSGID: =?utf-8?q?1768532604488247220?= From: Zhangjin Wu Some functions may be implemented with different syscalls in different platforms, these syscalls may set different errnos for the same arguments, let's support such cases. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index ff3da9539809..7896bc3f609e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -300,18 +300,24 @@ static int expect_sysne(int expr, int llen, int val) } +#define EXPECT_SYSER2(cond, expr, expret, experr1, experr2) \ + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0) + #define EXPECT_SYSER(cond, expr, expret, experr) \ - do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr(expr, expret, experr, llen); } while (0) + EXPECT_SYSER2(cond, expr, expret, experr, 0) -static int expect_syserr(int expr, int expret, int experr, int llen) +static int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen) { int ret = 0; int _errno = errno; llen += printf(" = %d %s ", expr, errorname(_errno)); - if (expr != expret || _errno != experr) { + if (expr != expret || (_errno != experr1 && _errno != experr2)) { ret = 1; - llen += printf(" != (%d %s) ", expret, errorname(experr)); + if (experr2 == 0) + llen += printf(" != (%d %s) ", expret, errorname(experr1)); + else + llen += printf(" != (%d %s %s) ", expret, errorname(experr1), errorname(experr2)); llen += pad_spc(llen, 64, "[FAIL]\n"); } else { llen += pad_spc(llen, 64, " [OK]\n"); From patchwork Mon Jun 12 20:45:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp131353vqr; Mon, 12 Jun 2023 14:04:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YIScD0j6mEBjyzSqcgchUBL/8Q2z8BtZjj34OgvNqKH5YYOZ9ZLtDIukpGGQWZphIJjk4 X-Received: by 2002:a17:902:c40a:b0:1a9:b8c3:c2c2 with SMTP id k10-20020a170902c40a00b001a9b8c3c2c2mr9540256plk.37.1686603874131; Mon, 12 Jun 2023 14:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686603874; cv=none; d=google.com; s=arc-20160816; b=LLOHbYQ79CXSuq6aWfXFy4OTlB033qHeRVjLU75q0Dg1Pu+8FY2uF5qX6XR/cK68rt oqAvdolxkCpKD2ycUxrLoY2VBv2zgboEJjFZg0M2E58Ed40/8esBw6k4+/slLLwA/e3p 1UpEQIWWWf60yGr9jWgPHA2jW7rb7WH1igrFDcuDR2lmoGG+bJIGFlVCGoaPCg1xasrd viSlLIe+dUkPjBNOmd3NtRXT9CwiJ99k/5RQmx/H62S9xKP4k6CdPrDh8YKsOltpcx9a WKdZHEjLZyDKpVFdvm3Ne2Pr6bV0zuVv7XCr+FHpJmcqO3/H98Hf2ezaI+wUm5daHgmr d+eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1PPwlAM5oOuMaGSOc58w0uGJ+8X3KFv8UNH7MpMIz6Q=; b=wQL9LdV0pevL0gQ4pvozNMDNl3CAcPqbc8U7xnX3ABV5XqJwFpfP8Sv/CUcR/KZ3qn oQ1OBBcatUFl2SGQsEC6IiNLxm2dwAe+wQ7vV3WUz3oSOKojc/zzUVG/HRzeFPA4RbVB RpTmYgpfJIDAdKZUezZ1ugH6Rs+EANNv2F5KEKRvPU086b77CRDOIDVKPHATxUFAvBdn HK1Dx+s3Abj/dAhYLHE2UVisjlIiT1xkVzAoeKg7l6TrZOwhghpG9h03tv1AHnT9SlbO 4nrvUrxlRj78O9QZJPlQxq7zRq08O60H72LwbQJGNWlhI9YfsHUGgrQTiSz6jcXtenr8 R13w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CZg9DHFh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a17090a868c00b00256822ea116si2640590pjn.164.2023.06.12.14.04.21; Mon, 12 Jun 2023 14:04:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CZg9DHFh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238487AbjFLUv1 (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235972AbjFLUtA (ORCPT ); Mon, 12 Jun 2023 16:49:00 -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 D80C71FEF for ; Mon, 12 Jun 2023 13:46:54 -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 E2FD462F24 for ; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6678BC433A4; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=UfVmyxrW4sUICr3wEMH37xShjLNOPo5lV2yjbch7arw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CZg9DHFhLfiw1sKYA+IDtBUBoVhx0kedHv2DFQ9QdHIUoyAi2TMbwhHp6plOrw0Uh 5pNqnM6cvthSZqj7hfWhaM4wF1iWKoVWTux8b8HKow2YqEqxn9hdAfjfQ8mhfCxuuf 7wEcMuA5Orc1YQVkp8J+jHWodTPbPOJykHuJ7Gur1JEibNbW+F1Y9tpoaJULbMgs1M q/Hm3+mhWPaW22J1BOzk79xRs5zc+OMcPYhTuOaTxab2qSKXQALKbHA3edS/a8zM9c 073lg/mS2ceyKAAIVhjf83i+xphkEM8RdizLXYWE2zkVdJXC3AtceGZU5G2DvspCO1 /5ugQXSPp94sw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 26FA1CE3A92; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , Willy Tarreau , =?utf-8?q?Thoma?= =?utf-8?q?s_Wei=C3=9Fschuh?= , "Paul E . McKenney" Subject: [PATCH v2 nolibc 50/53] selftests/nolibc: remove gettimeofday_bad1/2 completely Date: Mon, 12 Jun 2023 13:45:11 -0700 Message-Id: <20230612204514.292087-50-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532344070360425?= X-GMAIL-MSGID: =?utf-8?q?1768532344070360425?= From: Zhangjin Wu In the clock_gettime / clock_gettime64 syscalls based gettimeofday(), there is no way to let kernel space 'fixup' the invalid data pointer of 'struct timeval' and 'struct timezone' for us for we need to read timespec from kernel space and then convert to timeval in user-space ourselves and also we need to simply ignore and reset timezone in user-space. Without this removal, the invalid (void *)1 address will trigger a sigsegv (signum = 11) signal and stop the whole test. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 7896bc3f609e..b1f3ad25de35 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -593,10 +593,6 @@ int run_syscall(int min, int max) CASE_TEST(fork); EXPECT_SYSZR(1, test_fork()); break; CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; -#ifdef NOLIBC - CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break; - CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; -#endif CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; From patchwork Mon Jun 12 20:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106893 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp138263vqr; Mon, 12 Jun 2023 14:17:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Ex+Y0kaNnxn1WckoB/2ulA85RY/r0DRNJXK/Xmuk+4F9pSGzra7HwiG5WmVKn0L9HvyJs X-Received: by 2002:a17:907:7e9e:b0:96f:fc9d:6e9c with SMTP id qb30-20020a1709077e9e00b0096ffc9d6e9cmr11472973ejc.63.1686604673450; Mon, 12 Jun 2023 14:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604673; cv=none; d=google.com; s=arc-20160816; b=Wmqb4PjwI99pVkrAB4tBAQOc0cGUfbF7iRfwMd6zxMjQUDxJ/y+LHn4TwCh4OhQq3+ Cn4mtUA/RpEV0JAZsendFy6j912MmP2yd74hySEcAQZZyFWWmlHPprv9kOUDd3HQoniS K2chNsUHLmyt8vEp5IkZnHNmoCmEtEPgor060FMwfjyatlQOc+GN/5vJ+boW772CjAIy D4o7g1pL/K/4w9DAShK++ow0+rzUme/2Pho9y46IUBe+JCnreVwdTPo6CdX4/Ns7yDwS +35+IVqf2IHps7aAI4+O5KBnttIFdyIaQH98vsgMAjCX2+PmYK4erLzQ74yN29n8vln4 4c1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JdSdA9VdtpErqcO5IzEVF5cdaYkbapzS8hlPcoh/89o=; b=fbDDqoDnKqGXvSFHAuIf343DngHILPGkwdrGYvZTfr4OJSdavZQB/d9Qi9b9qUUi5m Fo5iUtJBc1z7jVpPyApEldee/1Anl1dSz0iI7HDoVFZcP+Bphikfr1jcroQflFQrh4Wa fycxnf8YijvJN0yP/mSBW9JfIGoanOWZUY9i6NQpAmPTPMpftYtuuV6nFPrIgDCO09iQ 989DItsvWcAm+sDuvqR9GjRWP2snk9HP6lvp+o/pPYBsFtIgMyn2wk6b1hnEY5fyOO3N +oP4QAopcZE1J920xvaQ7FzTDRxT8IfQZRe1PcvdWkirfh2Zjm9/C9xCjNP8BgcU2wWk qKAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TFlmnBI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170906718600b009750bc1cb30si5406782ejk.946.2023.06.12.14.17.28; Mon, 12 Jun 2023 14:17:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TFlmnBI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238538AbjFLUvh (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238225AbjFLUt0 (ORCPT ); Mon, 12 Jun 2023 16:49:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6189410FA for ; Mon, 12 Jun 2023 13:47:00 -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 05FEB62F2C for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E8F6C433A8; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=169K0FYgwINVjwhMoliOpWOqrdexyS9jQw6SkXAUMq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFlmnBI++Cbbi6mA9MNQOX7y2dKwK2tr7gq6Rr5+noFltmNnqvuZ9VEIKS5RwqSlg +2TXs4igXdebipyGxk9hwotbhqRPavFWP8o2hshow0oG8UBWClDNjWD5ZFTKyBZoug Fc/qdSUAfP/q4/+2mPWBx1zR+jD55cNDPXkJCJQ/8Px1KkIvFUlU72YdCmlIWMVUgq TBjhc9JN7Zv5sQTmBof1xp6SNUuaU91q1JFvW5pZW5xWQIYq+QgX0/Fz76S+TI71v3 QvBGgigXXUFt0/OJ9H/HZFx3iN6u6re2Vyt6S1zbcwuGg3bT2zYm8lIqyKMcRF3ClA hY1JZwX9rvldw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 292D4CE3A93; Mon, 12 Jun 2023 13:45:16 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Willy Tarreau , "Paul E . McKenney" Subject: [PATCH v2 nolibc 51/53] selftests/nolibc: add new gettimeofday test cases Date: Mon, 12 Jun 2023 13:45:12 -0700 Message-Id: <20230612204514.292087-51-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768533181631961739?= X-GMAIL-MSGID: =?utf-8?q?1768533181631961739?= From: Zhangjin Wu These 2 test cases are added to cover the normal using scenes of gettimeofday(). They have been used to trigger and fix up such issue with nolibc: nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' This issue happens while there is no "unsigned int" conversion in the coming new clock_gettime / clock_gettime64 syscall path of gettimeofday(): tv->tv_usec = ts.tv_nsec / 1000; Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/280867a8-7601-4a96-9b85-87668e1f1282@t-8ch.de/ Signed-off-by: Zhangjin Wu Reviewed-by: Thomas Weißschuh Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index b1f3ad25de35..486334981e60 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -539,6 +539,8 @@ static int test_stat_timestamps(void) */ int run_syscall(int min, int max) { + struct timeval tv; + struct timezone tz; struct stat stat_buf; int euid0; int proc; @@ -593,6 +595,8 @@ int run_syscall(int min, int max) CASE_TEST(fork); EXPECT_SYSZR(1, test_fork()); break; CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; + CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; From patchwork Mon Jun 12 20:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp134225vqr; Mon, 12 Jun 2023 14:09:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kvNyDAfhODdLeKZTqXNRcLFzGKdVpP4uJUtMrIlpSD+M0u/+OYBD4Kd27tDfWAStm5UmQ X-Received: by 2002:a17:906:fe45:b0:974:6de:8a5e with SMTP id wz5-20020a170906fe4500b0097406de8a5emr9608396ejb.40.1686604181467; Mon, 12 Jun 2023 14:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604181; cv=none; d=google.com; s=arc-20160816; b=Kx2LEEFTdzt95Z7VJk+FmnaS6xRbj2rlzo5rzCwxdodZJSxP73yh4uyphnLpnpqcXE Zmt2457k9zu2BLDASI8SBh6cOrkWQAWHSy81YF9Szz3uTNXoSyon7L7SGOnAf/WBuYzn Q0tN1xVBldZSWYmP+e8MziVA2fZ8kXzGFJffv8h7MFuPGKXfyA3NKOA1hrlOu2ZZzeaj km/9gh1P/ToxP46S5NGGwkazgh8yHRcXF972m+FFmHJqv0un3L/qAsU9Z2+mgVTIRm9m r0LgoZOqWznVzz7f+Q9zeSSnND4OwU+ilojsGCgFqMwr/66cwEevAuGaMdISGQBnall3 hkEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VuuEyDUxjG5axbLckc0GmsO3MVsKccJZbyk7IQckL7s=; b=K/Pkfs1FAALSTV5tkJc9vkbUdWoB2e52I0jxse/FjfyLfHMzMHxH9ND1Y9wQgjQaCF F+HvyXJy1sRfnh+rsVvd6YVqky2V6+HA352AUtF37xLxP/pMGImOrDpTXSOEkuqistwM n3PWuEYob7f0KBTVuPcuMOYgmOILKyfCW9CUXOJGScWuOYQS+TMsf3imLbD/arVVBB32 haj+0mmP7upds6rGSCQ9EE0nf6T4ohUeR/cXFUF7QCYJwn0W2iwTHlVHhNHdJL3lQdTj oTMEYYy8r8XadHOmSWygQvlqho+uJ5mKqlawbnip0dADL++Be3DobK/dEOVazYzpJ6dE I1AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ixa3VUIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ha13-20020a170906a88d00b009745124453csi5408180ejb.815.2023.06.12.14.09.16; Mon, 12 Jun 2023 14:09:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ixa3VUIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238610AbjFLUvp (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237707AbjFLUt1 (ORCPT ); Mon, 12 Jun 2023 16:49:27 -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 E91A81BDB for ; Mon, 12 Jun 2023 13:47:01 -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 0C0F462F29 for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 765A9C43335; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=Evs3XQM2ptmnQVe5RZ3I1FeVEzlmruXYwu3iSmSz9lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ixa3VUIP4/MWYPGOP9kEqnHyLPqFhnHm/9+xZofBjXuUTnfR1pB+oJ0gyij4vtoZg eMKZ9pmrD9GXtfwY8aUWURwdBrqwnM5axbQBV7jeGZdUtotgbCnSazSnwWQFIac0Zf ol7hDyD+eX6jpJphumP6D25tgCWMtJ9wXDs6y9DCjjCZ7IvvQE5HeIz1xpc0CxFa3O GZaiS2lmOrfxBFVpEW/GZV/3ADTlFYBh22LfQcZB9l42fjGxdLldprrDtHnxPHEzM6 uuCRleCOpFB4sCZagzDNcey7pxCnODSmcKkqjPDDLEJFPSXpaQaZ6quL1BdDAhD93Q ppNY/zSDYRzeg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2B562CE09E7; Mon, 12 Jun 2023 13:45:16 -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 v2 nolibc 52/53] selftests/nolibc: also count skipped and failed tests in output Date: Mon, 12 Jun 2023 13:45:13 -0700 Message-Id: <20230612204514.292087-52-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768532665721040424?= X-GMAIL-MSGID: =?utf-8?q?1768532665721040424?= From: Willy Tarreau Right now skipped and failed test counts are not reported, and a few times already we missed skipped ones that ought not to. Let's now count each category and continue to invite the user to check the report file when skipped+fail > 0. E.g: $ make run-user (...) CC nolibc-test 136 test(s) passed, 2 skipped, 0 failed. See all results in .../run.out Note that it's important to be careful about the trailing \r on the qemu output (thanks Zhangjin for noticing). Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 44088535682e..4a3a105e1fdf 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -130,7 +130,10 @@ libc-test: nolibc-test.c # qemu user-land test run-user: nolibc-test $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || : - $(Q)grep -w FAIL "$(CURDIR)/run.out" && echo "See all results in $(CURDIR)/run.out" || echo "$$(grep -c ^[0-9].*OK $(CURDIR)/run.out) test(s) passed." + $(Q)awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ + END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ + if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ + $(CURDIR)/run.out initramfs: nolibc-test $(QUIET_MKDIR)mkdir -p initramfs @@ -146,12 +149,18 @@ kernel: initramfs # run the tests after building the kernel run: kernel $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" - $(Q)grep -w FAIL "$(CURDIR)/run.out" && echo "See all results in $(CURDIR)/run.out" || echo "$$(grep -c ^[0-9].*OK $(CURDIR)/run.out) test(s) passed." + $(Q)awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ + END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ + if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ + $(CURDIR)/run.out # re-run the tests from an existing kernel rerun: $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" - $(Q)grep -w FAIL "$(CURDIR)/run.out" && echo "See all results in $(CURDIR)/run.out" || echo "$$(grep -c ^[0-9].*OK $(CURDIR)/run.out) test(s) passed." + $(Q)awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{f++} /\[SKIPPED\][\r]*$$/{s++} \ + END{ printf("%d test(s) passed, %d skipped, %d failed.", p, s, f); \ + if (s+f > 0) printf(" See all results in %s\n", ARGV[1]); else print; }' \ + $(CURDIR)/run.out clean: $(call QUIET_CLEAN, sysroot) From patchwork Mon Jun 12 20:45:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 106892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp137759vqr; Mon, 12 Jun 2023 14:16:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7syBHz2DHHIfeqgH+sHokrbTTepj5t+V9AKeQ/19s2UDjzribjTSOiuSYs/EnaZuHWnEHm X-Received: by 2002:a17:907:8a12:b0:978:928:3b99 with SMTP id sc18-20020a1709078a1200b0097809283b99mr11054303ejc.46.1686604612544; Mon, 12 Jun 2023 14:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604612; cv=none; d=google.com; s=arc-20160816; b=t1gkE+0bMQInr7Ro4qE6p1BzfwPGpDBl5JKk15Nz1953DBDVkky/soQjv6A9DyGUqI w03+NQkvgun8/h/wjM8Wh6dLA+xZqUFKxGvPGJBrRTqI3eF5j/oNEkQpezWfb6g44tXQ LJx2uTmUWagraFj6V5NPyEDf16h1cGmZBrnS4WO1WrTIJyBeanY/1PUqoVVjXuPRrofh qgAOM9YgbaHJ7q3a45Zi7bh+K4jsZOuAGx8F8dk9rd/09gwY6eNYJjo5TNB9gZ7wx+Ir UCFiJf9+G/OZpxh9z9Q/RgApaXDEr/ltrqN2S9OdwcINyzVz/C0Lh2AU4PtEZKkuMDFz rW9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VKUM3pr7w7Fxm3FvUAXN1wtBap20HsJzp5RLhQuQ4Nk=; b=N2F+xMw5b+wmQJHplnxsSxbyyVBXxtiVjKT7OYDez/bOGRZRZ98RsBWdyv7aKnAXYL h9E1IqFV3PfPTSrrz0oaxnv339dq5sRP4ClIcd0L4+P00Va6x5Sw9DhnOc5NeMkq/EPZ St7sf6imNdsz+8apCuP3cvEiRkK/9kS0TFOYyFoLBt6UmN6j1GPakZoR/lfwj4M43b7f TGHgfZy76MfuuRCi2i+GkjfI4GwyKXrdfBQRXHRnqNa1W6PnMXSlNSPj7E65rAb3AN5H n3j7hRaZRSyzFpetjJzTO9V5YjDlhwwP3TUsBcZgXRc+MXWrAy8GdZIUOtcO+hPfPC78 n6/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CWZ76t1U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170906398800b0094f48329ed1si5814869eje.647.2023.06.12.14.16.18; Mon, 12 Jun 2023 14:16:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CWZ76t1U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238594AbjFLUvm (ORCPT + 99 others); Mon, 12 Jun 2023 16:51:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237708AbjFLUt1 (ORCPT ); Mon, 12 Jun 2023 16:49:27 -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 8EEFA1BF1 for ; Mon, 12 Jun 2023 13:47:02 -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 0C9CE62F2E for ; Mon, 12 Jun 2023 20:45:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 757E5C433AC; Mon, 12 Jun 2023 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686602717; bh=fUMXY6pyixSpxlndYjLR4VYqCyPqno/RiVwO5z9bIu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CWZ76t1UE0jXqLcLWFJaQr3fM7S/jUG4p39IndUX7Nvpf5q3qh0YXTv8oWMJhLaPl 2zcynq08acBH3UHNqKPMFc4TqQJjWPOnRl17fAMTaUfpG8/drblQNso8l30gXHoISJ Gm+OzY2e98bRKztzorGGlwn2NQGk2z/xfZM8k1VY6VNIjG2slWonTKTP7fP+p+7pqW ugM0X62bm2hRYNgvX4WfZuBbl3P/E41U9yuiG8+5tCUjowmezPw7n3k5DaPkvDM+mL LuKyV8H+RxwvpwdUYeacTZzWCLrR3wGy2sPb2IEjD5PUqiFW21DkJKjg4nTPTgAwFV /9EiLZZgzkjsA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2D761CE3A95; Mon, 12 Jun 2023 13:45:16 -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 v2 nolibc 53/53] selftests/nolibc: make sure gcc always use little endian on MIPS Date: Mon, 12 Jun 2023 13:45:14 -0700 Message-Id: <20230612204514.292087-53-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> References: <8b757cc0-3719-4e63-a755-9710384137bc@paulmck-laptop> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768533117839375460?= X-GMAIL-MSGID: =?utf-8?q?1768533117839375460?= From: Willy Tarreau The test on MIPS stopped working after I upgraded some of my toolchains to use the ones from kernel.org because the mips toolchain defaults to big endian, even though it supports both endians. Let's just add an explicit -EL to make sure it always succeeds like the kernel does. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 4a3a105e1fdf..1b7b3c82f8ad 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -77,6 +77,7 @@ Q=@ endif CFLAGS_s390 = -m64 +CFLAGS_mips = -EL CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \