| 1 | :100644 100644 12a0614b9fd4983deffe5d6a7cfa06ba8d92a516 918a2caa070ebc681a9525f0518afffcf10f5ae3 M	tools/testing/selftests/vDSO/Makefile |
| 2 | :100644 100644 722260f9756198956f0dfccced907284b6851e76 5fdd0f36233742bc47ae79f23d2cfae5a0f56dee M	tools/testing/selftests/vDSO/vdso_config.h |
| 3 | :100644 120000 9ce795b806f0992b83cef78c7e16fac0e54750da 4d3d96f1e440c965474681a6f35375a60b3921be T	tools/testing/selftests/vDSO/vdso_standalone_test_x86.c |
| 4 | :100644 100644 8757f738b0b1a76a48c83c5e5df79925a30c1bc7 0aad682b12c8836efabb49a65a47cf87466891a3 M	tools/testing/selftests/vDSO/vdso_test_chacha.c |
| 5 | :100644 100644 38d46a8bf7cba7a9b4a9b13b5eb17aa207972bd0 b5d5f59f725a703c357dfca91bfe170aaaeb42fa M	tools/testing/selftests/vDSO/vdso_test_clock_getres.c |
| 6 | :100644 100644 5fb97ad67eeaf17b6cfa4f82783c57894f03e5c5 da651cf53c6ca4242085de109c7fc57bd807297c M	tools/testing/selftests/vDSO/vdso_test_correctness.c |
| 7 | :100644 100644 95057f7567db22226d9cb09a667a56e387a33a46 dd1132508a0db29a32ec977b30f64b20aa43e03d M	tools/testing/selftests/vDSO/vdso_test_getrandom.c |
| 8 | |
| 9 | diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile |
| 10 | index 12a0614b9fd4983deffe5d6a7cfa06ba8d92a516..918a2caa070ebc681a9525f0518afffcf10f5ae3 100644 |
| 11 | --- a/tools/testing/selftests/vDSO/Makefile |
| 12 | +++ b/tools/testing/selftests/vDSO/Makefile |
| 13 | @@ -12,7 +12,7 @@ TEST_GEN_PROGS += vdso_test_correctness |
| 14 | TEST_GEN_PROGS += vdso_test_getrandom |
| 15 | TEST_GEN_PROGS += vdso_test_chacha |
| 16 | |
| 17 | -CFLAGS := -std=gnu99 -O2 |
| 18 | +CFLAGS := -std=gnu99 -O2 -Wall -Wstrict-prototypes |
| 19 | |
| 20 | ifeq ($(CONFIG_X86_32),y) |
| 21 | LDLIBS += -lgcc_s |
| 22 | diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h |
| 23 | index 722260f9756198956f0dfccced907284b6851e76..5fdd0f36233742bc47ae79f23d2cfae5a0f56dee 100644 |
| 24 | --- a/tools/testing/selftests/vDSO/vdso_config.h |
| 25 | +++ b/tools/testing/selftests/vDSO/vdso_config.h |
| 26 | @@ -58,6 +58,7 @@ |
| 27 | #define VDSO_NAMES		1 |
| 28 | #endif |
| 29 | |
| 30 | +__attribute__((unused)) |
| 31 | static const char *versions[7] = { |
| 32 | 	"LINUX_2.6", |
| 33 | 	"LINUX_2.6.15", |
| 34 | @@ -68,6 +69,7 @@ static const char *versions[7] = { |
| 35 | 	"LINUX_5.10" |
| 36 | }; |
| 37 | |
| 38 | +__attribute__((unused)) |
| 39 | static const char *names[2][7] = { |
| 40 | 	{ |
| 41 | 		"__kernel_gettimeofday", |
| 42 | diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c |
| 43 | deleted file mode 100644 |
| 44 | index 9ce795b806f0992b83cef78c7e16fac0e54750da..0000000000000000000000000000000000000000 |
| 45 | --- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c |
| 46 | +++ /dev/null |
| 47 | @@ -1,58 +0,0 @@ |
| 48 | -// SPDX-License-Identifier: GPL-2.0-only |
| 49 | -/* |
| 50 | - * vdso_test_gettimeofday.c: Sample code to test parse_vdso.c and |
| 51 | - * vDSO gettimeofday() |
| 52 | - * Copyright (c) 2014 Andy Lutomirski |
| 53 | - * |
| 54 | - * Compile with: |
| 55 | - * gcc -std=gnu99 vdso_test_gettimeofday.c parse_vdso_gettimeofday.c |
| 56 | - * |
| 57 | - * Tested on x86, 32-bit and 64-bit. It may work on other architectures, too. |
| 58 | - */ |
| 59 | - |
| 60 | -#include <stdio.h> |
| 61 | -#ifndef NOLIBC |
| 62 | -#include <sys/auxv.h> |
| 63 | -#include <sys/time.h> |
| 64 | -#endif |
| 65 | - |
| 66 | -#include "../kselftest.h" |
| 67 | -#include "parse_vdso.h" |
| 68 | -#include "vdso_config.h" |
| 69 | -#include "vdso_call.h" |
| 70 | - |
| 71 | -int main(int argc, char **argv) |
| 72 | -{ |
| 73 | -	const char *version = versions[VDSO_VERSION]; |
| 74 | -	const char **name = (const char **)&names[VDSO_NAMES]; |
| 75 | - |
| 76 | -	unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); |
| 77 | -	if (!sysinfo_ehdr) { |
| 78 | -		printf("AT_SYSINFO_EHDR is not present!\n"); |
| 79 | -		return KSFT_SKIP; |
| 80 | -	} |
| 81 | - |
| 82 | -	vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); |
| 83 | - |
| 84 | -	/* Find gettimeofday. */ |
| 85 | -	typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); |
| 86 | -	gtod_t gtod = (gtod_t)vdso_sym(version, name[0]); |
| 87 | - |
| 88 | -	if (!gtod) { |
| 89 | -		printf("Could not find %s\n", name[0]); |
| 90 | -		return KSFT_SKIP; |
| 91 | -	} |
| 92 | - |
| 93 | -	struct timeval tv; |
| 94 | -	long ret = VDSO_CALL(gtod, 2, &tv, 0); |
| 95 | - |
| 96 | -	if (ret == 0) { |
| 97 | -		printf("The time is %lld.%06lld\n", |
| 98 | -		 (long long)tv.tv_sec, (long long)tv.tv_usec); |
| 99 | -	} else { |
| 100 | -		printf("%s failed\n", name[0]); |
| 101 | -		return KSFT_FAIL; |
| 102 | -	} |
| 103 | - |
| 104 | -	return 0; |
| 105 | -} |
| 106 | diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c |
| 107 | new file mode 120000 |
| 108 | index 0000000000000000000000000000000000000000..4d3d96f1e440c965474681a6f35375a60b3921be |
| 109 | --- /dev/null |
| 110 | +++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c |
| 111 | @@ -0,0 +1 @@ |
| 112 | +vdso_test_gettimeofday.c |
| 113 | \ No newline at end of file |
| 114 | diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c |
| 115 | index 8757f738b0b1a76a48c83c5e5df79925a30c1bc7..0aad682b12c8836efabb49a65a47cf87466891a3 100644 |
| 116 | --- a/tools/testing/selftests/vDSO/vdso_test_chacha.c |
| 117 | +++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c |
| 118 | @@ -76,7 +76,8 @@ static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, u |
| 119 | |
| 120 | void __weak __arch_chacha20_blocks_nostack(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks) |
| 121 | { |
| 122 | -	ksft_exit_skip("Not implemented on architecture\n"); |
| 123 | +	ksft_test_result_skip("Not implemented on architecture\n"); |
| 124 | +	ksft_finished(); |
| 125 | } |
| 126 | |
| 127 | int main(int argc, char *argv[]) |
| 128 | diff --git a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c |
| 129 | index 38d46a8bf7cba7a9b4a9b13b5eb17aa207972bd0..b5d5f59f725a703c357dfca91bfe170aaaeb42fa 100644 |
| 130 | --- a/tools/testing/selftests/vDSO/vdso_test_clock_getres.c |
| 131 | +++ b/tools/testing/selftests/vDSO/vdso_test_clock_getres.c |
| 132 | @@ -13,7 +13,6 @@ |
| 133 | |
| 134 | #define _GNU_SOURCE |
| 135 | #include <elf.h> |
| 136 | -#include <err.h> |
| 137 | #include <fcntl.h> |
| 138 | #include <stdint.h> |
| 139 | #include <stdio.h> |
| 140 | diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/testing/selftests/vDSO/vdso_test_correctness.c |
| 141 | index 5fb97ad67eeaf17b6cfa4f82783c57894f03e5c5..da651cf53c6ca4242085de109c7fc57bd807297c 100644 |
| 142 | --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c |
| 143 | +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c |
| 144 | @@ -108,7 +108,7 @@ static void *vsyscall_getcpu(void) |
| 145 | } |
| 146 | |
| 147 | |
| 148 | -static void fill_function_pointers() |
| 149 | +static void fill_function_pointers(void) |
| 150 | { |
| 151 | 	void *vdso = dlopen("linux-vdso.so.1", |
| 152 | 			 RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); |
| 153 | diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c |
| 154 | index 95057f7567db22226d9cb09a667a56e387a33a46..dd1132508a0db29a32ec977b30f64b20aa43e03d 100644 |
| 155 | --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c |
| 156 | +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c |
| 157 | @@ -21,7 +21,6 @@ |
| 158 | #include <sys/wait.h> |
| 159 | #include <sys/types.h> |
| 160 | #include <linux/random.h> |
| 161 | -#include <linux/compiler.h> |
| 162 | #include <linux/ptrace.h> |
| 163 | |
| 164 | #include "../kselftest.h" |
| 165 | @@ -101,6 +100,7 @@ static void *vgetrandom_get_state(void) |
| 166 | 	return state; |
| 167 | } |
| 168 | |
| 169 | +__attribute__((unused)) /* Example for libc implementors */ |
| 170 | static void vgetrandom_put_state(void *state) |
| 171 | { |
| 172 | 	if (!state) |
| 173 | @@ -242,6 +242,7 @@ static void kselftest(void) |
| 174 | 	pid_t child; |
| 175 | |
| 176 | 	ksft_print_header(); |
| 177 | +	vgetrandom_init(); |
| 178 | 	ksft_set_plan(2); |
| 179 | |
| 180 | 	for (size_t i = 0; i < 1000; ++i) { |
| 181 | @@ -265,7 +266,7 @@ static void kselftest(void) |
| 182 | 	} |
| 183 | 	for (;;) { |
| 184 | 		struct ptrace_syscall_info info = { 0 }; |
| 185 | -		int status, ret; |
| 186 | +		int status; |
| 187 | 		ksft_assert(waitpid(child, &status, 0) >= 0); |
| 188 | 		if (WIFEXITED(status)) { |
| 189 | 			ksft_assert(WEXITSTATUS(status) == 0); |
| 190 | @@ -295,8 +296,6 @@ static void usage(const char *argv0) |
| 191 | |
| 192 | int main(int argc, char *argv[]) |
| 193 | { |
| 194 | -	vgetrandom_init(); |
| 195 | - |
| 196 | 	if (argc == 1) { |
| 197 | 		kselftest(); |
| 198 | 		return 0; |
| 199 | @@ -306,6 +305,9 @@ int main(int argc, char *argv[]) |
| 200 | 		usage(argv[0]); |
| 201 | 		return 1; |
| 202 | 	} |
| 203 | + |
| 204 | +	vgetrandom_init(); |
| 205 | + |
| 206 | 	if (!strcmp(argv[1], "bench-single")) |
| 207 | 		bench_single(); |
| 208 | 	else if (!strcmp(argv[1], "bench-multi")) |