From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60081C531DF for ; Thu, 22 Aug 2024 07:13:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E72336B00FE; Thu, 22 Aug 2024 03:13:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD55D6B01F9; Thu, 22 Aug 2024 03:13:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C27386B01FA; Thu, 22 Aug 2024 03:13:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 97FE66B00FE for ; Thu, 22 Aug 2024 03:13:41 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 50F75A1340 for ; Thu, 22 Aug 2024 07:13:41 +0000 (UTC) X-FDA: 82479016242.24.B7BAA03 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf03.hostedemail.com (Postfix) with ESMTP id 333A120007 for ; Thu, 22 Aug 2024 07:13:38 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724310779; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6SDwL14ZIrZxG7R+BLlX+inC+cmgy6s0nI9uw46bbT0=; b=PYC14P9Iz42EpWU7nfEJiR1z/mt40h5wnnudnu5Zhiu23x5BtfpzlyuG8YUByKWmE1s3o7 oSeEDCGRD+cyFd5cFJAB/eHznxN1TUzwKPcsXfPQkd1WhvweP6EGjehvMZwVvGoNhCllnh k2Ob0epIsnZNOUl0DCGp83+nk9F7Rv4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724310779; a=rsa-sha256; cv=none; b=OYKqbIW/6P3eOOPyJ0V9Vy/+yyl2jl0avIhB5c5cqGM/kMM9MIzDC8Uy9LlL+LodlzteK9 K44kccDc2p7CrMwfcAPYQOP8rcYcmXATguwbIViVdrGW36ILEhBILT/xBtvJAGiN+umxho V9ioYfe5o+C+tGi+eFak9V+AueDiMm8= Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4WqDv96knHz9sSR; Thu, 22 Aug 2024 09:13:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZY8vgATUItE0; Thu, 22 Aug 2024 09:13:25 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4WqDv95q7Yz9sSH; Thu, 22 Aug 2024 09:13:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B59318B77E; Thu, 22 Aug 2024 09:13:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id XTrqY5A4cZMU; Thu, 22 Aug 2024 09:13:25 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (PO16920.IDSI0.si.c-s.fr [192.168.232.181]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9FE3E8B77D; Thu, 22 Aug 2024 09:13:24 +0200 (CEST) From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" , Arnd Bergmann , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Vincenzo Frascino , Shuah Khan Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 03/17] vdso: Add __arch_get_k_vdso_rng_data() Date: Thu, 22 Aug 2024 09:13:11 +0200 Message-ID: <30560b394eaa00fded11fa5bbe5f679c7ffe1714.1724309198.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724310793; l=3615; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=0FkV6ZQv7UmPicI0ISFP55470ytlmKI8lU8exIbKjSc=; b=rfgTJTLJ/AVYzFQ0JlvoCOtXx4fadthoJUp407DtCeMplj9i+sD7+IM9C0ey883rkE5yU2iFJ tg03vMqD5JmCRbRJZ3og1OVFm2FAdigfeIv6Ehg0Ok2plru3FzYH+sf X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 333A120007 X-Stat-Signature: 358aja35ec9mfs635o99iz7dnhihwhd1 X-HE-Tag: 1724310818-257192 X-HE-Meta: U2FsdGVkX1/h2pk01+POdtevckjCIddGbwdIhZ0rs61XX/bWCrvcqH0qlXvxqIJCLhvJSIi5ZmwHPIIhYrXnrgRFX3xGf376HLgJT4qB+BZ0bkGDvR26sQwyUZqGBF8rWDjopZ5y/Q27rZkJ05pdfXjASwh2zizBHY6+VWqVtK6nENQJeQDdjZk1vFu2f2UbDFeEoXvqV2OWPCws9LIR1hlhPHNuwpGyujGlzbeINfkRI3GSrB6mxpCquGrhdFgm9Fwezqdkx3PT6EWmhmAYYPRFqZItkv/HFHIKk4tIM6/I7UO4bPeEPjfNomXEUVHeFazFelf/x6YKLLoJxnWB5Qj0OXCbw1TzPlLMJfHewirntZ4pEw161wajGEO+j1wjguIIIsLk23N7gA+0ttB6cNKX0D04TnnsDX3pVBdMnpXIlwh4FO7isbSLJd50ewnBq/fzLaWb4L39GZ3U3b8ME8M/pAAL3WC37TevD2Pp8qIm3c7wJG6Xwnv0Huj0RccQaysuSAi4ScUgXVi0jcIIrERWI3PuFoPKUeQYEYKCGHRkwwrsYrj5AujdxIaeGKfgnP0h+DYXL7w66wov0GulhgsQw2tKZ2ismDPcnONSEqjqrGaq4RE8TXkk9FRWj7QFpvuQ/N14XWkdqClFNEgXNmNhjdywEeSrsgRjmK5MBGQvmqbhcOd6XXo2dAca29zg0LG5hpl7ObuTtTzuW4wbBTj/C07gDOXXawz3IP98NfQxM5OM1bXtDk7oPlpa2kbC/mSPp516/Y7hqoBsyhIkSsp1ByzAkCIBfdnkGN9R7HESQYcAFUJ2/6XC325/J+YDnOblukQ9HkC+h0UTwrBu6sh0CHlTXqqMJbMWiCeS801VjsRMgZ0v5fO8cQubDq+Xii0rKH7fugEZafYjL9JS2YC123mSrTIze71Vat/GM0XGgEDF3DdsQXaI63Y0/FC92kscgzos3vKNirLfjfS Yff0cQaT hlfXbA8J5pu3BgILDgZQ0UsUleymVYJcXxmOvr70EF+rYLBNxR3qIOqMj/dWASPUgF4qxdIOfH/7dWTY3YRKoeyjPBlJttxcNQU3E3GaVO7MOQZND3weg/zBKWhglMNZFjOdR7pRh4SK/LoyhOiDjPzXXAJFSCNfyRHBaR2Chy8LSbWE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: _vdso_data is specific to x86 and __arch_get_k_vdso_data() is provided so that all architectures can provide the requested pointer. Do the same with _vdso_rng_data, provide __arch_get_k_vdso_rng_data() and don't use x86 _vdso_rng_data directly. Until now vdso/vsyscall.h was only included by time/vsyscall.c but now it will also be included in char/random.c, leading to a duplicate declaration of _vdso_data and _vdso_rng_data. To fix this issue, move declaration in a C file. vma.c looks like the most appropriate candidate. Don't need to replace the definitions in vsyscall.h by declarations as declarations are already in asm/vvar.h Signed-off-by: Christophe Leroy --- v2: Move x86 DEFINE_VVAR(_vdso_data) and DEFINE_VVAR(_vdso_rng_data) in vma.c --- arch/x86/entry/vdso/vma.c | 3 +++ arch/x86/include/asm/vdso/vsyscall.h | 10 +++++++--- drivers/char/random.c | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 6d83ceb7f1ba..b8fed8b8b9cc 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -38,6 +38,9 @@ struct vdso_data *arch_get_vdso_data(void *vvar_page) } #undef EMIT_VVAR +DEFINE_VVAR(struct vdso_data, _vdso_data); +DEFINE_VVAR_SINGLE(struct vdso_rng_data, _vdso_rng_data); + unsigned int vclocks_used __read_mostly; #if defined(CONFIG_X86_64) diff --git a/arch/x86/include/asm/vdso/vsyscall.h b/arch/x86/include/asm/vdso/vsyscall.h index 972415a8be31..67fedf1698b5 100644 --- a/arch/x86/include/asm/vdso/vsyscall.h +++ b/arch/x86/include/asm/vdso/vsyscall.h @@ -9,9 +9,6 @@ #include #include -DEFINE_VVAR(struct vdso_data, _vdso_data); -DEFINE_VVAR_SINGLE(struct vdso_rng_data, _vdso_rng_data); - /* * Update the vDSO data page to keep in sync with kernel timekeeping. */ @@ -22,6 +19,13 @@ struct vdso_data *__x86_get_k_vdso_data(void) } #define __arch_get_k_vdso_data __x86_get_k_vdso_data +static __always_inline +struct vdso_rng_data *__x86_get_k_vdso_rng_data(void) +{ + return &_vdso_rng_data; +} +#define __arch_get_k_vdso_rng_data __x86_get_k_vdso_rng_data + /* The asm-generic header needs to be included after the definitions above */ #include diff --git a/drivers/char/random.c b/drivers/char/random.c index 87fe61295ea1..77968309e2c2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -59,6 +59,7 @@ #ifdef CONFIG_VDSO_GETRANDOM #include #include +#include #endif #include #include @@ -282,7 +283,7 @@ static void crng_reseed(struct work_struct *work) * is ordered with the write above to base_crng.generation. Pairs with * the smp_rmb() before the syscall in the vDSO code. */ - smp_store_release(&_vdso_rng_data.generation, next_gen + 1); + smp_store_release(&__arch_get_k_vdso_rng_data()->generation, next_gen + 1); #endif if (!static_branch_likely(&crng_is_ready)) crng_init = CRNG_READY; @@ -735,7 +736,7 @@ static void __cold _credit_init_bits(size_t bits) queue_work(system_unbound_wq, &set_ready); atomic_notifier_call_chain(&random_ready_notifier, 0, NULL); #ifdef CONFIG_VDSO_GETRANDOM - WRITE_ONCE(_vdso_rng_data.is_ready, true); + WRITE_ONCE(__arch_get_k_vdso_rng_data()->is_ready, true); #endif wake_up_interruptible(&crng_init_wait); kill_fasync(&fasync, SIGIO, POLL_IN); -- 2.44.0