From patchwork Thu Aug 22 07:13:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13772842 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 874EDC531DF for ; Thu, 22 Aug 2024 07:15:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68AAF80018; Thu, 22 Aug 2024 03:15:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60DE480017; Thu, 22 Aug 2024 03:15:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4620080018; Thu, 22 Aug 2024 03:15:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2224F80017 for ; Thu, 22 Aug 2024 03:15:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D59C3140558 for ; Thu, 22 Aug 2024 07:15:09 +0000 (UTC) X-FDA: 82479019938.15.9CE0040 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf06.hostedemail.com (Postfix) with ESMTP id A590518002C for ; Thu, 22 Aug 2024 07:15:07 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.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=1724310827; 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=sZGsX/eQOLr/fZ79f0S/sX6lLhFKgJ8hlWo2Id87YPg=; b=x3gTZUs4e49vLNYblfNruHO464CQ06aadKISio7IP8rgIFmSG8gHKfAJiC2ChnaOBZLPTx oxfjDtB/Tk8oRPs6e4l0aUcdqIJYRLzM1CEzvrODVhwtNAJleAa7QLKu16abIhIXqCJzso qN5a+a9RyWgnLe3QNc7Fgh7kSz14+QE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724310827; a=rsa-sha256; cv=none; b=vjulgKC6Yp+nH9wzehpFtQx/LaqKSGc0pibaE1nTyaH6gXeab4A/zSpfFS2PPh2UgVEjPN cTZ4cAL0NhEjy1vbB/qGrXp1mTCAM9/8ibY+cX0l01H+bzm4kGVXBWw+/WGSMNvTIVt75P 0iMTyAB/UIt9Yd1azmdkK1kJK/7ogGU= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.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 4WqDvS5M5gz9sTD; Thu, 22 Aug 2024 09:13:40 +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 5BXvRolJCPmB; Thu, 22 Aug 2024 09:13:40 +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 4WqDvS4Ts4z9sSy; Thu, 22 Aug 2024 09:13:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 898D68B763; Thu, 22 Aug 2024 09:13:40 +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 M06ncktVG1Is; Thu, 22 Aug 2024 09:13:40 +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 7999F8B77D; Thu, 22 Aug 2024 09:13:39 +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 17/17] selftests: vdso: Add support for vdso_test_random for powerpc Date: Thu, 22 Aug 2024 09:13:25 +0200 Message-ID: <7a612370f645d6f8defd4dc8c1ebf31ee39dfb1f.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=1724310795; l=2831; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=yXWU/vOrVCh1tH6IvVskRabYNHCoI2MUD+0kW8f8BRY=; b=KS6Wqd4DIG71241Ra4HKWqyJqfA08PcnWHdqJqXSzHx1GQ2rQRMw4i3n5nKIJ8DUdMbYpgKlH PcZJDDWZcGgD4/4e4J7ugbtDnH9tX2JYCnkXxsBKExFDkk4hm1KeDA9 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A590518002C X-Stat-Signature: 1qs1o3tf4ehy36udtx1ywkhmozyibtci X-HE-Tag: 1724310907-876422 X-HE-Meta: U2FsdGVkX1+EhysMRQfvDRy6bfTL5h43CRrXsusZNQX8B+xAU977bBz8B7kIwlwnZtaLt3ZrB0/r4uNEtLErLmsk77hvuvk/q9hxe4iKexnFxeRNxTad5TEoXTALGVPV4vWY/prSYasqvkicxP5YphtuMbmCv/wg+Krwtsf2ozWNtuwgGMyNFY1tdLYmWkl60i3G36mPVD9c7d1gV6+6HA/Etgm8thaC7rIzlRlszoBtuhcGDR3hT9s/4ZuoLte8ZRhYgZ+axmD7vLPQG5I3dSMNJtBCNq2552jzNLkXwT3Udnh9xTFLzmX3mKUpqniHxh0u5BFk/4PgvxSvPwoWUqxKtIZAGhngXpD+SoxdXSgmcJvXVMuRkvzmTRldtpQtlfMDMcfpUnrjkxXd/0G3BRH+gmMb6NmMPBfIeHDnftuUSnYhMnNeW120jrwO0/lJcrDH65ZHmiQPUk5ICu5Qd8gBMdSUr0uqnOlCb8oNT6+SK0VUOHTTl7HUjd7gF0hw0McHlDg6FVYgFAheop7iU/qwdZochV1DPWVPmjHqI2QRdGbnNipCLn5BP/m5z2FA14ZqCg5C9FVvlE3GzfkLfiiMN2bzIHNMyOrtRAKcpyr2a3p1MGa+KeiIL7th+6DjScp8kPALH3nvTABQWbsXHcHnWggpdpdZoycCFOJsG7TI/Bkm8lMJdMZAhgrWTG24JI94I26ZsNcH9907O7EXPPHW93GxVXw0g/mAoieiILZm/QbKvOOuAL60RntsjiSmmiB8A26+FERpJ3SUJ0bvXjkLA2bz+s8//upEsHF/a4L/9j45J9r2jv6d84paDBejYIwe8XX4L1dHHTPstP+8wTl+x5fgXm7rvCiM8uKTg8ZKmthACluxUw6B0lR6I9vJfBT7VlNvg7jmUS8SzGiwh9ZcVZ7YwU0OZbe5U3trMj5vLrLCAR4ZT2h9nC6xQyjk3mVcnflT5dSYeM+d3V1 I1oMite7 R2ZXWjlU9UhtMWp1Yy7uMOzzfCB7V+UEhZL/urWDHHBUO72YVAlcAbP0PoJV+l/WCqUmIaELc65XfNe/4G/zwsaXlvc74ceYO4kC5b3Ja1I++xbGEDLL5K4e1zM2akQphDzIuZHGwYN29ZuV8DrhleWTBs1zY41q0vBRzF2xZjlOjUx0= 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: Add the necessary symbolic link and tell Makefile to build vdso_test_random for powerpc. In makefile, don't use $(uname_M) which is wrong when cross-building for powerpc on an x86_64. Implement the required VDSO_CALL macro to correctly handle errors. Signed-off-by: Christophe Leroy --- tools/arch/powerpc/vdso | 1 + tools/testing/selftests/vDSO/Makefile | 6 ++++ tools/testing/selftests/vDSO/vdso_call.h | 40 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 120000 tools/arch/powerpc/vdso diff --git a/tools/arch/powerpc/vdso b/tools/arch/powerpc/vdso new file mode 120000 index 000000000000..d31004bf8f55 --- /dev/null +++ b/tools/arch/powerpc/vdso @@ -0,0 +1 @@ +../../../arch/powerpc/kernel/vdso/ \ No newline at end of file diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile index 10ffdda3f2fa..7e7c9fd200d3 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -17,6 +17,12 @@ ifneq ($(SODIUM),) TEST_GEN_PROGS += vdso_test_chacha endif endif +ifeq ($(ARCH),powerpc) +TEST_GEN_PROGS += vdso_test_getrandom +ifneq ($(SODIUM),) +TEST_GEN_PROGS += vdso_test_chacha +endif +endif CFLAGS := -std=gnu99 diff --git a/tools/testing/selftests/vDSO/vdso_call.h b/tools/testing/selftests/vDSO/vdso_call.h index ca5db2220925..2a33c25756dc 100644 --- a/tools/testing/selftests/vDSO/vdso_call.h +++ b/tools/testing/selftests/vDSO/vdso_call.h @@ -7,6 +7,46 @@ #ifndef __VDSO_CALL_H__ #define __VDSO_CALL_H__ +#ifdef __powerpc__ + +#define LOADARGS_5(fn, __arg1, __arg2, __arg3, __arg4, __arg5) do { \ + _r0 = fn; \ + _r3 = (long)__arg1; \ + _r4 = (long)__arg2; \ + _r5 = (long)__arg3; \ + _r6 = (long)__arg4; \ + _r7 = (long)__arg5; \ +} while (0) + +#define VDSO_CALL(fn, nr, args...) ({ \ + register void *_r0 asm ("r0"); \ + register long _r3 asm ("r3"); \ + register long _r4 asm ("r4"); \ + register long _r5 asm ("r5"); \ + register long _r6 asm ("r6"); \ + register long _r7 asm ("r7"); \ + register long _r8 asm ("r8"); \ + register long _rval asm ("r3"); \ + \ + LOADARGS_##nr(fn, args); \ + \ + asm volatile( \ + " mtctr %0\n" \ + " bctrl\n" \ + " bns+ 1f\n" \ + " neg 3, 3\n" \ + "1:" \ + : "+r" (_r0), "=r" (_r3), "+r" (_r4), "+r" (_r5), \ + "+r" (_r6), "+r" (_r7), "+r" (_r8) \ + : "r" (_rval) \ + : "r9", "r10", "r11", "r12", "cr0", "cr1", "cr5", \ + "cr6", "cr7", "xer", "lr", "ctr", "memory" \ + ); \ + _rval; \ +}) + +#else #define VDSO_CALL(fn, nr, args...) fn(args) +#endif #endif