<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/tools/include/nolibc/sys.h, branch v6.6.134</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.134</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.134'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2023-08-23T03:17:07+00:00</updated>
<entry>
<title>tools/nolibc: avoid undesired casts in the __sysret() macro</title>
<updated>2023-08-23T03:17:07+00:00</updated>
<author>
<name>Willy Tarreau</name>
<email>w@1wt.eu</email>
</author>
<published>2023-08-15T11:55:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=556fb7131e03b0283672fb40f6dc2d151752aaa7'/>
<id>urn:sha1:556fb7131e03b0283672fb40f6dc2d151752aaa7</id>
<content type='text'>
Having __sysret() as an inline function has the unfortunate effect of
adding casts and large constants comparisons after the syscall returns
that significantly inflate some light code that's otherwise syscall-
heavy. Even nolibc-test grew by ~1%.

Let's switch back to a macro for this, and use it only with signed
arguments. Note that it is also possible to design a slightly more
complex macro covering unsigned and pointers but we only have 3 such
syscalls so it is pointless, and these were just addressed not to use
this macro anymore. Now for the argument (the local variable containing
the syscall return value), any negative value is an error, that results
in -1 being returned and errno to be assigned the opposite value.

This may be revisited again in the future if really needed but for now
let's get back to something sane.

Fixes: 428905da6ec4 ("tools/nolibc: sys.h: add a syscall return helper")
Link: https://lore.kernel.org/lkml/20230806095846.GB10627@1wt.eu/
Link: https://lore.kernel.org/lkml/ZNKOJY+g66nkIyvv@1wt.eu/
Cc: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Cc: David Laight &lt;David.Laight@ACULAB.COM&gt;
Cc: Thomas Weißschuh &lt;thomas@t-8ch.de&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: keep brk(), sbrk(), mmap() away from __sysret()</title>
<updated>2023-08-23T03:19:22+00:00</updated>
<author>
<name>Willy Tarreau</name>
<email>w@1wt.eu</email>
</author>
<published>2023-08-15T11:44:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fb01ff635efd0aba862c843587554167aacc4d2f'/>
<id>urn:sha1:fb01ff635efd0aba862c843587554167aacc4d2f</id>
<content type='text'>
The __sysret() function causes some undesirable casts so we'll revert
it. In order to keep it simple it will now only support integer return
values like in the past, so we must basically revert the changes that
were made to these 3 syscalls which return a pointer so that they
simply rely on their own test and the SET_ERRNO() macro.

Fixes: 4201cfce15fe ("tools/nolibc: clean up sbrk() routine")
Fixes: 924e9539aeaa ("tools/nolibc: clean up mmap() routine")
Fixes: d27447bc2e0a ("tools/nolibc: sys.h: apply __sysret() helper")
Link: https://lore.kernel.org/lkml/20230806095846.GB10627@1wt.eu/
Link: https://lore.kernel.org/lkml/ZNKOJY+g66nkIyvv@1wt.eu/
Cc: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Cc: David Laight &lt;David.Laight@ACULAB.COM&gt;
Cc: Thomas Weißschuh &lt;thomas@t-8ch.de&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: sys: avoid implicit sign cast</title>
<updated>2023-08-23T03:17:07+00:00</updated>
<author>
<name>Thomas Weißschuh</name>
<email>linux@weissschuh.net</email>
</author>
<published>2023-08-03T07:28:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=04694658ad4a7df13a74160864d87ab858a9da53'/>
<id>urn:sha1:04694658ad4a7df13a74160864d87ab858a9da53</id>
<content type='text'>
getauxval() returns an unsigned long but the overall type of the ternary
operator needs to be signed.

Signed-off-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: fix return type of getpagesize()</title>
<updated>2023-08-23T03:17:07+00:00</updated>
<author>
<name>Thomas Weißschuh</name>
<email>linux@weissschuh.net</email>
</author>
<published>2023-08-03T07:28:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=640775022572380b6f78247f10c036e69d404947'/>
<id>urn:sha1:640775022572380b6f78247f10c036e69d404947</id>
<content type='text'>
It's documented as returning int which is also implemented by glibc and
musl, so adopt that return type.

Signed-off-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: drop unused variables</title>
<updated>2023-08-23T03:17:07+00:00</updated>
<author>
<name>Thomas Weißschuh</name>
<email>linux@weissschuh.net</email>
</author>
<published>2023-08-03T07:28:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f2f5eaefa17e4c432ffd22577682c21543ee39cf'/>
<id>urn:sha1:f2f5eaefa17e4c432ffd22577682c21543ee39cf</id>
<content type='text'>
Nobody needs it, get rid of it.

Signed-off-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: add pipe() and pipe2() support</title>
<updated>2023-08-23T03:17:07+00:00</updated>
<author>
<name>Yuan Tan</name>
<email>tanyuan@tinylab.org</email>
</author>
<published>2023-08-01T15:39:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3ec38af6eedb1659f4a2b0350f61782952dd50b7'/>
<id>urn:sha1:3ec38af6eedb1659f4a2b0350f61782952dd50b7</id>
<content type='text'>
According to manual page [1], posix spec [2] and source code like
arch/mips/kernel/syscall.c, for historic reasons, the sys_pipe() syscall
on some architectures has an unusual calling convention.  It returns
results in two registers which means there is no need for it to do
verify the validity of a userspace pointer argument.  Historically that
used to be expensive in Linux.  These days the performance advantage is
negligible.

Nolibc doesn't support the unusual calling convention above, luckily
Linux provides a generic sys_pipe2() with an additional flags argument
from 2.6.27. If flags is 0, then pipe2() is the same as pipe(). So here
we use sys_pipe2() to implement the pipe().

pipe2() is also provided to allow users to use flags argument on demand.

[1]: https://man7.org/linux/man-pages/man2/pipe.2.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/pipe.html

Suggested-by: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Link: https://lore.kernel.org/all/20230729100401.GA4577@1wt.eu/
Signed-off-by: Yuan Tan &lt;tanyuan@tinylab.org&gt;
Reviewed-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: remove the old sys_stat support</title>
<updated>2023-08-23T02:40:22+00:00</updated>
<author>
<name>Zhangjin Wu</name>
<email>falcon@tinylab.org</email>
</author>
<published>2023-07-15T18:20:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=af93807eaef689a4964fdec085c77c24b49a5560'/>
<id>urn:sha1:af93807eaef689a4964fdec085c77c24b49a5560</id>
<content type='text'>
The statx manpage [1] shows that it has been supported from Linux 4.11
and glibc 2.28, the Linux support can be checked for all of the
architectures with this command:

    $ git grep -r statx v4.11 arch/ include/uapi/asm-generic/unistd.h \
      | grep -E "aarch64|arm|mips|s390|x86|:include/uapi"

Besides riscv and loongarch, all of the nolibc supported architectures
have added sys_statx from Linux v4.11. riscv is mainlined to v4.15,
loongarch is mainlined to v5.19, both of them use the generic unistd.h,
so, they have added sys_statx from their first mainline versions.

The current oldest stable branch is v4.14, only reserving sys_statx
still preserves compatibility with all of the supported stable branches,
So, let's remove the old arch related and dependent sys_stat support
completely.

This is friendly to the future new architecture porting.

[1]: https://man7.org/linux/man-pages/man2/statx.2.html

Signed-off-by: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: add rmdir() support</title>
<updated>2023-08-23T02:38:02+00:00</updated>
<author>
<name>Zhangjin Wu</name>
<email>falcon@tinylab.org</email>
</author>
<published>2023-07-07T18:34:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f4191f3d524289080284fa3a48ccd096b319d280'/>
<id>urn:sha1:f4191f3d524289080284fa3a48ccd096b319d280</id>
<content type='text'>
a reverse operation of mkdir() is meaningful, add rmdir() here.

required by nolibc-test to remove /proc while CONFIG_PROC_FS is not
enabled.

Reviewed-by: Thomas Weißschuh &lt;linux@weissschuh.net&gt;
Signed-off-by: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: types.h: add RB_ flags for reboot()</title>
<updated>2023-08-23T02:38:02+00:00</updated>
<author>
<name>Zhangjin Wu</name>
<email>falcon@tinylab.org</email>
</author>
<published>2023-07-07T18:29:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=788aca91ab5e4cccae158aac03a1d653c6da2fde'/>
<id>urn:sha1:788aca91ab5e4cccae158aac03a1d653c6da2fde</id>
<content type='text'>
Both glibc and musl provide RB_ flags via &lt;sys/reboot.h&gt; for reboot(),
they don't need to include &lt;linux/reboot.h&gt;, let nolibc provide RB_
flags too.

Signed-off-by: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
<entry>
<title>tools/nolibc: clean up sbrk() routine</title>
<updated>2023-08-23T02:38:02+00:00</updated>
<author>
<name>Zhangjin Wu</name>
<email>falcon@tinylab.org</email>
</author>
<published>2023-07-07T14:59:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4201cfce15fe35d9d90ae870aba12eb84c0452ab'/>
<id>urn:sha1:4201cfce15fe35d9d90ae870aba12eb84c0452ab</id>
<content type='text'>
Fix up the error reported by scripts/checkpatch.pl:

    ERROR: do not use assignment in if condition
    #95: FILE: tools/include/nolibc/sys.h:95:
    +	if ((ret = sys_brk(0)) &amp;&amp; (sys_brk(ret + inc) == ret + inc))

Apply the new generic __sysret() to merge the SET_ERRNO() and return
lines.

Signed-off-by: Zhangjin Wu &lt;falcon@tinylab.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
</entry>
</feed>
