vdso: Provide a sanitized subset of UAPI types for vDSO code
Subsystems (8)
cover vdso: Provide a sanitized subset of UAPI types for vDSO code
This series prototypes the "vDSO-specific types" option discussed in the bitsperlong thread:
https://lore.kernel.org/all/[email protected]/
Today the sanctioned include/vdso headers take their types from <linux/types.h> or the UAPI time/types headers. In kernel builds those resolve to the kernel-internal include/linux and include/asm-generic variants, so vDSO code ends up depending on kernel-internal headers such as include/asm-generic/bitsperlong.h, even though vDSO code is supposed to use only include/vdso/ headers.
Patch 1 adds a self-contained include/vdso/types.h providing the small subset of types the vDSO shares (basic integer types and their plain aliases, bool, size_t, the legacy time typedefs, clock IDs), mirroring the UAPI and kernel type headers without including them. Architecture- specific overrides keep the UAPI convention: __kernel_long_t carries the macro guard that lets an architecture install its own definition ahead of the generic one, as x86 does for x32 in the UAPI, though no vDSO build needs an override today. __kernel_old_time_t simply follows it. __kernel_suseconds_t is deliberately not defined here, as no vDSO code refers to the typedef directly; it remains available through the existing UAPI time structures, untouched for architectures like sparc64 that define it as 'int'. Patch 2 drops redundant kernel header includes from the x86 vDSO sources as preparation, making the asm/div64.h include explicit so the x86 mul_u32_u32() implementation keeps taking effect on 32-bit builds. Patch 3 switches the five sanctioned headers (datapage.h, gettime.h, getrandom.h, time.h, auxclock.h) over to it. Patches 4 and 5 then drop the now-redundant direct includes of internal headers from the riscv and loongarch vDSO sources, taking those
architectures to the include-free shape arm64 already has; they are a first sample of the follow-up cleanup and can be dropped or extended to the remaining archs if the design is reworked.
What this series does NOT do, on purpose:
- It does not mirror the time structs (struct __kernel_timespec, struct __kernel_old_timeval, struct timezone) yet: the vDSO build still reaches the UAPI time headers through unrelated kernel-header paths (e.g. asm/msr.h -> linux/percpu.h -> linux/time64.h on x86), so mirroring them here would conflict. Breaking those remaining chains is follow-up work.
- It only cleans up riscv and loongarch sources in patches 4/5; the direct includes in the arm, mips and powerpc vDSO sources, riscv's hwprobe.c (still needs <linux/string.h>), and the leaks in lib/vdso/gettimeofday.c are left as similar follow-ups.
- It does not touch the areas of the in-flight absolute-reloc series (relocation checking) or the math64 series (BITS_PER_* macros and CLOCK_AUX precision): no file in this series overlaps with them.
Verification:
- x86_64 defconfig (CONFIG_IA32_EMULATION=y, CONFIG_X86_X32_ABI=y):
bzImage builds cleanly with 0 errors at each commit of the series (bisectable); vdso32.so.dbg, vdso64.so.dbg and vdsox32.so.dbg are produced at the tip.
- arm64 defconfig cross-build (aarch64-linux-gnu-gcc): Image builds cleanly with 0 errors with the full series applied, vdso.so.dbg is produced (arm64 compat vdso32 is not built by defconfig and thus not covered here).
- Additional archs with the full series applied: arm (gcc), riscv64, loongarch64 and s390x (clang) all build cleanly and produce their vDSO shared objects. On mips64 and powerpc64 (clang) the vDSO objects (vdso.so / vdso64.so.dbg) also build cleanly; the full-tree failures there (clang integrated-assembler limitations on arch/mips GAS macros, and the bootwrapper needing a powerpc cross-gcc) reproduce identically on the unpatched baseline.
- Native i386 defconfig: bzImage builds cleanly with the full series; the resulting vdso32 vclock_gettime.o is size-identical to the unpatched baseline, with matching per-function sizes and an -E -dD dump showing mul_u32_u32() defined by the asm/div64.h implementation, so the x86 one is still in effect on 32-bit builds.
- sparc64 has no usable toolchain here, so its type visibility was checked with a clang -fsyntax-only probe mirroring the include sequence of arch/sparc/vdso/vclock_gettime.c (<linux/compiler.h>, <linux/types.h>, <vdso/types.h>); it compiles cleanly, while hardcoding __kernel_suseconds_t as long fails the same probe with the expected 'long' vs 'int' typedef conflict.
- With patches 4 and 5 applied, fresh riscv64 and loongarch64 defconfig builds (clang) remain clean with 0 errors and still produce their vdso.so(.dbg).
- No arch-specific adaptation patches were needed on any of the architectures tested.
- checkpatch --strict: 0 errors on all five patches.
- Base: v7.4-rc5 (fe6ff8d5d675). The per-commit build results were collected on v7.4-rc4; none of the fifteen files touched by this series changed between the two tags, and the x86 vDSO rebuilds byte-identically on this base.
The design question from the thread above (vDSO-specific types vs a sanitized subset generated from the UAPI headers) is still open, so this is posted as RFC; happy to rework if the preferred direction is different.
Fang Xieyan (5):
vdso: Provide a sanitized subset of UAPI types
x86/vdso: Drop redundant kernel header includes
vdso: Switch the sanctioned headers to vdso/types.h
riscv: Drop redundant internal header includes from the vDSO sources
loongarch: Drop redundant internal header includes from the vDSO
sources
arch/loongarch/vdso/vgetrandom.c | 1 - arch/loongarch/vdso/vgettimeofday.c | 1 - arch/riscv/kernel/vdso/getrandom.c | 1 - arch/riscv/kernel/vdso/vgettimeofday.c | 2 - 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 - include/vdso/auxclock.h | 3 +- include/vdso/datapage.h | 3 +- include/vdso/getrandom.h | 2 +- include/vdso/gettime.h | 2 +- include/vdso/time.h | 2 +- include/vdso/types.h | 109 ++++++++++++++++++++ 15 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 include/vdso/types.h
Signature · 1 line
2.50.1
RFC PATCH 1/5 vdso: Provide a sanitized subset of UAPI types
The sanctioned include/vdso headers pull in <linux/types.h> and the UAPI time headers. When building the kernel, those headers resolve to the kernel-internal include/linux and include/asm-generic variants, so vDSO code ends up depending on kernel-internal headers such as include/asm-generic/bitsperlong.h, even though vDSO code is supposed to use only the include/vdso/ headers.
Add include/vdso/types.h providing a self-contained sanitized subset of the types that vDSO code shares: the basic integer types with their plain u8..u64 aliases and bool (mirroring asm-generic/int-ll64.h and linux/types.h), size_t/ssize_t (from the compiler, so they always match the target C ABI), the legacy time types (mirroring asm-generic/posix_types.h) and the clock IDs (mirroring uapi/linux/time.h). The header includes nothing itself, so consumers get the types without pulling in any kernel-internal header.
Architecture overridable types follow the UAPI convention instead of being hardcoded: __kernel_long_t carries the UAPI macro sentinel, so an architecture that defines it before including this header keeps precedence, the way x86 does for x32 in the UAPI; no vDSO build needs that today. __kernel_old_time_t follows __kernel_long_t, mirroring the generic UAPI, which provides no separate override for it. __kernel_suseconds_t is not mirrored at all: no vDSO code refers to the type name (sparc64 overrides it with 'int' in its UAPI), it only appears inside struct __kernel_old_timeval.
The time structs (struct __kernel_timespec, struct __kernel_old_timeval and struct timezone) are intentionally not mirrored yet: the vDSO build still reaches the UAPI time headers through other kernel headers (e.g. asm/msr.h -> linux/percpu.h -> linux/time64.h), so defining them here would conflict. They continue to come from the UAPI headers until those remaining dependencies are isolated in follow-up work.
The new header has no users yet and there is no functional change.
---
The new header has no users yet, so this patch alone cannot affect any build; the x86_64 and arm64 builds in this series verify the consumers. A clang -fsyntax-only sparc64 probe that mirrors the include sequence of arch/sparc/vdso/vclock_gettime.c (<linux/compiler.h>, <linux/types.h>, <vdso/types.h>) compiles cleanly; hardcoding __kernel_suseconds_t as long instead fails there with the expected 'long' vs 'int' typedef conflict, which is why the type is not mirrored.
The __kernel_long_t guard is inert in the current tree: no vDSO build installs an override (the x86 x32 vDSO objects are objcopy'd from the -m64 ones, and no vDSO .cmd file in the x86 or i386 object trees uses -mx32, while under __KERNEL__ the x86 uapi posix_types layer is not visible), so it only preserves the UAPI convention for a future override.
checkpatch --strict reports 0 errors (the new-typedef and _Bool CamelCase warnings are inherent false positives for a types header).
include/vdso/types.h | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 include/vdso/types.h
include/vdso/types.h new file +109 -0
@@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _VDSO_TYPES_H +#define _VDSO_TYPES_H + +#ifndef __ASSEMBLER__ + +/* +* Sanitized subset of the UAPI types for vDSO code. +* +* The definitions below mirror the UAPI integer and time types +* (asm-generic/int-ll64.h, asm-generic/posix_types.h and the clock IDs +* from linux/time.h) plus the plain u8..u64 aliases and bool from the +* kernel-internal type headers, but they are provided here without +* including any of those headers: when building the kernel, those +* headers resolve to the kernel-internal include/linux and +* include/asm-generic variants, which vDSO code must not depend on. +* +* The time structs (struct __kernel_timespec, struct __kernel_old_timeval +* and struct timezone) are not mirrored here: the vDSO build still pulls +* in the UAPI time headers through other kernel headers, so defining them +* here would conflict. They continue to come from the UAPI headers until +* those remaining dependencies are isolated. +* +* Keep this header self-contained and in sync with the UAPI ABI. +*/ + +typedef __signed__ char __s8; +typedef unsigned char __u8 ; + +typedef __signed__ short __s16 ; +typedef unsigned short __u16 ; + +typedef __signed__ int __s32; +typedef unsigned int __u32 ; + +typedef __signed__ long long __s64 ; +typedef unsigned long long __u64 ; + +typedef __s8 s8 ; +typedef __u8 u8 ; +typedef __s16 s16 ; +typedef __u16 u16 ; +typedef __s32 s32 ; +typedef __u32 u32 ; +typedef __s64 s64 ; +typedef __u64 u64 ; + +typedef _Bool bool ; + +/* +* size_t and ssize_t come from the compiler rather than mirroring +* __kernel_size_t/__kernel_ssize_t, so they always match the target +* C ABI, including 32-bit vDSO variants built inside 64-bit kernels. +*/ +typedef __SIZE_TYPE__ size_t ; +typedef __PTRDIFF_TYPE__ ssize_t ; + +typedef int __kernel_clockid_t ; +typedef __kernel_clockid_t clockid_t ; + +typedef long long __kernel_time64_t ; + +/* +* Mirror the generic UAPI definitions, which derive from +* __kernel_long_t. That type is architecture overridable in the UAPI, +* where a macro sentinel guards it so that an architecture can define +* the type ahead of the generic one, as x86 does for x32. The same +* guard is kept here, although no vDSO build overrides the type today. +* __kernel_old_time_t simply follows __kernel_long_t; the UAPI has no +* separate override for it. __kernel_suseconds_t is deliberately not +* mirrored: no vDSO code refers to the type name, it only appears +* inside struct __kernel_old_timeval, which still comes from the UAPI +* headers (sparc64 overrides it with 'int'). +*/ +#ifndef __kernel_long_t +typedef long __kernel_long_t ; +#endif + +typedef __kernel_long_t __kernel_old_time_t ; + +/* +* Clock IDs, mirroring include/uapi/linux/time.h. +*/ +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 +#define CLOCK_PROCESS_CPUTIME_ID 2 +#define CLOCK_THREAD_CPUTIME_ID 3 +#define CLOCK_MONOTONIC_RAW 4 +#define CLOCK_REALTIME_COARSE 5 +#define CLOCK_MONOTONIC_COARSE 6 +#define CLOCK_BOOTTIME 7 +#define CLOCK_REALTIME_ALARM 8 +#define CLOCK_BOOTTIME_ALARM 9 +/* +* The driver implementing this got removed. The clock ID is kept as a +* place holder. Do not reuse! +*/ +#define CLOCK_SGI_CYCLE 10 +#define CLOCK_TAI 11 + +#define MAX_CLOCKS 16 + +#define CLOCK_AUX MAX_CLOCKS +#define MAX_AUX_CLOCKS 8 +#define CLOCK_AUX_LAST (CLOCK_AUX + MAX_AUX_CLOCKS - 1) + +#endif /* __ASSEMBLER__ */ + +#endif /* _VDSO_TYPES_H */
Signature · 1 line
2.50.1
Re: [RFC PATCH 1/5] vdso: Provide a sanitized subset of UAPI types
On 2026-12-01 18:24:06+0800, Fang Xieyan wrote:
(...)
Quoted 33 lines
---
The new header has no users yet, so this patch alone cannot affect any build; thex86_64and arm64 builds in this series verify the consumers. A clang -fsyntax-only sparc64 probe that mirrors the include sequence ofarch/sparc/vdso/vclock_gettime.c(<linux/compiler.h>, <linux/types.h>, <vdso/types.h>) compiles cleanly; hardcoding__kernel_suseconds_tas long instead fails there with the expected 'long' vs 'int' typedef conflict, which is why the type is not mirrored.
The__kernel_long_tguard is inert in the current tree: no vDSO build installs an override (the x86 x32 vDSO objects are objcopy'd from the(quoted diff) +0
-2-m64 ones, and no vDSO .cmd file in the x86 or i386 object trees uses -mx32, while under __KERNEL__ the x86 uapi posix_types layer is notvisible), so it only preserves the UAPI convention for a future override.
checkpatch --strict reports 0 errors (the new-typedef and_BoolCamelCase warnings are inherent false positives for a types header).include/vdso/types.h | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 include/vdso/types.hinclude/vdso/types.h new file +6
-0@@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _VDSO_TYPES_H +#define _VDSO_TYPES_H + +#ifndef __ASSEMBLER__ +
include/vdso/types.h line 16
Quoted 10 lines
include/vdso/types.h new file +10
-0+/* +* Sanitized subset of the UAPI types for vDSO code. +* +* The definitions below mirror the UAPI integer and time types +* (asm-generic/int-ll64.h, asm-generic/posix_types.h and the clock IDs +* from linux/time.h) plus the plain u8..u64 aliases and bool from the +* kernel-internal type headers, but they are provided here without +* including any of those headers: when building the kernel, those +* headers resolve to the kernel-internal include/linux and +* include/asm-generic variants, which vDSO code must not depend on.
I am really not a fan of all the duplication.
It would be much nicer if we can avoid pulling in the non-UAPI headers when building the vDSO. (And have a compile-time check enforcing this) Also this current version still defers some important questions to the future without any hints on how they would be resolved.
Maybe you could start by chipping away on the header dependency chains pulling in kernel headers from the vDSO builds. These will need to go away in any case. And when they are gone the problem will have become simpler and easier to discuss.
The same goes for the usage of UAPI types over kernel types:size_t -> __kernel_size_t, clockid_t -> __kernel_clockid_t, etc.
Quoted 9 lines
include/vdso/types.h new file +9
-0+* +* The time structs (struct __kernel_timespec, struct __kernel_old_timeval +* and struct timezone) are not mirrored here: the vDSO build still pulls +* in the UAPI time headers through other kernel headers, so defining them +* here would conflict. They continue to come from the UAPI headers until +* those remaining dependencies are isolated. +* +* Keep this header self-contained and in sync with the UAPI ABI. +*/
(...)
include/vdso/types.h line 59
Quoted 2 lines
include/vdso/types.h new file +2
-0+typedef int __kernel_clockid_t ; +typedef __kernel_clockid_t clockid_t ;
While we are at it, the vDSO should just use __kernel_clockid_t instead of clockid_t.
include/vdso/types.h line 68
Quoted 9 lines
include/vdso/types.h new file +9
-0+ +typedef long long __kernel_time64_t ; + +/* +* Mirror the generic UAPI definitions, which derive from +* __kernel_long_t. That type is architecture overridable in the UAPI, +* where a macro sentinel guards it so that an architecture can define +* the type ahead of the generic one, as x86 does for x32. The same +* guard is kept here, although no vDSO build overrides the type today.
So this type is broken on x32 now? I am aware that we don't really build the x32 anyways and x32 is on its way out. But this is a very brittle pattern.
Quoted 5 lines
+ *
__kernel_old_time_tsimply follows__kernel_long_t; the UAPI has no
+ * separate override for it.__kernel_suseconds_tis deliberately not
+ * mirrored: no vDSO code refers to the type name, it only appears
+ * inside struct__kernel_old_timeval, which still comes from the UAPI
+ * headers (sparc64 overrides it with 'int').
What is the longterm plan here?
(...)
RFC PATCH 2/5 x86/vdso: Drop redundant kernel header includes
In reply to Fang XieyanPreparation 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.
---
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(-)
arch/x86/entry/vdso/common/vclock_gettime.c +7 -3
@@ -8,10 +8,14 @@* 32 Bit compat layer by Stefani Seibold <[email protected]> * 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"
arch/x86/entry/vdso/common/vgetcpu.c +1 -1
@@ -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>
arch/x86/entry/vdso/vdso64/vgetrandom.c +0 -2
@@ -2,8 +2,6 @@/* * Copyright (C) 2022-2024 Jason A. Donenfeld <[email protected]>. 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)
arch/x86/include/asm/vdso/gettimeofday.h +0 -1
@@ -12,7 +12,6 @@#ifndef __ASSEMBLER__ -#include <uapi/linux/time.h> #include <asm/vgtod.h> #include <asm/unistd.h> #include <asm/msr.h>
arch/x86/include/asm/vgtod.h +0 -2
@@ -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 */
Signature · 1 line
2.50.1
RFC PATCH 3/5 vdso: Switch the sanctioned headers to vdso/types.h
In reply to Fang XieyanNow that <vdso/types.h> provides the sanitized UAPI type subset and the x86 side no longer carries redundant includes that would clash, convert the sanctioned include/vdso headers to take their types from it:
datapage.h: <linux/types.h> -> <vdso/types.h>, drop <uapi/linux/time.h> gettime.h: <linux/types.h> -> <vdso/types.h> getrandom.h: <linux/types.h> -> <vdso/types.h>
time.h: <uapi/linux/types.h> -> <vdso/types.h>
auxclock.h: <uapi/linux/time.h>, <uapi/linux/types.h> -> <vdso/types.h>
This removes the direct dependency of the sanctioned headers on kernel-internal and UAPI type headers, so vDSO code compiled against them no longer reaches include/asm-generic/bitsperlong.h through the type headers.
Note the vDSO build still reaches <linux/types.h> indirectly through unrelated kernel-header paths (e.g. asm/msr.h -> linux/percpu.h -> linux/time64.h on x86); breaking those remaining chains is left for follow-up work.
---
Build-tested at this commit: x86_64 defconfig (CONFIG_IA32_EMULATION=y, CONFIG_X86_X32_ABI=y) builds bzImage with 0 errors producing vdso32.so.dbg, vdso64.so.dbg and vdsox32.so.dbg, and the arm64 defconfig cross-build (aarch64-linux-gnu-gcc) builds Image with 0 errors producing vdso.so/vdso.so.dbg. arm, riscv, loongarch and s390 also build cleanly with the full series; the mips and powerpc vDSO objects build cleanly too (their full-tree failures reproduce identically on the unpatched baseline with the same clang toolchain limitations).
A compiler -H trace confirms include/vdso/types.h is self-contained and that the sanctioned headers no longer include <linux/types.h> or the UAPI time headers directly. The remaining linux/types.h / asm-generic/ bitsperlong.h inclusions reach the vDSO build through unrelated kernel-header paths (e.g. asm/msr.h -> linux/percpu.h -> linux/time64.h) and are left for follow-up work, as noted above.
Series based on v7.4-rc5 (fe6ff8d5d675). The per-commit build results above were collected on v7.4-rc4; none of the fifteen files this series touches changed between the two tags, and rebuilding the x86 vDSO on this base yields byte-identical vdso64, vdsox32 and vdso32 objects.
include/vdso/auxclock.h | 3 +-- include/vdso/datapage.h | 3 +-- include/vdso/getrandom.h | 2 +- include/vdso/gettime.h | 2 +- include/vdso/time.h | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-)
include/vdso/auxclock.h +1 -2
@@ -2,8 +2,7 @@#ifndef _VDSO_AUXCLOCK_H#define _VDSO_AUXCLOCK_H -#include <uapi/linux/time.h> -#include <uapi/linux/types.h> +#include <vdso/types.h> static __always_inline u64 aux_clock_resolution_ns(void) {
include/vdso/datapage.h +1 -2
@@ -4,10 +4,9 @@#ifndef __ASSEMBLER__ -#include <linux/types.h> +#include <vdso/types.h> #include <uapi/linux/bits.h> -#include <uapi/linux/time.h> #include <vdso/align.h> #include <vdso/bits.h>
include/vdso/getrandom.h +1 -1
@@ -6,7 +6,7 @@#ifndef _VDSO_GETRANDOM_H#define _VDSO_GETRANDOM_H -#include <linux/types.h> +#include <vdso/types.h> #define CHACHA_KEY_SIZE 32#define CHACHA_BLOCK_SIZE 64
include/vdso/gettime.h +1 -1
@@ -2,7 +2,7 @@#ifndef _VDSO_GETTIME_H#define _VDSO_GETTIME_H -#include <linux/types.h> +#include <vdso/types.h> struct __kernel_timespec ;struct __kernel_old_timeval ;
include/vdso/time.h +1 -1
@@ -2,7 +2,7 @@ #ifndef __VDSO_TIME_H #define __VDSO_TIME_H -#include <uapi/linux/types.h> +#include <vdso/types.h> struct timens_offset { s64 sec;
Signature · 1 line
2.50.1
RFC PATCH 4/5 riscv: Drop redundant internal header includes from the vDSO sources
In reply to Fang XieyanWith the sanctioned headers providing all types through <vdso/types.h>, the direct includes of internal headers in the riscv vDSO sources are dead weight: they are the only thing keeping the <linux/types.h> -> <asm/...> -> bitsperlong chain alive inside these vDSO translation units.
The vDSO Makefile already force-includes the sanctioned headers (c-gettimeofday-y / c-getrandom-y), so the same code shape as the include-free arm64 vDSO sources can be used here. <linux/time.h> in vgettimeofday.c is redundant for the same reason: struct __kernel_timespec and friends reach the file through the same chain.
hwprobe.c is left untouched: it still needs <linux/string.h> from the internal chain, a separate cleanup.
---
Build-tested at the series tip (this patch and patch 5 both applied):
riscv64 defconfig cross-build (clang --target=riscv64-linux-gnu) completes with 0 errors and still produces arch/riscv/kernel/vdso/vdso.so(.dbg); the riscv sources are identical between this commit and the tested tip.
arch/riscv/kernel/vdso/getrandom.c | 1 - arch/riscv/kernel/vdso/vgettimeofday.c | 2 -- 2 files changed, 3 deletions(-)
arch/riscv/kernel/vdso/getrandom.c +0 -1
@@ -2,7 +2,6 @@/* * Copyright (C) 2025 Xi Ruoyao <[email protected]>. All Rights Reserved. */ -#include <linux/types.h> ssize_t __vdso_getrandom (void *buffer,size_t len,unsigned int flags,void *opaque_state,size_t opaque_len) {
arch/riscv/kernel/vdso/vgettimeofday.c +0 -2
@@ -6,8 +6,6 @@* Copyright (C) 2020 SiFive */ -#include <linux/time.h> -#include <linux/types.h> #include <vdso/gettime.h> int __vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts)
Signature · 1 line
2.50.1
RFC PATCH 5/5 loongarch: Drop redundant internal header includes from the vDSO sources
In reply to Fang XieyanPatch 3 made the sanctioned headers self-contained via <vdso/types.h>, so the direct <linux/types.h> includes in the loongarch vDSO sources are dead weight: they are the only thing keeping the internal <linux/types.h> -> <asm/...> -> bitsperlong chain alive inside these vDSO translation units.
The vDSO Makefile already force-includes the sanctioned headers (c-gettimeofday-y / c-getrandom-y), so dropping the includes brings loongarch to the same shape as arm64, whose vDSO sources contain no direct type includes at all.
---
Build-tested at this commit (= series tip): loongarch64 defconfig cross-build (clang --target=loongarch64-linux-gnu) completes with 0 errors and still produces arch/loongarch/vdso/vdso.so(.dbg); the riscv build was verified green in the same tree state.
arch/loongarch/vdso/vgetrandom.c | 1 - arch/loongarch/vdso/vgettimeofday.c | 1 - 2 files changed, 2 deletions(-)
arch/loongarch/vdso/vgetrandom.c +0 -1
@@ -2,7 +2,6 @@/* * Copyright (C) 2024 Xi Ruoyao <[email protected]>. All Rights Reserved. */ -#include <linux/types.h> ssize_t __vdso_getrandom (void *buffer,size_t len,unsigned int flags,void *opaque_state,size_t opaque_len) {
arch/loongarch/vdso/vgettimeofday.c +0 -1
@@ -4,7 +4,6 @@* * Copyright (C) 2020-2022 Loongson Technology Corporation Limited */ -#include <linux/types.h> #include <vdso/gettime.h> int __vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts)
Signature · 1 line
2.50.1