From nobody Fri Jul 10 06:54:32 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 8E2DE39478D for ; Tue, 30 Jun 2026 07:32:10 +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=1782804731; cv=none; b=hYdpWDWDNshSkjPE2k6JjVVsv9jao6AXbxdV3bWb16kNFhwWs+lOw2109sN8wD/BPYcRJNw3AEbfgqkbPDBJiDOSvx/l5xSZ/pdNfW02GHm68HRPB+3oUF6MC/o0p4CwX+47L71k1ViE/Jzi2KX2Iva+u8iAk2kPZXuPDxcE2gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804731; c=relaxed/simple; bh=H61r2K6PkZFx+YOky6g0kT8W3xUvIBmiUExOyg2VP9I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E2xKDdL561+jnaUbnBbvv0GWhXQOo71+ozHTJqsqtzTXooA+uap7ZSoTRNFZnhQSkZsREMDlkMRy/CZNeS0bjQkjjVeEhGmBgfQf0TavjqUzQJFxRqw3qyA9LMZIS8xZztcrH2eAb2uVaJVdmC7i5dL/D2WzqEIonbIxnBXGVrM= 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=eiDf87lu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rWqMlZZF; 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="eiDf87lu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rWqMlZZF" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782804722; 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=BBTKfhi8DDDyz3/pIu8r5DjBjCuk6Pd7FRij9VQbeeQ=; b=eiDf87lufpJJoY3iD6mQ0w0B6QIUE09ZDskb6AgMO+sf71FQgS7RAQOce+ARO0skITSxrn agEGiv7CK6Ikl3BebB9h218K47Z8NVdcI6qA3nVsgebVFcDPI7IkZ9nwK5jhVLYog+ePde fIRVmY4LIjuJVbrsiwvWnkFHAwO9W2mlO8fsdJegJMVrCZwOocfWjgB2PqyRvSNFZti0+X sQXkhDCg4aQCxg218vV+LZ95DPYBI7wihE/lcgiU7TmmOyjFofnNbFP//rWUXNAyN21xd5 enm3aX0W1RVc8uW0ypEe1ksGka3IU4J5Od1I8B0wQawzoD5SeQkITa8GhG0ifg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782804722; 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=BBTKfhi8DDDyz3/pIu8r5DjBjCuk6Pd7FRij9VQbeeQ=; b=rWqMlZZF2MS5qVv6fHEEhtXM74/WsfsRswKtW3YUexgHCpKNerGt1aQHz8Ru+1UMUO4O+b K1vZ4SoHsEvcNJAQ== Date: Tue, 30 Jun 2026 09:31:55 +0200 Subject: [PATCH v4 1/6] vdso/datastore: Rename data pages variable 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: <20260630-vdso-mlockall-v4-1-6c93708ce723@linutronix.de> References: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> In-Reply-To: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" X-Developer-Signature: v=1; a=ed25519-sha256; t=1782804721; l=2343; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=H61r2K6PkZFx+YOky6g0kT8W3xUvIBmiUExOyg2VP9I=; b=oqvB2zhbeTcP1JB5vofh+nb3w2d/ACNvZWrzXlUpwrY03dnQ1Tq0ZAbb53F1l8+qUuTzLcx+E 8oU5V9IQbuuCHP7XQ7R2LQd2pEhiyEBvfZeP1sZLQXQ1B40VLRmKeGx X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= An upcoming change will make this a file-scoped variable, for which it should have a clearer name. Rename the variable to prepare for that. Signed-off-by: Thomas Wei=C3=9Fschuh Tested-by: Nam Cao --- lib/vdso/datastore.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 17d37b82ebc6..7f78a32656aa 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -32,7 +32,7 @@ struct vdso_arch_data *vdso_k_arch_data __ro_after_init = =3D void __init vdso_setup_data_pages(void) { unsigned int order =3D get_order(VDSO_NR_PAGES * PAGE_SIZE); - struct page *pages; + struct page *vdso_data_pages; =20 /* * Allocate the data pages dynamically. SPARC does not support mapping @@ -42,24 +42,24 @@ void __init vdso_setup_data_pages(void) * Do not use folios. In time namespaces the pages are mapped in a differ= ent order * to userspace, which is not handled by the folio optimizations in finis= h_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 b= e 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= _SIZE); =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_OFFSE= T); =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_STAR= T); } =20 static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, --=20 2.55.0 From nobody Fri Jul 10 06:54:32 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 8E24A3815E3 for ; Tue, 30 Jun 2026 07:32:10 +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=1782804731; cv=none; b=otiRxgf9SqZlj31u+q/JAwEwH6lhfxkLak4yps2rZSTxmUjdsKvJN+UawF14f9lrMkQTyMb+sZEl5ted3+wX1al8rSXPf+3VwZG82Zmj24lfewodcsTJ/J2CQYYBdH1+OPk84+0gNv7bwT2q1tXpAv0kzXA68jCIx7FZqvl6Ddg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804731; c=relaxed/simple; bh=v+s3eegLtl06E0VWrRB2TMTDrXQKVH75BuSy1mEU1sY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H4y+YY8P/YNCkUHqpq1QLven7eMDceJDSXy/ZfvR8w877MeQAvVtrdvC1XuWaTu9IFZcKcl24XdXJi/u7wbdOZRlecivBsCuihn/V7I73ey1+q2EIifS1N22g+cEMWVV4PFgWEO1aC94FQHmJ7iL7OwdZM4EQ4vfZ3Hg4snKKw4= 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=V4R6bgie; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ljxxedR7; 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="V4R6bgie"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ljxxedR7" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782804723; 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=+pKh2f77m/+CAvr5W8wkHo9AO1t2s6dXpZFMecXchAc=; b=V4R6bgieP28Y/buSKCgijJhFtTo7vOgLdID50UJf7y9JShtFsa/UWQGcQbu7Xulu9+atcr qwk8wiN2TsmFAR+IN+MQyo1k/3YP4iJUQdiT+nAMHNxUwi4OOPPYPZ1djGj30czsWKblKU YHrsmudlv4fNF2/gM3iRfYXA5MFOGsjt4PuS0E7gO/eKBOAfx3IZ8tDLuDAoA/dmB1SX+R IVHghBVwJsB38HFCPnV4wLD+8XiTu9ZH+8Z8txsv5sPDeRyZqIbmP9PMuk9AM/AB1OqAwi iYg+UTVKT0EqlinKP0CKCmFoXw7RBIWj2TcedveRSCudyqTOC3s87e/nSdFqzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782804723; 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=+pKh2f77m/+CAvr5W8wkHo9AO1t2s6dXpZFMecXchAc=; b=ljxxedR7x0sXHU03E5wU7iF1bAqjDW2yOA7o/6eI96ye7PSWiuh8wXoKLwGMU0x7fuNQwW wsz28ZZZlHOKjRAQ== Date: Tue, 30 Jun 2026 09:31:56 +0200 Subject: [PATCH v4 2/6] vdso/datastore: Map pages in terms of the faults pgoff 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: <20260630-vdso-mlockall-v4-2-6c93708ce723@linutronix.de> References: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> In-Reply-To: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" X-Developer-Signature: v=1; a=ed25519-sha256; t=1782804721; l=2391; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=v+s3eegLtl06E0VWrRB2TMTDrXQKVH75BuSy1mEU1sY=; b=tZ1bSMpHj+1/cZ0YW6L8GKtTuLVi+pUpSWQrEAT1X4kYn6l9u7b/rxP/SKMkGJsmagWNj6hRI N3FEu2SysyzDkpFBHdNuKETGfNi+aDaM0SRrpbcZTu1pUCLCoOGgxXE X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= To support mlockall() on the datapages the VMA can have no holes where inner pages return VM_FAULT_SIGBUS. An upcoming change will avoid these holes by mapping a zeroed pages into these holes. That logic will be simpler when the mapping logic is based on vmf->pgoff instead of the vdso_k_ symbols. Switch to the equivalent vmf->pgoff logic. Signed-off-by: Thomas Wei=C3=9Fschuh Tested-by: Nam Cao --- lib/vdso/datastore.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 7f78a32656aa..e01db9607534 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 *vdso_data_pages; =20 /* * Allocate the data pages dynamically. SPARC does not support mapping @@ -67,13 +68,13 @@ static vm_fault_t vvar_fault(const struct vm_special_ma= pping *sm, { struct page *page, *timens_page; =20 + 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 @@ -99,17 +100,15 @@ static vm_fault_t vvar_fault(const struct vm_special_m= apping *sm, */ if (!IS_ENABLED(CONFIG_TIME_NS) || !timens_page) return VM_FAULT_SIGBUS; - page =3D virt_to_page(vdso_k_time_data); + 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_S= TART; break; default: return VM_FAULT_SIGBUS; --=20 2.55.0 From nobody Fri Jul 10 06:54:32 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 7C24F3A6B67 for ; Tue, 30 Jun 2026 07:32:11 +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=1782804733; cv=none; b=ql000yvksS9Ot3JMviJtd9K1V1TgEGDMIUW0ZvQxkSNCsCAvtoZD1PFMc6n3j5nCBVumN1w+c3Qv3jvYgyzokS0lrOHfj2jK4Jrsq55BlB6G3BKshNLWhJv4LNUPsG++1FrgUb2Ie55FFhKYgk4ADcrpF/f9h0aIFQEwkgWSNOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804733; c=relaxed/simple; bh=yqs0awL8w4LoCZn087DSNqA873VFAAn2J8DEn2oDJxw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BUaIIcofN1L6qXJAliCNSiHBWvfg2ZtmC3p6SwFZRZ7mM9FW3p6Yn8qiNFr7FThieDi5a6dRGWgHeBXuFpak17ZsMZ4q9HFWlHZCwb1PTQiHh9bVR+F3aF8WwE5XoXSEYHU01NDoJxF56JVzLw2BsUzZFlxXF3QrrhTKXQqH4v8= 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=Bxl3YyLh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NzBLG2Mi; 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="Bxl3YyLh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NzBLG2Mi" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782804724; 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=oE77uZJY0l0QxnYAgs7xNyzj+GJUBJARmqc/YVyQTc0=; b=Bxl3YyLhg9qt1mZo3c1jyTAFB0F7EpHLblvh+k5TVID31D3j4JwLdoQ02Hb2FzfLWpgEHD Dl7Zb4KkA7pTEqatFB42fRsNHxrrLTIFCWQmG2x5ZLs1a4oRfxDYvZ/r+JzKRDj1bNzJIK eF/RvAk90m518pLxWMlMpYfAaasM/UauNVZcynB58IcjGJwrVNap298OdzwUAsDkou1XVn yjhL5fJEyDjuQ2sEqhn8EDlbjmLpte5w5OgKNUO4+ndg7EkCfraFzOkP9OGdPO0KKphGoR RgVuShicbAPkCNjlt4Je9anLhljUsYpmvaAZg0eUyU8UgyETu1qROYGqoQAj/A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782804724; 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=oE77uZJY0l0QxnYAgs7xNyzj+GJUBJARmqc/YVyQTc0=; b=NzBLG2MitHx8d2jKUhpyXO/FV2MDmLIxia+qWIHuEkd1fPfbDa/b9/+ud2jOfk8y94t7no 4agovJHlab26QRDg== Date: Tue, 30 Jun 2026 09:31:57 +0200 Subject: [PATCH v4 3/6] vdso/datastore: Map zeroed pages for unavailable data 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: <20260630-vdso-mlockall-v4-3-6c93708ce723@linutronix.de> References: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> In-Reply-To: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" X-Developer-Signature: v=1; a=ed25519-sha256; t=1782804721; l=1779; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=yqs0awL8w4LoCZn087DSNqA873VFAAn2J8DEn2oDJxw=; b=KJKfshCQsaLaqMWDPp34LqfUqpxqh1XA0nl53TcmkAgeBUqnXrUsvERjMXGyHrW6ADuH4qY66 gJQxO4JpMcaDp+XALMtIewme8WIRqrXmSa+x7WQlovmHmCeeMScTZeg X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= mlockall() stops if a page in a VMA is unmappable. As the datastore VMA can contain holes, mlockall() would not process all data pages. Replace the mapping error VM_FAULT_SIGBUS by just mapping the underlying unused and zeroed-out data page. The vDSO will not access these pages in any case and for other userspace these pages have undefined contents. This will allow mlockall() to process all pages within the VMA as soon as VM_IO is removed from the VMA. Signed-off-by: Thomas Wei=C3=9Fschuh Tested-by: Nam Cao --- lib/vdso/datastore.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index e01db9607534..cf7aa80355cf 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -74,7 +74,7 @@ static vm_fault_t vvar_fault(const struct vm_special_mapp= ing *sm, switch (vmf->pgoff) { case VDSO_TIME_PAGE_OFFSET: if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) - return VM_FAULT_SIGBUS; + break; if (timens_page) { /* * Fault in VVAR page too, since it will be accessed @@ -99,16 +99,11 @@ static vm_fault_t vvar_fault(const struct vm_special_ma= pping *sm, * See also the comment near timens_setup_vdso_data(). */ if (!IS_ENABLED(CONFIG_TIME_NS) || !timens_page) - return VM_FAULT_SIGBUS; + 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; - break; case VDSO_ARCH_PAGES_START ... VDSO_ARCH_PAGES_END: - if (!IS_ENABLED(CONFIG_ARCH_HAS_VDSO_ARCH_DATA)) - return VM_FAULT_SIGBUS; break; default: return VM_FAULT_SIGBUS; --=20 2.55.0 From nobody Fri Jul 10 06:54:32 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 3DC533D330C for ; Tue, 30 Jun 2026 07:32:12 +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=1782804733; cv=none; b=heB/u3Ytw5dw/Tpzpnn/feq9UtTyCSLJJR5dFehDd07XnpPjYFOM1yNlN3YqRyiJBnlA0J5JEpBJkWeRolSA61SSLtdh0AQCTNAJ0SsgILHLP7dlMR7VzUcKsvtYgv+VPJzHTqaKV9yIoZ/1B7h+mIr+OTVbWQZnnVfo0g9umGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804733; c=relaxed/simple; bh=62ZyzfWrxivNkkXt0tG+7VuX88Xoz0Nluqqw9A4GpRY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cGa7t6xpIIaE+kujiYE9bo3jp9xDfd2TMR4Mc58QKEAcXXxmT0jIhcMmYbxzVLxRE4Q/1QjorTKFeokCrVz+BTEpbV+BT+cQ6VTiIZHyhWj/JL7eW5w9AUM1jfFbkcTM2K0z7PKC7SvptQYCYhq3FI7A0GEjDECX6WVo2kggONs= 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=b8AKZp/t; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gNeIOBPB; 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="b8AKZp/t"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gNeIOBPB" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782804724; 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=W+5gxk9aax3Z8MOxBntdlxrt0qnkQz1zmf0p9zXt3Ns=; b=b8AKZp/tZ7bJmZvaxT3DKf6ygmG88fpNOYX2Wy/faJx2mEW9oHuRUa1sf9nswfy5+tZiTR pATXXAa1QUI4TyywVXshoQwYwewkzwgeEqsZfCqZI/SXB+Mw7/tvdnC5GlRtPjMhT7EMXn iy98ypMWh34mBoK9/TbvT66qZlayzoe+vdRD64ziP9cDYYkvSYqy302mgibYDFp8h/97gI DWABZsakMhdHbdp4UKPz7Ip/MIEqZfV4oPs7s47tUhRIa4aBUFeKEinwGmqgzTiRVGy7wI ahO/Gfra2WBRz4rRZIZ2XH/VDOcJzusxCzNLiJmh8xzrl7sGwJRuMUcL6CT8xw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782804724; 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=W+5gxk9aax3Z8MOxBntdlxrt0qnkQz1zmf0p9zXt3Ns=; b=gNeIOBPB55m13prz9rKch53P+lnHJD3NYpOh49vH9tvvQmkXMqBNY1vmAZRYdmH0zwJwnJ GECqEveK9eb9VPDA== Date: Tue, 30 Jun 2026 09:31:58 +0200 Subject: [PATCH v4 4/6] vdso/datastore: Explicitly prevent remote access to timens vvar page 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: <20260630-vdso-mlockall-v4-4-6c93708ce723@linutronix.de> References: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> In-Reply-To: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" X-Developer-Signature: v=1; a=ed25519-sha256; t=1782804721; l=1920; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=62ZyzfWrxivNkkXt0tG+7VuX88Xoz0Nluqqw9A4GpRY=; b=a0urJHAq/WQkSKm2trCnr2/J0DvfCsdWRNoNI+pDyw89cBmOwlmyuCdTMoE3pdAJ5fE1nHgnG 1PqnMjzQVu9Do427gMQOpmp2ArJTnK4842/DKNZWJ/9J/mzsY8FsSrC X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The fault handler for the timens page does not have access to the target task and therefore can not be invoked remotely. Currently the handler relies on the fact that the vvar mapping is marked as VM_IO and VM_PFNMAP for which the mm core always prevents remote access. However the VM_IO and VM_PFNMAP flags are going to be removed. Add an explicit check to prevent remote access to the mapping. Signed-off-by: Thomas Wei=C3=9Fschuh Tested-by: Nam Cao --- kernel/time/namespace_vdso.c | 7 ++----- lib/vdso/datastore.c | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) 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= like + * /proc/$pid/mem or process_vm_{readv,writev}(). */ =20 WARN(1, "vvar_page accessed remotely"); diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index cf7aa80355cf..0ca43965a8a9 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -68,6 +68,9 @@ 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 --=20 2.55.0 From nobody Fri Jul 10 06:54:32 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 7EB633D7A15 for ; Tue, 30 Jun 2026 07:32:12 +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=1782804735; cv=none; b=VtCgrqPaRueZ+72brBSLd0fp6Xtv/12QJvAnqA/p/0Hr3hTT910ilLSW3C9q5iu+q14S8CLmxEGMel4rHN175HMBCIqkSbouWOhJkHVXlW1JQ/Fp9C1h/0bw0xOhxg+4OMj4COr69pWiOY6mw+4laq2hNjwhOUzOT3AdpavUyPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804735; c=relaxed/simple; bh=p/0sBe0dK25prXvIP+rbuqZbauXCumjZnpFS8hQDCB4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ofVA756L6avrI0DfSTnWLapj1RhKXTd5DXc85ih51HLdFGzvL6E7XOBn3zq6U566+Gynx4eznS+7cbSylXu3dMIw5t7FRODj8n6FWEZZGdpGkkgE2j4/MvC7qf8iPmVlPCIw/Dkkd+ezTOrlCXWKj29/+af4aINw+b2OZVN2VqE= 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=t5MxdkAr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cJxkjAUR; 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="t5MxdkAr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cJxkjAUR" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782804725; 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=AMHxE7YkKk7GdhOrMJdhPTL65ejZljPAmsiF73QwsOk=; b=t5MxdkAr0qR6zKEVOW4zSokyQYaKmTfFK76Q7VF31rw4YnQNoBzCddK+TIHd6xikymBWBz fnsokDjdJtr65wMCXQJO7nIiqEzwc+09zFHcTXOPCMu7Bs2fpLTQaZxqVLgDV3BedOW+SB 1s3NkMLxf8QA8VK/sQRVDYvo3FUoRLMXAMRS4kTrG8UeKX9AB4HFnzDei1+7S8ytPPvTeI ptZOcQ8tcg4iAUiyHBrrYZEK3xjmEkFNRNK/KjmYntLo+9x+bEJgtCKsZgykwnfjiMTso4 YHrDQ9HUHLRXBIy8g+4tfs1A78PPaNiTc7LFrz91dS6YPnPV5WNjIj9o80plLA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782804725; 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=AMHxE7YkKk7GdhOrMJdhPTL65ejZljPAmsiF73QwsOk=; b=cJxkjAURqQzAw9/KFAhRPazr008ra2/RpOy/gqph2VcvkD6kYcBH5LDaY5PyHwpAQbxM42 Uy6ojJM7l/ysxzAg== Date: Tue, 30 Jun 2026 09:31:59 +0200 Subject: [PATCH v4 5/6] vdso/datastore: Allow prefaulting by mlockall() 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: <20260630-vdso-mlockall-v4-5-6c93708ce723@linutronix.de> References: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> In-Reply-To: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" X-Developer-Signature: v=1; a=ed25519-sha256; t=1782804721; l=2120; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=p/0sBe0dK25prXvIP+rbuqZbauXCumjZnpFS8hQDCB4=; b=CK5rWQRlKZ50ZmCUDDA/6Le1n5kStzrypTXGtA45AiD/ONdyXh43UG2jKgGSKR0V6Y4qotKMg 96woUFtDXCBAQaV2zvIxOYjQBfNlt313F+iDKrWnLgpPYWkpzKm3nSp X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= While mlockall() is meant to lock page *memory*, effectively it will also create and lock the corresponding page table entries. Latency-sensitive applications expect not to experience any pagefaults after calling mlockall(). However mlockall() ignores VM_IO mappings, which is used by the generic vDSO datastore. While the fault handler itself is very fast, going through the full pagefault exception handling is much slower, on the order of 20us in a test machine. Since the memory behind the datastore mappings is always present and accessible it is not necessary to use VM_IO for them. The data page mapping is now also aligned with the architecture-specific code pages. Some architecture-specific data pages, like the x86 VCLOCK pages, continue to use VM_IO as they are not always mappable. They will require their own special handling later when the general approach has been agreed upon. As a side-effect this will allow GUP on these pages and allow more ways to access the data in them. This is fine, as all data in this mapping is globally visible anyways. Either because it is mapped into all tasks, or in the case of the time namespace pages, can be read from procfs. Regular mlock() would also work, but userspace does not know the boundaries of the vDSO. Reported-by: Nam Cao Signed-off-by: Thomas Wei=C3=9Fschuh Tested-by: Nam Cao --- lib/vdso/datastore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 0ca43965a8a9..d7ab077cd604 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -125,7 +125,7 @@ const struct vm_special_mapping vdso_vvar_mapping =3D { struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, uns= igned 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); } --=20 2.55.0 From nobody Fri Jul 10 06:54:32 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 6C31C3D6CD3 for ; Tue, 30 Jun 2026 07:32:12 +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=1782804734; cv=none; b=YctthFudqUjc6ITeziWPexrkZC0sQ/FR/sjO9gTZQ8gwyG94xllXsfxq1ZQiB9h5qVAuk5RlOchYQuXo/AtlKEoJ2DG6hMi3K8sqAw5y8H2HS62gYVR52DdiwmzadbQzDGYMKCHUsb2TKtBL2N13JqgcAY8Blr/sLSY6Jf7Za+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804734; c=relaxed/simple; bh=tMYyr+0MUZgqXxRCaSudj+eF7RhqsNYP604whSkkFls=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G1oIQN4lyiNOe5QrSOWOJxq6xNGJPq+6vjZpUKRvyvruIEZhITmOvG+VDUChmmTt6DNDgtcFpn/1Pvr1cFMgjGK4yJDS722Z+9vy2jVbgnf1+FRxAxxDJOQPgP/6bQsVn0H1FH+40Z1ZbtYcm7Q7HJYqe7svSqrWm72VOf7N+kk= 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=pkiZd5RE; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BuXKYez3; 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="pkiZd5RE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BuXKYez3" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782804725; 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=b9woAwxTCd5iqMf0h6O2yZttpHnUjaQxSjRP4D9f09Y=; b=pkiZd5RE3R16RLIHgJSrNZojyXivPIjLOENwgHZEw//KpsY5f7MZn/JtKFuYl+KH/Avdo2 J6ccKqWWMpZgQfHjORmegmRaHO+LPzlem3xQCauGpIGmdUXijcxggHgooQ5WaoDRQKOieG MSobUx+QDUPlw6Z8bDVGF5uw29vkQhXqUuT+mWvLUIf+eN0L+Z0yydsroCArBKkFckHIhO rX05qYl0VCmVLihAeqq1sklGDCPLMtrTWJ3PNtog2x2/PbD7erUgTwh6OWn3nWupPEGQVT SXMieBMYMoM1hpugyJ0jgIzK7C1k+Ae/YvHKMOkzsyirVtmJOBHFxY7OFb+i3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782804725; 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=b9woAwxTCd5iqMf0h6O2yZttpHnUjaQxSjRP4D9f09Y=; b=BuXKYez3e12iaVkuRRIoAUGjK94QgjbpbzL8Ej6/bbYPj4+Syb6h9CC/F/7bMWhHyT0BOZ pTGQSC994lU4C0AA== Date: Tue, 30 Jun 2026 09:32:00 +0200 Subject: [PATCH v4 6/6] vdso/datastore: Simplify the mapping logic for VDSO_TIME_PAGE_OFFSET 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: <20260630-vdso-mlockall-v4-6-6c93708ce723@linutronix.de> References: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> In-Reply-To: <20260630-vdso-mlockall-v4-0-6c93708ce723@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andy Lutomirski , Vincenzo Frascino Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , "Liam R. Howlett" X-Developer-Signature: v=1; a=ed25519-sha256; t=1782804721; l=1523; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=tMYyr+0MUZgqXxRCaSudj+eF7RhqsNYP604whSkkFls=; b=aO9l5/rIajahyFgMu+6t9DtyWFk+0YDSWX/pe0+uidn7k1GXsGHpy5RYFEUzu8nic9h5gnb55 SPE2zsS3mD3AN85vpJUkQJS6yG0pCKySQ1YDi6WfsCFLCmSHIupjvp9 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The logic for CONFIG_GENERIC_GETTIMEOFDAY=3Dn and !timens_page is identical now. Use this to simplify the logic a bit. Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vdso/datastore.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index d7ab077cd604..1426bf4e0c12 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -76,22 +76,20 @@ static vm_fault_t vvar_fault(const struct vm_special_ma= pping *sm, =20 switch (vmf->pgoff) { case VDSO_TIME_PAGE_OFFSET: - if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) + if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY) || !timens_page) break; - 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; - } + /* + * 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: /* --=20 2.55.0