dd58d666 | 07-Jun-2023 |
Willy Tarreau <w@1wt.eu> |
selftests/nolibc: make sure gcc always use little endian on MIPS
The test on MIPS stopped working after I upgraded some of my toolchains to use the ones from kernel.org because the mips toolchain de
selftests/nolibc: make sure gcc always use little endian on MIPS
The test on MIPS stopped working after I upgraded some of my toolchains to use the ones from kernel.org because the mips toolchain defaults to big endian, even though it supports both endians. Let's just add an explicit -EL to make sure it always succeeds like the kernel does.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
fa0df56a | 04-Jun-2023 |
Willy Tarreau <w@1wt.eu> |
selftests/nolibc: also count skipped and failed tests in output
Right now skipped and failed test counts are not reported, and a few times already we missed skipped ones that ought not to. Let's now
selftests/nolibc: also count skipped and failed tests in output
Right now skipped and failed test counts are not reported, and a few times already we missed skipped ones that ought not to. Let's now count each category and continue to invite the user to check the report file when skipped+fail > 0. E.g:
$ make run-user (...) CC nolibc-test 136 test(s) passed, 2 skipped, 0 failed. See all results in .../run.out
Note that it's important to be careful about the trailing \r on the qemu output (thanks Zhangjin for noticing).
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
957bfa31 | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: add new gettimeofday test cases
These 2 test cases are added to cover the normal using scenes of gettimeofday().
They have been used to trigger and fix up such issue with nolibc:
selftests/nolibc: add new gettimeofday test cases
These 2 test cases are added to cover the normal using scenes of gettimeofday().
They have been used to trigger and fix up such issue with nolibc:
nolibc-test.c:(.text.gettimeofday+0x54): undefined reference to `__aeabi_ldivmod'
This issue happens while there is no "unsigned int" conversion in the coming new clock_gettime / clock_gettime64 syscall path of gettimeofday():
tv->tv_usec = ts.tv_nsec / 1000;
Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/linux-riscv/280867a8-7601-4a96-9b85-87668e1f1282@t-8ch.de/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
4cbab2ec | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: remove gettimeofday_bad1/2 completely
In the clock_gettime / clock_gettime64 syscalls based gettimeofday(), there is no way to let kernel space 'fixup' the invalid data pointer of
selftests/nolibc: remove gettimeofday_bad1/2 completely
In the clock_gettime / clock_gettime64 syscalls based gettimeofday(), there is no way to let kernel space 'fixup' the invalid data pointer of 'struct timeval' and 'struct timezone' for us for we need to read timespec from kernel space and then convert to timeval in user-space ourselves and also we need to simply ignore and reset timezone in user-space.
Without this removal, the invalid (void *)1 address will trigger a sigsegv (signum = 11) signal and stop the whole test.
Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
75d75a7b | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: support two errnos with EXPECT_SYSER2()
Some functions may be implemented with different syscalls in different platforms, these syscalls may set different errnos for the same argum
selftests/nolibc: support two errnos with EXPECT_SYSER2()
Some functions may be implemented with different syscalls in different platforms, these syscalls may set different errnos for the same arguments, let's support such cases.
Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/linux-riscv/20230528113325.GJ1956@1wt.eu/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
a36cfc5e | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: use INT_MAX instead of __INT_MAX__
nolibc now has INT_MAX in stdint.h, so, don't mix INT_MAX and __INT_MAX__, unify them to INT_MAX.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org
selftests/nolibc: use INT_MAX instead of __INT_MAX__
nolibc now has INT_MAX in stdint.h, so, don't mix INT_MAX and __INT_MAX__, unify them to INT_MAX.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
bd27fef3 | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: not include limits.h for nolibc
When compile nolibc-test.c with 2.31 glibc, we got such error:
In file included from /usr/riscv64-linux-gnu/include/sys/cdefs.h:452,
selftests/nolibc: not include limits.h for nolibc
When compile nolibc-test.c with 2.31 glibc, we got such error:
In file included from /usr/riscv64-linux-gnu/include/sys/cdefs.h:452, from /usr/riscv64-linux-gnu/include/features.h:461, from /usr/riscv64-linux-gnu/include/bits/libc-header-start.h:33, from /usr/riscv64-linux-gnu/include/limits.h:26, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:194, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/syslimits.h:7, from /usr/lib/gcc-cross/riscv64-linux-gnu/9/include/limits.h:34, from /labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/nolibc-test.c:6: /usr/riscv64-linux-gnu/include/bits/wordsize.h:28:3: error: #error "rv32i-based targets are not supported" 28 | # error "rv32i-based targets are not supported"
Glibc (>= 2.33) commit 5b6113d62efa ("RISC-V: Support the 32-bit ABI implementation") fixed up above error.
As suggested by Thomas, defining INT_MIN/INT_MAX for nolibc can remove the including of limits.h, and therefore no above error. of course, the other libcs still require limits.h, move it to the right place.
The LONG_MIN/LONG_MAX are also defined too.
Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/linux-riscv/09d60dc2-e298-4c22-8e2f-8375861bd9be@t-8ch.de/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
0858aec4 | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: fix up compile warning with glibc on x86_64
Compiling nolibc-test.c with gcc on x86_64 got such warning:
tools/testing/selftests/nolibc/nolibc-test.c: In function ‘expect_eq’: too
selftests/nolibc: fix up compile warning with glibc on x86_64
Compiling nolibc-test.c with gcc on x86_64 got such warning:
tools/testing/selftests/nolibc/nolibc-test.c: In function ‘expect_eq’: tools/testing/selftests/nolibc/nolibc-test.c:177:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=] 177 | llen += printf(" = %lld ", expr); | ~~~^ ~~~~ | | | | | uint64_t {aka long unsigned int} | long long int | %ld
It because that glibc defines uint64_t as "unsigned long int" when word size (means sizeof(long)) is 64bit (see include/bits/types.h), but nolibc directly use the 64bit "unsigned long long" (see tools/include/nolibc/stdint.h), which is simpler, seems kernel uses it too (include/uapi/asm-generic/int-ll64.h).
use a simple conversion to solve it.
Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/linux-riscv/20230529130449.GA2813@1wt.eu/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
c88e46d6 | 03-Jun-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: allow specify extra arguments for qemu
The opensbi package from Ubuntu 20.04 only provides rv64 firmwares:
$ dpkg -S opensbi | grep -E "fw_.*bin|fw_.*elf" | uniq opensbi:
selftests/nolibc: allow specify extra arguments for qemu
The opensbi package from Ubuntu 20.04 only provides rv64 firmwares:
$ dpkg -S opensbi | grep -E "fw_.*bin|fw_.*elf" | uniq opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.bin opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.elf opensbi: /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf
To run this nolibc test for rv32, users must build opensbi or download a prebuilt one from qemu repository:
https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/opensbi-riscv32-generic-fw_dynamic.bin
And then use -bios to tell qemu use it to avoid such failure:
$ qemu-system-riscv32 -display none -no-reboot -kernel /path/to/arch/riscv/boot/Image -serial stdio -M virt -append "console=ttyS0 panic=-1" qemu-system-riscv32: Unable to load the RISC-V firmware "opensbi-riscv32-generic-fw_dynamic.bin"
To run from makefile, QEMU_ARGS_EXTRA is added to allow pass extra arguments like -bios:
$ make run QEMU_ARGS_EXTRA="-bios /path/to/opensbi-riscv32-generic-fw_dynamic.bin" ...
Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/linux-riscv/2ab94136-d341-4a26-964e-6d6c32e66c9b@t-8ch.de/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
a4c65af1 | 30-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
selftests/nolibc: remove test gettimeofday_null
gettimeofday() is not guaranteed by posix to handle a NULL value as first argument gracefully. On glibc for example it crashes. (When not going throug
selftests/nolibc: remove test gettimeofday_null
gettimeofday() is not guaranteed by posix to handle a NULL value as first argument gracefully. On glibc for example it crashes. (When not going through the vdso)
Link: https://lore.kernel.org/lkml/96f1134d-ce6e-4d82-ae00-1cd4038809c4@t-8ch.de/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
f9bf5944 | 30-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: ensure fast64 integer types have 64 bits
On 32bit platforms size_t is not enough to represent [u]int_fast64_t.
Fixes: 3e9fd4e9a1d5 ("tools/nolibc: add integer types and integer limit
tools/nolibc: ensure fast64 integer types have 64 bits
On 32bit platforms size_t is not enough to represent [u]int_fast64_t.
Fixes: 3e9fd4e9a1d5 ("tools/nolibc: add integer types and integer limit macros") Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
ed495f09 | 30-May-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: test_fork: fix up duplicated print
running nolibc-test with glibc on x86_64 got such print issue:
29 execve_root = -1 EACCES [OK] 30
selftests/nolibc: test_fork: fix up duplicated print
running nolibc-test with glibc on x86_64 got such print issue:
29 execve_root = -1 EACCES [OK] 30 fork30 fork = 0 [OK] 31 getdents64_root = 712 [OK]
The fork test case has three printf calls:
(1) llen += printf("%d %s", test, #name); (2) llen += printf(" = %d %s ", expr, errorname(errno)); (3) llen += pad_spc(llen, 64, "[FAIL]\n"); --> vfprintf()
In the following scene, the above issue happens:
(a) The parent calls (1) (b) The parent calls fork() (c) The child runs and shares the print buffer of (1) (d) The child exits, flushs the print buffer and closes its own stdout/stderr * "30 fork" is printed at the first time. (e) The parent calls (2) and (3), with "\n" in (3), it flushs the whole buffer * "30 fork = 0 ..." is printed
Therefore, there are two "30 fork" in the stdout.
Between (a) and (b), if flush the stdout (and the sterr), the child in stage (c) will not be able to 'see' the print buffer.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
da1affc5 | 24-May-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: remove the duplicated gettimeofday_bad2
There were two exactly similar occurrences of this test.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Signed-off-by: Willy Tarreau <w@1w
selftests/nolibc: remove the duplicated gettimeofday_bad2
There were two exactly similar occurrences of this test.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
758f970f | 24-May-2023 |
Zhangjin Wu <falcon@tinylab.org> |
selftests/nolibc: print name instead of number for EOVERFLOW
EOVERFLOW will be used in the coming time64 syscalls support.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißsc
selftests/nolibc: print name instead of number for EOVERFLOW
EOVERFLOW will be used in the coming time64 syscalls support.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
87b9fa66 | 27-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: support nanoseconds in stat()
Keep backwards compatibility through unions.
The compatibility macros like
#define st_atime st_atim.tv_sec
as documented in stat(3type) don't work for
tools/nolibc: support nanoseconds in stat()
Keep backwards compatibility through unions.
The compatibility macros like
#define st_atime st_atim.tv_sec
as documented in stat(3type) don't work for nolibc because it would break with other stat-like structures that contain the field st_atime.
The stx_atime, stx_mtime, stx_ctime are in type of 'struct statx_timestamp', which is incompatible with 'struct timespec', should be converted explicitly.
/* include/uapi/linux/stat.h */
struct statx_timestamp { __s64 tv_sec; __u32 tv_nsec; __s32 __reserved; };
/* include/uapi/linux/time.h */ struct timespec { __kernel_old_time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ };
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/linux-riscv/3a3edd48-1ace-4c89-89e8-9c594dd1b3c9@t-8ch.de/ Co-authored-by: Zhangjin Wu <falcon@tinylab.org> Signed-off-by: Zhangjin Wu <falcon@tinylab.org> [wt: squashed Zhangjin & Thomas' patches into one to preserve "bisectability"] Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
9a75575b | 26-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
selftests/nolibc: prevent coredumps during test execution
The child process forked during stackprotector tests intentionally gets killed with SIGABRT. By default this will trigger writing a coredump
selftests/nolibc: prevent coredumps during test execution
The child process forked during stackprotector tests intentionally gets killed with SIGABRT. By default this will trigger writing a coredump. The writing of the coredump can spam the systems coredump machinery and take some time.
Timings for the full run of nolibc-test: Before: 200ms After: 20ms
This is on a desktop x86 system with systemd-coredumpd enabled.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
208aa9d9 | 26-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add support for prctl()
It will be used to disable core dumps from the child spawned to validate the stack protector functionality.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.n
tools/nolibc: add support for prctl()
It will be used to disable core dumps from the child spawned to validate the stack protector functionality.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
0093c2da | 21-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: simplify stackprotector compiler flags
Now that nolibc enable stackprotector support automatically when the compiler enables it we only have to get the -fstack-protector flags correct.
tools/nolibc: simplify stackprotector compiler flags
Now that nolibc enable stackprotector support automatically when the compiler enables it we only have to get the -fstack-protector flags correct.
The cc-options are structured so that -fstack-protector-all is only enabled if -mstack-protector=guard works, as that is the only mode supported by nolibc.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
818924d1 | 21-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add autodetection for stackprotector support
The stackprotector support in nolibc should be enabled iff it is also enabled in the compiler. Use the preprocessor defines added by gcc an
tools/nolibc: add autodetection for stackprotector support
The stackprotector support in nolibc should be enabled iff it is also enabled in the compiler. Use the preprocessor defines added by gcc and clang if stackprotector support is enable to automatically do so in nolibc.
This completely removes the need for any user-visible API.
To avoid inlining the lengthy preprocessor check into every user introduce a new header compiler.h that abstracts the logic away.
As the define NOLIBC_STACKPROTECTOR is now not user-relevant anymore prefix it with an underscore.
Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/lkml/20230520133237.GA27501@1wt.eu/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
85250921 | 21-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add test for __stack_chk_guard initialization
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@ke
tools/nolibc: add test for __stack_chk_guard initialization
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
56d294a5 | 20-May-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: riscv: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-o
tools/nolibc: riscv: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
3da0de37 | 17-Apr-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: mips: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> |
ca2d0437 | 17-Apr-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: loongarch: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> |
ed6c0d89 | 17-Apr-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: arm: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> |
c1e30f7d | 17-Apr-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: aarch64: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> |