From patchwork Mon May 29 19:46:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 155C3C77B7E for ; Mon, 29 May 2023 19:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mFd0LGNlNMS9cIS+LhXK7yrVo4PvmKRwTSY350l/dEw=; b=hxHSHQlGNrvI7z F1V9yT9AK2G5/zs5/4kN+nGeVhJRonZIzOoUfjPfXqFYylE6AeF6Pg/o2TT7FDvDEm6OOZcgVA+SN AFyuc9hrCd6Ih69j3OgqIYFpWEzbkmH5Acv81uDIx8FytgXIKnQohE3rYLCqaK95sG6+XgJCeSZ9W Qm4QjmDjMqToAN3r43XYvyN04BfgiVopNRz+Zp1HjaDgi6NAKB/SWdLj6SRa9HWCXrgHDH0ZtEJZF SMhY8LZeKogvQeJfcwWzZs+Sf9DvYD39t2F9L5wv9zXfEJklYFSOjySvNr/kJe+91Xly8QU36POaf TK4iU4UmkKgXjTv//qSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3ipf-00BXkZ-01; Mon, 29 May 2023 19:47:07 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3ipc-00BXjD-1L for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:47:05 +0000 X-QQ-mid: bizesmtp79t1685389607t80smhoc Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:46:46 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: q+EIYT+FhZqztxguIVnnRhTx7mjT8KL3kpkNC9vlw/RJOJQunBpKKt3coh9nS b3hqugotci/+9LQaEWn5aWBw66TFgblIOoUHGzmoydkxp1VYBK3Jk0ftC+E+SfP8adRPKNC UOsplQSyz0Noa7ioorK0D4V2iSL+p0qOOTecBgsQGIF03PxcS8Wg384BzjdHIzbWaJY6A9P goVQyM/uk01ucMbDc8gymFRq/Br7+KWgXOlJbnQnNhcW26+kodAetsOUhrxkRr7H4ylwCrw UZsspZLj5FqA/WiT3kx2fAwpok1NcIOqmfOaxha6aU4OOvFLZ3nLptqkzd5wdCMDmGDCCMx o54rHau5cEQE7opKNJnlEEdyJKve++VllBqRR/ep/KB8//hCOyKMbqg+HwrLQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 274745737586768442 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 01/13] selftests/nolibc: remove gettimeofday_bad1/2 completely Date: Tue, 30 May 2023 03:46:42 +0800 Message-Id: <485fe4e27c1fd1a84d11e9fc47178a48de39263b.1685387484.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_124704_755524_4120FF53 X-CRM114-Status: UNSURE ( 8.44 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org In the clock_gettime / clock_gettime64 syscalls based gettimeofday(), there is no way to let kernel space 'fixup' the invalid data pointer of 'struct timeval' and 'struct timezone' for us for we need to read timespec from kernel space and then convert to timeval in user-space ourselves and also we need to simply ignore and reset timezone in user-space. Without this removal, the invalid (void *)1 address will trigger a sigsegv (signum = 11) signal and stop the whole test. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index a8fcad801cf2..7be2625f952d 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -582,10 +582,6 @@ int run_syscall(int min, int max) CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break; CASE_TEST(getdents64_null); EXPECT_SYSER(1, test_getdents64("/dev/null"), -1, ENOTDIR); break; CASE_TEST(gettimeofday_null); EXPECT_SYSZR(1, gettimeofday(NULL, NULL)); break; -#ifdef NOLIBC - CASE_TEST(gettimeofday_bad1); EXPECT_SYSER(1, gettimeofday((void *)1, NULL), -1, EFAULT); break; - CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; -#endif CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; From patchwork Mon May 29 19:47:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE4B1C77B7E for ; Mon, 29 May 2023 19:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MjIUTiimX+H8m77vJx9IWVh8IJv7iMRAbyuXi5NVkIo=; b=M/nSZgJYsDWCjT kduFyrhVgDhYMSL1lpPnZSGrFMPowM/7pUjn//hTtti9+Hhgu8+eKtrF9x1w6dMWMAPUGCe2m+C/N 07r1f8mrVTEMg4FNyD5vqAaocqzNrFqRur2eoHcib3Tn6YBHYMRXXDFxPy/ukUabKtvbga5iTVWVW y/vPtzDSuXVvYZvpMLMIaTv1Py5OjNVARzZKP8WFY3c6Qzt3fABAWxE4s78QyaMC3gPt93snnRPHY /DQEJLPtjpiBTxDmSeZqbH+EayDuLBTj0E302egbQVkBlcZsJ1x5WlLmq+HtqMmhmi+9ZuhjQ3EQM N45qw3H1rUPJCdTySQew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3iqt-00BXuV-2Q; Mon, 29 May 2023 19:48:23 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3iqp-00BXsb-0h for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:48:20 +0000 X-QQ-mid: bizesmtp69t1685389686tvz8s19j Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:48:05 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: dKvkn8qoLrH/qrejci3fihvIQXoBf5YJrhmGUUzcf6qh+6IazDSOYdwIhP/YW ORgu5EPCd6gOyYSDLJ50tIYOWHXJxLAHR+9ATsEoUhwa54b9uqgZV8rWyvxv5W1sGh3Dw0f yzw3WsCbvyXct5MtQJqJt/JFGFvi3IWadG8J3YkTbMp0ForpQJ/4qiirjssVz+7nPuHC5wH zOP+3TtFbEJQahQpwJpxiK5lh9V5fPTxAGAibu31tRi7EEfUpX+/b6G5EdjvKBHfJUrz/40 IcdygC3t7OZS2n+o3MeIYbt6xp+apeSPMnuQC/Qj2LQQeDS/zt6WhRt3e8Ns8QuBKgJ8LoD RID1pt1s13NEExuGLJSuUmrq+riUGsiUJO5h+JsZIs+Q6yPZdUdER2Yi1BNlQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17992497824335630657 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 02/13] selftests/nolibc: support two errnos with EXPECT_SYSER2() Date: Tue, 30 May 2023 03:47:55 +0800 Message-Id: <63510e8d586d2d20337f3bb2ff753db4e09bfe11.1685387484.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_124819_554175_7FAFAE23 X-CRM114-Status: UNSURE ( 9.73 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Some functions may be implemented with different syscalls in different platforms, these syscalls may set different errnos for the same arguments, let's support such cases. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 7be2625f952d..bf63fc66e486 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -300,18 +300,24 @@ static int expect_sysne(int expr, int llen, int val) } +#define EXPECT_SYSER2(cond, expr, expret, experr1, experr2) \ + do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0) + #define EXPECT_SYSER(cond, expr, expret, experr) \ - do { if (!cond) pad_spc(llen, 64, "[SKIPPED]\n"); else ret += expect_syserr(expr, expret, experr, llen); } while (0) + EXPECT_SYSER2(cond, expr, expret, experr, 0) -static int expect_syserr(int expr, int expret, int experr, int llen) +static int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen) { int ret = 0; int _errno = errno; llen += printf(" = %d %s ", expr, errorname(_errno)); - if (expr != expret || _errno != experr) { + if (expr != expret || (_errno != experr1 && _errno != experr2)) { ret = 1; - llen += printf(" != (%d %s) ", expret, errorname(experr)); + if (experr2 == 0) + llen += printf(" != (%d %s) ", expret, errorname(experr1)); + else + llen += printf(" != (%d %s %s) ", expret, errorname(experr1), errorname(experr2)); llen += pad_spc(llen, 64, "[FAIL]\n"); } else { llen += pad_spc(llen, 64, " [OK]\n"); From patchwork Mon May 29 19:49:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 065B9C7EE23 for ; Mon, 29 May 2023 19:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kbmuvu+6l8AmC8prYFjtybzr+1YAg2O5AuRDKqJ7X38=; b=rwSS1LNzlY8yZe EgKUCWLvt4wlmoOF/vUUsgrZSxUg7YO7P/yi3EKwdX9I+nWIYx9BsZaLF/fms75jntLhviDwFdhqo q0QOu1Ow3HwBBdYrsO2trVhzpwVeyPGHgqOXW7u1JaCYxOw+76+919871iy/BcIck1WvBfN8M8UCt VyucjeJLhUsdozAsUf2uAvpHuQQcM0lNNCestkAQ9DONKwt8mX9jHLE77LHc0bLUu5ITFtFPVDKhn qoVseU9yYZKsj/PqO1p1i2hHJEU4N6anS2J1K0/YH47UBp2HJBX5PS2bgmkAeHbomMUHQR//Lxii9 hG8J4LnI3Jh1JSiDQZYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3isC-00BYAZ-1c; Mon, 29 May 2023 19:49:44 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3isA-00BY9K-0A for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:49:43 +0000 X-QQ-mid: bizesmtp83t1685389766t53i55xa Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:49:25 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: XBN7tc9DADK11f2bR4vYw8XCXzz6JcjAHYV1K2y5nPxMJB79I1Jp2sCFv3dB8 iWvFxzDt5ZBO3/bVujU2W+nt/UA864ldEDVdt2QSjJhlfLCFx8a+GtHntrNXKQIP1rHXDuc apqK12n9mJIs7Ij9lXeQ69kiq9c3lq2eE9vKtqcVqZll+r1w1FU/+MPq9h6w/YnYjl1dB6X KbnN+QNfllARfcvZLB5QUu3mmHuKconJm3cU4J7X+xK9SrGZu64fOOKkE+nelsfVLERS46t OnYVaL2SeEnHyq5nNSOCononupQNDSiDFCOk9LaAJZJ+McV6LQll49XPFN7EXqDrFPVxRLz l533bTcMwWSQq+ywKl8jP9ZmLqs2PGN6ArqxLYoPsl8Zfca2ltTFw5rTPTkcg== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 7469899247824790916 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 03/13] selftests/nolibc: waitpid_min: add waitid syscall support Date: Tue, 30 May 2023 03:49:14 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_124942_391455_1127B6BF X-CRM114-Status: UNSURE ( 8.64 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org waitpid() is based on sys_wait4(). When the first argument is INT_MIN, the wait4 syscall based sys_wait4() return EFAULT by default, but the waitid syscall based sys_wait4() return EINVAL in rv32 platform, let's support such case. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index bf63fc66e486..8ba8c2fc71a0 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -616,7 +616,7 @@ int run_syscall(int min, int max) CASE_TEST(unlink_root); EXPECT_SYSER(1, unlink("/"), -1, EISDIR); break; CASE_TEST(unlink_blah); EXPECT_SYSER(1, unlink("/proc/self/blah"), -1, ENOENT); break; CASE_TEST(wait_child); EXPECT_SYSER(1, wait(&tmp), -1, ECHILD); break; - CASE_TEST(waitpid_min); EXPECT_SYSER(1, waitpid(INT_MIN, &tmp, WNOHANG), -1, ESRCH); break; + CASE_TEST(waitpid_min); EXPECT_SYSER2(1, waitpid(INT_MIN, &tmp, WNOHANG), -1, ESRCH, EINVAL); break; CASE_TEST(waitpid_child); EXPECT_SYSER(1, waitpid(getpid(), &tmp, WNOHANG), -1, ECHILD); break; CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; From patchwork Mon May 29 19:50:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C18C7C7EE23 for ; Mon, 29 May 2023 19:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OUK0xedM4ZSHjxc+e/EWLbF4BFTsAJ0qzBBYcXddEiU=; b=dO8iCAhe2t7ZuB ipERhopaH4cUuAamBDyuN0vLmrQSLJXOMup/qITrEK9hGcuo+RABupxKkp+1OUcm+ZNoMLGRzgHD+ bhBuwT2kSnPIzKS6CQ6IDDBgXxrUz/wcHOztzIuHCi9MwMQzqFEqktMldNOZhvi5XXnkHUo0c23sr LFh0+rGU65uQK6Ynyci+sXxijaG05g44V/vGJXK5PrvDcud8Z9PWC76nETLzOhuqSZeygh7NFA123 9pY/6JQwAo4LVG/A1uRlGgUjtsHmcXKZUOuQiXsBwt+YoohMLnVU+nsArQNo0FH0DskBUPM4d9vDF 6u6Dattb7BskM1t/00sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3itO-00BYL4-02; Mon, 29 May 2023 19:50:58 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3itK-00BYJ0-0y for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:50:55 +0000 X-QQ-mid: bizesmtp83t1685389840t1ldvvpj Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:50:39 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: dKvkn8qoLrFfEd304t1Xl83vvHzcvnC5EbPGl6s3cJET+n5LM1YDkRuZaPpId hp3bJ7KbDOlPLie0wL+QhZCmS6Ym5I3VeBvkxj/bRb7MTlDa33drXsOjI66pujE8j+7fncI L6Fnw0neLjbdK/6pgleFNIAbeK+rx1MA282jNwz6q+2YZuvTDOoBUf7/B8xqBW6Dp09Wb7f ism+NRTnMMJSNVs2lNPqesZMBxOJtK74ASsYMXd7AcpK5Hk3+rPgSmwIA3ip8LF7iOG9w92 OlkSZ79gWfXHiVBWBtuYYBw+EqMK32qFP8x0dcMKGHEqR5eYUDKrGKxOzVNRmgHxiASOB30 XPiK6fv7mSwkQeCgPpPSdu8qQiUeTDy2D5zRv+KIP5aJ4AFOm3hh77HWm7UxQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 18400951668219620669 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 04/13] tools/nolibc: add missing nanoseconds support for __NR_statx Date: Tue, 30 May 2023 03:50:34 +0800 Message-Id: <4cd637be248b5bfad6f2a01b82a9fb6f3fe4c6fa.1685387484.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125054_639806_B272F75D X-CRM114-Status: UNSURE ( 9.19 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Commit a89c937d781a ("tools/nolibc: support nanoseconds in stat()") added nanoseconds for stat() but missed the statx case, this adds it. The stx_atime, stx_mtime, stx_ctime are in type of 'struct statx_timestamp', which is incompatible with 'struct timespec', should convert explicitly. /* include/uapi/linux/stat.h */ struct statx_timestamp { __s64 tv_sec; __u32 tv_nsec; __s32 __reserved; }; /* include/uapi/linux/time_types.h */ struct __kernel_timespec { __kernel_time64_t tv_sec; /* seconds */ long long tv_nsec; /* nanoseconds */ }; /* tools/include/nolibc/types.h */ #define timespec __kernel_timespec Without this patch, the stat_timestamps test case would fail on rv32. Fixes: a89c937d781a ("tools/nolibc: support nanoseconds in stat()") Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 154194056962..98cfa2f6d021 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1175,9 +1175,9 @@ int sys_stat(const char *path, struct stat *buf) buf->st_size = statx.stx_size; buf->st_blksize = statx.stx_blksize; buf->st_blocks = statx.stx_blocks; - buf->st_atime = statx.stx_atime.tv_sec; - buf->st_mtime = statx.stx_mtime.tv_sec; - buf->st_ctime = statx.stx_ctime.tv_sec; + buf->st_atim = (struct timespec){ .tv_sec = statx.stx_atime.tv_sec, .tv_nsec = statx.stx_atime.tv_nsec }; + buf->st_mtim = (struct timespec){ .tv_sec = statx.stx_mtime.tv_sec, .tv_nsec = statx.stx_mtime.tv_nsec }; + buf->st_ctim = (struct timespec){ .tv_sec = statx.stx_ctime.tv_sec, .tv_nsec = statx.stx_ctime.tv_nsec }; return ret; } #else From patchwork Mon May 29 19:51:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF826C77B7E for ; Mon, 29 May 2023 19:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dMjoJW4bE8T0dEQ5xsZk1yKL54ObdTcJCsCUW5A+x3I=; b=ssg4vuBpnfjGJN 9XPyD7uEM24MJSe56LUvJQfEKtfVlz28KU1ceegZwbZsTyI6CFIZN4OuLN1mdRoHWN1smQuYB8eaY DCdq4egSRax1LaspQbU8E2PNJvdmzKDecRJrW2ehekPHClNCifabiPK34v1VAi6DfacyVsWkQ5Q/k xXLN6fvoeGd7tTFVZ64CXJtoxEWGdJQYv/XvdeXPSDerq3Nk6/f2h6aTuZTr6xttItxPdB42IYW/F dLSKzlFXfXsmpv+GnOJMia7GtTcjabNG1ibl+U1eiJPp4VsRgahYHulwrMXZRfOEypq2j3JbAmfgA AuV/L72UWgwskIVoCwwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3iuY-00BYeE-06; Mon, 29 May 2023 19:52:10 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3iuV-00BYc0-0Z for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:52:08 +0000 X-QQ-mid: bizesmtp87t1685389912tusgo9mr Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:51:51 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: LE7C6P2vL8R5XJtM7F/ylhDdnSf4EUI8w+v082wCayEwS8rdu+e8MzUqlG3Sb QuE4mqAnTVj6AADlLJu/mYN813+YPw+wXBoUtUM/fgbT6eqZhO8mdM4qSyoVp4k8dOh/beL /l7yxz9x8w9r+TSZWZLLMsMD9u3qECqZpmPkRw0+tQOYBeXpiaRhRFDEEoxVspoDs9zmbAg 977LlI4WFKBMXCoTk3CBGjDpFdvDeGrbH0Fsj2GfLw+U4NeVeHbXa3Ycefev6zt9mzP01Qo LJnk0Twv4xlHA/20ARRy2Qt8n9dEKicVztokHy1O+8hrgKAQQHYbo5SNcKjO3ajFS8Vnkwl KO6HYcWeOwM/XfiLougrpGNauB5hUSmFxblr/kzjnLpPEhiZhWuZnbWOyY86IFQeBWRJY38 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 14959843268558275111 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 05/13] tools/nolibc: add more wait status related types Date: Tue, 30 May 2023 03:51:48 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125207_511167_D65B288B X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org More wait status related types are added for the coming waitid syscall based wait4() support. Resue the ones from , add the missing ones from sys/wait.h and bits/waitstatus.h of glibc. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/types.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index f96e28bff4ba..698d859fc6e2 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -10,6 +10,7 @@ #include "std.h" #include #include +#include /* Only the generic macros and types may be defined here. The arch-specific @@ -91,9 +92,13 @@ #define WIFEXITED(status) (((status) & 0x7f) == 0) #define WTERMSIG(status) ((status) & 0x7f) #define WIFSIGNALED(status) ((status) - 1 < 0xff) +#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) -/* waitpid() flags */ -#define WNOHANG 1 +/* Macros for constructing status values. */ +#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#define W_STOPCODE(sig) ((sig) << 8 | 0x7f) +#define W_CONTINUED 0xffff +#define WCOREFLAG 0x80 /* standard exit() codes */ #define EXIT_SUCCESS 0 From patchwork Mon May 29 19:53:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79CDAC77B7E for ; Mon, 29 May 2023 19:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UoJClE4LMDkbAwqGjaYiImP+IkLmCWRDJc1vgjB89IQ=; b=xmG6hwAS9doL5+ dlmOjEBqP7HMpoLnEiEGWhcSZc349Fp0DvfDvJlBBklkiOYNGSDYhpZzBwpO1zK7e/1UT9tLco5A5 fIyxi3gAUYKWUCEoRjDS6DOmE0zKtgTr+nweWYSjfAF6NSKbPEc0VztUsEmktaANpObT+fTChPrR4 61ezX8t6DW0D1a4tYx6JJ5ByMC0Rtt4g8+ZHvcKb0yw8y1U2R6lFJsrF/CL8F8Sur1HpSspuD4ED6 Po2mXOODXvhXa2MTxfTpq+bf7KLXzM5DeZg3yu4Yu31NRffQIRAMHHTcegpl0uniEuYH1NgI+F98d htcYEphS1bjUK9UVPffg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3ivu-00BYut-2V; Mon, 29 May 2023 19:53:34 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3ivo-00BYtT-1K for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:53:30 +0000 X-QQ-mid: bizesmtp87t1685389995t9lfs5qi Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:53:14 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: CR3LFp2JE4kuE2cO00Q/1KOi7QfVnxapLBkeSoUSu+aL7k4cNLL5T6EAjWCRL qWr+iK9XeavjZJL6SHlw1xJ39WYbVKpn5xi/kAYVRjWTUL0jc2GvhKngTUvjVkB3ZP96t8a f6bQH5yJmO7ydx9hHga2PhgYSPsewy6BXmnd6JDH+Ie/uv5PlwLeMbh5hPN9bnBjuf1wI3/ GX2HxLY2DDBNVjPV+v9pZ+RHjGYrURspNgApsk8t2R447yUh1MyCWXTv37OH8MqQk7xofTe afhTgbVNBvAS13Ewbqx3MqxnOl2Za5ZPSVDk9HvB/MNtCFJIf1+Y3Kh+P7RY2QdIZKD4kmW uCPOfJoEI2bVSbOW6d9M/0ygbJnGPeXTqMdOiA1LxQIbZHwVtv3xTZEg6CNn28wnViEtzW+ X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2371937537439054605 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 06/13] tools/nolibc: add pure 64bit off_t, time_t and blkcnt_t Date: Tue, 30 May 2023 03:53:00 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125328_752241_33055FE1 X-CRM114-Status: UNSURE ( 8.06 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org clean up std.h with include/uapi/linux/posix_types.h convert time_t to 64bit even in 32bit platforms, for y2038 issue. align off_t and blkcnt_t with 'struct statx' in include/uapi/linux/stat.h Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/83ab9f47-e1ed-463c-a717-26aad6bf2b71@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/std.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 933bc0be7e1c..0f458c1c24de 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -20,17 +20,21 @@ #include "stdint.h" -/* those are commonly provided by sys/types.h */ -typedef unsigned int dev_t; -typedef unsigned long ino_t; -typedef unsigned int mode_t; -typedef signed int pid_t; -typedef unsigned int uid_t; -typedef unsigned int gid_t; -typedef unsigned long nlink_t; -typedef signed long off_t; -typedef signed long blksize_t; -typedef signed long blkcnt_t; -typedef signed long time_t; +#include + +/* based on linux/types.h */ +typedef uint32_t __kernel_dev_t; + +typedef __kernel_dev_t dev_t; +typedef __kernel_ulong_t ino_t; +typedef __kernel_mode_t mode_t; +typedef __kernel_pid_t pid_t; +typedef __kernel_uid32_t uid_t; +typedef __kernel_gid32_t gid_t; +typedef __kernel_loff_t off_t; +typedef __kernel_time64_t time_t; +typedef uint32_t nlink_t; +typedef uint32_t blksize_t; +typedef uint64_t blkcnt_t; #endif /* _NOLIBC_STD_H */ From patchwork Mon May 29 19:54:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6311CC7EE23 for ; Mon, 29 May 2023 19:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HxnwkFvMHdcg+X2HGzQYhZGergtNvcwvyDxDFYENFPc=; b=010DPKG9Do+60k +njnB0dP7pIxtVw5QFThIoIHGN0pyaUaEB9IxOHGV+eYzmoALJdej5iBhjqLPoR4oe5QVFxNslD8o h0o55ieK7JDrGiNXRn6x8nj8Ki0p2FpamJR1R5M6F/sGZx29g7Az3eNTi03tS3Hn4dwB50ZBSgn0c YB7rJ5ZtCGO87nA3Q7mcmS1acuiXj6Fsw5l+1FP0XL61ZQJkohApJk0tW209FPyyAvioTRXtawXFN hWG7w5m/q/YAg2P0+wfBMh+Jtk9GRlB/prnnpXPbcmKRxdOgsRyo/bSZ1OQag/uK0akfSVV7zFcVH kf4YBG0te6Tvi4T44USw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3ixT-00BZHB-2m; Mon, 29 May 2023 19:55:11 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3ixR-00BZEz-1V for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:55:10 +0000 X-QQ-mid: bizesmtp74t1685390094tpc5r986 Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:54:53 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: uGhnJwy6xZISo/AEbiO2R7D9Bkp1qAC1x25dTn245rn0AypFebeWwalodNjhE EL0Hxl2tTtRKwyjA9hWn6rJEMWZwJ13M7sTzYmfFM1VAENq33hSqeuCTSPxUjmRP8In5z0j jE3PPH0La2QBf3gtfL4qavbfPRbU9RB/PQuJibgW2/x+jjWS9xtIWSHbLtt65NMZEKdLaN8 dkZK4Ia/D7JyiFc+a1Kz4je5B5SnuVU37OtBIhZa6tgmgd8wfgtSuev0V/BKN+5P6bH/hRU 5o3Ae2l3mwfoTcHHys8UBybwBk03+OCAL3pFbxALn8Bt+8SyD8qmmeKLiKKhfao3WsglZUh Asti4FqiHE3VbrkVNKSBjtA3A/Az2xVvvEmvGiv9bla+QGTOev9aF8pmMHpuQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5796279202276383086 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 07/13] tools/nolibc: sys_lseek: add pure 64bit lseek Date: Tue, 30 May 2023 03:54:23 +0800 Message-Id: <2f5c3338898da65210ad3f62d7b7773a96f6d251.1685387484.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125509_803646_C50D2EC5 X-CRM114-Status: UNSURE ( 7.09 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org use sys_llseek instead of sys_lseek to add 64bit seek even in 32bit platforms. This code is based on sysdeps/unix/sysv/linux/lseek.c of glibc and src/unistd/lseek.c of musl. Signed-off-by: Zhangjin Wu Signed-off-by: Willy Tarreau --- tools/include/nolibc/sys.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 98cfa2f6d021..d0720af84b6d 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -672,7 +672,17 @@ int link(const char *old, const char *new) static __attribute__((unused)) off_t sys_lseek(int fd, off_t offset, int whence) { +#if defined(__NR_llseek) || defined(__NR__llseek) +#ifndef __NR__llseek +#define __NR__llseek __NR_llseek +#endif + off_t result; + return my_syscall5(__NR__llseek, fd, offset >> 32, offset, &result, whence) ?: result; +#elif defined(__NR_lseek) return my_syscall3(__NR_lseek, fd, offset, whence); +#else +#error None of __NR_lseek, __NR_llseek nor __NR__llseek defined, cannot implement sys_lseek() +#endif } static __attribute__((unused)) From patchwork Mon May 29 19:56:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE1C2C7EE23 for ; Mon, 29 May 2023 19:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DYAV5M+Wl/8YaqTS1kBXZ1Hl7nBe5CJaFHwFMmljsQ8=; b=o9jdmsYFNBMd8W IQ3BDrlzhbFTQjRRHcTLpGlrtyi7j99PeiXvaQa0/4p7eBvvrcqEpxKGMVhUbV143L+rQvwxQHXG2 bigCOohYZsYK1kwoJdWKiiBf0nQqCjQzs+0Sqr4TT7eD9ZQM/Om/Enco7XYVMw5l8BfnuD5wBuWWc Jb6AZw4zEfDmIpVtSG5FzIgjn8tya/tpHIEcTD0xF9klsAI7Skzk44ZZe99tnpQWrZfYnCj4Rl8kZ LoOQs8eCxeIIaBUjnmoeFH6/alBrVoBPZkCZMl7pxX8v2CbWqMRZG1RdAOEEpEKTouLLHK2YcKlxs lgTxDa9eCcJqX6YwnkgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3iyo-00BZUJ-1z; Mon, 29 May 2023 19:56:34 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3iyl-00BZT7-0H for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:56:33 +0000 X-QQ-mid: bizesmtp78t1685390175tmckq6oi Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:56:14 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: CRJwvrMA7Ii5QGhWTR7gAjDn/im3cUJTMJLrKCItiu9//IedHrZO8VPqve9CI JREbxHhECEfjcwj3iOLI7AtJRxZhcfwcuO1SA3a+CkIkUPFo9ONYVTiml7M01fxeghXu0CT vdthD4zOS6F9DsGvD+yFqUeF+tsLVoWmREiNsqk8v4emuWimsNWz2q3X91Rr5bTzuDeRHu1 8SYxkOwE40helGX0uZm1e7sq9E+ub2TQrpXIWvhGbqB2tcaoNclftY75ysAHMxF/uv56ubI q3Ha1mhj6elqdQbHhlOWR2LgMgKeKz4aGx+iiiglqpb3OKP3Sh2pYWRiEYiiIwD3rL2aP6Z skaIKTfTv2vEIU7Boxl8Xp2wT5XTgRGw92F+cgkFVvRT1zRnHdRY8A885R47PP8mfLT54NQ 3BjvdTpJLo4= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 14858657345865464071 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 08/13] tools/nolibc: add pure 64bit time structs Date: Tue, 30 May 2023 03:56:01 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125631_428194_C98FB3F0 X-CRM114-Status: GOOD ( 14.84 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org It's time to provide 64bit time structs for all platforms, for y2038 is near. There are still old "struct timeval" and "struct itimerval" in include/uapi/linux/time.h, remove "#include " and add our own pure 64bit ones. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/9e4064fc-f0c5-4dd3-941f-344d2150e1cd@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 2 -- tools/include/nolibc/types.h | 49 +++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index d0720af84b6d..1b3675d4c5fc 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include /* for O_* and AT_* */ #include /* for statx() */ @@ -28,7 +27,6 @@ #include "errno.h" #include "types.h" - /* Functions in this file only describe syscalls. They're declared static so * that the compiler usually decides to inline them while still being allowed * to pass a pointer to one of their instances. Each syscall exists in two diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 698d859fc6e2..4ff35b7ea2bb 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -8,10 +8,57 @@ #define _NOLIBC_TYPES_H #include "std.h" -#include +#include #include #include +/* based on linux/time.h but with pure 64bit time structs */ +#define timespec __kernel_timespec +#define itimerspec __kernel_itimerspec + +/* timeval is only provided for users, not compatible with syscalls */ +struct timeval { + __kernel_time64_t tv_sec; /* seconds */ + __s64 tv_usec; /* microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +/* itimerval is only provided for users, not compatible with syscalls */ +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +/* + * Names of the interval timers, and structure + * defining a timer setting: + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +/* + * The IDs of the various system clocks (for POSIX.1b interval timers): + */ +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 +#define CLOCK_PROCESS_CPUTIME_ID 2 +#define CLOCK_THREAD_CPUTIME_ID 3 +#define CLOCK_MONOTONIC_RAW 4 +#define CLOCK_REALTIME_COARSE 5 +#define CLOCK_MONOTONIC_COARSE 6 +#define CLOCK_BOOTTIME 7 +#define CLOCK_REALTIME_ALARM 8 +#define CLOCK_BOOTTIME_ALARM 9 + +/* + * The various flags for setting POSIX.1b interval timers: + */ +#define TIMER_ABSTIME 0x01 /* Only the generic macros and types may be defined here. The arch-specific * ones such as the O_RDONLY and related macros used by fcntl() and open(), or From patchwork Mon May 29 19:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BB95C77B7E for ; Mon, 29 May 2023 19:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2MVHOqo31vz5qMkS5MTNLTQE9v4DSaQ8nY13sqxv3Xo=; b=WSzsRtMje/9XQv 0FZAEel0Z6T5+965qFYdGAz2lwDbvGpUNYY/TZ/mP4wjcXuUuRsGVJygDAhyISUXZ/4++Rg5r3ZaV C5qSOYUgo/WvSuEoDQAHBPOjQ8pIEhJXRCZoOA88W/LFMJCAvSN7cSyoNfoMJ7oGCUdfp4m3K1lAR 3a4tahp4w0mD5+s7MgkadXVH8JinjP39rg5uL4Z64XhqCmdPDOe7r8Ze7XHfzNhYv9T/wKIY5U+EX p4GhiXq23OyBjX32tndfFOG5WkTrDqFeGryFmXdRzlF/xnoSG4Cz2vBzIvOJECvJ2nBFLGSfK1Uwu d5LT1Bp9pN2bGTjJlN3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3j06-00BZcJ-1D; Mon, 29 May 2023 19:57:54 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3izz-00BZav-33 for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:57:52 +0000 X-QQ-mid: bizesmtp80t1685390254t729c4zv Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:57:32 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: OXH3MF60TyUJojDygxgZs4OMGkp1TUBtXvEWJdTtHAxot7E3XnB+0jWSYs5Qa BpmJ83k0gOTutEc9dsST9cB8jNwauzivhsGGJ+WxNBuD9M9eNdiIZUiSovoSAwtJzVLUqNm 6l1RtQ45rz9J2I3WLQmOeHihNwFnMtTRziVyjB0iz59ARI+qIWT0VVbOhERipkWFJ3lGSgs z31bSq9gRuFfFjPOr/TnPG9HYs05G8i6RHx6VH+8NqisChYzoHDYOtLHXrJQ9UnnJ5xgUiG dFCN5lljhXjqrqsg4PxpyT3yteKfbL1fTzNCP55FIWq10KjWQOyKMweMhP0WyvDzHbgWZJr TFKLrgmQR/8gwTpM43kNKwXTRSuAGZdl+qjEyHibORah4Pf6S3xUE86Z/xwAHoNYlmIeKbK X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9056491278207555835 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v2 09/13] tools/nolibc: sys_select: add pure 64bit select Date: Tue, 30 May 2023 03:57:23 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125748_288772_0F25FCC1 X-CRM114-Status: GOOD ( 11.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org It's time to provide 64bit time structs for all platforms, for y2038 is near. pselect6_time64 has been added from v4.20 and the last arch support is at least from v5.0.0. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/76a5f9a0-eec4-415a-9c5d-ac3bca4d4b0e@t-8ch.de/ Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/bf3e07c1-75f5-425b-9124-f3f2b230e63a@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/arch-aarch64.h | 3 --- tools/include/nolibc/arch-loongarch.h | 3 --- tools/include/nolibc/arch-riscv.h | 3 --- tools/include/nolibc/sys.h | 25 ++++++++++--------------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 11f294a406b7..53255a3a326f 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -47,10 +47,7 @@ struct sys_stat_struct { * - the arguments are cast to long and assigned into the target registers * which are then simply passed as registers to the asm code, so that we * don't have to experience issues with register constraints. - * - * On aarch64, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index ad3f266e7093..973fdca96651 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -18,10 +18,7 @@ * - the arguments are cast to long and assigned into the target * registers which are then simply passed as registers to the asm code, * so that we don't have to experience issues with register constraints. - * - * On LoongArch, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index a2e8564e66d6..713eb9d2c91d 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -53,10 +53,7 @@ struct sys_stat_struct { * - the arguments are cast to long and assigned into the target * registers which are then simply passed as registers to the asm code, * so that we don't have to experience issues with register constraints. - * - * On riscv, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 1b3675d4c5fc..db648b5b9a1c 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1046,28 +1046,23 @@ int sched_yield(void) static __attribute__((unused)) int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout) { -#if defined(__ARCH_WANT_SYS_OLD_SELECT) && !defined(__NR__newselect) - struct sel_arg_struct { - unsigned long n; - fd_set *r, *w, *e; - struct timeval *t; - } arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout }; - return my_syscall1(__NR_select, &arg); -#elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6) +#if defined(__NR_pselect6) || defined(__NR_pselect6_time64) +#ifdef __NR_pselect6_time64 + const long nr_pselect = __NR_pselect6_time64; +#elif __SIZEOF_LONG__ == 8 + const long nr_pselect = __NR_pselect6; +#else +#error No __NR_pselect6_time64 defined, cannot implement time64 sys_select() +#endif struct timespec t; if (timeout) { t.tv_sec = timeout->tv_sec; t.tv_nsec = timeout->tv_usec * 1000; } - return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); -#elif defined(__NR__newselect) || defined(__NR_select) -#ifndef __NR__newselect -#define __NR__newselect __NR_select -#endif - return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); + return my_syscall6(nr_pselect, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); #else -#error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select() +#error Neither __NR_pselect6 nor __NR_pselect6_time64 defined, cannot implement sys_select() #endif } From patchwork Mon May 29 19:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 789E9C77B7E for ; Mon, 29 May 2023 19:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KWSqtRPdOag+fTkJORpzRZVgFrlbp+kKEmYm7q1de80=; b=RMbULiZw248GOI XwkTIXPZJp5sUKpju8zW57DtWNDpo1WT/+SDk3qkXpd2Jhxue6HXFIJhNp7KFqjG7gqC8R5v8Tjq1 dLjlvLFFbHfP8Aq0SxURKIH3lJn9GZSHZX60MsJ24RXSRduCBellR7jUfwHoZwAbrMhKyVax0PKN5 dBSXhl0dJ9kU4fem7iiSuQ1lM+JDaHKFi7pJIJpG+d1X7j9dxT6zlF4saN33YWQO4p9osiMrNUtkz EO0rQcCBHJ4Tx+1t0wn2FG1zLheP2B3BWiuiRStmsAL59Cna7NvqK7fpPQKS4EcIT824s4gcfj1AA ppdHMzhs+cxWi60D2rIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3j1D-00BZoi-2Q; Mon, 29 May 2023 19:59:03 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3j1B-00BZnJ-2q for linux-riscv@lists.infradead.org; Mon, 29 May 2023 19:59:03 +0000 X-QQ-mid: bizesmtp81t1685390329tl4a1sn8 Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 03:58:48 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: 9fp+MOMfZT2zNx5cI/90p1+iD3OFYm3s3YK5fd6MqPYblqw1OWNOqBS6mtmxO fMoOM+E+goEI3ecHYGOH/rDB2EhsgYIwM5UgrdO6NKUa0jQ0vC5le58Goq/yJpBxb+QpkiK f/vtUsnjRUKAVtIvhP3uG0qEaAOKEDu1l+HU9ziNNi/9Lfj7/wkOqNDUij2iR6gXCjDyZ4n 9lTIoyirLK/p7BAhjuaT0ah2jVt+yKYWrTeA25q9PEpJK2mFtyrxEXUF6lqNnOmRL3N/K9i 45+J3itzDAeYalzg1hO+DaTd+jvKUXN2yBI7B5sZqCUToA1X/NJbzbD662koEts8WroOj3X dtwBusqYja9KxUeXB3ViNXaNnE0ucLWqFCxKVsIIrih7kvbRw4= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5773408727969922355 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 10/13] tools/nolibc: sys_poll: add pure 64bit poll Date: Tue, 30 May 2023 03:58:42 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_125902_216527_199E4596 X-CRM114-Status: UNSURE ( 7.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org It's time to provide 64bit time structs for all platforms, for y2038 is near. ppoll_time64 has been added from v4.20 and the last arch support is at least from v5.0.0 Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index db648b5b9a1c..ca802627e88f 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -940,14 +940,21 @@ int pivot_root(const char *new, const char *old) static __attribute__((unused)) int sys_poll(struct pollfd *fds, int nfds, int timeout) { -#if defined(__NR_ppoll) +#if defined(__NR_ppoll) || defined(__NR_ppoll_time64) +#ifdef __NR_ppoll_time64 + const long nr_ppoll = __NR_ppoll_time64; +#elif __SIZEOF_LONG__ == 8 + const long nr_ppoll = __NR_ppoll; +#else +#error No __NR_ppoll_time64 defined, cannot implement time64 sys_poll() +#endif struct timespec t; if (timeout >= 0) { t.tv_sec = timeout / 1000; t.tv_nsec = (timeout % 1000) * 1000000; } - return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); + return my_syscall5(nr_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0); #elif defined(__NR_poll) return my_syscall3(__NR_poll, fds, nfds, timeout); #else From patchwork Mon May 29 19:59:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31695C77B7E for ; Mon, 29 May 2023 20:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AnQR4ecCrdRfjitxiZZ2GV7OeJFMMbu3VTVqzBd2roc=; b=QNCxI1ZxeZ+Ukh bAUHgUKrXvlBdek72thKm0Ln9HYn4hh7uUlP/Q5oyPpQEOT8opW+qoDuUBopA47sv4HWJSuGJDHPd ktGeJNkTcTo8DTejwiZMYqzkoI41tWdgOOdjFjtqrCVE3I5e74Wjo3uNj1/R/LPlPSQEhja19JviI +HZMsNcCmTbgg+69XHT2W+fhxiVukOTatcxiLSMY11t1o1f2z8XyALagHiQRfrAVSlEKW+Nl8vht7 twnstTwm5m+su9/RhyCE4K5Gr0dOhtrqaNEHM/5W0BvxZQanJ+FNjqlowmakAShPm4T9gPctR4tR0 xIcJ7KtMif+VmwbrkWsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3j2S-00BaDB-1b; Mon, 29 May 2023 20:00:20 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3j2P-00BaB7-2f for linux-riscv@lists.infradead.org; Mon, 29 May 2023 20:00:19 +0000 X-QQ-mid: bizesmtp72t1685390404tm1hc6lq Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 04:00:03 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: hHcwae2JLGcWbJfH39kHmo4snlKcsDyQqojZPXS964VUI/pU9KgvLuypS0Ah7 jYeyVqCZsExVvRBfJlr+CiyoUz3vLCHyLwxLp/d64KPpdGb9bB8hSTxi9nDGIkG3T5CUXWl ekxz82XJnF4H40ogAAvy1iEdLCLqKp94Eo1uPbII44VKTBekWYtZMOzFa+Wod+3vQNiiWRa pmueuBHNfNVM2iNDyqMzp8NUw7yYOifbwx+HQ6iREaLTCMyhglMI3jTjepktljlKAjdC2hf jMvzw5hE1hfVlh/86OfbTnombI5g+dpuv2aAWpJsjdxXMJWC5lNwPtoAaHQHMzhAXCLpTAV qXV0/H7I/oJg8xtfQg/yElw+Z0v+AGL/OWV9+iaWjDFf9RP0kwU+XVcK9A5Tn7Vqx0UKNeT X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3843116070107166378 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 11/13] tools/nolibc: sys_gettimeofday: add pure 64bit gettimeofday Date: Tue, 30 May 2023 03:59:57 +0800 Message-Id: <6d293f3957c43e60319af94b3e5463b376a86752.1685387484.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_130018_167745_516050EF X-CRM114-Status: GOOD ( 11.69 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org It's time to provide 64bit time structs for all platforms, for y2038 is near. clock_gettime64 has been added from at least v5.0.0. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/afc4944f-9494-4367-906d-06ac47648ab7@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index ca802627e88f..533233094733 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -25,6 +25,7 @@ #include "arch.h" #include "errno.h" +#include "string.h" #include "types.h" /* Functions in this file only describe syscalls. They're declared static so @@ -552,7 +553,34 @@ long getpagesize(void) static __attribute__((unused)) int sys_gettimeofday(struct timeval *tv, struct timezone *tz) { - return my_syscall2(__NR_gettimeofday, tv, tz); +#if defined(__NR_clock_gettime) || defined(__NR_clock_gettime64) +#ifdef __NR_clock_gettime64 + const long nr_clock_gettime = __NR_clock_gettime64; +#elif __SIZEOF_LONG__ == 8 + const long nr_clock_gettime = __NR_clock_gettime; +#else +#error No __NR_clock_gettime64 defined, cannot implement time64 sys_gettimeofday() +#endif + struct timespec ts; + int ret; + + /* set tz to zero to avoid random number */ + if (tz != NULL) + memset(tz, 0, sizeof(struct timezone)); + + if (tv == NULL) + return 0; + + ret = my_syscall2(nr_clock_gettime, CLOCK_REALTIME, &ts); + if (ret) + return ret; + + tv->tv_sec = ts.tv_sec; + tv->tv_usec = (unsigned int)ts.tv_nsec / 1000; + return 0; +#else +#error Neither __NR_clock_gettime nor __NR_clock_gettime64 defined, cannot implement sys_gettimeofday() +#endif } static __attribute__((unused)) From patchwork Mon May 29 20:01:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9217DC7EE23 for ; Mon, 29 May 2023 20:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FWAGpDHSl+W7ZiaY5o9mcWtyMkusxQznl5Tz2jx/5Z0=; b=NTMlGsz9E4ceBX XNmePiRHw/FKfpFfczWcpt9t7fwd+mtN/qp6r3+E6iq7F5/5SJTxT6pziMjraWPdAPHsluSR47xma 1rukwGmU1KFlbt8jo3ysPjrpZSCShV23rg6YF1EOpwBrw+ePsp0yxEYKr8Wg15nx7GAEjQX9YLgmk 1UgeLsiQxPSvPNwIuN45Cw8tNCZtGXQFloFZrWVrbvOTwtE2ZWIyIeSedHc1wExbEMhjtx6qgdjUl fKeRFHdRU3nAraQHDGkQBZxY7a2PYM9uXBHkii1Qse01KQwIBpJ+uYHK5U7DZ2seHZdi9qc060dHI +eNW5rFzf4B4ddeL1FYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3j4Q-00BaXi-0w; Mon, 29 May 2023 20:02:22 +0000 Received: from bg4.exmail.qq.com ([43.155.65.254]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3j4N-00BaW6-13 for linux-riscv@lists.infradead.org; Mon, 29 May 2023 20:02:20 +0000 X-QQ-mid: bizesmtp82t1685390525tz5qfwin Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 04:02:04 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: znfcQSa1hKbqS/wmQkhqLdwrSmiDHvyr6TKGy5erBP95lAX2a5SNTQj/PK8Ly 8Q83734ok7p3uV3bvpoEUwgs/ETtKRKuQB1PRX5jqAcr3G2iCef+kteIP98SFtKkceBncv+ MU25NzwaU1R+nbXctsMuEFHS4GBXB9qUQ0DCeQXoztp3RNnsWwxo8HnSRzot7jR2VfW2qdn 29yKvC/LFYAoenIfSYWVRR4hZ8lMsHjfDJ9j4zsH/TH/t6nPtK+9vP1YoxnWxDgYLfCbZ4c mg5+yl3HmrTNLLQb+iT5TFdh2GXi5osb3dyKJfwwtXfTWtDSt5YeDV3rGF3HkCOdyhQFJ6J 6+l86v9uzLe/q46AZmM1/ZbROiYVJMj7zfWr2h1gTU8UOyK/JX+o2QuEH055w== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4662585006422710528 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 12/13] tools/nolibc: sys_wait4: add waitid syscall support Date: Tue, 30 May 2023 04:01:13 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_130219_671392_6FC1D91C X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org rv32 uses the generic include/uapi/asm-generic/unistd.h and it has no __NR_wait4 after kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), use __NR_waitid instead. This code is based on sysdeps/unix/sysv/linux/wait4.c of glibc. Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 533233094733..a32b90b1fd3b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -12,6 +12,7 @@ /* system includes */ #include +#include /* for siginfo_t */ #include /* for SIGCHLD */ #include #include @@ -1373,7 +1374,56 @@ int unlink(const char *path) static __attribute__((unused)) pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage) { +#ifdef __NR_wait4 return my_syscall4(__NR_wait4, pid, status, options, rusage); +#elif defined(__NR_waitid) + siginfo_t infop; + int idtype = P_PID; + int ret; + + if (pid < -1) { + idtype = P_PGID; + pid *= -1; + } else if (pid == -1) { + idtype = P_ALL; + } else if (pid == 0) { + idtype = P_PGID; + } + + options |= WEXITED; + + ret = my_syscall5(__NR_waitid, idtype, pid, &infop, options, rusage); + if (ret < 0) + return ret; + + if (status) { + switch (infop.si_code) { + case CLD_EXITED: + *status = W_EXITCODE(infop.si_status, 0); + break; + case CLD_DUMPED: + *status = WCOREFLAG | infop.si_status; + break; + case CLD_KILLED: + *status = infop.si_status; + break; + case CLD_TRAPPED: + case CLD_STOPPED: + *status = W_STOPCODE(infop.si_status); + break; + case CLD_CONTINUED: + *status = W_CONTINUED; + break; + default: + *status = 0; + break; + } + } + + return infop.si_pid; +#else +#error Neither __NR_wait4 nor __NR_waitid defined, cannot implement sys_wait4() +#endif } static __attribute__((unused)) From patchwork Mon May 29 20:03:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D357DC7EE23 for ; Mon, 29 May 2023 20:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vi3EhqCvPfXhqEwseAQc4Bpr/LsNlJV8qD1Uo/AP3is=; b=zqa8t65JUJvU/M sNsx0JTgJn7ZPWzjsBiKizXEt+F3tXPMiIIjBxFWFUuUurRbykIieJVCgo/gGWIsKQ/F8N5LBajhA SNuXxJd9Fz5a/GBJHAEDhqnt8v/4MAPmNrDwFqKcCWdjroGT1FBLyojJAmluwWz+a7EcfxQWNfnX+ SjrMJmqPc3H0XXwEUhEaKaAybdph+JsXK7KFMIHU+nvkLL7QvLQK6OC9HQtatok83Sv3tjw8qJUwj ltPsvVCrFgqiD6B9/PLyw166IDjrbElc0piJEVUjJviiCDnC1hm5TSPeuIn5F5U82iKPtjmoXJC52 LnxQRe+jv5vZ/iskwljw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3j5b-00BahX-38; Mon, 29 May 2023 20:03:35 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3j5Y-00Bafs-1N for linux-riscv@lists.infradead.org; Mon, 29 May 2023 20:03:34 +0000 X-QQ-mid: bizesmtp69t1685390599tn4jgnkv Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 30 May 2023 04:03:18 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: k0mQ4ihyJQNl0tPjdjOgNqX0jjoVkxp1GSPuWGQl656yikeNBviNJKBitUkp6 lm+aMUjEhrGBVafJe/0RXm005dmvPr0svXZCa00fN2INLXf8FnX81RmDUt2RhzUgAQmcJaY X/4en6armYsi4js8RQbWSj7MXj+1rrUUZu0TBjhA9ohK0H0sNutaoVfQBevgcxiUkv87vvL +//jtz8F0e5Q0CYbDrwZ5uz07UcKaxwX0zS7KvhqZyM0K2PQzxduLNZPan30L2AVmLACHeh eURVC7zC4QyiX2NfPz2+tAWb4UnLZt1DZtzFcv2zFEbXFBGRgAzzEve+INc5O82EGXUTX6q Jn2upXB9ZPMongQJPWwow/0kN1eZf1RBE53Rw0kETzF1NOKT5hNlIbUUAZG6V5q2HzXpa8i X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5246615934604989803 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 13/13] selftests/nolibc: riscv: customize makefile for rv32 Date: Tue, 30 May 2023 04:03:13 +0800 Message-Id: <6f065441a6be9e63238ffb3d43cf09a6e4ac6773.1685387485.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_130332_768565_A469754D X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Both riscv64 and riscv32 have: * the same ARCH value, it is riscv * the same arch/riscv source code tree The only differences are: * riscv64 uses defconfig, riscv32 uses rv32_defconfig * riscv64 uses qemu-system-riscv64, riscv32 uses qemu-system-riscv32 * riscv32 has different compiler options (-march= and -mabi=) So, riscv32 can share most of the settings with riscv64, there is no need to add it as a whole new architecture but just need a flag to record and reflect the difference. The 32bit mips and loongarch may be able to use the same method, so, let's use a meaningful flag: CONFIG_32BIT. If required in the future, this flag can also be automatically loaded from include/config/auto.conf. With this patch, it is able to run nolibc test for rv32 like this: $ make run ARCH=riscv32 CROSS_COMPILE=riscv64-linux-gnu- ... Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 44088535682e..ea434a0acdc1 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -14,6 +14,12 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif +# Allow pass ARCH=riscv|riscv32|riscv64, riscv implies riscv64 +ifneq ($(findstring xriscv,x$(ARCH)),) + CONFIG_32BIT := $(if $(findstring 32x,$(ARCH)x),1) + override ARCH := riscv +endif + # kernel image names by architecture IMAGE_i386 = arch/x86/boot/bzImage IMAGE_x86_64 = arch/x86/boot/bzImage @@ -34,7 +40,7 @@ DEFCONFIG_x86 = defconfig DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips = malta_defconfig -DEFCONFIG_riscv = defconfig +DEFCONFIG_riscv = $(if $(CONFIG_32BIT),rv32_defconfig,defconfig) DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig DEFCONFIG = $(DEFCONFIG_$(ARCH)) @@ -49,7 +55,7 @@ QEMU_ARCH_x86 = x86_64 QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm QEMU_ARCH_mips = mipsel # works with malta_defconfig -QEMU_ARCH_riscv = riscv64 +QEMU_ARCH_riscv = $(if $(CONFIG_32BIT),riscv32,riscv64) QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 QEMU_ARCH = $(QEMU_ARCH_$(ARCH)) @@ -76,6 +82,7 @@ else Q=@ endif +CFLAGS_riscv = $(if $(CONFIG_32BIT),-march=rv32i -mabi=ilp32) CFLAGS_s390 = -m64 CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \