mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
selftests: vDSO: vdso_test_abi: Add tests for clock_gettime64()
To be y2038-safe, 32-bit userspace needs to explicitly call the 64-bit safe time APIs. For this the 32-bit vDSOs contains a clock_gettime() variant which always uses 64-bit time types. Also test this vDSO function. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250812-vdso-tests-fixes-v2-7-90f499dd35f8@linutronix.de
This commit is contained in:
parent
7b87dbf9d8
commit
7262aa781f
|
|
@ -26,8 +26,15 @@
|
|||
static const char *version;
|
||||
static const char **name;
|
||||
|
||||
/* 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 *tz);
|
||||
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_timespec64 *ts);
|
||||
typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts);
|
||||
typedef time_t (*vdso_time_t)(time_t *t);
|
||||
|
||||
|
|
@ -70,6 +77,33 @@ static void vdso_test_gettimeofday(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void vdso_test_clock_gettime64(clockid_t clk_id)
|
||||
{
|
||||
/* Find clock_gettime64. */
|
||||
vdso_clock_gettime64_t vdso_clock_gettime64 =
|
||||
(vdso_clock_gettime64_t)vdso_sym(version, name[5]);
|
||||
|
||||
if (!vdso_clock_gettime64) {
|
||||
ksft_print_msg("Couldn't find %s\n", name[5]);
|
||||
ksft_test_result_skip("%s %s\n", name[5],
|
||||
vdso_clock_name[clk_id]);
|
||||
return;
|
||||
}
|
||||
|
||||
struct vdso_timespec64 ts;
|
||||
long ret = VDSO_CALL(vdso_clock_gettime64, 2, clk_id, &ts);
|
||||
|
||||
if (ret == 0) {
|
||||
ksft_print_msg("The time is %lld.%06lld\n",
|
||||
(long long)ts.tv_sec, (long long)ts.tv_nsec);
|
||||
ksft_test_result_pass("%s %s\n", name[5],
|
||||
vdso_clock_name[clk_id]);
|
||||
} else {
|
||||
ksft_test_result_fail("%s %s\n", name[5],
|
||||
vdso_clock_name[clk_id]);
|
||||
}
|
||||
}
|
||||
|
||||
static void vdso_test_clock_gettime(clockid_t clk_id)
|
||||
{
|
||||
/* Find clock_gettime. */
|
||||
|
|
@ -171,11 +205,12 @@ static inline void vdso_test_clock(clockid_t clock_id)
|
|||
ksft_print_msg("clock_id: %s\n", vdso_clock_name[clock_id]);
|
||||
|
||||
vdso_test_clock_gettime(clock_id);
|
||||
vdso_test_clock_gettime64(clock_id);
|
||||
|
||||
vdso_test_clock_getres(clock_id);
|
||||
}
|
||||
|
||||
#define VDSO_TEST_PLAN 20
|
||||
#define VDSO_TEST_PLAN 29
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user