From nobody Thu Apr 2 23:55:39 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 561B92F6192 for ; Thu, 26 Mar 2026 11:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774525380; cv=none; b=GPHPWZ1iUo884LOtWlBFjZRz6Nop0DUkDZrq8JGR5tFfdnIsqZ0muCsnz1QJUPpYthIvbq4WTnIWhP4ZQv7wUrtdMNJGlmtxrZ1mn9MDwnaXmGD6CphHT1l7d0S8K1KMIPUTWOSYgiZra9p7u7d5tB9sxj8tqnhc0NHmj0cGq58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774525380; c=relaxed/simple; bh=s9L9qWJGOlJsU7ojUyTnh2exZhu8oFoOvBAXvYIA56o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fdYLM/ROcmb7d81OkzW1r/IzBGApUri13acYofxMIiGDMZC5n4kDG3bRIRNQLWB4/pIKT3iLm+LZ9oeQpz9aD57hFlAhmfmIGzbACN0CyBdBZTPaGLorFebGB7XzCg46hhs5QtTgEWU6oa+CyI7E+OUNSS3Dn+dtm1CcLnnI0T4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YnX9tOoi; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cvSEiYDX; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YnX9tOoi"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cvSEiYDX" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774525370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fzmp4Ecp8vqK8i5tsguuWLrV1tEl3U2b/hyDkVrtqYQ=; b=YnX9tOoi/q5n2Kq3BOPG3WZPQN83Oe8/13vCII47SydK+ueZgKWK8SeLMZU43ZtMkdQ0gP 9w21xktdsrSFsirwvOcnr5jx5oYzNDwibQR2jTdvXuo4TVYipKMqPnWi5OsnZVsFuqZdbR lUDLHPYjq5xwgrBiQurVXXvcjgZSA64m+dorb7yWyqUc5VYC6rkvIsmGe5zutKWLLIOtEB njW9rVl3poI+x4X7nCrW8aLG9m18OQK9KgBFHZQLyUsGq9btB86PSEJ4rM/Xn2X1UTHWHD Hb4Iz0VKWnNnO+duPro2+ZXsY/YS24q/ZUs+GkSzJSoU7TjlJc/KW284N3hcwQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774525370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fzmp4Ecp8vqK8i5tsguuWLrV1tEl3U2b/hyDkVrtqYQ=; b=cvSEiYDXmEn1iMsx/fOk1TzTAJrA8ugnWmz+PZA83KArhst46azV3HB97nur+BQ6cWWF1f LqUJQOH1Zyv42hBA== Date: Thu, 26 Mar 2026 12:42:31 +0100 Subject: [PATCH v2 2/2] timens: Remove dependency on the vDSO Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260326-vdso-timens-decoupling-v2-2-c82693a7775f@linutronix.de> References: <20260326-vdso-timens-decoupling-v2-0-c82693a7775f@linutronix.de> In-Reply-To: <20260326-vdso-timens-decoupling-v2-0-c82693a7775f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1774525367; l=7106; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=s9L9qWJGOlJsU7ojUyTnh2exZhu8oFoOvBAXvYIA56o=; b=s4+Kbd4P9jLJDlJ58itENt2QVfvdcDHKBH7xUr8QTEzTX24jEAkNzVN9TLtVveguz8+upEvq3 qEnQZUxceqUC4riJ/H/pjhk9p190Q9dh7UGUk2ilxFn7kzhwRmf0nQG X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Previously, missing time namespace support in the vDSO meant that time namespaces needed to be disabled globally. This was expressed in a hard dependency on the generic vDSO library. This also meant that architectures without any vDSO or only a stub vDSO could not enable time namespaces. Now that all architectures using a real vDSO are using the generic library, that dependency is not necessary anymore. Remove the dependency and let all architectures enable time namespaces. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/time_namespace.h | 28 ++++++++++++++++------------ init/Kconfig | 4 +++- kernel/time/Makefile | 3 ++- kernel/time/namespace.c | 8 ++++---- kernel/time/namespace_internal.h | 15 +++++++++++++++ kernel/time/namespace_vdso.c | 14 ++++++++++++++ 6 files changed, 54 insertions(+), 18 deletions(-) diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index 0421bf1b13d7..c1de21a27c34 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -25,7 +25,9 @@ struct time_namespace { struct ucounts *ucounts; struct ns_common ns; struct timens_offsets offsets; +#ifdef CONFIG_TIME_NS_VDSO struct page *vvar_page; +#endif /* If set prevents changing offsets after any task joined namespace. */ bool frozen_offsets; } __randomize_layout; @@ -38,7 +40,6 @@ static inline struct time_namespace *to_time_ns(struct ns= _common *ns) return container_of(ns, struct time_namespace, ns); } void __init time_ns_init(void); -extern void timens_commit(struct task_struct *tsk, struct time_namespace *= ns); =20 static inline struct time_namespace *get_time_ns(struct time_namespace *ns) { @@ -51,7 +52,6 @@ struct time_namespace *copy_time_ns(u64 flags, struct time_namespace *old_ns); void free_time_ns(struct time_namespace *ns); void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); -struct page *find_timens_vvar_page(struct vm_area_struct *vma); =20 static inline void put_time_ns(struct time_namespace *ns) { @@ -115,11 +115,6 @@ static inline void __init time_ns_init(void) { } =20 -static inline void timens_commit(struct task_struct *tsk, - struct time_namespace *ns) -{ -} - static inline struct time_namespace *get_time_ns(struct time_namespace *ns) { return NULL; @@ -146,11 +141,6 @@ static inline void timens_on_fork(struct nsproxy *nspr= oxy, return; } =20 -static inline struct page *find_timens_vvar_page(struct vm_area_struct *vm= a) -{ - return NULL; -} - static inline void timens_add_monotonic(struct timespec64 *ts) { } static inline void timens_add_boottime(struct timespec64 *ts) { } =20 @@ -167,4 +157,18 @@ static inline ktime_t timens_ktime_to_host(clockid_t c= lockid, ktime_t tim) } #endif =20 +#ifdef CONFIG_TIME_NS_VDSO +extern void timens_commit(struct task_struct *tsk, struct time_namespace *= ns); +struct page *find_timens_vvar_page(struct vm_area_struct *vma); +#else /* !CONFIG_TIME_NS_VDSO */ +static inline void timens_commit(struct task_struct *tsk, struct time_name= space *ns) +{ +} + +static inline struct page *find_timens_vvar_page(struct vm_area_struct *vm= a) +{ + return NULL; +} +#endif /* CONFIG_TIME_NS_VDSO */ + #endif /* _LINUX_TIMENS_H */ diff --git a/init/Kconfig b/init/Kconfig index 444ce811ea67..5e710b03a27a 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1386,12 +1386,14 @@ config UTS_NS =20 config TIME_NS bool "TIME namespace" - depends on GENERIC_GETTIMEOFDAY default y help In this namespace boottime and monotonic clocks can be set. The time will keep going with the same pace. =20 +config TIME_NS_VDSO + def_bool TIME_NS && GENERIC_GETTIMEOFDAY + config IPC_NS bool "IPC namespace" depends on (SYSVIPC || POSIX_MQUEUE) diff --git a/kernel/time/Makefile b/kernel/time/Makefile index 662bccb3b7f9..eaf290c972f9 100644 --- a/kernel/time/Makefile +++ b/kernel/time/Makefile @@ -29,6 +29,7 @@ endif obj-$(CONFIG_GENERIC_GETTIMEOFDAY) +=3D vsyscall.o obj-$(CONFIG_DEBUG_FS) +=3D timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) +=3D test_udelay.o -obj-$(CONFIG_TIME_NS) +=3D namespace.o namespace_vdso.o +obj-$(CONFIG_TIME_NS) +=3D namespace.o +obj-$(CONFIG_TIME_NS_VDSO) +=3D namespace_vdso.o obj-$(CONFIG_TEST_CLOCKSOURCE_WATCHDOG) +=3D clocksource-wdtest.o obj-$(CONFIG_TIME_KUNIT_TEST) +=3D time_test.o diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index 903f55a2dfb2..42302cc3f3fb 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -93,8 +93,8 @@ static struct time_namespace *clone_time_ns(struct user_n= amespace *user_ns, if (!ns) goto fail_dec; =20 - ns->vvar_page =3D alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO); - if (!ns->vvar_page) + err =3D timens_vdso_alloc_vvar_page(ns); + if (err) goto fail_free; =20 err =3D ns_common_init(ns); @@ -109,7 +109,7 @@ static struct time_namespace *clone_time_ns(struct user= _namespace *user_ns, return ns; =20 fail_free_page: - __free_page(ns->vvar_page); + timens_vdso_free_vvar_page(ns); fail_free: kfree(ns); fail_dec: @@ -146,7 +146,7 @@ void free_time_ns(struct time_namespace *ns) dec_time_namespaces(ns->ucounts); put_user_ns(ns->user_ns); ns_common_free(ns); - __free_page(ns->vvar_page); + timens_vdso_free_vvar_page(ns); /* Concurrent nstree traversal depends on a grace period. */ kfree_rcu(ns, ns.ns_rcu); } diff --git a/kernel/time/namespace_internal.h b/kernel/time/namespace_inter= nal.h index e85da11abb4d..b37ba179f43b 100644 --- a/kernel/time/namespace_internal.h +++ b/kernel/time/namespace_internal.h @@ -4,10 +4,25 @@ =20 #include =20 +struct time_namespace; + /* * Protects possibly multiple offsets writers racing each other * and tasks entering the namespace. */ extern struct mutex timens_offset_lock; =20 +#ifdef CONFIG_TIME_NS_VDSO +int timens_vdso_alloc_vvar_page(struct time_namespace *ns); +void timens_vdso_free_vvar_page(struct time_namespace *ns); +#else /* !CONFIG_TIME_NS_VDSO */ +static inline int timens_vdso_alloc_vvar_page(struct time_namespace *ns) +{ + return 0; +} +static inline void timens_vdso_free_vvar_page(struct time_namespace *ns) +{ +} +#endif /* CONFIG_TIME_NS_VDSO */ + #endif /* _TIME_NAMESPACE_INTERNAL_H */ diff --git a/kernel/time/namespace_vdso.c b/kernel/time/namespace_vdso.c index c3582befa7a4..ea37047801e7 100644 --- a/kernel/time/namespace_vdso.c +++ b/kernel/time/namespace_vdso.c @@ -146,3 +146,17 @@ void timens_commit(struct task_struct *tsk, struct tim= e_namespace *ns) timens_set_vvar_page(tsk, ns); vdso_join_timens(tsk, ns); } + +int timens_vdso_alloc_vvar_page(struct time_namespace *ns) +{ + ns->vvar_page =3D alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO); + if (!ns->vvar_page) + return -ENOMEM; + + return 0; +} + +void timens_vdso_free_vvar_page(struct time_namespace *ns) +{ + __free_page(ns->vvar_page); +} --=20 2.53.0