From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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ßschuh 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 = (void *)&vdso_initdata[VDSO_ARCH_PAGES_START * PAGE_SIZE]; #endif /* CONFIG_ARCH_HAS_VDSO_ARCH_DATA */ +static struct page *vdso_data_pages __ro_after_init; + void __init vdso_setup_data_pages(void) { unsigned int order = get_order(VDSO_NR_PAGES * PAGE_SIZE); - struct page *vdso_data_pages; /* * Allocate the data pages dynamically. SPARC does not support mapping @@ -67,13 +68,13 @@ static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, { struct page *page, *timens_page; + page = vdso_data_pages + vmf->pgoff; timens_page = find_timens_vvar_page(vma); switch (vmf->pgoff) { case VDSO_TIME_PAGE_OFFSET: if (!IS_ENABLED(CONFIG_GENERIC_GETTIMEOFDAY)) return VM_FAULT_SIGBUS; - page = 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_mapping *sm, */ if (!IS_ENABLED(CONFIG_TIME_NS) || !timens_page) return VM_FAULT_SIGBUS; - page = virt_to_page(vdso_k_time_data); + page = vdso_data_pages + VDSO_TIME_PAGE_OFFSET; break; case VDSO_RNG_PAGE_OFFSET: if (!IS_ENABLED(CONFIG_VDSO_GETRANDOM)) return VM_FAULT_SIGBUS; - page = 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 = virt_to_page(vdso_k_arch_data) + vmf->pgoff - VDSO_ARCH_PAGES_START; break; default: return VM_FAULT_SIGBUS; -- 2.53.0