Skip to content

Commit 3ef32d9

Browse files
t-8chKAGA-KOKO
authored andcommitted
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: e93d252 ("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
1 parent a64dcfb commit 3ef32d9

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

arch/x86/entry/vdso/vdso-layout.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SECTIONS
2424

2525
timens_page = vvar_start + PAGE_SIZE;
2626

27-
vclock_pages = vvar_start + VDSO_NR_VCLOCK_PAGES * PAGE_SIZE;
27+
vclock_pages = VDSO_VCLOCK_PAGES_START(vvar_start);
2828
pvclock_page = vclock_pages + VDSO_PAGE_PVCLOCK_OFFSET * PAGE_SIZE;
2929
hvclock_page = vclock_pages + VDSO_PAGE_HVCLOCK_OFFSET * PAGE_SIZE;
3030

arch/x86/entry/vdso/vma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
290290
}
291291

292292
vma = _install_special_mapping(mm,
293-
addr + (__VVAR_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE,
293+
VDSO_VCLOCK_PAGES_START(addr),
294294
VDSO_NR_VCLOCK_PAGES * PAGE_SIZE,
295295
VM_READ|VM_MAYREAD|VM_IO|VM_DONTDUMP|
296296
VM_PFNMAP,

arch/x86/include/asm/vdso/vsyscall.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define __VVAR_PAGES 4
77

88
#define VDSO_NR_VCLOCK_PAGES 2
9+
#define VDSO_VCLOCK_PAGES_START(_b) ((_b) + (__VVAR_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE)
910
#define VDSO_PAGE_PVCLOCK_OFFSET 0
1011
#define VDSO_PAGE_HVCLOCK_OFFSET 1
1112

0 commit comments

Comments
 (0)