Message ID | cover.1684425792.git.falcon@tinylab.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp646318vqo; Thu, 18 May 2023 10:03:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YI2HhqVbBokc5MIVNtOQRtpl86JTZeiAIM5x4Q78rI1ZengaQ5xYOMIziE4ATe91ni+QU X-Received: by 2002:a17:902:904a:b0:1ad:1c29:80ef with SMTP id w10-20020a170902904a00b001ad1c2980efmr3319505plz.18.1684429416323; Thu, 18 May 2023 10:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684429416; cv=none; d=google.com; s=arc-20160816; b=uRMAtz+Ob1MNIG6QwJYPz5kL7cqZiP17OewKhKZV2ZJYRDRoXcuYlRyslektinknZJ 2vTB3m3+puuZzT3IIF94NAT3T0xWqD4W2Ed6m4qEg9G2p//3PSHtoM2ZaRKY2mpJ0ooC 5Zt6KS/RgrwmgcWJG+aMmLXG7Q7w/iFWeK49jQrH4Ytx7MQ7RsLJ2gQB6/9tf+JVhPlc q8c/aQAf0nC+JSqYIcMuQDBGR9qtHuJHrT+zIy9vgbAHhyobYMIeJhkozjNyGSMVYEMt B7KaOiLeD0wtVf411fdLB3vBAs9LVqJ6Z1fZc65sGPIm70TttDv0t5pj6FasKMUwB0eh fcqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=PPizcCMP3j8Nfihqjpujxt0JMYz1l2hgKkasFmvxwoI=; b=wUbA6QGTC1VhKTK3IokQOYmFidfzGP18vZ+AItUKy3AruRmv/QeNiIVHf1iTr3Bpep lgxrP0x7nZyTDm1Ua1mfzBWqQaKocwcVQmMLHfHzgq9swY1H2UgRuefjgUqf6O0XX07a mzbaMG4xDOcyxQAWjsssinAaUSgPGcPyyeifMVz3XyE9XXRbMWqcQJQODxg6zYLGEntf R6AO2RZtO0zL+tMaw6Zc4TV7jfYdStVOxIYwnDrBRf42kxlXXI32U095tiX/Jkeq5Hr5 C7kn0tyEa601NT/I1nWPLtzf33yhjSDYEtwIpB8ovNoIwdtckGcyjm4cv3y9jGXJg627 WlKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a170902e81000b001a6fe422894si1830202plg.200.2023.05.18.10.03.19; Thu, 18 May 2023 10:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbjERRAx (ORCPT <rfc822;pacteraone@gmail.com> + 99 others); Thu, 18 May 2023 13:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjERRAv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 18 May 2023 13:00:51 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D7019A for <linux-kernel@vger.kernel.org>; Thu, 18 May 2023 10:00:49 -0700 (PDT) X-QQ-mid: bizesmtp74t1684429236tgelvkjl Received: from linux-lab-host.localdomain ( [119.123.131.162]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 19 May 2023 01:00:35 +0800 (CST) X-QQ-SSF: 01200000000000C0V000000A0000000 X-QQ-FEAT: pauNAy/IFzO0FaQLOne96cFwWdA59Rv4ZuUqOLkZM5vji7bwoCZfS5oHPCMNR 48M0RE4xcp7ioGHPUTFDmgZNOj8L11HPDeSMZPI0b90K7Jv+Nh32m0kmQ/2eJDuBvjU0nqD rxRFk0z2JlwsVGj4O80PV9hisxKncI9YGz+2lJz8YJD6bD5Y9UciT6oVEee6jfpaq2bfKEA HrD0t1VI81q3uNLbr20tgc4tHuur1dy5sG9LiLuwTGWsdB+Ran0iTH52kg5yFFbiLmaHExg 827Tca72h1Yfy+ko7CRNn0mNtrcWNhrkvV0LKlT9CQZGKoU3nBQ6UtJRYrfJm5RWfHgD2cs y77EH3kjkfWGDxkRos= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4878818344533688938 From: Zhangjin Wu <falcon@tinylab.org> To: Willy Tarreau <w@1wt.eu>, Palmer Dabbelt <palmer@rivosinc.com>, Paul Walmsley <paul.walmsley@sifive.com>, Albert Ou <aou@eecs.berkeley.edu> Cc: "Paul E . McKenney" <paulmck@kernel.org>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Zhangjin Wu <falcon@tinylab.org> Subject: [PATCH 0/2] tools/nolibc: riscv: Fix up compile error for rv32 Date: Fri, 19 May 2023 01:00:18 +0800 Message-Id: <cover.1684425792.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766252259302679802?= X-GMAIL-MSGID: =?utf-8?q?1766252259302679802?= |
Series |
tools/nolibc: riscv: Fix up compile error for rv32
|
|
Message
Zhangjin Wu
May 18, 2023, 5 p.m. UTC
Hi, Willy nolibc for riscv is only tested for rv64 currently (see tools/testing/selftests/nolibc/Makefile), this patchset tries to let it compile for rv32, but still not pass the nolibc selftest: * The first patch uses lw/sw instead of ld/sd for rv32 and verse-vice for rv64 * This patch may conflict with the stackprotector patch [1], because both of them changed the _start assembly in arch-riscv.h * The second patch adds __NR_llseek based sys_lseek implementation for rv32 * There is no __NR_lseek for rv32, see include/uapi/asm-generic/unistd.h * This code is based on the version from glibc, sysdeps/unix/sysv/linux/lseek.c * It passed the two lseek tests in nolibc selftest (write a test case manually) * To let it compile for rv32, we still need to apply one of such actions: * Revert the kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), but it is not the right direction, that commit has removed all of the time32 syscalls, and let C lib (e.g. glibc) provide the same C APIs based on the other time64 syscalls * If not really use any of the time32 syscalls, defining __ARCH_WANT_TIME32_SYSCALLS macro will let it compile, but this is buggy for the current implmentations are based on time32 syscalls! * Really implement the C APIs for rv32, based on the time64 syscalls, just like glibc. This commit c8ce48f06503 ("asm-generic: Make time32 syscall numbers optional") shows us which functions should be re-implemented. So, the work todo for rv32 is: * Rebasing all of the old time32 syscalls based C APIs on the new time64 syscalls, but they are not simply mapped one by one, glibc is a good reference. * Add standalone rv32 test support in tools/testing/selftests/nolibc/ Best Regards, Zhangjin Wu [1]: https://lore.kernel.org/linux-riscv/mhng-1ec176a9-ec5d-470b-a278-a4e9cec728a8@palmer-ri-x1c9a/ Zhangjin Wu (2): tools/nolibc: riscv: Fix up load/store instructions for rv32 tools/nolibc: riscv: Support __NR_llseek for rv32 tools/include/nolibc/arch-riscv.h | 14 +++++++++----- tools/include/nolibc/std.h | 1 + tools/include/nolibc/sys.h | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-)
Comments
Hi Zhangjin, On Fri, May 19, 2023 at 01:00:18AM +0800, Zhangjin Wu wrote: > Hi, Willy > > nolibc for riscv is only tested for rv64 currently (see > tools/testing/selftests/nolibc/Makefile), this patchset tries to let it > compile for rv32, but still not pass the nolibc selftest: > > * The first patch uses lw/sw instead of ld/sd for rv32 and verse-vice for rv64 > * This patch may conflict with the stackprotector patch [1], because > both of them changed the _start assembly in arch-riscv.h That's quite embarrassing, I'm having to trace of that series here. Now I can find it in my LKML archives, but I don't have the direct message and didn't spot the other ones. I'll have to investigate, thanks for notifying me! I'm CCing Thomas, I will check with him how to best merge the two. > * The second patch adds __NR_llseek based sys_lseek implementation for rv32 > * There is no __NR_lseek for rv32, see include/uapi/asm-generic/unistd.h > * This code is based on the version from glibc, sysdeps/unix/sysv/linux/lseek.c > * It passed the two lseek tests in nolibc selftest (write a test case manually) OK. > * To let it compile for rv32, we still need to apply one of such actions: > * Revert the kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), > but it is not the right direction, that commit has removed all of the time32 syscalls, > and let C lib (e.g. glibc) provide the same C APIs based on the other time64 syscalls > > * If not really use any of the time32 syscalls, defining __ARCH_WANT_TIME32_SYSCALLS > macro will let it compile, but this is buggy for the current implmentations are based > on time32 syscalls! > > * Really implement the C APIs for rv32, based on the time64 syscalls, just like glibc. > This commit c8ce48f06503 ("asm-generic: Make time32 syscall numbers optional") shows > us which functions should be re-implemented. > > So, the work todo for rv32 is: > > * Rebasing all of the old time32 syscalls based C APIs on the new time64 syscalls, > but they are not simply mapped one by one, glibc is a good reference. > > * Add standalone rv32 test support in tools/testing/selftests/nolibc/ I'm not the right one to judge how to best support rv32 but at least I just don't want to go backwards. I'm just having a probably stupid question, but how relevant is rv32 ? I mean, all the boards I've seen to date were based on rv64 even the smallest embedded ones, so I'm sincerely wondering if there exists at all any rv32 devices capable of running Linux. Because if that's not the case, maybe we should instead declare that we only support rv64 ? If such devices exist however, I'm all for us supporting them well. Thanks, Willy
Hi Willy, On 2023-05-19 11:40:30+0200, Willy Tarreau wrote: > Hi Zhangjin, > > On Fri, May 19, 2023 at 01:00:18AM +0800, Zhangjin Wu wrote: > > Hi, Willy > > > > nolibc for riscv is only tested for rv64 currently (see > > tools/testing/selftests/nolibc/Makefile), this patchset tries to let it > > compile for rv32, but still not pass the nolibc selftest: > > > > * The first patch uses lw/sw instead of ld/sd for rv32 and verse-vice for rv64 > > * This patch may conflict with the stackprotector patch [1], because > > both of them changed the _start assembly in arch-riscv.h > > That's quite embarrassing, I'm having to trace of that series here. Now > I can find it in my LKML archives, but I don't have the direct message and > didn't spot the other ones. I'll have to investigate, thanks for notifying > me! I'm CCing Thomas, I will check with him how to best merge the two. I think the conflict should be trivial to fix. I can also resend my series or just the single riscv patch. <snip> Thomas
On Fri, May 19, 2023 at 12:11:00PM +0200, Thomas Weißschuh wrote: > Hi Willy, > > On 2023-05-19 11:40:30+0200, Willy Tarreau wrote: > > Hi Zhangjin, > > > > On Fri, May 19, 2023 at 01:00:18AM +0800, Zhangjin Wu wrote: > > > Hi, Willy > > > > > > nolibc for riscv is only tested for rv64 currently (see > > > tools/testing/selftests/nolibc/Makefile), this patchset tries to let it > > > compile for rv32, but still not pass the nolibc selftest: > > > > > > * The first patch uses lw/sw instead of ld/sd for rv32 and verse-vice for rv64 > > > * This patch may conflict with the stackprotector patch [1], because > > > both of them changed the _start assembly in arch-riscv.h > > > > That's quite embarrassing, I'm having to trace of that series here. Now > > I can find it in my LKML archives, but I don't have the direct message and > > didn't spot the other ones. I'll have to investigate, thanks for notifying > > me! I'm CCing Thomas, I will check with him how to best merge the two. > > I think the conflict should be trivial to fix. > > I can also resend my series or just the single riscv patch. OK then I'll pick Zhangjin's series and will apply yours on top of it. Do not bother resending the whole series, only the riscv patch will be sufficient, I have the rest of your series in my lkml mbox. Thanks! Willy
On 2023-05-19 12:19:10+0200, Willy Tarreau wrote: > On Fri, May 19, 2023 at 12:11:00PM +0200, Thomas Weißschuh wrote: > > Hi Willy, > > > > On 2023-05-19 11:40:30+0200, Willy Tarreau wrote: > > > Hi Zhangjin, > > > > > > On Fri, May 19, 2023 at 01:00:18AM +0800, Zhangjin Wu wrote: > > > > Hi, Willy > > > > > > > > nolibc for riscv is only tested for rv64 currently (see > > > > tools/testing/selftests/nolibc/Makefile), this patchset tries to let it > > > > compile for rv32, but still not pass the nolibc selftest: > > > > > > > > * The first patch uses lw/sw instead of ld/sd for rv32 and verse-vice for rv64 > > > > * This patch may conflict with the stackprotector patch [1], because > > > > both of them changed the _start assembly in arch-riscv.h > > > > > > That's quite embarrassing, I'm having to trace of that series here. Now > > > I can find it in my LKML archives, but I don't have the direct message and > > > didn't spot the other ones. I'll have to investigate, thanks for notifying > > > me! I'm CCing Thomas, I will check with him how to best merge the two. > > > > I think the conflict should be trivial to fix. > > > > I can also resend my series or just the single riscv patch. > > OK then I'll pick Zhangjin's series and will apply yours on top of it. > Do not bother resending the whole series, only the riscv patch will be > sufficient, I have the rest of your series in my lkml mbox. Could you let me know if or when your are publishing your integration branch? Thomas
Hi Thomas, On Sat, May 20, 2023 at 09:18:25AM +0200, Thomas Weißschuh wrote: > On 2023-05-19 12:19:10+0200, Willy Tarreau wrote: > > On Fri, May 19, 2023 at 12:11:00PM +0200, Thomas Weißschuh wrote: > > > Hi Willy, > > > > > > On 2023-05-19 11:40:30+0200, Willy Tarreau wrote: > > > > Hi Zhangjin, > > > > > > > > On Fri, May 19, 2023 at 01:00:18AM +0800, Zhangjin Wu wrote: > > > > > Hi, Willy > > > > > > > > > > nolibc for riscv is only tested for rv64 currently (see > > > > > tools/testing/selftests/nolibc/Makefile), this patchset tries to let it > > > > > compile for rv32, but still not pass the nolibc selftest: > > > > > > > > > > * The first patch uses lw/sw instead of ld/sd for rv32 and verse-vice for rv64 > > > > > * This patch may conflict with the stackprotector patch [1], because > > > > > both of them changed the _start assembly in arch-riscv.h > > > > > > > > That's quite embarrassing, I'm having to trace of that series here. Now > > > > I can find it in my LKML archives, but I don't have the direct message and > > > > didn't spot the other ones. I'll have to investigate, thanks for notifying > > > > me! I'm CCing Thomas, I will check with him how to best merge the two. > > > > > > I think the conflict should be trivial to fix. > > > > > > I can also resend my series or just the single riscv patch. > > > > OK then I'll pick Zhangjin's series and will apply yours on top of it. > > Do not bother resending the whole series, only the riscv patch will be > > sufficient, I have the rest of your series in my lkml mbox. > > Could you let me know if or when your are publishing your integration > branch? Just finished it now, I had to manually rebase all patches and had to interrupt it yesterday. You'll find it here: https://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git 20230520-nolibc-rv32+stkp It contains a temporary series made of: - Zhangjin's RV32 patches - your syscall() patch - your stkp series except the riscv one so that you just need to update the riscv one and that will be fine. Be careful, I have *not* restested the riscv port. As usual, do not hesitate to le me know if I messed up with anything. Thanks! Willy
Hi Willy, > Hi Zhangjin, > > On Fri, May 19, 2023 at 01:00:18AM +0800, Zhangjin Wu wrote: > ... > > > * To let it compile for rv32, we still need to apply one of such actions: > > * Revert the kernel commit d4c08b9776b3 ("riscv: Use latest system call ABI"), > > but it is not the right direction, that commit has removed all of the time32 syscalls, > > and let C lib (e.g. glibc) provide the same C APIs based on the other time64 syscalls > > > > * If not really use any of the time32 syscalls, defining __ARCH_WANT_TIME32_SYSCALLS > > macro will let it compile, but this is buggy for the current implmentations are based > > on time32 syscalls! > > > > * Really implement the C APIs for rv32, based on the time64 syscalls, just like glibc. > > This commit c8ce48f06503 ("asm-generic: Make time32 syscall numbers optional") shows > > us which functions should be re-implemented. > > > > So, the work todo for rv32 is: > > > > * Rebasing all of the old time32 syscalls based C APIs on the new time64 syscalls, > > but they are not simply mapped one by one, glibc is a good reference. > > > > * Add standalone rv32 test support in tools/testing/selftests/nolibc/ > > I'm not the right one to judge how to best support rv32 but at least I just > don't want to go backwards. I'm just having a probably stupid question, but > how relevant is rv32 ? I mean, all the boards I've seen to date were based > on rv64 even the smallest embedded ones, so I'm sincerely wondering if there > exists at all any rv32 devices capable of running Linux. Because if that's > not the case, maybe we should instead declare that we only support rv64 ? > If such devices exist however, I'm all for us supporting them well. > Firstly, as the commit c8ce48f06503 ("asm-generic: Make time32 syscall numbers optional") shows: We don't want new architectures to even provide the old 32-bit time_t based system calls any more, or define the syscall number macros. So, this is not rv32 specific, more and more architectures are trying to use the generic unistd.h (include/uapi/asm-generic/unistd.h), but rv32 may be the first new architecture variant who have no time32 syscalls. Second, I did search some rv32 socs/boards from two companies, they are bl602/bl616/bl702, esp32-c2/c3/c6, some of them even have 532KB sRAM which is enough for nolibc-based app + linux kernel, I have gotten 334K rv64 vmlinuz (+nolibc hello.c) in the tinylinux work for riscv, the future work may be running linux on such a real rv32 board ;-) Best regards, Zhangjin Wu > Thanks, > Willy