Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/nolibc: add support for 32-bit s390

32-bit s390 is very close to the existing 64-bit implementation.

Some special handling is necessary as there is neither LLVM nor
QEMU support. Also the kernel itself can not build natively for 32-bit
s390, so instead the test program is executed with a 64-bit kernel.

Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250206-nolibc-s390-v2-2-991ad97e3d58@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

+16 -2
+5
tools/include/nolibc/arch-s390.h
··· 143 143 void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void) 144 144 { 145 145 __asm__ volatile ( 146 + #ifdef __s390x__ 146 147 "lgr %r2, %r15\n" /* save stack pointer to %r2, as arg1 of _start_c */ 147 148 "aghi %r15, -160\n" /* allocate new stackframe */ 149 + #else 150 + "lr %r2, %r15\n" 151 + "ahi %r15, -96\n" 152 + #endif 148 153 "xc 0(8,%r15), 0(%r15)\n" /* clear backchain */ 149 154 "brasl %r14, _start_c\n" /* transfer to c runtime */ 150 155 );
+1 -1
tools/include/nolibc/arch.h
··· 29 29 #include "arch-powerpc.h" 30 30 #elif defined(__riscv) 31 31 #include "arch-riscv.h" 32 - #elif defined(__s390x__) 32 + #elif defined(__s390x__) || defined(__s390__) 33 33 #include "arch-s390.h" 34 34 #elif defined(__loongarch__) 35 35 #include "arch-loongarch.h"
+5
tools/testing/selftests/nolibc/Makefile
··· 72 72 IMAGE_riscv32 = arch/riscv/boot/Image 73 73 IMAGE_riscv64 = arch/riscv/boot/Image 74 74 IMAGE_s390x = arch/s390/boot/bzImage 75 + IMAGE_s390 = arch/s390/boot/bzImage 75 76 IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi 76 77 IMAGE = $(objtree)/$(IMAGE_$(XARCH)) 77 78 IMAGE_NAME = $(notdir $(IMAGE)) ··· 92 91 DEFCONFIG_riscv32 = rv32_defconfig 93 92 DEFCONFIG_riscv64 = defconfig 94 93 DEFCONFIG_s390x = defconfig 94 + DEFCONFIG_s390 = defconfig compat.config 95 95 DEFCONFIG_loongarch = defconfig 96 96 DEFCONFIG = $(DEFCONFIG_$(XARCH)) 97 97 ··· 116 114 QEMU_ARCH_riscv32 = riscv32 117 115 QEMU_ARCH_riscv64 = riscv64 118 116 QEMU_ARCH_s390x = s390x 117 + QEMU_ARCH_s390 = s390x 119 118 QEMU_ARCH_loongarch = loongarch64 120 119 QEMU_ARCH = $(QEMU_ARCH_$(XARCH)) 121 120 ··· 145 142 QEMU_ARGS_riscv32 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 146 143 QEMU_ARGS_riscv64 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 147 144 QEMU_ARGS_s390x = -M s390-ccw-virtio -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 145 + QEMU_ARGS_s390 = -M s390-ccw-virtio -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 148 146 QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 149 147 QEMU_ARGS = -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA) 150 148 ··· 164 160 CFLAGS_ppc64 = -m64 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) 165 161 CFLAGS_ppc64le = -m64 -mlittle-endian -mno-vsx $(call cc-option,-mabi=elfv2) 166 162 CFLAGS_s390x = -m64 163 + CFLAGS_s390 = -m31 167 164 CFLAGS_mips32le = -EL -mabi=32 -fPIC 168 165 CFLAGS_mips32be = -EB -mabi=32 169 166 CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all))
+5 -1
tools/testing/selftests/nolibc/run-tests.sh
··· 23 23 mips32le mips32be 24 24 ppc ppc64 ppc64le 25 25 riscv32 riscv64 26 - s390x 26 + s390x s390 27 27 loongarch 28 28 ) 29 29 archs="${all_archs[@]}" ··· 179 179 exit 1 180 180 esac 181 181 printf '%-15s' "$arch:" 182 + if [ "$arch" = "s390" ] && ([ "$llvm" = "1" ] || [ "$test_mode" = "user" ]); then 183 + echo "Unsupported configuration" 184 + return 185 + fi 182 186 183 187 mkdir -p "$build_dir" 184 188 swallow_output "${MAKE[@]}" defconfig