From nobody Thu Oct 2 12:04:38 2025 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 AA51B2E8B7C; Wed, 17 Sep 2025 14:02: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=1758117734; cv=none; b=Q8D6WrzKHaaMnVvuIj/p1bEQwh4bh1+LInPzD6vk/eizDS1TSkn/rXl4kPzsYDHkPVr6s8OAWP6MXfVA14R31yGQuo/19D7foc4YjVl5/CPo3lZdEX6v2P8p6tWe7LZkbbjjCs1VX0bXwg2xYp4KXTRiWf9PnrgKoDGtX0nODkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758117734; c=relaxed/simple; bh=h36fVH5emtVkv73ZElXIXZ6NtrpKkOFLq+ychKgkihU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LX1s2iZUtraLJwWuvOc7q5a1WOcyp8BxMCqQkfuo3Rg8gfXcg/+m5UOsGt0cwskeIIy+pAmIL66ElC1vZmE7mZ1vzjeX0fVROWubb5N86dMg5FcdyGUvO/KUdYyFlCn4j4Hv0ivmAlHCoCY5DUrOwPQ1FXOvyZDHDHuTpZqLkuQ= 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=ez6n5UPp; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rwGdc1qs; 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="ez6n5UPp"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rwGdc1qs" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1758117726; 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=VDshTHDdyOS+4oK6msGdvXtwIDG3+AYYE2weZr1dlWw=; b=ez6n5UPpSQ6ZNmJCDfByMelo2B56twKfod8kCsWJQ7H0Rg0ZW0/Ul0dS2w0TX1HFZvYyJM mEusXN/bf0OLci8Tv/czFl+DWKUDKkEiNSC3oI7sU9+X9C4qrR2RTy//iNi6xTAGeWhR+8 N6HtEWYvlhpISUAf+PatIXLh47z14HottZvBLFYMLSlcUhulpHR9adRvn5VAMASBw6fC3J 1jqyzvLJKD+NC5UDF/wKQb4Ft7QAkt+cUiiwUG2z9Oamo3QHUzJJMkbOU+1wCEYo3W4/6S 4HdadsAXQrjt8cZPWE106Y3qZG9+ZxNyQoJ8u6ecTOpbRMpzjOyh6juy4dr3NQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1758117726; 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=VDshTHDdyOS+4oK6msGdvXtwIDG3+AYYE2weZr1dlWw=; b=rwGdc1qsu5S5j65PJ7t2hIXwy/yfQ7c2e3ZkcHB66LdLp6bgVTNqEuT/ekKgkLImxxJ9a2 y8SM6YWr76MjHxCQ== Date: Wed, 17 Sep 2025 16:00:25 +0200 Subject: [PATCH v3 23/36] vdso/datastore: Map pages through struct 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: <20250917-vdso-sparc64-generic-2-v3-23-3679b1bc8ee8@linutronix.de> References: <20250917-vdso-sparc64-generic-2-v3-0-3679b1bc8ee8@linutronix.de> In-Reply-To: <20250917-vdso-sparc64-generic-2-v3-0-3679b1bc8ee8@linutronix.de> To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Arnd Bergmann , "David S. Miller" , Andreas Larsson , Nick Alcock , John Stultz , Stephen Boyd , John Paul Adrian Glaubitz , Shuah Khan , Catalin Marinas , Will Deacon , Theodore Ts'o , "Jason A. Donenfeld" , Russell King , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Nagarathnam Muthusamy , Shannon Nelson Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1758117712; l=3281; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=h36fVH5emtVkv73ZElXIXZ6NtrpKkOFLq+ychKgkihU=; b=1Q87PG88XCaYX4KGyp+D/lWyMrgzA9tTWURtmpJ3RbXmhrluuZY5yKr1xn7icSsFx1nd1JDK8 Kfy4uo7mq3hB2beBjRr5EjdOngk6IDs5iYv4FiU/CAfCeAodj3ikfdB X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= An upcoming change will allocate the datapages dynamically instead of as part of the kernel image. Such pages can only be mapped through 'struct page' and not through PFNs. Prepare for the dynamic allocation by mapping through 'struct page'. VM_MIXEDMAP is necessary for the call to vmf_insert_page() in the timens prefault path to work. Signed-off-by: Thomas Wei=C3=9Fschuh --- lib/vdso/datastore.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 7377fcb6e1dfe31d02ffcae371fdf9da069ae4c1..6e5feb4a95b85f5a1cbdced7cde= ddc593fcbad40 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -39,14 +39,15 @@ struct vdso_arch_data *vdso_k_arch_data =3D &vdso_arch_= data_store.data; static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { - struct page *timens_page =3D find_timens_vvar_page(vma); - unsigned long pfn; + struct page *page, *timens_page; + + 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; - pfn =3D __phys_to_pfn(__pa_symbol(vdso_k_time_data)); + page =3D virt_to_page(vdso_k_time_data); if (timens_page) { /* * Fault in VVAR page too, since it will be accessed @@ -56,10 +57,10 @@ static vm_fault_t vvar_fault(const struct vm_special_ma= pping *sm, vm_fault_t err; =20 addr =3D vmf->address + VDSO_TIMENS_PAGE_OFFSET * PAGE_SIZE; - err =3D vmf_insert_pfn(vma, addr, pfn); + err =3D vmf_insert_page(vma, addr, page); if (unlikely(err & VM_FAULT_ERROR)) return err; - pfn =3D page_to_pfn(timens_page); + page =3D timens_page; } break; case VDSO_TIMENS_PAGE_OFFSET: @@ -72,24 +73,25 @@ static vm_fault_t vvar_fault(const struct vm_special_ma= pping *sm, */ if (!IS_ENABLED(CONFIG_TIME_NS) || !timens_page) return VM_FAULT_SIGBUS; - pfn =3D __phys_to_pfn(__pa_symbol(vdso_k_time_data)); + page =3D virt_to_page(vdso_k_time_data); break; case VDSO_RNG_PAGE_OFFSET: if (!IS_ENABLED(CONFIG_VDSO_GETRANDOM)) return VM_FAULT_SIGBUS; - pfn =3D __phys_to_pfn(__pa_symbol(vdso_k_rng_data)); + 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; - pfn =3D __phys_to_pfn(__pa_symbol(vdso_k_arch_data)) + - vmf->pgoff - VDSO_ARCH_PAGES_START; + page =3D virt_to_page(vdso_k_arch_data) + vmf->pgoff - VDSO_ARCH_PAGES_S= TART; break; default: return VM_FAULT_SIGBUS; } =20 - return vmf_insert_pfn(vma, vmf->address, pfn); + get_page(page); + vmf->page =3D page; + return 0; } =20 const struct vm_special_mapping vdso_vvar_mapping =3D { @@ -101,7 +103,7 @@ struct vm_area_struct *vdso_install_vvar_mapping(struct= mm_struct *mm, unsigned { return _install_special_mapping(mm, addr, VDSO_NR_PAGES * PAGE_SIZE, VM_READ | VM_MAYREAD | VM_IO | VM_DONTDUMP | - VM_PFNMAP | VM_SEALED_SYSMAP, + VM_MIXEDMAP | VM_SEALED_SYSMAP, &vdso_vvar_mapping); } =20 --=20 2.51.0