Commit 3b5992ea authored by Jason A. Donenfeld's avatar Jason A. Donenfeld Committed by Shuah Khan

selftests: vDSO: unconditionally build chacha test

Rather than using symlinks to find the vgetrandom-chacha.S file for each
arch, store this in a file that uses the compiler to determine
architecture, and then make use of weak symbols to skip the test on
architectures that don't provide the code.
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent c66be905
../../../arch/arm64/kernel/vdso
\ No newline at end of file
../../../arch/loongarch/vdso
\ No newline at end of file
../../../arch/powerpc/kernel/vdso
\ No newline at end of file
../../../arch/s390/kernel/vdso64
\ No newline at end of file
../../../arch/x86/entry/vdso/
\ No newline at end of file
...@@ -11,8 +11,8 @@ endif ...@@ -11,8 +11,8 @@ endif
TEST_GEN_PROGS += vdso_test_correctness TEST_GEN_PROGS += vdso_test_correctness
ifeq ($(ARCH)$(CONFIG_X86_32),$(filter $(ARCH)$(CONFIG_X86_32),x86 x86_64 loongarch arm64 powerpc s390)) ifeq ($(ARCH)$(CONFIG_X86_32),$(filter $(ARCH)$(CONFIG_X86_32),x86 x86_64 loongarch arm64 powerpc s390))
TEST_GEN_PROGS += vdso_test_getrandom TEST_GEN_PROGS += vdso_test_getrandom
TEST_GEN_PROGS += vdso_test_chacha
endif endif
TEST_GEN_PROGS += vdso_test_chacha
CFLAGS := -std=gnu99 -O2 CFLAGS := -std=gnu99 -O2
...@@ -37,9 +37,9 @@ $(OUTPUT)/vdso_test_getrandom: CFLAGS += -isystem $(top_srcdir)/tools/include \ ...@@ -37,9 +37,9 @@ $(OUTPUT)/vdso_test_getrandom: CFLAGS += -isystem $(top_srcdir)/tools/include \
$(KHDR_INCLUDES) \ $(KHDR_INCLUDES) \
-isystem $(top_srcdir)/include/uapi -isystem $(top_srcdir)/include/uapi
$(OUTPUT)/vdso_test_chacha: $(top_srcdir)/tools/arch/$(SRCARCH)/vdso/vgetrandom-chacha.S $(OUTPUT)/vdso_test_chacha: vgetrandom-chacha.S
$(OUTPUT)/vdso_test_chacha: CFLAGS += -idirafter $(top_srcdir)/tools/include \ $(OUTPUT)/vdso_test_chacha: CFLAGS += -idirafter $(top_srcdir)/tools/include \
-idirafter $(top_srcdir)/tools/include/generated \ -idirafter $(top_srcdir)/tools/include/generated \
-idirafter $(top_srcdir)/arch/$(SRCARCH)/include \ -idirafter $(top_srcdir)/arch/$(SRCARCH)/include \
-idirafter $(top_srcdir)/include \ -idirafter $(top_srcdir)/include \
-D__ASSEMBLY__ -Wa,--noexecstack -Wa,--noexecstack
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. * Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/ */
#include <linux/compiler.h>
#include <tools/le_byteshift.h> #include <tools/le_byteshift.h>
#include <sys/random.h> #include <sys/random.h>
#include <sys/auxv.h> #include <sys/auxv.h>
...@@ -73,10 +74,10 @@ static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, u ...@@ -73,10 +74,10 @@ static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, u
counter[1] = s[13]; counter[1] = s[13];
} }
typedef uint8_t u8; void __weak __arch_chacha20_blocks_nostack(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks)
typedef uint32_t u32; {
typedef uint64_t u64; ksft_exit_skip("Not implemented on architecture\n");
#include <vdso/getrandom.h> }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
......
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2024 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/
#define __ASSEMBLY__
#if defined(__aarch64__)
#include "../../../../arch/arm64/kernel/vdso/vgetrandom-chacha.S"
#elif defined(__loongarch__)
#include "../../../../arch/loongarch/vdso/vgetrandom-chacha.S"
#elif defined(__powerpc__) || defined(__powerpc64__)
#include "../../../../arch/powerpc/kernel/vdso/vgetrandom-chacha.S"
#elif defined(__s390x__)
#include "../../../../arch/s390/kernel/vdso64/vgetrandom-chacha.S"
#elif defined(__x86_64__)
#include "../../../../arch/x86/entry/vdso/vgetrandom-chacha.S"
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment