mbox series

[v4,00/10] tools/nolibc: add a new syscall helper

Message ID cover.1687187451.git.falcon@tinylab.org (mailing list archive)
Headers show
Series tools/nolibc: add a new syscall helper | expand

Message

Zhangjin Wu June 19, 2023, 3:40 p.m. UTC
Hi, Thomas, David, Willy

Thanks very much for your kindly review.

This is the revision of v3 "tools/nolibc: add a new syscall helper" [1],
this mainly applies the suggestion from David in this reply [2] and
rebased everything on the dev.2023.06.14a branch of linux-rcu [3].

The old __sysret() doesn't support the syscalls with pointer return
value, this revision now supports such syscalls. The left mmap() syscall
is converted to use this new __sysret() with additional test cases.

Changes from v3 -> v4:

* tools/nolibc: sys.h: add a syscall return helper
  tools/nolibc: unistd.h: apply __sysret() helper
  tools/nolibc: sys.h: apply __sysret() helper

  The original v3 series, no code change, except the Reviewed-by lines
  from Thomas.

* tools/nolibc: unistd.h: reorder the syscall macros

  reorder the syscall macros in using order and align most of them.

* tools/nolibc: add missing my_syscall6() for mips

  required by mmap() syscall, this is the last missing my_syscall6().

* tools/nolibc: __sysret: support syscalls who return a pointer

  Apply suggestion from David.  

  Let __sysret() also supports syscalls with pointer return value, so, the
  return value is converted to unsigned long and the comparing of < 0 is
  converted to the comparing of [(unsigned long)-MAX_ERRNO, (unsigned long)-1].

  This also allows return a huge value (not pointer) with highest bit as 1.

  It is able to merge this one to the first one if necessary.

* tools/nolibc: clean up mmap() support

  Apply new __sysret(), clean up #ifdef and some macros.

* selftests/nolibc: add EXPECT_PTREQ, EXPECT_PTRNE and EXPECT_PTRER
  selftests/nolibc: add sbrk_0 to test current brk getting
  selftests/nolibc: add mmap and munmap test cases

  Add some mmap & munmap test cases and the corresponding helpers, to
  verify one of the new helpers, a sbrk_0 test case is also added.

Best regards,
Zhangjin
---
[1]: https://lore.kernel.org/linux-riscv/87e7a391-b97b-4001-b12a-76d20790563e@t-8ch.de/
[2]: https://lore.kernel.org/linux-riscv/94dd5170929f454fbc0a10a2eb3b108d@AcuMS.aculab.com/
[3]: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git/

Zhangjin Wu (10):
  tools/nolibc: sys.h: add a syscall return helper
  tools/nolibc: unistd.h: apply __sysret() helper
  tools/nolibc: sys.h: apply __sysret() helper
  tools/nolibc: unistd.h: reorder the syscall macros
  tools/nolibc: add missing my_syscall6() for mips
  tools/nolibc: __sysret: support syscalls who return a pointer
  tools/nolibc: clean up mmap() support
  selftests/nolibc: add EXPECT_PTREQ, EXPECT_PTRNE and EXPECT_PTRER
  selftests/nolibc: add sbrk_0 to test current brk getting
  selftests/nolibc: add mmap and munmap test cases

 tools/include/nolibc/arch-mips.h             |  26 ++
 tools/include/nolibc/nolibc.h                |   9 +-
 tools/include/nolibc/sys.h                   | 391 +++----------------
 tools/include/nolibc/types.h                 |  11 +
 tools/include/nolibc/unistd.h                |  13 +-
 tools/testing/selftests/nolibc/nolibc-test.c |  90 +++++
 6 files changed, 191 insertions(+), 349 deletions(-)

Comments

Zhangjin Wu June 28, 2023, 1:07 p.m. UTC | #1
Willy, Thomas

This is the revision of our 'tools/nolibc: add a new syscall helper'
series [1].

It mainly applies the core part of suggestions from Thomas (Many thanks)
and cleans up the multiple whitespaces issues reported by
scripts/checkpatch.pl.

Changes from v4 --> v5:

* tools/nolibc: sys.h: add a syscall return helper
  tools/nolibc: unistd.h: apply __sysret() helper
  tools/nolibc: sys.h: apply __sysret() helper
  tools/nolibc: unistd.h: reorder the syscall macros
  tools/nolibc: __sysret: support syscalls who return a pointer
  selftests/nolibc: add EXPECT_PTREQ, EXPECT_PTRNE and EXPECT_PTRER
  selftests/nolibc: add sbrk_0 to test current brk getting

    The same to original v4 series, no code change.

* tools/nolibc: string.h: clean up multiple whitespaces with tab
  tools/nolibc: arch-*.h: clean up multiple whitespaces
  tools/nolibc: arch-loongarch.h: shrink with SYSCALL_CLOBBERLIST
  tools/nolibc: arch-mips.h: shrink with SYSCALL_CLOBBERLIST

    Clean up the multiple whitespaces issues reported by
    scripts/checkpatch.pl, prepare for the coming mips my_syscall6()

    This cleanup is also required by another new arch shrink patchset.

    In v4, we didn't touch multiple whitespaces, because the
    changes are huge, but it is really important to do this
    before being always 'complained' by scripts/checkpatch.pl in the
    future.

* tools/nolibc: add missing my_syscall6() for mips

    Use tab instead of multiple whitespaces, let scripts/checkpatch.pl
    happy, also apply SYSCALL_CLOBBERLIST

* tools/nolibc: clean up mmap() support

    Include <linux/mman.h> and remove more macros from nolibc side.

    The return type of sys_mmap() is reserved as before, not changed
    currently.
  
* selftests/nolibc: add mmap and munmap test cases

    Applies some suggestions from Thomas,

    - Rebase length and offset on page_size and file_size

    - make sure the last offset argument is not always zero to test
      my_syscall6()

    - easier the for loop with NULL check

    - use /proc/1/exe and /proc/self/exe for run, run-user and libc-test

      but still reserve the old init files to align our another attempt
      to remove the unnecessary dependency on procfs (this is important
      to let developers happy to do all-architectures-test, the
      accumulated time cost and wait is really appreciable, it is really
      a pain for me to do repeated all-architectures-test for the new
      'minimal' kernel config patchset [2], a v2 is ready for it).

Best regards,
Zhangjin
---
[1]: https://lore.kernel.org/lkml/cover.1687187451.git.falcon@tinylab.org/
[2]: https://lore.kernel.org/lkml/cover.1687706332.git.falcon@tinylab.org/

Zhangjin Wu (14):
  tools/nolibc: sys.h: add a syscall return helper
  tools/nolibc: unistd.h: apply __sysret() helper
  tools/nolibc: sys.h: apply __sysret() helper
  tools/nolibc: unistd.h: reorder the syscall macros
  tools/nolibc: string.h: clean up multiple whitespaces with tab
  tools/nolibc: arch-*.h: clean up multiple whitespaces
  tools/nolibc: arch-loongarch.h: shrink with SYSCALL_CLOBBERLIST
  tools/nolibc: arch-mips.h: shrink with SYSCALL_CLOBBERLIST
  tools/nolibc: add missing my_syscall6() for mips
  tools/nolibc: __sysret: support syscalls who return a pointer
  tools/nolibc: clean up mmap() support
  selftests/nolibc: add EXPECT_PTREQ, EXPECT_PTRNE and EXPECT_PTRER
  selftests/nolibc: add sbrk_0 to test current brk getting
  selftests/nolibc: add mmap and munmap test cases

 tools/include/nolibc/arch-aarch64.h          | 210 +++++-----
 tools/include/nolibc/arch-arm.h              | 240 ++++++------
 tools/include/nolibc/arch-i386.h             | 226 +++++------
 tools/include/nolibc/arch-loongarch.h        | 219 +++++------
 tools/include/nolibc/arch-mips.h             | 241 ++++++------
 tools/include/nolibc/arch-riscv.h            | 208 +++++-----
 tools/include/nolibc/arch-s390.h             | 202 +++++-----
 tools/include/nolibc/arch-x86_64.h           | 222 +++++------
 tools/include/nolibc/nolibc.h                |   9 +-
 tools/include/nolibc/string.h                |   8 +-
 tools/include/nolibc/sys.h                   | 391 +++----------------
 tools/include/nolibc/types.h                 |   6 +
 tools/include/nolibc/unistd.h                |  13 +-
 tools/testing/selftests/nolibc/nolibc-test.c | 115 ++++++
 14 files changed, 1083 insertions(+), 1227 deletions(-)
Willy Tarreau July 2, 2023, 7:34 p.m. UTC | #2
On Wed, Jun 28, 2023 at 09:07:16PM +0800, Zhangjin Wu wrote:
> Willy, Thomas
> 
> This is the revision of our 'tools/nolibc: add a new syscall helper'
> series [1].
(...)

just to let you know that I've read them all and am fine with the ones
I didn't comment on.

Thanks Zhangjin!
Willy