mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-17 03:15:21 +00:00

vdso_test_correctness test fails on powerpc: ~ # ./vdso_test_correctness ... [RUN] Testing clock_gettime for clock CLOCK_REALTIME_ALARM (8)... [FAIL] No such clock, but __vdso_clock_gettime returned 22 [RUN] Testing clock_gettime for clock CLOCK_BOOTTIME_ALARM (9)... [FAIL] No such clock, but __vdso_clock_gettime returned 22 [RUN] Testing clock_gettime for clock CLOCK_SGI_CYCLE (10)... [FAIL] No such clock, but __vdso_clock_gettime returned 22 ... [RUN] Testing clock_gettime for clock invalid (-1)... [FAIL] No such clock, but __vdso_clock_gettime returned 22 [RUN] Testing clock_gettime for clock invalid (-2147483648)... [FAIL] No such clock, but __vdso_clock_gettime returned 22 [RUN] Testing clock_gettime for clock invalid (2147483647)... [FAIL] No such clock, but __vdso_clock_gettime returned 22 On powerpc, a call to a VDSO function is not an ordinary C function call. Unlike several architectures which returns a negative error code in case of an error, powerpc sets CR[SO] and returns the error code as a positive value. Define and use a macro called VDSO_CALL() which takes a pointer to the function to call, the number of arguments and the arguments. Also update ABI vdso documentation to reflect this subtlety. Provide a specific version of VDSO_CALL() for powerpc that negates the error code on return when CR[SO] is set. Fixes:c7e5789b24
("kselftest: Move test_vdso to the vDSO test suite") Fixes:2e9a972566
("selftests: vdso: Add a selftest for vDSO getcpu()") Fixes:693f5ca08c
("kselftest: Extend vDSO selftest") Fixes:b2f1c3db28
("kselftest: Extend vdso correctness test to clock_gettime64") Fixes:4920a2590e
("selftests/vDSO: add tests for vgetrandom") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Acked-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* vdso_test_getcpu.c: Sample code to test parse_vdso.c and vDSO getcpu()
|
|
*
|
|
* Copyright (c) 2020 Arm Ltd
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <elf.h>
|
|
#include <stdio.h>
|
|
#include <sys/auxv.h>
|
|
#include <sys/time.h>
|
|
|
|
#include "../kselftest.h"
|
|
#include "parse_vdso.h"
|
|
#include "vdso_config.h"
|
|
#include "vdso_call.h"
|
|
|
|
struct getcpu_cache;
|
|
typedef long (*getcpu_t)(unsigned int *, unsigned int *,
|
|
struct getcpu_cache *);
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
const char *version = versions[VDSO_VERSION];
|
|
const char **name = (const char **)&names[VDSO_NAMES];
|
|
unsigned long sysinfo_ehdr;
|
|
unsigned int cpu, node;
|
|
getcpu_t get_cpu;
|
|
long ret;
|
|
|
|
sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
|
|
if (!sysinfo_ehdr) {
|
|
printf("AT_SYSINFO_EHDR is not present!\n");
|
|
return KSFT_SKIP;
|
|
}
|
|
|
|
vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
|
|
|
|
get_cpu = (getcpu_t)vdso_sym(version, name[4]);
|
|
if (!get_cpu) {
|
|
printf("Could not find %s\n", name[4]);
|
|
return KSFT_SKIP;
|
|
}
|
|
|
|
ret = VDSO_CALL(get_cpu, 3, &cpu, &node, 0);
|
|
if (ret == 0) {
|
|
printf("Running on CPU %u node %u\n", cpu, node);
|
|
} else {
|
|
printf("%s failed\n", name[4]);
|
|
return KSFT_FAIL;
|
|
}
|
|
|
|
return 0;
|
|
}
|