mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Fang Xieyan <fangxy@xiaopeng.com>
Cc: Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	 Vincenzo Frascino <vincenzo.frascino@arm.com>,
	x86@kernel.org, Ingo Molnar <mingo@redhat.com>,
	 Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	 Arnd Bergmann <arnd@arndb.de>,
	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: Re: [RFC PATCH 1/5] vdso: Provide a sanitized subset of UAPI types
Date: Tue, 1 Dec 2026 12:28:27 +0100	[thread overview]
Message-ID: <19a9e94d-0ff4-4461-b3e9-e5b40ef03ceb@message-id.t-8ch.de> (raw)
In-Reply-To: <20261201102410.44071-2-fangxy@xiaopeng.com>

On 2026-12-01 18:24:06+0800, Fang Xieyan wrote:
(...)

> ---
> 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
> 
> diff --git a/include/vdso/types.h b/include/vdso/types.h
> new file mode 100644
> index 000000000000..9afaaf22688e
> --- /dev/null
> +++ b/include/vdso/types.h
> @@ -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.

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.

> + *
> + * 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 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.

> +
> +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.

> + * __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').

What is the longterm plan here?


(...)

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

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 10:24 [RFC PATCH 0/5] vdso: Provide a sanitized subset of UAPI types for vDSO code Fang Xieyan
2026-12-01 10:24 ` [RFC PATCH 1/5] vdso: Provide a sanitized subset of UAPI types Fang Xieyan
2026-12-01 11:28   ` Thomas Weißschuh [this message]
2026-12-01 10:24 ` [RFC PATCH 2/5] x86/vdso: Drop redundant kernel header includes Fang Xieyan
2026-12-01 10:24 ` [RFC PATCH 3/5] vdso: Switch the sanctioned headers to vdso/types.h Fang Xieyan
2026-12-01 10:24 ` [RFC PATCH 4/5] riscv: Drop redundant internal header includes from the vDSO sources Fang Xieyan
2026-12-01 10:24 ` [RFC PATCH 5/5] loongarch: " Fang Xieyan
2026-12-01 11:55 [RFC PATCH 0/5] vdso: Provide a sanitized subset of UAPI types for vDSO code Fang Xieyan
2026-12-01 11:55 ` [RFC PATCH 1/5] vdso: Provide a sanitized subset of UAPI types 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=19a9e94d-0ff4-4461-b3e9-e5b40ef03ceb@message-id.t-8ch.de \
    --to=linux@weissschuh.net \
    --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=fangxy@xiaopeng.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --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®