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

selftests/nolibc: add x32 test configuration

Nolibc supports the x32 ABI on x86.
Add a testcase to make sure the support stays functional.

QEMU user does not have support for x32, so skip the test there.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250712-nolibc-x32-v1-2-6d81cb798710@weissschuh.net

+18 -1
+12
tools/testing/selftests/nolibc/Makefile.nolibc
··· 47 47 XARCH = $(or $(XARCH_$(ARCH)),$(ARCH)) 48 48 49 49 # map from user input variants to their kernel supported architectures 50 + ARCH_x32 = x86 50 51 ARCH_armthumb = arm 51 52 ARCH_ppc = powerpc 52 53 ARCH_ppc64 = powerpc ··· 69 68 # kernel image names by architecture 70 69 IMAGE_i386 = arch/x86/boot/bzImage 71 70 IMAGE_x86_64 = arch/x86/boot/bzImage 71 + IMAGE_x32 = arch/x86/boot/bzImage 72 72 IMAGE_x86 = arch/x86/boot/bzImage 73 73 IMAGE_arm64 = arch/arm64/boot/Image 74 74 IMAGE_arm = arch/arm/boot/zImage ··· 99 97 # default kernel configurations that appear to be usable 100 98 DEFCONFIG_i386 = defconfig 101 99 DEFCONFIG_x86_64 = defconfig 100 + DEFCONFIG_x32 = defconfig 102 101 DEFCONFIG_x86 = defconfig 103 102 DEFCONFIG_arm64 = defconfig 104 103 DEFCONFIG_arm = multi_v7_defconfig ··· 125 122 DEFCONFIG_sh4 = rts7751r2dplus_defconfig 126 123 DEFCONFIG = $(DEFCONFIG_$(XARCH)) 127 124 125 + EXTRACONFIG_x32 = -e CONFIG_X86_X32_ABI 128 126 EXTRACONFIG_arm = -e CONFIG_NAMESPACES 129 127 EXTRACONFIG_armthumb = -e CONFIG_NAMESPACES 130 128 EXTRACONFIG_m68k = -e CONFIG_BLK_DEV_INITRD ··· 138 134 # QEMU_ARCH: arch names used by qemu 139 135 QEMU_ARCH_i386 = i386 140 136 QEMU_ARCH_x86_64 = x86_64 137 + QEMU_ARCH_x32 = x86_64 141 138 QEMU_ARCH_x86 = x86_64 142 139 QEMU_ARCH_arm64 = aarch64 143 140 QEMU_ARCH_arm = arm ··· 179 174 # QEMU_ARGS : some arch-specific args to pass to qemu 180 175 QEMU_ARGS_i386 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" 181 176 QEMU_ARGS_x86_64 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" 177 + QEMU_ARGS_x32 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" 182 178 QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" 183 179 QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" 184 180 QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" ··· 216 210 endif 217 211 218 212 CFLAGS_i386 = $(call cc-option,-m32) 213 + CFLAGS_x32 = -mx32 219 214 CFLAGS_arm = -marm 220 215 CFLAGS_armthumb = -mthumb -march=armv6t2 221 216 CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) ··· 242 235 LDFLAGS := 243 236 244 237 LIBGCC := -lgcc 238 + 239 + ifeq ($(ARCH),x86) 240 + # Not needed on x86, probably not present for x32 241 + LIBGCC := 242 + endif 245 243 246 244 ifneq ($(LLVM),) 247 245 # Not needed for clang
+6 -1
tools/testing/selftests/nolibc/run-tests.sh
··· 18 18 werror=1 19 19 llvm= 20 20 all_archs=( 21 - i386 x86_64 21 + i386 x86_64 x32 22 22 arm64 arm armthumb 23 23 mips32le mips32be mipsn32le mipsn32be mips64le mips64be 24 24 ppc ppc64 ppc64le ··· 115 115 mips*) echo mips;; 116 116 s390*) echo s390;; 117 117 sparc*) echo sparc64;; 118 + x32*) echo x86_64;; 118 119 *) echo "$1";; 119 120 esac 120 121 } ··· 190 189 return 191 190 fi 192 191 if [ "$arch" = "m68k" -o "$arch" = "sh4" ] && [ "$llvm" = "1" ]; then 192 + echo "Unsupported configuration" 193 + return 194 + fi 195 + if [ "$arch" = "x32" ] && [ "$test_mode" = "user" ]; then 193 196 echo "Unsupported configuration" 194 197 return 195 198 fi