[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175205505591.406.9674153187149360854.tip-bot2@tip-bot2>
Date: Wed, 09 Jul 2025 09:57:35 -0000
From:
tip-bot2 for Thomas Weißschuh <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: thomas.weissschuh@...utronix.de, Thomas Gleixner <tglx@...utronix.de>,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [tip: timers/ptp] vdso/gettimeofday: Introduce vdso_clockid_valid()
The following commit has been merged into the timers/ptp branch of tip:
Commit-ID: a2a9c3129dd8495e48a54f19193adbac1efe673b
Gitweb: https://git.kernel.org/tip/a2a9c3129dd8495e48a54f19193adbac1efe673b
Author: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
AuthorDate: Tue, 01 Jul 2025 10:58:01 +02:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Wed, 09 Jul 2025 11:52:34 +02:00
vdso/gettimeofday: Introduce vdso_clockid_valid()
Move the clock ID validation check into a common helper.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Link: https://lore.kernel.org/all/20250701-vdso-auxclock-v1-7-df7d9f87b9b8@linutronix.de
---
lib/vdso/gettimeofday.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 7e79b02..87e7aae 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -71,6 +71,12 @@ static inline bool vdso_cycles_ok(u64 cycles)
}
#endif
+static __always_inline bool vdso_clockid_valid(clockid_t clock)
+{
+ /* Check for negative values or invalid clocks */
+ return likely((u32) clock < MAX_CLOCKS);
+}
+
#ifdef CONFIG_TIME_NS
#ifdef CONFIG_GENERIC_VDSO_DATA_STORE
@@ -268,8 +274,7 @@ __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
const struct vdso_clock *vc = vd->clock_data;
u32 msk;
- /* Check for negative values or invalid clocks */
- if (unlikely((u32) clock >= MAX_CLOCKS))
+ if (!vdso_clockid_valid(clock))
return false;
/*
@@ -405,8 +410,7 @@ bool __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t cloc
u32 msk;
u64 ns;
- /* Check for negative values or invalid clocks */
- if (unlikely((u32) clock >= MAX_CLOCKS))
+ if (!vdso_clockid_valid(clock))
return false;
if (IS_ENABLED(CONFIG_TIME_NS) &&
Powered by blists - more mailing lists