Skip to content

Commit 67a121a

Browse files
committed
selftests: vDSO: fix cross build for getrandom and chacha tests
Unlike the check for the standalone x86 test, the check for building the vDSO getrandom and chacaha tests looks at the architecture for the host rather than the architecture for the target when deciding if they should be built. Since the chacha test includes some assembler code this means that cross building with x86 as either the target or host is broken. There's also some additional complications, where ARCH can legitimately be either x86_64 or x86, but the source code we need to compile lives in a directory path containing arch/x86. The standard SRCARCH variable handles that. And actually, all these variables and proper substitutions are already described in tools/scripts/Makefile.arch, so just include that to handle it. Similarly, ARCH=x86 can actually describe ARCH=x86_64, just with CONFIG_64BIT, so we can't rely on ARCH for selecting non-32-bit tests. For that, check against $(ARCH)$(CONFIG_X86_32). This won't help for people manually running this inside the vDSO selftest directory (which isn't really supported anyway and has problems on various archs), but it should work for builds of the kselftests, where the CONFIG_* variables are defined. On x86_64 machines, $(ARCH)$(CONFIG_X86_32) will evaluate to x86. On arm64 machines, it will evaluate to arm64. On 32-bit x86 machines, it will evaluate to x86y, which won't match the filter list. Reported-by: Mark Brown <[email protected]> Reported-by: Christophe Leroy <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 7f05381 commit 67a121a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/testing/selftests/vDSO/Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
uname_M := $(shell uname -m 2>/dev/null || echo not)
3-
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
2+
include ../../../scripts/Makefile.arch
43

54
TEST_GEN_PROGS := vdso_test_gettimeofday
65
TEST_GEN_PROGS += vdso_test_getcpu
@@ -10,7 +9,7 @@ ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64))
109
TEST_GEN_PROGS += vdso_standalone_test_x86
1110
endif
1211
TEST_GEN_PROGS += vdso_test_correctness
13-
ifeq ($(uname_M),x86_64)
12+
ifeq ($(ARCH)$(CONFIG_X86_32),$(filter $(ARCH)$(CONFIG_X86_32),x86 x86_64))
1413
TEST_GEN_PROGS += vdso_test_getrandom
1514
TEST_GEN_PROGS += vdso_test_chacha
1615
endif
@@ -38,8 +37,8 @@ $(OUTPUT)/vdso_test_getrandom: CFLAGS += -isystem $(top_srcdir)/tools/include \
3837
$(KHDR_INCLUDES) \
3938
-isystem $(top_srcdir)/include/uapi
4039

41-
$(OUTPUT)/vdso_test_chacha: $(top_srcdir)/tools/arch/$(ARCH)/vdso/vgetrandom-chacha.S
40+
$(OUTPUT)/vdso_test_chacha: $(top_srcdir)/tools/arch/$(SRCARCH)/vdso/vgetrandom-chacha.S
4241
$(OUTPUT)/vdso_test_chacha: CFLAGS += -idirafter $(top_srcdir)/tools/include \
43-
-idirafter $(top_srcdir)/arch/$(ARCH)/include \
42+
-idirafter $(top_srcdir)/arch/$(SRCARCH)/include \
4443
-idirafter $(top_srcdir)/include \
4544
-D__ASSEMBLY__ -Wa,--noexecstack

0 commit comments

Comments
 (0)