From patchwork Thu May 18 14:55: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: 95930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp555250vqo; Thu, 18 May 2023 07:59:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73wDMerkeOuo4sMP0VsYIEgBL+JdU6ZUEVnEW9rx0nGSSRlkg3T4DDJdlDsXXk4NdORyrQ X-Received: by 2002:a05:6a20:9f48:b0:f2:f05f:6e9e with SMTP id ml8-20020a056a209f4800b000f2f05f6e9emr2309880pzb.29.1684421993358; Thu, 18 May 2023 07:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421993; cv=none; d=google.com; s=arc-20160816; b=SXU1QTAbbdLCpdsni8FLWJlpwsQvqoTG4KLvLZpiyciXGqG1FzQeM9PLi6VRChOU+g +WvyytXAgAykXx1L1/m/23+c+8EcDhcUM4RZ6N9HTvWuCwcoKTT1Xz6ECxBTJXkhkgU1 Ttp/YgLqvQrIGFLhsjSD/5/EeCkKCoJnQhU7hZGfJxEzq3Y3klF6AkOVyD/sH6oMjid9 EJ+k1mczibPArMvrzYw2v+RrtUKVCymT9Fqo4gD5xnxO/laTBqMpFntPH7YJyQyVvJMj zv6Ko44cSwDbIxCdctVDOKk4hrElQl9CfnAIOC9eYsDwgcBqiktKXr7jXpHk51pqRnML nF0g== 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=0pW1viZ/GCaTrRs3BXojzdCN6FDJSw/DK0NMMjD63bWr2wk+532VfBBTTx6/tLnikB KTBi63c00/YpuDQunfhPAmSbJgpH13AJlOWAlbywuRL01QVZNr2FnzBkh88r0xzJCOD+ Gy8d8GcnRw3xJRnGnVMIeDjG3ksSy0XduaTHGUEM6Zr702rFO6qFJM7yC+OXKKzhQeos SU7ucJVDNL8KXpeWJKwQOGffbyPkRkVnpqKBnJDZeESpZgvIPeK26Jkaara8i5hmJERS jHDuMc2f+NPXQ0isvxXTGQzmkUfdnXMEvJTJwZyZjpeRxHioaoymaDYszS9J/3W292eX IjtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oIsBFX1N; 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 gp4-20020a17090adf0400b00233f3034302si4287454pjb.46.2023.05.18.07.59.40; Thu, 18 May 2023 07:59: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=oIsBFX1N; 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 S231584AbjEROzb (ORCPT + 99 others); Thu, 18 May 2023 10:55:31 -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 S231657AbjEROz0 (ORCPT ); Thu, 18 May 2023 10:55:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E91E122 for ; Thu, 18 May 2023 07:55: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 F130C60A52 for ; Thu, 18 May 2023 14:55:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E0D2C433EF; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=zEjOj9DdUomfDLsrKXBstSrS7dzFFqc89ym3/GOXT1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oIsBFX1Ny4utAyZupY3cQkO1912mk5kGP8McWNn0wWQ5MZfhMjlqqWp9cbSjb/b9X ZGddSdguSWXri82msb/vYmIN41QT+rUWkpzXSeh39cEtlzyqsvGFPtvNTkob6D1Ffh GksLBct27kof6Z4L3OuODpwv8qTQBZ7cw4F5HwRZWLuQhuVcUkLfP8T0UsUJDk/8MM lZ1ieYteZKYcysCtVUol/xdkyWAp3+jpDxq4VmjnqDMh47HkMllMZO8XuSP2GFcfzC aKzsp9k8XWx2JwODedpezVzeYhntrLUyjOhZCqhE30SfGCDGcUpruk+01gQqX+g2BT d5lboSAWpLuBQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 12F7ECE0CC3; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: tests: use volatile to force stack smashing Date: Thu, 18 May 2023 07:55:07 -0700 Message-Id: <20230518145521.3806117-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244475909962587?= X-GMAIL-MSGID: =?utf-8?q?1766244475909962587?= 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 Thu May 18 14:55: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: 95924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp554659vqo; Thu, 18 May 2023 07:58:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PZ2ZzAqHpOLzl0rIheR65wEYgod+tHdriCr8OXdEeUpUKx+beV2ZjiytAWKqaRh10Z4Sv X-Received: by 2002:a05:6a21:339a:b0:100:c4f1:72a0 with SMTP id yy26-20020a056a21339a00b00100c4f172a0mr41123pzb.3.1684421932099; Thu, 18 May 2023 07:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421932; cv=none; d=google.com; s=arc-20160816; b=S9YfkOUNlv4wdkA+LjBBgfv06fzbByIeUWQxONu9OD1U5XmPohkMVRsVDRurKjIMdR 83ZhRkLrXrGI/rtuRHiVEbAuW5LHPJCzPQIJG905JIG7LaZUbOZGVdnE4Q+bDnqVWdIg ZKVLTwzvfyYgH293ZgZHL2yH94BHsOdx0JTG1Taeu+hqcjd9OGV0v62LLDYvP27E4bCO 5yj7YnzRAOgJVzCOkF3cAOIlC24r5ZDkYWzHhaO0cmgUwxlVqH2eG0GtUcsNS/1SuQ9S 6+luFIiP1o+4e2UcoHg6IDpgOzPbbaQNMix+41GSVNgKwC72QzpOd+hnvUyWhjlViDM1 slkw== 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=IlAV6xeEKnq88lyAJdsV3A9YKBa6lrJXbKH7jCqPNU3X3CmN6rfQbrxzucHGgzNCOg cHAzB0jN0uTcU+aTHWTAVrtpzXAgCf1FKfuwpDm3eGzZ8Pv3pBjbbkBtP63GlRcRFNKl /U9/Vl79YJxo0XnDgewWBkxmyQVeGz1AgZibtky7ixp2nYHxDhCps+WO7KchNJNjF/1t HLpHtIrulHMfhbmM7wU8cYbtER59f/qFAW22TnYPVL+1rWXMuAFqaxVb8IdBOR9X9Ijs +JfsEyaUk2698DWfF6Umd80LacnijEXN3Ipaxqxja7jaIN4DNetbbTRFVI/zXof9kxIj 5g9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bNS+TekK; 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 e1-20020a636901000000b0053073da1102si1467961pgc.513.2023.05.18.07.58.38; Thu, 18 May 2023 07:58: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=bNS+TekK; 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 S231764AbjEROzd (ORCPT + 99 others); Thu, 18 May 2023 10:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbjEROz0 (ORCPT ); Thu, 18 May 2023 10:55: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 46F3E12E for ; Thu, 18 May 2023 07:55: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 0259764FD9 for ; Thu, 18 May 2023 14:55:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 633CFC4339B; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=Ks2BcB2HxSbBY7mPbJIjN33LPo2/4OOsJWgK+op14zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNS+TekKDdkvsHrj3RcZ9hgMDDRdzgoHGGrErRzo9MA2Zow+POuD6WovfiWP2Jgsp PQUbyODWIX8J72tFeD7CV80O0qTjvIPGu2Gzz8mQ9EUiWTt/DaM86rHWlcaEzhzC2G GnjfrAlJl6ebtRnFELp9cPQdUPCmI2H82de93QX4C38jLPyGuOgO7wFMbg3V+C2tOZ 37Vof3pSyINO9knyDddsfeZ41kWd6UbNJ0+xCY0CYme0lBQr4BPlMSJmLZWR1HVwX2 LeTPM5goZ+1HPI5+rLZXOS3ouLPB3F4j3N6DHbcAz7Bzt3WQ04rdPIhkRS+32U0REI YH5IRbqHugzmA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 159FBCE04B0; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: tests: fix build on non-c99 compliant compilers Date: Thu, 18 May 2023 07:55:08 -0700 Message-Id: <20230518145521.3806117-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244411912658188?= X-GMAIL-MSGID: =?utf-8?q?1766244411912658188?= 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 Thu May 18 14:55:09 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: 95945 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp568661vqo; Thu, 18 May 2023 08:14:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ABcbxrxGTv685fU+3XKGzNrzdaEvAxt4/WcYI/iQ9BSiWzingsKtUUX/qyZgE5rEgQydd X-Received: by 2002:a17:90a:b396:b0:250:551b:773c with SMTP id e22-20020a17090ab39600b00250551b773cmr3009367pjr.3.1684422895908; Thu, 18 May 2023 08:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422895; cv=none; d=google.com; s=arc-20160816; b=Q3E1goDJ7QsS4b0Q7MTj7wOFp2CddFPXEanBX//Y15WB6g7ZuMnQ9D4Wk/BrvyDDXn VGSVq3Ikpt/aAz5BRsm2pLf2wIVRzqYSC0ZIBLpG4kUlNni0JIbjyNyz1DCxaGo9xQ3d K4qf3PEtF4k9Fy5kGDED6t0/FlfmvKBPU8L9ryJZmaX8UbxijZxJB1WxLWsGi+GMzWNC 7B8z6pAQaJK7ymr3/e14/eY2uCx4VHV8fL6DJXpkRBjb6Irw+WwnKQgFGTF67q8nDK/u Av5G5epL5e5YCIknqnYxr12l9odfyplf1nEn6g4bW/QiuQoLeG0XYNr+8Ua+RSufTGvI Ro0w== 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=iDBwogmE/EBOq4EBDHE1yDO+domcc7wWnqtGUR7pu4umNUYhgt59iPJXrB4Q1P3vf0 PNiY9BH6ftgYGVQ0epytySqla1w4x77jzqdymPR4qacoZbun2/2CHl+/Wx8c8xtHe9ih fhPFkGBtcH/nMjDZlfdtZYScZIDMolVtVPukgySNBeyjJTE6aBTvCJiOChsJehAU0pdi SDfpfHpnuzGQMZ3hKcHn5pKuXYjgg+KpKkGhvSFGoyMKM0bJq9iH7+QcEsnROJZErj9f 5HSSYt4UBfaG0fouKVZPE8mFFL1rGUXTkBHABvESIldmmMayZct9uSkJRMF63Ki/dguq 5Aig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nIszTSbi; 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 o9-20020a17090ab88900b002500dd30da9si1907503pjr.6.2023.05.18.08.14.42; Thu, 18 May 2023 08:14:55 -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=nIszTSbi; 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 S230215AbjEROz2 (ORCPT + 99 others); Thu, 18 May 2023 10:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbjEROz0 (ORCPT ); Thu, 18 May 2023 10:55:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E74F119 for ; Thu, 18 May 2023 07:55: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 3585964FDB for ; Thu, 18 May 2023 14:55:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 831C3C433D2; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=cN3q9iCF/gJ/uPtCwHUQPd6CHzRDYrNdYVOXcOrOK64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIszTSbiME0wYc4lQI+izSXixJxHzChuLf1c44BLHb0D/luq4shcZvg3I3ene9INJ W7nZZsO8avz6UWnWwKnZ/MZIpC+GSkFTdu+8ix8oN1Ooubl9aPlO0k316F5C+Xtl56 f4WcwcAR2W0vcwTWrnd2IM7rCO6jn8Z2Mu8pPokfpNT/MHgv8hjwWuYLXHu0WHFa1K FIWjcWaGyfaxECLgmLQKnxLe0PclvkpCtPsmeSrWhsfn6fOzCGsN7BUUq0FqnjNcLh Ax6NSN+g5QQ5ytfwCRf1WwPZHwzWhJqop1vBBtA8d1THkhjadn6IfRNCsYUjrivOmi noHbkT1fB3jOg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 17F46CE0FED; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: fix build of the test case using glibc Date: Thu, 18 May 2023 07:55:09 -0700 Message-Id: <20230518145521.3806117-3-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766245422305346701?= X-GMAIL-MSGID: =?utf-8?q?1766245422305346701?= 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 Thu May 18 14:55: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: 95926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp554789vqo; Thu, 18 May 2023 07:59:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NMOW0paXhHXIYeIaQuBFD8jR9CGdCAQ+GWNdNJ31U9wMrthktXCL4IDrOjXwLHVAklrPY X-Received: by 2002:a05:6a20:7489:b0:102:3f67:dbe1 with SMTP id p9-20020a056a20748900b001023f67dbe1mr42873pzd.4.1684421943926; Thu, 18 May 2023 07:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421943; cv=none; d=google.com; s=arc-20160816; b=RnoKNK58jaUnWXI+i0Bi6gYekUYErspxeWVj2cY7cqQmis9swdthUX8PelUZ3lJ1kk FXWySdwqAYm8ECelriL3FbfbjWuDa0XzFh8gykEjYq5BWj5FzXAMwQ47g25gIR1OiwoP yIYkCuVnXm9qiCdFasxwZ3ESRLqHivqkHjnGw8bmQSLas9Fe14eQ6PRQ2So7GcxXcmba vqOWMfdenS3FZh/RLBhIYSiw+04smicZhg61607gB2Y9QbydNzjTKA8LKqSDU3+fvR/N kGvoF4MbgKdf4LB5q09GuMjWENvKNbCNUtQvbzWJ7Lfif6OFJ84tikIbiPOUcWWspTot 7YfQ== 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=l9K4Q2CdCdkquzopc/xBRyAixPORw7cHGDVcf/xIum9o810/CCZk7yG0spBSUQ+cEQ hTZ8cEiLr5e85Q/tf3fsix3mCSxbFep7hhdueob6Jx5P7c9SmqLiP1LSL8o5QkDsyy2f zPHy0CuxW3G2pM5CYujILyiRWJ0IdSPAov73gXi2Mx12aWFyLVe7YUGiEJhM2qZbbr63 U18jnU7YmBT/YnPNRjSp8HmDCnZlwg69d3AUrCPPhgZKesrVcp808RjF39J+FA8FbWp/ lMV90ZGnPjutNq/8M2gVrfSOLL4x7cyKojYD2FUXtz4oT28xJI3VIrHoK91fsnOwggvE 1fDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s7JNhFX4; 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 c14-20020a17090a674e00b002402275fc56si1871128pjm.118.2023.05.18.07.58.49; Thu, 18 May 2023 07:59:03 -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=s7JNhFX4; 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 S231772AbjEROzi (ORCPT + 99 others); Thu, 18 May 2023 10:55:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbjEROz1 (ORCPT ); Thu, 18 May 2023 10:55:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA41123 for ; Thu, 18 May 2023 07:55: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 36CB964FDE for ; Thu, 18 May 2023 14:55:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88079C4339C; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=C0Q9VdND465nWzuW7Df4EbGHS4KOUK1apvejVVAdFFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7JNhFX44miWB0EcDLBwiEJBuh176OfcNbIEqPcw7GGFbX2vSr6dmCpzj4fTwe7gI /ngHov1htsrhmtjvq4U/IOYRx/uYKRZ8FZu7D9fzkFKPde0jf9+qdlhWaHm7Gt7vFh eRZVQKqdO5He+HdmAXFWK9rtJ4f9IfhqnvMnYE085Sxbym92AZvli9rEkUGOh1EdX4 BZiAuqJeIGP/BQ2iT/6cobN7xkjwsmnnnrqf/zewCvLCO1Q7rFqeWr+64pakRxI16y dPMrnQfjdaShShfwvq0UvUoROup0PWje+EJtXiIUdUmuzsX5vL4D3Q296WCySBBXan VMtTm1tZcJH3A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1A688CE105A; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: add libc-test binary Date: Thu, 18 May 2023 07:55:10 -0700 Message-Id: <20230518145521.3806117-4-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244424216098508?= X-GMAIL-MSGID: =?utf-8?q?1766244424216098508?= 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 Thu May 18 14:55: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: 95925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp554746vqo; Thu, 18 May 2023 07:59:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/82JF2ylnm4gvy571qxQJ0vifOK07fq7piStt4SlsmL85ZJlGPUnnMEcgIS/JGbjJ3FN2 X-Received: by 2002:a05:6a00:190e:b0:643:558d:9ce2 with SMTP id y14-20020a056a00190e00b00643558d9ce2mr4880547pfi.21.1684421940132; Thu, 18 May 2023 07:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421940; cv=none; d=google.com; s=arc-20160816; b=pg2yDbgXoJuYVmyTHfvacEYbiB9ZiVItD3q1wK7cchvjd7U5Tqv/g7rj7V/DZhC49P 8eTue0oV3M67XZqQuKGJrFljnBNrq8fnRP3pO3O339mQyIbuoXeu8l5WBlr6c/JtsiW7 2C1nmb4Qzu9iubId0r44vPy9rOAdy9oihhFk66X3OhnQ0OrQqufgJH0iXgzQ2JFypsuk EXJSrOdYrjBlxqGAOCcqLh/ffLJ70JFWxgCWndbT8BrsbSFVVfHm7oMDCGiVqzCX/VdD hgEdC/Y+WkA0ejSAtJA5iNYjrJ5CFXVlow18cNpPuQQKlr7zafZ35YLSNrSqYDsoUFww PO5A== 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=zv8eGXjnZB4TxSksT483Dz6+eqCufp1q7tIqpt4+8i96mqWuhYujcWoF0eMPI4bzH5 agpMeQkHuzOzlfwGh9gHV+ndGqLka6vEqFqc04CQD9JEl5O2vZQkLNYZD9oL+mVuDT0+ e/KGe+AXpiZgoiWSg6MAF5+IiCfiMFUjGw/gy1jfEB1OXN2HXfDKWTHei1/3rtqffmrv QFxoqjX53L8Ku868fe5N8E/4Eo3asjo7fB4aPcM/LtWKuHL6TMB0KY1jhLS/oaNCIwK8 GFGBiUNwzJ53idVnBjwIRh4kil7aaGWiP9f0HX+ct2AOOPm7jcY1f2XPG5FjozW0yP2v WNgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yi97IyUO; 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 h125-20020a636c83000000b005285dfbf364si1554872pgc.262.2023.05.18.07.58.46; Thu, 18 May 2023 07:59:00 -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=Yi97IyUO; 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 S231783AbjEROzg (ORCPT + 99 others); Thu, 18 May 2023 10:55:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbjEROz1 (ORCPT ); Thu, 18 May 2023 10:55: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 3E8B511C for ; Thu, 18 May 2023 07:55: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 4677864FDD for ; Thu, 18 May 2023 14:55:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A389BC433A0; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=thHRx3gNkEts77+ULbTuRFI/XccuwcFtR++swDbxeA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yi97IyUOiY4TyB3fpkgKDrTS8C61Xq4cyxFiiHwQEzsgx2xPDBx9Nlazo90NGOEMf t7MFxBbAzfgDyDRh6uJSIlXUIqNpJhmYInJbpo4nzG2B8aORp1aI9NPoRh96enmIau 6O/Kmfi0scb92UQCI5mf2M+FFm98EUCPNBqf9ZLejykKbgZczaZzFhwPwDl5HKWn1m stwvM2hHDgnSPtoOQS9u4UBNf7E6inTAc6gkFDU45Ci+RzjUiq2qEnYsB2if0QqqBU qft+LAcMRujpjyfBR5PtP+XsRzZ8lBDPqbgW6vSQ7ZTigIoBfMPtK7YAMFvphWbFi3 2PZNMfh2x5pEA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1CB62CE107D; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: add wrapper for memfd_create Date: Thu, 18 May 2023 07:55:11 -0700 Message-Id: <20230518145521.3806117-5-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244420258959593?= X-GMAIL-MSGID: =?utf-8?q?1766244420258959593?= 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 Thu May 18 14:55: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: 95948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp569429vqo; Thu, 18 May 2023 08:15:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5aSTbEHgVsZVQaV6o7uk/H1GmYnlUWjY1CEP7TVLYa1C5JBEmxfftOTSLeImdVbMORGrSU X-Received: by 2002:a17:90b:46ca:b0:24e:5a0:d2c5 with SMTP id jx10-20020a17090b46ca00b0024e05a0d2c5mr2617619pjb.30.1684422950410; Thu, 18 May 2023 08:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422950; cv=none; d=google.com; s=arc-20160816; b=fuYrI6/jQFMe+By0z39c0dofGrvSncPEBANo/jT3NyNfE8RMTQYKiusYKDhPTDtI9M wHj5FMSGhQNU5sx0bOjFZX/f8zJvGwAFEo8n0kkUQS1UNM+n+zPbPk0hyJ2hP6LDgEg/ p9LCFMQ9h9u5RLAYPFpL40H+uFfLanZt1Vlff5ssN/iiQH8NGR1/rou1MWpr3aR6TrXt CVGuoGtY6q8LTEmaKA5sbuNwPJNRh2jr7ce5GCh0oSKa13yAedQZrBKwAUKysyfEk5Ob nfCWIi18BON34Kb7buu6kZvuyxRyj8SP7tfkFepsOJ8mnDr7CJk6lotk6bIyGhpOt42H 9aow== 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=jFKXTXXPtcp2JBRjLJ+wddnRW4/xqSK2LgyvD9AKP1JW+TrBI1vua+eF/KBhmycbuY /8Y5ZCq/AzZs3Wr72caK5epAKxwL7fVbteGCRyIFT7dsxCLgnZaUt852mKnyrk9Cyu28 k7n5O7epGNI38gtC0WmXSSrb+bsyaaS8n22tbsEj4ytiDQS5TU1YehtRtsSU8Cd/IeZ8 6SBW/qwUBNdEu/aAqpqUKVY0QYYKRztAaiVYFfThZxZEUnTZ6zvs54puHeX7bTedflj6 ImQpolb8tZjvr1pDzowGRAbfK1rkAvdijNqRFjKfCZFdKnxzS+WubpbJQ7TBEEpbDKR3 0weQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QU+1m9++; 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 w10-20020a63af0a000000b00534758009b3si1414382pge.573.2023.05.18.08.15.35; Thu, 18 May 2023 08:15:50 -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=QU+1m9++; 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 S231800AbjEROzr (ORCPT + 99 others); Thu, 18 May 2023 10:55:47 -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 S231225AbjEROz2 (ORCPT ); Thu, 18 May 2023 10:55: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 064F2135 for ; Thu, 18 May 2023 07:55: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 59C2E64FE8 for ; Thu, 18 May 2023 14:55:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6F87C433A4; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=fkkJpit5a3ZlIC5i/D5UeQi47Yy3csUMhtA5gdos6Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QU+1m9+++DTKwLknKSXgDJYhDjOSEeYSysSmhEB9J4WFitQ9rwKjV9y8NIHUPLGS3 RvneKXuXABUfG0Im2F/tAPTj85wlmwgCT++Kzlnq8Wcxm8hxW4bUILiSzUUGOARjZw Y3v6IZxS/HKB71Mg5D/f2FHz0ArzIUk3F2f3OzH0VjYbmpORBV5J2ZsneLVq/oan2z P9mEwOIr3diw0FSeD0nTLcASzZn8FZ0JD5pV2zjRlBbbwEefApmdJvwdn1YUzbnkCv XvGCTRqHeukfNGjJIrOsRj35ZgAxvqYx9IsvLlF0yNVUIDTS8H9Z6znM0k31py8KrS nazpcEZD5Lukg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1F405CE142E; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: implement fd-based FILE streams Date: Thu, 18 May 2023 07:55:12 -0700 Message-Id: <20230518145521.3806117-6-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766245479234540278?= X-GMAIL-MSGID: =?utf-8?q?1766245479234540278?= 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 Thu May 18 14:55:13 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: 95949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp570168vqo; Thu, 18 May 2023 08:16:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5WzRJgn6drEcplvD+EBS89TDWNTwweuFWNabmYxyOvV/UORF5McEcECzbWU6+73D76H+27 X-Received: by 2002:a17:902:ee42:b0:1ac:753a:7933 with SMTP id 2-20020a170902ee4200b001ac753a7933mr2830656plo.39.1684423000701; Thu, 18 May 2023 08:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684423000; cv=none; d=google.com; s=arc-20160816; b=ucZCkBgNFN5ksDCejNyhbx5FnLlxRu6P/uSiX6mac2xVuqXSqwHmNxvfv7tA2d9lKQ egB8PW3l9Wn+V4ceabsNDXZCBPG5VGyX/wA6MVjejmyzKzER87i9lgpU94stqi5JTVB0 V0z/mItJlKppsyF8hdoJGvChozVHL1mg0960iVnWHyjWMQ4AS+YVMrXY9+Lo10ok+1IU iUTXGXF66b93c8+grc6Xt0a/OyyQOZDYL4PwpgzvENNKCnjI4UgepqDufD8HRN9Hsb9r xFsJD84r7aYkqyJoZR7c6QDf3ugOcMf1rbej34g+qpBJfRQ6uNuBUj5drMWWuCZgMyCN KBFA== 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=0IKbfLWug91OfVDakYe9sfiYqfY55gtvTUBbrZOzxZ+5qWR/uggpGjLYjXSG47PEKe 5JGC4eei0FQ5Op/PyWZ4t8CsP8EgH7ad9CXgPUOVNuF9k7HXuOhFY8rLaTnaHavxITrw 7BuGo2FOqkXd+y/EtCBZRHYhXDMan2L3aOH61KnN+eVmdWLa/DTkR3fKXaP0KTK/WDSM 01HGoJAEJJIaU2Exyd9Rvs11/XtEBVC325lm5pW6e76xwM3ZVjc+7RypiE0CNea0h4Uz UAjxDD4x/SFAVrpWJBsIZu8oADqzASaagt02jOyOW5nvfXDljBbRpBuVhk+rf7MnWs8I +eLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=exJk6fUV; 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 h5-20020a170902680500b001aade54f986si1442856plk.249.2023.05.18.08.16.24; Thu, 18 May 2023 08:16: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=exJk6fUV; 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 S230211AbjEROzu (ORCPT + 99 others); Thu, 18 May 2023 10:55:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbjEROza (ORCPT ); Thu, 18 May 2023 10:55:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC91B12E for ; Thu, 18 May 2023 07:55: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 593BE64FE7 for ; Thu, 18 May 2023 14:55:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A0BC433A1; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=gpgpcEtunmdu9Bwe6EgvPNpLf5lDxIDNN1gL/ShrEz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=exJk6fUVzzcyLzaPPr1taRHEZh0enXf1X54640PYulffd2Un8/j2KA8Feo1md9LgI 1CuSNHS5L0wTj1uTNGuX87n0GgdB2jVRR7ETNCPskPSGWU9mbpgOJ9b0ytdnugd46U tZtjuDYRpME60oJpLRivbDIFJ2HG7TC/yBd2j9V5tgkrboOQBHHIq8CoNwqfh8kJIG XAVFNmTb+BL/8DZSqHamFBEkbEcGYfJjCvzV84YQ/OGRE1AvzrOB0XKK9189rI3WhY s9eO+V5bXAN6IReEILoVlzcxi2nay734ud7jeinMmh7s/tzSgMTENPUaXXefackw0M X/mx0OoI4Vp0w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 21BAECE1431; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: add testcases for vfprintf Date: Thu, 18 May 2023 07:55:13 -0700 Message-Id: <20230518145521.3806117-7-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766245532585438234?= X-GMAIL-MSGID: =?utf-8?q?1766245532585438234?= 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 Thu May 18 14:55: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: 95942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp564340vqo; Thu, 18 May 2023 08:09:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Gok4P/dBvg38CxAGObrnUbHq8eQc24UIsj1DxB1sOmwJ6L7YsSY5CFjHcWCrV0PJgvbIx X-Received: by 2002:a17:90a:14c6:b0:252:e7dd:4703 with SMTP id k64-20020a17090a14c600b00252e7dd4703mr2936336pja.43.1684422566952; Thu, 18 May 2023 08:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422566; cv=none; d=google.com; s=arc-20160816; b=p4gplFBoVJK0rRb/tQnHbUcH8nUdC0hCu6NWWpXqP4LaLLj8ZkB9R1tWUmYcwXpDH4 sSe++YmMkg+1HaA5WwksbdkngolHIrwt/Q6uu/5rp+CcUBKqrTtYeAkr92Zx4GDZmgn8 ZlRvg9wWwSajduUMW6tmRHR0TyACd+VHh4EL6vWgRuiaCd/qeq4b2JhAGev6NhSGdlvG dkAFyXfsVUJkZNA0wECbQ5WaFhY9+0mtq4d3y32uOl/r2LYuHxQV0ki9R6rmLUKYdQO3 8LTGViuQKd5Fdf3sDtlI68Dic/NF4uqJQQk02D9IG9jEoRns1eYV2OIcrrrfeRGmAHU4 aA/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=7r6HqrW7bsanRgARsJZC2aoSxCh4rFQXPL7ndT48X8I=; b=R4FzB2U17rd1ISIhOTl78iOgc6Epz0nB/aZVh5bjnwNOjlDvSFI/MkhPLouAc3GalS 7azJA/T6cBNgiFDJ3WB9tUj4XfgGR0tJw1PVhiJuaJWSdvECOZ6J6fqnzM5ZpTcaVcvL hWmpGE261NSIkM4bJ4wNbHMEhKJHe01F2yezjhIj3XmMj9RdRE6bawgEhIQTPg3oKu/V 0dR6BSjRErTiwJxmFYak7m0nkZgH8LssSey0Z/eKPzE5j0c655iShbxKzyTLa9rF0PuJ lRo0etcfFKc12VewyLLSpHuYV8Ob9zuS/OE90WMpPaddGRj2pYcbGpWl8M8wpSU5T6Gm IUgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ESEWGnAj; 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 x7-20020a17090a294700b00250331e6044si1842785pjf.25.2023.05.18.08.09.04; Thu, 18 May 2023 08:09:26 -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=ESEWGnAj; 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 S231795AbjEROzk (ORCPT + 99 others); Thu, 18 May 2023 10:55:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbjEROz2 (ORCPT ); Thu, 18 May 2023 10:55:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3E5C134 for ; Thu, 18 May 2023 07:55: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 58C0664FE5 for ; Thu, 18 May 2023 14:55:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D283EC433A7; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=7fx9cBawBfJl+YSrog0I3p8/dTOjG7DqC+tH8F5Flnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ESEWGnAjo/HVn4GfEj1I8nQlHRIlDNN8ReIhSbL/olfubCAM841eighiyg7x4JbIk GY+ANPWfE/M3UIEcwNIbbrhorl+53hUwLiGiyZewKWWVOfxJe5MRxQcdIVO3RkwOcS BVM5ufgarQGaoUChgvIH7JWjqwKpxCAbP+avSC0yvhZolXaFKjjJwean4/gdaEe8ja Zt+/tQGmRKf+8ThrePKtAOwZa7rAQo+k2dcwPRX7IpspEUmkno61pQwn+hcORB9x3N sg0W901GN1ycSkDkC19/bTsB/NnSof95wXltR5PH+nbM9pt+WMYC7VjEYMrMKGtPmo +1ivgNlH8bHag== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2435DCE176A; Thu, 18 May 2023 07:55:23 -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 , "Paul E . McKenney" Subject: [PATCH v2 nolibc 08/15] tools/nolibc: Fix build of stdio.h due to header ordering Date: Thu, 18 May 2023 07:55:14 -0700 Message-Id: <20230518145521.3806117-8-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766245077552128353?= X-GMAIL-MSGID: =?utf-8?q?1766245077552128353?= 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: 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 Thu May 18 14:55:15 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: 95927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp554860vqo; Thu, 18 May 2023 07:59:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NQttp7JHYJxOBvk86d5dheg03BNy4+2FvHCSwDtnRK4aetupuQbxZsADuYVnnznvfD5RF X-Received: by 2002:a17:902:ab49:b0:1ad:d1ab:9cc9 with SMTP id ij9-20020a170902ab4900b001add1ab9cc9mr2854413plb.12.1684421950668; Thu, 18 May 2023 07:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421950; cv=none; d=google.com; s=arc-20160816; b=cchCsZbupnnm9DjYEVn3+jW6b3oSsR2eF1lamLfquXbUW500u+fektDqUQ5zURJcm1 3ZPMRU/PjRoOSM3e7nD94ByR2vebQa8qH9Ks2nq/a/H2jr8f2yUWJQD9iE6+oR3JMzC9 SdJWBxLRoCKU46eMWlVRTyig/ROsqD+/scZ2QurkYKCkTK6br9asKsT9TJh5OfaqnDtw oxblJvnjwidfvOG383C8CmGimi+Nex+PS1Rrh8fGdlkG+6iVjhU4PsHQXaR7Ui8HjqKQ BuGflFQIZByxCMTbwwWWTdqsn38CYWH0bSJ876NjoLmG74JhWLyzG4lZVkHOnDI39f4w ktGA== 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=e8on+507Ri3KFx0Vdadklcqun6kT75wvhrLRBtnVJH1ldBbMLpyY8JjWF0W6+MkNqf 6eU2cqT8lC2jwpJQVmvzI5iDHHBmnzBtrkaN7NpYayWY3wStIQ30UT22YKCDhYKtwSbs 4ktE4fIhF058HNZs6MIJoUWsPZGU2+kw3suZzICkCsIbFVfORKVa4iYV+QNTOp99dQCq jqzJTXni5oqUzyq0cXZ5CBaziJJ3K+hUfNC0J1S0vBRgFfLJFsOFFNfiYO5B9ACmAyIP P4cRsrqjYaBnwPi71Zg+a/vuvC8MVh0j3LbXpsbw9Kp8bX7tNP5z1dmbcHY8exV1Wby6 sf9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wd9pVuNp; 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 c7-20020a170902d48700b001aafe3f40a7si1544710plg.579.2023.05.18.07.58.57; Thu, 18 May 2023 07:59:10 -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=Wd9pVuNp; 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 S231745AbjEROzn (ORCPT + 99 others); Thu, 18 May 2023 10:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbjEROz2 (ORCPT ); Thu, 18 May 2023 10:55:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0543F12C for ; Thu, 18 May 2023 07:55: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 6060964FEA for ; Thu, 18 May 2023 14:55:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D78B9C433A8; Thu, 18 May 2023 14:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421723; bh=gd5sfN1vi5rnkiQ19By4Dp4+vXMweeEIcbPWx+T5fUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wd9pVuNpeORTZeUWFooKRKOhtKiYy2P4Iy15dgHOCmPUcEBWxt7y65eWb0DpU0asI Cb7lv16vcydmnX2oabt3denMAA6RLDEjvx+3eeSFPbxXfG15DVxwkUdGMY+rJU6vvL cIvJAk//TVwEZURnsbwhZxGFqRmaHkVVFrNuuVsxqqIlsl5G6f2d4JdBEPkxlbHowj 6rOUp2M3CwlNIiLr/yXyaW50PSmd77qULBnDnNPhnBeag3/eZKsNcoMlxeg+AbM5NH 5TQ22DG+2vQ8ulnrVcV+7LVvNur62iVg+J3zbzk068bAgbqXd0KroTQxUwrjLbRemq Cjkg/4SBwENlg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 268F4CE18F6; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: use standard __asm__ statements Date: Thu, 18 May 2023 07:55:15 -0700 Message-Id: <20230518145521.3806117-9-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244431622997141?= X-GMAIL-MSGID: =?utf-8?q?1766244431622997141?= 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 Thu May 18 14:55:16 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: 95934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp560675vqo; Thu, 18 May 2023 08:05:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7rokEH7FWOPtjgPPIqwlt5Kw0uOvQGzZhnsyymyW0N+gtFlPv+niZAUjfGZveTS3RylfQQ X-Received: by 2002:a05:6a20:187:b0:101:3fe5:8785 with SMTP id 7-20020a056a20018700b001013fe58785mr2126388pzy.44.1684422325719; Thu, 18 May 2023 08:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422325; cv=none; d=google.com; s=arc-20160816; b=00QZi/AAhJq1tRBMF1LXLuaZGJWPdXHdbMCwZOvedmEEASZ8q5ZSPlj35FRkiX0FO8 rtUUyivIA/g+WlWZHohlA7s+ObKo3TjlUlekex8fl8HOoQPqHu8WHQ45tEhH/AB6zXsr 3UTpCQBPyu2gTt1kCLS9C5OvLDGxlyzC1SmVgIqWMtPv6j13nk8Ha6IN4EHs9zwcXd8v TSeLZbRIeNsliugFkd1xE/LDZXrms4H2SI6qagK9rldFPOoLIZbeelGbtyu1a3RZDljp p6g+EVUhnvBMdZez5kaCedyGTg++K8zXgIf7L7awldJj3ZrWk6hKlAlgyLxqaXMVaSW+ AgXQ== 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=D0FBZ6zzpzWNw7YG6KVJgjLzxERHmiWvfu6i4lKfY9ZdrpmJgnhzQEZATqvbL88JUG JU+wIS5WY8k358yljaUoa+qFDY62k+sr6zJZid2FZnnw2KLrpQn/qOLG3zXXyuWyKsB4 HUVFCQB78Tk7+d/NCng1fPvwcnRcB3jAzkYZmppQFvOdYBEP/fvsSWBGDy7EALn5oIDF 6VK0SsnfXNyhLdvsdtiXo8VTCf37ilEMq4faSiCsOi80qqZsHn/W5dvMkVIdFtzPKomZ zVWbb3mhKjx6pg88G3YZ3kEc0k/vd7y9WAxVP1HsWdA6BM/wKhLCiqGQSyfaV76IxMZ4 LRBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LQs0Ki8W; 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 t134-20020a63788c000000b005304ceae2e9si1578038pgc.78.2023.05.18.08.05.05; Thu, 18 May 2023 08:05: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=LQs0Ki8W; 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 S231871AbjERO4I (ORCPT + 99 others); Thu, 18 May 2023 10:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231787AbjEROzi (ORCPT ); Thu, 18 May 2023 10:55:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37DF11C for ; Thu, 18 May 2023 07:55: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 0C7FC64FED for ; Thu, 18 May 2023 14:55:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E965AC433D2; Thu, 18 May 2023 14:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421728; bh=rJ8Zak39w7CtOYLtgafcmk/YeBO+i/iIqJ6y3UtNwdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQs0Ki8WszLf3yHy4ktR898ITP5BaljyV9uKw+xdZer8uJPq9lyoJ1j57V5DZfLP7 wIsSRJ/KqTocra7feyZTq/H8hA4CboUe2DaEbbkgVKvZVbH4OD2IBX6H8mdueCe4pH /9G7OXi8BHiOWWyjMniPKsu+XEdzI54urT50yEqNJ/XU0ywcP74D1QmaUI+3B+vizO WjMK9ZjAZGfR8KtUFbUO9HGjrwBRWGFkezP3Nk6DLxzo+1mIjXZWdH7ZS90EYdBcfp OOagrVCYS1d2qsZGfDTHb2jd1OfRwe878Vu5d030Ff/GR2YvZaYVJbFlltQUebz8nr y/x/5mKeU3qcw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 292CBCE190B; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: use __inline__ syntax Date: Thu, 18 May 2023 07:55:16 -0700 Message-Id: <20230518145521.3806117-10-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244824502754709?= X-GMAIL-MSGID: =?utf-8?q?1766244824502754709?= 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 Thu May 18 14:55:17 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: 95929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp555123vqo; Thu, 18 May 2023 07:59:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7A31nPQPKtnhzztupwK47zLAJdSQieR4lUypk9vym8Z+qV50TYvoiihbmIKcRRCUD6N9Ps X-Received: by 2002:a17:903:2786:b0:1ae:4ba0:af86 with SMTP id jw6-20020a170903278600b001ae4ba0af86mr2249053plb.64.1684421977834; Thu, 18 May 2023 07:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421977; cv=none; d=google.com; s=arc-20160816; b=B+zcORorLYD/ehdmPrz1GIGbk4a4qGW+a0AjQ9HSx6QRovsBsgziY8Y9HbE7kCj/qA oG7kxetw+BIUk9H00MBwgfmin3EYuV5fu/sMGYqio1QJD/21aF1/44d3J0RF6ONNm+DR Nu8zaT7qa2vNtq+7Q8IvOrZGMSScpzXYYyVSe0uowrPmI5w1zt6jkkKnhbseeUBHxfPd gf7Tj9hl7eyAXvZf/pvr/LXTRL2PaOWXHJ0KhlB1V+p5l6hdrI2pautw7sE7BrqKqiQy skJsc6zGCBTgpVBuu/YjRZFNF21E99Gf8ORzpmnm/w/MctskOvSu7QJltHi99lGxp1VR iAfw== 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=WjXOCcCXopXzJuzp8vmzP2PHKjhpoVaAIOBJs9ys/2FSiBHM8ff4QF7fPExvFABMkj 3IxsPMf7OfubG27KEI5V4LO4L/0LzfAOxaWThUZp8hzQ3NZsXvWMJsxieJUpMYzs/zCW ELGPPkOWGI+ImR+EnrGk5zDwJAsp9FI1rQprDnd62vkT8UDU7UpoSbwBFwuUh5ogsi6B aJXk3sqfyUc1hBiYfckuHhoHtBlg2HF4B/KGKcbTtrknrMKVKD1GVd7ou86EUimVWfPz lBOJFl1+4CPSl5kddwQTL+CbjWYqws/St2N6gSojQ+cY52uFshvDlMgPk63Sfc1Qq8jt mZxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ScZ40A5p; 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 k18-20020a170902c41200b001ae4026d82bsi1650411plk.12.2023.05.18.07.59.25; Thu, 18 May 2023 07:59:37 -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=ScZ40A5p; 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 S231918AbjERO4L (ORCPT + 99 others); Thu, 18 May 2023 10:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjEROzu (ORCPT ); Thu, 18 May 2023 10:55: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 3E1A41B6 for ; Thu, 18 May 2023 07:55: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 759DC64FE5 for ; Thu, 18 May 2023 14:55:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBB40C433EF; Thu, 18 May 2023 14:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421728; bh=EWN17qREk8YC1MUcrW1F8VdO7n3Z0vTPmJeNoge1tUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ScZ40A5phZasEfCLED6HhhkALpH9L+xuVprOBPzn9Si1l/WHV68LMnUeesVPV0nqr cSJEPlPHATJ26cRs93xcE+Gp8eLTGeyqvd93aX9d0oiqz5rBAWa8sdwOjVCmQcEP6X +1Z7HRKRDinrHbZowmtomCDpETrNCBoQx5L37Jb57llZiThSTz9SWk/cJZ/sIgoR/C RLKL11ri69PUOvVbpywNCH6jrp2nT0TWS718VwR6pBvD1uoW7jxxsackhnotT17XRK NHPecVSKMWH7vSHiYbVd6lvna8NNp2Jl3F3ZPl/cQaTkYCCQnKBXSv78M818PZhD2X jJ8iaUmmjSunA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2BF9BCE198C; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: use C89 comment syntax Date: Thu, 18 May 2023 07:55:17 -0700 Message-Id: <20230518145521.3806117-11-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244459838531662?= X-GMAIL-MSGID: =?utf-8?q?1766244459838531662?= 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 Thu May 18 14:55:18 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: 95943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp566409vqo; Thu, 18 May 2023 08:12:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TvvFBD3UV7TLOMTnFaEKVC4YRWR1RoQmaK+3W5w+lMeqCNgI9yDrz97EjfU4eYHdBhC1r X-Received: by 2002:a05:6a21:2d86:b0:101:530a:1d12 with SMTP id ty6-20020a056a212d8600b00101530a1d12mr2584180pzb.44.1684422725686; Thu, 18 May 2023 08:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422725; cv=none; d=google.com; s=arc-20160816; b=mdQzIF5V3eL/eW9QsggmRniSoe0xu2d+HY8XTndKnKCYORafpklCCB+92vOlemC11+ OwIQn5UzB7VYZuitZnvIIaGsJntd2mSDU16vw58QPtlxL5bHJvXftERjUIyas3q1bpu0 y+nu37UXzkUWp5faQmK32KlNR+0Up61OZXn3ZdYSPLut9eNttoffdYnghqk5LNF7KaGB NYwoOADf688AF8ApyS0sM386q6G1CawOL81pBgzUogz0ujHC5EzjxrNsx6YkodaBYvpk WMpEv9z/EUvdjBW5uXS/v5bn3jQHFxvEXZEgCNaCWKmfc1VWTkTwaKLac9LFSPFubaP0 VY9g== 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=OElKzp0IzOKpkf/ict+9bhUOxBvep7TSfvh6UOvI8y5iGzmsHyO2netTX4hTi7SRLd SfX5IKhJN2JQufJR1ZblcCWRH3qlSQLqwv8EdTvs9+R9m5oPsD4xHoYyY9KPgWWUfMiH Oi1IF7RnB+0k7R+eYAxp5SfsjRgjCqOFlY+BJRB2orD8PQ4glL5eAjguKux6yV2715oa hdAxcBSLxQAiUOxKea4mveAEzwIpxqtqYQ2hJEs8/5q1VaV19p8ZKFC2rCwQ54LtKWYq 3ekM2B+Rfv5aynMkv5NPRuao9ZUHjNR9BzbbUNETpkPvG29r3DynzhvLGc/mNF1H2wHh ZeNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZ7KSjqr; 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 x7-20020a17090a294700b00250331e6044si1842785pjf.25.2023.05.18.08.11.44; Thu, 18 May 2023 08:12:05 -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=rZ7KSjqr; 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 S231814AbjEROzw (ORCPT + 99 others); Thu, 18 May 2023 10:55:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjEROze (ORCPT ); Thu, 18 May 2023 10:55:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94627199 for ; Thu, 18 May 2023 07:55: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 7558964FD9 for ; Thu, 18 May 2023 14:55:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC03DC4339B; Thu, 18 May 2023 14:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421728; bh=qXNtbl8qeb3lbiMWDYS0tmfhxByKNfAQg29LsRRZRZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rZ7KSjqr5Bc+48uYlHrhz9+TtkRPjXcPFrQEJtbfXmEtfdj7F635EDcGOMHa8bxPC uzZ0rbo836zrvvKRfuJfH+rPyBJ4GC9juS9kdWDAHRpbDPzC8Nb13fav05gcbaexnh 5hAPhWVzhPCbAFB3Aq+qhHzUu86UxYnz4+hU4A8ym8W32huzypG8OMNhheKrnjTeYo bNW8+iUwpjmEsKhHIdMZykmNQMOE4ufpyHZzWYJUp62t5jjpldJE9xrOaOkVwvteqS TsvuyeVTXws61M0zLAbZCADNCuXQnrlPX89WSGrGPMOgtcotN2HsirU/A1rLR4hB5e 6oZrOUXwl7M5w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2E6D4CE198D; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: validate C89 compatibility Date: Thu, 18 May 2023 07:55:18 -0700 Message-Id: <20230518145521.3806117-12-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766245244394029830?= X-GMAIL-MSGID: =?utf-8?q?1766245244394029830?= 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 Thu May 18 14:55:19 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: 95931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp559853vqo; Thu, 18 May 2023 08:04:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4txVcV5DKY43aJ/JfV3qZy1jegrznZngWNxvase441bf69Pt28A5zMIdVlBKki7MvTk70+ X-Received: by 2002:a05:6a20:a10c:b0:104:98ea:48d5 with SMTP id q12-20020a056a20a10c00b0010498ea48d5mr2974520pzk.36.1684422271243; Thu, 18 May 2023 08:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422271; cv=none; d=google.com; s=arc-20160816; b=o6MmAbwwTh/EFlfVmZDZ+QbVyy2ude6isN7h432EUGy/ep5UzKhviXMExlNZTUirKz +MZ6d4eO24yjIOWosRaKF/KHoKg9Nbz2XEqdPRpJsp0yyTSHwshPGvFYU+md/KY4L8l4 kwtGLR1EaCm84msXO940Y++F0a3lV8/IXE9ra0zMfciQmO/6MbooWqVFsGDQWmiQljif V7y8xIY2xESZzfvImAbWTkJ3bXi9VrmmNjBq0Cf/6zIlETm1wmfXiJ2NzaaS3h4P1iP4 G/lAchAyXkMmRN1EfluB//0kO48oGdXIGnRkDsFrsVr1NmTDdnjZHfS4GAAvmadVvuo0 r/jw== 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=OjovskPf22IQ19mk6yn+ioM5VE2Ex1lI70KTi1wRlNMLztOmGPd3+q5cyiHJ9hIsYW z7Grsc45U2I+vzNiuEw/wPmW5GlqVmTepSzb3NRL4JcyoUM2CZQ4G3mgkZasryyhxrch g1dSEtqR3oEI6WR1dSIBq8O58r4rznLLcw8iOUs8RUmY6WfSSEWkIBmEGGi1Ub3zazxz O4FHYmRQuOxquZi1QmtUDcfct6IiHp7YOwCmI+jnT8RlVWnVP4OhS0cUj9rIDx7ALsiv EyZ+tr+cz2ZazH7fsUkVIkOKJ9GjF6FBHbW1Ozc+OVkkD71FBos+ybPPMaZn1Rh144tf Pp4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L7Pi7tFT; 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 i4-20020a63e444000000b005340955881asi1546612pgk.700.2023.05.18.08.04.10; Thu, 18 May 2023 08:04: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=L7Pi7tFT; 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 S231808AbjERO4E (ORCPT + 99 others); Thu, 18 May 2023 10:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231782AbjEROzf (ORCPT ); Thu, 18 May 2023 10:55:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46B3C1B8 for ; Thu, 18 May 2023 07:55: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 866AC64FEC for ; Thu, 18 May 2023 14:55:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6BCFC433A0; Thu, 18 May 2023 14:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421728; bh=oC2jzfNDP3qXofDBVXlAqaNEq75nX/bGi7jR4v97zaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L7Pi7tFTWuHRkeYMhXRudDqd7gY+kSB1xD3N/MMZQimDb0N2rzg5mIP2ql8OEw5mI /p/KeubrVNcAIk8HX9CnizMDUF6ChJ1eQ/6atxkLiltAFwlItKUy0jtw95EUk1QCTs 0RRVOiXNDxE3VaAvPQueOwiK/A1mAzaspIFoBBEzb6YG1A2SAxF02f8J6liTDUplmj mDUvlEDoNMr61FlD/xnyA2PdRXGGS18XRF6dh0L6gg9reeErMVFUEe91vbBL3O5X8Z i9anV7/rRBnR5bXE0KawkUbsERJfESb2fTy3p18VcYoaGOip7KWo8Sdr3+32dsYh3Y Gr7Ob5NemnCuA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 30B94CE1BF0; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: s390: provide custom implementation for sys_fork Date: Thu, 18 May 2023 07:55:19 -0700 Message-Id: <20230518145521.3806117-13-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244767616463374?= X-GMAIL-MSGID: =?utf-8?q?1766244767616463374?= 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 Thu May 18 14:55:20 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: 95928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp555032vqo; Thu, 18 May 2023 07:59:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5aA8QQiztG7QuJIGWsKk3a12ZyGHZ36DnD+0Rh9vF8gVqppITM4XOhIWRIdGhpGwfhaqdv X-Received: by 2002:a05:6a20:258d:b0:109:1310:958b with SMTP id k13-20020a056a20258d00b001091310958bmr2957549pzd.37.1684421969610; Thu, 18 May 2023 07:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684421969; cv=none; d=google.com; s=arc-20160816; b=ysV+qJ734wzvTxbn/xMPq4AREFtoyiFH5BWyotBKTHgsi7UzUvFJPB0MR6xbkH0zmt F0ZWz47sT2yk9uTRXbslyEVOJ8P6zJVk3Ev41g59C345CZyPaUx8qFYqsazq/ZmM/p+f vbqdFnPDm6AhOE0gLRoD288GJlGoK3/bd1JP+ZDTKldo7mYMtE6vLLKqo2suhjFFi/hj 2SYrVMwhT5H8U3Rw5P/dUzZhwL5F7VkwbocuBpNS9jSCuDJou5xz1uxUYm6dJVkQMw0G fxauEqaieuc7uftrypNLCtAyaBOfI565+j2X4EOcE4i90qkBGg0EvYHTDZs4sVrmCWLm CUIQ== 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=lmiBsxu6IpQ5DP4MOLZCDqS97BP0rOQxG9BiDkTXF3nK5tM6mf1l0nYJhAfnuGS9bS U3ayLuEqN8msZUsPrW2pbW6g0xe+t6ZqH5bovF3SNPA1d362O74riOt6UFBQ8stvSX6I 4qyC82Agh1oF/3UmDMi7QPVC9utUKpxlqOasnQjZ4kv7215NOjP4CL7jgBbqC75wsCJn eNq+/2Fo6nGK1KVbYoy0Km/tew2ZwuQ2F+Z/Ku6iDnzWugnRtD7orkIP60AFeMofSQfq AHf7KHNS1NTRZ/zb6m8HmM7mZewd1lDZoMclQUokRtX1sT7ILrVEzP9IkqCz/PxdlpLE e8Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ccgs9cWE; 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 z12-20020a63b90c000000b005303a36c1bbsi1525038pge.420.2023.05.18.07.59.16; Thu, 18 May 2023 07:59:29 -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=Ccgs9cWE; 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 S231820AbjEROz6 (ORCPT + 99 others); Thu, 18 May 2023 10:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231658AbjEROzf (ORCPT ); Thu, 18 May 2023 10:55: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 97F6519C for ; Thu, 18 May 2023 07:55: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 7888864FE8 for ; Thu, 18 May 2023 14:55:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD3E5C4339C; Thu, 18 May 2023 14:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421728; bh=UfezgJW4qV6A3Fx5ZwnvEgO/thFwlCGX/qvaitn6eGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ccgs9cWEvcgjUxlizOqSW2qLhQvu4CQM3HFH74ASRei1MxE7NieaGI2MLXNKikNIS b7ygBM1wjd8gEpNNZI+iPGiglqRVAjhEnOCF3v/FTLo5RPLwYlb8lpBunbnkWLwDOR xy3LEj7n7Sa2yDPphgbPw/a46XGNBZCX76H1T2lZ419unUVXvRP04/loMs1ikPFXTH 3Pu2ucfZedAtFIjzawBzQD0L+Gtpf8Gsg/qvWARFHunVx2BDTIaqHB5OyieeSXYLRy tkXs6Wvwa6p51yji9LUDOKX9o+Wc49Bvj5e3JajpUnXE4q5yA7iQfLe/R32GdK/Ov9 UA0CUjY+Y7TPQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 32D43CE1C2F; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: add testcase for fork()/waitpid() Date: Thu, 18 May 2023 07:55:20 -0700 Message-Id: <20230518145521.3806117-14-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244451474123102?= X-GMAIL-MSGID: =?utf-8?q?1766244451474123102?= 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 Thu May 18 14:55:21 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: 95936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp561737vqo; Thu, 18 May 2023 08:06:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6puJG3uTQZWFUisbpHbzAYG5eGmLgA6pMJMBVNoMG423ePFt0jRkExx3i6la1AnW56+SuU X-Received: by 2002:a17:902:ead4:b0:1ae:3bfb:f58b with SMTP id p20-20020a170902ead400b001ae3bfbf58bmr2399501pld.64.1684422397803; Thu, 18 May 2023 08:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422397; cv=none; d=google.com; s=arc-20160816; b=Vd9LhWofX3dw+4zlNgH9c3M3X5SczGS9OgKGp8YkxOJq7wKcrmyESX7RK0zzVNEKNj 9z9CnxCTdxC23Y6HKQ3cwwuw6etOqR+lsXWziAgxZUUKLawAxxKQ586JRMjKjyig5lc3 UUKUIxboJ/Kr2t7uG2gtOmTFHzhImcZDAVfcZReo5aFQpaSqfJ6qcq6TVt1a2csuvgph 3knm2nYa4cxsJzbyg7PYQr3VvLIjzCi2G0oZENsBU/jxmyWbcRILfAZAhozJJ/C6iz28 2xDoR2hTGiw8G+2JYmzt0w123n4sifR2EDVIsEDeRu+ACksR/Kt3xcdfuA+bhGrMJH1k HJww== 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=Fpe8P9+rweAHw9Tb51Uv6Ccd7HD480slhjE2TeQ2Yb71g0+cS5Aa5PeTgSCfgIOO00 I8xFXeNOsGP4gYjt5fEYQQW5h8rf5mAWqryF4fToBcQY7dAyu5DF25G7MlGjQDNCt/5u JuPnKbH2hPDTD+YZccUf5wDY1kmhR68n390HLa1S0MK/L9RPKpp2yleqvN9f/YGfylhK r9uygYLLT2bLP9wwb1kXdPzJ6n1ok7Mn6QcY5YQB6Pa3Hcith3/4lJGK5DdXRGf/R9B2 XFgir4qyWmYEdpBA/tGVwbGSL+XXob+TkkLdgMiorP9JWxQUsJglmznSn8NQyZfPbXWj k5CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MqpuKx2q; 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 1-20020a170902ee4100b001ae5fe35b6esi1414951plo.261.2023.05.18.08.06.14; Thu, 18 May 2023 08:06:37 -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=MqpuKx2q; 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 S231789AbjERO4B (ORCPT + 99 others); Thu, 18 May 2023 10:56:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbjEROzf (ORCPT ); Thu, 18 May 2023 10:55: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 0B0C4121 for ; Thu, 18 May 2023 07:55: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 7E9DA64FE9 for ; Thu, 18 May 2023 14:55:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2F60C4339E; Thu, 18 May 2023 14:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421728; bh=aYadX67GYiG+Nuff8Hdg1wAWmzTfTdurTxNUVvBVt1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MqpuKx2qd87uRhPLIzDuC16HORu6fs9E2wBSEeGEe76eL4pvT840w1VxPqOpFC1Bt xV8Sua3zCYk3GPsZhpeOk+4Q70e7kihILcvakVp1p2LlY8Owz3uuMEQH9MXWHuzib7 d0qmdWhEbK0fXvkufioIYEo5fUCYUvDH1XICDQ0UZFW7PeVCH402cgIErqVD8ZSIdB mZgGh8b2Ad+bJpqbQocrtWc15Un3YjqRIDI1GKZP7TbsVosymFpgYDvUWamwKzeqtG /PN4qiHq1Zp+fl8y5ZUDawDFJJdM4Y+OumHRJXQi8Taw+enmXve/OEobiRfNY20s6n xCBZK12hUwF4w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 350D1CE1CFE; Thu, 18 May 2023 07:55:23 -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/15] tools/nolibc: remove LINUX_REBOOT_ constants Date: Thu, 18 May 2023 07:55:21 -0700 Message-Id: <20230518145521.3806117-15-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <4817a4dc-69e6-4937-84d5-f2f630ff646c@paulmck-laptop> References: <4817a4dc-69e6-4937-84d5-f2f630ff646c@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?1766244900030494304?= X-GMAIL-MSGID: =?utf-8?q?1766244900030494304?= 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)