mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-04 20:39:08 -04:00
It could not find __vdso_getcpu and __vdso_gettimeofday when test getcpu
and gettimeofday on LoongArch.
# make headers && cd tools/testing/selftests/vDSO && make
# ./vdso_test_getcpu
Could not find __vdso_getcpu
# ./vdso_test_gettimeofday
Could not find __vdso_gettimeofday
One simple way is to add LoongArch case to define version and name, just
like commit d942f231af ("selftests/vDSO: Add riscv getcpu & gettimeofday
test"), but it is not the best way.
Since each architecture has already defined names and versions in
vdso_config.h, it is proper to include vdso_config.h to get version and
name for all archs.
Link: https://lkml.kernel.org/r/20240428030530.24399-3-yangtiezhu@loongson.cn
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Tested-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
55 lines
1.1 KiB
C
55 lines
1.1 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"
|
|
|
|
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 = get_cpu(&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;
|
|
}
|