[PATCH v3 3/4] vdso/gettimeofday: Add support for CLOCK_BOOTTIME_ALARM

From: Thomas Weißschuh

Date: Tue Nov 10 2026 - 09:05:23 EST


CLOCK_BOOTTIME_ALARM behaves exactly as CLOCK_BOOTTIME as far as the
vDSO is concerned. The vDSO library can handle it automatically
correctly. Only the basetime needs to be maintained during the tick.

The namespace offset is already set correctly, although it was not
used before.

Reuse the CLOCK_BOOTTIME basetime for CLOCK_BOOTTIME_ALARM and update
the userspace hres clock mask to include CLOCK_BOOTTIME_ALARM.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
include/vdso/datapage.h | 2 +-
kernel/time/vsyscall.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h
index 89ecf9f9fce5..49f388a54e6a 100644
--- a/include/vdso/datapage.h
+++ b/include/vdso/datapage.h
@@ -40,7 +40,7 @@ struct vdso_arch_data {
BIT(CLOCK_MONOTONIC_COARSE))
#define VDSO_RAW (BIT(CLOCK_MONOTONIC_RAW))
#define VDSO_AUX __GENMASK(CLOCK_AUX_LAST, CLOCK_AUX)
-#define VDSO_ALARM 0
+#define VDSO_ALARM BIT(CLOCK_BOOTTIME_ALARM)

/**
* struct vdso_timestamp - basetime per clock_id
diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c
index fc3313d6afa6..4231b04aec2c 100644
--- a/kernel/time/vsyscall.c
+++ b/kernel/time/vsyscall.c
@@ -69,6 +69,9 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti
vdso_ts->sec += __iter_div64_u64_rem(nsec, (u64)NSEC_PER_SEC << tk->tkr_mono.shift,
&vdso_ts->nsec);

+ /* CLOCK_BOOTTIME_ALARM, copy of CLOCK_BOOTIME */
+ vdata->hres_coarse.basetime[CLOCK_BOOTTIME_ALARM] = *vdso_ts;
+
/* CLOCK_MONOTONIC_RAW */
vdso_ts = &vdata->raw.basetime[CLOCK_MONOTONIC_RAW];
vdso_ts->sec = tk->raw_sec;

--
2.56.0