From patchwork Thu Aug 22 07:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13772837 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 D09F2C3DA4A for ; Thu, 22 Aug 2024 07:14:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3C8880014; Thu, 22 Aug 2024 03:14:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9F1380012; Thu, 22 Aug 2024 03:14:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACB8C80014; Thu, 22 Aug 2024 03:14:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 855D280012 for ; Thu, 22 Aug 2024 03:14:57 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4F6EF1613A4 for ; Thu, 22 Aug 2024 07:14:57 +0000 (UTC) X-FDA: 82479019434.20.3B8667B Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by imf04.hostedemail.com (Postfix) with ESMTP id 3424E40019 for ; Thu, 22 Aug 2024 07:14:54 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf04.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724310805; 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=X9eQxluLDiPLeH9ltVew3qYuePl2JQJJyf/L9RkRD5I=; b=JtI2rUbO/ha8ZJMZU3Mz+xVClbbZtLudiq5L+nMvMQygslUbcxDjd8rmSBGEb77DRcOvvi o3s9YiWXchAIA/pPI3kOY0Jb27Ujthr1rM4NvPgGsxleImGmf9z0L0/hoPkKwWCli7hsMx K/ZBVxvIPypLSxi+BcIAbB+n0wcnyso= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724310805; a=rsa-sha256; cv=none; b=nHEAo09Jw00Exs/or2K8ZOSzJDHeBECJO2BaJ9gxgAYSDDpPhBK4Hq47svH0jxjNrMg4vV +9gMo44PJiS5S5QpvgE2NeK+94WrUAj8vUyzD+VacUrvSw9mU7OzlT9bJBJQdFafUozbak 8JL5NxPMm5P7FEfkBLACf3tI3OgeXck= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf04.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.235.10 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4WqDvP4Td1z9sT1; Thu, 22 Aug 2024 09:13:37 +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 09leES4wh1IT; Thu, 22 Aug 2024 09:13:37 +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 4WqDvP3ZyDz9sSy; Thu, 22 Aug 2024 09:13:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 677238B77E; Thu, 22 Aug 2024 09:13:37 +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 RlobwgkX-7ZS; Thu, 22 Aug 2024 09:13:37 +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 57A568B763; Thu, 22 Aug 2024 09:13:36 +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 14/17] selftests: vdso: Make test_vdso_getrandom look for the right vDSO function Date: Thu, 22 Aug 2024 09:13:22 +0200 Message-ID: <04d1de23a2ff14e2709edd8b75e27b81d703bc57.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=1724310794; l=2750; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=XmrEpCsMzE9+kz6qQUG5kHUCZS2KlgNDovuZDzi1tW8=; b=OQ+cTCj7yV9Xo8q0GnJliOhCQVzFZ+ijay4M06NYygaEBLMtMi7pCe4Q4I/Ci+O/oMyq9e4UF iUvY6HCYUMlDrWIesk4eenuoXEY5x27+R68IZY9KDwMCYTEXHBIsX+v X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3424E40019 X-Stat-Signature: kkquxt8zgwea5tcsk9adgjr4o1p11e13 X-Rspam-User: X-HE-Tag: 1724310894-138110 X-HE-Meta: U2FsdGVkX1/kd0PuWmIDHPLJlunbPoCjFFA85NDbvL41h85FXv4h6p5pfB4+fK0PTXU/ma+B1CNn3ci94IzbUl9kOJE4ppZzpEyssg/JU+ZRsIajTVzIvMyDERhHBzwziAbPHfg0YTNWFlPOnVkkaNSw2vgbVZzg5pUKDvgQg68THYl7bauHbeatthXiOMdxbyh4w6hiJwoGYz6JW+fOIjvUQlHNhWdVSJ649dkiyWPWLK4WmfaNdmCd/ey3d3y69Ppyg/kzu9NAjo6P+cPd9eDzkGVeAEwrV0kgDvEtTkYX6RuSXs6wBRe/rijDBWQLVUJF770j4IcjwjoIraxVfkUegzUD10N+Xs5KBWcX9HMZdxTFj3hrbjWB7rKFLmxUPKqnrSTpLjhNuMZiL+vIs0GWrVWwkLpUuvzOYFLeZqeu9vrN/0dPzxd4M6OpzmwIq3yd0o6zLBe3Av3SOL7vefeIisl+KviDvkQw3ztmJiUpm7/D25vkqNb7RqovnvUD8Kep14m17q1/G+LGPw/yBMhCfJkTBU3nbJCBbYKFfXYGv1tRp16LwCyNvTPm8e08VAO0GK99qVZTqY/MSxdvzioXePR3rvtjbfHK9OE6DAuk0CWpY8F/rI6Ka0y/z4XvExmFWTDTxZaAvrnWhkUhkrPtg6vUd/KHGlZS11z+SamDbD7Qg9YKYGA3q7+KSKzl4OBqqb/8VF6Lbl9Rtmv9ZOU/VZNYTffA9FCovMa5rhse0jBJtrCc5LZLYJpuVnlUogr7UGB/d9OjwvpEINIeI7NJXbJtmYC3td1o9YwPvJDkcpE+nPRY6N9NyLqmn8jU50pJH7NQH6FjlVMHuml+absa/Ny3hP/o65V4M+AiHHPxFvrHGH3Vaw5Ehr875XDe0A2pLKhhYSvtnH7onHtYvH6ff3SHxuMp1biIvLU2EhhlDO5yzSWgfNhA7uFBNv1ex+R7vgRdg2cZMx4O1un +pzFg2bB 2fXquQDWCbr4IuEsjGncnBriFymGUtXU0ylAZG9VR1dIj77WJH8nuikF+XKXgQaEZaq+oi75oWEhlRAMOCM1Ti1K9pOF5f4dG1jrINZt35KV7cUSD3PGBTY24bZbglY0UNgkBSPN2UPaJSLsd8CtfHY6xvatUg1i8HSiDzdIV8kLPLnU= 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: Don't hard-code x86 specific names, use vdso_config definitions to find the correct function matching the architecture. Add random VDSO function names in names[][]. Remove the #ifdef CONFIG_VDSO32, having the name there all the time is harmless and guaranties a steady index for following strings. Signed-off-by: Christophe Leroy --- tools/testing/selftests/vDSO/vdso_config.h | 8 +++----- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 8 ++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h index 00bfed6e4922..740ce8c98d2e 100644 --- a/tools/testing/selftests/vDSO/vdso_config.h +++ b/tools/testing/selftests/vDSO/vdso_config.h @@ -68,16 +68,15 @@ static const char *versions[7] = { "LINUX_5.10" }; -static const char *names[2][6] = { +static const char *names[2][7] = { { "__kernel_gettimeofday", "__kernel_clock_gettime", "__kernel_time", "__kernel_clock_getres", "__kernel_getcpu", -#if defined(VDSO_32BIT) "__kernel_clock_gettime64", -#endif + "__kernel_getrandom", }, { "__vdso_gettimeofday", @@ -85,9 +84,8 @@ static const char *names[2][6] = { "__vdso_time", "__vdso_clock_getres", "__vdso_getcpu", -#if defined(VDSO_32BIT) "__vdso_clock_gettime64", -#endif + "__vdso_getrandom", }, }; diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c index 05122425a873..02bcffc23e0c 100644 --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c @@ -21,6 +21,7 @@ #include "../kselftest.h" #include "parse_vdso.h" +#include "vdso_config.h" #ifndef timespecsub #define timespecsub(tsp, usp, vsp) \ @@ -107,6 +108,9 @@ static void vgetrandom_put_state(void *state) static void vgetrandom_init(void) { + const char *version = versions[VDSO_VERSION]; + const char **name = (const char **)&names[VDSO_NAMES]; + if (pthread_key_create(&grnd_ctx.key, vgetrandom_put_state) != 0) return; unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); @@ -115,9 +119,9 @@ static void vgetrandom_init(void) exit(KSFT_SKIP); } vdso_init_from_sysinfo_ehdr(sysinfo_ehdr); - grnd_ctx.fn = (__typeof__(grnd_ctx.fn))vdso_sym("LINUX_2.6", "__vdso_getrandom"); + grnd_ctx.fn = (__typeof__(grnd_ctx.fn))vdso_sym(version, name[6]); if (!grnd_ctx.fn) { - printf("__vdso_getrandom is missing!\n"); + printf("%s is missing!\n", name[6]); exit(KSFT_FAIL); } if (grnd_ctx.fn(NULL, 0, 0, &grnd_ctx.params, ~0UL) != 0) {