From patchwork Thu Oct 10 07:01:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13829746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47E4FCF07BF for ; Thu, 10 Oct 2024 08:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NOmDYcigYQIrIJIh3Um8635h5qr4veQV5uL1dAIYrXA=; b=3Hf/Rpsw+HmUm3cd2YEsuWiuJ5 WDRDo7/94J+EjzNEG2FY47qBmiWzOzPdE1/8/mTwyp+a/ITAS9CBQvC/3NOBD4EY58AJUR4B/7Kv9 r3dwJFLoiKHbH3GBR/BzctPpmixQfoizbGCcu/IVqd0bFYjxgz7itsYaKdW75EaFpZNNzuSUflSKL ItItyfHt3sqD76ZMgiwzPbWKZIwyR0yfxtHgqQcKzmOQTdycksT0hcIC6s1K0e28/6JRZXVNsctki MnrvxHbI+zZuWI23/DNfl88+UVPGkwAGXMvxch7eVqdfGYVRrgMtFYn8an56HIQ54J1BjjzBBdt1u RKfs1nHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syoZd-0000000C0xg-0kv0; Thu, 10 Oct 2024 08:31:05 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1synBj-0000000BlnB-1A3U; Thu, 10 Oct 2024 07:02:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Cc:To:In-Reply-To:References:Message-Id :Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender :Reply-To:Content-ID:Content-Description; bh=NOmDYcigYQIrIJIh3Um8635h5qr4veQV5uL1dAIYrXA=; b=dRZzuCYrRNyMgQx4eLMUr2pWFs lgQ9I4/g0u4iaCXKluWCPgfm1HTq5e+KY208+99rvl82pW4KY8zYcKS/0wPp0C0bSUJ2uOqwmm4rZ TBpbfDBwUdf2GTDePQioKlL3hceBpZiGl74zR5GA3tzdCwTAaBSqhu/F+T9eA4W8+/N4MrcdrjuSb WUsfgrQyt6tWtBbOvtm2bgadcg5yFqgQiXE/gkN3wqKNgR2dZhGxbGDxZupS8yHtDLmYeNY70WTCd B/6xtS5WyXZ5lmHxyEw3jlgV3Egu0fQA9BKNMB1QPdBgL3ymVQaHiS1xw3y3DRfSaa/0tAhX4NsDo IhRzkutw==; Received: from galois.linutronix.de ([193.142.43.55]) by casper.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1synBe-00000006yEb-35h4; Thu, 10 Oct 2024 07:02:18 +0000 From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1728543730; 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=NOmDYcigYQIrIJIh3Um8635h5qr4veQV5uL1dAIYrXA=; b=SVOAmEfpcB9zjCSlIl/abBlZtdgNslJZDJhREX69+DVllRbdyJNzuQ9AUCZ75N6Gz4WpZ7 ZzujaAdmYucVDATv5ONGlJ2963QEzqFmk/Rk9S6pFIMYiCxodZILexuFmlQMMzMDNC+87s K0BdiS1EdKrWR0R5MRBmx7Ffm4zulKbHUGftMJBMzRtA0nmpseK4qzdOKsuVVkSxDG2VHq lHdzYfeiBMnlcxyrOurvyj6FQlKxtzMxqhO2rciK5mFv1Nkp817+IPI2195wt4Q35Br1Ea wqlXmTuoPsoo1NFKXetYn4Ucz4lsPC0KyLg6pbZvs6LOWRxmNNASWOz5JhGhGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1728543730; 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=NOmDYcigYQIrIJIh3Um8635h5qr4veQV5uL1dAIYrXA=; b=fxHYPA0y490ySRRaI+Ew/229aCO/TeUTWvw3My8s0Y/ybAlV0Dr/e+mn6NyTne6zMb0eLm w824UqsUTq7vi+BA== Date: Thu, 10 Oct 2024 09:01:18 +0200 Subject: [PATCH 16/28] x86: vdso: Access rng vdso data without vvar.h MIME-Version: 1.0 Message-Id: <20241010-vdso-generic-base-v1-16-b64f0842d512@linutronix.de> References: <20241010-vdso-generic-base-v1-0-b64f0842d512@linutronix.de> In-Reply-To: <20241010-vdso-generic-base-v1-0-b64f0842d512@linutronix.de> To: Guo Ren , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Russell King , Huacai Chen , WANG Xuerui , Theodore Ts'o , "Jason A. Donenfeld" , Thomas Bogendoerfer , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Vincenzo Frascino Cc: Christophe Leroy , linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, =?utf-8?q?Thoma?= =?utf-8?q?s_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1728543717; l=2664; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=mPoW5wkTlEwrk7j/HBgEku1axNP1bE6//krdhLeEj6A=; b=SOS85n3wR1QQHupApY/YV5xsjsehWzr0JxWLt8ReYzlvQC1/64wff4+HN/GVvYTspFT1+NgJm f2EbWP1fw2vAOLJykZQlYW9djXtP20HkUIkKEWSQ98SEQdV4MsIKmia X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_080215_544226_2F3C5C2E X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The vdso_rng_data is at a well-known offset in the vvar page. Make use of this invariant to remove the usage of vvar.h. Signed-off-by: Thomas Weißschuh --- arch/x86/entry/vdso/vdso-layout.lds.S | 2 ++ arch/x86/include/asm/vdso/getrandom.h | 8 ++++---- arch/x86/include/asm/vvar.h | 5 ----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S index 51c0cc0119748dda0f29d577197c520f272fd02f..acce60732e541f49dfc21d75e1b525c8a74f2341 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -24,6 +24,8 @@ SECTIONS #include #undef EMIT_VVAR + vdso_rng_data = vvar_page + __VDSO_RND_DATA_OFFSET; + pvclock_page = vvar_start + PAGE_SIZE; hvclock_page = vvar_start + 2 * PAGE_SIZE; timens_page = vvar_start + 3 * PAGE_SIZE; diff --git a/arch/x86/include/asm/vdso/getrandom.h b/arch/x86/include/asm/vdso/getrandom.h index d0713c829254cc8172c5903a1fdba168b52ff1ea..2bf9c0e970c3e7d2a2ddfcb1d007cb73da200494 100644 --- a/arch/x86/include/asm/vdso/getrandom.h +++ b/arch/x86/include/asm/vdso/getrandom.h @@ -8,7 +8,6 @@ #ifndef __ASSEMBLY__ #include -#include /** * getrandom_syscall - Invoke the getrandom() syscall. @@ -28,13 +27,14 @@ static __always_inline ssize_t getrandom_syscall(void *buffer, size_t len, unsig return ret; } -#define __vdso_rng_data (VVAR(_vdso_rng_data)) +extern struct vdso_rng_data vdso_rng_data + __attribute__((visibility("hidden"))); static __always_inline const struct vdso_rng_data *__arch_get_vdso_rng_data(void) { if (IS_ENABLED(CONFIG_TIME_NS) && __arch_get_vdso_data()->clock_mode == VDSO_CLOCKMODE_TIMENS) - return (void *)&__vdso_rng_data + ((void *)&timens_page - (void *)__arch_get_vdso_data()); - return &__vdso_rng_data; + return (void *)&vdso_rng_data + ((void *)&timens_page - (void *)__arch_get_vdso_data()); + return &vdso_rng_data; } #endif /* !__ASSEMBLY__ */ diff --git a/arch/x86/include/asm/vvar.h b/arch/x86/include/asm/vvar.h index fe3434d3b5b1eef806e8328b86650e001b177de2..b605914f4d4347c16344e5b5e063697538d4895e 100644 --- a/arch/x86/include/asm/vvar.h +++ b/arch/x86/include/asm/vvar.h @@ -62,11 +62,6 @@ extern char __vvar_page; DECLARE_VVAR(0, struct vdso_data, _vdso_data) -#if !defined(_SINGLE_DATA) -#define _SINGLE_DATA -DECLARE_VVAR_SINGLE(__VDSO_RND_DATA_OFFSET, struct vdso_rng_data, _vdso_rng_data) -#endif - #undef DECLARE_VVAR #undef DECLARE_VVAR_SINGLE