Skip to content

Commit b9e5036

Browse files
committed
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 <[email protected]> Acked-by: Willy Tarreau <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d5094bc commit b9e5036

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tools/testing/selftests/nolibc/Makefile.nolibc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ XARCH_riscv = riscv64
4747
XARCH = $(or $(XARCH_$(ARCH)),$(ARCH))
4848

4949
# map from user input variants to their kernel supported architectures
50+
ARCH_x32 = x86
5051
ARCH_armthumb = arm
5152
ARCH_ppc = powerpc
5253
ARCH_ppc64 = powerpc
@@ -68,6 +69,7 @@ ARCH := $(or $(ARCH_$(XARCH)),$(XARCH))
6869
# kernel image names by architecture
6970
IMAGE_i386 = arch/x86/boot/bzImage
7071
IMAGE_x86_64 = arch/x86/boot/bzImage
72+
IMAGE_x32 = arch/x86/boot/bzImage
7173
IMAGE_x86 = arch/x86/boot/bzImage
7274
IMAGE_arm64 = arch/arm64/boot/Image
7375
IMAGE_arm = arch/arm/boot/zImage
@@ -97,6 +99,7 @@ IMAGE_NAME = $(notdir $(IMAGE))
9799
# default kernel configurations that appear to be usable
98100
DEFCONFIG_i386 = defconfig
99101
DEFCONFIG_x86_64 = defconfig
102+
DEFCONFIG_x32 = defconfig
100103
DEFCONFIG_x86 = defconfig
101104
DEFCONFIG_arm64 = defconfig
102105
DEFCONFIG_arm = multi_v7_defconfig
@@ -122,6 +125,7 @@ DEFCONFIG_m68k = virt_defconfig
122125
DEFCONFIG_sh4 = rts7751r2dplus_defconfig
123126
DEFCONFIG = $(DEFCONFIG_$(XARCH))
124127

128+
EXTRACONFIG_x32 = -e CONFIG_X86_X32_ABI
125129
EXTRACONFIG_arm = -e CONFIG_NAMESPACES
126130
EXTRACONFIG_armthumb = -e CONFIG_NAMESPACES
127131
EXTRACONFIG_m68k = -e CONFIG_BLK_DEV_INITRD
@@ -134,6 +138,7 @@ TEST =
134138
# QEMU_ARCH: arch names used by qemu
135139
QEMU_ARCH_i386 = i386
136140
QEMU_ARCH_x86_64 = x86_64
141+
QEMU_ARCH_x32 = x86_64
137142
QEMU_ARCH_x86 = x86_64
138143
QEMU_ARCH_arm64 = aarch64
139144
QEMU_ARCH_arm = arm
@@ -174,6 +179,7 @@ endif
174179
# QEMU_ARGS : some arch-specific args to pass to qemu
175180
QEMU_ARGS_i386 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
176181
QEMU_ARGS_x86_64 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
182+
QEMU_ARGS_x32 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
177183
QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
178184
QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)"
179185
QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)"
@@ -210,6 +216,7 @@ Q=@
210216
endif
211217

212218
CFLAGS_i386 = $(call cc-option,-m32)
219+
CFLAGS_x32 = -mx32
213220
CFLAGS_arm = -marm
214221
CFLAGS_armthumb = -mthumb -march=armv6t2
215222
CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple)
@@ -236,6 +243,11 @@ LDFLAGS :=
236243

237244
LIBGCC := -lgcc
238245

246+
ifeq ($(ARCH),x86)
247+
# Not needed on x86, probably not present for x32
248+
LIBGCC :=
249+
endif
250+
239251
ifneq ($(LLVM),)
240252
# Not needed for clang
241253
LIBGCC :=

tools/testing/selftests/nolibc/run-tests.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test_mode=system
1818
werror=1
1919
llvm=
2020
all_archs=(
21-
i386 x86_64
21+
i386 x86_64 x32
2222
arm64 arm armthumb
2323
mips32le mips32be mipsn32le mipsn32be mips64le mips64be
2424
ppc ppc64 ppc64le
@@ -115,6 +115,7 @@ crosstool_arch() {
115115
mips*) echo mips;;
116116
s390*) echo s390;;
117117
sparc*) echo sparc64;;
118+
x32*) echo x86_64;;
118119
*) echo "$1";;
119120
esac
120121
}
@@ -192,6 +193,10 @@ test_arch() {
192193
echo "Unsupported configuration"
193194
return
194195
fi
196+
if [ "$arch" = "x32" ] && [ "$test_mode" = "user" ]; then
197+
echo "Unsupported configuration"
198+
return
199+
fi
195200

196201
mkdir -p "$build_dir"
197202
swallow_output "${MAKE[@]}" defconfig

0 commit comments

Comments
 (0)