From 7557273419dd618df6d83ed37449b0e5918fd501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 30 Jun 2026 09:31:56 +0200 Subject: [PATCH] vdso/datastore: Map pages in terms of the faults pgoff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Thomas Gleixner Tested-by: Nam Cao Link: https://patch.msgid.link/20260630-vdso-mlockall-v4-2-6c93708ce723@linutronix.de --- 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 = (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;