mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 22:05:08 +00:00
selftests/vDSO: fix runtime errors on LoongArch
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 d942f231afc0 ("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>
This commit is contained in:
parent
dc8dc573aa
commit
48f044a784
@ -13,13 +13,7 @@
|
|||||||
|
|
||||||
#include "../kselftest.h"
|
#include "../kselftest.h"
|
||||||
#include "parse_vdso.h"
|
#include "parse_vdso.h"
|
||||||
|
#include "vdso_config.h"
|
||||||
#if defined(__riscv)
|
|
||||||
const char *version = "LINUX_4.15";
|
|
||||||
#else
|
|
||||||
const char *version = "LINUX_2.6";
|
|
||||||
#endif
|
|
||||||
const char *name = "__vdso_getcpu";
|
|
||||||
|
|
||||||
struct getcpu_cache;
|
struct getcpu_cache;
|
||||||
typedef long (*getcpu_t)(unsigned int *, unsigned int *,
|
typedef long (*getcpu_t)(unsigned int *, unsigned int *,
|
||||||
@ -27,6 +21,8 @@ typedef long (*getcpu_t)(unsigned int *, unsigned int *,
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
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 long sysinfo_ehdr;
|
||||||
unsigned int cpu, node;
|
unsigned int cpu, node;
|
||||||
getcpu_t get_cpu;
|
getcpu_t get_cpu;
|
||||||
@ -40,9 +36,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
|
vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
|
||||||
|
|
||||||
get_cpu = (getcpu_t)vdso_sym(version, name);
|
get_cpu = (getcpu_t)vdso_sym(version, name[4]);
|
||||||
if (!get_cpu) {
|
if (!get_cpu) {
|
||||||
printf("Could not find %s\n", name);
|
printf("Could not find %s\n", name[4]);
|
||||||
return KSFT_SKIP;
|
return KSFT_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +46,7 @@ int main(int argc, char **argv)
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
printf("Running on CPU %u node %u\n", cpu, node);
|
printf("Running on CPU %u node %u\n", cpu, node);
|
||||||
} else {
|
} else {
|
||||||
printf("%s failed\n", name);
|
printf("%s failed\n", name[4]);
|
||||||
return KSFT_FAIL;
|
return KSFT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,25 +18,13 @@
|
|||||||
|
|
||||||
#include "../kselftest.h"
|
#include "../kselftest.h"
|
||||||
#include "parse_vdso.h"
|
#include "parse_vdso.h"
|
||||||
|
#include "vdso_config.h"
|
||||||
/*
|
|
||||||
* ARM64's vDSO exports its gettimeofday() implementation with a different
|
|
||||||
* name and version from other architectures, so we need to handle it as
|
|
||||||
* a special case.
|
|
||||||
*/
|
|
||||||
#if defined(__aarch64__)
|
|
||||||
const char *version = "LINUX_2.6.39";
|
|
||||||
const char *name = "__kernel_gettimeofday";
|
|
||||||
#elif defined(__riscv)
|
|
||||||
const char *version = "LINUX_4.15";
|
|
||||||
const char *name = "__vdso_gettimeofday";
|
|
||||||
#else
|
|
||||||
const char *version = "LINUX_2.6";
|
|
||||||
const char *name = "__vdso_gettimeofday";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
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);
|
unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
|
||||||
if (!sysinfo_ehdr) {
|
if (!sysinfo_ehdr) {
|
||||||
printf("AT_SYSINFO_EHDR is not present!\n");
|
printf("AT_SYSINFO_EHDR is not present!\n");
|
||||||
@ -47,10 +35,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Find gettimeofday. */
|
/* Find gettimeofday. */
|
||||||
typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
|
typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
|
||||||
gtod_t gtod = (gtod_t)vdso_sym(version, name);
|
gtod_t gtod = (gtod_t)vdso_sym(version, name[0]);
|
||||||
|
|
||||||
if (!gtod) {
|
if (!gtod) {
|
||||||
printf("Could not find %s\n", name);
|
printf("Could not find %s\n", name[0]);
|
||||||
return KSFT_SKIP;
|
return KSFT_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +49,7 @@ int main(int argc, char **argv)
|
|||||||
printf("The time is %lld.%06lld\n",
|
printf("The time is %lld.%06lld\n",
|
||||||
(long long)tv.tv_sec, (long long)tv.tv_usec);
|
(long long)tv.tv_sec, (long long)tv.tv_usec);
|
||||||
} else {
|
} else {
|
||||||
printf("%s failed\n", name);
|
printf("%s failed\n", name[0]);
|
||||||
return KSFT_FAIL;
|
return KSFT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user