linux-stable/tools/testing/selftests/vDSO/vdso_config.h
Tobias Klauser f405ac83fa selftests/vDSO: fix ABI selftest on riscv
Only older versions of the RISC-V GCC toolchain define __riscv__. Check
for __riscv as well, which is used by newer GCC toolchains. Also set
VDSO_32BIT based on __riscv_xlen.

Before (on riscv64):

$ ./vdso_test_abi
[vDSO kselftest] VDSO_VERSION: LINUX_4
Could not find __vdso_gettimeofday
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_REALTIME [PASS]
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_BOOTTIME [PASS]
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_TAI [PASS]
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_REALTIME_COARSE [PASS]
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_MONOTONIC [PASS]
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_MONOTONIC_RAW [PASS]
Could not find __vdso_clock_gettime
Could not find __vdso_clock_getres
clock_id: CLOCK_MONOTONIC_COARSE [PASS]
Could not find __vdso_time

After (on riscv32):

$ ./vdso_test_abi
[vDSO kselftest] VDSO_VERSION: LINUX_4.15
The time is 1612449376.015086
The time is 1612449376.18340784
The resolution is 0 1
clock_id: CLOCK_REALTIME [PASS]
The time is 774.842586182
The resolution is 0 1
clock_id: CLOCK_BOOTTIME [PASS]
The time is 1612449376.22536565
The resolution is 0 1
clock_id: CLOCK_TAI [PASS]
The time is 1612449376.20885172
The resolution is 0 4000000
clock_id: CLOCK_REALTIME_COARSE [PASS]
The time is 774.845491269
The resolution is 0 1
clock_id: CLOCK_MONOTONIC [PASS]
The time is 774.849534200
The resolution is 0 1
clock_id: CLOCK_MONOTONIC_RAW [PASS]
The time is 774.842139684
The resolution is 0 4000000
clock_id: CLOCK_MONOTONIC_COARSE [PASS]
Could not find __vdso_time

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
Acked-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-02-08 16:38:34 -07:00

94 lines
2 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* vdso_config.h: Configuration options for vDSO tests.
* Copyright (c) 2019 Arm Ltd.
*/
#ifndef __VDSO_CONFIG_H__
#define __VDSO_CONFIG_H__
/*
* Each architecture exports its vDSO implementation with different names
* and a different version from the others, so we need to handle it as a
* special case.
*/
#if defined(__arm__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__aarch64__)
#define VDSO_VERSION 3
#define VDSO_NAMES 0
#elif defined(__powerpc__)
#define VDSO_VERSION 1
#define VDSO_NAMES 0
#define VDSO_32BIT 1
#elif defined(__powerpc64__)
#define VDSO_VERSION 1
#define VDSO_NAMES 0
#elif defined (__s390__)
#define VDSO_VERSION 2
#define VDSO_NAMES 0
#define VDSO_32BIT 1
#elif defined (__s390X__)
#define VDSO_VERSION 2
#define VDSO_NAMES 0
#elif defined(__mips__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__sparc__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__i386__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#elif defined(__x86_64__)
#define VDSO_VERSION 0
#define VDSO_NAMES 1
#elif defined(__riscv__) || defined(__riscv)
#define VDSO_VERSION 5
#define VDSO_NAMES 1
#if __riscv_xlen == 32
#define VDSO_32BIT 1
#endif
#else /* nds32 */
#define VDSO_VERSION 4
#define VDSO_NAMES 1
#define VDSO_32BIT 1
#endif
static const char *versions[6] = {
"LINUX_2.6",
"LINUX_2.6.15",
"LINUX_2.6.29",
"LINUX_2.6.39",
"LINUX_4",
"LINUX_4.15",
};
static const char *names[2][6] = {
{
"__kernel_gettimeofday",
"__kernel_clock_gettime",
"__kernel_time",
"__kernel_clock_getres",
"__kernel_getcpu",
#if defined(VDSO_32BIT)
"__kernel_clock_gettime64",
#endif
},
{
"__vdso_gettimeofday",
"__vdso_clock_gettime",
"__vdso_time",
"__vdso_clock_getres",
"__vdso_getcpu",
#if defined(VDSO_32BIT)
"__vdso_clock_gettime64",
#endif
},
};
#endif /* __VDSO_CONFIG_H__ */