From patchwork Sat Jun 3 08:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5247FC77B7A for ; Sat, 3 Jun 2023 08:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234011AbjFCIBK (ORCPT ); Sat, 3 Jun 2023 04:01:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjFCIBJ (ORCPT ); Sat, 3 Jun 2023 04:01:09 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812D81B6; Sat, 3 Jun 2023 01:01:06 -0700 (PDT) X-QQ-mid: bizesmtp66t1685779256tfrhwl1v Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:00:55 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: k0mQ4ihyJQNgkVwygW0yshuGkeM5gEbPP6qD3JPq1MQNFpbusU7tTU0lbB22l A/5UcKnooUQIfO7IdU6An49Ew/yF6sQud/gbxCL4QnanhGzK5jwDlyfGoBThAEWl768oPaN eBs1jfQtfGszTLv2Ika597BM+IvXXcun0tPnrU6tHzcRc2UZUueBk6bih+duFmLswS5oeaG vFxXt7CE38Pel27vLsN2UsJz//tO/rgvA+hJSXSRHAQTde1zwQCX9o42qUvx0BGe+Zs2U5Z 2CNFuUUZWezBEgy6ORi06eutXif6JZYh+Pnlp3AnWar+2IW0xvGRO9ed1T643iOLM4zGfFm dF/cgTkjCgfOoncc6p43EE+tkxQsdBQsYmRC9NXrF1fNybD8O6YFpEQI/CODCNYAvg059yP X-QQ-GoodBg: 0 X-BIZMAIL-ID: 13312987647065387357 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 01/12] selftests/nolibc: syscall_args: use generic __NR_statx Date: Sat, 3 Jun 2023 16:00:46 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Compiling nolibc-test.c for rv32 got such error: tools/testing/selftests/nolibc/nolibc-test.c:599:57: error: ‘__NR_fstat’ undeclared (first use in this function) 599 | CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; The generic include/uapi/asm-generic/unistd.h used by rv32 doesn't support __NR_fstat, use the more generic __NR_statx instead: Running test 'syscall' 69 syscall_noargs = 1 [OK] 70 syscall_args = -1 EFAULT [OK] __NR_statx has been added from v4.10: commit a528d35e8bfc ("statx: Add a system call to make enhanced file info available") It has been supported by all of the platforms since at least from v4.20. Fixes: 8e3ab529bef9 ("tools/nolibc/unistd: add syscall()") Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/ee8b1f02-ded1-488b-a3a5-68774f0349b5@app.fastmail.com/ 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 7de46305f419..d417ca5d976f 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -621,7 +621,7 @@ int run_syscall(int min, int max) CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getpid()); break; - CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_fstat, 0, NULL), -1, EFAULT); break; + CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_statx, 0, NULL, 0, 0, NULL), -1, EFAULT); break; case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ From patchwork Sat Jun 3 08:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EBF6C7EE24 for ; Sat, 3 Jun 2023 08:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbjFCIDP (ORCPT ); Sat, 3 Jun 2023 04:03:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjFCIDO (ORCPT ); Sat, 3 Jun 2023 04:03:14 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAE3E40; Sat, 3 Jun 2023 01:03:12 -0700 (PDT) X-QQ-mid: bizesmtp88t1685779382tnnl2ip3 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:03:01 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: /+iK7ZpVlLQCQXqPSdOBhJJtHOaA/uGGRHPayXIRaGu+YhAFWsPazE+ULSLgS s96RiiK7GwzPd6n89GHKQ6SFyVzhAqWyrFlaMYaOWdhjhbHb+VixYEAYRUPKZ/rQtyNckdi Zi25NQ0xylNsTwAaSxVLoioPCOMe8dtaR7JxTZ1xYpMFZ283x4epDN6y5QixLz8+iZP0EfJ HvS+E4mwJnyo4BzYB8Dnvkv08tDSmnmlt5WxwR5X2dw2THx/n7ZPVm+0e8Wgc04QLzraW17 ZNGSqreCAtS/IQdHnr/1E2GfnX2rLYl70mHTMeCkWhU9d+Udx4qEAgNftIJGCjPiNotnHYR f3WDBW5fL5oG0fLP3oLir4hW+hIQGRTVyTaQu9rpMwP+WLysZ3z9Hgl46OfyXFXNEC80Cml 2uhx01xuDXA= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15194475891504528648 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, 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 v3 02/12] tools/nolibc: add missing nanoseconds support for __NR_statx Date: Sat, 3 Jun 2023 16:02:04 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.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.h */ struct timespec { __kernel_old_time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; Without this patch, the stat_timestamps test case would fail when __NR_statx defined. Fixes: a89c937d781a ("tools/nolibc: support nanoseconds in stat()") Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/3a3edd48-1ace-4c89-89e8-9c594dd1b3c9@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 1d6f33f58629..0160605444e7 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1161,23 +1161,26 @@ int sys_stat(const char *path, struct stat *buf) long ret; ret = sys_statx(AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &statx); - buf->st_dev = ((statx.stx_dev_minor & 0xff) - | (statx.stx_dev_major << 8) - | ((statx.stx_dev_minor & ~0xff) << 12)); - buf->st_ino = statx.stx_ino; - buf->st_mode = statx.stx_mode; - buf->st_nlink = statx.stx_nlink; - buf->st_uid = statx.stx_uid; - buf->st_gid = statx.stx_gid; - buf->st_rdev = ((statx.stx_rdev_minor & 0xff) - | (statx.stx_rdev_major << 8) - | ((statx.stx_rdev_minor & ~0xff) << 12)); - buf->st_size = statx.stx_size; - buf->st_blksize = statx.stx_blksize; - buf->st_blocks = statx.stx_blocks; - buf->st_atime = statx.stx_atime.tv_sec; - buf->st_mtime = statx.stx_mtime.tv_sec; - buf->st_ctime = statx.stx_ctime.tv_sec; + buf->st_dev = ((statx.stx_dev_minor & 0xff) + | (statx.stx_dev_major << 8) + | ((statx.stx_dev_minor & ~0xff) << 12)); + buf->st_ino = statx.stx_ino; + buf->st_mode = statx.stx_mode; + buf->st_nlink = statx.stx_nlink; + buf->st_uid = statx.stx_uid; + buf->st_gid = statx.stx_gid; + buf->st_rdev = ((statx.stx_rdev_minor & 0xff) + | (statx.stx_rdev_major << 8) + | ((statx.stx_rdev_minor & ~0xff) << 12)); + buf->st_size = statx.stx_size; + buf->st_blksize = statx.stx_blksize; + buf->st_blocks = statx.stx_blocks; + buf->st_atim.tv_sec = statx.stx_atime.tv_sec; + buf->st_atim.tv_nsec = statx.stx_atime.tv_nsec; + buf->st_mtim.tv_sec = statx.stx_mtime.tv_sec; + buf->st_mtim.tv_nsec = statx.stx_mtime.tv_nsec; + buf->st_ctim.tv_sec = statx.stx_ctime.tv_sec; + buf->st_ctim.tv_nsec = statx.stx_ctime.tv_nsec; return ret; } #else From patchwork Sat Jun 3 08:04:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DED4C7EE24 for ; Sat, 3 Jun 2023 08:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232328AbjFCIEf (ORCPT ); Sat, 3 Jun 2023 04:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjFCIEd (ORCPT ); Sat, 3 Jun 2023 04:04:33 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BADC8E41; Sat, 3 Jun 2023 01:04:31 -0700 (PDT) X-QQ-mid: bizesmtp76t1685779463tf50ulh5 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:04:21 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: zT6n3Y95oi1dVQM7LOUCe4ZErci7J0hzthPkaKsmZlRivSBkUu9oKsHTpK5iT 0ibxDOemCdi1l+T/yHYtBufVQx/bK105xvHta2f1ev1UfOGQW6UR4QI8ILpFABfBDs4Ldez PAIAwuuORwFw2j7gb6/FXc65FaEcYepkFvSrRQ+mRb0nTBmRtEeYBQdeoG5IsQTuHg6VWav 0XZceUgZxFEPKf0G/yYLqWteHLu+lfLWS/+wYVs2QNOYFcxJMAnjdiSQk+lk6r2ocBR3AjR QLOOVtbExyU2MM7yVMPK98ZL0kXlKhtPYmONaR6j9SstlAplCc+Pims0s10/tmrw8QxRuiR IkIiRQzDdA2jVEQHfKba8VIwrwOw2Q6CM6UeZHSgi5U3tez1D1Ql2UI0yb7HcSFf3/LWydY mcX+sxskv5U= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11632177116397536855 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, 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 v3 03/12] selftests/nolibc: allow specify extra arguments for qemu Date: Sat, 3 Jun 2023 16:04:10 +0800 Message-Id: <6763a735c95fe0fea8109450411c7501e02ce2b6.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The opensbi package from Ubuntu 20.04 only provides rv64 firmwares: $ dpkg -S opensbi | grep -E "fw_.*bin|fw_.*elf" | uniq opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.bin opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.elf opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf To run this nolibc test for rv32, users must build opensbi or download a prebuilt one from qemu repository: https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/opensbi-riscv32-generic-fw_dynamic.bin And then use -bios to tell qemu use it to avoid such failure: $ qemu-system-riscv32 -display none -no-reboot -kernel /path/to/arch/riscv/boot/Image -serial stdio -M virt -append "console=ttyS0 panic=-1" qemu-system-riscv32: Unable to load the RISC-V firmware "opensbi-riscv32-generic-fw_dynamic.bin" To run from makefile, QEMU_ARGS_EXTRA is added to allow pass extra arguments like -bios: $ make run QEMU_ARGS_EXTRA="-bios /path/to/opensbi-riscv32-generic-fw_dynamic.bin" ... Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/2ab94136-d341-4a26-964e-6d6c32e66c9b@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 47c3c89092e4..44088535682e 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -64,7 +64,7 @@ QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" -QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) +QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA) # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. From patchwork Sat Jun 3 08:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7522CC77B7A for ; Sat, 3 Jun 2023 08:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbjFCIGA (ORCPT ); Sat, 3 Jun 2023 04:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIGA (ORCPT ); Sat, 3 Jun 2023 04:06:00 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C5CCE40; Sat, 3 Jun 2023 01:05:58 -0700 (PDT) X-QQ-mid: bizesmtp73t1685779549t2ig12j6 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:05:48 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: 5CNn+SP0K2tsOionl/0qwFkto2mrob0OpN+vWURE2tYM65THhHtj71FAAGwF9 OHfpVFQZWFWNg003NYWU3Fed3VjmEgjfH0VEiKfzoCC9x1lPpUpqjuPCBEQ9cwGb+kNx2uz 8ODZZl0Vg7kpMG+4idFATFRnoD6xllszwiioL1IQZq3pJIjiEteOcwnQLkmLihMC8Ytr2ZQ Lzn60B7Gv+NrtWbnPlaedDpvBa9WjGx9avOWjpeM4bMz/256y4uPHB5E9Tjok94D2WBYBTC m4Be7XkPDi4Pup0R0s5A8AHaU8EkG6y+r9ZCTgb1kOD8bMbb0O+VVSUGpm7Dd+oVBHZP4VM 1TIfWKoEdDYVJ4W7R2/hnRWOyFGos/MH4eqN9UbQfL2A6wCucm5MFDIzLdPDYAvtQq94QKf X-QQ-GoodBg: 0 X-BIZMAIL-ID: 14226334804372199419 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 04/12] selftests/nolibc: fix up compile warning with glibc on x86_64 Date: Sat, 3 Jun 2023 16:05:30 +0800 Message-Id: <0626464891e7fc938e6f7a55f1f475f31fbc6f37.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Compiling nolibc-test.c with gcc on x86_64 got such warning: tools/testing/selftests/nolibc/nolibc-test.c: In function ‘expect_eq’: tools/testing/selftests/nolibc/nolibc-test.c:177:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=] 177 | llen += printf(" = %lld ", expr); | ~~~^ ~~~~ | | | | | uint64_t {aka long unsigned int} | long long int | %ld It because that glibc defines uint64_t as "unsigned long int" when word size (means sizeof(long)) is 64bit (see include/bits/types.h), but nolibc directly use the 64bit "unsigned long long" (see tools/include/nolibc/stdint.h), which is simpler, seems kernel uses it too (include/uapi/asm-generic/int-ll64.h). use a simple conversion to solve it. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/linux-riscv/20230529130449.GA2813@1wt.eu/ Signed-off-by: Zhangjin Wu --- 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 d417ca5d976f..403f6255c177 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -174,7 +174,7 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret = !(expr == val); - llen += printf(" = %lld ", expr); + llen += printf(" = %lld ", (long long)expr); pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; } From patchwork Sat Jun 3 08:06:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22AA3C77B7A for ; Sat, 3 Jun 2023 08:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231566AbjFCIHQ (ORCPT ); Sat, 3 Jun 2023 04:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIHP (ORCPT ); Sat, 3 Jun 2023 04:07:15 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C201B3; Sat, 3 Jun 2023 01:07:13 -0700 (PDT) X-QQ-mid: bizesmtp69t1685779624txgoo497 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:07:03 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: jGGC4gWX7WHvWPvSTOy/Lb7c8eVQpIcZemPq3PNoP6Btk/BRzXuaFdwjgIiSQ W6WK+idd8OnQM2tBuGBsUB5beRI5q0M/Pseeq9EajJLxpVMERzq4SbzdXJeAMmnvk+RDf2P TZjyzttZ1Ehh6oddMbwBEiGZTqJ3qpRAtwBtvGt7chZQ8i8xgDj4SqHU8eUwv9wDgpEEjHY lnJU4TMdKXxJGfhwX6qivcyJSXse9hUWqH6YasFJrCeSsBTuQ8ETIo6vk2yikQ6VuH4V1L8 8se4qXCohhtmlaq4NYQoptvpaNs/qDVEi7JnyngIyi42FDB3nAsGKDq6CHusQPKWdlA7tCc LEgI7y4TMRHR9CVXYEeCIxiSgqOv5XthjaPtZWt2q0Hdr/vnY4EdwGsTfpjFPpZORhVhBp5 K+cfJACxuF4= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 18271478634976400800 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, 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 v3 05/12] selftests/nolibc: not include limits.h for nolibc Date: Sat, 3 Jun 2023 16:06:57 +0800 Message-Id: <0aa3b57a44b0922a118dda503a9bbb2e49125f96.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When compile nolibc-test.c with 2.31 glibc, we got such error: In file included from /usr/riscv64-linux-gnu/include/sys/cdefs.h:452, from /usr/riscv64-linux-gnu/include/features.h:461, from /usr/riscv64-linux-gnu/include/bits/libc-header-start.h:33, from /usr/riscv64-linux-gnu/include/limits.h:26, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:194, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/syslimits.h:7, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:34, from /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/nolibc-test.c:6: /usr/riscv64-linux-gnu/include/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported" 28 | # error "rv32i-based targets are not supported" Glibc (>= 2.33) commit 5b6113d62efa ("RISC-V: Support the 32-bit ABI implementation") fixed up above error. As suggested by Thomas, defining INT_MIN/INT_MAX for nolibc can remove the including of limits.h, and therefore no above error. of course, the other libcs still require limits.h, move it to the right place. The LONG_MIN/LONG_MAX are also defined too. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/09d60dc2-e298-4c22-8e2f-8375861bd9be@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/stdint.h | 14 ++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h index c1ce4f5e0603..31a5264539ae 100644 --- a/tools/include/nolibc/stdint.h +++ b/tools/include/nolibc/stdint.h @@ -96,4 +96,18 @@ typedef uint64_t uintmax_t; #define UINT_FAST32_MAX SIZE_MAX #define UINT_FAST64_MAX SIZE_MAX +#ifndef INT_MIN +#define INT_MIN (-__INT_MAX__ - 1) +#endif +#ifndef INT_MAX +#define INT_MAX __INT_MAX__ +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-__LONG_MAX__ - 1) +#endif +#ifndef LONG_MAX +#define LONG_MAX __LONG_MAX__ +#endif + #endif /* _NOLIBC_STDINT_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 403f6255c177..2a2954cb7bef 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -2,9 +2,6 @@ #define _GNU_SOURCE -/* platform-specific include files coming from the compiler */ -#include - /* libc-specific include files * The program may be built in 3 ways: * $(CC) -nostdlib -include /path/to/nolibc.h => NOLIBC already defined @@ -39,6 +36,7 @@ #include #include #include +#include #endif #endif From patchwork Sat Jun 3 08:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266100 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BC05C77B73 for ; Sat, 3 Jun 2023 08:08:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjFCIIp (ORCPT ); Sat, 3 Jun 2023 04:08:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIIo (ORCPT ); Sat, 3 Jun 2023 04:08:44 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5886B1B3; Sat, 3 Jun 2023 01:08:43 -0700 (PDT) X-QQ-mid: bizesmtp71t1685779713tgcqkwdm Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:08:32 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: XBN7tc9DADLabrxk/+QDcnBfINyYg7hhkwxt2+gkdZwvWG8oXdYSvY4ACTUEK n+bM6hXEGtjzMWAut9D+MR9IRJiuWBUhAMptGJTyaSGuTS+zNj2PwvFLnK6O+fEod5ePmJ4 kzos7o/x54UwO+YylckkWOsgZYjfYkkzOkFnysR7xn77a0Nt3bl902/Q6v1226RSUYNfNWu rdohXqJ8xtcviTGsD4rZTt4RWdY9+j4APz5jkhrHYiZLLABKtnmK4VRSbYhhKXK0L2JlE+j +VGh5GKFc9D/O8lIopK9trH7Kn8+8UfZ2gzyuXCGyx3D6XP+U+U26Td3XAPDP0BjtgJJCkR 57O8mIZIN1jazn9PjSTbpuzjwHybPXzcb9PFM1ZIXMN3MtM3KCTcxmd9fs22pH2m7/At6HL X-QQ-GoodBg: 0 X-BIZMAIL-ID: 18070674266371447120 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 06/12] selftests/nolibc: use INT_MAX instead of __INT_MAX__ Date: Sat, 3 Jun 2023 16:08:12 +0800 Message-Id: <9e48ea5aab5a988fcba923632e6681c111dd5525.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org nolibc now has INT_MAX in stdint.h, so, don't mix INT_MAX and __INT_MAX__, unify them to INT_MAX. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 2a2954cb7bef..a8fcad801cf2 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -931,7 +931,7 @@ static const struct test test_names[] = { int main(int argc, char **argv, char **envp) { int min = 0; - int max = __INT_MAX__; + int max = INT_MAX; int ret = 0; int err; int idx; @@ -979,7 +979,7 @@ int main(int argc, char **argv, char **envp) * here, which defaults to the full range. */ do { - min = 0; max = __INT_MAX__; + min = 0; max = INT_MAX; value = colon; if (value && *value) { colon = strchr(value, ':'); From patchwork Sat Jun 3 08:09:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 553F8C77B73 for ; Sat, 3 Jun 2023 08:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbjFCILD (ORCPT ); Sat, 3 Jun 2023 04:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCILC (ORCPT ); Sat, 3 Jun 2023 04:11:02 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D0C1B3; Sat, 3 Jun 2023 01:10:59 -0700 (PDT) X-QQ-mid: bizesmtp84t1685779850t070pfh4 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:10:48 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: OFQdrTmJ2CRHOIPOvPtA3e3sNPsSHx/EuKOIZ/4rlJjrEdoz8zKYkHvsc0a0g uVElhx17GeBytasxWjr74uHrLAFmp+cvg7v6zEQSDxFWP6HpzXc7UFvixkc50irMnOQ1Me1 lbNXYNdCQLzyQig1+Cd5VecTpxTacvtTO+UqOwAYJad0x7TPJCcbgpSvABLqWjhYXCljV4m TClILQ1MrAGVoIvZrkY1gANg57tvM20wBNI/U6b/7ga+0lEl1pQmQEB+/+Db4McoyZ+Iyy9 gEwwBqdKP7S3mJAY8hy6BQKUEB/NZX9drKaKSNugSWr/jD0pRZ/glA5QiZfYdWBrDLRaaBm KkCuQ+A1QhNTfHOjLdVXMFG36sDOzck8GP7x3X17LS7yCrUaXus5m0UCVqCs/gNPr/+t88C X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4932993796128682688 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 07/12] tools/nolibc: arm: add missing my_syscall6 Date: Sat, 3 Jun 2023 16:09:41 +0800 Message-Id: <75c37f86eb9ae5173d136676432d5ace3a8c54df.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This is required by the coming removal of the oldselect and newselect support. pselect6/pselect6_time64 will be used unconditionally, they have 6 arguments. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/linux-riscv/bf3e07c1-75f5-425b-9124-f3f2b230e63a@app.fastmail.com/ Signed-off-by: Zhangjin Wu --- tools/include/nolibc/arch-arm.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h index 45b89ffe8247..ca4c66987497 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -198,6 +198,29 @@ struct sys_stat_struct { _arg1; \ }) +#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + register long _num __asm__(_NOLIBC_SYSCALL_REG) = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + register long _arg3 __asm__ ("r2") = (long)(arg3); \ + register long _arg4 __asm__ ("r3") = (long)(arg4); \ + register long _arg5 __asm__ ("r4") = (long)(arg5); \ + register long _arg6 __asm__ ("r5") = (long)(arg6); \ + \ + __asm__ volatile ( \ + _NOLIBC_THUMB_SET_R7 \ + "svc #0\n" \ + _NOLIBC_THUMB_RESTORE_R7 \ + : "=r"(_arg1), "=r" (_num) \ + : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \ + "r"(_arg6), "r"(_num) \ + : "memory", "cc", "lr" \ + ); \ + _arg1; \ +}) + + char **environ __attribute__((weak)); const unsigned long *_auxv __attribute__((weak)); From patchwork Sat Jun 3 08:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB046C77B73 for ; Sat, 3 Jun 2023 08:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbjFCIMn (ORCPT ); Sat, 3 Jun 2023 04:12:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIMn (ORCPT ); Sat, 3 Jun 2023 04:12:43 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FCF11B3; Sat, 3 Jun 2023 01:12:41 -0700 (PDT) X-QQ-mid: bizesmtp67t1685779952t05dliz3 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:12:31 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: 3M0okmaRx3jysSi7KPtogxkoekhC659z+ArtoJAEYTmllq6RxfjS8BCn5mqHJ O98HVUV0S5ZwQZkWqwX4sJdto+Rln35sV6MiI+4oN1YpPXiJxDGBEA0ZD4AsakhyzgxQEcB +LDpUY6CKcIgfZCHMis0AdjIpU+jAN8A1YDKWoNxahXCzvHZBH80INcI59EL0m1rulehtAa RwH6J1iAR8OzjdxwHL8YMi7pZ4WYVpQN/ClKWo1C7Cj+W/ub2y91JqWvGCCknHxX4AwBG9u te6wHZdWxiJ0EtJrB/vogkD5aJkiFm1IaZoceZHJ3taEVEj6VBkZe8YvGN3yEWituugrvxb HCZCVJNS/WOcoYH2sqLVK8Hb0OF8lhktNWXUUaOZNjhd5wXiHQMtjYv0sMB6U9wlr7QOZDx X-QQ-GoodBg: 0 X-BIZMAIL-ID: 7582937344931115199 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 08/12] tools/nolibc: open: fix up compile warning for arm Date: Sat, 3 Jun 2023 16:11:57 +0800 Message-Id: <66f55993e77b55bc666c003de2d598f81f19e4e4.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In function ‘open’: nolibc/sysroot/arm/include/sys.h:919:23: warning: ‘mode_t’ {aka ‘short unsigned int’} is promoted to ‘int’ when passed through ‘...’ 919 | mode = va_arg(args, mode_t); | ^ nolibc/sysroot/arm/include/sys.h:919:23: note: (so you should pass ‘int’ not ‘mode_t’ {aka ‘short unsigned int’} to ‘va_arg’) nolibc/sysroot/arm/include/sys.h:919:23: note: if this code is reached, the program will abort Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 0160605444e7..856249a11890 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -862,7 +862,7 @@ int open(const char *path, int flags, ...) va_list args; va_start(args, flags); - mode = va_arg(args, mode_t); + mode = va_arg(args, int); va_end(args); } From patchwork Sat Jun 3 08:13:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B479C77B7A for ; Sat, 3 Jun 2023 08:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbjFCIN7 (ORCPT ); Sat, 3 Jun 2023 04:13:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIN7 (ORCPT ); Sat, 3 Jun 2023 04:13:59 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A19FE1B3; Sat, 3 Jun 2023 01:13:57 -0700 (PDT) X-QQ-mid: bizesmtp81t1685780027txyb6un4 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:13:46 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: OFQdrTmJ2CRnGX8nVsKHr+YHzlkPZt5cNCRThmliWSmaPWUuX+pWuPeCQB+Y8 JAfkpUn4w/DJAP1he/6M6/LIY+/AKW0VDoLH6gY98CM1dwtMvU3KdeSla8x9I65C6c0zhCD 5GVxav2Y/twBS7c81AJzmqjCmamH64ivTPSG5MEs0J7mbN5L9hQhZlHZVC6T4MhKNkYBx2n AAzFJJ+WvSyRQD+Y28jCE+3/LpyzXP+sN05kqIsroD8fn1ddQxDdAblDbh0421O0z2ZpRAe eTYQNVt7ysvNJbIEPEkE1QtaKOM4UOF1bIDUVEBFZUwhVUUYB9VMT/5bDGhPMDlKzmP1kk/ EVzZu8CpRkCu6YK13JMMnBVFyCE0Tke3T/K0PmxriXuJIVr8KaQ3IRdq8GrMUdI5vs59tVX X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1522453405928296276 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 09/12] selftests/nolibc: support two errnos with EXPECT_SYSER2() Date: Sat, 3 Jun 2023 16:13:40 +0800 Message-Id: <220827b791ed94a465d03545caa490fdbbd47d1f.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.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. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/ 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 a8fcad801cf2..a1c402ce32f4 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 Sat Jun 3 08:14: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: 13266111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F04D0C77B7A for ; Sat, 3 Jun 2023 08:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbjFCIPL (ORCPT ); Sat, 3 Jun 2023 04:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIPK (ORCPT ); Sat, 3 Jun 2023 04:15:10 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12AB71B3; Sat, 3 Jun 2023 01:15:08 -0700 (PDT) X-QQ-mid: bizesmtp86t1685780099tqgbsuv9 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:14:58 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: r/cTxDoDoiFSJcynUBZ645fSSLznEC5jgi3uRP7p6xwjwJ8yn76kBQYvv1+GG iSipIpMWgeICdSXmOhHNqLO/hOb9a5g5856OSS72uk43s6aREo8TPK0o30mBeug9pyUBLrA ZiLJ8k7sA6+0MXELj+RZn+XGSSA3Q/ntnx/vUhzeGoY2kBexAX2DklILwcrBfrSx9afdubX 497b/Fry/Cf0DfK9l+fgBCU+RlJuaZonwfKrkQFZ1LqdSm2vkoorwENzGUUoJWn62agPV3l x6N4lgt6iYLXz2z/uvnNqE1SuEJs29gQz+108F2wiJv9flrYxecsaTZHFgzU5qNIgNKyV55 67KtRV6ZoEdOMjWid/N6HLbKZ6RVvaA0n+W19QwOz6ykH3goDRIarP5h2O/snuiSaYfMmm+ X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8443338395293632196 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v3 10/12] selftests/nolibc: remove gettimeofday_bad1/2 completely Date: Sat, 3 Jun 2023 16:14:55 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.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. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/ 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 a1c402ce32f4..bf63fc66e486 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -588,10 +588,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 Sat Jun 3 08:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEFB1C77B7A for ; Sat, 3 Jun 2023 08:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbjFCIQ3 (ORCPT ); Sat, 3 Jun 2023 04:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIQ2 (ORCPT ); Sat, 3 Jun 2023 04:16:28 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E9F1B3; Sat, 3 Jun 2023 01:16:26 -0700 (PDT) X-QQ-mid: bizesmtp77t1685780177tiq7j5j8 Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:16:15 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: hoArX50alxFFZWWL2Wyj1D3SOa6jZE2VhGESBJVTnGUig23E/NM6osFUoAejc ZMnT/lOPYyAss5rGMd5FNaLZyAovm6YOd7t29lhWCVjscHA33su6FF+MkKHvlCsNyzW3iet QTTEeqpyfmlHlPe16kFQ8T//b0we/bCoXaw76jfP8nhXhjqXglXlhb3mLhsjItcfXzOcVsn ow6D/k9IEf0Q7tF/wtaReG1iUW2jRUByaH8tMIGBtv/FkX2Uc9m49rBTvnu33BAK+aeG/eg wXrlbRPV63CeKIcUmlwSnu2AEvTkhVFGK0euwG0yyMpM1m0Px8nY0Z8nIOFF+ohSORa7fjN dNu7jD6jHWXx5n2wUcEz9LxNYZixsgris0WcF8ROqihn3JWeCY2apZ5A0RrzSKN4dZp/MJx BVUWy7RiVqo= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8375714549719897536 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, 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 v3 11/12] selftests/nolibc: add new gettimeofday test cases Date: Sat, 3 Jun 2023 16:16:07 +0800 Message-Id: <68dace9e2532316ff454894697ecfd99e419a523.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org These 2 test cases are added to cover the normal using scenes of gettimeofday(). They have been used to trigger and fix up such issue with nolibc: nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod' This issue happens while there is no "unsigned int" conversion in the coming new clock_gettime / clock_gettime64 syscall path of gettimeofday(): tv->tv_usec = ts.tv_nsec / 1000; Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/linux-riscv/280867a8-7601-4a96-9b85-87668e1f1282@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index bf63fc66e486..e68c5692ec54 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -533,6 +533,8 @@ static int test_stat_timestamps(void) */ int run_syscall(int min, int max) { + struct timeval tv; + struct timezone tz; struct stat stat_buf; int euid0; int proc; @@ -588,6 +590,8 @@ 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; + CASE_TEST(gettimeofday_tv); EXPECT_SYSZR(1, gettimeofday(&tv, NULL)); break; + CASE_TEST(gettimeofday_tv_tz);EXPECT_SYSZR(1, gettimeofday(&tv, &tz)); break; CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; From patchwork Sat Jun 3 08:17:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13266113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80A69C77B7A for ; Sat, 3 Jun 2023 08:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbjFCIRy (ORCPT ); Sat, 3 Jun 2023 04:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjFCIRx (ORCPT ); Sat, 3 Jun 2023 04:17:53 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE5AE56; Sat, 3 Jun 2023 01:17:50 -0700 (PDT) X-QQ-mid: bizesmtp77t1685780261tx6oj29b Received: from linux-lab-host.localdomain ( [119.123.130.226]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Jun 2023 16:17:40 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: E5K4RXiq5f16O7Lg/ibaIwDGJ/dBM+SgASgVWJNrZJ0DycLMa61F85p3zn/s0 pmVP+uUxVO+uRq/qEVaGBrw6dy5nIj47egVC3sA8D6LyXOmfE2qgnjJAplThr2LHojLED11 dN48gvX6BDj+6ZskNGLKC05GNgBi/1WsGLb1E+3d17NhlPgK0/LzJRM0pb94DuYlP0Nmb59 w/YBaNODEaG8SfvzKEIj3lR1qDDwBvXpe5afs1A1FBfiTrIN0OgVeJJbKuaREYCdlovpmwR TbYhxWH70C7N9rrtU2bVFSPPjUczDufHPnteLBOjhwo549unG3iUV5HoN68eGMNqiD9QnOE Mbf4IaVts3z35QJQ2XUbnjfxanJ+JTJpIGiU/3+zwyVM15wQhyWDL98jOVCeDUWXeWyrFpD X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11015261677064545706 From: Zhangjin Wu To: w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, 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 v3 12/12] selftests/nolibc: test_fork: fix up duplicated print Date: Sat, 3 Jun 2023 16:17:25 +0800 Message-Id: <4e090aff64abeca598d1bb6ee54b40ee4ce52858.1685777982.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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org running nolibc-test with glibc on x86_64 got such print issue: 29 execve_root = -1 EACCES [OK] 30 fork30 fork = 0 [OK] 31 getdents64_root = 712 [OK] The fork test case has three printf calls: (1) llen += printf("%d %s", test, #name); (2) llen += printf(" = %d %s ", expr, errorname(errno)); (3) llen += pad_spc(llen, 64, "[FAIL]\n"); --> vfprintf() In the following scene, the above issue happens: (a) The parent calls (1) (b) The parent calls fork() (c) The child runs and shares the print buffer of (1) (d) The child exits, flushs the print buffer and closes its own stdout/stderr * "30 fork" is printed at the first time. (e) The parent calls (2) and (3), with "\n" in (3), it flushs the whole buffer * "30 fork = 0 ..." is printed Therefore, there are two "30 fork" in the stdout. Between (a) and (b), if flush the stdout (and the sterr), the child in stage (c) will not be able to 'see' the print buffer. Reviewed-by: Thomas Weißschuh Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index e68c5692ec54..7dd950879161 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -490,7 +490,13 @@ static int test_getpagesize(void) static int test_fork(void) { int status; - pid_t pid = fork(); + pid_t pid; + + /* flush the printf buffer to avoid child flush it */ + fflush(stdout); + fflush(stderr); + + pid = fork(); switch (pid) { case -1: