Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/vdso: Fix latent bug in vclock_pages calculation

The vclock pages are *after* the non-vclock pages. Currently there are both
two vclock and two non-vclock pages so the existing logic works by
accident. As soon as the number of pages changes it will break however.
This will be the case with the introduction of the generic vDSO data
storage.

Use a macro to keep the calculation understandable and in sync between
the linker script and mapping code.

Fixes: e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250204-vdso-store-rng-v3-1-13a4669dfc8c@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
3ef32d90 a64dcfb4

+3 -2
+1 -1
arch/x86/entry/vdso/vdso-layout.lds.S
··· 24 24 25 25 timens_page = vvar_start + PAGE_SIZE; 26 26 27 - vclock_pages = vvar_start + VDSO_NR_VCLOCK_PAGES * PAGE_SIZE; 27 + vclock_pages = VDSO_VCLOCK_PAGES_START(vvar_start); 28 28 pvclock_page = vclock_pages + VDSO_PAGE_PVCLOCK_OFFSET * PAGE_SIZE; 29 29 hvclock_page = vclock_pages + VDSO_PAGE_HVCLOCK_OFFSET * PAGE_SIZE; 30 30
+1 -1
arch/x86/entry/vdso/vma.c
··· 290 290 } 291 291 292 292 vma = _install_special_mapping(mm, 293 - addr + (__VVAR_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE, 293 + VDSO_VCLOCK_PAGES_START(addr), 294 294 VDSO_NR_VCLOCK_PAGES * PAGE_SIZE, 295 295 VM_READ|VM_MAYREAD|VM_IO|VM_DONTDUMP| 296 296 VM_PFNMAP,
+1
arch/x86/include/asm/vdso/vsyscall.h
··· 6 6 #define __VVAR_PAGES 4 7 7 8 8 #define VDSO_NR_VCLOCK_PAGES 2 9 + #define VDSO_VCLOCK_PAGES_START(_b) ((_b) + (__VVAR_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE) 9 10 #define VDSO_PAGE_PVCLOCK_OFFSET 0 10 11 #define VDSO_PAGE_HVCLOCK_OFFSET 1 11 12