* [PATCH v2 0/3] tools/nolibc: add support for SuperH
@ 2025-06-23 21:15 Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 1/3] selftests/nolibc: fix EXTRACONFIG variables ordering Thomas Weißschuh
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-06-23 21:15 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
Willy Tarreau, Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel, Thomas Weißschuh
Add support for SuperH/"sh" to nolibc.
Only sh4 is tested for now.
This is only tested on QEMU so far.
Additional testing would be very welcome.
Test instructions:
$ cd tools/testings/selftests/nolibc/
$ make -f Makefile.nolibc ARCH=sh CROSS_COMPILE=sh4-linux- nolibc-test
$ file nolibc-test
nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), statically linked, not stripped
$ ./nolibc-test
Running test 'startup'
0 argc = 1 [OK]
...
Total number of errors: 0
Exiting with status 0
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Rebase onto latest nolibc-next
- Pick up Ack from Willy
- Provide some test instructions
- Link to v1: https://lore.kernel.org/r/20250609-nolibc-sh-v1-0-9dcdb1b66bb5@weissschuh.net
---
Thomas Weißschuh (3):
selftests/nolibc: fix EXTRACONFIG variables ordering
selftests/nolibc: use file driver for QEMU serial
tools/nolibc: add support for SuperH
tools/include/nolibc/arch-sh.h | 162 +++++++++++++++++++++++++
tools/include/nolibc/arch.h | 2 +
tools/testing/selftests/nolibc/Makefile.nolibc | 15 ++-
tools/testing/selftests/nolibc/run-tests.sh | 3 +-
4 files changed, 177 insertions(+), 5 deletions(-)
---
base-commit: eb135311083100b6590a7545618cd9760d896a86
change-id: 20250528-nolibc-sh-8b4e3bb8efcb
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] selftests/nolibc: fix EXTRACONFIG variables ordering
2025-06-23 21:15 [PATCH v2 0/3] tools/nolibc: add support for SuperH Thomas Weißschuh
@ 2025-06-23 21:15 ` Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 2/3] selftests/nolibc: use file driver for QEMU serial Thomas Weißschuh
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-06-23 21:15 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
Willy Tarreau, Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel, Thomas Weißschuh
The variable block got disordered at some point.
Use the correct ordering.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
---
tools/testing/selftests/nolibc/Makefile.nolibc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index 6d62f350d0c16405785a8aabc7f5741b82e55370..9e220a733d97f3f916c6aa38df2414781f17ef94 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -107,10 +107,10 @@ DEFCONFIG_sparc64 = sparc64_defconfig
DEFCONFIG_m68k = virt_defconfig
DEFCONFIG = $(DEFCONFIG_$(XARCH))
-EXTRACONFIG_m68k = -e CONFIG_BLK_DEV_INITRD
-EXTRACONFIG = $(EXTRACONFIG_$(XARCH))
EXTRACONFIG_arm = -e CONFIG_NAMESPACES
EXTRACONFIG_armthumb = -e CONFIG_NAMESPACES
+EXTRACONFIG_m68k = -e CONFIG_BLK_DEV_INITRD
+EXTRACONFIG = $(EXTRACONFIG_$(XARCH))
# optional tests to run (default = all)
TEST =
--
2.50.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] selftests/nolibc: use file driver for QEMU serial
2025-06-23 21:15 [PATCH v2 0/3] tools/nolibc: add support for SuperH Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 1/3] selftests/nolibc: fix EXTRACONFIG variables ordering Thomas Weißschuh
@ 2025-06-23 21:15 ` Thomas Weißschuh
2025-06-24 8:56 ` Sergey Shtylyov
2025-06-23 21:15 ` [PATCH v2 3/3] tools/nolibc: add support for SuperH Thomas Weißschuh
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2025-06-23 21:15 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
Willy Tarreau, Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel, Thomas Weißschuh
For the test implementation of the SuperH architecture a second serial
serial port needs to be used. Unfortunately the currently used 'stdio'
driver does not support multiple serial ports at the same time.
Switch to the 'file' driver which does support multiple ports and is
sufficient for the nolibc-test usecase.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
---
tools/testing/selftests/nolibc/Makefile.nolibc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index 9e220a733d97f3f916c6aa38df2414781f17ef94..ba3b762cb103ee87aafecbd5e838fc0e678b7b50 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -311,12 +311,12 @@ kernel-standalone: initramfs
# run the tests after building the kernel
run: kernel initramfs.cpio
- $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
+ $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial file:/dev/stdout $(QEMU_ARGS) > "$(CURDIR)/run.out"
$(Q)$(REPORT) $(CURDIR)/run.out
# re-run the tests from an existing kernel
rerun:
- $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out"
+ $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial file:/dev/stdout $(QEMU_ARGS) > "$(CURDIR)/run.out"
$(Q)$(REPORT) $(CURDIR)/run.out
# report with existing test log
--
2.50.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] tools/nolibc: add support for SuperH
2025-06-23 21:15 [PATCH v2 0/3] tools/nolibc: add support for SuperH Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 1/3] selftests/nolibc: fix EXTRACONFIG variables ordering Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 2/3] selftests/nolibc: use file driver for QEMU serial Thomas Weißschuh
@ 2025-06-23 21:15 ` Thomas Weißschuh
2025-06-24 6:03 ` [PATCH v2 0/3] " John Paul Adrian Glaubitz
2025-06-25 9:47 ` John Paul Adrian Glaubitz
4 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-06-23 21:15 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
Willy Tarreau, Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel, Thomas Weißschuh
Add support for SuperH/"sh" to nolibc.
Only sh4 is tested for now.
The startup code is special:
__nolibc_entrypoint_epilogue() calls __builtin_unreachable() which emits
a call to abort(). To make this work a function prologue is generated to
set up a GOT pointer which corrupts "sp".
__builtin_unreachable() is necessary for __attribute__((noreturn)).
Also depending on compiler flags (for example -fPIC) even more prologue
is generated.
Work around this by defining a nested function in asm.
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70216
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
---
tools/include/nolibc/arch-sh.h | 162 +++++++++++++++++++++++++
tools/include/nolibc/arch.h | 2 +
tools/testing/selftests/nolibc/Makefile.nolibc | 7 ++
tools/testing/selftests/nolibc/run-tests.sh | 3 +-
4 files changed, 173 insertions(+), 1 deletion(-)
diff --git a/tools/include/nolibc/arch-sh.h b/tools/include/nolibc/arch-sh.h
new file mode 100644
index 0000000000000000000000000000000000000000..1ad006cba0f627f663eea36b41bc7399cca4addb
--- /dev/null
+++ b/tools/include/nolibc/arch-sh.h
@@ -0,0 +1,162 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * SuperH specific definitions for NOLIBC
+ * Copyright (C) 2025 Thomas Weißschuh <linux@weissschuh.net>
+ */
+
+#ifndef _NOLIBC_ARCH_SH_H
+#define _NOLIBC_ARCH_SH_H
+
+#include "compiler.h"
+#include "crt.h"
+
+/*
+ * Syscalls for SuperH:
+ * - registers are 32bit wide
+ * - syscall number is passed in r3
+ * - arguments are in r4, r5, r6, r7, r0, r1, r2
+ * - the system call is performed by calling trapa #31
+ * - syscall return value is in r0
+ */
+
+#define my_syscall0(num) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "+r"(_ret) \
+ : "r"(_num) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+#define my_syscall1(num, arg1) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ register long _arg1 __asm__ ("r4") = (long)(arg1); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "=r"(_ret) \
+ : "r"(_num), "r"(_arg1) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+#define my_syscall2(num, arg1, arg2) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ register long _arg1 __asm__ ("r4") = (long)(arg1); \
+ register long _arg2 __asm__ ("r5") = (long)(arg2); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "=r"(_ret) \
+ : "r"(_num), "r"(_arg1), "r"(_arg2) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+#define my_syscall3(num, arg1, arg2, arg3) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ register long _arg1 __asm__ ("r4") = (long)(arg1); \
+ register long _arg2 __asm__ ("r5") = (long)(arg2); \
+ register long _arg3 __asm__ ("r6") = (long)(arg3); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "=r"(_ret) \
+ : "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+#define my_syscall4(num, arg1, arg2, arg3, arg4) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ register long _arg1 __asm__ ("r4") = (long)(arg1); \
+ register long _arg2 __asm__ ("r5") = (long)(arg2); \
+ register long _arg3 __asm__ ("r6") = (long)(arg3); \
+ register long _arg4 __asm__ ("r7") = (long)(arg4); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "=r"(_ret) \
+ : "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ register long _arg1 __asm__ ("r4") = (long)(arg1); \
+ register long _arg2 __asm__ ("r5") = (long)(arg2); \
+ register long _arg3 __asm__ ("r6") = (long)(arg3); \
+ register long _arg4 __asm__ ("r7") = (long)(arg4); \
+ register long _arg5 __asm__ ("r0") = (long)(arg5); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "=r"(_ret) \
+ : "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \
+({ \
+ register long _num __asm__ ("r3") = (num); \
+ register long _ret __asm__ ("r0"); \
+ register long _arg1 __asm__ ("r4") = (long)(arg1); \
+ register long _arg2 __asm__ ("r5") = (long)(arg2); \
+ register long _arg3 __asm__ ("r6") = (long)(arg3); \
+ register long _arg4 __asm__ ("r7") = (long)(arg4); \
+ register long _arg5 __asm__ ("r0") = (long)(arg5); \
+ register long _arg6 __asm__ ("r1") = (long)(arg6); \
+ \
+ __asm__ volatile ( \
+ "trapa #31" \
+ : "=r"(_ret) \
+ : "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_arg6) \
+ : "memory", "cc" \
+ ); \
+ _ret; \
+})
+
+/* startup code */
+void _start_wrapper(void);
+void __attribute__((weak,noreturn)) __nolibc_entrypoint __no_stack_protector _start_wrapper(void)
+{
+ __asm__ volatile (
+ ".global _start\n" /* The C function will have a prologue, */
+ ".type _start, @function\n" /* corrupting "sp" */
+ ".weak _start\n"
+ "_start:\n"
+
+ "mov sp, r4\n" /* save argc pointer to r4, as arg1 of _start_c */
+ "bsr _start_c\n" /* transfer to c runtime */
+ "nop\n" /* delay slot */
+
+ ".size _start, .-_start\n"
+ );
+ __nolibc_entrypoint_epilogue();
+}
+
+#endif /* _NOLIBC_ARCH_SH_H */
diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h
index 4ae57aaf9779610dfb63458416f147116d0a98e6..5a34bce2981eaec557bc3616c7ef7b809a6dbf0b 100644
--- a/tools/include/nolibc/arch.h
+++ b/tools/include/nolibc/arch.h
@@ -35,6 +35,8 @@
#include "arch-sparc.h"
#elif defined(__m68k__)
#include "arch-m68k.h"
+#elif defined(__sh__)
+#include "arch-sh.h"
#else
#error Unsupported Architecture
#endif
diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index ba3b762cb103ee87aafecbd5e838fc0e678b7b50..41c708419d761df5de9e7df97b2f070396e8cbf3 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -58,6 +58,7 @@ ARCH_riscv64 = riscv
ARCH_s390x = s390
ARCH_sparc32 = sparc
ARCH_sparc64 = sparc
+ARCH_sh4 = sh
ARCH := $(or $(ARCH_$(XARCH)),$(XARCH))
# kernel image names by architecture
@@ -81,6 +82,7 @@ IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi
IMAGE_sparc32 = arch/sparc/boot/image
IMAGE_sparc64 = arch/sparc/boot/image
IMAGE_m68k = vmlinux
+IMAGE_sh4 = arch/sh/boot/zImage
IMAGE = $(objtree)/$(IMAGE_$(XARCH))
IMAGE_NAME = $(notdir $(IMAGE))
@@ -105,11 +107,13 @@ DEFCONFIG_loongarch = defconfig
DEFCONFIG_sparc32 = sparc32_defconfig
DEFCONFIG_sparc64 = sparc64_defconfig
DEFCONFIG_m68k = virt_defconfig
+DEFCONFIG_sh4 = rts7751r2dplus_defconfig
DEFCONFIG = $(DEFCONFIG_$(XARCH))
EXTRACONFIG_arm = -e CONFIG_NAMESPACES
EXTRACONFIG_armthumb = -e CONFIG_NAMESPACES
EXTRACONFIG_m68k = -e CONFIG_BLK_DEV_INITRD
+EXTRACONFIG_sh4 = -e CONFIG_BLK_DEV_INITRD -e CONFIG_CMDLINE_FROM_BOOTLOADER
EXTRACONFIG = $(EXTRACONFIG_$(XARCH))
# optional tests to run (default = all)
@@ -136,6 +140,7 @@ QEMU_ARCH_loongarch = loongarch64
QEMU_ARCH_sparc32 = sparc
QEMU_ARCH_sparc64 = sparc64
QEMU_ARCH_m68k = m68k
+QEMU_ARCH_sh4 = sh4
QEMU_ARCH = $(QEMU_ARCH_$(XARCH))
QEMU_ARCH_USER_ppc64le = ppc64le
@@ -169,6 +174,7 @@ QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=N
QEMU_ARGS_sparc32 = -M SS-5 -m 256M -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_sparc64 = -M sun4u -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_m68k = -M virt -append "console=ttyGF0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
+QEMU_ARGS_sh4 = -M r2d -serial file:/dev/stdout -append "console=ttySC1,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS = -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)
# OUTPUT is only set when run from the main makefile, otherwise
@@ -192,6 +198,7 @@ CFLAGS_s390 = -m31
CFLAGS_mips32le = -EL -mabi=32 -fPIC
CFLAGS_mips32be = -EB -mabi=32
CFLAGS_sparc32 = $(call cc-option,-m32)
+CFLAGS_sh4 = -ml -m4
ifeq ($(origin XARCH),command line)
CFLAGS_XARCH = $(CFLAGS_$(XARCH))
endif
diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh
index 279fbd93ef70497868689b7f1e14ddc6c5c1a15f..c55d6d3c10bba5df7f7e6413eea496148a5fbf52 100755
--- a/tools/testing/selftests/nolibc/run-tests.sh
+++ b/tools/testing/selftests/nolibc/run-tests.sh
@@ -27,6 +27,7 @@ all_archs=(
loongarch
sparc32 sparc64
m68k
+ sh4
)
archs="${all_archs[@]}"
@@ -187,7 +188,7 @@ test_arch() {
echo "Unsupported configuration"
return
fi
- if [ "$arch" = "m68k" ] && [ "$llvm" = "1" ]; then
+ if [ "$arch" = "m68k" -o "$arch" = "sh4" ] && [ "$llvm" = "1" ]; then
echo "Unsupported configuration"
return
fi
--
2.50.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] tools/nolibc: add support for SuperH
2025-06-23 21:15 [PATCH v2 0/3] tools/nolibc: add support for SuperH Thomas Weißschuh
` (2 preceding siblings ...)
2025-06-23 21:15 ` [PATCH v2 3/3] tools/nolibc: add support for SuperH Thomas Weißschuh
@ 2025-06-24 6:03 ` John Paul Adrian Glaubitz
2025-06-24 6:07 ` Willy Tarreau
2025-06-25 9:47 ` John Paul Adrian Glaubitz
4 siblings, 1 reply; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2025-06-24 6:03 UTC (permalink / raw)
To: Thomas Weißschuh, Yoshinori Sato, Rich Felker, Willy Tarreau,
Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel
Hi Thomas,
On Mon, 2025-06-23 at 23:15 +0200, Thomas Weißschuh wrote:
> Add support for SuperH/"sh" to nolibc.
> Only sh4 is tested for now.
>
> This is only tested on QEMU so far.
> Additional testing would be very welcome.
> Test instructions:
> $ cd tools/testings/selftests/nolibc/
> $ make -f Makefile.nolibc ARCH=sh CROSS_COMPILE=sh4-linux- nolibc-test
> $ file nolibc-test
> nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), statically linked, not stripped
> $ ./nolibc-test
> Running test 'startup'
> 0 argc = 1 [OK]
> ...
> Total number of errors: 0
> Exiting with status 0
Apologies, I haven't been able to test this yet as my board currently
doesn't want to boot kernels newer than v6.5.0 and I have not been able
to bisect the problem yet.
Can I test this on v6.5.0 as well?
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] tools/nolibc: add support for SuperH
2025-06-24 6:03 ` [PATCH v2 0/3] " John Paul Adrian Glaubitz
@ 2025-06-24 6:07 ` Willy Tarreau
0 siblings, 0 replies; 8+ messages in thread
From: Willy Tarreau @ 2025-06-24 6:07 UTC (permalink / raw)
To: John Paul Adrian Glaubitz
Cc: Thomas Weißschuh, Yoshinori Sato, Rich Felker, Shuah Khan,
linux-sh, linux-kselftest, linux-kernel
Hi Adrian,
On Tue, Jun 24, 2025 at 08:03:47AM +0200, John Paul Adrian Glaubitz wrote:
> Hi Thomas,
>
> On Mon, 2025-06-23 at 23:15 +0200, Thomas Weißschuh wrote:
> > Add support for SuperH/"sh" to nolibc.
> > Only sh4 is tested for now.
> >
> > This is only tested on QEMU so far.
> > Additional testing would be very welcome.
> > Test instructions:
> > $ cd tools/testings/selftests/nolibc/
> > $ make -f Makefile.nolibc ARCH=sh CROSS_COMPILE=sh4-linux- nolibc-test
> > $ file nolibc-test
> > nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), statically linked, not stripped
> > $ ./nolibc-test
> > Running test 'startup'
> > 0 argc = 1 [OK]
> > ...
> > Total number of errors: 0
> > Exiting with status 0
>
> Apologies, I haven't been able to test this yet as my board currently
> doesn't want to boot kernels newer than v6.5.0 and I have not been able
> to bisect the problem yet.
>
> Can I test this on v6.5.0 as well?
In theory it should be OK as we try to support oldest supported kernels.
Willy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] selftests/nolibc: use file driver for QEMU serial
2025-06-23 21:15 ` [PATCH v2 2/3] selftests/nolibc: use file driver for QEMU serial Thomas Weißschuh
@ 2025-06-24 8:56 ` Sergey Shtylyov
0 siblings, 0 replies; 8+ messages in thread
From: Sergey Shtylyov @ 2025-06-24 8:56 UTC (permalink / raw)
To: Thomas Weißschuh, Yoshinori Sato, Rich Felker,
John Paul Adrian Glaubitz, Willy Tarreau, Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel
On 6/24/25 12:15 AM, Thomas Weißschuh wrote:
> For the test implementation of the SuperH architecture a second serial
> serial port needs to be used. Unfortunately the currently used 'stdio'
"Serial" typed twice? :-)
> driver does not support multiple serial ports at the same time.
>
> Switch to the 'file' driver which does support multiple ports and is
> sufficient for the nolibc-test usecase.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> Acked-by: Willy Tarreau <w@1wt.eu>
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/3] tools/nolibc: add support for SuperH
2025-06-23 21:15 [PATCH v2 0/3] tools/nolibc: add support for SuperH Thomas Weißschuh
` (3 preceding siblings ...)
2025-06-24 6:03 ` [PATCH v2 0/3] " John Paul Adrian Glaubitz
@ 2025-06-25 9:47 ` John Paul Adrian Glaubitz
4 siblings, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2025-06-25 9:47 UTC (permalink / raw)
To: Thomas Weißschuh, Yoshinori Sato, Rich Felker, Willy Tarreau,
Shuah Khan
Cc: linux-sh, linux-kselftest, linux-kernel
Hi Thomas,
On Mon, 2025-06-23 at 23:15 +0200, Thomas Weißschuh wrote:
> Add support for SuperH/"sh" to nolibc.
> Only sh4 is tested for now.
>
> This is only tested on QEMU so far.
> Additional testing would be very welcome.
> Test instructions:
> $ cd tools/testings/selftests/nolibc/
> $ make -f Makefile.nolibc ARCH=sh CROSS_COMPILE=sh4-linux- nolibc-test
> $ file nolibc-test
> nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), statically linked, not stripped
> $ ./nolibc-test
> Running test 'startup'
> 0 argc = 1 [OK]
> ...
> Total number of errors: 0
> Exiting with status 0
Here is the testrun of the nolibc-test on my SH7785LCR evaluation board:
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc$ cat /proc/cpuinfo
machine : SH7785LCR
processor : 0
cpu family : sh4a
cpu type : SH7785
cut : 7.x
cpu flags : fpu perfctr llsc
cache type : split (harvard)
icache size : 32KiB (4-way)
dcache size : 32KiB (4-way)
address sizes : 32 bits physical
bogomips : 599.99
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc$ uname -a
Linux tirpitz.buildd.org 6.5.0-rc2 #1 PREEMPT Mon Jul 17 14:17:32 UTC 2023 sh4a GNU/Linux
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc$ cd tools/testing/selftests/nolibc/
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$ make -f Makefile.nolibc ARCH=sh nolibc-test
MKDIR sysroot/sh/include
make[1]: Entering directory '/srv/glaubitz/linux-nolibc'
make[2]: Nothing to be done for 'outputmakefile'.
make[1]: Leaving directory '/srv/glaubitz/linux-nolibc'
make[1]: Entering directory '/srv/glaubitz/linux-nolibc/tools/include/nolibc'
make[2]: Entering directory '/srv/glaubitz/linux-nolibc'
UPD include/generated/uapi/linux/version.h
HOSTCC scripts/basic/fixdep
HOSTCC scripts/unifdef
WRAP arch/sh/include/generated/uapi/asm/ucontext.h
WRAP arch/sh/include/generated/uapi/asm/bitsperlong.h
WRAP arch/sh/include/generated/uapi/asm/bpf_perf_event.h
WRAP arch/sh/include/generated/uapi/asm/errno.h
WRAP arch/sh/include/generated/uapi/asm/fcntl.h
WRAP arch/sh/include/generated/uapi/asm/ioctl.h
WRAP arch/sh/include/generated/uapi/asm/ipcbuf.h
WRAP arch/sh/include/generated/uapi/asm/mman.h
(...)
HDRINST usr/include/asm/statfs.h
HDRINST usr/include/asm/types.h
HDRINST usr/include/asm/setup.h
HDRINST usr/include/asm/resource.h
HDRINST usr/include/asm/termios.h
HDRINST usr/include/asm/poll.h
make[2]: Leaving directory '/srv/glaubitz/linux-nolibc'
make[2]: Entering directory '/srv/glaubitz/linux-nolibc'
INSTALL /srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc/sysroot/sysroot/include
make[2]: Leaving directory '/srv/glaubitz/linux-nolibc'
make[1]: Leaving directory '/srv/glaubitz/linux-nolibc/tools/include/nolibc'
CC nolibc-test
In file included from sysroot/sh/include/arch.h:11,
from sysroot/sh/include/nolibc.h:96,
from sysroot/sh/include/stdio.h:8,
from nolibc-test.c:12:
sysroot/sh/include/crt.h:34:1: warning: ‘function’ attribute directive ignored [-Wattributes]
34 | {
| ^
In file included from sysroot/sh/include/arch.h:11,
from sysroot/sh/include/nolibc.h:96,
from sysroot/sh/include/errno.h:8,
from nolibc-test-linkage.c:5:
sysroot/sh/include/crt.h:34:1: warning: ‘function’ attribute directive ignored [-Wattributes]
34 | {
| ^
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$ file ./nolibc-test
./nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV), statically linked, BuildID[sha1]=b23b591a8deeb8b746636128821be1b577f3266b, not stripped
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$ ./nolibc-test
Running test 'startup'
0 argc = 1 [OK]
1 argv_addr = <0x7bd4b074> [OK]
2 argv_environ = <0x7bd4b074> [OK]
3 argv_total = 1 [OK]
4 argv0_addr = <0x7bd4b1c2> [OK]
5 argv0_str = <./nolibc-test> [OK]
6 argv0_len = 13 [OK]
7 environ_addr = <0x7bd4b07c> [OK]
8 environ_envp = <0x7bd4b07c> [OK]
9 environ_auxv = <0x7bd4b07c> [OK]
10 environ_total = 111 [OK]
11 environ_HOME = <0x7bd4b672> [OK]
12 auxv_addr = <0x7bd4b0ec> [OK]
13 auxv_AT_UID = 1000 [OK]
14 constructor = 3 [OK]
15 linkage_errno = <0x42003c> [OK]
16 linkage_constr = 3 [OK]
Errors during this test: 0
Running test 'syscall'
0 access = 0 [OK]
1 access_bad = -1 EPERM [OK]
2 clock_getres = 0 [OK]
3 clock_gettime = 0 [OK]
4 clock_settime = -1 EINVAL [OK]
5 getpid = 24641 [OK]
6 getppid = 17166 [OK]
7 gettid = 24641 [OK]
8 getpgid_self = 24641 [OK]
9 getpgid_bad = -1 ESRCH [OK]
10 kill_0 = 0 [OK]
11 kill_CONT = 0 [OK]
12 kill_BADPID = -1 ESRCH [OK]
13 sbrk_0 = <0x421000> [OK]
14 sbrk = 0 [OK]
15 brk = 0 [OK]
16 chdir_root = 0 [OK]
17 chdir_dot = 0 [OK]
18 chdir_blah = -1 ENOENT [OK]
19 chmod_argv0 = 0 [OK]
20 chmod_self = -1 EPERM [OK]
21 chown_self = -1 EPERM [OK]
22 chroot_root [SKIPPED]
23 chroot_blah = -1 ENOENT [OK]
24 chroot_exe = -1 ENOTDIR [OK]
25 close_m1 = -1 EBADF [OK]
26 close_dup = 0 [OK]
27 dup_0 = 3 [OK]
28 dup_m1 = -1 EBADF [OK]
29 dup2_0 = 100 [OK]
30 dup2_m1 = -1 EBADF [OK]
31 dup3_0 = 100 [OK]
32 dup3_m1 = -1 EBADF [OK]
33 execve_root = -1 EACCES [OK]
34 file_stream = 0 [OK]
35 fork = 0 [OK]
36 getdents64_root = 944 [OK]
37 getdents64_null = -1 ENOTDIR [OK]
38 directories = 0 [OK]
39 getrandom = 0 [OK]
40 gettimeofday_tv = 0 [OK]
41 gettimeofday_tv_tz = 0 [OK]
42 getpagesize = 0 [OK]
43 ioctl_tiocinq = 0 [OK]
44 link_root1 = -1 EEXIST [OK]
45 link_blah = -1 ENOENT [OK]
46 link_dir [SKIPPED]
47 link_cross = -1 EXDEV [OK]
48 lseek_m1 = -1 EBADF [OK]
49 lseek_0 = -1 ESPIPE [OK]
50 mkdir_root = -1 EEXIST [OK]
51 mmap_bad = <0xffffffff> EINVAL [OK]
52 munmap_bad = -1 EINVAL [OK]
53 mmap_munmap_good = 0 [OK]
54 open_tty = 3 [OK]
55 open_blah = -1 ENOENT [OK]
56 openat_dir = 0 [OK]
57 pipe = 0 [OK]
58 poll_null = 0 [OK]
59 poll_stdout = 1 [OK]
60 poll_fault = -1 EFAULT [OK]
61 prctl = -1 EFAULT [OK]
62 read_badf = -1 EBADF [OK]
63 rlimit = 0 [OK]
64 rmdir_blah = -1 ENOENT [OK]
65 sched_yield = 0 [OK]
66 select_null = 0 [OK]
67 select_stdout = 1 [OK]
68 select_fault = -1 EFAULT [OK]
69 stat_blah = -1 ENOENT [OK]
70 stat_fault = -1 EFAULT [OK]
71 stat_timestamps = 0 [OK]
72 symlink_root = -1 EEXIST [OK]
73 timer = 0 [OK]
74 timerfd = 0 [OK]
75 uname = 0 [OK]
76 uname_fault = -1 EFAULT [OK]
77 unlink_root = -1 EISDIR [OK]
78 unlink_blah = -1 ENOENT [OK]
79 wait_child = -1 ECHILD [OK]
80 waitpid_min = -1 ESRCH [OK]
81 waitpid_child = -1 ECHILD [OK]
82 write_badf = -1 EBADF [OK]
83 write_zero = 0 [OK]
84 syscall_noargs = 24641 [OK]
85 syscall_args = -1 EFAULT [OK]
86 namespace [SKIPPED]
Errors during this test: 0
Running test 'stdlib'
0 getenv_TERM = <screen.xterm-256color> [OK]
1 getenv_blah = <(null)> [OK]
2 setcmp_blah_blah = 0 [OK]
3 setcmp_blah_blah2 = -50 [OK]
4 setncmp_blah_blah = 0 [OK]
5 setncmp_blah_blah4 = 0 [OK]
6 setncmp_blah_blah5 = -53 [OK]
7 setncmp_blah_blah6 = -54 [OK]
8 strchr_foobar_o = <oobar> [OK]
9 strchr_foobar_z = <(null)> [OK]
10 strrchr_foobar_o = <obar> [OK]
11 strrchr_foobar_z = <(null)> [OK]
12 strlcat_0 = 3 <test> [OK]
13 strlcat_1 = 4 <test> [OK]
14 strlcat_5 = 7 <test> [OK]
15 strlcat_6 = 7 <testb> [OK]
16 strlcat_7 = 7 <testba> [OK]
17 strlcat_8 = 7 <testbar> [OK]
18 strlcpy_0 = 3 <test> [OK]
19 strlcpy_1 = 3 <> [OK]
20 strlcpy_2 = 3 <b> [OK]
21 strlcpy_3 = 3 <ba> [OK]
22 strlcpy_4 = 3 <bar> [OK]
23 strstr_foobar_foo = <foobar> [OK]
24 strstr_foobar_bar = <bar> [OK]
25 strstr_foobar_baz = <0x0> [OK]
26 memcmp_20_20 = 0 [OK]
27 memcmp_20_60 = -64 [OK]
28 memcmp_60_20 = 64 [OK]
29 memcmp_20_e0 = -192 [OK]
30 memcmp_e0_20 = 192 [OK]
31 memcmp_80_e0 = -96 [OK]
32 memcmp_e0_80 = 96 [OK]
33 limit_int8_max = 127 [OK]
34 limit_int8_min = -128 [OK]
35 limit_uint8_max = 255 [OK]
36 limit_int16_max = 32767 [OK]
37 limit_int16_min = -32768 [OK]
38 limit_uint16_max = 65535 [OK]
39 limit_int32_max = 2147483647 [OK]
40 limit_int32_min = -2147483648 [OK]
41 limit_uint32_max = 4294967295 [OK]
42 limit_int64_max = 9223372036854775807 [OK]
43 limit_int64_min = -9223372036854775808 [OK]
44 limit_uint64_max = -1 [OK]
45 limit_int_least8_max = 127 [OK]
46 limit_int_least8_min = -128 [OK]
47 limit_uint_least8_max = 255 [OK]
48 limit_int_least16_max = 32767 [OK]
49 limit_int_least16_min = -32768 [OK]
50 limit_uint_least16_max = 65535 [OK]
51 limit_int_least32_max = 2147483647 [OK]
52 limit_int_least32_min = -2147483648 [OK]
53 limit_uint_least32_max = 4294967295 [OK]
54 limit_int_least64_min = -9223372036854775808 [OK]
55 limit_int_least64_max = 9223372036854775807 [OK]
56 limit_uint_least64_max = -1 [OK]
57 limit_int_fast8_max = 127 [OK]
58 limit_int_fast8_min = -128 [OK]
59 limit_uint_fast8_max = 255 [OK]
60 limit_int_fast16_min = -2147483648 [OK]
61 limit_int_fast16_max = 2147483647 [OK]
62 limit_uint_fast16_max = 4294967295 [OK]
63 limit_int_fast32_min = -2147483648 [OK]
64 limit_int_fast32_max = 2147483647 [OK]
65 limit_uint_fast32_max = 4294967295 [OK]
66 limit_int_fast64_min = -9223372036854775808 [OK]
67 limit_int_fast64_max = 9223372036854775807 [OK]
68 limit_uint_fast64_max = -1 [OK]
69 sizeof_long_sane = 1 [OK]
70 limit_intptr_min = -2147483648 [OK]
71 limit_intptr_max = 2147483647 [OK]
72 limit_uintptr_max = 4294967295 [OK]
73 limit_ptrdiff_min = -2147483648 [OK]
74 limit_ptrdiff_max = 2147483647 [OK]
75 limit_size_max = 4294967295 [OK]
76 strtol_simple 35 = 35 [OK]
77 strtol_positive 35 = 35 [OK]
78 strtol_negative -35 = -35 [OK]
79 strtol_hex_auto 255 = 255 [OK]
80 strtol_base36 50507 = 50507 [OK]
81 strtol_cutoff 342391 = 342391 [OK]
82 strtol_octal_auto 9 = 9 [OK]
83 strtol_hex_00 0 = 0 [OK]
84 strtol_hex_FF 255 = 255 [OK]
85 strtol_hex_ff 255 = 255 [OK]
86 strtol_hex_prefix 255 = 255 [OK]
87 strtol_trailer 35 = 35 [OK]
88 strtol_overflow 2147483647 = 2147483647 [OK]
89 strtol_underflow -2147483648 = -2147483648 [OK]
90 strtoul_negative 4294967295 = 4294967295 [OK]
91 strtoul_overflow 4294967295 = 4294967295 [OK]
92 strerror_success = <errno=0> [OK]
93 strerror_EINVAL = <errno=22> [OK]
94 strerror_int_max = <errno=2147483647> [OK]
95 strerror_int_min = <errno=-2147483648> [OK]
96 tolower = 97 [OK]
97 tolower_noop = 97 [OK]
98 toupper = 65 [OK]
99 toupper_noop = 65 [OK]
100 abs = 10 [OK]
101 abs_noop = 10 [OK]
102 difftime = 0 [OK]
Errors during this test: 0
Running test 'printf'
0 empty "" = "" [OK]
1 simple "foo" = "foo" [OK]
2 string "foo" = "foo" [OK]
3 number "1234" = "1234" [OK]
4 negnumber "-1234" = "-1234" [OK]
5 unsigned "12345" = "12345" [OK]
6 char "c" = "c" [OK]
7 hex "f" = "f" [OK]
8 pointer "0x1" = "0x1" [OK]
9 uintmax_t "18446744073709551615" = "18446744073709551615" [OK]
10 intmax_t "-9223372036854775807" = "-9223372036854775807" [OK]
11 truncation "01234567890123456789" = "01234567890123456789" [OK]
12 string_width " 1" = " 1" [OK]
13 number_width " 1" = " 1" [OK]
14 width_trunc " " = " " [OK]
15 scanf = 0 [OK]
16 strerror = 0 [OK]
Errors during this test: 0
Running test 'protection'
0 -fstackprotector [OK]
Errors during this test: 0
Total number of errors: 0
Exiting with status 0
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-25 9:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 21:15 [PATCH v2 0/3] tools/nolibc: add support for SuperH Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 1/3] selftests/nolibc: fix EXTRACONFIG variables ordering Thomas Weißschuh
2025-06-23 21:15 ` [PATCH v2 2/3] selftests/nolibc: use file driver for QEMU serial Thomas Weißschuh
2025-06-24 8:56 ` Sergey Shtylyov
2025-06-23 21:15 ` [PATCH v2 3/3] tools/nolibc: add support for SuperH Thomas Weißschuh
2025-06-24 6:03 ` [PATCH v2 0/3] " John Paul Adrian Glaubitz
2025-06-24 6:07 ` Willy Tarreau
2025-06-25 9:47 ` John Paul Adrian Glaubitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).