[RFC PATCH 2/5] x86/vdso: Drop redundant kernel header includes
From: Fang Xieyan
Date: Tue Dec 01 2026 - 06:55:57 EST
Preparation for switching the sanctioned include/vdso headers over to a
self-contained <vdso/types.h>.
The x86 vDSO sources include <linux/time.h>, <linux/kernel.h> and
<linux/types.h> even though everything they need comes from the vdso
headers they also include. Drop those redundant includes.
<linux/kernel.h> in vgetcpu.c was not purely redundant: the
<asm/segment.h> it also includes uses X86_FEATURE_RDPID in
vdso_read_cpunode() and relies on its includer to provide
<asm/cpufeatures.h>, so replace it with that header there.
Likewise drop the redundant <uapi/linux/time.h> includes from vgtod.h
and asm/vdso/gettimeofday.h: the clock IDs are already provided via
vdso/datapage.h and the includes that follow them.
One include had to be made explicit rather than dropped: on 32-bit
builds asm/div64.h provides an mul_u32_u32() implementation that must
take precedence over the generic fallback in vdso/math64.h. Previously
<linux/time.h> pulled asm/div64.h in before lib/vdso/gettimeofday.c
reaches vdso/math64.h, so the x86 implementation won. Include
<asm/div64.h> directly in vclock_gettime.c to keep that ordering
instead of relying on the kernel header chain.
No functional change intended.
Signed-off-by: Fang Xieyan <fangxy@xxxxxxxxxxxx>
---
Build-tested on x86_64 defconfig (CONFIG_IA32_EMULATION=y, with
CONFIG_X86_X32_ABI) and native i386 defconfig at this commit: bzImage
builds with 0 errors, keeping the series bisectable. On i386, the
resulting vdso32 vclock_gettime.o is size-identical to the unpatched
baseline with matching per-function sizes, and the -E -dD dump of the
translation unit shows the mul_u32_u32() macro being defined right at
the asm/div64.h implementation, confirming the x86 one is in effect.
arch/x86/entry/vdso/common/vclock_gettime.c | 10 +++++++---
arch/x86/entry/vdso/common/vgetcpu.c | 2 +-
arch/x86/entry/vdso/vdso64/vgetrandom.c | 2 --
arch/x86/include/asm/vdso/gettimeofday.h | 1 -
arch/x86/include/asm/vgtod.h | 2 --
5 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/arch/x86/entry/vdso/common/vclock_gettime.c b/arch/x86/entry/vdso/common/vclock_gettime.c
index 304dbd1f9db4..edef05f26d59 100644
--- a/arch/x86/entry/vdso/common/vclock_gettime.c
+++ b/arch/x86/entry/vdso/common/vclock_gettime.c
@@ -8,10 +8,14 @@
* 32 Bit compat layer by Stefani Seibold <stefani@xxxxxxxxxxx>
* sponsored by Rohde & Schwarz GmbH & Co. KG Munich/Germany
*/
-#include <linux/time.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
#include <vdso/gettime.h>
+/*
+ * Include asm/div64.h before the generic mul_u32_u32() fallback that
+ * vdso/math64.h provides on 32-bit builds, so the x86 implementation
+ * keeps taking effect; dropping <linux/time.h> used to lose that
+ * include ordering.
+ */
+#include <asm/div64.h>
#include "lib/vdso/gettimeofday.c"
diff --git a/arch/x86/entry/vdso/common/vgetcpu.c b/arch/x86/entry/vdso/common/vgetcpu.c
index 6381b472b7c5..6990491e0e48 100644
--- a/arch/x86/entry/vdso/common/vgetcpu.c
+++ b/arch/x86/entry/vdso/common/vgetcpu.c
@@ -5,7 +5,7 @@
* Fast user context implementation of getcpu()
*/
-#include <linux/kernel.h>
+#include <asm/cpufeatures.h>
#include <asm/segment.h>
#include <vdso/processor.h>
diff --git a/arch/x86/entry/vdso/vdso64/vgetrandom.c b/arch/x86/entry/vdso/vdso64/vgetrandom.c
index 6a95d36b12d9..b7154e1b7c60 100644
--- a/arch/x86/entry/vdso/vdso64/vgetrandom.c
+++ b/arch/x86/entry/vdso/vdso64/vgetrandom.c
@@ -2,8 +2,6 @@
/*
* Copyright (C) 2022-2024 Jason A. Donenfeld <Jason@xxxxxxxxx>. All Rights Reserved.
*/
-#include <linux/types.h>
-
#include "lib/vdso/getrandom.c"
ssize_t __vdso_getrandom(void *buffer, size_t len, unsigned int flags, void *opaque_state, size_t opaque_len)
diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h
index 3cf214cc4a75..73794aecefdc 100644
--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -12,7 +12,6 @@
#ifndef __ASSEMBLER__
-#include <uapi/linux/time.h>
#include <asm/vgtod.h>
#include <asm/unistd.h>
#include <asm/msr.h>
diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h
index a0ce291abcae..5db3e1bc8b76 100644
--- a/arch/x86/include/asm/vgtod.h
+++ b/arch/x86/include/asm/vgtod.h
@@ -12,8 +12,6 @@
#include <vdso/datapage.h>
#include <vdso/helpers.h>
-#include <uapi/linux/time.h>
-
#endif /* CONFIG_GENERIC_GETTIMEOFDAY */
#endif /* _ASM_X86_VGTOD_H */
--
2.50.1