From nobody Mon May 25 09:57:53 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 064491DD877 for ; Mon, 18 May 2026 09:50:49 +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=1779097851; cv=none; b=iBH9U+Zy+dJ1WOeSoR9JFMdhZ3OmN6m+0NcCjgoeMljHIb87rtipy26Q9hBtDYUWIR8pcIRma6j8ZK2SzimYAswyC9PEI7b3sLSvLnT3banHx2ohyrQNq9sL2kQmzk8CktwIiWzi8GcQaO++0/fBJuF+B+r3O8b36ODmmkNUZN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097851; c=relaxed/simple; bh=J/r1cK+ZTBjrDnGBN/Iaqap5r5bJkvBE95UTLELIr3M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P6TICN32Yf2/NCgF+IgUlATbVpJQMP8TxOmxBF2yl/V54dPM/LAP90vx6eNs2ZCBrdoDtio76AWNSCZfzKRedWVi7brcRcP10N9QbpyRKd32AG1urA9pwgy1TmIyMIXhieJG+y0liohqvPngKGDLxMLmtfBTTuhLRKFMPh26yAU= 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=wKsVCevx; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uKOICqlO; 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="wKsVCevx"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uKOICqlO" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097848; 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=pcGx4Sx4V/HTVgnHJ5ps/As51n3oT0tfi46eFvRYM2c=; b=wKsVCevx7VOo8ic7J5Y6GnIpUnQn0L9Znxg17pzdISsl0boYrPmHO+mvsyZ8aRVdu+USj8 c/8oNg6qsyzZQGDd89oI4g8BxIDDuylLfkoQauFbtl0ziWrsoEKFuLjZRxTBA0C6HHUm48 UrL4qu2tXlKNOcGPRq93IAq/TAUMbY/68f5j058AytSuaCGqTwqQxucK4zX9cElNuTVdeV B9tkTwrXfgNmx0VTUGK0N97gVY97OBWSkdjRXsq3YFQPsJDZcOhBnplnLBHSDa4mE7tthn cXXjryGWJ0D6Pz2g/yNIXsVeciDmbmXYNaCEQ6p9OP9GBNZlHoha8vg29mGusg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097848; 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=pcGx4Sx4V/HTVgnHJ5ps/As51n3oT0tfi46eFvRYM2c=; b=uKOICqlOG44cpRnKaRSj8UfTZ1u6UQ/JiaK44737DKmpMKeAlomrsHzRNlZqICHaMLMI8L 0J+QOC5KlkpTxNAQ== Date: Mon, 18 May 2026 11:49:39 +0200 Subject: [PATCH v3 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: <20260518-vdso-mlockall-v3-1-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner 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 , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=2337; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=J/r1cK+ZTBjrDnGBN/Iaqap5r5bJkvBE95UTLELIr3M=; b=S++2zrPBvIfatfiepUfR0/BfRTBAr9fI8HrG2QJV/fPAPaZrWeCfUJ3fTs3yUXhrRG7S33T7C Zhi6yhcMn9JD4qWkiG4X6U6zI8049PFb2aQrcNiV+ZfVTW/3CjdU3wa 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 cf5d784a4a5a..9d66ac2fdb8d 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -32,7 +32,7 @@ struct vdso_arch_data *vdso_k_arch_data __refdata =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.53.0 From nobody Mon May 25 09:57:53 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 8CFB13176FD for ; Mon, 18 May 2026 09:50:50 +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=1779097852; cv=none; b=BTXf2BFUIqTAAs0PALl+josS565LW5eoiIAPmrNxP0qqvw9mXeskfY45oNDtZY/5WBJcd/jBBaybqXWyPbDvt8YvpA5LdO9DhWjKkYtCpoYkQN8aV/dc4hlUupdgSWfga14bYdJ14wJqV4pwNl9qWcRpGoOYbL5ywvJLIW/S1eU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097852; c=relaxed/simple; bh=nzT+jyn6qlGajUV43mviB6CNboF/KXDQKyet06Cekss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EFGidDDayVsC6hO2Ye9Kae+eq6lVg0hMO8zikp/RsBFH+F3XJ676rYb/xST01Hc+6y1E/iqKxankaPqqKs6FOQTPwp9jVPUdTZYKycD9+SlVdozapuLNQALVeLIPs2tWgqwnNNbtPcaJQ1tVibSRx6LwTFSqRLTJgMmUa8nzXKE= 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=T1DwD4Y+; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+Rn9z5wq; 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="T1DwD4Y+"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+Rn9z5wq" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097849; 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=eKBBbMFW0zeLfKhafDGwFXWyVXzSARM45rAP15Pw1ts=; b=T1DwD4Y+9qZNYRn3+BCh7jG7baC/rIqSmxElD+uZdR93PpXrWGiLFjHH76dC0VacODtp08 ASKH8emTUOmy2RHIS9mgsCRYAfo35Rhyq/6lTk0XHB35XyZSY8gSz1s8dGrFXafP4b+zq2 S2VKInq5BVDeXkAmtokPSCiQTekOQAbzcFPcK/OS+6D6N3maS3FpL8PhEKzywrJ2eHYjSA EB2KuSwmxDe6JuE6b7Vl7nDv9MLrwDmSSeGagK6nmTiFUzazG2zkOhvA0rLEyPaJfypusJ m+aBRgNpuFF2blLVQ3cg0Hzv7LNrnvsyHU0ruoW/rGKgZvPdSbawp+PuLf3Fqg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097849; 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=eKBBbMFW0zeLfKhafDGwFXWyVXzSARM45rAP15Pw1ts=; b=+Rn9z5wqnKOCTl7+4iQLXvarvwFfJubpHkP7LnPRFyja5mtmlQ1KSUgtnkCLO1SbYLzti2 g20HAQx++B+I2eBg== Date: Mon, 18 May 2026 11:49:40 +0200 Subject: [PATCH v3 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: <20260518-vdso-mlockall-v3-2-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner 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 , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=2385; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=nzT+jyn6qlGajUV43mviB6CNboF/KXDQKyet06Cekss=; b=w37Z9N6Y8tgiF2a6w/a1sqtak00ri+ZGpAQvQQrdBSqIinWikPGz0HG5xyz9cU3DoIXg4X2RQ ZX6YbcNVILkDaLnJ4mJPx9qMc7jiOVkyxjGx666XKZo24JnHKfryvXQ 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 9d66ac2fdb8d..8aabb289a7b5 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -29,10 +29,11 @@ struct vdso_arch_data *vdso_k_arch_data __refdata =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.53.0 From nobody Mon May 25 09:57:53 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 EF40C322B87 for ; Mon, 18 May 2026 09:50:50 +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=1779097852; cv=none; b=YuTcBJGHh6LfSuy0qcDIvt9lIvev43CRE7XQ6Z2yV94zrVpEqdXTFwqC9sda4fJp9dilPB2q8O6SiI9KCkNP7wGMiWgPo85Ji6J+MbSavZ8TTKntm9O5cStsISuAdq90PG5kVx4OraZ3+SH7LFTzQoGe/6MYaS8d8U5NVMrHeM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097852; c=relaxed/simple; bh=dPJZ4cyiY7usvh3Dj3xb9H24EuXZmchSS2shKwLhI4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W3rNDAIs/++MnnU+QwT42eIVQcC8zsfAUVPSzDBIvJbFlvK8n669Msl3PPQSnoCh2uzQWj38Bnl6+C9GpJpyUzH+rQmPYJlVXb+KqR8VJ5uKS6okIVRb0YrEF6+LJjognpL5qKlQZcADF5MsZZzwT8jRxtioHnm75iodCcBLqEk= 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=GUX7YQkV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4j1ux4y0; 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="GUX7YQkV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4j1ux4y0" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097849; 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=xDACfn5mnkk4BzBZ8LQOYFhz188HcBcZRBoZRe6gBL4=; b=GUX7YQkV9tH8B+pbuxQlopuV/TuHc+IBlvcg1io/zbgozZbno/dhr0oPqgRIxvMqZdCca/ 6PRMWJxqC6wOe4JIez2PeXjxCHpH97RutmTF0siTM33lCXU6Q/busByu94iwSU0HgBLILQ zw11c1qXNaCmLJxTdpDLQyB0IVjzzzQexSJqskY4wTDz1Nbmz2dB00+dU0jwau1eGOTGUO lS20j9to7ftr0bCFPgk2uSUGewxJFn6j2TZpvGmqpnnu80yTdh79nWmBzlSuYFOCyxpUQA 7/+8GjlhWGaeszU+MAO0kF/pdWYZKeMbgsq2HV6naQpDcbnurxMkiEXHQk8oIw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097849; 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=xDACfn5mnkk4BzBZ8LQOYFhz188HcBcZRBoZRe6gBL4=; b=4j1ux4y0bHtY1BECe8ojDJ+mMSEqAh6xfrUs5WIVGZlz8w5//pwGo19JMLRHUggLVwbDuI 1oMgsPX9kFXIzKBg== Date: Mon, 18 May 2026 11:49:41 +0200 Subject: [PATCH v3 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: <20260518-vdso-mlockall-v3-3-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner 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 , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=1779; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=dPJZ4cyiY7usvh3Dj3xb9H24EuXZmchSS2shKwLhI4s=; b=Ng+knDPvybZE2AWH1rVLYkUjoc6qSujYwPAPvd2pWS+dgpTx5w5LSoOpY0egzbrYBeGzFOmNs 4JljMACKH3fBuU6RnvMEExmOPnHDDlpVN1oJX2dkwe0I13GGMfTKmKB 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 8aabb289a7b5..f9a1f0fb7ccd 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.53.0 From nobody Mon May 25 09:57:53 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 A4E763246EB for ; Mon, 18 May 2026 09:50:51 +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=1779097853; cv=none; b=VUewDFrw3nKQs2oOmfP/8RrSVjFtqP44RDW7YxFuO5h+rlJtV1OTXIr3J34feeOQVwdeRGZR+vVElw002n/qv3cMMQQTgb2rFjIIwWScjAPhWLrlInxKQWJAXAUzYx53aBYUBSeqDRB/5cVAVJY2qgVk9GqSDkZpm3QC/dUcDFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097853; c=relaxed/simple; bh=IV1AOHFxFtPMDWIuw8YM0qfvmYEK6TUnKOoH3bZ1kc8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r9q+WgCWH5r/sM6qc6dvj73pAJd7U3YS4nkPNXZDi3FqYKPNkSdXabDn/jL/eA8oiYoSFhked2x9WWYDsO4L1jUj7iRHQnOwy2rzaagCoXopHOu7wu1mHG0Jd8iBlfV/NInfUnoN6vUFRYpztULLAVBOIkbKKjPja03MBGbz0Es= 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=Rbh0C5wX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=o5rEHMOA; 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="Rbh0C5wX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="o5rEHMOA" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097850; 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=eoryIgzXF/oIa33zui9MlTduEZDwQ60Yge75gzlAI50=; b=Rbh0C5wXKorBFppJBF1BYLRhWQkZwOQEMIVdFCWM2Kn2Dwrrp41Zkqcl992JI4UK67ryLn fACK+stDxFS2SU2WxAU5EG1E8Fb/1EFQS7DalLfbGaGDFXi7cfa88KByGN0hGNe7v8cCbI 7QG94wVvIRMs/IQLOW7TlM54S+vJSWFMotOP3YpKv8m9REAeO7yT8TWv0sWb+gY3BWDdf7 sMpKtUa4t/YA9jyhHtIqsVs8lkwEScXj76SV+WA6ErBMwcMGTYt90qHaJdW42BHKJUXBi1 /Qu2v5ecWBTDC64Jg0elTTMifp+tCexQulStkjIPTQtIMB2sxWplaawuu/g7gw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097850; 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=eoryIgzXF/oIa33zui9MlTduEZDwQ60Yge75gzlAI50=; b=o5rEHMOAoSaZSnblbe7t66JQZ78Sna7tcTnG/RLzSjyNF+gFFT3fYLDOp4elRXN8kCqhgk /MROBOf8F8i5xOAg== Date: Mon, 18 May 2026 11:49:42 +0200 Subject: [PATCH v3 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: <20260518-vdso-mlockall-v3-4-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner 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 , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=1920; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=IV1AOHFxFtPMDWIuw8YM0qfvmYEK6TUnKOoH3bZ1kc8=; b=mwlMV5qGf3DE/o8vp+sBUofrQvPITNJqFDZVoJnzPQTMcKlAFbYvOBGJQCmc6tMj4QnN26AlC u26yl4VQgCzAWxB8PzMusFV3pN/RDkiGzXa7F7qJ7wmkjmw9xBU1Z9A 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 f9a1f0fb7ccd..3381ccf9edb1 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.53.0 From nobody Mon May 25 09:57:53 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 80713322B7B for ; Mon, 18 May 2026 09:50: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=1779097854; cv=none; b=e35haB0+cqEqgWJenXqJEH2n/USZQY5d0ryZKj7MW8JMZPdQozh5s/58aEqJKWduM6OAIwzio65I+cFRU9o3XTJdZKsCtPLxeMFtAY8DFbsRud+6fHKDjdK9eXvgVP2smSFHJdXuoGjOeJ1AgWQKJoRE42fprIAFvI4+NIwe6d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097854; c=relaxed/simple; bh=XWSQwoDFIaH2o1UGbnO7M9TuyMOc7ANs+7v39DOcLXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SaWLrRbvIGJSrAF2E4Q1+HJ+oQlOc7XBPxC1r4UiASAbwdv/hDAisjc4mhWjoGVs6RYidzV7vRsYFrIptWBnloO5rRWg2JYodYWjCaeMi2i3DMsEuH5awwwYHHxC9doW938NIwNEuKr/sLmA049fKWOKElzVeq4n/fSrWzTGVa4= 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=K30HU6Xz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hCBP/NQu; 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="K30HU6Xz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hCBP/NQu" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097850; 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=Jc7l/gg80oX0jL/4qJmHKXqxml1Vo+aQQWLxItlgPwo=; b=K30HU6Xz+/81xSNbNLhiKBnmtZnlVx4ZZkYj8p+N3j9jCZDGrl0ecrRjpkwYAG0XckZbm5 5AuzP0jnAQjPItmUOz4BjG0qa7FbDzeZbVx/ZHm4DiFguoYxFa0od3yyXTUtCtZiMqpCv7 hwlIRlsSszyAZVicxFRuHr2fa3RJMtQW5Ai+KNFyHUe3ZETraWqGuiq5zund0mxKLgWpqu R76le1iwJWo6n8QHxrWuZskWIZq7KYoO5duLTDiVmk1eJ1pN3Xm99B+eJvBY1jQS5As1CL UVnJF1AGf/g+U29C/gp3QebIDplFPyMpmHnmRB74fbb4GqC5faP/S2Dc2/jCNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097850; 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=Jc7l/gg80oX0jL/4qJmHKXqxml1Vo+aQQWLxItlgPwo=; b=hCBP/NQu4Zf+ysJPIP+Wj8MSwDJVODDN5Sy7HUuzAwDy50pUx/VadCw0LQYLcfNEzv7rb+ ws8v6EnW8PTDY3DA== Date: Mon, 18 May 2026 11:49:43 +0200 Subject: [PATCH v3 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: <20260518-vdso-mlockall-v3-5-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner 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 , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=1829; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=XWSQwoDFIaH2o1UGbnO7M9TuyMOc7ANs+7v39DOcLXw=; b=txqlEqpsMZu3yYNsjeo+PZQxSxxMLxOn1RELhIfkP1Q33PdbnPa53tZqehLhcLg0fZEvViCa/ UP+m2x5q3XuAhzPsAELANtmInSGHmsQh8b6E4qHB/Hk3mbwHiQbQkzV 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 aproach has been agreed upon. 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 3381ccf9edb1..3f837cb6a886 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.53.0 From nobody Mon May 25 09:57:53 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 28EC13B4E80 for ; Mon, 18 May 2026 09:50:53 +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=1779097855; cv=none; b=eYuI9xTvOuscbSkUVrEc08QQhzDOvEDBTf/5EIbp25hEUOrshjoFEU5WpqHS7y7c5qh5ZT4kiKqFwU4V2OlkLxJZS4Ow+Y95hROqxeLKwF51KXgb4tAuji1eGHfXntQcUS6yBkVSzpYNIb8IbKt51a4dot09SlEaEqg6qEQtND0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097855; c=relaxed/simple; bh=Hr9CQZ909W4yD70dLkMZGJHZWtArn65CtWZlQke5Hvg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gxz/bFRn6THOKFcrNsUBUZB+CfamN/7gRV3kM/QFiANqAYsYTlgrVA3Y3cDs/6iZB72Mxyk54ToZymlmOVpyyx/D7eTfLwr9qQOndT3cTtcRb+pH3+EYZ9HWeJGq+tJGBOEqQbWxiig1cUJ/ha8SPOxvOMxifdlWn9OMJR7BwbM= 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=SaHFP7is; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Nb4Xn1wp; 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="SaHFP7is"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Nb4Xn1wp" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097851; 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=56ec2S6UfJI5KAZ991lLf5dp68E9Sf1TsK9ZbOo3bbI=; b=SaHFP7isUdwhSVQ5l1Y9zvTejemEyd8BX0KqDvdTc5prGnufRKTB1aIcN00WjgftkGW1yK nmSHedDzBT+mU0qhyLb/5ygQCaRbzS8xE0u2EFdaAk1zHnBQ/Ee/GrOWM5XBN7jBDJ67c3 K5v92MujBuor3AeeTN6Kc79M2AugcInDpx4t2TjsuWni0pcrAlaKP0SZQvsZz2kuUNg7Zk ZWVh3pee2rReuHkUddlTsM3fewe6Lg8IpWIbzAKzdyO8eDWBYJMFuq/l5UvzQF14dIHbOY upyt45fZRcauj9XVyt9EK4Olboe126wSovoY7jqaTWiI38/snMKeXoo3M2O0EA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097851; 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=56ec2S6UfJI5KAZ991lLf5dp68E9Sf1TsK9ZbOo3bbI=; b=Nb4Xn1wpCA14AqC+1VqPEBORrcVz1VaIPEZ0emAqRIwhoiLrqtfJnQ6kVPM6ni+QXK/tCb IHwcDv8NpGLLCfDw== Date: Mon, 18 May 2026 11:49:44 +0200 Subject: [PATCH v3 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: <20260518-vdso-mlockall-v3-6-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner 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 , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=1523; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Hr9CQZ909W4yD70dLkMZGJHZWtArn65CtWZlQke5Hvg=; b=zmr3hyUYEww/Dm4yHLpAjozy/bJb3KTvigINE+q1hmoIY0Q3TUITjIbdYECHG700bRT3IWYFC fZB0m9GO4leC5up/AVIKU92rYA3kM2ipz2BcwUGZ+zSVkYM71Wm8ZAH 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 3f837cb6a886..21f09fa5e254 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.53.0