Commit a0482e34 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'timers-vdso-2025-07-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull VDSO selftest updates from Thomas Gleixner:

 - Skip the chacha test when the architecture does not provide the
   random infrastructure in the VDSO

 - Switch back to a symlink for vdso_standalone_test_x86 to avoid code
   duplication.

 - Improve code quality and TAP output compliance

* tag 'timers-vdso-2025-07-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  selftests: vDSO: vdso_standalone_test_x86: Replace source file with symlink
  selftests: vDSO: vdso_test_getrandom: Always print TAP header
  selftests: vDSO: vdso_test_correctness: Fix -Wstrict-prototypes
  selftests: vDSO: Enable -Wall
  selftests: vDSO: vdso_config: Avoid -Wunused-variables
  selftests: vDSO: vdso_test_getrandom: Avoid -Wunused
  selftests: vDSO: vdso_test_getrandom: Drop unused include of linux/compiler.h
  selftests: vDSO: clock_getres: Drop unused include of err.h
  selftests: vDSO: chacha: Correctly skip test if necessary
parents f38b1f24 43707960
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ TEST_GEN_PROGS += vdso_test_correctness
TEST_GEN_PROGS += vdso_test_getrandom
TEST_GEN_PROGS += vdso_test_chacha

CFLAGS := -std=gnu99 -O2
CFLAGS := -std=gnu99 -O2 -Wall -Wstrict-prototypes

ifeq ($(CONFIG_X86_32),y)
LDLIBS += -lgcc_s
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@
#define VDSO_NAMES		1
#endif

__attribute__((unused))
static const char *versions[7] = {
	"LINUX_2.6",
	"LINUX_2.6.15",
@@ -68,6 +69,7 @@ static const char *versions[7] = {
	"LINUX_5.10"
};

__attribute__((unused))
static const char *names[2][7] = {
	{
		"__kernel_gettimeofday",
+1 −58
Original line number Diff line number Diff line
// 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 <stdio.h>
#ifndef NOLIBC
#include <sys/auxv.h>
#include <sys/time.h>
#endif

#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;
}
+1 −58
Original line number Diff line number Diff line
vdso_test_gettimeofday.c
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, u

void __weak __arch_chacha20_blocks_nostack(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks)
{
	ksft_exit_skip("Not implemented on architecture\n");
	ksft_test_result_skip("Not implemented on architecture\n");
	ksft_finished();
}

int main(int argc, char *argv[])
Loading