From patchwork Tue Dec 27 13:06:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13082306 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD9DAC46467 for ; Tue, 27 Dec 2022 13:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbiL0NHV (ORCPT ); Tue, 27 Dec 2022 08:07:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231651AbiL0NG4 (ORCPT ); Tue, 27 Dec 2022 08:06:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BEF5277; Tue, 27 Dec 2022 05:06:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 32A9AB8101D; Tue, 27 Dec 2022 13:06:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42AB9C43392; Tue, 27 Dec 2022 13:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672146412; bh=RNcNgyi+XWeNF+WSinst8npBEXg52AmbeM5w3G+O9YA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X1mXjweTTYK8xa39s4cz6r7MbA+2CJZyqC5RKsj+ACMyyIOmfCUJUgL5+UZb4Dul4 fGaNKbhxAIXxZ+ZEXBOoJNXYEF9k/NwjmaM0AQeG8pu+yCkZDnSKbdQkmzN67B8M6M zr0ZU/GH7tvTgK9IzBa920Xed5Yg1aC/tvnebchLf4X/ySqw8cl6suqVwi8fbgtXEd WgStWeGtjRQlTEZ2P6Mxq8adIEM6LeAdXVIsGr5CoNAXy6oZWeMQR7aqv0aTvwQXYa 6S82w3JCzDnkXR4DTapI1NhW0/usghZ2naaIvpISx1gd/WgG9e436GGpwGDxwbcpym lZ2jnAt0IvECA== From: Mark Brown Date: Tue, 27 Dec 2022 13:06:35 +0000 Subject: [PATCH 1/4] kselftest/arm64: Fix syscall-abi for systems without 128 bit SME MIME-Version: 1.0 Message-Id: <20221223-arm64-syscall-abi-sme-only-v1-1-4fabfbd62087@kernel.org> References: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> In-Reply-To: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.12-dev-7ab1d X-Developer-Signature: v=1; a=openpgp-sha256; l=1220; i=broonie@kernel.org; h=from:subject:message-id; bh=RNcNgyi+XWeNF+WSinst8npBEXg52AmbeM5w3G+O9YA=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjqu3l6Oy4cmr1i0AZdD7/l1h/+/8+rwatiqVG6BTH CJpZJdKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY6rt5QAKCRAk1otyXVSH0C0GB/ 41Fa+ye3U2Z+ujAnWV+Wyw58vmNFHQRwErFPW8ILHwKAurwod1ESbL3QB84c6oyxBY0Xm5akg63pKv AHyoOJo0V7ylfEeo+KLhIUf+/j8g5TvTgL4Ao+wuUdR7FniW9n17Nup/g8NpAKE3zNNwK0gFZWBwZ2 K9w8Fh+LI8/LVusdHwE+3xf9EfObLOoFNTXDvrIR5XDFJkzX+shp7IFgdNLowymPJJHaeo4DQ+mAB5 UuFkn34rcrCOzQumrWH9SD6nD+PBk6SVn+K5J+RdJDkSWGj55n+FFmX+PBbUxyNLT4vHB3PnNqdJXG HitVrnB+Lng5mN3x5qHOU90Q67lNzG X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org SME does not mandate any specific VL so we may not have 128 bit SME but the algorithm used for enumerating VLs assumes that we will. Add the required check to ensure that the algorithm terminates. Fixes: 43e3f85523e4 ("kselftest/arm64: Add SME support to syscall ABI test") Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/syscall-abi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/arm64/abi/syscall-abi.c b/tools/testing/selftests/arm64/abi/syscall-abi.c index dd7ebe536d05..ffe719b50c21 100644 --- a/tools/testing/selftests/arm64/abi/syscall-abi.c +++ b/tools/testing/selftests/arm64/abi/syscall-abi.c @@ -390,6 +390,10 @@ static void test_one_syscall(struct syscall_cfg *cfg) sme_vl &= PR_SME_VL_LEN_MASK; + /* Found lowest VL */ + if (sve_vq_from_vl(sme_vl) > sme_vq) + break; + if (sme_vq != sve_vq_from_vl(sme_vl)) sme_vq = sve_vq_from_vl(sme_vl); @@ -461,6 +465,10 @@ int sme_count_vls(void) vl &= PR_SME_VL_LEN_MASK; + /* Found lowest VL */ + if (sve_vq_from_vl(vl) > vq) + break; + if (vq != sve_vq_from_vl(vl)) vq = sve_vq_from_vl(vl); From patchwork Tue Dec 27 13:06:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13082304 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F513C53210 for ; Tue, 27 Dec 2022 13:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231703AbiL0NHW (ORCPT ); Tue, 27 Dec 2022 08:07:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbiL0NG7 (ORCPT ); Tue, 27 Dec 2022 08:06:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5ABA277; Tue, 27 Dec 2022 05:06:57 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3B31FB81012; Tue, 27 Dec 2022 13:06:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54384C433F2; Tue, 27 Dec 2022 13:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672146415; bh=VJMEgISdhkuI2X6kuXk2S8aABLEH627CtkUAogZE4Tc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mJKk0UNx/OIdNPYM8GRw/WPOppSiVJa2OVohLyHudDPLNYvjkINjpiwUHag2KOtrw tzas5cjFO+8VmMBL9umYsngakpDdhJBlJJahSYX91NtpqDobzUCF2w7UwKjSGU3YY5 4HtuXvyA7hm1AUq5WMgRpfWMHd8aPr/XjioMnsA/RTclQiINW9WIbtpcmxeYzXzYNg ++2yMgpFHdgHaREROSKccjyttcyAoRzlrVaPaAekUNZvb82cNklUTToPNTbYcn5YHs 9EAydbHuFVtQjnVXu6gSVy/2z0Si8QwYHc5QrQ6sJ8AS/Oxv6GKuRwSI0pAuMAWYfv pbiYpKfPsdJfg== From: Mark Brown Date: Tue, 27 Dec 2022 13:06:36 +0000 Subject: [PATCH 2/4] kselftest/arm64: Only enumerate VLs once in syscall-abi MIME-Version: 1.0 Message-Id: <20221223-arm64-syscall-abi-sme-only-v1-2-4fabfbd62087@kernel.org> References: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> In-Reply-To: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.12-dev-7ab1d X-Developer-Signature: v=1; a=openpgp-sha256; l=5137; i=broonie@kernel.org; h=from:subject:message-id; bh=VJMEgISdhkuI2X6kuXk2S8aABLEH627CtkUAogZE4Tc=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjqu3mz61xaauKwvQgXATjyBywjrmusGIaI+bDH6jL jEOhnDiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY6rt5gAKCRAk1otyXVSH0FF9CA CC3vEIBMBUUVp08i5MrWy8tU+OyNRXzWG9ap5fvvDNhpEXmB66OPzHcCfWaCvUJLQp1Y2C+MNDcIrs eCFo8S4e32X1hXD+wo67LS6jF4vxIFq0vuarnOujWOIQEg254dA2ANvjD6XXia6EJ3Q70mqWZmPbRY i1mxyqLXplzcFIDnkp/dEk5J+k3mCmiBNo7QhDyTOYUV9okDkay1AnLNsRdUNLTKbV1/3xYpQCitGS kQfNCLva+cnuSsz1apSmtodvMpA4PzV2Sw0fMe8ZnZ9CK3W8tp1IWQJNTg0NtA93a1WNS1QtACJnNo ILlw6LFQshMJMD/cwqiJBGM6AlKKcy X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently syscall-abi not only enumerates the SVE VLs twice while working out how many tests are planned, it also repeats the enumeration process while doing the actual tests. Record the VLs when we enumerate and use that list when we are performing the tests, removing some duplicated logic. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/syscall-abi.c | 95 +++++++++++-------------- 1 file changed, 41 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/arm64/abi/syscall-abi.c b/tools/testing/selftests/arm64/abi/syscall-abi.c index ffe719b50c21..45fdcbe3e909 100644 --- a/tools/testing/selftests/arm64/abi/syscall-abi.c +++ b/tools/testing/selftests/arm64/abi/syscall-abi.c @@ -24,6 +24,11 @@ static int default_sme_vl; +static int sve_vl_count; +static unsigned int sve_vls[SVE_VQ_MAX]; +static int sme_vl_count; +static unsigned int sme_vls[SVE_VQ_MAX]; + extern void do_syscall(int sve_vl, int sme_vl); static void fill_random(void *buf, size_t size) @@ -355,72 +360,55 @@ static bool do_test(struct syscall_cfg *cfg, int sve_vl, int sme_vl, static void test_one_syscall(struct syscall_cfg *cfg) { - int sve_vq, sve_vl; - int sme_vq, sme_vl; + int sve, sme; + int ret; /* FPSIMD only case */ ksft_test_result(do_test(cfg, 0, default_sme_vl, 0), "%s FPSIMD\n", cfg->name); - if (!(getauxval(AT_HWCAP) & HWCAP_SVE)) - return; - - for (sve_vq = SVE_VQ_MAX; sve_vq > 0; --sve_vq) { - sve_vl = prctl(PR_SVE_SET_VL, sve_vq * 16); - if (sve_vl == -1) + for (sve = 0; sve < sve_vl_count; sve++) { + ret = prctl(PR_SVE_SET_VL, sve_vls[sve]); + if (ret == -1) ksft_exit_fail_msg("PR_SVE_SET_VL failed: %s (%d)\n", strerror(errno), errno); - sve_vl &= PR_SVE_VL_LEN_MASK; - - if (sve_vq != sve_vq_from_vl(sve_vl)) - sve_vq = sve_vq_from_vl(sve_vl); + ksft_test_result(do_test(cfg, sve_vls[sve], default_sme_vl, 0), + "%s SVE VL %d\n", cfg->name, sve_vls[sve]); - ksft_test_result(do_test(cfg, sve_vl, default_sme_vl, 0), - "%s SVE VL %d\n", cfg->name, sve_vl); - - if (!(getauxval(AT_HWCAP2) & HWCAP2_SME)) - continue; - - for (sme_vq = SVE_VQ_MAX; sme_vq > 0; --sme_vq) { - sme_vl = prctl(PR_SME_SET_VL, sme_vq * 16); - if (sme_vl == -1) + for (sme = 0; sme < sme_vl_count; sme++) { + ret = prctl(PR_SME_SET_VL, sme_vls[sme]); + if (ret == -1) ksft_exit_fail_msg("PR_SME_SET_VL failed: %s (%d)\n", strerror(errno), errno); - sme_vl &= PR_SME_VL_LEN_MASK; - - /* Found lowest VL */ - if (sve_vq_from_vl(sme_vl) > sme_vq) - break; - - if (sme_vq != sve_vq_from_vl(sme_vl)) - sme_vq = sve_vq_from_vl(sme_vl); - - ksft_test_result(do_test(cfg, sve_vl, sme_vl, + ksft_test_result(do_test(cfg, sve_vls[sve], + sme_vls[sme], SVCR_ZA_MASK | SVCR_SM_MASK), "%s SVE VL %d/SME VL %d SM+ZA\n", - cfg->name, sve_vl, sme_vl); - ksft_test_result(do_test(cfg, sve_vl, sme_vl, - SVCR_SM_MASK), + cfg->name, sve_vls[sve], + sme_vls[sme]); + ksft_test_result(do_test(cfg, sve_vls[sve], + sme_vls[sme], SVCR_SM_MASK), "%s SVE VL %d/SME VL %d SM\n", - cfg->name, sve_vl, sme_vl); - ksft_test_result(do_test(cfg, sve_vl, sme_vl, - SVCR_ZA_MASK), + cfg->name, sve_vls[sve], + sme_vls[sme]); + ksft_test_result(do_test(cfg, sve_vls[sve], + sme_vls[sme], SVCR_ZA_MASK), "%s SVE VL %d/SME VL %d ZA\n", - cfg->name, sve_vl, sme_vl); + cfg->name, sve_vls[sve], + sme_vls[sme]); } } } -int sve_count_vls(void) +void sve_count_vls(void) { unsigned int vq; - int vl_count = 0; int vl; if (!(getauxval(AT_HWCAP) & HWCAP_SVE)) - return 0; + return; /* * Enumerate up to SVE_VQ_MAX vector lengths @@ -436,23 +424,17 @@ int sve_count_vls(void) if (vq != sve_vq_from_vl(vl)) vq = sve_vq_from_vl(vl); - vl_count++; + sve_vls[sve_vl_count++] = vl; } - - return vl_count; } -int sme_count_vls(void) +void sme_count_vls(void) { unsigned int vq; - int vl_count = 0; int vl; if (!(getauxval(AT_HWCAP2) & HWCAP2_SME)) - return 0; - - /* Ensure we configure a SME VL, used to flag if SVCR is set */ - default_sme_vl = 16; + return; /* * Enumerate up to SVE_VQ_MAX vector lengths @@ -472,10 +454,11 @@ int sme_count_vls(void) if (vq != sve_vq_from_vl(vl)) vq = sve_vq_from_vl(vl); - vl_count++; + sme_vls[sme_vl_count++] = vl; } - return vl_count; + /* Ensure we configure a SME VL, used to flag if SVCR is set */ + default_sme_vl = sme_vls[0]; } int main(void) @@ -486,8 +469,12 @@ int main(void) srandom(getpid()); ksft_print_header(); - tests += sve_count_vls(); - tests += (sve_count_vls() * sme_count_vls()) * 3; + + sve_count_vls(); + sme_count_vls(); + + tests += sve_vl_count; + tests += (sve_vl_count * sme_vl_count) * 3; ksft_set_plan(ARRAY_SIZE(syscalls) * tests); if (getauxval(AT_HWCAP2) & HWCAP2_SME_FA64) From patchwork Tue Dec 27 13:06:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13082307 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E0ECC4708E for ; Tue, 27 Dec 2022 13:07:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbiL0NHX (ORCPT ); Tue, 27 Dec 2022 08:07:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbiL0NHB (ORCPT ); Tue, 27 Dec 2022 08:07:01 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995CE65B5; Tue, 27 Dec 2022 05:06:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 50BDBB8101B; Tue, 27 Dec 2022 13:06:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66CECC433D2; Tue, 27 Dec 2022 13:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672146417; bh=FkCT7CeF2shSYZvmS/axMpxelhP3SAvkHxuUZYWnJIE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=k5a1Fp6k4JM/SAz6EHZrDATlGxVJpwAplKssCMN8O8AvebKyvYcCtAdUwC07qDSFm vucAjfW5pj1FYVcWlZR6RPOdIzAX6GFyOI0HCLFBSde9yUMKZgS4DKXUcFmXsdJH3b Qh9FLmMXSIgc6IJUXT1K8mVfYDl5KMhcB5Xn5EKgJaZUd2HFJZeeFZPd3ClO/xkwtm zoylAD1FIhx2N8dI6+L/ojdFN5THEbKGvNttpEZmUDncIAsIjVYimf05mq2LjBOFRA pFaBKBkwuOgZoQ4z2OnBaZ1GPqKcf1Ivf7LpqR6JMLQfxXpO7ZcaaqZrF+1e6FeQ7C jErfN+/fycKoA== From: Mark Brown Date: Tue, 27 Dec 2022 13:06:37 +0000 Subject: [PATCH 3/4] kselftest/arm64: Verify SME only ABI in syscall-abi MIME-Version: 1.0 Message-Id: <20221223-arm64-syscall-abi-sme-only-v1-3-4fabfbd62087@kernel.org> References: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> In-Reply-To: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.12-dev-7ab1d X-Developer-Signature: v=1; a=openpgp-sha256; l=4483; i=broonie@kernel.org; h=from:subject:message-id; bh=FkCT7CeF2shSYZvmS/axMpxelhP3SAvkHxuUZYWnJIE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjqu3nf73Pjz+vQrz9xDatgVaakTyMlwkVuTleA8yn QhrAwGeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY6rt5wAKCRAk1otyXVSH0KlsB/ 9L9rONe+nrYiKbLKgNfpatd8y4qUJPoHXKFp76EtFk1W2vOUxWJmGR8gQw7pv7ZA1BEgKHAZhq8ztl Oai4XIY5IbrihK2NWBelkV4ht9yR3KQmtmSDSys4igU/R1r1wFrHzZok9bfpHEqR913n5Iz3oELQrr RX64R5rO9svwK+m+N/IGk+oFKIDTli08lldm/CQdTpsNSlwgSJaMg/Gz1BXlSJh5v1gJyasiKdJymr ei2i1AvZXOAa8l2rliqSjs839jxsOuprm3cAmnlr8RWNeDtMvnAIDXP0OoxqYEaH7E1i2NeGdVrSET c6B9z4vGznErF5BMUsoeMTEiaQxa5C X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently syscall-abi only covers SME in the case where the system supports SVE however it is architecturally valid to support SME without SVE. Update the program to cover this case, this requires adjustments in the code to check for SVCR.SM being set when deciding if we're handling the FPSIMD or SVE registers and the addition of new test cases for the SME only case. Note that in the SME only case we should not save the SVE registers after a syscall since even if we were in streaming mode and therefore set them the syscall should have exited streaming mode, we check that we have done so by looking at SVCR. Signed-off-by: Mark Brown --- .../testing/selftests/arm64/abi/syscall-abi-asm.S | 14 +++++---- tools/testing/selftests/arm64/abi/syscall-abi.c | 34 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/arm64/abi/syscall-abi-asm.S b/tools/testing/selftests/arm64/abi/syscall-abi-asm.S index acd5e9f3bc0b..cdfafc939a9e 100644 --- a/tools/testing/selftests/arm64/abi/syscall-abi-asm.S +++ b/tools/testing/selftests/arm64/abi/syscall-abi-asm.S @@ -92,8 +92,11 @@ do_syscall: str x29, [x2], #8 // FP str x30, [x2], #8 // LR - // Load FPRs if we're not doing SVE + // Load FPRs if we're not doing neither SVE nor streaming SVE cbnz x0, 1f + ldr x2, =svcr_in + tbnz x2, #SVCR_SM_SHIFT, 1f + ldr x2, =fpr_in ldp q0, q1, [x2] ldp q2, q3, [x2, #16 * 2] @@ -111,10 +114,11 @@ do_syscall: ldp q26, q27, [x2, #16 * 26] ldp q28, q29, [x2, #16 * 28] ldp q30, q31, [x2, #16 * 30] + + b 2f 1: // Load the SVE registers if we're doing SVE/SME - cbz x0, 1f ldr x2, =z_in ldr z0, [x2, #0, MUL VL] @@ -155,9 +159,9 @@ do_syscall: ldr x2, =ffr_in ldr p0, [x2] ldr x2, [x2, #0] - cbz x2, 2f + cbz x2, 1f wrffr p0.b -2: +1: ldr x2, =p_in ldr p0, [x2, #0, MUL VL] @@ -176,7 +180,7 @@ do_syscall: ldr p13, [x2, #13, MUL VL] ldr p14, [x2, #14, MUL VL] ldr p15, [x2, #15, MUL VL] -1: +2: // Do the syscall svc #0 diff --git a/tools/testing/selftests/arm64/abi/syscall-abi.c b/tools/testing/selftests/arm64/abi/syscall-abi.c index 45fdcbe3e909..7c9b6e947040 100644 --- a/tools/testing/selftests/arm64/abi/syscall-abi.c +++ b/tools/testing/selftests/arm64/abi/syscall-abi.c @@ -88,6 +88,7 @@ static int check_gpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, uint64_t s #define NUM_FPR 32 uint64_t fpr_in[NUM_FPR * 2]; uint64_t fpr_out[NUM_FPR * 2]; +uint64_t fpr_zero[NUM_FPR * 2]; static void setup_fpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, uint64_t svcr) @@ -102,7 +103,7 @@ static int check_fpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, int errors = 0; int i; - if (!sve_vl) { + if (!sve_vl && !(svcr & SVCR_SM_MASK)) { for (i = 0; i < ARRAY_SIZE(fpr_in); i++) { if (fpr_in[i] != fpr_out[i]) { ksft_print_msg("%s Q%d/%d mismatch %llx != %llx\n", @@ -114,6 +115,18 @@ static int check_fpr(struct syscall_cfg *cfg, int sve_vl, int sme_vl, } } + /* + * In streaming mode the whole register set should be cleared + * by the transition out of streaming mode. + */ + if (svcr & SVCR_SM_MASK) { + if (memcmp(fpr_zero, fpr_out, sizeof(fpr_out)) != 0) { + ksft_print_msg("%s FPSIMD registers non-zero exiting SM\n", + cfg->name); + errors++; + } + } + return errors; } @@ -400,6 +413,24 @@ static void test_one_syscall(struct syscall_cfg *cfg) sme_vls[sme]); } } + + for (sme = 0; sme < sme_vl_count; sme++) { + ret = prctl(PR_SME_SET_VL, sme_vls[sme]); + if (ret == -1) + ksft_exit_fail_msg("PR_SME_SET_VL failed: %s (%d)\n", + strerror(errno), errno); + + ksft_test_result(do_test(cfg, 0, sme_vls[sme], + SVCR_ZA_MASK | SVCR_SM_MASK), + "%s SME VL %d SM+ZA\n", + cfg->name, sme_vls[sme]); + ksft_test_result(do_test(cfg, 0, sme_vls[sme], SVCR_SM_MASK), + "%s SME VL %d SM\n", + cfg->name, sme_vls[sme]); + ksft_test_result(do_test(cfg, 0, sme_vls[sme], SVCR_ZA_MASK), + "%s SME VL %d ZA\n", + cfg->name, sme_vls[sme]); + } } void sve_count_vls(void) @@ -474,6 +505,7 @@ int main(void) sme_count_vls(); tests += sve_vl_count; + tests += sme_vl_count * 3; tests += (sve_vl_count * sme_vl_count) * 3; ksft_set_plan(ARRAY_SIZE(syscalls) * tests); From patchwork Tue Dec 27 13:06:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13082305 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F306DC4167B for ; Tue, 27 Dec 2022 13:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231718AbiL0NHX (ORCPT ); Tue, 27 Dec 2022 08:07:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231615AbiL0NHB (ORCPT ); Tue, 27 Dec 2022 08:07:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A3D4277; Tue, 27 Dec 2022 05:07:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AF1D06115E; Tue, 27 Dec 2022 13:06:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76D62C43392; Tue, 27 Dec 2022 13:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672146419; bh=ftKw9JxdN7OkfKbeAVWrxvHtpZk1v1+kLM5uE4WBFzg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=J9jBpf7YpIT/KUPBfiL0ijOMl3up/EqOTWovYRw6AiDyR7ZiTWaN/IZV4HsfbVAj8 GNrb0VSw3cJAsithpiUHhWeGY+yeBW0hzhbOL3zdgOFSE0G56hqwnD7JHIqfnyXV0o OSzveBmxCUQGzT2OSV9PGd7WnGt0otzMVFg5ywu0gHNFX7IVkGKRPgsQSEyxeEskKO lFydyFgMn7Fsiy81AsVE+Tcpf8Mg/xBP69hYNlO8h8seZAnLBnYNWPR9i6E/XkXyGh 8hcMH+OhpXF7SjazH1HYRm5yHGJNNxDN17oeC3H/JknK8zltzkb+1JQ67GK+/t4Oxc FEIRKZsi3nUuQ== From: Mark Brown Date: Tue, 27 Dec 2022 13:06:38 +0000 Subject: [PATCH 4/4] kselftest/arm64: Only enumerate power of two VLs in syscall-abi MIME-Version: 1.0 Message-Id: <20221223-arm64-syscall-abi-sme-only-v1-4-4fabfbd62087@kernel.org> References: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> In-Reply-To: <20221223-arm64-syscall-abi-sme-only-v1-0-4fabfbd62087@kernel.org> To: Catalin Marinas , Will Deacon , Shuah Khan Cc: Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.12-dev-7ab1d X-Developer-Signature: v=1; a=openpgp-sha256; l=2013; i=broonie@kernel.org; h=from:subject:message-id; bh=ftKw9JxdN7OkfKbeAVWrxvHtpZk1v1+kLM5uE4WBFzg=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjqu3oGR4UZqgD9m8L8fGlfTnGhEn85EVEwGm03O0/ uGhK1kCJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY6rt6AAKCRAk1otyXVSH0GAxB/ 0UF4ItAsSeRKn4TpESZ/DpfbOEkcF+ZzIdEuMKfESo072yQk+0JjHZulbv6n7to3jH5QfL1oJrvquA q4U/L7nbAOgaVe5C+9VYu4LDxNnfE7f9zmtCrT/9FrZTF+ZGxVpcerEcZ+nVWGYPWrOEKKQCDDaWf0 h3DMQXbxveAaw/7DmCZxddZ3joC9VaoJaoxi9bcwwkd74tlpJAFRfiqlQ7vlX5z616Tl9gF562mAyC gAFVzJNTHKpRCE9J8PUzIOn0vteUImFQpCNFhjR60qeL59MkOscmVYIJlnPfLOmRkn9GLffkxIZNhs jA0at65HqbaaqP3U7u7NQTcp7Cjjmk X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org As documented in issue C215 in the known issues list for DDI0487I.a [1] Arm will be making a retroactive change to SVE to remove the possibility of selecting non power of two vector lengths. This has no impact on existing physical implementations but most virtual implementations have implemented the full range of permissible vector lengths. Since virtual implementations are noticeably slow in general and the larger vector lengths amplify the issue there's a useful improvement in runtime from only covering the vector lengths that will exist in practical systems, adjust our enumeration accordingly. We have other tests that aim to cover the enumeration interfaces. For symmetry we apply the same change to the eumeration for SME vector lengths, though the power of two restriction was already present for SME so there is no impact on the set of vector lengths tested. [1] https://developer.arm.com/documentation/102105/ia-00/ Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/syscall-abi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/arm64/abi/syscall-abi.c b/tools/testing/selftests/arm64/abi/syscall-abi.c index 7c9b6e947040..8afcbf6861fd 100644 --- a/tools/testing/selftests/arm64/abi/syscall-abi.c +++ b/tools/testing/selftests/arm64/abi/syscall-abi.c @@ -444,7 +444,7 @@ void sve_count_vls(void) /* * Enumerate up to SVE_VQ_MAX vector lengths */ - for (vq = SVE_VQ_MAX; vq > 0; --vq) { + for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) { vl = prctl(PR_SVE_SET_VL, vq * 16); if (vl == -1) ksft_exit_fail_msg("PR_SVE_SET_VL failed: %s (%d)\n", @@ -470,7 +470,7 @@ void sme_count_vls(void) /* * Enumerate up to SVE_VQ_MAX vector lengths */ - for (vq = SVE_VQ_MAX; vq > 0; --vq) { + for (vq = SVE_VQ_MAX; vq > 0; vq /= 2) { vl = prctl(PR_SME_SET_VL, vq * 16); if (vl == -1) ksft_exit_fail_msg("PR_SME_SET_VL failed: %s (%d)\n",