RFC vdso: Provide a sanitized subset of UAPI types for vDSO code
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest5 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | vdso: Provide a sanitized subset of UAPI typesinclude/ | +109 | 1 reply | |
| 2/5 | x86/vdso: Drop redundant kernel header includesarch/ arch/ arch/ +2 more | +8 | 0 replies | |
| 3/5 | vdso: Switch the sanctioned headers to vdso/types.hinclude/ include/ include/ +2 more | +5 | 0 replies | |
| 4/5 | riscv: Drop redundant internal header includes from the vDSO sourcesarch/ arch/ | +0 | 0 replies | |
| 5/5 | loongarch: Drop redundant internal header includes from the vDSO sourcesarch/ arch/ | +0 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/5] 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