mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fang Xieyan <fangxy@xiaopeng.com>
To: Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	x86@kernel.org
Cc: "Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"WANG Xuerui" <kernel@xen0n.name>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 0/5] vdso: Provide a sanitized subset of UAPI types for vDSO code
Date: Tue,  1 Dec 2026 19:55:18 +0800	[thread overview]
Message-ID: <20261201115523.75606-1-fangxy@xiaopeng.com> (raw)

This series prototypes the "vDSO-specific types" option discussed in the
bitsperlong thread:
https://lore.kernel.org/all/20261123170833.30158-1-fangxy@xiaopeng.com/

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

-- 
2.50.1


             reply	other threads:[~2026-12-01 11:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 11:55 Fang Xieyan [this message]
2026-12-01 11:55 ` [RFC PATCH 1/5] vdso: Provide a sanitized subset of UAPI types Fang Xieyan
2026-12-01 11:55 ` [RFC PATCH 2/5] x86/vdso: Drop redundant kernel header includes Fang Xieyan
2026-12-01 11:55 ` [RFC PATCH 3/5] vdso: Switch the sanctioned headers to vdso/types.h Fang Xieyan
2026-12-01 11:55 ` [RFC PATCH 4/5] riscv: Drop redundant internal header includes from the vDSO sources Fang Xieyan
2026-12-01 11:55 ` [RFC PATCH 5/5] loongarch: " Fang Xieyan
  -- strict thread matches above, loose matches on Subject: below --
2026-12-01 10:24 [RFC PATCH 0/5] vdso: Provide a sanitized subset of UAPI types for vDSO code Fang Xieyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201115523.75606-1-fangxy@xiaopeng.com \
    --to=fangxy@xiaopeng.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=chenhuacai@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@weissschuh.net \
    --cc=loongarch@lists.linux.dev \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=tglx@kernel.org \
    --cc=vincenzo.frascino@arm.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®