From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F1423FA5CB for ; Mon, 17 Aug 2026 11:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965853; cv=none; b=ZkvU7EwP4RiWTG11gH47AZBv9oAEeGmrDQQMxeZXXHHD12Fkx27t/RIwgMBlkYHc9dK8PjQeuwIBe+XkJ+GZSJ/4eDcCrcKT99tbK29LJihJwPKL0iCqhaI5IRakpRAZuR1budGVQnpN17tojJbAPBcfZ4YBXqioKqU71G4c5iw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786965853; c=relaxed/simple; bh=zo5enyJCi4agLAnYOg26XOROr538ObQHqBEmJS0tKQQ=; h=Date:From:To:Cc:Subject:References:Message-ID:Content-Type: MIME-Version; b=SxTH5ip9yxReXAmJ8MiiyTTTtpLG5Rfp2WKCHjPz9lJQDAzmoTuEFa8VHVz4ahRViRcghjtcUYYyFQNT3+PeBeQ/eYqsV8I2edq5/Mlmqm/HEqxh0RraPdhiNpAk3Pqw6zvxDaP18PNAmJHmhQjOhJBX1NOtgGl7giVciBW/8sI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NDnO2tJO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NDnO2tJO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAE221F00A3A; Mon, 17 Aug 2026 11:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786965849; bh=H64RKVNEKzTnf4Q7o2uFn5RJSlaHa5UD9/wTb5bz0Lw=; h=Date:From:To:Cc:Subject:References; b=NDnO2tJOQQUVhJpZ5PpN16A57yMW54vwUNKYNgSgIvfTttBvv3U188C0sIRuXHzW6 L2twfkiiMYq0OluEIYNEOIh9M/yW6N/sEyJZNXF4xbNFd53jaKjMovJ5N90BYAOrbV GYWqxdLidCqxR0GzOV4BGPuJnJGjGt7McxO2ZqntF3sEzib68c2j8mI06unMTO+NRS VSHdSzhtOmfhFhhG0p6he8VE6115uai2WyzGoOu1cdBjvHDryerrUjPtN4jTEaZ87S VHaS7K3MDlRxgLf6LvJcL0TpLPlEt5N+XY1c9OIoTgRhqUBdYkA//dzh8VFzqafYjZ z6vstLOcwa2Ww== Date: Mon, 17 Aug 2026 13:24:06 +0200 From: Thomas Gleixner To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, x86@kernel.org Subject: [GIT pull] timers/vdso for v7.3-rc1 References: <178696575118.1270771.17154447195623102039.tglx@fw13> Message-ID: <178696576216.1270771.4428610074202853103.tglx@fw13> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Linus, please pull the latest timers/vdso branch from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-vdso-2026= -08-17 up to: 92e785d887a8: random: vDSO: Drop custom PAGE_SIZE definitions VDSO updates: - Consolidate the VDSO datastore further and provide support for mlock_all() and prefaulting. - Provide 32-bit legacy time related functionality only if CONFIG_COMPAT_32BIT_TIME is enabled. The config switch exists, but architecture code still exposes the legacy functionality even disabled. Clean this up by adding the missing guards and validating at build time that the VDSO is legacy free if disabled. - Consolidate the VDSO related config options in core and drivers, which removes some non-sensical dependencies and quite an amount of #ifdeffery. - Clean up the PAGE_SIZE definition maze Thanks, tglx ------------------> Thomas Huth (1): vdso: Replace __ASSEMBLY__ with __ASSEMBLER__ in header files Thomas Wei=C3=9Fschuh (29): vdso/datastore: Rename data pages variable vdso/datastore: Map pages in terms of the faults pgoff vdso/datastore: Map zeroed pages for unavailable data vdso/datastore: Explicitly prevent remote access to timens vvar page vdso/datastore: Allow prefaulting by mlockall() vdso/datastore: Simplify the mapping logic for VDSO_TIME_PAGE_OFFSET time: Respect COMPAT_32BIT_TIME for old time type functions vdso/gettimeofday: Validate system call existence for time() and gettim= eofday() x86/vdso: Respect COMPAT_32BIT_TIME arm64: vdso32: Respect COMPAT_32BIT_TIME ARM: VDSO: Respect COMPAT_32BIT_TIME powerpc/vdso: Respect COMPAT_32BIT_TIME MIPS: VDSO: Respect COMPAT_32BIT_TIME sparc: vdso: Respect COMPAT_32BIT_TIME vdso/gettimeofday: Verify COMPAT_32BIT_TIME interactions futex: Remove dependency on HAVE_GENERIC_VDSO from FUTEX_ROBUST_UNLOCK vdso: Remove the dependency on HAVE_GENERIC_VDSO from ARCH_HAS_VDSO_ARC= H_DATA MIPS: vdso: Stop using CONFIG_HAVE_GENERIC_VDSO vdso: Automatically select HAVE_GENERIC_VDSO if necessary vdso: Drop HAVE_GENERIC_VDSO from architecture kconfig files vdso: Rename HAVE_GENERIC_VDSO to VDSO_DATASTORE kbuild: Support generated asm-headers in subdirectories vDSO: Make clockmode constants available without CONFIG_GENERIC_GETTIME= OFDAY MIPS: csrc-r4k: Remove CONFIG_GENERIC_GETTIMEOFDAY ifdeffery clocksource/drivers/mips-gic-timer: Remove CONFIG_GENERIC_GETTIMEOFDAY = ifdeffery clocksource/drivers/arm_arch_timer: Remove CONFIG_GENERIC_GETTIMEOFDAY = ifdeffery clocksource/drivers/timer-riscv: Remove CONFIG_GENERIC_GETTIMEOFDAY ifd= effery LoongArch: Remove CONFIG_GENERIC_GETTIMEOFDAY ifdeffery random: vDSO: Drop custom PAGE_SIZE definitions arch/Kconfig | 1 - arch/arm/mm/Kconfig | 1 - arch/arm/vdso/vdso.lds.S | 2 + arch/arm/vdso/vgettimeofday.c | 14 ++++--- arch/arm64/Kconfig | 1 - arch/arm64/kernel/vdso32/vdso.lds.S | 2 + arch/arm64/kernel/vdso32/vgettimeofday.c | 14 ++++--- arch/loongarch/Kconfig | 2 +- arch/loongarch/kernel/time.c | 2 - arch/mips/Kconfig | 1 - arch/mips/kernel/csrc-r4k.c | 2 - arch/mips/kernel/vdso.c | 4 +- arch/mips/vdso/vdso.lds.S | 2 + arch/mips/vdso/vgettimeofday.c | 3 ++ arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/vdso/gettimeofday.S | 8 ++++ arch/powerpc/kernel/vdso/vdso32.lds.S | 8 ++-- arch/powerpc/kernel/vdso/vgettimeofday.c | 16 ++++--- arch/riscv/Kconfig | 8 ++-- arch/s390/Kconfig | 1 - arch/sparc/Kconfig | 1 - arch/sparc/vdso/vclock_gettime.c | 4 ++ arch/sparc/vdso/vdso32/vdso32.lds.S | 6 ++- arch/x86/Kconfig | 1 - arch/x86/entry/vdso/common/vclock_gettime.c | 20 +++++---- arch/x86/entry/vdso/vdso32/vdso32.lds.S | 2 + drivers/clocksource/arm_arch_timer.c | 4 -- drivers/clocksource/mips-gic-timer.c | 2 - drivers/clocksource/timer-riscv.c | 4 -- include/asm-generic/Kbuild | 1 + include/asm-generic/vdso/clocksource.h | 0 include/asm-generic/vdso/vsyscall.h | 4 +- include/linux/vdso_datastore.h | 6 +-- include/vdso/clocksource.h | 4 +- include/vdso/datapage.h | 6 +-- include/vdso/helpers.h | 4 +- include/vdso/processor.h | 4 +- include/vdso/vsyscall.h | 4 +- init/Kconfig | 2 +- kernel/sys_ni.c | 4 ++ kernel/time/namespace_vdso.c | 7 +--- kernel/time/time.c | 24 +++++++++-- lib/vdso/Kconfig | 8 ++-- lib/vdso/Makefile | 2 +- lib/vdso/datastore.c | 65 +++++++++++++--------------= -- lib/vdso/getrandom.c | 6 +-- lib/vdso/gettimeofday.c | 20 +++++++++ scripts/Makefile.asm-headers | 11 +++-- 48 files changed, 181 insertions(+), 139 deletions(-) create mode 100644 include/asm-generic/vdso/clocksource.h diff --git a/arch/Kconfig b/arch/Kconfig index fa7507ac8e13..8a8d1ab39757 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1682,7 +1682,6 @@ config HAVE_SPARSE_SYSCALL_NR related optimizations for a given architecture. =20 config ARCH_HAS_VDSO_ARCH_DATA - depends on HAVE_GENERIC_VDSO bool =20 config ARCH_HAS_VDSO_TIME_DATA diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 871bd58d2ccc..f7bea397a201 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig @@ -924,7 +924,6 @@ config VDSO bool "Enable VDSO for acceleration of some system calls" depends on AEABI && MMU && CPU_V7 default y if ARM_ARCH_TIMER - select HAVE_GENERIC_VDSO select GENERIC_GETTIMEOFDAY help Place in the process address space an ELF shared object diff --git a/arch/arm/vdso/vdso.lds.S b/arch/arm/vdso/vdso.lds.S index 74d8d8bc8a40..e61038c0195a 100644 --- a/arch/arm/vdso/vdso.lds.S +++ b/arch/arm/vdso/vdso.lds.S @@ -70,9 +70,11 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#endif /* CONFIG_COMPAT_32BIT_TIME */ __vdso_clock_gettime64; __vdso_clock_getres_time64; local: *; diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index f7a2f5dc2fdc..3eebeddbfd18 100644 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -10,16 +10,17 @@ #include #include =20 +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); } =20 -int __vdso_clock_gettime64(clockid_t clock, - struct __kernel_timespec *ts) +int __vdso_clock_getres(clockid_t clock_id, + struct old_timespec32 *res) { - return __cvdso_clock_gettime(clock, ts); + return __cvdso_clock_getres_time32(clock_id, res); } =20 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, @@ -27,11 +28,12 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, { return __cvdso_gettimeofday(tv, tz); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ =20 -int __vdso_clock_getres(clockid_t clock_id, - struct old_timespec32 *res) +int __vdso_clock_gettime64(clockid_t clock, + struct __kernel_timespec *ts) { - return __cvdso_clock_getres_time32(clock_id, res); + return __cvdso_clock_gettime(clock, ts); } =20 int __vdso_clock_getres_time64(clockid_t clock_id, struct __kernel_timespec = *res) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b3afe0688919..11e733b6a3cf 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -229,7 +229,6 @@ config ARM64 select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES select HAVE_KRETPROBES - select HAVE_GENERIC_VDSO select HOTPLUG_CORE_SYNC_DEAD if HOTPLUG_CPU select HOTPLUG_SMT if HOTPLUG_CPU select IRQ_DOMAIN diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/v= dso.lds.S index c374fb0146f3..12bfc39e8aab 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -82,9 +82,11 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#endif /* CONFIG_COMPAT_32BIT_TIME */ __vdso_clock_gettime64; __vdso_clock_getres_time64; local: *; diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vds= o32/vgettimeofday.c index 0c6998ebe491..12d0255cc2cf 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -8,16 +8,17 @@ #define BUILD_VDSO32_64 #include =20 +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); } =20 -int __vdso_clock_gettime64(clockid_t clock, - struct __kernel_timespec *ts) +int __vdso_clock_getres(clockid_t clock_id, + struct old_timespec32 *res) { - return __cvdso_clock_gettime(clock, ts); + return __cvdso_clock_getres_time32(clock_id, res); } =20 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, @@ -25,11 +26,12 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, { return __cvdso_gettimeofday(tv, tz); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ =20 -int __vdso_clock_getres(clockid_t clock_id, - struct old_timespec32 *res) +int __vdso_clock_gettime64(clockid_t clock, + struct __kernel_timespec *ts) { - return __cvdso_clock_getres_time32(clock_id, res); + return __cvdso_clock_gettime(clock, ts); } =20 int __vdso_clock_getres_time64(clockid_t clock_id, struct __kernel_timespec = *res) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index d8d252325017..41ed648fcec9 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -153,7 +153,6 @@ config LOONGARCH select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IOREMAP_PROT select HAVE_IRQ_EXIT_ON_IRQ_STACK @@ -213,6 +212,7 @@ config LOONGARCH select TRACE_IRQFLAGS_SUPPORT select USE_PERCPU_NUMA_NODE_ID select USER_STACKTRACE_SUPPORT + select VDSO_DATASTORE select VDSO_GETRANDOM select ZONE_DMA32 if 64BIT =20 diff --git a/arch/loongarch/kernel/time.c b/arch/loongarch/kernel/time.c index dbaaabcaf6f0..5892f6da07a5 100644 --- a/arch/loongarch/kernel/time.c +++ b/arch/loongarch/kernel/time.c @@ -212,9 +212,7 @@ static struct clocksource clocksource_const =3D { .read =3D read_const_counter, .mask =3D CLOCKSOURCE_MASK(64), .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, -#ifdef CONFIG_GENERIC_GETTIMEOFDAY .vdso_clock_mode =3D VDSO_CLOCKMODE_CPU, -#endif }; =20 int __init constant_clocksource_init(void) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8555bbf47c63..a06f24317306 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -3163,7 +3163,6 @@ config MIPS_EXTERNAL_TIMER config MIPS_GENERIC_GETTIMEOFDAY def_bool y select GENERIC_GETTIMEOFDAY - select HAVE_GENERIC_VDSO depends on CSRC_R4K || CLKSRC_MIPS_GIC # GCC (at least up to version 9.2) appears to emit function calls that make= use # of the GOT when targeting microMIPS, which we can't use in the VDSO due to diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c index 241a934543a8..59eca397f297 100644 --- a/arch/mips/kernel/csrc-r4k.c +++ b/arch/mips/kernel/csrc-r4k.c @@ -126,14 +126,12 @@ int __init init_r4k_clocksource(void) clocksource_mips.rating =3D 200; clocksource_mips.rating +=3D clamp(mips_hpt_frequency / 10000000, 0, 99); =20 -#ifdef CONFIG_GENERIC_GETTIMEOFDAY /* * R2 onwards makes the count accessible to user mode so it can be used * by the VDSO (HWREna is configured by configure_hwrena()). */ if (cpu_has_mips_r2_r6 && rdhwr_count_usable()) clocksource_mips.vdso_clock_mode =3D VDSO_CLOCKMODE_R4K; -#endif =20 clocksource_register_hz(&clocksource_mips, mips_hpt_frequency); =20 diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index bd1fc17d3975..29a10045f2b6 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c @@ -129,7 +129,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm= , int uses_interp) * This ensures that when the kernel updates the VDSO data userland * will observe it without requiring cache invalidations. */ - if (cpu_has_dc_aliases && IS_ENABLED(CONFIG_HAVE_GENERIC_VDSO)) { + if (cpu_has_dc_aliases && IS_ENABLED(CONFIG_MIPS_GENERIC_GETTIMEOFDAY)) { base =3D __ALIGN_MASK(base, shm_align_mask); base +=3D ((unsigned long)vdso_k_time_data - gic_size) & shm_align_mask; } @@ -137,7 +137,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm= , int uses_interp) data_addr =3D base + gic_size; vdso_addr =3D data_addr + VDSO_NR_PAGES * PAGE_SIZE; =20 - if (IS_ENABLED(CONFIG_HAVE_GENERIC_VDSO)) { + if (IS_ENABLED(CONFIG_MIPS_GENERIC_GETTIMEOFDAY)) { vma =3D vdso_install_vvar_mapping(mm, data_addr); if (IS_ERR(vma)) { ret =3D PTR_ERR(vma); diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S index 278ab6444e98..b11ee493c67f 100644 --- a/arch/mips/vdso/vdso.lds.S +++ b/arch/mips/vdso/vdso.lds.S @@ -97,9 +97,11 @@ VERSION LINUX_2.6 { #ifdef CONFIG_GENERIC_GETTIMEOFDAY global: +#if _MIPS_SIM =3D=3D _MIPS_SIM_ABI64 || defined(CONFIG_COMPAT_32BIT_TIME) __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#endif #if _MIPS_SIM !=3D _MIPS_SIM_ABI64 __vdso_clock_gettime64; __vdso_clock_getres_time64; diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c index 00f9fcfc327e..a1fb06b8973e 100644 --- a/arch/mips/vdso/vgettimeofday.c +++ b/arch/mips/vdso/vgettimeofday.c @@ -12,6 +12,8 @@ #include =20 #if _MIPS_SIM !=3D _MIPS_SIM_ABI64 + +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { @@ -29,6 +31,7 @@ int __vdso_clock_getres(clockid_t clock_id, { return __cvdso_clock_getres_time32(clock_id, res); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ =20 int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index f7ce5fff81f0..c6bc2cd6cc83 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -256,7 +256,6 @@ config PPC select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER if !COMPILE_TEST && (PPC64 || (PPC32 && CC_IS_= GCC)) select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO select HAVE_HARDLOCKUP_DETECTOR_ARCH if PPC_BOOK3S_64 && SMP select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) @@ -328,6 +327,7 @@ config PPC select SYSCTL_EXCEPTION_TRACE select THREAD_INFO_IN_TASK select TRACE_IRQFLAGS_SUPPORT + select VDSO_DATASTORE select VDSO_GETRANDOM # # Please keep this list sorted alphabetically. diff --git a/arch/powerpc/kernel/vdso/gettimeofday.S b/arch/powerpc/kernel/vd= so/gettimeofday.S index 1c8e51691bf8..c635cd1e77be 100644 --- a/arch/powerpc/kernel/vdso/gettimeofday.S +++ b/arch/powerpc/kernel/vdso/gettimeofday.S @@ -67,9 +67,11 @@ * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_gettimeofday) cvdso_call __c_kernel_gettimeofday V_FUNCTION_END(__kernel_gettimeofday) +#endif =20 /* * Exact prototype of clock_gettime() @@ -77,9 +79,11 @@ V_FUNCTION_END(__kernel_gettimeofday) * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_clock_gettime) cvdso_call __c_kernel_clock_gettime V_FUNCTION_END(__kernel_clock_gettime) +#endif =20 /* * Exact prototype of clock_gettime64() @@ -99,9 +103,11 @@ V_FUNCTION_END(__kernel_clock_gettime64) * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_clock_getres) cvdso_call __c_kernel_clock_getres V_FUNCTION_END(__kernel_clock_getres) +#endif =20 /* * Exact prototype of clock_getres_time64() @@ -122,6 +128,8 @@ V_FUNCTION_END(__kernel_clock_getres_time64) * time_t time(time *t); * */ +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) V_FUNCTION_BEGIN(__kernel_time) cvdso_call __c_kernel_time call_time=3D1 V_FUNCTION_END(__kernel_time) +#endif diff --git a/arch/powerpc/kernel/vdso/vdso32.lds.S b/arch/powerpc/kernel/vdso= /vdso32.lds.S index 3f384a2526ae..5e87c18fd282 100644 --- a/arch/powerpc/kernel/vdso/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso/vdso32.lds.S @@ -119,13 +119,15 @@ VERSION { VDSO_VERSION_STRING { global: - __kernel_get_syscall_map; +#ifdef CONFIG_COMPAT_32BIT_TIME __kernel_gettimeofday; __kernel_clock_gettime; - __kernel_clock_gettime64; __kernel_clock_getres; - __kernel_clock_getres_time64; __kernel_time; +#endif /* CONFIG_COMPAT_32BIT_TIME */ + __kernel_get_syscall_map; + __kernel_clock_gettime64; + __kernel_clock_getres_time64; __kernel_get_tbfreq; __kernel_sync_dicache; __kernel_sigtramp32; diff --git a/arch/powerpc/kernel/vdso/vgettimeofday.c b/arch/powerpc/kernel/v= dso/vgettimeofday.c index 3c194e1ab562..4b712fb01a3f 100644 --- a/arch/powerpc/kernel/vdso/vgettimeofday.c +++ b/arch/powerpc/kernel/vdso/vgettimeofday.c @@ -18,23 +18,25 @@ int __c_kernel_clock_getres(clockid_t clock_id, struct __= kernel_timespec *res, return __cvdso_clock_getres_data(vd, clock_id, res); } #else +#ifdef CONFIG_COMPAT_32BIT_TIME int __c_kernel_clock_gettime(clockid_t clock, struct old_timespec32 *ts, const struct vdso_time_data *vd) { return __cvdso_clock_gettime32_data(vd, clock, ts); } =20 -int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts, - const struct vdso_time_data *vd) -{ - return __cvdso_clock_gettime_data(vd, clock, ts); -} - int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res, const struct vdso_time_data *vd) { return __cvdso_clock_getres_time32_data(vd, clock_id, res); } +#endif /* CONFIG_COMPAT_32BIT_TIME */ + +int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts, + const struct vdso_time_data *vd) +{ + return __cvdso_clock_gettime_data(vd, clock, ts); +} =20 int __c_kernel_clock_getres_time64(clockid_t clock_id, struct __kernel_times= pec *res, const struct vdso_time_data *vd) @@ -43,6 +45,7 @@ int __c_kernel_clock_getres_time64(clockid_t clock_id, stru= ct __kernel_timespec } #endif =20 +#if defined(__powerpc64__) || defined(CONFIG_COMPAT_32BIT_TIME) int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone= *tz, const struct vdso_time_data *vd) { @@ -53,3 +56,4 @@ __kernel_old_time_t __c_kernel_time(__kernel_old_time_t *ti= me, const struct vdso { return __cvdso_time_data(vd, time); } +#endif diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 3f0a647218e4..019fb4799943 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -54,7 +54,7 @@ config RISCV select ARCH_HAS_SYSCALL_WRAPPER select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UBSAN - select ARCH_HAS_VDSO_ARCH_DATA if HAVE_GENERIC_VDSO + select ARCH_HAS_VDSO_ARCH_DATA select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_KEEP_MEMBLOCK if ACPI || KEXEC select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU @@ -110,7 +110,7 @@ config RISCV select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY - select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO && 64BIT + select GENERIC_GETTIMEOFDAY if MMU && 64BIT select GENERIC_IDLE_POLL_SETUP select GENERIC_IOREMAP if MMU select HAVE_IOREMAP_PROT if MMU @@ -171,7 +171,6 @@ config RISCV select HAVE_FUNCTION_ARG_ACCESS_API select HAVE_FUNCTION_ERROR_INJECTION select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO if MMU select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KERNEL_BZIP2 if !EFI_ZBOOT select HAVE_KERNEL_GZIP if !EFI_ZBOOT @@ -227,7 +226,8 @@ config RISCV select THREAD_INFO_IN_TASK select TRACE_IRQFLAGS_SUPPORT select UACCESS_MEMCPY if !MMU - select VDSO_GETRANDOM if HAVE_GENERIC_VDSO && 64BIT + select VDSO_DATASTORE if MMU + select VDSO_GETRANDOM if MMU && 64BIT select USER_STACKTRACE_SUPPORT select ZONE_DMA32 if 64BIT =20 diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 84404e6778d5..c9c55e3ddf1d 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -215,7 +215,6 @@ config S390 select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS - select HAVE_GENERIC_VDSO select HAVE_IOREMAP_PROT if PCI select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_GZIP diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 0e9c906c4b5d..4dd79311133f 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -113,7 +113,6 @@ config SPARC64 select ARCH_SUPPORTS_SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_MC if SMP select ARCH_HAS_LAZY_MMU_MODE - select HAVE_GENERIC_VDSO select GENERIC_GETTIMEOFDAY =20 config ARCH_PROC_KCORE_TEXT diff --git a/arch/sparc/vdso/vclock_gettime.c b/arch/sparc/vdso/vclock_gettim= e.c index 1d9859392e4c..221bd4ed19f5 100644 --- a/arch/sparc/vdso/vclock_gettime.c +++ b/arch/sparc/vdso/vclock_gettime.c @@ -21,6 +21,7 @@ =20 #include "../../../../lib/vdso/gettimeofday.c" =20 +#if defined(CONFIG_SPARC64) || defined(CONFIG_COMPAT_32BIT_TIME) int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); @@ -28,6 +29,7 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv, st= ruct timezone *tz) =20 int gettimeofday(struct __kernel_old_timeval *, struct timezone *) __weak __alias(__vdso_gettimeofday); +#endif =20 #if defined(CONFIG_SPARC64) int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) @@ -40,6 +42,7 @@ int clock_gettime(clockid_t, struct __kernel_timespec *) =20 #else =20 +#if defined(CONFIG_COMPAT_32BIT_TIME) int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); @@ -47,6 +50,7 @@ int __vdso_clock_gettime(clockid_t clock, struct old_timesp= ec32 *ts) =20 int clock_gettime(clockid_t, struct old_timespec32 *) __weak __alias(__vdso_clock_gettime); +#endif =20 int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) { diff --git a/arch/sparc/vdso/vdso32/vdso32.lds.S b/arch/sparc/vdso/vdso32/vds= o32.lds.S index a14e4f77e6f2..28052168b875 100644 --- a/arch/sparc/vdso/vdso32/vdso32.lds.S +++ b/arch/sparc/vdso/vdso32/vdso32.lds.S @@ -15,12 +15,14 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME clock_gettime; __vdso_clock_gettime; - clock_gettime64; - __vdso_clock_gettime64; gettimeofday; __vdso_gettimeofday; +#endif + clock_gettime64; + __vdso_clock_gettime64; local: *; }; } diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index bdad90f210e4..2f4a78024a96 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -302,7 +302,6 @@ config X86 select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_UNWIND_USER_FP if X86_64 select HAVE_USER_RETURN_NOTIFIER - select HAVE_GENERIC_VDSO select VDSO_GETRANDOM if X86_64 select HOTPLUG_PARALLEL if SMP && X86_64 select HOTPLUG_SMT if SMP diff --git a/arch/x86/entry/vdso/common/vclock_gettime.c b/arch/x86/entry/vds= o/common/vclock_gettime.c index 57066f346b3f..304dbd1f9db4 100644 --- a/arch/x86/entry/vdso/common/vclock_gettime.c +++ b/arch/x86/entry/vdso/common/vclock_gettime.c @@ -15,6 +15,7 @@ =20 #include "lib/vdso/gettimeofday.c" =20 +#if defined(__x86_64__) || defined(CONFIG_COMPAT_32BIT_TIME) int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); @@ -29,6 +30,7 @@ __kernel_old_time_t __vdso_time(__kernel_old_time_t *t) } =20 __kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias(= "__vdso_time"))); +#endif /* CONFIG_COMPAT_32BIT_TIME */ =20 =20 #if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64) @@ -51,6 +53,7 @@ int clock_getres(clockid_t, struct __kernel_timespec *) =20 #else /* i386 only */ +#ifdef CONFIG_COMPAT_32BIT_TIME int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { return __cvdso_clock_gettime32(clock, ts); @@ -59,14 +62,6 @@ int __vdso_clock_gettime(clockid_t clock, struct old_times= pec32 *ts) int clock_gettime(clockid_t, struct old_timespec32 *) __attribute__((weak, alias("__vdso_clock_gettime"))); =20 -int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) -{ - return __cvdso_clock_gettime(clock, ts); -} - -int clock_gettime64(clockid_t, struct __kernel_timespec *) - __attribute__((weak, alias("__vdso_clock_gettime64"))); - int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res) { return __cvdso_clock_getres_time32(clock, res); @@ -74,6 +69,15 @@ int __vdso_clock_getres(clockid_t clock, struct old_timesp= ec32 *res) =20 int clock_getres(clockid_t, struct old_timespec32 *) __attribute__((weak, alias("__vdso_clock_getres"))); +#endif /* CONFIG_COMPAT_32BIT_TIME */ + +int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) +{ + return __cvdso_clock_gettime(clock, ts); +} + +int clock_gettime64(clockid_t, struct __kernel_timespec *) + __attribute__((weak, alias("__vdso_clock_gettime64"))); =20 int __vdso_clock_getres_time64(clockid_t clock, struct __kernel_timespec *ts) { diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vd= so32/vdso32.lds.S index cee8f7f9fe80..00629192db56 100644 --- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S +++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S @@ -23,10 +23,12 @@ VERSION { LINUX_2.6 { global: +#ifdef CONFIG_COMPAT_32BIT_TIME __vdso_clock_gettime; __vdso_gettimeofday; __vdso_time; __vdso_clock_getres; +#endif /* CONFIG_COMPAT_32BIT_TIME */ __vdso_clock_gettime64; __vdso_clock_getres_time64; __vdso_getcpu; diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_a= rch_timer.c index 4adf756423de..a5157d8a8a13 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -56,11 +56,7 @@ static struct clock_event_device __percpu *arch_timer_evt; static enum arch_timer_ppi_nr arch_timer_uses_ppi __ro_after_init =3D ARCH_T= IMER_VIRT_PPI; static bool arch_timer_c3stop __ro_after_init; static bool arch_counter_suspend_stop __ro_after_init; -#ifdef CONFIG_GENERIC_GETTIMEOFDAY static enum vdso_clock_mode vdso_default =3D VDSO_CLOCKMODE_ARCHTIMER; -#else -static enum vdso_clock_mode vdso_default =3D VDSO_CLOCKMODE_NONE; -#endif /* CONFIG_GENERIC_GETTIMEOFDAY */ =20 static cpumask_t evtstrm_available =3D CPU_MASK_NONE; static bool evtstrm_enable __ro_after_init =3D IS_ENABLED(CONFIG_ARM_ARCH_TI= MER_EVTSTREAM); diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-= gic-timer.c index a1669266c94d..1501c7db9a8e 100644 --- a/drivers/clocksource/mips-gic-timer.c +++ b/drivers/clocksource/mips-gic-timer.c @@ -198,9 +198,7 @@ static struct clocksource gic_clocksource =3D { .name =3D "GIC", .read =3D gic_hpt_read, .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, -#ifdef CONFIG_GENERIC_GETTIMEOFDAY .vdso_clock_mode =3D VDSO_CLOCKMODE_GIC, -#endif }; =20 static void gic_clocksource_unstable(char *reason) diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-ri= scv.c index cfc4d83c42c0..b310e6721fac 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -98,11 +98,7 @@ static struct clocksource riscv_clocksource =3D { .mask =3D CLOCKSOURCE_MASK(64), .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, .read =3D riscv_clocksource_rdtime, -#if IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY) .vdso_clock_mode =3D VDSO_CLOCKMODE_ARCHTIMER, -#else - .vdso_clock_mode =3D VDSO_CLOCKMODE_NONE, -#endif }; =20 static int riscv_timer_starting_cpu(unsigned int cpu) diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index 15df9dcb42a5..2bc00c67dc54 100644 --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild @@ -62,6 +62,7 @@ mandatory-y +=3D topology.h mandatory-y +=3D trace_clock.h mandatory-y +=3D uaccess.h mandatory-y +=3D unwind_user.h +mandatory-y +=3D vdso/clocksource.h mandatory-y +=3D vermagic.h mandatory-y +=3D vga.h mandatory-y +=3D video.h diff --git a/include/asm-generic/vdso/clocksource.h b/include/asm-generic/vds= o/clocksource.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/include/asm-generic/vdso/vsyscall.h b/include/asm-generic/vdso/v= syscall.h index 5c6d9799f4e7..a6b03cfba0e2 100644 --- a/include/asm-generic/vdso/vsyscall.h +++ b/include/asm-generic/vdso/vsyscall.h @@ -2,7 +2,7 @@ #ifndef __ASM_GENERIC_VSYSCALL_H #define __ASM_GENERIC_VSYSCALL_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #ifndef __arch_get_vdso_u_time_data static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_d= ata(void) @@ -30,6 +30,6 @@ static __always_inline void __arch_sync_vdso_time_data(stru= ct vdso_time_data *vd } #endif /* __arch_sync_vdso_time_data */ =20 -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ =20 #endif /* __ASM_GENERIC_VSYSCALL_H */ diff --git a/include/linux/vdso_datastore.h b/include/linux/vdso_datastore.h index 3dfba9502d78..13b01baf3497 100644 --- a/include/linux/vdso_datastore.h +++ b/include/linux/vdso_datastore.h @@ -7,10 +7,10 @@ extern const struct vm_special_mapping vdso_vvar_mapping; struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, unsig= ned long addr); =20 -#ifdef CONFIG_HAVE_GENERIC_VDSO +#ifdef CONFIG_VDSO_DATASTORE void __init vdso_setup_data_pages(void); -#else /* !CONFIG_HAVE_GENERIC_VDSO */ +#else /* !CONFIG_VDSO_DATASTORE */ static inline void vdso_setup_data_pages(void) { } -#endif /* CONFIG_HAVE_GENERIC_VDSO */ +#endif /* CONFIG_VDSO_DATASTORE */ =20 #endif /* _LINUX_VDSO_DATASTORE_H */ diff --git a/include/vdso/clocksource.h b/include/vdso/clocksource.h index c682e7c60273..bce81c02a7c6 100644 --- a/include/vdso/clocksource.h +++ b/include/vdso/clocksource.h @@ -4,13 +4,11 @@ =20 #include =20 -#ifdef CONFIG_GENERIC_GETTIMEOFDAY #include -#endif /* CONFIG_GENERIC_GETTIMEOFDAY */ =20 enum vdso_clock_mode { VDSO_CLOCKMODE_NONE, -#ifdef CONFIG_GENERIC_GETTIMEOFDAY +#ifdef VDSO_ARCH_CLOCKMODES VDSO_ARCH_CLOCKMODES, #endif VDSO_CLOCKMODE_MAX, diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index 5977723fb3b5..09897f76ae07 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -2,7 +2,7 @@ #ifndef __VDSO_DATAPAGE_H #define __VDSO_DATAPAGE_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include =20 @@ -176,7 +176,7 @@ enum vdso_pages { VDSO_NR_PAGES }; =20 -#else /* !__ASSEMBLY__ */ +#else /* !__ASSEMBLER__ */ =20 #ifdef CONFIG_VDSO_GETRANDOM #define __vdso_u_rng_data PROVIDE(vdso_u_rng_data =3D vdso_u_data + 2 * PAGE= _SIZE); @@ -197,6 +197,6 @@ enum vdso_pages { __vdso_u_arch_data \ =20 =20 -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ =20 #endif /* __VDSO_DATAPAGE_H */ diff --git a/include/vdso/helpers.h b/include/vdso/helpers.h index a3bf4f1c0d37..65151b681c4f 100644 --- a/include/vdso/helpers.h +++ b/include/vdso/helpers.h @@ -2,7 +2,7 @@ #ifndef __VDSO_HELPERS_H #define __VDSO_HELPERS_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include #include @@ -111,6 +111,6 @@ static __always_inline void vdso_write_end(struct vdso_ti= me_data *vd) vdso_write_seq_end(&vc[CS_RAW]); } =20 -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ =20 #endif /* __VDSO_HELPERS_H */ diff --git a/include/vdso/processor.h b/include/vdso/processor.h index fbe8265ea3c4..cc781912a696 100644 --- a/include/vdso/processor.h +++ b/include/vdso/processor.h @@ -5,10 +5,10 @@ #ifndef __VDSO_PROCESSOR_H #define __VDSO_PROCESSOR_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include =20 -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ =20 #endif /* __VDSO_PROCESSOR_H */ diff --git a/include/vdso/vsyscall.h b/include/vdso/vsyscall.h index b0fdc9c6bf43..c5c2a2c07857 100644 --- a/include/vdso/vsyscall.h +++ b/include/vdso/vsyscall.h @@ -2,13 +2,13 @@ #ifndef __VDSO_VSYSCALL_H #define __VDSO_VSYSCALL_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include =20 unsigned long vdso_update_begin(void); void vdso_update_end(unsigned long flags); =20 -#endif /* !__ASSEMBLY__ */ +#endif /* !__ASSEMBLER__ */ =20 #endif /* __VDSO_VSYSCALL_H */ diff --git a/init/Kconfig b/init/Kconfig index 5230d4879b1c..53178ea4bc93 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1857,7 +1857,7 @@ config HAVE_FUTEX_ROBUST_UNLOCK bool =20 config FUTEX_ROBUST_UNLOCK - def_bool FUTEX && HAVE_GENERIC_VDSO && GENERIC_IRQ_ENTRY && RSEQ && HAVE_FU= TEX_ROBUST_UNLOCK + def_bool FUTEX && GENERIC_IRQ_ENTRY && RSEQ && HAVE_FUTEX_ROBUST_UNLOCK =20 config EPOLL bool "Enable eventpoll support" if EXPERT diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index add3032da16f..c8be0abaa407 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -351,6 +351,10 @@ COND_SYSCALL(ppoll_time32); COND_SYSCALL_COMPAT(ppoll_time32); COND_SYSCALL(utimensat_time32); COND_SYSCALL(clock_adjtime32); +COND_SYSCALL(gettimeofday); +COND_SYSCALL_COMPAT(gettimeofday); +COND_SYSCALL(time); +COND_SYSCALL(stime); =20 /* * The syscalls below are not found in include/uapi/asm-generic/unistd.h diff --git a/kernel/time/namespace_vdso.c b/kernel/time/namespace_vdso.c index 0d74d160eec9..5ac7b6a6d3a8 100644 --- a/kernel/time/namespace_vdso.c +++ b/kernel/time/namespace_vdso.c @@ -74,11 +74,8 @@ struct page *find_timens_vvar_page(struct vm_area_struct *= vma) return current->nsproxy->time_ns->vvar_page; =20 /* - * VM_PFNMAP | VM_IO protect .fault() handler from being called - * through interfaces like /proc/$pid/mem or - * process_vm_{readv,writev}() as long as there's no .access() - * in special_mapping_vmops(). - * For more details check_vma_flags() and __access_remote_vm() + * vvar_fault() protects this from being called through remote interfaces l= ike + * /proc/$pid/mem or process_vm_{readv,writev}(). */ =20 WARN(1, "vvar_page accessed remotely"); diff --git a/kernel/time/time.c b/kernel/time/time.c index 0dd63a91e7c5..f836a31751f4 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -43,6 +43,12 @@ #include #include "timekeeping.h" =20 +#if defined(CONFIG_64BIT) || defined(CONFIG_COMPAT_32BIT_TIME) +#define __WANT_OLD_TIME_TYPE_SYSCALL 1 +#endif + +static_assert(sizeof(__kernel_old_time_t) =3D=3D 8 ? IS_ENABLED(__WANT_OLD_T= IME_TYPE_SYSCALL) : true); + /* * The timezone where the local system is located. Used as a default by some * programs who obtain this value by using gettimeofday. @@ -51,7 +57,7 @@ struct timezone sys_tz; =20 EXPORT_SYMBOL(sys_tz); =20 -#ifdef __ARCH_WANT_SYS_TIME +#if defined(__ARCH_WANT_SYS_TIME) && defined(__WANT_OLD_TIME_TYPE_SYSCALL) =20 /* * sys_time() can be implemented in user-level using @@ -96,7 +102,7 @@ SYSCALL_DEFINE1(stime, __kernel_old_time_t __user *, tptr) return 0; } =20 -#endif /* __ARCH_WANT_SYS_TIME */ +#endif /* __ARCH_WANT_SYS_TIME && __WANT_OLD_TIME_TYPE_SYSCALL */ =20 #ifdef CONFIG_COMPAT_32BIT_TIME #ifdef __ARCH_WANT_SYS_TIME32 @@ -137,6 +143,7 @@ SYSCALL_DEFINE1(stime32, old_time32_t __user *, tptr) #endif /* __ARCH_WANT_SYS_TIME32 */ #endif =20 +#ifdef __WANT_OLD_TIME_TYPE_SYSCALL SYSCALL_DEFINE2(gettimeofday, struct __kernel_old_timeval __user *, tv, struct timezone __user *, tz) { @@ -154,6 +161,7 @@ SYSCALL_DEFINE2(gettimeofday, struct __kernel_old_timeval= __user *, tv, } return 0; } +#endif /* __WANT_OLD_TIME_TYPE_SYSCALL */ =20 /* * In case for some reason the CMOS clock has not already been running @@ -203,6 +211,9 @@ SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval= __user *, tv, struct timezone new_tz; =20 if (tv) { + if (!IS_ENABLED(__WANT_OLD_TIME_TYPE_SYSCALL)) + return -EINVAL; + if (get_user(new_ts.tv_sec, &tv->tv_sec) || get_user(new_ts.tv_nsec, &tv->tv_usec)) return -EFAULT; @@ -220,7 +231,7 @@ SYSCALL_DEFINE2(settimeofday, struct __kernel_old_timeval= __user *, tv, return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); } =20 -#ifdef CONFIG_COMPAT +#ifdef CONFIG_COMPAT_32BIT_TIME COMPAT_SYSCALL_DEFINE2(gettimeofday, struct old_timeval32 __user *, tv, struct timezone __user *, tz) { @@ -239,7 +250,9 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct old_timeval32= __user *, tv, =20 return 0; } +#endif /* CONFIG_COMPAT_32BIT_TIME */ =20 +#ifdef CONFIG_COMPAT COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv, struct timezone __user *, tz) { @@ -247,6 +260,9 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32= __user *, tv, struct timezone new_tz; =20 if (tv) { + if (!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)) + return -EINVAL; + if (get_user(new_ts.tv_sec, &tv->tv_sec) || get_user(new_ts.tv_nsec, &tv->tv_usec)) return -EFAULT; @@ -263,7 +279,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32= __user *, tv, =20 return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); } -#endif +#endif /* CONFIG_COMPAT */ =20 #ifdef CONFIG_64BIT SYSCALL_DEFINE1(adjtimex, struct __kernel_timex __user *, txc_p) diff --git a/lib/vdso/Kconfig b/lib/vdso/Kconfig index db87ba34ef19..597f5f0f9681 100644 --- a/lib/vdso/Kconfig +++ b/lib/vdso/Kconfig @@ -1,12 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 =20 -config HAVE_GENERIC_VDSO +config VDSO_DATASTORE bool =20 -if HAVE_GENERIC_VDSO - config GENERIC_GETTIMEOFDAY bool + select VDSO_DATASTORE help This is a generic implementation of gettimeofday vdso. Each architecture that enables this feature has to @@ -21,7 +20,6 @@ config GENERIC_VDSO_OVERFLOW_PROTECT =20 config VDSO_GETRANDOM bool + select VDSO_DATASTORE help Selected by architectures that support vDSO getrandom(). - -endif diff --git a/lib/vdso/Makefile b/lib/vdso/Makefile index 405f743253d7..ac304def42d6 100644 --- a/lib/vdso/Makefile +++ b/lib/vdso/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only =20 -obj-$(CONFIG_HAVE_GENERIC_VDSO) +=3D datastore.o +obj-$(CONFIG_VDSO_DATASTORE) +=3D datastore.o diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 17d37b82ebc6..1426bf4e0c12 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -29,10 +29,11 @@ struct vdso_arch_data *vdso_k_arch_data __ro_after_init = =3D (void *)&vdso_initdata[VDSO_ARCH_PAGES_START * PAGE_SIZE]; #endif /* CONFIG_ARCH_HAS_VDSO_ARCH_DATA */ =20 +static struct page *vdso_data_pages __ro_after_init; + void __init vdso_setup_data_pages(void) { unsigned int order =3D get_order(VDSO_NR_PAGES * PAGE_SIZE); - struct page *pages; =20 /* * Allocate the data pages dynamically. SPARC does not support mapping @@ -42,24 +43,24 @@ void __init vdso_setup_data_pages(void) * Do not use folios. In time namespaces the pages are mapped in a differen= t order * to userspace, which is not handled by the folio optimizations in finish_= fault(). */ - pages =3D alloc_pages(GFP_KERNEL, order); - if (!pages) + vdso_data_pages =3D alloc_pages(GFP_KERNEL, order); + if (!vdso_data_pages) panic("Unable to allocate VDSO storage pages"); =20 /* The pages are mapped one-by-one into userspace and each one needs to be = refcounted. */ - split_page(pages, order); + split_page(vdso_data_pages, order); =20 /* Move the data already written by other subsystems to the new pages */ - memcpy(page_address(pages), vdso_initdata, VDSO_NR_PAGES * PAGE_SIZE); + memcpy(page_address(vdso_data_pages), vdso_initdata, VDSO_NR_PAGES * PAGE_S= IZE); =20 if (IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) - vdso_k_time_data =3D page_address(pages + VDSO_TIME_PAGE_OFFSET); + vdso_k_time_data =3D page_address(vdso_data_pages + VDSO_TIME_PAGE_OFFSET); =20 if (IS_ENABLED(CONFIG_VDSO_GETRANDOM)) - vdso_k_rng_data =3D page_address(pages + VDSO_RNG_PAGE_OFFSET); + vdso_k_rng_data =3D page_address(vdso_data_pages + VDSO_RNG_PAGE_OFFSET); =20 if (IS_ENABLED(CONFIG_ARCH_HAS_VDSO_ARCH_DATA)) - vdso_k_arch_data =3D page_address(pages + VDSO_ARCH_PAGES_START); + vdso_k_arch_data =3D page_address(vdso_data_pages + VDSO_ARCH_PAGES_START); } =20 static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, @@ -67,27 +68,28 @@ static vm_fault_t vvar_fault(const struct vm_special_mapp= ing *sm, { struct page *page, *timens_page; =20 + if (unlikely(vmf->flags & FAULT_FLAG_REMOTE)) + return VM_FAULT_SIGBUS; + + page =3D vdso_data_pages + vmf->pgoff; timens_page =3D find_timens_vvar_page(vma); =20 switch (vmf->pgoff) { case VDSO_TIME_PAGE_OFFSET: - if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) - return VM_FAULT_SIGBUS; - page =3D virt_to_page(vdso_k_time_data); - if (timens_page) { - /* - * Fault in VVAR page too, since it will be accessed - * to get clock data anyway. - */ - unsigned long addr; - vm_fault_t err; - - addr =3D vmf->address + VDSO_TIMENS_PAGE_OFFSET * PAGE_SIZE; - err =3D vmf_insert_page(vma, addr, page); - if (unlikely(err & VM_FAULT_ERROR)) - return err; - page =3D timens_page; - } + if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY) || !timens_page) + break; + /* + * Fault in VVAR page too, since it will be accessed + * to get clock data anyway. + */ + unsigned long addr; + vm_fault_t err; + + addr =3D vmf->address + VDSO_TIMENS_PAGE_OFFSET * PAGE_SIZE; + err =3D vmf_insert_page(vma, addr, page); + if (unlikely(err & VM_FAULT_ERROR)) + return err; + page =3D timens_page; break; case VDSO_TIMENS_PAGE_OFFSET: /* @@ -98,18 +100,11 @@ static vm_fault_t vvar_fault(const struct vm_special_map= ping *sm, * See also the comment near timens_setup_vdso_data(). */ if (!IS_ENABLED(CONFIG_TIME_NS) || !timens_page) - return VM_FAULT_SIGBUS; - page =3D virt_to_page(vdso_k_time_data); + break; + page =3D vdso_data_pages + VDSO_TIME_PAGE_OFFSET; break; case VDSO_RNG_PAGE_OFFSET: - if (!IS_ENABLED(CONFIG_VDSO_GETRANDOM)) - return VM_FAULT_SIGBUS; - page =3D virt_to_page(vdso_k_rng_data); - break; case VDSO_ARCH_PAGES_START ... VDSO_ARCH_PAGES_END: - if (!IS_ENABLED(CONFIG_ARCH_HAS_VDSO_ARCH_DATA)) - return VM_FAULT_SIGBUS; - page =3D virt_to_page(vdso_k_arch_data) + vmf->pgoff - VDSO_ARCH_PAGES_STA= RT; break; default: return VM_FAULT_SIGBUS; @@ -128,7 +123,7 @@ const struct vm_special_mapping vdso_vvar_mapping =3D { struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, unsig= ned long addr) { return _install_special_mapping(mm, addr, VDSO_NR_PAGES * PAGE_SIZE, - VM_READ | VM_MAYREAD | VM_IO | VM_DONTDUMP | + VM_READ | VM_MAYREAD | VM_DONTDUMP | VM_MIXEDMAP | VM_SEALED_SYSMAP, &vdso_vvar_mapping); } diff --git a/lib/vdso/getrandom.c b/lib/vdso/getrandom.c index 7e29005aa208..2851afa9154f 100644 --- a/lib/vdso/getrandom.c +++ b/lib/vdso/getrandom.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -18,11 +19,6 @@ /* Bring in default accessors */ #include =20 -#undef PAGE_SIZE -#undef PAGE_MASK -#define PAGE_SIZE (1UL << CONFIG_PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE - 1)) - #define MEMCPY_AND_ZERO_SRC(type, dst, src, len) do { \ while (len >=3D sizeof(type)) { \ __put_unaligned_t(type, __get_unaligned_t(type, src), dst); \ diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index e0f289d3d110..f7a591aba59f 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -12,6 +12,8 @@ #include #include =20 +#include + /* * The generic vDSO implementation requires that gettimeofday.h * provides: @@ -23,6 +25,8 @@ */ #include =20 +#include + /* Bring in default accessors */ #include =20 @@ -323,6 +327,8 @@ __cvdso_clock_gettime32_data(const struct vdso_time_data = *vd, clockid_t clock, struct __kernel_timespec ts; bool ok; =20 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + ok =3D __cvdso_clock_gettime_common(vd, clock, &ts); =20 if (unlikely(!ok)) @@ -348,6 +354,12 @@ __cvdso_gettimeofday_data(const struct vdso_time_data *v= d, { const struct vdso_clock *vc =3D vd->clock_data; =20 +#ifndef __NR_gettimeofday + BUILD_BUG(); +#endif + + BUILD_BUG_ON(sizeof(tv->tv_sec) !=3D 8 && !IS_ENABLED(CONFIG_COMPAT_32BIT_T= IME)); + if (likely(tv !=3D NULL)) { struct __kernel_timespec ts; =20 @@ -382,6 +394,12 @@ __cvdso_time_data(const struct vdso_time_data *vd, __ker= nel_old_time_t *time) const struct vdso_clock *vc =3D vd->clock_data; __kernel_old_time_t t; =20 +#ifndef __NR_time + BUILD_BUG(); +#endif + + BUILD_BUG_ON(sizeof(*time) !=3D 8 && !IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + if (vdso_is_timens_clock(vc)) { vd =3D vdso_timens_data(vd); vc =3D vd->clock_data; @@ -471,6 +489,8 @@ __cvdso_clock_getres_time32_data(const struct vdso_time_d= ata *vd, clockid_t cloc struct __kernel_timespec ts; bool ok; =20 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)); + ok =3D __cvdso_clock_getres_common(vd, clock, &ts); =20 if (unlikely(!ok)) diff --git a/scripts/Makefile.asm-headers b/scripts/Makefile.asm-headers index 8a4856e74180..b38931314ad7 100644 --- a/scripts/Makefile.asm-headers +++ b/scripts/Makefile.asm-headers @@ -48,14 +48,13 @@ syscall-y :=3D $(addprefix $(obj)/, $(syscall-y)) generated-y :=3D $(addprefix $(obj)/, $(generated-y)) =20 # Remove stale wrappers when the corresponding files are removed from generi= c-y -old-headers :=3D $(wildcard $(obj)/*.h) +old-headers :=3D $(shell test -d $(obj) && find $(obj) -name *.h) unwanted :=3D $(filter-out $(generic-y) $(generated-y) $(syscall-y),$(old= -headers)) =20 -quiet_cmd_wrap =3D WRAP $@ - cmd_wrap =3D echo "\#include " > $@ +filechk_wrap =3D echo "\#include " =20 quiet_cmd_remove =3D REMOVE $(unwanted) - cmd_remove =3D rm -f $(unwanted) + cmd_remove =3D rm -f $(unwanted); find $(obj) -type d -empty -delete =20 quiet_cmd_syshdr =3D SYSHDR $@ cmd_syshdr =3D $(CONFIG_SHELL) $(syshdr) \ @@ -74,8 +73,8 @@ all: $(generic-y) $(syscall-y) $(if $(unwanted),$(call cmd,remove)) @: =20 -$(obj)/%.h: $(srctree)/$(generic)/%.h - $(call cmd,wrap) +$(obj)/%.h: $(srctree)/$(generic)/%.h FORCE + $(call filechk,wrap) =20 $(obj)/unistd_%.h: $(syscalltbl) $(syshdr) FORCE $(call if_changed,syshdr)