public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <cover.1684425792.git.falcon@tinylab.org> (raw)

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(-)

-- 
2.25.1



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2023-05-18 17:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 17:00 Zhangjin Wu [this message]
2023-05-18 17:02 ` [PATCH 1/2] tools/nolibc: riscv: Fix up load/store instructions for rv32 Zhangjin Wu
2023-05-20  8:50   ` Willy Tarreau
2023-05-20  9:11     ` Zhangjin Wu
2023-05-20  9:33       ` Willy Tarreau
2023-05-20 10:05         ` Zhangjin Wu
2023-05-20 10:20           ` Willy Tarreau
2023-05-18 17:03 ` [PATCH 2/2] tools/nolibc: riscv: Support __NR_llseek " Zhangjin Wu
2023-05-19  9:40 ` [PATCH 0/2] tools/nolibc: riscv: Fix up compile error " Willy Tarreau
2023-05-19 10:11   ` Thomas Weißschuh
2023-05-19 10:19     ` Willy Tarreau
2023-05-20  7:18       ` Thomas Weißschuh
2023-05-20  8:46         ` Willy Tarreau
2023-05-20 14:31   ` Zhangjin Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1684425792.git.falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulmck@kernel.org \
    --cc=w@1wt.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox