From 35f0a96848a730495ff310645387578ca68934cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:14 +0200 Subject: [PATCH 01/19] vdso: Move the kernel-side time update helpers to a new header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vdso/ header namespace is meant for symbols which are usable from vDSO userspace code. However vdso_update_begin() and vdso_update_end() are only usable from the kernel. Move them into a new header in the linux/ namespace. Also rename them to make clear that they are only for time-related data. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-1-63ae856cc659@linutronix.de --- MAINTAINERS | 1 + arch/s390/kernel/time.c | 5 +++-- include/linux/vdso_time.h | 8 ++++++++ include/vdso/vsyscall.h | 3 --- kernel/time/vsyscall.c | 15 ++++++++------- 5 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 include/linux/vdso_time.h diff --git a/MAINTAINERS b/MAINTAINERS index 72294ddfa5b7..879089f1ac1d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11064,6 +11064,7 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/vdso F: include/asm-generic/vdso/vsyscall.h F: include/linux/vdso_datastore.h +F: include/linux/vdso_time.h F: include/vdso/ F: kernel/time/namespace_vdso.c F: kernel/time/vsyscall.c diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index 2b989bebd220..161628f6906f 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -527,7 +528,7 @@ static int stp_sync_clock(void *data) cpu_relax(); rc = 0; if (stp_info.todoff || stp_info.tmd != 2) { - flags = vdso_update_begin(); + flags = vdso_time_update_begin(); rc = chsc_sstpc(stp_page, STP_OP_SYNC, 0, &clock_delta); if (rc == 0) { @@ -537,7 +538,7 @@ static int stp_sync_clock(void *data) if (rc == 0 && stp_info.tmd != 2) rc = -EAGAIN; } - vdso_update_end(flags); + vdso_time_update_end(flags); } sync->in_sync = rc ? -EAGAIN : 1; xchg(&first, 0); diff --git a/include/linux/vdso_time.h b/include/linux/vdso_time.h new file mode 100644 index 000000000000..6d81ee3a3c9c --- /dev/null +++ b/include/linux/vdso_time.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_VDSO_TIME_H +#define _LINUX_VDSO_TIME_H + +unsigned long vdso_time_update_begin(void); +void vdso_time_update_end(unsigned long flags); + +#endif /* _LINUX_VDSO_TIME_H */ diff --git a/include/vdso/vsyscall.h b/include/vdso/vsyscall.h index c5c2a2c07857..29dd4e097220 100644 --- a/include/vdso/vsyscall.h +++ b/include/vdso/vsyscall.h @@ -6,9 +6,6 @@ #include -unsigned long vdso_update_begin(void); -void vdso_update_end(unsigned long flags); - #endif /* !__ASSEMBLER__ */ #endif /* __VDSO_VSYSCALL_H */ diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c index aa59919b8f2c..4b96a8b23294 100644 --- a/kernel/time/vsyscall.c +++ b/kernel/time/vsyscall.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -177,7 +178,7 @@ void vdso_time_update_aux(struct timekeeper *tk) #endif /** - * vdso_update_begin - Start of a VDSO update section + * vdso_time_update_begin - Start of a VDSO update section * * Allows architecture code to safely update the architecture specific VDSO * data. Disables interrupts, acquires timekeeper lock to serialize against @@ -186,9 +187,9 @@ void vdso_time_update_aux(struct timekeeper *tk) * inconsistent data. * * Returns: Saved interrupt flags which need to be handed in to - * vdso_update_end(). + * vdso_time_update_end(). */ -unsigned long vdso_update_begin(void) +unsigned long vdso_time_update_begin(void) { struct vdso_time_data *vdata = vdso_k_time_data; unsigned long flags = timekeeper_lock_irqsave(); @@ -198,14 +199,14 @@ unsigned long vdso_update_begin(void) } /** - * vdso_update_end - End of a VDSO update section - * @flags: Interrupt flags as returned from vdso_update_begin() + * vdso_time_update_end - End of a VDSO update section + * @flags: Interrupt flags as returned from vdso_time_update_begin() * - * Pairs with vdso_update_begin(). Marks vdso data consistent, invokes data + * Pairs with vdso_time_update_begin(). Marks vdso data consistent, invokes data * synchronization if the architecture requires it, drops timekeeper lock * and restores interrupt flags. */ -void vdso_update_end(unsigned long flags) +void vdso_time_update_end(unsigned long flags) { struct vdso_time_data *vdata = vdso_k_time_data; From 4fba7bb3e73a8087c353a6679a49ad81579114bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:15 +0200 Subject: [PATCH 02/19] vdso/gettimeofday: Define fallback __arch_get_vdso_u_time_data() in gettimeofday.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __arch_get_vdso_u_time_data() is only used in gettimeofday.c. vsyscall.h has become a dumping ground for different kinds of fallbacks. Move the fallback function definition into gettimeofday.c, similar to other fallbacks. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-2-63ae856cc659@linutronix.de --- include/asm-generic/vdso/vsyscall.h | 7 ------- lib/vdso/gettimeofday.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h index a6b03cfba0e2..fe12fb1fb442 100644 --- a/include/asm-generic/vdso/vsyscall.h +++ b/include/asm-generic/vdso/vsyscall.h @@ -4,13 +4,6 @@ #ifndef __ASSEMBLER__ -#ifndef __arch_get_vdso_u_time_data -static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_data(void) -{ - return &vdso_u_time_data; -} -#endif - #ifndef __arch_get_vdso_u_rng_data static __always_inline const struct vdso_rng_data *__arch_get_vdso_u_rng_data(void) { diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index f7a591aba59f..b867c2301d5c 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -93,6 +93,13 @@ static inline bool vdso_cycles_ok(u64 cycles) } #endif +#ifndef __arch_get_vdso_u_time_data +static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_data(void) +{ + return &vdso_u_time_data; +} +#endif + static __always_inline bool vdso_clockid_valid(clockid_t clock) { /* Check for negative values or invalid clocks */ From ca0da001d3cfe536ec2cacccd36ce70364cff8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:16 +0200 Subject: [PATCH 03/19] vdso/getrandom: Define fallback __arch_get_vdso_u_rng_data() in getrandom.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __arch_get_vdso_u_rng_data() is only used in getrandom.c. vsyscall.h has become a dumping ground for different kinds of fallbacks. Move the fallback function definition into getrandom.c, similar to other fallbacks. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-3-63ae856cc659@linutronix.de --- include/asm-generic/vdso/vsyscall.h | 7 ------- lib/vdso/getrandom.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h index fe12fb1fb442..cdf7b39cd349 100644 --- a/include/asm-generic/vdso/vsyscall.h +++ b/include/asm-generic/vdso/vsyscall.h @@ -4,13 +4,6 @@ #ifndef __ASSEMBLER__ -#ifndef __arch_get_vdso_u_rng_data -static __always_inline const struct vdso_rng_data *__arch_get_vdso_u_rng_data(void) -{ - return &vdso_u_rng_data; -} -#endif - #ifndef __arch_update_vdso_clock static __always_inline void __arch_update_vdso_clock(struct vdso_clock *vc) { diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index 2851afa9154f..6ff46549281c 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -19,6 +19,13 @@ /* Bring in default accessors */ #include +#ifndef __arch_get_vdso_u_rng_data +static __always_inline const struct vdso_rng_data *__arch_get_vdso_u_rng_data(void) +{ + return &vdso_u_rng_data; +} +#endif + #define MEMCPY_AND_ZERO_SRC(type, dst, src, len) do { \ while (len >= sizeof(type)) { \ __put_unaligned_t(type, __get_unaligned_t(type, src), dst); \ From e4eeeaa14d8dd19613c5254afb335c685039778f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:17 +0200 Subject: [PATCH 04/19] vdso/vsyscall: Define fallback time synchronization functions in vsyscall.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __arch_update_vdso_clock() and __arch_sync_vdso_time_data() are only used in vsyscall.c. vsyscall.h has become a dumping ground for different kinds of fallbacks. Move the fallback function definitions into vsyscall.c. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-4-63ae856cc659@linutronix.de --- include/asm-generic/vdso/vsyscall.h | 11 ----------- kernel/time/vsyscall.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h index cdf7b39cd349..cfb740e82cb5 100644 --- a/include/asm-generic/vdso/vsyscall.h +++ b/include/asm-generic/vdso/vsyscall.h @@ -4,17 +4,6 @@ #ifndef __ASSEMBLER__ -#ifndef __arch_update_vdso_clock -static __always_inline void __arch_update_vdso_clock(struct vdso_clock *vc) -{ -} -#endif /* __arch_update_vdso_clock */ - -#ifndef __arch_sync_vdso_time_data -static __always_inline void __arch_sync_vdso_time_data(struct vdso_time_data *vdata) -{ -} -#endif /* __arch_sync_vdso_time_data */ #endif /* !__ASSEMBLER__ */ diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c index 4b96a8b23294..b314d6d4dce7 100644 --- a/kernel/time/vsyscall.c +++ b/kernel/time/vsyscall.c @@ -16,6 +16,18 @@ #include "timekeeping_internal.h" +#ifndef __arch_update_vdso_clock +static __always_inline void __arch_update_vdso_clock(struct vdso_clock *vc) +{ +} +#endif /* __arch_update_vdso_clock */ + +#ifndef __arch_sync_vdso_time_data +static __always_inline void __arch_sync_vdso_time_data(struct vdso_time_data *vdata) +{ +} +#endif /* __arch_sync_vdso_time_data */ + static inline void fill_clock_configuration(struct vdso_clock *vc, const struct tk_read_base *base) { vc->cycle_last = base->cycle_last; From 8579b901d1506024656bb398ddff9d9115f4a06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:18 +0200 Subject: [PATCH 05/19] vdso: Delete asm-generic/vdso/vsyscall.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recent refactoring have made the header empty. Remove it and its mentions. Also that header was never a real asm-generic header anyways. It had no reason to be in the asm-generic directory. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-5-63ae856cc659@linutronix.de --- MAINTAINERS | 1 - arch/arm/include/asm/vdso/vsyscall.h | 3 --- arch/arm64/include/asm/vdso/vsyscall.h | 3 --- arch/loongarch/include/asm/vdso/vsyscall.h | 3 --- arch/mips/include/asm/vdso/vsyscall.h | 3 --- arch/powerpc/include/asm/vdso/vsyscall.h | 3 --- arch/riscv/include/asm/vdso/vsyscall.h | 3 --- arch/s390/include/asm/vdso/vsyscall.h | 3 --- arch/sparc/include/asm/vdso/vsyscall.h | 2 -- arch/x86/include/asm/vdso/vsyscall.h | 3 --- include/asm-generic/vdso/vsyscall.h | 10 ---------- 11 files changed, 37 deletions(-) delete mode 100644 include/asm-generic/vdso/vsyscall.h diff --git a/MAINTAINERS b/MAINTAINERS index 879089f1ac1d..6c9810ff274a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11062,7 +11062,6 @@ M: Vincenzo Frascino L: linux-kernel@vger.kernel.org S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/vdso -F: include/asm-generic/vdso/vsyscall.h F: include/linux/vdso_datastore.h F: include/linux/vdso_time.h F: include/vdso/ diff --git a/arch/arm/include/asm/vdso/vsyscall.h b/arch/arm/include/asm/vdso/vsyscall.h index ff1c729af05f..14f2ea9d8640 100644 --- a/arch/arm/include/asm/vdso/vsyscall.h +++ b/arch/arm/include/asm/vdso/vsyscall.h @@ -14,9 +14,6 @@ void __arch_sync_vdso_time_data(struct vdso_time_data *vdata) } #define __arch_sync_vdso_time_data __arch_sync_vdso_time_data -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLY__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/arm64/include/asm/vdso/vsyscall.h b/arch/arm64/include/asm/vdso/vsyscall.h index 3f3c8eb74e2e..7d9d6bdd58b2 100644 --- a/arch/arm64/include/asm/vdso/vsyscall.h +++ b/arch/arm64/include/asm/vdso/vsyscall.h @@ -19,9 +19,6 @@ void __arch_update_vdso_clock(struct vdso_clock *vc) } #define __arch_update_vdso_clock __arch_update_vdso_clock -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/loongarch/include/asm/vdso/vsyscall.h b/arch/loongarch/include/asm/vdso/vsyscall.h index 558eb9dfda52..db653780519d 100644 --- a/arch/loongarch/include/asm/vdso/vsyscall.h +++ b/arch/loongarch/include/asm/vdso/vsyscall.h @@ -6,9 +6,6 @@ #include -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/mips/include/asm/vdso/vsyscall.h b/arch/mips/include/asm/vdso/vsyscall.h index 0f061a9babd1..f01ab2e15c08 100644 --- a/arch/mips/include/asm/vdso/vsyscall.h +++ b/arch/mips/include/asm/vdso/vsyscall.h @@ -8,9 +8,6 @@ #include -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/powerpc/include/asm/vdso/vsyscall.h b/arch/powerpc/include/asm/vdso/vsyscall.h index bee18e8660a0..6a6510fa8217 100644 --- a/arch/powerpc/include/asm/vdso/vsyscall.h +++ b/arch/powerpc/include/asm/vdso/vsyscall.h @@ -6,9 +6,6 @@ #include -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* _ASM_POWERPC_VDSO_VSYSCALL_H */ diff --git a/arch/riscv/include/asm/vdso/vsyscall.h b/arch/riscv/include/asm/vdso/vsyscall.h index 558eb9dfda52..db653780519d 100644 --- a/arch/riscv/include/asm/vdso/vsyscall.h +++ b/arch/riscv/include/asm/vdso/vsyscall.h @@ -6,9 +6,6 @@ #include -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/s390/include/asm/vdso/vsyscall.h b/arch/s390/include/asm/vdso/vsyscall.h index b00acec8ddbc..c74c307c320c 100644 --- a/arch/s390/include/asm/vdso/vsyscall.h +++ b/arch/s390/include/asm/vdso/vsyscall.h @@ -8,9 +8,6 @@ #include #include -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/sparc/include/asm/vdso/vsyscall.h b/arch/sparc/include/asm/vdso/vsyscall.h index 8bfe703fedc5..b08e0bd5e309 100644 --- a/arch/sparc/include/asm/vdso/vsyscall.h +++ b/arch/sparc/include/asm/vdso/vsyscall.h @@ -5,6 +5,4 @@ #define __VDSO_PAGES 4 -#include - #endif /* _ASM_SPARC_VDSO_VSYSCALL_H */ diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h index 4aa311a923f2..57598db8763b 100644 --- a/arch/x86/include/asm/vdso/vsyscall.h +++ b/arch/x86/include/asm/vdso/vsyscall.h @@ -14,9 +14,6 @@ #include #include -/* The asm-generic header needs to be included after the definitions above */ -#include - #endif /* !__ASSEMBLER__ */ #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h deleted file mode 100644 index cfb740e82cb5..000000000000 --- a/include/asm-generic/vdso/vsyscall.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_GENERIC_VSYSCALL_H -#define __ASM_GENERIC_VSYSCALL_H - -#ifndef __ASSEMBLER__ - - -#endif /* !__ASSEMBLER__ */ - -#endif /* __ASM_GENERIC_VSYSCALL_H */ From 8051a0f482e6039b257f534a39d820547e7c82bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:19 +0200 Subject: [PATCH 06/19] x86/vdso: Move vDSO page definitions to asm/vdso.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most architectures define the vDSO page macros in asm/vdso.h. Align the x86 headers. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-6-63ae856cc659@linutronix.de --- arch/x86/include/asm/vdso.h | 7 +++++++ arch/x86/include/asm/vdso/vsyscall.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h index 4e735158c1b2..071e4a262b50 100644 --- a/arch/x86/include/asm/vdso.h +++ b/arch/x86/include/asm/vdso.h @@ -6,6 +6,13 @@ #include #include +#define __VDSO_PAGES 6 + +#define VDSO_NR_VCLOCK_PAGES 2 +#define VDSO_VCLOCK_PAGES_START(_b) ((_b) + (__VDSO_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE) +#define VDSO_PAGE_PVCLOCK_OFFSET 0 +#define VDSO_PAGE_HVCLOCK_OFFSET 1 + #ifndef __ASSEMBLER__ #include diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h index 57598db8763b..65d10f4cc718 100644 --- a/arch/x86/include/asm/vdso/vsyscall.h +++ b/arch/x86/include/asm/vdso/vsyscall.h @@ -2,13 +2,6 @@ #ifndef __ASM_VDSO_VSYSCALL_H #define __ASM_VDSO_VSYSCALL_H -#define __VDSO_PAGES 6 - -#define VDSO_NR_VCLOCK_PAGES 2 -#define VDSO_VCLOCK_PAGES_START(_b) ((_b) + (__VDSO_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE) -#define VDSO_PAGE_PVCLOCK_OFFSET 0 -#define VDSO_PAGE_HVCLOCK_OFFSET 1 - #ifndef __ASSEMBLER__ #include From 782478555fc637bf0677940922bf64e7daaa0410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:20 +0200 Subject: [PATCH 07/19] sparc/vdso: Move __VDSO_PAGES to asm/vdso.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most architectures define the __VDSO_PAGES page macro in asm/vdso.h. Align the SPARC headers. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-7-63ae856cc659@linutronix.de --- arch/sparc/include/asm/vdso.h | 6 ++++++ arch/sparc/include/asm/vdso/vsyscall.h | 2 -- arch/sparc/vdso/vdso-layout.lds.S | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/sparc/include/asm/vdso.h b/arch/sparc/include/asm/vdso.h index f08562d10215..b17c37c8075b 100644 --- a/arch/sparc/include/asm/vdso.h +++ b/arch/sparc/include/asm/vdso.h @@ -5,6 +5,10 @@ #ifndef _ASM_SPARC_VDSO_H #define _ASM_SPARC_VDSO_H +#define __VDSO_PAGES 4 + +#ifndef __ASSEMBLER__ + struct vdso_image { void *data; unsigned long size; /* Always a multiple of PAGE_SIZE */ @@ -17,4 +21,6 @@ extern const struct vdso_image vdso_image_64_builtin; extern const struct vdso_image vdso_image_32_builtin; #endif +#endif /* __ASSEMBLER__ */ + #endif /* _ASM_SPARC_VDSO_H */ diff --git a/arch/sparc/include/asm/vdso/vsyscall.h b/arch/sparc/include/asm/vdso/vsyscall.h index b08e0bd5e309..ff62b291e4eb 100644 --- a/arch/sparc/include/asm/vdso/vsyscall.h +++ b/arch/sparc/include/asm/vdso/vsyscall.h @@ -3,6 +3,4 @@ #ifndef _ASM_SPARC_VDSO_VSYSCALL_H #define _ASM_SPARC_VDSO_VSYSCALL_H -#define __VDSO_PAGES 4 - #endif /* _ASM_SPARC_VDSO_VSYSCALL_H */ diff --git a/arch/sparc/vdso/vdso-layout.lds.S b/arch/sparc/vdso/vdso-layout.lds.S index 180e5d0ee071..920396203a2e 100644 --- a/arch/sparc/vdso/vdso-layout.lds.S +++ b/arch/sparc/vdso/vdso-layout.lds.S @@ -6,7 +6,7 @@ #include #include -#include +#include SECTIONS { From d5b1dadd2ef0d7aa05595401f824104fd8e07899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:21 +0200 Subject: [PATCH 08/19] s390/vdso: Delete asm/vdso/vsyscall.h inclusions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inclusions are unnecessary, remove them. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-8-63ae856cc659@linutronix.de --- arch/s390/include/asm/vdso/getrandom.h | 1 - arch/s390/kernel/vdso.c | 1 - arch/s390/kernel/vdso/vdso.lds.S | 1 - 3 files changed, 3 deletions(-) diff --git a/arch/s390/include/asm/vdso/getrandom.h b/arch/s390/include/asm/vdso/getrandom.h index 6741a27199f8..ff5882f2fc70 100644 --- a/arch/s390/include/asm/vdso/getrandom.h +++ b/arch/s390/include/asm/vdso/getrandom.h @@ -6,7 +6,6 @@ #ifndef __ASSEMBLER__ #include -#include #include #include #include diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index 0fe616c49fcc..a905f989f910 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/arch/s390/kernel/vdso/vdso.lds.S b/arch/s390/kernel/vdso/vdso.lds.S index 841daeec4be2..6bcdb64315f2 100644 --- a/arch/s390/kernel/vdso/vdso.lds.S +++ b/arch/s390/kernel/vdso/vdso.lds.S @@ -4,7 +4,6 @@ * library */ -#include #include #include #include From cc729f8448151a455b125a827f9fc883f822968f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:22 +0200 Subject: [PATCH 09/19] sparc/vdso: Delete asm/vdso/vsyscall.h inclusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inclusion is unnecessary, remove it. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-9-63ae856cc659@linutronix.de --- arch/sparc/vdso/vma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/sparc/vdso/vma.c b/arch/sparc/vdso/vma.c index 60029d60f4d3..ab6626c1ee61 100644 --- a/arch/sparc/vdso/vma.c +++ b/arch/sparc/vdso/vma.c @@ -23,7 +23,6 @@ #include #include -#include unsigned int __read_mostly vdso_enabled = 1; From 3086b69ee00f57a4b3c5735ce876801f25673aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:23 +0200 Subject: [PATCH 10/19] x86/vdso: Delete asm/vdso/vsyscall.h inclusions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inclusions are unnecessary, remove them. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-10-63ae856cc659@linutronix.de --- arch/x86/entry/vdso/common/vdso-layout.lds.S | 1 - arch/x86/entry/vdso/vma.c | 1 - 2 files changed, 2 deletions(-) diff --git a/arch/x86/entry/vdso/common/vdso-layout.lds.S b/arch/x86/entry/vdso/common/vdso-layout.lds.S index a1e30be3e83d..f190efbc640e 100644 --- a/arch/x86/entry/vdso/common/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/common/vdso-layout.lds.S @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include -#include #include /* diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 18dfd80a81ef..4bd3b22beea9 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -25,7 +25,6 @@ #include #include #include -#include #include static_assert(VDSO_NR_PAGES + VDSO_NR_VCLOCK_PAGES == __VDSO_PAGES); From 128b1c7d3ac8486018299a31c4398305ecb61b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:24 +0200 Subject: [PATCH 11/19] arm64/vdso: Delete asm/vdso/vsyscall.h inclusions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inclusions are unnecessary, remove them. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-11-63ae856cc659@linutronix.de --- arch/arm64/include/asm/vdso/getrandom.h | 1 - arch/arm64/kernel/vdso/vdso.lds.S | 1 - 2 files changed, 2 deletions(-) diff --git a/arch/arm64/include/asm/vdso/getrandom.h b/arch/arm64/include/asm/vdso/getrandom.h index da1d58bbfabe..d9b9104d4ea1 100644 --- a/arch/arm64/include/asm/vdso/getrandom.h +++ b/arch/arm64/include/asm/vdso/getrandom.h @@ -6,7 +6,6 @@ #ifndef __ASSEMBLER__ #include -#include #include /** diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index 52314be29191..6334ca0a7673 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -11,7 +11,6 @@ #include #include #include -#include #include #include From 0d10af5db4818ec1b90d1cf47a1d383598fc4129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:25 +0200 Subject: [PATCH 12/19] riscv/hwprobe: Include vdso/datapage.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The symbol vdso_k_arch_data is provided by vdso/datapage.h, which is currently not included explicitly. An upcoming refactoring will remove the currently used transitive inclusion. Add an explicit inclusion. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-12-63ae856cc659@linutronix.de --- arch/riscv/kernel/sys_hwprobe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c index 7818e1d32622..5c440ec661fb 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -18,6 +18,7 @@ #include #include #include +#include #include From d6df494a01351b1b757b7f1f559bcf696d03667d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:26 +0200 Subject: [PATCH 13/19] vdso: Remove unnecessary vdso/vsyscall.h includes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit None of these files uses anything from the header. Remove the inclusion. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-13-63ae856cc659@linutronix.de --- arch/arm/kernel/vdso.c | 1 - arch/arm64/kernel/vdso.c | 1 - arch/loongarch/kernel/vdso.c | 1 - arch/mips/kernel/vdso.c | 1 - arch/riscv/kernel/sys_hwprobe.c | 1 - arch/riscv/kernel/vdso.c | 1 - arch/s390/kernel/time.c | 1 - lib/vdso/getrandom.c | 3 --- lib/vdso/gettimeofday.c | 3 --- 9 files changed, 13 deletions(-) diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index e306d0c5a21c..7be871f5eb9e 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -23,7 +23,6 @@ #include #include #include -#include #define MAX_SYMNAME 64 diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 592dd8668de4..50596dab23f9 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c index 8ce8159c10b9..1edc8fb720de 100644 --- a/arch/loongarch/kernel/vdso.c +++ b/arch/loongarch/kernel/vdso.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index 8165dd3fc1f8..8eb1760a8a9b 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c @@ -23,7 +23,6 @@ #include #include #include -#include static_assert(VDSO_NR_PAGES == __VDSO_PAGES); diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c index 5c440ec661fb..d427d2f02c60 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -19,7 +19,6 @@ #include #include #include -#include #define EXT_KEY(isa_arg, ext, pv, missing) \ diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index 9c2f5e442338..5666cec180ac 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -15,7 +15,6 @@ #include #include #include -#include #define VVAR_SIZE (VDSO_NR_PAGES << PAGE_SHIFT) diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index 161628f6906f..bca65bf1c8cb 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index 6ff46549281c..e0fa10bbefc9 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -16,9 +16,6 @@ #include #include -/* Bring in default accessors */ -#include - #ifndef __arch_get_vdso_u_rng_data static __always_inline const struct vdso_rng_data *__arch_get_vdso_u_rng_data(void) { diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index b867c2301d5c..728fed1ae52f 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -27,9 +27,6 @@ #include -/* Bring in default accessors */ -#include - #ifndef vdso_calc_ns #ifdef VDSO_DELTA_NOMASK From 996b01393e9317d6443b0c1816fa7e5134c2a0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:27 +0200 Subject: [PATCH 14/19] vdso: Add asm-generic/vdso/vsyscall.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most architectures' asm/vdso/vsyscall.h do not define any symbols. Add an empty asm-generic variant and replace the pointless architecture-specific copies. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-14-63ae856cc659@linutronix.de --- arch/loongarch/include/asm/vdso/vsyscall.h | 11 ----------- arch/mips/include/asm/vdso/vsyscall.h | 13 ------------- arch/powerpc/include/asm/vdso/vsyscall.h | 11 ----------- arch/riscv/include/asm/vdso/vsyscall.h | 11 ----------- arch/s390/include/asm/vdso/vsyscall.h | 13 ------------- arch/sparc/include/asm/vdso/vsyscall.h | 6 ------ arch/x86/include/asm/vdso/vsyscall.h | 12 ------------ include/asm-generic/Kbuild | 1 + include/asm-generic/vdso/vsyscall.h | 0 9 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 arch/loongarch/include/asm/vdso/vsyscall.h delete mode 100644 arch/mips/include/asm/vdso/vsyscall.h delete mode 100644 arch/powerpc/include/asm/vdso/vsyscall.h delete mode 100644 arch/riscv/include/asm/vdso/vsyscall.h delete mode 100644 arch/s390/include/asm/vdso/vsyscall.h delete mode 100644 arch/sparc/include/asm/vdso/vsyscall.h delete mode 100644 arch/x86/include/asm/vdso/vsyscall.h create mode 100644 include/asm-generic/vdso/vsyscall.h diff --git a/arch/loongarch/include/asm/vdso/vsyscall.h b/arch/loongarch/include/asm/vdso/vsyscall.h deleted file mode 100644 index db653780519d..000000000000 --- a/arch/loongarch/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_VDSO_VSYSCALL_H -#define __ASM_VDSO_VSYSCALL_H - -#ifndef __ASSEMBLER__ - -#include - -#endif /* !__ASSEMBLER__ */ - -#endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/mips/include/asm/vdso/vsyscall.h b/arch/mips/include/asm/vdso/vsyscall.h deleted file mode 100644 index f01ab2e15c08..000000000000 --- a/arch/mips/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_VDSO_VSYSCALL_H -#define __ASM_VDSO_VSYSCALL_H - -#include - -#ifndef __ASSEMBLER__ - -#include - -#endif /* !__ASSEMBLER__ */ - -#endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/powerpc/include/asm/vdso/vsyscall.h b/arch/powerpc/include/asm/vdso/vsyscall.h deleted file mode 100644 index 6a6510fa8217..000000000000 --- a/arch/powerpc/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_POWERPC_VDSO_VSYSCALL_H -#define _ASM_POWERPC_VDSO_VSYSCALL_H - -#ifndef __ASSEMBLER__ - -#include - -#endif /* !__ASSEMBLER__ */ - -#endif /* _ASM_POWERPC_VDSO_VSYSCALL_H */ diff --git a/arch/riscv/include/asm/vdso/vsyscall.h b/arch/riscv/include/asm/vdso/vsyscall.h deleted file mode 100644 index db653780519d..000000000000 --- a/arch/riscv/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_VDSO_VSYSCALL_H -#define __ASM_VDSO_VSYSCALL_H - -#ifndef __ASSEMBLER__ - -#include - -#endif /* !__ASSEMBLER__ */ - -#endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/s390/include/asm/vdso/vsyscall.h b/arch/s390/include/asm/vdso/vsyscall.h deleted file mode 100644 index c74c307c320c..000000000000 --- a/arch/s390/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_VDSO_VSYSCALL_H -#define __ASM_VDSO_VSYSCALL_H - -#ifndef __ASSEMBLER__ - -#include -#include -#include - -#endif /* !__ASSEMBLER__ */ - -#endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/sparc/include/asm/vdso/vsyscall.h b/arch/sparc/include/asm/vdso/vsyscall.h deleted file mode 100644 index ff62b291e4eb..000000000000 --- a/arch/sparc/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef _ASM_SPARC_VDSO_VSYSCALL_H -#define _ASM_SPARC_VDSO_VSYSCALL_H - -#endif /* _ASM_SPARC_VDSO_VSYSCALL_H */ diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h deleted file mode 100644 index 65d10f4cc718..000000000000 --- a/arch/x86/include/asm/vdso/vsyscall.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_VDSO_VSYSCALL_H -#define __ASM_VDSO_VSYSCALL_H - -#ifndef __ASSEMBLER__ - -#include -#include - -#endif /* !__ASSEMBLER__ */ - -#endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index 2bc00c67dc54..b7a388bef6ea 100644 --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild @@ -63,6 +63,7 @@ mandatory-y += trace_clock.h mandatory-y += uaccess.h mandatory-y += unwind_user.h mandatory-y += vdso/clocksource.h +mandatory-y += vdso/vsyscall.h mandatory-y += vermagic.h mandatory-y += vga.h mandatory-y += video.h diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/vsyscall.h new file mode 100644 index 000000000000..e69de29bb2d1 From 9e61cabcce2bdc14a5e4c0b08b2fbf5515f2ac23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 9 Sep 2026 10:51:28 +0200 Subject: [PATCH 15/19] vdso: Remove __ASSEMBLER__ guards from vsyscall.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These headers are only used from regular C code. Remove the unnecessary guards. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260909-vdso-asm-generic-vsyscall-h-v1-15-63ae856cc659@linutronix.de --- arch/arm/include/asm/vdso/vsyscall.h | 4 ---- arch/arm64/include/asm/vdso/vsyscall.h | 4 ---- include/vdso/vsyscall.h | 4 ---- 3 files changed, 12 deletions(-) diff --git a/arch/arm/include/asm/vdso/vsyscall.h b/arch/arm/include/asm/vdso/vsyscall.h index 14f2ea9d8640..b97dda100e52 100644 --- a/arch/arm/include/asm/vdso/vsyscall.h +++ b/arch/arm/include/asm/vdso/vsyscall.h @@ -2,8 +2,6 @@ #ifndef __ASM_VDSO_VSYSCALL_H #define __ASM_VDSO_VSYSCALL_H -#ifndef __ASSEMBLY__ - #include #include @@ -14,6 +12,4 @@ void __arch_sync_vdso_time_data(struct vdso_time_data *vdata) } #define __arch_sync_vdso_time_data __arch_sync_vdso_time_data -#endif /* !__ASSEMBLY__ */ - #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/arch/arm64/include/asm/vdso/vsyscall.h b/arch/arm64/include/asm/vdso/vsyscall.h index 7d9d6bdd58b2..7c46c37fd36f 100644 --- a/arch/arm64/include/asm/vdso/vsyscall.h +++ b/arch/arm64/include/asm/vdso/vsyscall.h @@ -2,8 +2,6 @@ #ifndef __ASM_VDSO_VSYSCALL_H #define __ASM_VDSO_VSYSCALL_H -#ifndef __ASSEMBLER__ - #include #define VDSO_PRECISION_MASK ~(0xFF00ULL<<48) @@ -19,6 +17,4 @@ void __arch_update_vdso_clock(struct vdso_clock *vc) } #define __arch_update_vdso_clock __arch_update_vdso_clock -#endif /* !__ASSEMBLER__ */ - #endif /* __ASM_VDSO_VSYSCALL_H */ diff --git a/include/vdso/vsyscall.h b/include/vdso/vsyscall.h index 29dd4e097220..af62bbf04eac 100644 --- a/include/vdso/vsyscall.h +++ b/include/vdso/vsyscall.h @@ -2,10 +2,6 @@ #ifndef __VDSO_VSYSCALL_H #define __VDSO_VSYSCALL_H -#ifndef __ASSEMBLER__ - #include -#endif /* !__ASSEMBLER__ */ - #endif /* __VDSO_VSYSCALL_H */ From 50628893711fd5dc3fdbe8cb95e685f2fe75b662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 21 Sep 2026 11:45:58 +0200 Subject: [PATCH 16/19] vdso/gettimeofday: Avoid runtime conditional in do_hres_timens() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the derivation of the non-namespaced clock from its namespaced sibling uses a runtime conditional. This conditional mirrors the VDSO_RAW check in __cvdso_clock_gettime_common(), in a non-obvious way. Replace the runtime conditional with unconditional pointer arithmetic, which removes the duplication of logic and also is smaller and faster. Also get rid of the weird double use of the 'vc' variable, pointing both to the array of clocks and later to one specific one. This saves 31 bytes of .text on x86_64. Signed-off-by: Thomas Weißschuh Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260921-vdso-timens-conditional-v1-1-eac173f8bd92@weissschuh.net --- lib/vdso/gettimeofday.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 728fed1ae52f..c0e81996532d 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -139,22 +139,23 @@ const struct vdso_time_data *vdso_timens_data(const struct vdso_time_data *vd) return (void *)vd + PAGE_SIZE; } +static __always_inline +const struct vdso_clock *vdso_timens_clock(const struct vdso_clock *vc) +{ + return (void *)vc + PAGE_SIZE; +} + static __always_inline bool do_hres_timens(const struct vdso_time_data *vdns, const struct vdso_clock *vcns, clockid_t clk, struct __kernel_timespec *ts) { const struct vdso_time_data *vd = vdso_timens_data(vdns); + const struct vdso_clock *vc = vdso_timens_clock(vcns); const struct timens_offset *offs = &vcns->offset[clk]; - const struct vdso_clock *vc = vd->clock_data; u32 seq; s64 sec; u64 ns; - if (clk != CLOCK_MONOTONIC_RAW) - vc = &vc[CS_HRES_COARSE]; - else - vc = &vc[CS_RAW]; - do { seq = vdso_read_begin(vc); From c1b910b270fee8930865410455f71e273f4c602c Mon Sep 17 00:00:00 2001 From: Zhan Xusheng Date: Fri, 2 Oct 2026 23:30:59 +0800 Subject: [PATCH 17/19] vdso/math64: Use OPTIMIZER_HIDE_VAR() in __iter_div_u64_rem() __iter_div_u64_rem() open-codes an empty asm() to keep the compiler from turning the subtraction loop into a modulo operation. That is what OPTIMIZER_HIDE_VAR() is for, so use it and reflow the comment. The macro lives in linux/compiler.h, which this header did not include. vdso/math64.h is reached from linux/math64.h, whose includes are linux/types.h, linux/math.h, asm/div64.h and vdso/math64.h; none of them guarantees linux/compiler.h. x86 happens to get it through asm/div64.h -> linux/log2.h, m68k's asm/div64.h only pulls in asm-generic/div64.h and linux/types.h, so the macro is undeclared there and the build fails with -Werror=implicit-function-declaration. Include linux/compiler.h so the header no longer depends on its includer. This is a no-op for the vDSO, where lib/vdso/gettimeofday.c already gets it through linux/build_bug.h, and vdso/unaligned.h sets the same precedent by including linux/compiler_types.h. Reported-by: kernel test robot Signed-off-by: Zhan Xusheng Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20261002153104.1347978-2-zhanxusheng@xiaomi.com Closes: https://lore.kernel.org/oe-kbuild-all/202609300626.zwNjKaO6-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202609301300.uAawkHuh-lkp@intel.com/ --- include/vdso/math64.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/vdso/math64.h b/include/vdso/math64.h index 22ae212f8b28..3c08909e742b 100644 --- a/include/vdso/math64.h +++ b/include/vdso/math64.h @@ -2,15 +2,18 @@ #ifndef __VDSO_MATH64_H #define __VDSO_MATH64_H -static __always_inline u32 -__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) +#include + +static __always_inline u32 __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) { u32 ret = 0; while (dividend >= divisor) { - /* The following asm() prevents the compiler from - optimising this loop into a modulo operation. */ - asm("" : "+rm"(dividend)); + /* + * Prevent the compiler from optimising this loop into a + * modulo operation. + */ + OPTIMIZER_HIDE_VAR(dividend); dividend -= divisor; ret++; From dcd65074e2c593a06bed36178bba6d49d6b6883c Mon Sep 17 00:00:00 2001 From: Zhan Xusheng Date: Fri, 2 Oct 2026 23:31:00 +0800 Subject: [PATCH 18/19] vdso/math64: Add and use __iter_div64_u64_rem() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vDSO basetimes for CLOCK_MONOTONIC and CLOCK_BOOTTIME are stored in the scaled nanoseconds of tkr_mono, so normalising them requires a division by NSEC_PER_SEC << shift. That divisor does not fit the u32 parameter of __iter_div_u64_rem(), so update_vdso_time_data() open-codes the same iterative division twice. Repeated subtraction is the appropriate form at these two sites because the quotient never exceeds one. accumulate_nsecs_to_secs() keeps xtime_nsec below one scaled second, and the offset added to it is a normalised timespec64 fraction, so the dividend stays below twice the divisor. That bound holds on every architecture, which matters more here than the cost of a division on any particular one. Add __iter_div64_u64_rem(), the u64-divisor counterpart of __iter_div_u64_rem(), and use it at both sites. Return the quotient as a u32 for consistency with the u32-divisor variant; the bound above leaves no use for a wider type. Store the remainder directly into the basetime, as the coarse clocks already do. The CLOCK_BOOTTIME copy of the CLOCK_MONOTONIC values then takes both fields from the same place. Folding the two open-coded loops into one inlined helper removes 16 bytes of vsyscall.o text on x86-64 with gcc 13. No functional change. Suggested-by: David Laight Signed-off-by: Zhan Xusheng Signed-off-by: Thomas Gleixner Reviewed-by: Thomas Weißschuh Link: https://patch.msgid.link/20261002153104.1347978-3-zhanxusheng@xiaomi.com --- include/vdso/math64.h | 20 ++++++++++++++++++++ kernel/time/vsyscall.c | 16 +++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/vdso/math64.h b/include/vdso/math64.h index 3c08909e742b..6f1e311cfdbd 100644 --- a/include/vdso/math64.h +++ b/include/vdso/math64.h @@ -24,6 +24,26 @@ static __always_inline u32 __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *re return ret; } +static __always_inline u32 __iter_div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) +{ + u32 ret = 0; + + while (dividend >= divisor) { + /* + * Prevent the compiler from optimising this loop into a + * modulo operation. + */ + OPTIMIZER_HIDE_VAR(dividend); + + dividend -= divisor; + ret++; + } + + *remainder = dividend; + + return ret; +} + #if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__) #ifndef mul_u64_u32_add_u64_shr diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c index b314d6d4dce7..bd57c54a07c3 100644 --- a/kernel/time/vsyscall.c +++ b/kernel/time/vsyscall.c @@ -54,14 +54,12 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti nsec = tk->tkr_mono.xtime_nsec; nsec += ((u64)tk->wall_to_monotonic.tv_nsec << tk->tkr_mono.shift); - while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) { - nsec -= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift); - vdso_ts->sec++; - } - vdso_ts->nsec = nsec; + vdso_ts->sec += __iter_div64_u64_rem(nsec, (u64)NSEC_PER_SEC << tk->tkr_mono.shift, + &vdso_ts->nsec); /* Copy MONOTONIC time for BOOTTIME */ sec = vdso_ts->sec; + nsec = vdso_ts->nsec; /* Add the boot offset */ sec += tk->monotonic_to_boot.tv_sec; nsec += (u64)tk->monotonic_to_boot.tv_nsec << tk->tkr_mono.shift; @@ -69,12 +67,8 @@ static inline void update_vdso_time_data(struct vdso_time_data *vdata, struct ti /* CLOCK_BOOTTIME */ vdso_ts = &vc[CS_HRES_COARSE].basetime[CLOCK_BOOTTIME]; vdso_ts->sec = sec; - - while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) { - nsec -= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift); - vdso_ts->sec++; - } - vdso_ts->nsec = nsec; + vdso_ts->sec += __iter_div64_u64_rem(nsec, (u64)NSEC_PER_SEC << tk->tkr_mono.shift, + &vdso_ts->nsec); /* CLOCK_MONOTONIC_RAW */ vdso_ts = &vc[CS_RAW].basetime[CLOCK_MONOTONIC_RAW]; From 8d17190fae2caab89cd5df19257ed9dac0739e3b Mon Sep 17 00:00:00 2001 From: Zhan Xusheng Date: Fri, 2 Oct 2026 23:31:01 +0800 Subject: [PATCH 19/19] vdso/vsyscall: Keep the CLOCK_AUX base scaled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vDSO basetime of a clock is stored in the scaled nanoseconds of tkr_mono, so that the reader can floor the base and the cycle delta together in vdso_calc_ns(). vdso_time_update_aux() instead shifts the base down to nanoseconds, adds the offset, and shifts it back up, which zeroes the fractional nanoseconds of xtime_nsec. The reader then floors the base and the delta separately: ktime_get_aux(): base + ((delta * mult + xtime_nsec) >> shift) vdso: base + (xtime_nsec >> shift) + ((delta * mult) >> shift) Since floor(a) + floor(b) <= floor(a + b), the vDSO reports 0 or 1 ns below the syscall for the same clock. It is not a monotonicity problem: across an update the step is floor(a + d) - floor(a) - floor(d), which is 0 or 1, never negative. Add the offset in scaled nanoseconds as the other high resolution clocks do, and normalise with __iter_div64_u64_rem() so that the stored base stays below one second and the userspace fast-path does not iterate more in __iter_div_u64_rem(). Only the sub-second field changes. (a + (b << shift)) >> shift is exactly (a >> shift) + b, so the seconds carried out of the normalisation are the same as before; what the old form dropped was the low shift bits of the remainder. monotonic_to_aux.tv_nsec is a normalised timespec64 fraction, so it stays below NSEC_PER_SEC even for a negative offset, and the sum stays below 2 * (NSEC_PER_SEC << shift). The largest shift clocks_calc_mult_shift() can pick is 32, which makes that 8.6e18 against a u64 limit of 1.8e19. Fixes: 380b84e168e5 ("vdso/vsyscall: Update auxiliary clock data in the datapage") Signed-off-by: Zhan Xusheng Signed-off-by: Thomas Gleixner Reviewed-by: Thomas Weißschuh Link: https://patch.msgid.link/20261002153104.1347978-4-zhanxusheng@xiaomi.com --- kernel/time/vsyscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/time/vsyscall.c b/kernel/time/vsyscall.c index bd57c54a07c3..658553fd910b 100644 --- a/kernel/time/vsyscall.c +++ b/kernel/time/vsyscall.c @@ -168,11 +168,11 @@ void vdso_time_update_aux(struct timekeeper *tk) vdso_ts->sec = tk->xtime_sec + tk->monotonic_to_aux.tv_sec; - nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; - nsec += tk->monotonic_to_aux.tv_nsec; - vdso_ts->sec += __iter_div_u64_rem(nsec, NSEC_PER_SEC, &nsec); - nsec = nsec << tk->tkr_mono.shift; - vdso_ts->nsec = nsec; + nsec = tk->tkr_mono.xtime_nsec; + nsec += (u64)tk->monotonic_to_aux.tv_nsec << tk->tkr_mono.shift; + vdso_ts->sec += __iter_div64_u64_rem(nsec, + (u64)NSEC_PER_SEC << tk->tkr_mono.shift, + &vdso_ts->nsec); } __arch_update_vdso_clock(vc);