From patchwork Fri Aug 30 15:57:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13785296 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 AF867CA1005 for ; Fri, 30 Aug 2024 15:57:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB796B0186; Fri, 30 Aug 2024 11:57:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29A4F6B0187; Fri, 30 Aug 2024 11:57:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1623C6B0188; Fri, 30 Aug 2024 11:57:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EBE096B0186 for ; Fri, 30 Aug 2024 11:57:21 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9DC7E140ED3 for ; Fri, 30 Aug 2024 15:57:21 +0000 (UTC) X-FDA: 82509366282.28.B272769 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf28.hostedemail.com (Postfix) with ESMTP id 7238AC0002 for ; Fri, 30 Aug 2024 15:57:19 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.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=1725033349; 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:references; bh=vjyCJEohfF8T6frh9+utcYWG5B1rPS3HHzOAAE4Yf8k=; b=tNx8ymidZ/bl4TE7DkxnI6rJv2ZBcu5DiSOKRpPDhuAkhdnXAQIMQXTaIpOZ/LYMPJod1s 7eSFk6CvNHBB021CpKBPhN+iGLdawJkpxr7pXvMg7soBmAjbir7prZdnjm/PTgacGGpGO8 jdLxnuqQR76Ms8S3fotml4OciANsU38= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725033349; a=rsa-sha256; cv=none; b=1bP5eTEJrObqxsnZ+TnmLOFttZBhqHuObqPtBPaJh4U5jHKmLWuKdy+g8Jpngd4zS0F5cI +HpHPiudoW+2eNVPXl7M3X2Hqtn/PyYR/UGfn/zb4mYHn8NYCEuMrHzHxbVS4FvH/lUYpi 5KQ9pXKsjqlzalvoBxr8sEeB2agEy1I= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.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 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4WwN7x0kQwz9sS8; Fri, 30 Aug 2024 17:57:17 +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 mymjIuAY4EBv; Fri, 30 Aug 2024 17:57:17 +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 4WwN7w6rsfz9sS7; Fri, 30 Aug 2024 17:57:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D8B458B799; Fri, 30 Aug 2024 17:57:16 +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 CPmUjCYwGEVP; Fri, 30 Aug 2024 17:57:16 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.234.133]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A89FC8B764; Fri, 30 Aug 2024 17:57:15 +0200 (CEST) From: Christophe Leroy To: Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Shuah Khan , "Jason A . Donenfeld" Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, Adhemerval Zanella , Xi Ruoyao Subject: [PATCH v3 0/5] Wire up getrandom() vDSO implementation on powerpc Date: Fri, 30 Aug 2024 17:57:04 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1725033425; l=3371; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=y3iwLZ6Sa8VJum04nYQaErSpQ5CPdwViE691hLVfI+o=; b=NRHCstSidDvuiokedYQKGefeU1iTW0BD0L3KzlxjbIajJ3Ub+7iTxmRzio38XlxFBdVXoBJ9x Gr7YMgiPmZBCG4DIWRtCC1DzycecQa7YDwArX2NN0WmY3s+K89z/7l4 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-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1svoDLQ+il+14bv793e7zU/kDtBFy Cvq8pOgI 1LLlBOLJYIEkgyf3wO3c8x/I8wCA+MIVIsAig69DWhWiqQKaGnRxj8FWCHHUEJQtM361ZQU7k6BUi44XoPQzaCzZIowmF9V8Otip8Ln3MUxLxVN+wY1Cz/GP5jwasI19Xi/CHtP3b+2Rb5Vp2fs67voDtdA== 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: This series wires up getrandom() vDSO implementation on powerpc. Tested on PPC32 on real hardware. Tested on PPC64 (both BE and LE) on QEMU: Performance on powerpc 885: ~# ./vdso_test_getrandom bench-single vdso: 25000000 times in 62.938002291 seconds libc: 25000000 times in 535.581916866 seconds syscall: 25000000 times in 531.525042806 seconds Performance on powerpc 8321: ~# ./vdso_test_getrandom bench-single vdso: 25000000 times in 16.899318858 seconds libc: 25000000 times in 131.050596522 seconds syscall: 25000000 times in 129.794790389 seconds Performance on QEMU pseries: ~ # ./vdso_test_getrandom bench-single vdso: 25000000 times in 4.977777162 seconds libc: 25000000 times in 75.516749981 seconds syscall: 25000000 times in 86.842242014 seconds In order to run selftests, some fixes are needed, see https://lore.kernel.org/linuxppc-dev/6c5da802e72befecfa09046c489aa45d934d611f.1725020674.git.christophe.leroy@csgroup.eu/ Those selftest fixes are independant and are not required to apply and use this series. Changes in v3: - Rebased on recent random git tree (0c7e00e22c21) - Fixed build failures reported by robots around VM_DROPPABLE - Fixed crash on PPC64 due to clobbered r13 by not using r13 anymore (saving it was not enough for signals). - Split final patch in two, first for PPC32, second for PPC64 - Moved selftest fixes out of this series Changes in v2: - Define VM_DROPPABLE for powerpc/32 - Fixes generic vDSO getrandom headers to enable CONFIG_COMPAT build. - Fixed size of generation counter - Fixed selftests to work on non x86 architectures Christophe Leroy (5): mm: Define VM_DROPPABLE for powerpc/32 powerpc/vdso32: Add crtsavres powerpc/vdso: Refactor CFLAGS for CVDSO build powerpc/vdso: Wire up getrandom() vDSO implementation on PPC32 powerpc/vdso: Wire up getrandom() vDSO implementation on PPC64 arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/asm-compat.h | 8 + arch/powerpc/include/asm/mman.h | 2 +- arch/powerpc/include/asm/vdso/getrandom.h | 54 ++++ arch/powerpc/include/asm/vdso/vsyscall.h | 6 + arch/powerpc/include/asm/vdso_datapage.h | 2 + arch/powerpc/kernel/asm-offsets.c | 1 + arch/powerpc/kernel/vdso/Makefile | 57 ++-- arch/powerpc/kernel/vdso/getrandom.S | 58 ++++ arch/powerpc/kernel/vdso/gettimeofday.S | 13 - arch/powerpc/kernel/vdso/vdso32.lds.S | 1 + arch/powerpc/kernel/vdso/vdso64.lds.S | 1 + arch/powerpc/kernel/vdso/vgetrandom-chacha.S | 299 +++++++++++++++++++ arch/powerpc/kernel/vdso/vgetrandom.c | 14 + fs/proc/task_mmu.c | 4 +- include/linux/mm.h | 4 +- include/trace/events/mmflags.h | 4 +- tools/arch/powerpc/vdso | 1 + tools/testing/selftests/vDSO/Makefile | 4 + 19 files changed, 492 insertions(+), 42 deletions(-) create mode 100644 arch/powerpc/include/asm/vdso/getrandom.h create mode 100644 arch/powerpc/kernel/vdso/getrandom.S create mode 100644 arch/powerpc/kernel/vdso/vgetrandom-chacha.S create mode 100644 arch/powerpc/kernel/vdso/vgetrandom.c create mode 120000 tools/arch/powerpc/vdso