From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796126132; b=4m5qIdg7G2WVW3AE3amntI9paaoEiQ+s3JRAtmjeE6oLdDQi8UlowIJjleydB5krT9TZ 4Loowoo7KBi9gxR2iuOh9JSbn2YvTUj1SvdMtd9Ze7aOyawwZ+BgmP3awdg6lVq7cLHur gz+YyBtJwzEUBVsfAS6cVLpPdOzmJkVGUGkne1rqfKcF8FG6YTgcd/wpyqQ0tfpqzzahJ JbQllC94+1GP/0E2i243b5X+81Q0fnj9iHoJPA4NnEGZDxL7TlFKejm8qgTCCsyvVDmrJ DkK4ZbDWA+O7kHKb0IZ+xsHjoqpG7vGQI3GRm1vNXOklLs5dc5NmnQRmo7NjkHWX0TQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796126132; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=JZa718OfETH/B9Zgcj/B49GF6RBCTAG/nzdZ8fGFOQs=; b=HNwLIbX4y2QdbwGr+DrRjNPFc5XaPD8IqRbTa1Z0Sun0kjD6Lf67ZZqGFDKNyaBCH/WW EkQXXMAd+zP+9EBgbAKDEEuZbZ5FF42SGdr3eb420cQHn7U0F5vNqjLvbzCSCvzPNChJw ANUxSVqXKo94oUSxNOXkcLdsx+5UtY9zejNGbwKwhb6Savsq/55c3csvq+TPQw9KhYSK7 4lEfwOgIfxBmEa9kvE5MLlXaX6nH11TAmreWgM19v9W5gvdvAlDm7lVMGntv7Nk42+VpR 7VMEKv2tS34zJ5aaIUeOzYp8/JsJkEmiqmnnX33icjub7AEgBLmklY2Ggwn46cWzQ0Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=xiaopeng.com; spf=pass smtp.mailfrom=xiaopeng.com; dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=jTNoGfg6; arc=none smtp.remote-ip=115.124.28.124 Received: from out28-124.mail.aliyun.com (out28-124.mail.aliyun.com [115.124.28.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8835C606A320; Tue, 1 Dec 2026 11:55:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8835C606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=jTNoGfg6 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=xiaopeng.com; s=default; t=1796126128; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=JZa718OfETH/B9Zgcj/B49GF6RBCTAG/nzdZ8fGFOQs=; b=jTNoGfg6tR+bRDZqX04jeETUWy9kIOoNvZ3aEXMLcACngp8UznLdmBP7It9ye8geViOaOkfW3uhrjDYVXlpAF+852pwqqe9Y/J6n9htY39yr01Lq436cRTfhak9WRRG7VaJDDjXWTQqa2hpM/1rm+r16ZIMRizLt5bXH9p21Pv4= X-Alimail-AntiSpam:AC=CONTINUE;BC=0.04437435|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0128017-0.000717129-0.986481;FP=17857667371572416402|9|3|19|0|-1|-1|-1;HT=maildocker-contentspam033045139068;MF=fangxy@xiaopeng.com;NM=1;PH=DS;RN=19;RT=19;SR=0;TI=SMTPD_---.kEK1Ti8_1796126125; Received: from localhost.localdomain(mailfrom:fangxy@xiaopeng.com fp:SMTPD_---.kEK1Ti8_1796126125 cluster:ay29) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 19:55:27 +0800 From: Fang Xieyan To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , x86@kernel.org Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , Arnd Bergmann , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/5] vdso: Provide a sanitized subset of UAPI types Date: Tue, 1 Dec 2026 19:55:19 +0800 Message-ID: <20261201115523.75606-2-fangxy@xiaopeng.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261201115523.75606-1-fangxy@xiaopeng.com> References: <20261201115523.75606-1-fangxy@xiaopeng.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The sanctioned include/vdso headers pull in 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. Signed-off-by: Fang Xieyan --- 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 (, , ) 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. + * + * 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 */ -- 2.50.1