linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 Helge Deller <deller@gmx.de>, Andy Lutomirski <luto@kernel.org>,
	 Thomas Gleixner <tglx@linutronix.de>,
	 Vincenzo Frascino <vincenzo.frascino@arm.com>,
	 Anna-Maria Behnsen <anna-maria@linutronix.de>,
	 Frederic Weisbecker <frederic@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,  Theodore Ts'o <tytso@mit.edu>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	 Paul Walmsley <paul.walmsley@sifive.com>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	 Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	 Russell King <linux@armlinux.org.uk>,
	Heiko Carstens <hca@linux.ibm.com>,
	 Vasily Gorbik <gor@linux.ibm.com>,
	 Alexander Gordeev <agordeev@linux.ibm.com>,
	 Christian Borntraeger <borntraeger@linux.ibm.com>,
	 Sven Schnelle <svens@linux.ibm.com>,
	 Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	 Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	 Christophe Leroy <christophe.leroy@csgroup.eu>,
	 Naveen N Rao <naveen@kernel.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	 Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org,  "H. Peter Anvin" <hpa@zytor.com>,
	Arnd Bergmann <arnd@arndb.de>,  Guo Ren <guoren@kernel.org>
Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org, loongarch@lists.linux.dev,
	linux-s390@vger.kernel.org, linux-mips@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org,
	"Nam Cao" <namcao@linutronix.de>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	linux-csky@vger.kernel.org
Subject: [PATCH v3 01/18] x86/vdso: Fix latent bug in vclock_pages calculation
Date: Tue, 04 Feb 2025 13:05:33 +0100	[thread overview]
Message-ID: <20250204-vdso-store-rng-v3-1-13a4669dfc8c@linutronix.de> (raw)
In-Reply-To: <20250204-vdso-store-rng-v3-0-13a4669dfc8c@linutronix.de>

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>
---
 arch/x86/entry/vdso/vdso-layout.lds.S | 2 +-
 arch/x86/entry/vdso/vma.c             | 2 +-
 arch/x86/include/asm/vdso/vsyscall.h  | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
index 872947c1004c35c006f7508eac7dff251c286aeb..918606ff92a988b14f5e64f984750ae04b3b6ede 100644
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/vdso-layout.lds.S
@@ -24,7 +24,7 @@ SECTIONS
 
 	timens_page  = vvar_start + PAGE_SIZE;
 
-	vclock_pages = vvar_start + VDSO_NR_VCLOCK_PAGES * PAGE_SIZE;
+	vclock_pages = VDSO_VCLOCK_PAGES_START(vvar_start);
 	pvclock_page = vclock_pages + VDSO_PAGE_PVCLOCK_OFFSET * PAGE_SIZE;
 	hvclock_page = vclock_pages + VDSO_PAGE_HVCLOCK_OFFSET * PAGE_SIZE;
 
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 39e6efc1a9cab760b8a65e4b02c624e8c75244b5..aa62949335ecec3765d3b46eac7f7b83be5efdda 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -290,7 +290,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
 	}
 
 	vma = _install_special_mapping(mm,
-				       addr + (__VVAR_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE,
+				       VDSO_VCLOCK_PAGES_START(addr),
 				       VDSO_NR_VCLOCK_PAGES * PAGE_SIZE,
 				       VM_READ|VM_MAYREAD|VM_IO|VM_DONTDUMP|
 				       VM_PFNMAP,
diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h
index 37b4a70559a8228601203fe7b99b9ddfc3d94f1b..88b31d4cdfaf331d2d597981d3f8ee0c5a339085 100644
--- a/arch/x86/include/asm/vdso/vsyscall.h
+++ b/arch/x86/include/asm/vdso/vsyscall.h
@@ -6,6 +6,7 @@
 #define __VVAR_PAGES	4
 
 #define VDSO_NR_VCLOCK_PAGES	2
+#define VDSO_VCLOCK_PAGES_START(_b)	((_b) + (__VVAR_PAGES - VDSO_NR_VCLOCK_PAGES) * PAGE_SIZE)
 #define VDSO_PAGE_PVCLOCK_OFFSET	0
 #define VDSO_PAGE_HVCLOCK_OFFSET	1
 

-- 
2.48.1


  reply	other threads:[~2025-02-04 12:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04 12:05 [PATCH v3 00/18] vDSO: Introduce generic data storage Thomas Weißschuh
2025-02-04 12:05 ` Thomas Weißschuh [this message]
2025-02-04 12:05 ` [PATCH v3 02/18] parisc: Remove unused symbol vdso_data Thomas Weißschuh
2025-02-05 18:06   ` Helge Deller
2025-02-04 12:05 ` [PATCH v3 03/18] vdso: Introduce vdso/align.h Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 04/18] vdso: Rename included Makefile Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 05/18] vdso: Add generic time data storage Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 06/18] vdso: Add generic random " Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 07/18] vdso: Add generic architecture-specific " Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 08/18] arm64: vdso: Switch to generic storage implementation Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 09/18] riscv: " Thomas Weißschuh
2025-02-22  8:17   ` Xi Ruoyao
2025-02-22 10:14     ` Thomas Gleixner
2025-02-04 12:05 ` [PATCH v3 10/18] LoongArch: vDSO: " Thomas Weißschuh
2025-02-22  8:20   ` Xi Ruoyao
2025-02-04 12:05 ` [PATCH v3 11/18] arm: vdso: " Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 12/18] s390/vdso: " Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 13/18] MIPS: vdso: " Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 14/18] powerpc/vdso: " Thomas Weißschuh
2025-02-05  8:50   ` Christophe Leroy
2025-02-04 12:05 ` [PATCH v3 15/18] x86/vdso: " Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 16/18] x86/vdso/vdso2c: Remove page handling Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 17/18] vdso: Remove remnants of architecture-specific random state storage Thomas Weißschuh
2025-02-04 12:05 ` [PATCH v3 18/18] vdso: Remove remnants of architecture-specific time storage Thomas Weißschuh
2025-02-06  9:31 ` [PATCH v3 00/18] vDSO: Introduce generic data storage David Woodhouse
2025-02-06 10:59   ` Thomas Weißschuh
2025-02-07 10:15     ` David Woodhouse
2025-02-14 11:34   ` Thomas Gleixner
2025-02-14 12:04     ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250204-vdso-store-rng-v3-1-13a4669dfc8c@linutronix.de \
    --to=thomas.weissschuh@linutronix.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=Jason@zx2c4.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anna-maria@linutronix.de \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=borntraeger@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dave.hansen@linux.intel.com \
    --cc=deller@gmx.de \
    --cc=frederic@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=guoren@kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=hpa@zytor.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=loongarch@lists.linux.dev \
    --cc=luto@kernel.org \
    --cc=maddy@linux.ibm.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=namcao@linutronix.de \
    --cc=naveen@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=svens@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=tsbogend@alpha.franken.de \
    --cc=tytso@mit.edu \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).