From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B98C0372ECF; Thu, 3 Sep 2026 07:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421108; cv=none; b=DltYUBk75HB86gThLWdC2JWRuaHDZkMc4HEVEpqmDUEDaEGpdCjjoyS0/CAZlbEpup+xeBq8/PeyUMuuxostIHwzkXVxbKOTByORO700PhZRwYNQH6LTWRXCllq1HKlZ/abRPpRhj9OiaotmFAgx7otOlcyJqwcnSbMS9y7XzUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421108; c=relaxed/simple; bh=jSbsNrDsNF8eG8WyWSi9/+LYAGR9JEBbXV6OZR1wqHI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W0sfGfKIFsLPLPD36Fm78C0pTOi7EQajH8oYqV4O+Xd3ZRUiTDDL4f12m5J62aet5PNKePPEdyB+RZoNKFFph6xV9x7OiudlI3KQ4BNq4ryc/zBPFsd6MjqImXs5iLv78U8HdTbm5mfSKf9SLtg3CPO5t3UXgCBZ3QeI9pq2Xfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lzw22daR; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Oef0lU1o; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lzw22daR"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Oef0lU1o" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g5r3iNEl0MalsavYoO99hlFyAi3SsE7pkO3K5bXIIbE=; b=lzw22daRC2ySfyh8dqSkxmmCPxL2OM7C7JOBcnhlhUb+FCAM63ZV1r0z7qHOVqclakW66u hUZaP2A57HdD+RRQ3rw+3OQ1pO4fKi/uMZh9Y8Tk7rhBYNebadQF+r0q110O0OJgfcR8UB pYMKv+Y+Si45VOZy/4wcCCDK/vsrbksw5DNAigqkRxdwKYiXL1Ih0qvlM1TcgyPsd7mDd9 rrxlxhIknib+QTGTS3bBd50iJYYh0iknd5VWXySOSjHp0/iFIgOs9ux3zsK2wtHZ/ptIT1 dSrlGXGUTNfWpUvKSRzoFnbrpmIIA7NvfFHNHIJ/b0JVZE3kKB2kxzs4tNoGxA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g5r3iNEl0MalsavYoO99hlFyAi3SsE7pkO3K5bXIIbE=; b=Oef0lU1oT6UFQqjltZXUrfDagCN6KRFIiwtWUa+eNjLKjsBWC594M3mLVwm/hZK0ZnNvYk dVHneD17Qjy92FCg== Date: Thu, 03 Sep 2026 09:38:13 +0200 Subject: [PATCH v2 1/8] selftests: vDSO: Introduce vdso_types.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-1-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=3314; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=jSbsNrDsNF8eG8WyWSi9/+LYAGR9JEBbXV6OZR1wqHI=; b=FrJaC/zqqg5H6TTP0Fm9WJ+J/SLQeJtOKap/9ewVbCLtLqP0UUoIxDYwGG2QOWPFXpTVxpR32 nWCko3CWk1MB+uDkwW4wMv7ncsbkumX46Y9Q//q61MEO9Uu+ILdVrGC X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Currently the vDSO selftests use the time-related types from libc. This works on glibc by chance today but will break with other libc implementations or on distributions which switch to 64-bit times everywhere. The kernel's UAPI headers provide the proper types to use with the vDSO (and raw syscalls) but are not necessarily compatible with libc types. Introduce a new header which makes the UAPI headers compatible with the libc. Tested with glibc, musl and nolibc. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/vDSO/vdso_types.h | 75 +++++++++++++++++++++++++++= ++++ 1 file changed, 75 insertions(+) diff --git a/tools/testing/selftests/vDSO/vdso_types.h b/tools/testing/self= tests/vDSO/vdso_types.h new file mode 100644 index 000000000000..4cb564f3fa94 --- /dev/null +++ b/tools/testing/selftests/vDSO/vdso_types.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2025 Thomas Wei=C3=9Fschuh , Linutronix GmbH + * + * Types to use with vDSO functions. + * + * The types used by the vDSO functions do not necessarily match the ones = used + * by libc. The kernel's UAPI headers do provide definitions for those typ= es + * but are often not compatible with libc which applications need to use. + * As the types differ between platforms listing them manually is a lot of= work + * and error prone. Instead hack around the incompatibilities of the libc = and + * UAPI headers and use the UAPI types. + */ +#ifndef __VDSO_TYPES_H__ +#define __VDSO_TYPES_H__ + +/* + * Include the headers from libc first to not override any of its types la= ter. + */ +#include +#include + +/* + * Avoid collisions. + */ +#define timeval kernel_timeval_moved +#define itimerspec kernel_itimerspec_moved +#define itimerval kernel_itimerval_moved +#define timezone kernel_timezone_moved + +#ifndef _STRUCT_TIMESPEC +#define _STRUCT_TIMESPEC +#endif + +/* + * Get the UAPI types. + */ +#include + +#undef timeval +#undef itimerspec +#undef itimerval +#undef timezone + +/* + * The UAPI headers do not provide their own 'struct __kernel_timezone'. + * 'struct timezone' is the one from libc. + */ +struct kernel_timezone { + int tz_minuteswest; + int tz_dsttime; +}; + +#include + +/* + * UAPI headers from the libc may be older and not provide these. + */ +#if KERNEL_VERSION(5, 5, 0) > LINUX_VERSION_CODE +typedef __kernel_long_t __kernel_old_time_t; + +struct __kernel_old_timespec { + __kernel_old_time_t tv_sec; + __kernel_long_t tv_nsec; +}; +#endif + +typedef long (*vdso_gettimeofday_t)(struct __kernel_old_timeval *tv, struc= t kernel_timezone *tz); +typedef long (*vdso_clock_gettime_t)(__kernel_clockid_t clk_id, struct __k= ernel_old_timespec *ts); +typedef long (*vdso_clock_gettime64_t)(__kernel_clockid_t clk_id, struct _= _kernel_timespec *ts); +typedef long (*vdso_clock_getres_t)(__kernel_clockid_t clk_id, struct __ke= rnel_old_timespec *ts); +typedef long (*vdso_clock_getres_time64_t)(__kernel_clockid_t clk_id, stru= ct __kernel_timespec *ts); +typedef __kernel_old_time_t (*vdso_time_t)(__kernel_old_time_t *t); + +#endif /* __VDSO_TYPES_H__ */ --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9838368941; Thu, 3 Sep 2026 07:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421109; cv=none; b=A4PTSxCcpvze6znrLmxbdUFbkJ1d6kBtt8E0wh9fKeYbB2lQsw+HZ1rWX0QpTsKR46M++9DMebCof3UebulXHCVgpv347coSF5dqe0nc8TZajjhxraejNTvg9qvZebEqbKpA5vRTg8Koq2Cqz+4MCOjW4B+uyatEa7WP71KtiJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421109; c=relaxed/simple; bh=am8ORWYYrdZY9YvmvzxzTF8duuviOrKYIO8My2YnSEE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hsDEZCtw/Qqxla93YTvJMdR41Qb1JgDLq45fYP9sl5nHLr+bm0FAiywxy+1nfk99te+bGGKUU2A/n5z2HZUDqIidOdBM2DejjNPRXDlsF0KIDFOuX8F98Nt4Zi4fE8Gbt3i9fksg9wZ7ja/YwxbXYF3CHxuG0o8pHxR2i5wGa+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=y3M6duGN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6Ng6v4Qd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="y3M6duGN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6Ng6v4Qd" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0HxrzKPhU3lF9wxgKboXGl5FTfDIVJGsi91Sr5qIi4=; b=y3M6duGNyR41zHesueauFEZ52foIVB/PKx2mWRnWlth5F21qvxESkB8badJn3hL0QxhL/+ 88Cvxl0NoVaWERl5iJdDCWr8vd49CRbFaDTVMl7KuhubWm761RzmQrhtsQ25l5IjEeIU30 3ZNT5N3xOHG0qar52gjXG0hmoq7ifxVzvAU0Tn5iPcr6xtuWjl0PBg1NOZCSx8p6FPAG0S 9urR/t5k1PBFsFIr7a2OS+jtz8oDFznd8FQfeFlzDyUQ+G2QZ6BGm2LIkKQtweg4TxQIYQ pnMLsVvQiPKRDlqqd/vYYYhjXBUAxs/RZjK5Fzn6VRCCz2PQpr6N3gNztjq83g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0HxrzKPhU3lF9wxgKboXGl5FTfDIVJGsi91Sr5qIi4=; b=6Ng6v4QddXG74MOLNC1/liwERIv4PrUjmb61k6rXwLq6sm5hiSp6lfBLjz04gKEuuG/oOK LPv+7d1l9x94BZBw== Date: Thu, 03 Sep 2026 09:38:14 +0200 Subject: [PATCH v2 2/8] selftests: vDSO: Introduce vdso_syscalls.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-2-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=3955; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=am8ORWYYrdZY9YvmvzxzTF8duuviOrKYIO8My2YnSEE=; b=ECBxjtst6Dc2uC+JXKCAKcbHfEeRFKq4G1vGNkwTPdlKhcjkMh94tAvCmmC61V2MF1f9++a2M eXchBH+MLN9Bjabv+HXIT2PPyGkzeiMxt2m4TNXajwQj9AcBmG/U4rc X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The vDSO selftests use raw system call wrapper to validate the correctness of the vDSO implementation. The exactly available system calls differ between architectures and kernel configurations. Raw system calls should not use libc types as these are not necessarily compatible. Introduce a helper header which uses the correct types and fallbacks. Link: https://lore.kernel.org/lkml/29dd9e11-9ae8-415a-acb3-b96af56550b0@app= .fastmail.com/ Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/vDSO/vdso_syscalls.h | 92 ++++++++++++++++++++++++= ++++ 1 file changed, 92 insertions(+) diff --git a/tools/testing/selftests/vDSO/vdso_syscalls.h b/tools/testing/s= elftests/vDSO/vdso_syscalls.h new file mode 100644 index 000000000000..d4ed95b50eb5 --- /dev/null +++ b/tools/testing/selftests/vDSO/vdso_syscalls.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2025 Thomas Wei=C3=9Fschuh , Linutronix GmbH + * + * System call wrappers to use for vDSO testing. + * + * vDSO calls are expected to return the same data as the equivalent syste= m call. + * To ensure this the tests need to trigger system calls. Calling into lib= c may + * silently use the vDSO, so explicit system calls are necessary. + * Not all system calls are available on all platforms, so some fallback l= ogic + * is needed. Use __NR_ constants from the kernel's UAPI headers over SYS_= from + * ones from libc to avoid any potential interference from libc. + * Always prefer the 64-bit time variants of the system calls as 32-bit on= es + * may not be present on the platform or disabled in the kernel configurat= ion. + * No fallback to the 32-bit ones is necessary, as the vDSO function + * availability always mirrors the system call one. + */ +#ifndef __VDSO_SYSCALLS_H__ +#define __VDSO_SYSCALLS_H__ + +#include "vdso_types.h" + +#include +#include +#include + +#define typeof_member(T, m) typeof(((T *)0)->m) +#define sizeof_member(T, m) sizeof(typeof_member(T, m)) + +/* + * To keep the fallback logic simple we assume that, although the types be= tween + * the wrapper and the system call are different, they are compatible. + * Validate that assumption. + */ +#define ASSERT_MEMBER_COMPATIBLE(T1, T2, m) \ + do { \ + _Static_assert(sizeof_member(T1, m) =3D=3D sizeof_member(T2, m), ""); \ + _Static_assert(offsetof(T1, m) =3D=3D offsetof(T2, m), ""); \ + } while (0) + +#define ASSERT_TIMESPEC_COMPATIBLE(ts1, ts2) \ + do { \ + _Static_assert(sizeof(ts1) =3D=3D sizeof(ts2), ""); \ + ASSERT_MEMBER_COMPATIBLE(typeof(ts1), typeof(ts2), tv_sec); \ + ASSERT_MEMBER_COMPATIBLE(typeof(ts1), typeof(ts2), tv_nsec); \ + } while (0) + +static inline +int sys_clock_getres(__kernel_clockid_t clock, struct __kernel_timespec *t= s) +{ +#ifdef __NR_clock_getres_time64 + return syscall(__NR_clock_getres_time64, clock, ts); +#else + ASSERT_TIMESPEC_COMPATIBLE(*ts, struct __kernel_old_timespec); + return syscall(__NR_clock_getres, clock, ts); +#endif +} + +static inline +int sys_clock_gettime(__kernel_clockid_t clock, struct __kernel_timespec *= ts) +{ +#ifdef __NR_clock_gettime64 + return syscall(__NR_clock_gettime64, clock, ts); +#else + ASSERT_TIMESPEC_COMPATIBLE(*ts, struct __kernel_old_timespec); + return syscall(__NR_clock_gettime, clock, ts); +#endif +} + +static inline +int sys_gettimeofday(struct __kernel_old_timeval *tv, struct kernel_timezo= ne *tz) +{ +#ifdef __NR_gettimeofday + return syscall(__NR_gettimeofday, tv, tz); +#else + errno =3D ENOSYS; + return -1; +#endif +} + +static inline +__kernel_old_time_t sys_time(__kernel_old_time_t *tloc) +{ +#ifdef __NR_time + return syscall(__NR_time, tloc); +#else + errno =3D ENOSYS; + return -1; +#endif +} + +#endif /* __VDSO_SYSCALLS_H__ */ --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B996937EFF1; Thu, 3 Sep 2026 07:38:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421108; cv=none; b=gUtnRRsPHzQahCHpLoeMl51p/q0RHCRTM1wVlJmMIBHWSxubsSakPykqoRTrhuqLFYJGf1MU2Y1tp1/iNoIicMJIYt57znMVfgmx0h6SpbifnySRzgElAA2YBbYAcOf6yzVnBx4am8F30OE+MyP2y+sXBpciQ0KxiyNA5vJQiIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421108; c=relaxed/simple; bh=kfXhrU5ZDCCCcPmeDM78XUsWU5SKCVK8SjyPBbaDFX8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e7YDG6iF11LhqwMegrHsOxPB653ZmUX2j5QRu8df707KnBRBfPcKfwbEfmtJ6hcAlfsoYWk/ZsKb4e9MY3yJ0RnjL4zs2X1Obl1TIz0YbZiSiZENyRo5TTa672M8LwCdb9vM/SYQPLthEcP+X1wygbTBknMne4d3wesfVLGNq/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bDrMNU6B; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AgmCtq+g; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bDrMNU6B"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AgmCtq+g" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LV3CUf3SZGLcf02CEjkl1gTTOJdadZAMTEhDYrh8D2c=; b=bDrMNU6BLozNvhhXg0wtk86WW00oUBUXcOPNnum0/foKxxtsFszs3R+RGkqwSW4xobDEe1 2lbrEQSi/g0v/yFvMonaMCZxIj1rL4HJyMJboocRwczygM/A+J8KbRVmwu+g2OX2th8CGN s3BLEAa83Q1hZImgQf2J08c0ozhQ7VAq8ZAHLp2JuzWBG5hVnxaRXpYTPgeWdczJoMyU4z dGs6wWxQ77/9ke7SyJ7/vsiSqBDeiwI3e/zyN8+bVb6dS1IfufR3QB+uh0/N91AmSWxOwr 2x4gDpEgHJ4spf5KDFjh5IGIZkUdfoWLC4RO7Gpb2DTuJbkMZQ1EgtkwWXU0RA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LV3CUf3SZGLcf02CEjkl1gTTOJdadZAMTEhDYrh8D2c=; b=AgmCtq+gW1FeKJ5OyYnTbRCXwpKfZ/t7y3MixnvZT5g3Yn0Cs6+PYjmZIVEukVNK2w47RK DFOGdNfHfn8AOSCg== Date: Thu, 03 Sep 2026 09:38:15 +0200 Subject: [PATCH v2 3/8] selftests: vDSO: vdso_test_abi: Use types from vdso_types.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-3-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=4174; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=kfXhrU5ZDCCCcPmeDM78XUsWU5SKCVK8SjyPBbaDFX8=; b=fu3AOWRJwXw+5vNPFNrTpZxQcjp+7Q1OQ9l33neCvGqJA2TkOJMqzsF4VZkUPikWXLENIp4Tw mM26Cqw2RRBBLcmnlmJrH6gPV/JlnSLm1EoPdKoYGnJt1Z77qM357zK X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The libc types are not necessarily compatible with the vDSO functions. Use the dedicated types from vdso_types.h instead. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/vDSO/vdso_test_abi.c | 35 +++++++++---------------= ---- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/s= elftests/vDSO/vdso_test_abi.c index b162a4ba9c4f..b7590a727f06 100644 --- a/tools/testing/selftests/vDSO/vdso_test_abi.c +++ b/tools/testing/selftests/vDSO/vdso_test_abi.c @@ -11,9 +11,7 @@ #include #include #include -#include #include -#include #define _GNU_SOURCE #include #include @@ -21,24 +19,12 @@ #include "kselftest.h" #include "vdso_config.h" #include "vdso_call.h" +#include "vdso_types.h" #include "parse_vdso.h" =20 static const char *version; static const char **name; =20 -/* The same as struct __kernel_timespec */ -struct vdso_timespec64 { - uint64_t tv_sec; - uint64_t tv_nsec; -}; - -typedef long (*vdso_gettimeofday_t)(struct timeval *tv, struct timezone *t= z); -typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts= ); -typedef long (*vdso_clock_gettime64_t)(clockid_t clk_id, struct vdso_times= pec64 *ts); -typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts); -typedef long (*vdso_clock_getres_time64_t)(clockid_t clk_id, struct vdso_t= imespec64 *ts); -typedef time_t (*vdso_time_t)(time_t *t); - static const char * const vdso_clock_name[] =3D { [CLOCK_REALTIME] =3D "CLOCK_REALTIME", [CLOCK_MONOTONIC] =3D "CLOCK_MONOTONIC", @@ -66,7 +52,7 @@ static void vdso_test_gettimeofday(void) return; } =20 - struct timeval tv; + struct __kernel_old_timeval tv; long ret =3D VDSO_CALL(vdso_gettimeofday, 2, &tv, 0); =20 if (ret =3D=3D 0) { @@ -78,7 +64,7 @@ static void vdso_test_gettimeofday(void) } } =20 -static void vdso_test_clock_gettime64(clockid_t clk_id) +static void vdso_test_clock_gettime64(__kernel_clockid_t clk_id) { /* Find clock_gettime64. */ vdso_clock_gettime64_t vdso_clock_gettime64 =3D @@ -91,7 +77,7 @@ static void vdso_test_clock_gettime64(clockid_t clk_id) return; } =20 - struct vdso_timespec64 ts; + struct __kernel_timespec ts; long ret =3D VDSO_CALL(vdso_clock_gettime64, 2, clk_id, &ts); =20 if (ret =3D=3D 0) { @@ -105,7 +91,7 @@ static void vdso_test_clock_gettime64(clockid_t clk_id) } } =20 -static void vdso_test_clock_gettime(clockid_t clk_id) +static void vdso_test_clock_gettime(__kernel_clockid_t clk_id) { /* Find clock_gettime. */ vdso_clock_gettime_t vdso_clock_gettime =3D @@ -118,7 +104,7 @@ static void vdso_test_clock_gettime(clockid_t clk_id) return; } =20 - struct timespec ts; + struct __kernel_old_timespec ts; long ret =3D VDSO_CALL(vdso_clock_gettime, 2, clk_id, &ts); =20 if (ret =3D=3D 0) { @@ -155,7 +141,7 @@ static void vdso_test_time(void) } } =20 -static void vdso_test_clock_getres(clockid_t clk_id) +static void vdso_test_clock_getres(__kernel_clockid_t clk_id) { int clock_getres_fail =3D 0; =20 @@ -170,7 +156,8 @@ static void vdso_test_clock_getres(clockid_t clk_id) return; } =20 - struct timespec ts, sys_ts; + struct __kernel_old_timespec ts; + struct timespec sys_ts; long ret =3D VDSO_CALL(vdso_clock_getres, 2, clk_id, &ts); =20 if (ret =3D=3D 0) { @@ -213,7 +200,7 @@ static void vdso_test_clock_getres_time64(clockid_t clk= _id) return; } =20 - struct vdso_timespec64 ts, sys_ts; + struct __kernel_timespec ts, sys_ts; long ret =3D VDSO_CALL(vdso_clock_getres_time64, 2, clk_id, &ts); =20 if (ret =3D=3D 0) { @@ -250,7 +237,7 @@ static void vdso_test_clock_getres_time64(clockid_t clk= _id) * This function calls vdso_test_clock_gettime and vdso_test_clock_getres * with different values for clock_id. */ -static inline void vdso_test_clock(clockid_t clock_id) +static inline void vdso_test_clock(__kernel_clockid_t clock_id) { ksft_print_msg("clock_id: %s\n", vdso_clock_name[clock_id]); =20 --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A20B3E1203; Thu, 3 Sep 2026 07:38:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421109; cv=none; b=FOdu6KykB1JpgRJr5Q/c4llzlwUPzqn4uzTjM+jZES8sj0QbLROTJL8l9Q7rTMcvgWDT9HwinGWCbgENnmWh7APh/ujU+iFjR2bUL26hOgcgForntIpMFRrg6fz/Xh/NzsVTrB5C5fP0MKn1NxJM4X19PK4LcPIA+hUrmVcmoOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421109; c=relaxed/simple; bh=9FCxlMLSZpoxZ3Ra9hcixI7EIm3apsjbfqrvi+XsRlw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rMH5z44fwRvA4PLZ0uWh1XfrI1Ofxun0F8L1fzTjxRDqfzCBZq38Z5v9gPwX69r61Qnr3DnTYLfQIt2DoTrdShnKEITm8OJvg39ehBVsWICdZvZnf3pztsyKspl3ElZLhgtXgOfWHk9X8NpMixGr2qxjG2D8OSov7fn/8DoHe5U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tRRWk4sk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=jY7+NlFV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tRRWk4sk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jY7+NlFV" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IXgMeHW2Ljzg4Fdzw6/9muy1ZzZpBfRtq04fn6Kd1UY=; b=tRRWk4skfPhRDZnTHT3V2CDgdLy7fo2jedsxBQGvwB4XTw/e3ybGyW8mMH0rRE/ByMLn80 HUWzaLcYuIOGkaJZvJHQaMybUBtK181uh1WVVCIRSCH4tpyR2sPAHLtm2HufWlBhceH5Op DgJ0gII2B3OXAK2ZYayWkc5l4+487onPc0LFcqAwfni1AD28BtUKKPXRZuXYUi1kzxHmDg fN4wNdoOl1ds7qFLfWdmgg6KmShzsWtQfJWNviJ192bjvVCGZAilmmdBUL5P+4yGzoXjbn LTehhVvn5wNGUyqD7poRsjuYDVnvL48SYcW5UIlphvhyD6airyHnKuiPcJudlg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IXgMeHW2Ljzg4Fdzw6/9muy1ZzZpBfRtq04fn6Kd1UY=; b=jY7+NlFVkYf6CbZW5ENvqj9la935CFLVT31UUV9mj36vpwKtvVrzhU9+nUbjnUFXDbUwFC TCmG2Xf/e2qivsDA== Date: Thu, 03 Sep 2026 09:38:16 +0200 Subject: [PATCH v2 4/8] selftests: vDSO: vdso_test_abi: Use system call wrappers from vdso_syscalls.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-4-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=1720; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=9FCxlMLSZpoxZ3Ra9hcixI7EIm3apsjbfqrvi+XsRlw=; b=9KHokY70A8GpdbURC4ZF8xhH9MDl4GOy+kanCSt3jl9cfOmYHVF+1I9IxW/+gm6fxww6q+zdk H6uyQbIrsyiAV+ZpfviIqhLKCFM0CLjgPMtml1oSoQWHHU27xXTvY34 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Using syscall(SYS_getcpu) is problematic for the reasons outlined in vdso_syscalls.h. Use the wrappers from the utility header instead. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/vDSO/vdso_test_abi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/s= elftests/vDSO/vdso_test_abi.c index b7590a727f06..4f63582f4e65 100644 --- a/tools/testing/selftests/vDSO/vdso_test_abi.c +++ b/tools/testing/selftests/vDSO/vdso_test_abi.c @@ -19,6 +19,7 @@ #include "kselftest.h" #include "vdso_config.h" #include "vdso_call.h" +#include "vdso_syscalls.h" #include "vdso_types.h" #include "parse_vdso.h" =20 @@ -157,7 +158,7 @@ static void vdso_test_clock_getres(__kernel_clockid_t c= lk_id) } =20 struct __kernel_old_timespec ts; - struct timespec sys_ts; + struct __kernel_timespec sys_ts; long ret =3D VDSO_CALL(vdso_clock_getres, 2, clk_id, &ts); =20 if (ret =3D=3D 0) { @@ -167,7 +168,7 @@ static void vdso_test_clock_getres(__kernel_clockid_t c= lk_id) clock_getres_fail++; } =20 - ret =3D syscall(__NR_clock_getres, clk_id, &sys_ts); + ret =3D sys_clock_getres(clk_id, &sys_ts); =20 ksft_print_msg("The syscall resolution is %lld %lld\n", (long long)sys_ts.tv_sec, (long long)sys_ts.tv_nsec); @@ -210,7 +211,7 @@ static void vdso_test_clock_getres_time64(clockid_t clk= _id) clock_getres_fail++; } =20 - ret =3D syscall(__NR_clock_getres_time64, clk_id, &sys_ts); + ret =3D sys_clock_getres(clk_id, &sys_ts); =20 ksft_print_msg("The syscall resolution is %lld %lld\n", (long long)sys_ts.tv_sec, (long long)sys_ts.tv_nsec); --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEEA3418363; Thu, 3 Sep 2026 07:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421111; cv=none; b=hnk/V3jyaz3YDFcz8nVGYZjRFVob5Y9tEQSD59AejhSLuYWVTUJCJLFG1xHcXUsmJ4vVVXUfk5/KpWEMEHUxodCe0MJ0pNvxfF9boZQ43ZUWDSnMNc6souPSXBDUehx8C2vWdLOUHlWFg8RgsEYbSrs0rAL86Qe2/4G+C1o893k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421111; c=relaxed/simple; bh=Di/4PqdAEQOJQ/ayv+51BektmeNr4Z4vFgZ+NMwhuQM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SC/P7HmsCiahNCpvy1tIBfCbabIexsx9fBx7TgeghdGiV53Pbv7/9q5imH6MjEJfpEAwIPpS2M0QmTRw00AIANSwyrEW8zD08EeAN8pP3G7GPqFPCowINN33HxmKxIXL9MvTBPqBuZNCZQoqkNW98pt9GGg6Hf8gcYBVU5tUAw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oJu12IJq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KMzkbaDi; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oJu12IJq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KMzkbaDi" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nnKv5IjDqBc3X8/pWetZaLv1z0pddVPv9JqcNEXKQZY=; b=oJu12IJqMxeK0hNpb/I2q3QbkkjMqmSAAfJjDJ5suJJuiZiZCwvRf5+OG06Dk+v6Dmr8at XfqPM8pt3T/iyoBVVhjUA/GK3oMARbHYgSxzr09R3yU5tGWSxPiGyZHNw61jfDDVcD3tbb tfoBxNnDySA5BNXVI3Px+n6r9L2fglJzi9gmeEH09/sYRY0Z/krq413xcoPoj/4o13YoPJ RVs/tR5sp6Hm4YEZF7QkvczctOQMJh9+MCQt20CDdzaIIsC8H3j9iDvwbbgNODNZtaDg/F jxybzml/aaeb6uZ1Va6Z4OUjizGfv1Bv0YpYR/nQM7p8y6s12F2lFmw7LwlJQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nnKv5IjDqBc3X8/pWetZaLv1z0pddVPv9JqcNEXKQZY=; b=KMzkbaDiBT6+7uGSkxkiJ7f4AzUIonesZ+rBcpX61I6/XVa25Va1Nm6rk1k0zOJfXR7DvX YyxEe8XClRiBVIDg== Date: Thu, 03 Sep 2026 09:38:17 +0200 Subject: [PATCH v2 5/8] selftests: vDSO: vdso_test_gettimeofday: Use types from vdso_types.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-5-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=1447; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Di/4PqdAEQOJQ/ayv+51BektmeNr4Z4vFgZ+NMwhuQM=; b=Xh0v3S2AW3PRmOt0/MiYKx1JPmdS19myqwQCRLwLAXCmstTdWORW+5Dl2gjIhL1ln3HjXbNsw iowx925zyKdDSo3bjieKK7jguksV0jzJbFHGPDGEiSntqQ85rIgoL4S X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The libc types are not necessarily compatible with the vDSO functions. Use the dedicated types from vdso_types.h instead. Signed-off-by: Thomas Wei=C3=9Fschuh --- tools/testing/selftests/vDSO/vdso_test_gettimeofday.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/= testing/selftests/vDSO/vdso_test_gettimeofday.c index 990b29e0e272..2119a6429835 100644 --- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c @@ -12,12 +12,12 @@ =20 #include #include -#include =20 #include "kselftest.h" #include "parse_vdso.h" #include "vdso_config.h" #include "vdso_call.h" +#include "vdso_types.h" =20 int main(int argc, char **argv) { @@ -33,15 +33,14 @@ int main(int argc, char **argv) vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); =20 /* Find gettimeofday. */ - typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); - gtod_t gtod =3D (gtod_t)vdso_sym(version, name[0]); + vdso_gettimeofday_t gtod =3D (vdso_gettimeofday_t)vdso_sym(version, name[= 0]); =20 if (!gtod) { printf("Could not find %s\n", name[0]); return KSFT_SKIP; } =20 - struct timeval tv; + struct __kernel_old_timeval tv; long ret =3D VDSO_CALL(gtod, 2, &tv, 0); =20 if (ret =3D=3D 0) { --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEB3941835E; Thu, 3 Sep 2026 07:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421110; cv=none; b=EIkofNWAVKR57AJPnQMqRlm0ZEsH+bW6H3yoVL71qJyN41WIRPjAQPOM65d/20hxs0otLarynYfVhm4mdCSd3TJqM8Yhm8qig+5Uphz5XLOLbR3rBsCbp07hWjL7uZ3o/wLYjZ+gFL+Pa553USbQBGymiMGBdIwSZV6vm/HIO1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421110; c=relaxed/simple; bh=lSRnyAPwkxTiR+7LqZhQLOk8FGTR7q33aG6vR4tUR4k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Nc8OXtRXQv/FLAInNEmrTxdfA1BXKvLkvOAAkaa2z+WRciNq2OflD/Sa9lM4PO7IOb4rlZNXWh+OzTu2s2xwpUAppBhj9WZgq6hN2T/aNdeSLQq1bvyN1mbxcU03MF5At2tlftTAXRnIw8f+kN0sozNoCxlkDjse9Ztgb1KQ5T8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ACkNfwcV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=p67w3Mca; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ACkNfwcV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="p67w3Mca" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DZhPxWlYTtiTqvDB/rjm4ou5PwP5Ufta+ZoHCQD5N8U=; b=ACkNfwcV4/TidgU7f8+L3UC9ET5abkJ1JlL8d9WsDijvKFgB8dOyaHLkT/UVs5rG6Zdq36 NXyl+kG6N7Q9AzPeCwhhZ5fOAkgZlsJIW3wsF/CtefZ+f8ciJTs+ydZobF0cC0d9vlbBHJ VuQOWbg4kYTgfhyExZPaBXR7BR0u5Ess/0h49T9qX4HllpahJCFnV5voK4A/WeDgP3+6kD XM07y7PTQxKtKaaWdbid4EqsUJX/BHQEvk/mzfhwjL3o6SJqsjEqwR8p8xZvq1dDfl3DIb Lh/IVuhm2eAgix+r9Qzy7mVnQL/Wj3a8Y2RTXlU0ykKwSRrls0R66HYOqSWV2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DZhPxWlYTtiTqvDB/rjm4ou5PwP5Ufta+ZoHCQD5N8U=; b=p67w3Mcaw20hgWdpjigtdw+hQnbQgxqo0wBmStCArBL10JA8noG+fiMGAWObuByEyvmBtw C9qJYDHk2EGX7oDg== Date: Thu, 03 Sep 2026 09:38:18 +0200 Subject: [PATCH v2 6/8] selftests: vDSO: vdso_test_correctness: Make ts_leq() and tv_leq() more generic Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-6-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=2368; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=lSRnyAPwkxTiR+7LqZhQLOk8FGTR7q33aG6vR4tUR4k=; b=ygg1mL9k4ohqUEq6CzMYiTHZ9YaYWb9uNzAqd5jWFe0c5gLPXhDR+APxYR1J0+9e3bDi92/XI stf7VL3Szl3C0GnNly6tcshPFtzCLEp7Ib3f0JJ/HOscbUHjICy1cl7 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Upcoming changes will shuffle around the timespec and timeval types. To keep ts_leq() and tv_leq() working with all of those types, transform them into macros. Also drop ts64_leq() as it can now be replaced by the regular ts_leq(). Signed-off-by: Thomas Wei=C3=9Fschuh --- .../testing/selftests/vDSO/vdso_test_correctness.c | 47 ++++++++++--------= ---- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/t= esting/selftests/vDSO/vdso_test_correctness.c index 5c5a07dd1128..537e0030aa16 100644 --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c @@ -226,30 +226,27 @@ static void test_getcpu(void) } } =20 -static bool ts_leq(const struct timespec *a, const struct timespec *b) -{ - if (a->tv_sec !=3D b->tv_sec) - return a->tv_sec < b->tv_sec; - else - return a->tv_nsec <=3D b->tv_nsec; -} - -static bool ts64_leq(const struct __kernel_timespec *a, - const struct __kernel_timespec *b) -{ - if (a->tv_sec !=3D b->tv_sec) - return a->tv_sec < b->tv_sec; - else - return a->tv_nsec <=3D b->tv_nsec; -} - -static bool tv_leq(const struct timeval *a, const struct timeval *b) -{ - if (a->tv_sec !=3D b->tv_sec) - return a->tv_sec < b->tv_sec; - else - return a->tv_usec <=3D b->tv_usec; -} +#define ts_leq(_a, _b) ({ \ + bool _ret; \ + \ + if ((_a)->tv_sec !=3D (_b)->tv_sec) \ + _ret =3D (_a)->tv_sec < (_b)->tv_sec; \ + else \ + _ret =3D (_a)->tv_nsec <=3D (_b)->tv_nsec; \ + \ + _ret; \ +}) + +#define tv_leq(_a, _b) ({ \ + bool _ret; \ + \ + if ((_a)->tv_sec !=3D (_b)->tv_sec) \ + _ret =3D (_a)->tv_sec < (_b)->tv_sec; \ + else \ + _ret =3D (_a)->tv_usec <=3D (_b)->tv_usec; \ + \ + _ret; \ +}) =20 static char const * const clocknames[] =3D { [0] =3D "CLOCK_REALTIME", @@ -365,7 +362,7 @@ static void test_one_clock_gettime64(int clock, const c= har *name) (unsigned long long)vdso.tv_sec, vdso.tv_nsec, (unsigned long long)end.tv_sec, end.tv_nsec); =20 - if (!ts64_leq(&start, &vdso) || !ts64_leq(&vdso, &end)) { + if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) { printf("[FAIL]\tTimes are out of sequence\n"); nerrs++; return; --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE1CB42047A; Thu, 3 Sep 2026 07:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421112; cv=none; b=T1ze5xCsFJmtsNq3zhpjf2sFtgMpPyp+R/qnXHU9D4mTDknhliUh5Wbd/5CRjXKlwrnG6wLeNZpg8rgE7h0J9sLfyr+D++oVnEVsM3Sq4w//tmpbxVGopmv2DvyXu5XeeTcC1RXf6tVfkNApk2DAO8BJZnqHDPz87XG5cB1+B+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421112; c=relaxed/simple; bh=PmwujXtSxuU9x+7Synyy2iY53+6g5TwLZio9clbzMdk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bvBZ5B2Z7yEglxsMWWlH/Ixr1hNaZ5Ryf3BAxkYOyZIu7obZLmV9dn1UtwfQdci8BZbt0bGc0bvPTRBdTsXG6I9vvNJj71ijvBR3PHIhByie9GU+T2ngQ4ULLwStEhMvUuhPkw76BkI9u+iTHXK7ffgRr7mK4Cv7R5aqkX/PdPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=znWeqBey; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+6Y3mdLE; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="znWeqBey"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+6Y3mdLE" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P9VS99y4JKgFj3YzkVvqcAF4wpbqEVo7rub8H6dFEJ8=; b=znWeqBeyryqhW1+GW8x85pgvzVFWdLf8MTm95BgdtO1VpHHdRrOCu6+d6wPR8Y5yuARkbj D0omQfkVy1UoaFxm+S4GirXHLUzT8ds29aqWxhOW6RhRIzdgCNr3pR2l5MxcwDjxnJIk5Z NyqMYaWR+f/a9Bnk7s5zGeJxzoMola/IffWOl8a32bIZ6TlkV6X0u/jKuPTnUcCmC8UapH ozI5+evb/IRvGsrMdW1eN50lC1a+P57/ffsTHfpXgvm7AeM5E5s2ZpnW2M6RbLKv1iJeyz 44JFZ4LezrPQlAa1aT9Oq8KfFZ6sor849dNXMHSUAbZiVMfqCSwM2s9PKfQS1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P9VS99y4JKgFj3YzkVvqcAF4wpbqEVo7rub8H6dFEJ8=; b=+6Y3mdLEnHYLjE4EOkMpVyNRVauAo8SvYNiZ8F0k8QzrRO7IaWX4c98JckZWnG2CzStpUA VMuSnEoAZt0EmfCw== Date: Thu, 03 Sep 2026 09:38:19 +0200 Subject: [PATCH v2 7/8] selftests: vDSO: vdso_test_correctness: Use types from vdso_types.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-7-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=3667; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=PmwujXtSxuU9x+7Synyy2iY53+6g5TwLZio9clbzMdk=; b=3Jn+vxYz9FHipDc5XoE8EUdycsRrrntSAWyPzOhA0tsS7uNrOSHJJiAtWJzKZOKkfe/Svz8ds sr+9kOCETZoDngXXvH20Df35LoybpUft+rK3WP9Akj+/kUCoKssQ6W2 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The libc types are not necessarily compatible with the vDSO functions. Use the dedicated types from vdso_types.h instead. Signed-off-by: Thomas Wei=C3=9Fschuh --- .../testing/selftests/vDSO/vdso_test_correctness.c | 45 ++++++++----------= ---- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/t= esting/selftests/vDSO/vdso_test_correctness.c index 537e0030aa16..83cb408c5947 100644 --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c @@ -7,7 +7,6 @@ #define _GNU_SOURCE =20 #include -#include #include #include #include @@ -22,6 +21,7 @@ #include "parse_vdso.h" #include "vdso_config.h" #include "vdso_call.h" +#include "vdso_types.h" #include "kselftest.h" =20 static const char *version; @@ -31,33 +31,15 @@ static const char **name; #define __NR_clock_gettime64 403 #endif =20 -#ifndef __kernel_timespec -struct __kernel_timespec { - long long tv_sec; - long long tv_nsec; -}; -#endif - /* max length of lines in /proc/self/maps - anything longer is skipped her= e */ #define MAPS_LINE_LEN 128 =20 int nerrs =3D 0; =20 -typedef int (*vgettime_t)(clockid_t, struct timespec *); - -vgettime_t vdso_clock_gettime; - -typedef int (*vgettime64_t)(clockid_t, struct __kernel_timespec *); - -vgettime64_t vdso_clock_gettime64; - -typedef long (*vgtod_t)(struct timeval *tv, struct timezone *tz); - -vgtod_t vdso_gettimeofday; - -typedef time_t (*vtime_t)(__kernel_time_t *tloc); - -vtime_t vdso_time; +vdso_clock_gettime_t vdso_clock_gettime; +vdso_clock_gettime64_t vdso_clock_gettime64; +vdso_gettimeofday_t vdso_gettimeofday; +vdso_time_t vdso_time; =20 typedef long (*getcpu_t)(unsigned *, unsigned *, void *); =20 @@ -123,21 +105,21 @@ static void fill_function_pointers(void) =20 vgetcpu =3D (getcpu_t) vsyscall_getcpu(); =20 - vdso_clock_gettime =3D (vgettime_t)vdso_sym(version, name[1]); + vdso_clock_gettime =3D (vdso_clock_gettime_t)vdso_sym(version, name[1]); if (!vdso_clock_gettime) printf("Warning: failed to find clock_gettime in vDSO\n"); =20 #if defined(VDSO_32BIT) - vdso_clock_gettime64 =3D (vgettime64_t)vdso_sym(version, name[5]); + vdso_clock_gettime64 =3D (vdso_clock_gettime64_t)vdso_sym(version, name[5= ]); if (!vdso_clock_gettime64) printf("Warning: failed to find clock_gettime64 in vDSO\n"); #endif =20 - vdso_gettimeofday =3D (vgtod_t)vdso_sym(version, name[0]); + vdso_gettimeofday =3D (vdso_gettimeofday_t)vdso_sym(version, name[0]); if (!vdso_gettimeofday) printf("Warning: failed to find gettimeofday in vDSO\n"); =20 - vdso_time =3D (vtime_t)vdso_sym(version, name[2]); + vdso_time =3D (vdso_time_t)vdso_sym(version, name[2]); if (!vdso_time) printf("Warning: failed to find time in vDSO\n"); =20 @@ -265,7 +247,8 @@ static char const * const clocknames[] =3D { =20 static void test_one_clock_gettime(int clock, const char *name) { - struct timespec start, vdso, end; + struct __kernel_old_timespec vdso; + struct timespec start, end; int vdso_ret, end_ret; =20 printf("[RUN]\tTesting clock_gettime for clock %s (%d)...\n", name, clock= ); @@ -389,8 +372,10 @@ static void test_clock_gettime64(void) =20 static void test_gettimeofday(void) { - struct timeval start, vdso, end; - struct timezone sys_tz, vdso_tz; + struct __kernel_old_timeval vdso; + struct kernel_timezone vdso_tz; + struct timeval start, end; + struct timezone sys_tz; int vdso_ret, end_ret; =20 if (!vdso_gettimeofday) --=20 2.55.0 From nobody Sat Sep 26 08:38:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68481412BFB; Thu, 3 Sep 2026 07:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421112; cv=none; b=u6QcuuBILjZ0l85AbwHzc9jN4lCFO6O1QHH7gyymRgDArImHRmL2TpWrYBqAdI9Ah0YtIsEikj7EFRSJd62FHPuxMyF6uH+YKxk9cREZNZtPNGqkiqpuJtQGFuqDdAuOnuhhEYVMoEYPfLsEGuXgAVxv+Q+BTJw6tihk+oK5BKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788421112; c=relaxed/simple; bh=TKhqe2TTfNfj5sVgLqQO7VGrRZqhW+HkUrYx9bVViVM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rOTgKlsBHq2Vdb1z8f2L2c7YM/9SS5msgzjxRk56x2axVJShoMED6VWX9UYdAmcOR5r9Mu1bGnX6Itl7F5/2UbGM0B3ImsjG7V/GHgwUSiRlTfcnxa6EbrdRUxKIYgD1XHH02rx4pmgAR5Vm/AWO1i1EyjzJvDhw6cYdXYHrzoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=x+m0s4cu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Nj2wLmGt; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="x+m0s4cu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Nj2wLmGt" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788421102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U8CGbkM5rrJiQ04yKNrLPdNbiL3kdhf4Yu4nKYrxqKI=; b=x+m0s4cubI0u5x4nwbt3Ocpqr9zmMJkURaPzUeEbCmd2KLjdahM7SpWCjwlB3KBvaMUpsI r6nF0DUH2gLH5DyFdyP0WYWw80AzADIUk0l9GTZymJmKAbZTH5aJokr/QTW0KMp6rcC/ek KkS9qMacbaG1eWkjbU/iIQAOK9lD5Pecp37C9vBnovwslG5ytRgL7DraBPqpjsfUGn+8rF RmqXBWsgBHy4viYX96uGxOhhA+4a5Wom8vBpyzg1Iy4UIJ8E+SThsd6SrODm5P0e/FmFKa ZqAq9TSEmRgpPoZIS/Ubhwbp5OrxeTflPUDxvO/+xQhSAqlz5QMFZjKkSNGnwQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788421102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U8CGbkM5rrJiQ04yKNrLPdNbiL3kdhf4Yu4nKYrxqKI=; b=Nj2wLmGtD8cL2VneksO3+I9rg2EXatGCeMgFtqN12aWw+kXLquIkEOD57+pgjdfp0KdzGC aFV0rqFeMKOh3gBw== Date: Thu, 03 Sep 2026 09:38:20 +0200 Subject: [PATCH v2 8/8] selftests: vDSO: vdso_test_correctness: Use system call wrappers from vdso_syscalls.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260903-vdso-test-types-v2-8-1eec04eb3658@linutronix.de> References: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> In-Reply-To: <20260903-vdso-test-types-v2-0-1eec04eb3658@linutronix.de> To: Andy Lutomirski , Vincenzo Frascino , Shuah Khan , Thomas Gleixner Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1788421097; l=3755; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=TKhqe2TTfNfj5sVgLqQO7VGrRZqhW+HkUrYx9bVViVM=; b=RNGYbkdLMlxJUvW9wM1o6ytG4ocDq2BW+wgUlla0ytqmzPh2ZVF5RSc04tNh2X2vPWqUoN8gG GXlJLCEbWSvCFLOGh7fD+r8HSO+EjAFC3f9CMqJbqHLIJV7AD8dFlMX X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Using syscall() is problematic for the reasons outlined in vdso_syscalls.h. Use the wrappers from the utility header instead. Signed-off-by: Thomas Wei=C3=9Fschuh --- .../testing/selftests/vDSO/vdso_test_correctness.c | 44 +++++-------------= ---- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_test_correctness.c b/tools/t= esting/selftests/vDSO/vdso_test_correctness.c index 83cb408c5947..76133566d747 100644 --- a/tools/testing/selftests/vDSO/vdso_test_correctness.c +++ b/tools/testing/selftests/vDSO/vdso_test_correctness.c @@ -21,6 +21,7 @@ #include "parse_vdso.h" #include "vdso_config.h" #include "vdso_call.h" +#include "vdso_syscalls.h" #include "vdso_types.h" #include "kselftest.h" =20 @@ -131,31 +132,6 @@ static long sys_getcpu(unsigned * cpu, unsigned * node, return syscall(__NR_getcpu, cpu, node, cache); } =20 -static inline int sys_clock_gettime(clockid_t id, struct timespec *ts) -{ - return syscall(__NR_clock_gettime, id, ts); -} - -static inline int sys_clock_gettime64(clockid_t id, struct __kernel_timesp= ec *ts) -{ - return syscall(__NR_clock_gettime64, id, ts); -} - -static inline int sys_gettimeofday(struct timeval *tv, struct timezone *tz) -{ - return syscall(__NR_gettimeofday, tv, tz); -} - -static inline __kernel_old_time_t sys_time(__kernel_old_time_t *tloc) -{ -#ifdef __NR_time - return syscall(__NR_time, tloc); -#else - errno =3D ENOSYS; - return -1; -#endif -} - static void test_getcpu(void) { printf("[RUN]\tTesting getcpu...\n"); @@ -247,8 +223,8 @@ static char const * const clocknames[] =3D { =20 static void test_one_clock_gettime(int clock, const char *name) { + struct __kernel_timespec start, end; struct __kernel_old_timespec vdso; - struct timespec start, end; int vdso_ret, end_ret; =20 printf("[RUN]\tTesting clock_gettime for clock %s (%d)...\n", name, clock= ); @@ -279,9 +255,9 @@ static void test_one_clock_gettime(int clock, const cha= r *name) } =20 printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n", - (unsigned long long)start.tv_sec, start.tv_nsec, - (unsigned long long)vdso.tv_sec, vdso.tv_nsec, - (unsigned long long)end.tv_sec, end.tv_nsec); + (unsigned long long)start.tv_sec, (unsigned long)start.tv_nsec, + (unsigned long long)vdso.tv_sec, (unsigned long)vdso.tv_nsec, + (unsigned long long)end.tv_sec, (unsigned long)end.tv_nsec); =20 if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) { printf("[FAIL]\tTimes are out of sequence\n"); @@ -315,7 +291,7 @@ static void test_one_clock_gettime64(int clock, const c= har *name) =20 printf("[RUN]\tTesting clock_gettime64 for clock %s (%d)...\n", name, clo= ck); =20 - if (sys_clock_gettime64(clock, &start) < 0) { + if (sys_clock_gettime(clock, &start) < 0) { if (errno =3D=3D EINVAL) { vdso_ret =3D VDSO_CALL(vdso_clock_gettime64, 2, clock, &vdso); if (vdso_ret =3D=3D -EINVAL) { @@ -331,7 +307,7 @@ static void test_one_clock_gettime64(int clock, const c= har *name) } =20 vdso_ret =3D VDSO_CALL(vdso_clock_gettime64, 2, clock, &vdso); - end_ret =3D sys_clock_gettime64(clock, &end); + end_ret =3D sys_clock_gettime(clock, &end); =20 if (vdso_ret !=3D 0 || end_ret !=3D 0) { printf("[FAIL]\tvDSO returned %d, syscall errno=3D%d\n", @@ -372,10 +348,8 @@ static void test_clock_gettime64(void) =20 static void test_gettimeofday(void) { - struct __kernel_old_timeval vdso; - struct kernel_timezone vdso_tz; - struct timeval start, end; - struct timezone sys_tz; + struct __kernel_old_timeval start, vdso, end; + struct kernel_timezone vdso_tz, sys_tz; int vdso_ret, end_ret; =20 if (!vdso_gettimeofday) --=20 2.55.0