Re: [PATCH v18 08/15] PCI: endpoint: pci-ep-msi: Add MSI address/data pair mutable check

2025-05-07 Thread Thomas Gleixner
On Mon, Apr 14 2025 at 14:31, Frank Li wrote: > Some MSI controller change address/data pair when irq_set_affinity(). > Current PCI endpoint can't support this type MSI controller. So add flag > MSI_FLAG_MUTABLE in include/linux/msi.h and check it when allocate > doorbell. This changelog has no re

[PATCH v4 14/14] HACK: selftests/nolibc: demonstrate usage of the kselftest harness

2025-05-05 Thread Thomas Weißschuh
the future nolibc-test can use the harness for itself. Not-Signed-off-by: Thomas Weißschuh Acked-by: Shuah Khan --- .../selftests/kselftest_harness/harness-selftest.c |2 +- tools/testing/selftests/nolibc/Makefile| 15 +- tools/testing/selftests/nolibc/harness-selftest.c

[PATCH v4 13/14] selftests: harness: Guard includes on nolibc

2025-05-05 Thread Thomas Weißschuh
Nolibc doesn't provide all normal header files. Don't try to include these non-existent header files, as the symbols are available unconditionally anyways. Signed-off-by: Thomas Weißschuh Acked-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 7 +-- 1 file

[PATCH v4 12/14] selftests: harness: Stop using setjmp()/longjmp()

2025-05-05 Thread Thomas Weißschuh
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-

[PATCH v4 11/14] selftests: harness: Add "variant" and "self" to test metadata

2025-05-05 Thread Thomas Weißschuh
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 --- tools/testing/selftests/kselftest_harness.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests

[PATCH v4 09/14] selftests: harness: Move teardown conditional into test metadata

2025-05-05 Thread Thomas Weißschuh
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 Acked-by: Shuah Khan --- too

[PATCH v4 10/14] selftests: harness: Add teardown callback to test metadata

2025-05-05 Thread Thomas Weißschuh
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 Acked-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 19 +-- 1 file changed, 13 insertions(+), 6 deletions

[PATCH v4 06/14] selftests: harness: Remove dependency on libatomic

2025-05-05 Thread Thomas Weißschuh
__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 Reviewed-by: Muhammad Usama Anjum Acked

[PATCH v4 07/14] selftests: harness: Implement test timeouts through pidfd

2025-05-05 Thread Thomas Weißschuh
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 Acked-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 72

[PATCH v4 08/14] selftests: harness: Don't set setup_completed for fixtureless tests

2025-05-05 Thread Thomas Weißschuh
This field is unused and has no meaning for tests without fixtures. Don't set it for them. Signed-off-by: Thomas Weißschuh Acked-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/kselftest_harness

[PATCH v4 05/14] selftests: harness: Remove inline qualifier for wrappers

2025-05-05 Thread Thomas Weißschuh
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 Reviewed-by: Muhammad Usama Anjum Acked-by: Shuah Khan

[PATCH v4 04/14] selftests: harness: Mark functions without prototypes static

2025-05-05 Thread Thomas Weißschuh
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

[PATCH v4 03/14] selftests: harness: Ignore unused variant argument warning

2025-05-05 Thread Thomas Weißschuh
ame) __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 Reviewed-by: Muhammad Usama Anjum Acked-by: Shuah Khan --- tools/testing

[PATCH v4 01/14] selftests: harness: Add kselftest harness selftest

2025-05-05 Thread Thomas Weißschuh
Add a selftest for the kselftest harness itself so any changes can be validated. Signed-off-by: Thomas Weißschuh Reviewed-by: Muhammad Usama Anjum Acked-by: Shuah Khan --- MAINTAINERS| 1 + tools/testing/selftests/Makefile | 1

[PATCH v4 00/14] kselftest harness and nolibc compatibility

2025-05-05 Thread Thomas Weißschuh
the usage of problematic libc features from the harness. Based on nolibc/for-next. The series is meant to be merged through the nolibc tree. Signed-off-by: Thomas Weißschuh --- Changes in v4: - Drop patches for nolibc which where already applied - Preserve signatures of test functions for tests

[PATCH v4 02/14] selftests: harness: Use C89 comment style

2025-05-05 Thread Thomas Weißschuh
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 Acked-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a

Re: [PATCH v2 4/8] selftests: vDSO: vdso_test_getrandom: Drop some dead code

2025-05-05 Thread Thomas Weißschuh
On Mon, May 05, 2025 at 02:58:06PM +0200, Jason A. Donenfeld wrote: > Hi Thomas, > > On Mon, May 5, 2025 at 11:19 AM Thomas Weißschuh > wrote: > > > > vgetrandom_put_state() and the variable ret in kselftest() are never used. > > > > Drop the dead code. >

Re: [PATCH v3 12/32] selftests: harness: Stop using setjmp()/longjmp()

2025-05-05 Thread Thomas Weißschuh
Hi Mark, On Mon, May 05, 2025 at 07:50:31PM +0900, Mark Brown wrote: > On Fri, Apr 11, 2025 at 11:00:36AM +0200, Thomas Weißschuh wrote: > > Usage of longjmp() was added to ensure that teardown is always run in > > commit 63e6b2a42342 ("selftests/harness: Run TEARDOWN

[PATCH v2 8/8] selftests: vDSO: vdso_test_getrandom: Always print TAP header

2025-05-05 Thread Thomas Weißschuh
The TAP specification requires that the output begins with a header line. If vgetrandom_init() fails and skips the test, that header line is missing. Call vgetrandom_init() after ksft_print_header(). Signed-off-by: Thomas Weißschuh Reviewed-by: Muhammad Usama Anjum --- tools/testing/selftests

[PATCH v2 7/8] selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes

2025-05-05 Thread Thomas Weißschuh
use an empty argument list. Now that all selftests a free of this warning, enable it in the Makefile. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/Makefile| 2 +- tools/testing/selftests/vDSO/vdso_test_correctness.c | 2 +- 2 files changed, 2 insertions(+), 2

[PATCH v2 4/8] selftests: vDSO: vdso_test_getrandom: Drop some dead code

2025-05-05 Thread Thomas Weißschuh
vgetrandom_put_state() and the variable ret in kselftest() are never used. Drop the dead code. Signed-off-by: Thomas Weißschuh Reviewed-by: Muhammad Usama Anjum --- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git

[PATCH v2 6/8] selftests: vDSO: enable -Wall

2025-05-05 Thread Thomas Weißschuh
Protect against common programming errors through compiler warnings. These warnings are also used for the kernel itself. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/vDSO

[PATCH v2 5/8] selftests: vDSO: vdso_config: Avoid -Wunused-variables

2025-05-05 Thread Thomas Weißschuh
versions[7] = { |^~~~ Avoid those warnings through attribute((unused)). Signed-off-by: Thomas Weißschuh Reviewed-by: Muhammad Usama Anjum --- tools/testing/selftests/vDSO/vdso_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/vDSO/vds

[PATCH v2 3/8] selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h

2025-05-05 Thread Thomas Weißschuh
The header is unused. Furthermore this is not a real UAPI header, but only exists in tools/include/. This prevents building the selftest against real UAPI headers. Drop the include. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 1 - 1 file changed, 1

[PATCH v2 2/8] selftests: vDSO: clock_getres: Drop unused include of err.h

2025-05-05 Thread Thomas Weißschuh
Nothing from err.h is used. Drop the include. Signed-off-by: Thomas Weißschuh Reviewed-by: Muhammad Usama Anjum --- tools/testing/selftests/vDSO/vdso_test_clock_getres.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing

[PATCH v2 1/8] selftests: vDSO: chacha: Correctly skip test if necessary

2025-05-05 Thread Thomas Weißschuh
implemented on architecture The SKIP line should start with "ok 1" as the plan only contains one test. Fixes: 3b5992eaf730 ("selftests: vDSO: unconditionally build chacha test") Reviewed-by: Muhammad Usama Anjum Signed-off-by: Thomas Weißschuh --- I'm not sure if thi

[PATCH v2 0/8] selftests: vDSO: Some cleanups and (warning) fixes

2025-05-05 Thread Thomas Weißschuh
Fixes and cleanups for various issues in the vDSO selftests. Signed-off-by: Thomas Weißschuh --- Changes in v2: - Refer to -Wstrict-prototypes over -Wold-style-prototypes - Pick up Acks - Enable fixed warnings in Makefile - Link to v1: https://lore.kernel.org/r/20250502-selftests-vdso-fixes-v1

[PATCH 7/7] selftests: vDSO: vdso_config: Avoid -Wunused-variables

2025-05-02 Thread Thomas Weißschuh
versions[7] = { |^~~~ Avoid those warnings through attribute((unused)). Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/self

[PATCH 5/7] selftests: vDSO: vdso_test_getrandom: Drop some dead code

2025-05-02 Thread Thomas Weißschuh
vgetrandom_put_state() and the variable ret in kselftest() are never used. Drop the dead code. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tools/testing/selftests/vDSO

[PATCH 6/7] selftests: vDSO: vdso_test_getrandom: Always print TAP header

2025-05-02 Thread Thomas Weißschuh
The TAP specification requires that the output begins with a header line. If vgetrandom_init() fails and skips the test, that header line is missing. Call vgetrandom_init() after ksft_print_header(). Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 6

[PATCH 4/7] selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h

2025-05-02 Thread Thomas Weißschuh
The header is unused. Furthermore this is not a real UAPI header, but only exists in tools/include/. This prevents building the selftest against real UAPI headers. Drop the include. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 1 - 1 file changed, 1

[PATCH 3/7] selftests: vDSO: vdso_test_correctness: Fix -Wold-style-definitions

2025-05-02 Thread Thomas Weißschuh
an empty argument list. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_correctness.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c index

[PATCH 1/7] selftests: vDSO: chacha: Correctly skip test if necessary

2025-05-02 Thread Thomas Weißschuh
implemented on architecture The SKIP line should start with "ok 1" as the plan only contains one test. Fixes: 3b5992eaf730 ("selftests: vDSO: unconditionally build chacha test") Signed-off-by: Thomas Weißschuh --- I'm not sure if this is not a general bug in ksft_exit_sk

[PATCH 2/7] selftests: vDSO: clock_getres: Drop unused include of err.h

2025-05-02 Thread Thomas Weißschuh
Nothing from err.h is used. Drop the include. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/vDSO/vdso_test_clock_getres.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing/selftests/vDSO

[PATCH 0/7] selftests: vDSO: Some cleanups and fixes

2025-05-02 Thread Thomas Weißschuh
Fixes and cleanups for various issues in the vDSO selftests. Signed-off-by: Thomas Weißschuh --- Thomas Weißschuh (7): selftests: vDSO: chacha: Correctly skip test if necessary selftests: vDSO: clock_getres: Drop unused include of err.h selftests: vDSO: vdso_test_correctness

[PATCH 2/3] selftests/timens: Make run_tests() functions static

2025-05-02 Thread Thomas Weißschuh
These functions are never used outside their defining compilation unit and can be made static. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/timens/clock_nanosleep.c | 2 +- tools/testing/selftests/timens/timer.c | 2 +- tools/testing/selftests/timens/timerfd.c

[PATCH 3/3] selftests/timens: timerfd: Use correct clockid type in tclock_gettime()

2025-05-02 Thread Thomas Weißschuh
tclock_gettime() is a wrapper around clock_gettime(). The first parameter of clock_gettime() is of type "clockid_t", not "clock_t". Use the correct type instead. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/timens/timerfd.c | 2 +- 1 file changed, 1 inse

[PATCH 1/3] selftests/timens: Print TAP headers

2025-05-02 Thread Thomas Weißschuh
The TAP specification requires that the output begins with a header line. These headers lines are missing in the timens tests. Print such a line. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/timens/clock_nanosleep.c | 2 ++ tools/testing/selftests/timens/exec.c| 2

[PATCH 0/3] selftests/timens: Various small fixes

2025-05-02 Thread Thomas Weißschuh
Fixes for various issues in the timens selftests. Signed-off-by: Thomas Weißschuh --- Thomas Weißschuh (3): selftests/timens: Print TAP headers selftests/timens: Make run_tests() functions static selftests/timens: timerfd: Use correct clockid type in tclock_gettime() tools

Re: [PATCH v3 00/32] kselftest harness and nolibc compatibility

2025-04-29 Thread Thomas Weißschuh
On 2025-04-29 12:52:56-0600, Shuah Khan wrote: > On 4/24/25 14:06, Shuah Khan wrote: > > On 4/22/25 02:51, Willy Tarreau wrote: > > > Hi Thomas, > > > > > > On Tue, Apr 22, 2025 at 10:48:28AM +0200, Thomas Weißschuh wrote: > > > > Hi, > >

[PATCH v2 15/15] tools/nolibc: implement wait() in terms of waitpid()

2025-04-28 Thread Thomas Weißschuh
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 implment it on all architectures. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/sys/wait.h

[PATCH v2 14/15] tools/nolibc: fall back to sys_clock_gettime() in gettimeofday()

2025-04-28 Thread Thomas Weißschuh
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: T

[PATCH v2 12/15] tools/nolibc: add namespace functionality

2025-04-28 Thread Thomas Weißschuh
enabled by default. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/nolibc.h| 1 + tools/include/nolibc/sched.h | 50 + tools/testing/selftests/nolibc/Makefile

[PATCH v2 13/15] tools/nolibc: add fopen()

2025-04-28 Thread Thomas Weißschuh
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 Acked-by: Willy Tarreau --- tools/include/noli

[PATCH v2 11/15] tools/nolibc: add difftime()

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/time.h | 7 +++ tools/testing/selftests/nolibc/nolibc-test.c | 12 2 files changed, 19

[PATCH v2 10/15] tools/nolibc: add timerfd functionality

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/nolibc.h| 1 + tools/include/nolibc/sys/timerfd.h

[PATCH v2 09/15] tools/nolibc: add timer functions

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/time.h | 86 tools/include/nolibc/types.h | 1 + tools/testing

[PATCH v2 05/15] tools/nolibc: add getrandom()

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/nolibc.h| 1 + tools/include/nolibc/sys/random.h

[PATCH v2 08/15] tools/nolibc: add clock_getres(), clock_gettime() and clock_settime()

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/time.h | 92 tools/include/nolibc/types.h | 2 + tools/testing

[PATCH v2 06/15] tools/nolibc: add abs() and friends

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/math.h | 31 tools/include

[PATCH v2 07/15] tools/nolibc: add support for access() and faccessat()

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/unistd.h| 28 tools/testing/selftests/nolibc/nolibc-test.c | 2 ++ 2 files

[PATCH v2 04/15] tools/nolibc: add mremap()

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/sys/mman.h | 19 +++ tools/testing/selftests/nolibc/nolibc-test.c | 14 +++--- 2 files

[PATCH v2 03/15] tools/nolibc: add more stat() variants

2025-04-28 Thread Thomas Weißschuh
Add fstat(), fstatat() and lstat(). All of them use the existing implementation based on statx(). Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/sys/stat.h | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools

[PATCH v2 02/15] tools/nolibc: add %m printf format

2025-04-28 Thread Thomas Weißschuh
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 Acked-by: Willy Tarreau --- tools/include/nolibc/stdio.h | 7

[PATCH v2 01/15] tools/nolibc: add strstr()

2025-04-28 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/string.h| 20 tools/testing/selftests/nolibc/nolibc-test.c | 3 +++ 2 files changed, 23

[PATCH v2 00/15] tools/nolibc: various new functions

2025-04-28 Thread Thomas Weißschuh
A few functions used by different selftests. Adding them now avoids later conflicts between different selftest serieses. Also add full support for nolibc-test.c on riscv32. All unsupported syscalls have been replaced. Signed-off-by: Thomas Weißschuh --- Changes in v2: - Rebase onto latest

Re: [PATCH 11/15] tools/nolibc: add difftime()

2025-04-28 Thread Thomas Weißschuh
On Sat, Apr 26, 2025 at 12:45:20PM +0200, Willy Tarreau wrote: > On Wed, Apr 23, 2025 at 05:01:41PM +0200, Thomas Weißschuh wrote: > > This is used in various selftests and will be handy when integrating > > those with nolibc. > > > > Signed-off-by: Thomas Weißschuh

Re: [PATCH 05/15] tools/nolibc: add getrandom()

2025-04-28 Thread Thomas Weißschuh
On Sat, Apr 26, 2025 at 12:31:58PM +0200, Willy Tarreau wrote: > Hi Thomas, > > On Wed, Apr 23, 2025 at 05:01:35PM +0200, Thomas Weißschuh wrote: > > --- /dev/null > > +++ b/tools/include/nolibc/sys/random.h > > @@ -0,0 +1,32 @@ > > +/* SPDX-Li

[PATCH 2/3] tools/nolibc: include nolibc.h early from all header files

2025-04-24 Thread Thomas Weißschuh
t; while the include guards prevent any duplicate definitions. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/ctype.h | 6 +++--- tools/include/nolibc/dirent.h | 6 +++--- tools/include/nolibc/elf.h | 6 +++--- tools/include/nolibc/errno.h | 6 +++--- tools/in

[PATCH 0/3] tools/nolibc: make all headers usable directly

2025-04-24 Thread Thomas Weißschuh
olibc-misc-v1-0-a925bf402...@linutronix.de/ Signed-off-by: Thomas Weißschuh --- Thomas Weißschuh (3): tools/nolibc: add target to check header usability tools/nolibc: include nolibc.h early from all header files selftests/nolibc: always run nolibc header check tools/include/

[PATCH 1/3] tools/nolibc: add target to check header usability

2025-04-24 Thread Thomas Weißschuh
ned-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile | 9 + 1 file changed, 9 insertions(+) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index e05862cd08051685112f067d6eb45716613dd43c..41ef18872a7e9435a5efec9c0b32b9e29fcd4ce8 100644 --- a/tools/incl

[PATCH 3/3] selftests/nolibc: always run nolibc header check

2025-04-24 Thread Thomas Weißschuh
Prevent regressions of issues validates by the header check by always running it together with the nolibc selftests. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc

[PATCH 10/15] tools/nolibc: add timerfd functionality

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/nolibc.h| 1 + tools/include/nolibc/sys/timerfd.h | 87

[PATCH 08/15] tools/nolibc: add clock_getres(), clock_gettime() and clock_settime()

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/time.h | 92 tools/include/nolibc/types.h | 2 + tools/testing/selftests/nolibc/nolibc

[PATCH 02/15] tools/nolibc: add %m printf format

2025-04-23 Thread Thomas Weißschuh
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 --- tools/include/nolibc/stdio.h | 7 +++ tools/testing/selftests

[PATCH 15/15] tools/nolibc: implement wait() in terms of waitpid()

2025-04-23 Thread Thomas Weißschuh
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 implment it on all architectures. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys/wait.h | 12 ++-- 1 file cha

[PATCH 14/15] tools/nolibc: implement fall back to sys_clock_gettime() in gettimeofday()

2025-04-23 Thread Thomas Weißschuh
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: T

[PATCH 09/15] tools/nolibc: add timer functions

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/time.h | 86 tools/include/nolibc/types.h | 1 + tools/testing/selftests/nolibc/nolibc

[PATCH 00/15] tools/nolibc: various new functions

2025-04-23 Thread Thomas Weißschuh
A few functions used by different selftests. Adding them now avoids later conflicts between different selftest serieses. Also add full support for nolibc-test.c on riscv32. All unsupported syscalls have been replaced. Signed-off-by: Thomas Weißschuh --- Thomas Weißschuh (15): tools/nolibc

[PATCH 13/15] tools/nolibc: add fopen()

2025-04-23 Thread Thomas Weißschuh
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 --- tools/include/nolibc/stdio.h

[PATCH 11/15] tools/nolibc: add difftime()

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/time.h | 7 +++ tools/testing/selftests/nolibc/nolibc-test.c | 1 + 2 files changed, 8 insertions(+) diff --git a/tools/include

[PATCH 07/15] tools/nolibc: add support for access() and faccessat()

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/unistd.h| 28 tools/testing/selftests/nolibc/nolibc-test.c | 2 ++ 2 files changed, 30 insertions

[PATCH 06/15] tools/nolibc: add abs() and friends

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/math.h | 31 tools/include/nolibc/nolibc.h

[PATCH 05/15] tools/nolibc: add getrandom()

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/nolibc.h| 1 + tools/include/nolibc/sys/random.h| 32

[PATCH 03/15] tools/nolibc: add more stat() variants

2025-04-23 Thread Thomas Weißschuh
Add fstat(), fstatat() and lstat(). All of them use the existing implementation based on statx(). Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys/stat.h | 25 +++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/sys/stat.h b

[PATCH 01/15] tools/nolibc: add strstr()

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/string.h| 20 tools/testing/selftests/nolibc/nolibc-test.c | 3 +++ 2 files changed, 23 insertions(+) diff

[PATCH 12/15] tools/nolibc: add namespace functionality

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/Makefile| 1 + tools/include/nolibc/nolibc.h| 1 + tools/include/nolibc/sched.h | 50

[PATCH 04/15] tools/nolibc: add mremap()

2025-04-23 Thread Thomas Weißschuh
This is used in various selftests and will be handy when integrating those with nolibc. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys/mman.h | 19 +++ tools/testing/selftests/nolibc/nolibc-test.c | 14 +++--- 2 files changed, 30 insertions

Re: [PATCH v3 00/32] kselftest harness and nolibc compatibility

2025-04-22 Thread Thomas Weißschuh
Hi, On Fri, Apr 11, 2025 at 11:00:24AM +0200, Thomas Weißschuh wrote: > Nolibc is useful for selftests as the test programs can be very small, > and compiled with just a kernel crosscompiler, without userspace support. > Currently nolibc is only usable with kselftest.h, not the more >

[PATCH v2 3/7] tools/nolibc: disable function sanitizer for _start_c()

2025-04-19 Thread Thomas Weißschuh
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 --- tools/include/nolibc/crt.h | 5 + 1 file changed

[PATCH v2 2/7] tools/nolibc: add __nolibc_aligned() and __nolibc_aligned_as()

2025-04-19 Thread Thomas Weißschuh
Provide a convenience macro around __attribute__((aligned)). Signed-off-by: Thomas Weißschuh --- Willy, I used the name __nolibc_align*ed* because it matches what the underlying attribute and the kernel macros are using. --- tools/include/nolibc/compiler.h | 3 +++ 1 file changed, 3 insertions

[PATCH v2 7/7] selftests/nolibc: enable UBSAN if available

2025-04-19 Thread Thomas Weißschuh
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 Acked-by: Willy Tarreau --- tools/testing/selftests/nolibc/Makefile | 3

[PATCH v2 5/7] tools/nolibc: fix integer overflow in i{64,}toa_r() and

2025-04-19 Thread Thomas Weißschuh
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 ---

[PATCH v2 6/7] selftests/nolibc: disable ubsan for smash_stack()

2025-04-19 Thread Thomas Weißschuh
smash_stack() intentionally crashes. Prevent UBSAN from tripping over it. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc

[PATCH v2 4/7] tools/nolibc: properly align dirent buffer

2025-04-19 Thread Thomas Weißschuh
As byte buffer is overlaid with a 'struct dirent64'. it has to satisfy the structs alignment requirements. Fixes: 665fa8dea90d ("tools/nolibc: add support for directory access") Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/dirent.h | 3 ++

[PATCH v2 0/7] tools/nolibc: fix some undefined behaviour and enable UBSAN

2025-04-19 Thread Thomas Weißschuh
Fix some issues uncovered by UBSAN and enable UBSAN for nolibc-test to avoid regressions. Signed-off-by: Thomas Weißschuh --- Changes in v2: - Introduce and use __nolibc_aligned_as() - Reduce size of fixes to i{64,}toa_r() - Link to v1: https://lore.kernel.org/r/20250416-nolibc-ubsan-v1-0

[PATCH v2 1/7] tools/nolibc: add __nolibc_has_feature()

2025-04-19 Thread Thomas Weißschuh
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 --- tools/include/nolibc/compiler.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/include

Re: [PATCH 4/6] tools/nolibc: fix integer overflow in i{64,}toa_r() and

2025-04-19 Thread Thomas Weißschuh
On 2025-04-19 11:40:08+0200, Willy Tarreau wrote: > On Wed, Apr 16, 2025 at 08:40:19PM +0200, Thomas Weißschuh wrote: > > In twos complement the most negative number can not be negated. > > well, if we're picky, that's not really an int overflow since it's only &g

Re: [PATCH 3/6] tools/nolibc: properly align dirent buffer

2025-04-19 Thread Thomas Weißschuh
On 2025-04-19 11:11:40+0200, Willy Tarreau wrote: > On Wed, Apr 16, 2025 at 08:40:18PM +0200, Thomas Weißschuh wrote: > > As byte buffer is overlaid with a 'struct dirent64'. > > it has to satisfy the structs alignment requirements. > > > > Fixes: 665fa8d

Re: [PATCH 2/6] tools/nolibc: disable function sanitizer for _start_c()

2025-04-19 Thread Thomas Weißschuh
On 2025-04-19 11:06:31+0200, Willy Tarreau wrote: > On Wed, Apr 16, 2025 at 08:40:17PM +0200, Thomas Weißschuh wrote: > > Both constructors and main() may be executed with different function > > signatures than they are actually using. > > This is intentional but trips up UB

Re: [PATCH 0/6] tools/nolibc: fix some undefined behaviour and enable UBSAN

2025-04-18 Thread Thomas Weißschuh
Hi Paul, On 2025-04-18 10:32:27-0700, Paul E. McKenney wrote: > On Wed, Apr 16, 2025 at 08:40:15PM +0200, Thomas Weißschuh wrote: > > Fix some issues uncovered by UBSAN and enable UBSAN for nolibc-test to > > avoid regressions. > > > > Signed-off-by: Thomas Weißsc

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-18 Thread Thomas Gleixner
On Fri, Apr 18 2025 at 08:37, Thomas Gleixner wrote: > On Thu, Apr 17 2025 at 17:46, John Stultz wrote: >> Instead it seems like we should just do: >> tk->coarse_nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; > > You end up with the same probl

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-17 Thread Thomas Gleixner
On Thu, Apr 17 2025 at 17:46, John Stultz wrote: > On Sat, Apr 5, 2025 at 2:40 PM Thomas Gleixner wrote: >> @@ -1831,6 +1847,8 @@ void timekeeping_resume(void) >> /* Re-base the last cycle value */ >> tks->tkr_mono.cycle_last = cycle_now; >>

Re: [PATCH] timekeeping: Prevent coarse clocks going backwards

2025-04-17 Thread Thomas Gleixner
On Wed, Apr 16 2025 at 22:29, John Stultz wrote: > Looking over the patch, it seems ok to me, but in a test run with it, > I've seen an error with CLOCK_REALTIME_COARSE during the > clocksource-switch test (as well as some seemingly unrelated test > errors, which I need to investigate) so I'm look

[PATCH 3/6] tools/nolibc: properly align dirent buffer

2025-04-16 Thread Thomas Weißschuh
As byte buffer is overlaid with a 'struct dirent64'. it has to satisfy the structs alignment requirements. Fixes: 665fa8dea90d ("tools/nolibc: add support for directory access") Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/dirent.h | 1 + 1 file changed, 1 insert

[PATCH 5/6] selftests/nolibc: disable ubsan for smash_stack()

2025-04-16 Thread Thomas Weißschuh
smash_stack() intentionally crashes. Prevent UBSAN from tripping over it. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc

[PATCH 6/6] selftests/nolibc: enable UBSAN if available

2025-04-16 Thread Thomas Weißschuh
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 --- tools/testing/selftests/nolibc/Makefile | 3 ++- 1 file changed, 2

[PATCH 1/6] tools/nolibc: add __nolibc_has_feature()

2025-04-16 Thread Thomas Weißschuh
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 --- tools/include/nolibc/compiler.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/tools/include

[PATCH 0/6] tools/nolibc: fix some undefined behaviour and enable UBSAN

2025-04-16 Thread Thomas Weißschuh
Fix some issues uncovered by UBSAN and enable UBSAN for nolibc-test to avoid regressions. Signed-off-by: Thomas Weißschuh --- Thomas Weißschuh (6): tools/nolibc: add __nolibc_has_feature() tools/nolibc: disable function sanitizer for _start_c() tools/nolibc: properly align

[PATCH 4/6] tools/nolibc: fix integer overflow in i{64,}toa_r() and

2025-04-16 Thread Thomas Weißschuh
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 ---

  1   2   3   4   5   6   7   8   9   10   >