]> www.infradead.org Git - users/dwmw2/linux.git/log
users/dwmw2/linux.git
2 months agoselftests: harness: Stop using setjmp()/longjmp()
Thomas Weißschuh [Mon, 5 May 2025 15:15:30 +0000 (17:15 +0200)]
selftests: harness: Stop using setjmp()/longjmp()

Usage of longjmp() was added to ensure that teardown is always run in
commit 63e6b2a42342 ("selftests/harness: Run TEARDOWN for ASSERT failures")
However instead of calling longjmp() to the teardown handler it is easier to
just call the teardown handler directly from __bail().
Any potential duplicate teardown invocations are harmless as the actual
handler will only ever be executed once since
commit fff37bd32c76 ("selftests/harness: Fix fixture teardown").

Additionally this removes a incompatibility with nolibc,
which does not support setjmp()/longjmp().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-12-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Add "variant" and "self" to test metadata
Thomas Weißschuh [Mon, 5 May 2025 15:15:29 +0000 (17:15 +0200)]
selftests: harness: Add "variant" and "self" to test metadata

To get rid of setjmp()/longjmp(), the variant and self need to be usable
from __bail().

Make them available from the test metadata.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-11-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Add teardown callback to test metadata
Thomas Weißschuh [Mon, 5 May 2025 15:15:28 +0000 (17:15 +0200)]
selftests: harness: Add teardown callback to test metadata

To get rid of setjmp()/longjmp(), the teardown logic needs to be usable
from __bail(). Introduce a new callback for it.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-10-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Move teardown conditional into test metadata
Thomas Weißschuh [Mon, 5 May 2025 15:15:27 +0000 (17:15 +0200)]
selftests: harness: Move teardown conditional into test metadata

To get rid of setjmp()/longjmp(), the teardown logic needs to be usable
from __bail(). To access the atomic teardown conditional from there,
move it into the test metadata.
This also allows the removal of "setup_completed".

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-9-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Don't set setup_completed for fixtureless tests
Thomas Weißschuh [Mon, 5 May 2025 15:15:26 +0000 (17:15 +0200)]
selftests: harness: Don't set setup_completed for fixtureless tests

This field is unused and has no meaning for tests without fixtures.
Don't set it for them.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-8-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Implement test timeouts through pidfd
Thomas Weißschuh [Mon, 5 May 2025 15:15:25 +0000 (17:15 +0200)]
selftests: harness: Implement test timeouts through pidfd

Make the kselftest harness compatible with nolibc which does not implement
signals by replacing the signal logic with pidfds.
The code also becomes simpler.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-7-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Remove dependency on libatomic
Thomas Weißschuh [Mon, 5 May 2025 15:15:24 +0000 (17:15 +0200)]
selftests: harness: Remove dependency on libatomic

__sync_bool_compare_and_swap() is deprecated and requires libatomic on
GCC. Compiler toolchains don't necessarily have libatomic available, so
avoid this requirement by using atomics that don't need libatomic.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-6-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Remove inline qualifier for wrappers
Thomas Weißschuh [Mon, 5 May 2025 15:15:23 +0000 (17:15 +0200)]
selftests: harness: Remove inline qualifier for wrappers

The pointers to the wrappers are stored in function pointers,
preventing them from actually being inlined.
Remove the inline qualifier, aligning these wrappers with the other
functions defined through macros.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-5-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Mark functions without prototypes static
Thomas Weißschuh [Mon, 5 May 2025 15:15:22 +0000 (17:15 +0200)]
selftests: harness: Mark functions without prototypes static

With -Wmissing-prototypes the compiler will warn about non-static
functions which don't have a prototype defined.
As they are not used from a different compilation unit they don't need to
be defined globally.

Avoid the issue by marking the functions static.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-4-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Ignore unused variant argument warning
Thomas Weißschuh [Mon, 5 May 2025 15:15:21 +0000 (17:15 +0200)]
selftests: harness: Ignore unused variant argument warning

For tests without fixtures the variant argument is unused.
This is intentional, prevent to compiler from complaining.

Example warning:

    harness-selftest.c: In function 'wrapper_standalone_pass':
    ../kselftest_harness.h:181:52: error: unused parameter 'variant' [-Werror=unused-parameter]
      181 |                 struct __fixture_variant_metadata *variant) \
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    ../kselftest_harness.h:156:25: note: in expansion of macro '__TEST_IMPL'
      156 | #define TEST(test_name) __TEST_IMPL(test_name, -1)
          |                         ^~~~~~~~~~~
    harness-selftest.c:15:1: note: in expansion of macro 'TEST'
       15 | TEST(standalone_pass) {
          | ^~~~

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-3-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Use C89 comment style
Thomas Weißschuh [Mon, 5 May 2025 15:15:20 +0000 (17:15 +0200)]
selftests: harness: Use C89 comment style

All comments in this file use C89 comment style.
Except for this one. Change it to get one step closer to C89
compatibility.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-2-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests: harness: Add kselftest harness selftest
Thomas Weißschuh [Mon, 5 May 2025 15:15:19 +0000 (17:15 +0200)]
selftests: harness: Add kselftest harness selftest

Add a selftest for the kselftest harness itself so any changes can be
validated.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250505-nolibc-kselftest-harness-v4-1-ee4dd5257135@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests/nolibc: drop include guards around standard headers
Thomas Weißschuh [Thu, 15 May 2025 19:57:55 +0000 (21:57 +0200)]
selftests/nolibc: drop include guards around standard headers

Nolibc now provides all the headers required by nolibc-test.c.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-9-74f82eea3b59@weissschuh.net
Acked-by: Willy Tarreau <w@1wt.eu>
2 months agotools/nolibc: move NULL and offsetof() to sys/stddef.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:54 +0000 (21:57 +0200)]
tools/nolibc: move NULL and offsetof() to sys/stddef.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-8-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move uname() and friends to sys/utsname.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:53 +0000 (21:57 +0200)]
tools/nolibc: move uname() and friends to sys/utsname.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-7-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move makedev() and friends to sys/sysmacros.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:52 +0000 (21:57 +0200)]
tools/nolibc: move makedev() and friends to sys/sysmacros.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-6-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move getrlimit() and friends to sys/resource.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:51 +0000 (21:57 +0200)]
tools/nolibc: move getrlimit() and friends to sys/resource.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-5-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move reboot() to sys/reboot.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:50 +0000 (21:57 +0200)]
tools/nolibc: move reboot() to sys/reboot.h

This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-4-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move prctl() to sys/prctl.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:49 +0000 (21:57 +0200)]
tools/nolibc: move prctl() to sys/prctl.h

This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-3-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move mount() to sys/mount.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:48 +0000 (21:57 +0200)]
tools/nolibc: move mount() to sys/mount.h

This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-2-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: move ioctl() to sys/ioctl.h
Thomas Weißschuh [Thu, 15 May 2025 19:57:47 +0000 (21:57 +0200)]
tools/nolibc: move ioctl() to sys/ioctl.h

This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-1-74f82eea3b59@weissschuh.net
2 months agotools/nolibc: implement wait() in terms of waitpid()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:16 +0000 (14:40 +0200)]
tools/nolibc: implement wait() in terms of waitpid()

Newer architectures like riscv 32-bit are missing sys_wait4().
Make use of the fact that wait(&status) is defined to be equivalent to
waitpid(-1, status, 0) to implement it on all architectures.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-15-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: fall back to sys_clock_gettime() in gettimeofday()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:15 +0000 (14:40 +0200)]
tools/nolibc: fall back to sys_clock_gettime() in gettimeofday()

Newer architectures (like riscv32) do not implement sys_gettimeofday().
In those cases fall back to sys_clock_gettime().
While that does not support the timezone argument of sys_gettimeofday(),
specifying this argument invokes undefined behaviour, so it's safe to ignore.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-14-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add fopen()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:14 +0000 (14:40 +0200)]
tools/nolibc: add fopen()

This is used in various selftests and will be handy when integrating
those with nolibc.

Only the standard POSIX modes are supported.
No extensions nor the (noop) "b" from ISO C are accepted.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-13-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add namespace functionality
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:13 +0000 (14:40 +0200)]
tools/nolibc: add namespace functionality

This is used in various selftests and will be handy when integrating
those with nolibc.

Not all configurations support namespaces, so skip the tests where
necessary.  Also if the tests are running without privileges.
Enable the namespace configuration for those architectures where it is not
enabled by default.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-12-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add difftime()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:12 +0000 (14:40 +0200)]
tools/nolibc: add difftime()

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-11-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add timerfd functionality
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:11 +0000 (14:40 +0200)]
tools/nolibc: add timerfd functionality

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-10-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add timer functions
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:10 +0000 (14:40 +0200)]
tools/nolibc: add timer functions

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-9-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add clock_getres(), clock_gettime() and clock_settime()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:09 +0000 (14:40 +0200)]
tools/nolibc: add clock_getres(), clock_gettime() and clock_settime()

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-8-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add support for access() and faccessat()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:08 +0000 (14:40 +0200)]
tools/nolibc: add support for access() and faccessat()

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-7-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add abs() and friends
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:07 +0000 (14:40 +0200)]
tools/nolibc: add abs() and friends

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-6-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add getrandom()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:06 +0000 (14:40 +0200)]
tools/nolibc: add getrandom()

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-5-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add mremap()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:05 +0000 (14:40 +0200)]
tools/nolibc: add mremap()

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-4-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add more stat() variants
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:04 +0000 (14:40 +0200)]
tools/nolibc: add more stat() variants

Add fstat(), fstatat() and lstat(). All of them use the existing implementation
based on statx().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-3-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add %m printf format
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:03 +0000 (14:40 +0200)]
tools/nolibc: add %m printf format

The %m format can be used to format the current errno.
It is non-standard but supported by other commonly used libcs like glibc and
musl, so applications do rely on them.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-2-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: add strstr()
Thomas Weißschuh [Mon, 28 Apr 2025 12:40:02 +0000 (14:40 +0200)]
tools/nolibc: add strstr()

This is used in various selftests and will be handy when integrating
those with nolibc.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-1-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: use poll-related definitions from UAPI headers
Thomas Weißschuh [Wed, 30 Apr 2025 09:35:33 +0000 (11:35 +0200)]
tools/nolibc: use poll-related definitions from UAPI headers

The UAPI headers already provide definitions for these symbols.
Using them makes the code shorter, more robust and compatible with
applications using linux/poll.h directly.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250430-poll-v1-2-44b5ceabdeee@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: move poll() to poll.h
Thomas Weißschuh [Wed, 30 Apr 2025 09:35:32 +0000 (11:35 +0200)]
tools/nolibc: move poll() to poll.h

This is the location regular userspace expects the definition.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250430-poll-v1-1-44b5ceabdeee@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agotools/nolibc: Add m68k support
Daniel Palmer [Sat, 26 Apr 2025 22:47:38 +0000 (07:47 +0900)]
tools/nolibc: Add m68k support

Add nolibc support for m68k. Should be helpful for nommu where
linking libc can bloat even hello world to the point where you get
an OOM just trying to load it.

Signed-off-by: Daniel Palmer <daniel@thingy.jp>
Link: https://lore.kernel.org/r/20250426224738.284874-1-daniel@0x0f.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2 months agoselftests/nolibc: always run nolibc header check
Thomas Weißschuh [Thu, 24 Apr 2025 11:48:13 +0000 (13:48 +0200)]
selftests/nolibc: always run nolibc header check

Prevent regressions of issues validates by the header check by always
running it together with the nolibc selftests.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250424-nolibc-header-check-v1-3-011576b6ed6f@linutronix.de
2 months agotools/nolibc: include nolibc.h early from all header files
Thomas Weißschuh [Thu, 24 Apr 2025 11:48:12 +0000 (13:48 +0200)]
tools/nolibc: include nolibc.h early from all header files

Inclusion of any nolibc header file should also bring all other headers.
On the other hand it should also be possible to include any nolibc header
files
in any order.

Currently this is implemented by including the catch-all nolibc.h after the
headers own definitions.
This is problematic if one nolibc header depends on another one.
The first header has to include the other one before defining any symbols.
That in turn will include the rest of nolibc while the current header has
not defined anything yet. If any other part of nolibc depends on
definitions from the current header, errors are encountered.
This is already the case today. Effectively nolibc can only be included in
the order of nolibc.h.

Restructure the way "nolibc.h" is included.
Move it to the beginning of the header files and before the include guards.
Now any header will behave exactly like "nolibc.h" while the include
guards prevent any duplicate definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250424-nolibc-header-check-v1-2-011576b6ed6f@linutronix.de
2 months agotools/nolibc: add target to check header usability
Thomas Weißschuh [Thu, 24 Apr 2025 11:48:11 +0000 (13:48 +0200)]
tools/nolibc: add target to check header usability

Each nolibc header should be valid for inclusion irrespective of any
special ordering requirements.

Add a new make target, based on the old kbuild "make header_check" target
to validate this requirement.

For now the check fails, but the following commits will fix the issues.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250424-nolibc-header-check-v1-1-011576b6ed6f@linutronix.de
3 months agotools/nolibc: implement width padding in printf()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:55 +0000 (11:00 +0200)]
tools/nolibc: implement width padding in printf()

printf can pad each argument to a certain width.
Implement this for compatibility with the kselftest harness.
Currently only padding with spaces is supported.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agoselftests/nolibc: add test for snprintf() truncation
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:54 +0000 (11:00 +0200)]
selftests/nolibc: add test for snprintf() truncation

Now that we have a proper snprintf() implementation,
make sure truncation is handled properly.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agoselftests/nolibc: rename vfprintf test suite
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:53 +0000 (11:00 +0200)]
selftests/nolibc: rename vfprintf test suite

With the addition of snprintf() and its usage in nolibc-test, the name of
the "vfprintf" test suite is not accurate anymore.

Rename the suite to be more generic.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agoselftests/nolibc: use snprintf() for printf tests
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:52 +0000 (11:00 +0200)]
selftests/nolibc: use snprintf() for printf tests

With a proper snprintf() implementation in place, the ugly pipe usage is
not necessary anymore.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: add snprintf() and friends
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:51 +0000 (11:00 +0200)]
tools/nolibc: add snprintf() and friends

Add more of the printf() functions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: allow limiting of printf destination size
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:50 +0000 (11:00 +0200)]
tools/nolibc: allow limiting of printf destination size

snprintf() allows limiting the output buffer, while still returning the
number of all bytes that would have been written.
Implement the limitation logic in preparation for snprintf().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: allow different write callbacks in printf
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:49 +0000 (11:00 +0200)]
tools/nolibc: allow different write callbacks in printf

Decouple the formatting logic from the writing logic to later enable
writing straight to a buffer in sprintf().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: add getopt()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:48 +0000 (11:00 +0200)]
tools/nolibc: add getopt()

Introduce a getopt() implementation based on the one from musl.
The only deviations are adaption to the kernel coding style and nolibc
infrastructure and removal of multi-byte support.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: add dprintf() and vdprintf()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:47 +0000 (11:00 +0200)]
tools/nolibc: add dprintf() and vdprintf()

dprintf() and vdprintf() are printf() variants printing directly into a
filedescriptor. As FILE in nolibc is based directly on filedescriptors,
the implementation is trivial.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agoRevert "selftests/nolibc: use waitid() over waitpid()"
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:46 +0000 (11:00 +0200)]
Revert "selftests/nolibc: use waitid() over waitpid()"

nolibc's waitpid() now uses the waitid() syscall internally.
This removes the original reasoning for the reverted commit as
waitpid() is now available on all platforms and has an easier interface.

Switch back to waitpid().

This reverts commit a0bc8947ac731ff95a56e0c1737e69e8c56d5b78.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: implement waitpid() in terms of waitid()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:45 +0000 (11:00 +0200)]
tools/nolibc: implement waitpid() in terms of waitid()

The old wait4() syscall used by waitpid() before is not available everywhere.
Switch to the waitid() syscall which is the new replacement.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: add setpgrp()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:44 +0000 (11:00 +0200)]
tools/nolibc: add setpgrp()

setpgrp() is defined to be identical to setpgid(0, 0).

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: add _exit()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:43 +0000 (11:00 +0200)]
tools/nolibc: add _exit()

_exit() is the faster variant of exit(), skipping all cleanup actions.
As nolibc does not perform any cleanup anyways, the implementation is
trivial.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: add tolower() and toupper()
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:42 +0000 (11:00 +0200)]
tools/nolibc: add tolower() and toupper()

The kselftest harness uses these functions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: use ppoll_time64 if available
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:41 +0000 (11:00 +0200)]
tools/nolibc: use ppoll_time64 if available

riscv32 does not have any of the older poll systemcalls.
Use ppoll_time64 instead.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: use pselect6_time64 if available
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:40 +0000 (11:00 +0200)]
tools/nolibc: use pselect6_time64 if available

riscv32 does not have any of the older select systemcalls.
Use pselect6_time64 instead.
poll() is also used to implement sleep().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: use intmax definitions from compiler
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:39 +0000 (11:00 +0200)]
tools/nolibc: use intmax definitions from compiler

The printf format checking in the compiler uses the intmax types from
the compiler, not libc. This can lead to compiler errors.

Instead use the types already provided by the compiler.

Example issue with clang 19 for arm64:

nolibc-test.c:30:2: error: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uintmax_t' (aka 'unsigned long long') [-Werror,-Wformat]

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
3 months agotools/nolibc: handle intmax_t/uintmax_t in printf
Thomas Weißschuh [Fri, 11 Apr 2025 09:00:38 +0000 (11:00 +0200)]
tools/nolibc: handle intmax_t/uintmax_t in printf

In nolibc intmax_t and uintmax_t are always the same as
(unsigned) long long/uint64_t as 128bit numbers are not supported.
Even libcs that do support 128bit numbers often fix intmax_t to 64bit
as it is used in ABIs and any change would break those.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
4 months agotools/nolibc: move wait() and friends to sys/wait.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:25 +0000 (14:06 +0200)]
tools/nolibc: move wait() and friends to sys/wait.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-10-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: add sys/types.h shim
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:24 +0000 (14:06 +0200)]
tools/nolibc: add sys/types.h shim

This is the location regular userspace expects the header.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-9-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: move gettimeofday() to sys/time.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:23 +0000 (14:06 +0200)]
tools/nolibc: move gettimeofday() to sys/time.h

This is the location regular userspace expects this definition.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-8-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: move syscall() to sys/syscall.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:22 +0000 (14:06 +0200)]
tools/nolibc: move syscall() to sys/syscall.h

This is the location regular userspace expects the definition.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-7-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: move stat() and friends to sys/stat.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:21 +0000 (14:06 +0200)]
tools/nolibc: move stat() and friends to sys/stat.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-6-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: move mmap() and friends to sys/mman.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:20 +0000 (14:06 +0200)]
tools/nolibc: move mmap() and friends to sys/mman.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-5-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: move getauxval() to sys/auxv.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:19 +0000 (14:06 +0200)]
tools/nolibc: move getauxval() to sys/auxv.h

This is the location regular userspace expects the definition.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-4-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: move open() and friends to fcntl.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:18 +0000 (14:06 +0200)]
tools/nolibc: move open() and friends to fcntl.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-3-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: add elf.h
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:17 +0000 (14:06 +0200)]
tools/nolibc: add elf.h

The UAPI header do already provide an elf.h implementation.
Reexport it under its libc name.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-2-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agotools/nolibc: prepare for headers in subdirectories
Thomas Weißschuh [Wed, 16 Apr 2025 12:06:16 +0000 (14:06 +0200)]
tools/nolibc: prepare for headers in subdirectories

To support headers in subdirectories (like sys/), their subdirectory needs
to be preserved during installation into the sysroot.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-1-a069a3f1d145@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agoselftests/nolibc: enable UBSAN if available
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:24 +0000 (12:46 +0200)]
selftests/nolibc: enable UBSAN if available

UBSAN detects undefined behaviour at runtime.
To avoid introduction of new UB, enable UBSAN for nolibc-test.

By signalling detected errors through traps no runtime dependency
is necessary.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-7-060b8a016917@weissschuh.net
4 months agoselftests/nolibc: disable ubsan for smash_stack()
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:23 +0000 (12:46 +0200)]
selftests/nolibc: disable ubsan for smash_stack()

smash_stack() intentionally crashes.

Prevent UBSAN from tripping over it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-6-060b8a016917@weissschuh.net
4 months agotools/nolibc: fix integer overflow in i{64,}toa_r() and
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:22 +0000 (12:46 +0200)]
tools/nolibc: fix integer overflow in i{64,}toa_r() and

In twos complement the most negative number can not be negated.

Fixes: b1c21e7d99cd ("tools/nolibc/stdlib: add i64toa() and u64toa()")
Fixes: 66c397c4d2e1 ("tools/nolibc/stdlib: replace the ltoa() function with more efficient ones")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-5-060b8a016917@weissschuh.net
4 months agotools/nolibc: properly align dirent buffer
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:21 +0000 (12:46 +0200)]
tools/nolibc: properly align dirent buffer

As byte buffer is overlaid with a 'struct dirent64'.
it has to satisfy the structs alignment requirements.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Fixes: 665fa8dea90d ("tools/nolibc: add support for directory access")
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-4-060b8a016917@weissschuh.net
4 months agotools/nolibc: disable function sanitizer for _start_c()
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:20 +0000 (12:46 +0200)]
tools/nolibc: disable function sanitizer for _start_c()

Both constructors and main() may be executed with different function
signatures than they are actually using.
This is intentional but trips up UBSAN.

Disable the function sanitizer of UBSAN in _start_c().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-3-060b8a016917@weissschuh.net
4 months agotools/nolibc: add __nolibc_aligned() and __nolibc_aligned_as()
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:19 +0000 (12:46 +0200)]
tools/nolibc: add __nolibc_aligned() and __nolibc_aligned_as()

Provide a convenience macro around __attribute__((aligned)).

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-2-060b8a016917@weissschuh.net
4 months agotools/nolibc: add __nolibc_has_feature()
Thomas Weißschuh [Sat, 19 Apr 2025 10:46:18 +0000 (12:46 +0200)]
tools/nolibc: add __nolibc_has_feature()

Certain compiler features are signaled via the __has_feature()
preprocessor builtin.

Add a nolibc wrapper for it, similar to __nolibc_has_attribute().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250419-nolibc-ubsan-v2-1-060b8a016917@weissschuh.net
4 months agotools/nolibc: drop manual stack pointer alignment
Thomas Weißschuh [Sun, 16 Mar 2025 19:46:07 +0000 (20:46 +0100)]
tools/nolibc: drop manual stack pointer alignment

The stack pointer is already aligned by the kernel to a multiple of 16.
See STACK_ROUND() in fs/binfmt_elf.c.

The manual realignment is unnecessary, drop it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250316-nolibc-sp-align-v1-1-1e1fb073ca1e@weissschuh.net
4 months agotools/nolibc: Add support for SPARC
Thomas Weißschuh [Wed, 26 Feb 2025 14:05:17 +0000 (15:05 +0100)]
tools/nolibc: Add support for SPARC

Add support for 32bit and 64bit SPARC to nolibc.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> # UltraSparc T4 (Niagara4)
Link: https://lore.kernel.org/lkml/20250322-nolibc-sparc-v2-1-89af018c6296@weissschuh.net/
4 months agoselftests/nolibc: only consider XARCH for CFLAGS when requested
Thomas Weißschuh [Wed, 2 Apr 2025 21:39:00 +0000 (23:39 +0200)]
selftests/nolibc: only consider XARCH for CFLAGS when requested

If no explicit XARCH is specified, use the toolchains default.

Suggested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Link: https://lore.kernel.org/lkml/20250326205434.bPx_kVUx@breakpoint.cc/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250402-nolibc-nolibc-test-native-v1-2-62f2f8585220@weissschuh.net
4 months agoselftests/nolibc: drop dependency from sysroot to defconfig
Thomas Weißschuh [Wed, 2 Apr 2025 21:38:59 +0000 (23:38 +0200)]
selftests/nolibc: drop dependency from sysroot to defconfig

The creation of the sysroot does not require a kernel configuration.

Drop the dependency.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250402-nolibc-nolibc-test-native-v1-1-62f2f8585220@weissschuh.net
4 months agotools/nolibc/types.h: fix mismatched parenthesis in minor()
Jemmy Wong [Fri, 11 Apr 2025 07:36:24 +0000 (15:36 +0800)]
tools/nolibc/types.h: fix mismatched parenthesis in minor()

Fix an imbalance where opening parentheses exceed closing ones.

Fixes: eba6d00d38e7c ("tools/nolibc/types: move makedev to types.h and make it a macro")
Signed-off-by: Jemmy Wong <jemmywong512@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250411073624.22153-1-jemmywong512@gmail.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
4 months agoselftests/nolibc: drop unnecessary sys/io.h include
Thomas Weißschuh [Mon, 24 Mar 2025 22:01:28 +0000 (23:01 +0100)]
selftests/nolibc: drop unnecessary sys/io.h include

The include of sys/io.h is not necessary anymore since
commit 67eb617a8e1e ("selftests/nolibc: simplify call to ioperm").
It's existence is also problematic as the header does not exist on all
architectures.

Reported-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250324-nolibc-ioperm-v1-1-8a7cfb2876ae@weissschuh.net
4 months agoLinux 6.15-rc1
Linus Torvalds [Sun, 6 Apr 2025 20:11:33 +0000 (13:11 -0700)]
Linux 6.15-rc1

4 months agotools/include: make uapi/linux/types.h usable from assembly
Thomas Weißschuh [Wed, 2 Apr 2025 20:21:57 +0000 (21:21 +0100)]
tools/include: make uapi/linux/types.h usable from assembly

The "real" linux/types.h UAPI header gracefully degrades to a NOOP when
included from assembly code.

Mirror this behaviour in the tools/ variant.

Test for __ASSEMBLER__ over __ASSEMBLY__ as the former is provided by the
toolchain automatically.

Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/lkml/af553c62-ca2f-4956-932c-dd6e3a126f58@sirena.org.uk/
Fixes: c9fbaa879508 ("selftests: vDSO: parse_vdso: Use UAPI headers instead of libc headers")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://patch.msgid.link/20250321-uapi-consistency-v1-1-439070118dc0@linutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 months agoMerge tag 'turbostat-2025.05.06' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 6 Apr 2025 19:32:43 +0000 (12:32 -0700)]
Merge tag 'turbostat-2025.05.06' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux

Pull turbostat updates from Len Brown:

 - support up to 8192 processors

 - add cpuidle governor debug telemetry, disabled by default

 - update default output to exclude cpuidle invocation counts

 - bug fixes

* tag 'turbostat-2025.05.06' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: v2025.05.06
  tools/power turbostat: disable "cpuidle" invocation counters, by default
  tools/power turbostat: re-factor sysfs code
  tools/power turbostat: Restore GFX sysfs fflush() call
  tools/power turbostat: Document GNR UncMHz domain convention
  tools/power turbostat: report CoreThr per measurement interval
  tools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192
  tools/power turbostat: Add idle governor statistics reporting
  tools/power turbostat: Fix names matching
  tools/power turbostat: Allow Zero return value for some RAPL registers
  tools/power turbostat: Clustered Uncore MHz counters should honor show/hide options

4 months agoMerge tag 'soundwire-6.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 6 Apr 2025 19:04:53 +0000 (12:04 -0700)]
Merge tag 'soundwire-6.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire

Pull soundwire fix from Vinod Koul:

 - add missing config symbol CONFIG_SND_HDA_EXT_CORE required for asoc
   driver CONFIG_SND_SOF_SOF_HDA_SDW_BPT

* tag 'soundwire-6.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
  ASoC: SOF: Intel: Let SND_SOF_SOF_HDA_SDW_BPT select SND_HDA_EXT_CORE

4 months agotools/power turbostat: v2025.05.06
Len Brown [Sun, 6 Apr 2025 18:49:20 +0000 (14:49 -0400)]
tools/power turbostat: v2025.05.06

Support up to 8192 processors
Add cpuidle governor debug telemetry, disabled by default
Update default output to exclude cpuidle invocation counts
Bug fixes

Signed-off-by: Len Brown <len.brown@intel.com>
4 months agotools/power turbostat: disable "cpuidle" invocation counters, by default
Len Brown [Sun, 6 Apr 2025 18:29:57 +0000 (14:29 -0400)]
tools/power turbostat: disable "cpuidle" invocation counters, by default

Create "pct_idle" counter group, the sofware notion of residency
so it can now be singled out, independent of other counter groups.

Create "cpuidle" group, the cpuidle invocation counts.
Disable "cpuidle", by default.

Create "swidle" = "cpuidle" + "pct_idle".
Undocument "sysfs", the old name for "swidle", but keep it working
for backwards compatibilty.

Create "hwidle", all the HW idle counters

Modify "idle", enabled by default
"idle" = "hwidle" + "pct_idle" (and now excludes "cpuidle")

Signed-off-by: Len Brown <len.brown@intel.com>
4 months agoMerge tag 'perf-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 6 Apr 2025 17:48:12 +0000 (10:48 -0700)]
Merge tag 'perf-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf event fix from Ingo Molnar:
 "Fix a perf events time accounting bug"

* tag 'perf-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Fix child_total_time_enabled accounting bug at task exit

4 months agoMerge tag 'sched-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 6 Apr 2025 17:44:58 +0000 (10:44 -0700)]
Merge tag 'sched-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull scheduler fixes from Ingo Molnar:

 - Fix a nonsensical Kconfig combination

 - Remove an unnecessary rseq-notification

* tag 'sched-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  rseq: Eliminate useless task_work on execve
  sched/isolation: Make CONFIG_CPU_ISOLATION depend on CONFIG_SMP

4 months agoDisable SLUB_TINY for build testing
Linus Torvalds [Sun, 6 Apr 2025 17:00:04 +0000 (10:00 -0700)]
Disable SLUB_TINY for build testing

... and don't error out so hard on missing module descriptions.

Before commit 6c6c1fc09de3 ("modpost: require a MODULE_DESCRIPTION()")
we used to warn about missing module descriptions, but only when
building with extra warnigns (ie 'W=1').

After that commit the warning became an unconditional hard error.

And it turns out not all modules have been converted despite the claims
to the contrary.  As reported by Damian Tometzki, the slub KUnit test
didn't have a module description, and apparently nobody ever really
noticed.

The reason nobody noticed seems to be that the slub KUnit tests get
disabled by SLUB_TINY, which also ends up disabling a lot of other code,
both in tests and in slub itself.  And so anybody doing full build tests
didn't actually see this failre.

So let's disable SLUB_TINY for build-only tests, since it clearly ends
up limiting build coverage.  Also turn the missing module descriptions
error back into a warning, but let's keep it around for non-'W=1'
builds.

Reported-by: Damian Tometzki <damian@riscv-rocks.de>
Link: https://lore.kernel.org/all/01070196099fd059-e8463438-7b1b-4ec8-816d-173874be9966-000000@eu-central-1.amazonses.com/
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
Fixes: 6c6c1fc09de3 ("modpost: require a MODULE_DESCRIPTION()")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
4 months agotools/power turbostat: re-factor sysfs code
Len Brown [Sun, 6 Apr 2025 16:53:18 +0000 (12:53 -0400)]
tools/power turbostat: re-factor sysfs code

Probe cpuidle "sysfs" residency and counts separately,
since soon we will make one disabled on, and the
other disabled off.

Clarify that some BIC (build-in-counters) are actually "groups".
since we're about to re-name some of those groups.

no functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
4 months agotools/power turbostat: Restore GFX sysfs fflush() call
Zhang Rui [Wed, 19 Mar 2025 00:53:07 +0000 (08:53 +0800)]
tools/power turbostat: Restore GFX sysfs fflush() call

Do fflush() to discard the buffered data, before each read of the
graphics sysfs knobs.

Fixes: ba99a4fc8c24 ("tools/power turbostat: Remove unnecessary fflush() call")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
4 months agotools/power turbostat: Document GNR UncMHz domain convention
Len Brown [Sun, 6 Apr 2025 16:23:22 +0000 (12:23 -0400)]
tools/power turbostat: Document GNR UncMHz domain convention

Document that on Intel Granite Rapids Systems,
Uncore domains 0-2 are CPU domains, and
uncore domains 3-4 are IO domains.

Signed-off-by: Len Brown <len.brown@intel.com>
4 months agotools/power turbostat: report CoreThr per measurement interval
Len Brown [Sun, 6 Apr 2025 15:18:39 +0000 (11:18 -0400)]
tools/power turbostat: report CoreThr per measurement interval

The CoreThr column displays total thermal throttling events
since boot time.

Change it to report events during the measurement interval.

This is more useful for showing a user the current conditions.
Total events since boot time are still available to the user via
/sys/devices/system/cpu/cpu*/thermal_throttle/*

Document CoreThr on turbostat.8

Fixes: eae97e053fe30 ("turbostat: Support thermal throttle count print")
Reported-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Cc: Chen Yu <yu.c.chen@intel.com>
4 months agotools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192
Justin Ernst [Wed, 19 Mar 2025 20:27:31 +0000 (15:27 -0500)]
tools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192

On systems with >= 1024 cpus (in my case 1152), turbostat fails with the error output:
"turbostat: /sys/fs/cgroup/cpuset.cpus.effective: cpu str malformat 0-1151"

A similar error appears with the use of turbostat --cpu when the inputted cpu
range contains a cpu number >= 1024:
# turbostat -c 1100-1151
"--cpu 1100-1151" malformed
...

Both errors are caused by parse_cpu_str() reaching its limit of CPU_SUBSET_MAXCPUS.

It's a good idea to limit the maximum cpu number being parsed, but 1024 is too low.
For a small increase in compute and allocated memory, increasing CPU_SUBSET_MAXCPUS
brings support for parsing cpu numbers >= 1024.

Increase CPU_SUBSET_MAXCPUS to 8192, a common setting for CONFIG_NR_CPUS on x86_64.

Signed-off-by: Justin Ernst <justin.ernst@hpe.com>
Signed-off-by: Len Brown <len.brown@intel.com>
4 months agoMerge tag 'timers-cleanups-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 6 Apr 2025 15:35:37 +0000 (08:35 -0700)]
Merge tag 'timers-cleanups-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer cleanups from Thomas Gleixner:
 "A set of final cleanups for the timer subsystem:

   - Convert all del_timer[_sync]() instances over to the new
     timer_delete[_sync]() API and remove the legacy wrappers.

     Conversion was done with coccinelle plus some manual fixups as
     coccinelle chokes on scoped_guard().

   - The final cleanup of the hrtimer_init() to hrtimer_setup()
     conversion.

     This has been delayed to the end of the merge window, so that all
     patches which have been merged through other trees are in mainline
     and all new users are catched.

  Doing this right before rc1 ensures that new code which is merged post
  rc1 is not introducing new instances of the original functionality"

* tag 'timers-cleanups-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  tracing/timers: Rename the hrtimer_init event to hrtimer_setup
  hrtimers: Rename debug_init_on_stack() to debug_setup_on_stack()
  hrtimers: Rename debug_init() to debug_setup()
  hrtimers: Rename __hrtimer_init_sleeper() to __hrtimer_setup_sleeper()
  hrtimers: Remove unnecessary NULL check in hrtimer_start_range_ns()
  hrtimers: Make callback function pointer private
  hrtimers: Merge __hrtimer_init() into __hrtimer_setup()
  hrtimers: Switch to use __htimer_setup()
  hrtimers: Delete hrtimer_init()
  treewide: Convert new and leftover hrtimer_init() users
  treewide: Switch/rename to timer_delete[_sync]()

4 months agoMerge tag 'irq-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 6 Apr 2025 15:17:43 +0000 (08:17 -0700)]
Merge tag 'irq-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull more irq updates from Thomas Gleixner:
 "A set of updates for the interrupt subsystem:

   - A treewide cleanup for the irq_domain code, which makes the naming
     consistent and gets rid of the original oddity of naming domains
     'host'.

     This is a trivial mechanical change and is done late to ensure that
     all instances have been catched and new code merged post rc1 wont
     reintroduce new instances.

   - A trivial consistency fix in the migration code

     The recent introduction of irq_force_complete_move() in the core
     code, causes a problem for the nostalgia crowd who maintains ia64
     out of tree.

     The code assumes that hierarchical interrupt domains are enabled
     and dereferences irq_data::parent_data unconditionally. That works
     in mainline because both architectures which enable that code have
     hierarchical domains enabled. Though it breaks the ia64 build,
     which enables the functionality, but does not have hierarchical
     domains.

     While it's not really a problem for mainline today, this
     unconditional dereference is inconsistent and trivially fixable by
     using the existing helper function irqd_get_parent_data(), which
     has the appropriate #ifdeffery in place"

* tag 'irq-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  genirq/migration: Use irqd_get_parent_data() in irq_force_complete_move()
  irqdomain: Stop using 'host' for domain
  irqdomain: Rename irq_get_default_host() to irq_get_default_domain()
  irqdomain: Rename irq_set_default_host() to irq_set_default_domain()

4 months agoMerge tag 'timers-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 6 Apr 2025 15:13:16 +0000 (08:13 -0700)]
Merge tag 'timers-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer fix from Thomas Gleixner:
 "A revert to fix a adjtimex() regression:

  The recent change to prevent that time goes backwards for the coarse
  time getters due to immediate multiplier adjustments via adjtimex(),
  changed the way how the timekeeping core treats that.

  That change result in a regression on the adjtimex() side, which is
  user space visible:

   1) The forwarding of the base time moves the update out of the
      original period and establishes a new one. That's changing the
      behaviour of the [PF]LL control, which user space expects to be
      applied periodically.

   2) The clearing of the accumulated NTP error due to #1, changes the
      behaviour as well.

  An attempt to delay the multiplier/frequency update to the next tick
  did not solve the problem as userspace expects that the multiplier or
  frequency updates are in effect, when the syscall returns.

  There is a different solution for the coarse time problem available,
  so revert the offending commit to restore the existing adjtimex()
  behaviour"

* tag 'timers-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  Revert "timekeeping: Fix possible inconsistencies in _COARSE clockids"