mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-21 16:31:14 +02: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>
59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* vdso_test_gettimeofday.c: Sample code to test parse_vdso.c and
|
|
* vDSO gettimeofday()
|
|
* Copyright (c) 2014 Andy Lutomirski
|
|
*
|
|
* Compile with:
|
|
* gcc -std=gnu99 vdso_test_gettimeofday.c parse_vdso_gettimeofday.c
|
|
*
|
|
* Tested on x86, 32-bit and 64-bit. It may work on other architectures, too.
|
|
*/
|
|
|
|
#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"
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
const char *version = versions[VDSO_VERSION];
|
|
const char **name = (const char **)&names[VDSO_NAMES];
|
|
|
|
unsigned long 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));
|
|
|
|
/* Find gettimeofday. */
|
|
typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
|
|
gtod_t gtod = (gtod_t)vdso_sym(version, name[0]);
|
|
|
|
if (!gtod) {
|
|
printf("Could not find %s\n", name[0]);
|
|
return KSFT_SKIP;
|
|
}
|
|
|
|
struct timeval tv;
|
|
long ret = VDSO_CALL(gtod, 2, &tv, 0);
|
|
|
|
if (ret == 0) {
|
|
printf("The time is %lld.%06lld\n",
|
|
(long long)tv.tv_sec, (long long)tv.tv_usec);
|
|
} else {
|
|
printf("%s failed\n", name[0]);
|
|
return KSFT_FAIL;
|
|
}
|
|
|
|
return 0;
|
|
}
|