From patchwork Mon Sep 13 12:54:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17FF8C433FE for ; Mon, 13 Sep 2021 13:20:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 074E661155 for ; Mon, 13 Sep 2021 13:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240416AbhIMNVO (ORCPT ); Mon, 13 Sep 2021 09:21:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:35052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240369AbhIMNU2 (ORCPT ); Mon, 13 Sep 2021 09:20:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E538D610A2; Mon, 13 Sep 2021 13:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539129; bh=vQDQ+/qG/LA/nRQzQGstev6NVULTlIXk2hGztV2UteM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eqOdA1+3zhc6YwC/f8v6Amy9aEhhOFTMIr3xfErrZDRTS8XE88MrOp6VyZTkFgYii 6tclXKfWUoPr2hmelkztZIhSahfNbi8+8TkklOTHjnwONgn7J7RlLagFRjpJfCBZUf NBtM6gX8srWLGpJUAT9UdsmwamCj1vEnMp2M55SmjifVh16ub7RNGF7RbOwAwnBBSR EGo7BfHKlXMbyD8E+ALCxJ3ixLYzAYVhxdVTM2qRnkpzggTAl9IxlF369AxL9hcRRe LaheRlTiBHYuiRdVuXKDCj1pq/7YKOu5SrCggiLs39AevkCzDxqGQTNDAFAbPPsVTQ 1MgYx0LfS6aMg== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 1/8] selftests: arm64: Use a define for the number of SVE ptrace tests to be run Date: Mon, 13 Sep 2021 13:54:58 +0100 Message-Id: <20210913125505.52619-2-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1009; h=from:subject; bh=vQDQ+/qG/LA/nRQzQGstev6NVULTlIXk2hGztV2UteM=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0ojs9Vk+/o+GTD2AjKNaqbcwhx75hQGZxNVU3s1 cj6R8YCJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KIwAKCRAk1otyXVSH0Kt+B/ 40BTs6y8xK7oAExeJcW0SR1vhjKsEMhxINqcMwOExxzdr++OzfeElYqJLepwCTivrUUZR0o0qygzVJ XDRTh5a71tFYA83/iv/csS9P2/HxWrTopfAcD2HS9CJLXnaUxVkiXbN/Jq3+UDPkNe5eeCC2QRvzuG c9QGzQ7l6nxMI3Ino/rOUP7SD4zrZpVkVMU1ZtTVXcmkJXaXG5Zr7ieStWjiO+us+FBZUCzKvR+acr ieGUAEoArgL3Aw4LkjM32JemJ77rEwYIwqlbH41MSx2uPaIMZr2eH/u/sjuyik6aSBNvsN6xDcFPWN t03gx/sQIInHu5JdW/uxfZQrHkPi8o X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Partly in preparation for future refactoring move from hard coding the number of tests in main() to putting #define at the top of the source instead. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 612d3899614a..7f7ed1c96867 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -19,6 +19,8 @@ #include "../../kselftest.h" +#define EXPECTED_TESTS 20 + /* and don't like each other, so: */ #ifndef NT_ARM_SVE #define NT_ARM_SVE 0x405 @@ -313,7 +315,7 @@ int main(void) pid_t child; ksft_print_header(); - ksft_set_plan(20); + ksft_set_plan(EXPECTED_TESTS); if (!(getauxval(AT_HWCAP) & HWCAP_SVE)) ksft_exit_skip("SVE not available\n"); From patchwork Mon Sep 13 12:54:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F221C433FE for ; Mon, 13 Sep 2021 13:19:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BBF5610F7 for ; Mon, 13 Sep 2021 13:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240399AbhIMNVN (ORCPT ); Mon, 13 Sep 2021 09:21:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239327AbhIMNUa (ORCPT ); Mon, 13 Sep 2021 09:20:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D2CFF610CC; Mon, 13 Sep 2021 13:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539132; bh=O2J0CBowzd5LAgXHGk3QgAQrfXWhXtRsRLXZBHHOUxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jcpf+X+DQ05dkYlvsf9xDTDTJKQfMhMUPT7R51F12qphK5QYSxoozQMpfwlWmePY8 lrXhA/au9lDdVRr24UP/5MC8RLAE48YIv3yo4GWJQX993X19CkxXALAn33SIUihuXO qP0dPoDDfrNwFK5nOgqax0MwpAm5sWkWowxqnHMeSeUMagYwQnTCVv6HDteCh0C4t8 pLRg1zvxn2M5yMtlTMz9uNByWfjf0xXmpLPH/r1mcRcpiinxvId9/Ft0NH53/1ddmp Lf1z9JbUFudhf0CxmkmCGi54V6l1imOLa13Osm7Y9KWd9asu/gDEF2uzPv9LUwI6FH GK5Vd1NdA1Cvg== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 2/8] selftests: arm64: Don't log child creation as a test in SVE ptrace test Date: Mon, 13 Sep 2021 13:54:59 +0100 Message-Id: <20210913125505.52619-3-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1104; h=from:subject; bh=O2J0CBowzd5LAgXHGk3QgAQrfXWhXtRsRLXZBHHOUxY=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0okCN56MnhjjHYb3UJB6Gi5I0LAgBkIBd0x0AlX aFHNGAOJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KJAAKCRAk1otyXVSH0Jq5B/ 96f6jDSG7jhRQYXKuzJqRV4RuZUm2rKBItpZuGghAg5HX/Dxtb1I6bkFDWysd3vVjZzu4DiHTZELZP CcyX+OWrJmcq4fqUHtRzu7knZEnXiQwm9o7Yu5pTSGbEafZcqcQXQxxvJGjAbAlETTiG26xVAZn7Pq 9NMCHCwpFIaQO+WOSImtc6usdZ5z89FhmASXytYkt2LWAZVRIGW8duLfCy86+tYWNhR++/zVv8nfK5 9AWxtiHos2FPkucpxeuanH5QjmSbQ9Ryg4ipBjzYJmAl1RNrr1eOaVd+S3C+PQTxc1FPD9WibwhWAw R3+Mmi6zgu3gG0+tJ5MR24lKoBHtxO X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently we log the creation of the child process as a test but it's not really relevant to what we're trying to test and can make the output a little confusing so don't do that. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 7f7ed1c96867..7035f01423b3 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -19,7 +19,7 @@ #include "../../kselftest.h" -#define EXPECTED_TESTS 20 +#define EXPECTED_TESTS 19 /* and don't like each other, so: */ #ifndef NT_ARM_SVE @@ -169,8 +169,6 @@ static int do_parent(pid_t child) if (WIFEXITED(status) || WIFSIGNALED(status)) ksft_exit_fail_msg("Child died unexpectedly\n"); - ksft_test_result(WIFSTOPPED(status), "WIFSTOPPED(%d)\n", - status); if (!WIFSTOPPED(status)) goto error; From patchwork Mon Sep 13 12:55:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B6C9C433EF for ; Mon, 13 Sep 2021 13:19:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2A34610F7 for ; Mon, 13 Sep 2021 13:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240304AbhIMNVM (ORCPT ); Mon, 13 Sep 2021 09:21:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:34852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240395AbhIMNUd (ORCPT ); Mon, 13 Sep 2021 09:20:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80228610A8; Mon, 13 Sep 2021 13:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539135; bh=GBsRjVbp2ScqVMX9Rr82B9alQFkrFeuX8lSU+S6t9jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mo8M6F4jz6PBNNdSEeT08UIeYOdOhmcWcxJ4JK1yp/v6YWhep7BCTWJloB0NlJ2+z Q2XslFd1yWpmMkPJTEX9pPBhUEhMDxmQjphAjuyaCT5WQ2oVXW9RBMuE97hLMCDhWw ZhGQGoF6Pt/NORov6iBqBLIljMKvXccQX9wU1ZaxSPZurQgVxAWFJ6B91a7ABR7m/r hK5qmedrYZrgjya+6DP6xQXoLWqk38LjjIAitkoI47DOus28FTzyHLose+lzXlVBFR +t6UHHtk/oMezHnKwGexZchwJVJ3gYBD80LdbQ84cYgtKerw4jnOO75azukZJBEjGp VrADSS5L8EVVw== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 3/8] selftests: arm64: Remove extraneous register setting code Date: Mon, 13 Sep 2021 13:55:00 +0100 Message-Id: <20210913125505.52619-4-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3606; h=from:subject; bh=GBsRjVbp2ScqVMX9Rr82B9alQFkrFeuX8lSU+S6t9jw=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0oklyFeSTAZL9y/xQilQl6l9HiIjTJLxnjcpFwn v/JDMgeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KJAAKCRAk1otyXVSH0JLrB/ 0TvQ6h1gx2cw1qONvFzw2hBsrYjxazyL0NYUXZzQTLueRtG6mTVimLc6oT3VIkVUkJtWK0mlDH/Vph 7AAetum9hEkOYvio5+iT89JqhR1U8hNkqvE0d5rJA5rXWSVQYhs4znMI+JS0kois5sg7QIciU4bc7o FP7XRkef64uucbVQ3CMOP3KyT6eT4ov/RwSyu9Z9vrKtenl8cAecmZdBvHWF/WbFj4bG3C0VfMnzTt EJb3C4tLN3FKpALgN0kTgU/WbQwTobX57c6iYosnl6IWNnlbeOqqOcfDLzFeg484PgjkEiXAtK6myL lbZPrRPQBjukbw8EOm0URM4VA4oL/Z X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org For some reason the SVE ptrace test code starts off by setting values in some of the SVE vector registers in the parent process which it then never interacts with when verifying the ptrace interfaces. This is not especially relevant to what's being tested and somewhat confusing when reading the code so let's remove it. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/Makefile | 2 +- .../selftests/arm64/fp/sve-ptrace-asm.S | 33 ------------------- tools/testing/selftests/arm64/fp/sve-ptrace.c | 28 ---------------- 3 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 tools/testing/selftests/arm64/fp/sve-ptrace-asm.S diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/selftests/arm64/fp/Makefile index f2abdd6ba12e..4367125b7c27 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -12,7 +12,7 @@ all: $(TEST_GEN_PROGS) $(TEST_PROGS_EXTENDED) fpsimd-test: fpsimd-test.o $(CC) -nostdlib $^ -o $@ rdvl-sve: rdvl-sve.o rdvl.o -sve-ptrace: sve-ptrace.o sve-ptrace-asm.o +sve-ptrace: sve-ptrace.o sve-probe-vls: sve-probe-vls.o rdvl.o sve-test: sve-test.o $(CC) -nostdlib $^ -o $@ diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace-asm.S b/tools/testing/selftests/arm64/fp/sve-ptrace-asm.S deleted file mode 100644 index 3e81f9fab574..000000000000 --- a/tools/testing/selftests/arm64/fp/sve-ptrace-asm.S +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -// Copyright (C) 2015-2019 ARM Limited. -// Original author: Dave Martin -#include - -.arch_extension sve - -.globl sve_store_patterns - -sve_store_patterns: - mov x1, x0 - - index z0.b, #0, #1 - str q0, [x1] - - mov w8, #__NR_getpid - svc #0 - str q0, [x1, #0x10] - - mov z1.d, z0.d - str q0, [x1, #0x20] - - mov w8, #__NR_getpid - svc #0 - str q0, [x1, #0x30] - - mov z1.d, z0.d - str q0, [x1, #0x40] - - ret - -.size sve_store_patterns, . - sve_store_patterns -.type sve_store_patterns, @function diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 7035f01423b3..d2ec48f649f9 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -26,11 +26,6 @@ #define NT_ARM_SVE 0x405 #endif -/* Number of registers filled in by sve_store_patterns */ -#define NR_VREGS 5 - -void sve_store_patterns(__uint128_t v[NR_VREGS]); - static void dump(const void *buf, size_t size) { size_t i; @@ -40,23 +35,6 @@ static void dump(const void *buf, size_t size) printf(" %.2x", *p++); } -static int check_vregs(const __uint128_t vregs[NR_VREGS]) -{ - int i; - int ok = 1; - - for (i = 0; i < NR_VREGS; ++i) { - printf("# v[%d]:", i); - dump(&vregs[i], sizeof vregs[i]); - putchar('\n'); - - if (vregs[i] != vregs[0]) - ok = 0; - } - - return ok; -} - static int do_child(void) { if (ptrace(PTRACE_TRACEME, -1, NULL, NULL)) @@ -309,7 +287,6 @@ static int do_parent(pid_t child) int main(void) { int ret = EXIT_SUCCESS; - __uint128_t v[NR_VREGS]; pid_t child; ksft_print_header(); @@ -318,11 +295,6 @@ int main(void) if (!(getauxval(AT_HWCAP) & HWCAP_SVE)) ksft_exit_skip("SVE not available\n"); - sve_store_patterns(v); - - if (!check_vregs(v)) - ksft_exit_fail_msg("Initial check_vregs() failed\n"); - child = fork(); if (!child) return do_child(); From patchwork Mon Sep 13 12:55:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAFFAC4332F for ; Mon, 13 Sep 2021 13:19:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C7E7610CB for ; Mon, 13 Sep 2021 13:19:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240233AbhIMNVL (ORCPT ); Mon, 13 Sep 2021 09:21:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:34854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240399AbhIMNUd (ORCPT ); Mon, 13 Sep 2021 09:20:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3673361216; Mon, 13 Sep 2021 13:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539137; bh=3RGlMrOqTC9QZNG8f5YOa/s+hJ+c18k3VekrOVRUQEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IFbjj6TVfED9S9hFdrABRBiPHgjsJy9Vn6kn4XrpXDQhQL/zOLEFomg3Vr+wNZrk5 4Y0rdZXrWWtYMGG2zhmyZoCF0Ulztir+NcpKpO7Bs40ht5pmFygtQfKVEvfQBnCjJZ NTYqZKDOxUhBaTF9zFXluRuD+uU3t9xMAY8vv383K1tw+q0AtZkN+0mEvxZLQw5WVN /zp8KezwAdNv8Jr1e49Vt09sBVtWK0aO6N9Iez0BnHx5QBfgQGU4Q9Bzbpe7hCwBfz v6RbGAWGrfbBoaXrMcQY89vDFaQP58r3VEXniFhGvXBk/WjB1Y/S96PDsrLXMpl0B+ D8osld9OQ9hmQ== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 4/8] selftests: arm64: Document what the SVE ptrace test is doing Date: Mon, 13 Sep 2021 13:55:01 +0100 Message-Id: <20210913125505.52619-5-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2330; h=from:subject; bh=3RGlMrOqTC9QZNG8f5YOa/s+hJ+c18k3VekrOVRUQEA=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0ol6DkHVUICf8Th6pUk6tfsdEP8uH4OL+9Tu5lU 0FceRhqJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KJQAKCRAk1otyXVSH0LgVB/ 9A/aC9RnVqvaN747YpyJsNIdYQ3o0Uhr6aQXDK3BRYACofl6l4MCga6Kc86rrtUPyHGBxQ29d7+jAj Rr2PYf4nYn3IZ6qPXZD9ZlXNuSOll4ilpEzlDpoxN6+nVTQUQovU9lBYuXULo6bQrLXT3FT2psB1Su mxR/vMqcUaEy6Kx+E7vaKigrZPnR1OpML7/OIpTzP6dAh9FDgqLDaqIdgbcArzNBaJHufAfG525N9i ls6l8tjS6WvKSXh+YrAEdy6BbCkoteGxDnFhag1mT9DRQGsXUfJUkxzNjUvSgp6J56iUgMYCl8v5iY fcfJDtASr41L/eJhnKIyGWQnIrlOFt X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Before we go modifying it further let's add some comments and output clarifications explaining what this test is actually doing. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index d2ec48f649f9..fc4a672825eb 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -181,6 +181,7 @@ static int do_parent(pid_t child) } } + /* New process should start with FPSIMD registers only */ sve = get_sve(pid, &svebuf, &svebufsz); if (!sve) { int e = errno; @@ -191,14 +192,15 @@ static int do_parent(pid_t child) goto error; } else { - ksft_test_result_pass("get_sve\n"); + ksft_test_result_pass("get_sve(FPSIMD)\n"); } ksft_test_result((sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD, - "FPSIMD registers\n"); + "Set FPSIMD registers\n"); if ((sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_FPSIMD) goto error; + /* Try to set a known FPSIMD state via PT_REGS_SVE */ fpsimd = (struct user_fpsimd_state *)((char *)sve + SVE_PT_FPSIMD_OFFSET); for (i = 0; i < 32; ++i) { @@ -219,6 +221,7 @@ static int do_parent(pid_t child) goto error; } + /* Zero the first SVE Z register */ vq = sve_vq_from_vl(sve->vl); newsvebufsz = SVE_PT_SVE_ZREG_OFFSET(vq, 1); @@ -245,6 +248,7 @@ static int do_parent(pid_t child) goto error; } + /* Try to read back the value we just set */ new_sve = get_sve(pid, &newsvebuf, &newsvebufsz); if (!new_sve) { int e = errno; @@ -257,12 +261,13 @@ static int do_parent(pid_t child) } ksft_test_result((new_sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE, - "SVE registers\n"); + "Get SVE registers\n"); if ((new_sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_SVE) goto error; dump_sve_regs(new_sve, 3, sizeof fpsimd->vregs[0]); + /* Verify that the register we set has the value we expected */ p = (unsigned char *)new_sve + SVE_PT_SVE_ZREG_OFFSET(vq, 1); for (i = 0; i < sizeof fpsimd->vregs[0]; ++i) { unsigned char expected = i; From patchwork Mon Sep 13 12:55:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0700C433EF for ; Mon, 13 Sep 2021 13:19:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8A72610A8 for ; Mon, 13 Sep 2021 13:19:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236172AbhIMNVK (ORCPT ); Mon, 13 Sep 2021 09:21:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:35302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240407AbhIMNUe (ORCPT ); Mon, 13 Sep 2021 09:20:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DAA261211; Mon, 13 Sep 2021 13:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539140; bh=OgQoI0YmbmfY7WdrTXe60wCgVXiWk5V9jGWdGjPhjqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwtDZ97HcCdaFGQq4xPCkWDOfD51PsCk6fFaSGo0XvkA2uuE+ZBq5hoVbpqzZ7QZF b94hNuMKYb+0jLs5vLmXmzOI3+8C/rjLi4Of8gsBmTsWbAhwNq9WIU53y5ebgfGDuT GftXXJdDW7T+URKFAPbd6DxjW6mEFFAdK1FnSsEeBhGo9gVdL2K9hYAHNd4Hpaa7oJ 3uDYQhF2hm6E2JU/lKxDTTcGCCnc46mdRLh97cIDr3OKog9Xbblp/cs8RwYRq0YwBb 2D4n7DPBuXnLiTFfFVnKUwqjxaA9NGRySIHGalfkDK+F+iW2sohiThtA7ts2itsmID EfboXDt3hmtjQ== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 5/8] selftests: arm64: Clarify output when verifying SVE register set Date: Mon, 13 Sep 2021 13:55:02 +0100 Message-Id: <20210913125505.52619-6-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1089; h=from:subject; bh=OgQoI0YmbmfY7WdrTXe60wCgVXiWk5V9jGWdGjPhjqk=; b=owGbwMvMwMWocq27KDak/QLjabUkhkR7L7W4frVdnlVq4jo6Vb+WvC9vqrB95+t/1eaJr8y9I3Mb 18/qZDRmYWDkYpAVU2RZ+yxjVXq4xNb5j+a/ghnEygQyhYGLUwAmItPH/le2h2f7UlYF1wTW2infJS R/aXDrLDilaPjwz9XFCtW1HQx7Zu/xY1x9sDizsifRfv41NlVuf1fpv3W3BQty2C9fmpT11P5WXsHh Y4ouQomOqjyvn3vz7GWUsut3PHbVt8vCLqh94mS9sISFeSJRxxIF3ZS2Cz+QLzZiuPt0+hr/n9xME/ MsLu1VDvx6/c0NLlnnhruMAurXTvBPuhNo9u/ltx5hz8vREQ/keyczae1tLTzvGltTabhnL3/VdYUH HWu3ntGQacjtL3jH3373Trh376ygSXF1B1iuComsv6TftqArWbewvHzahnltx7YLebJsYfI+7s11Y9 1DbwVNltiN2Wlh/cufT37avVcJAA== X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When verifying setting a Z register via ptrace we check each byte by hand, iterating over the buffer using a pointer called p and treating each register value written as a test. This creates output referring to "p[X]" which is confusing since SVE also has predicate registers Pn. Tweak the output to avoid confusion here. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index fc4a672825eb..2d130fedc019 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -275,7 +275,7 @@ static int do_parent(pid_t child) if (__BYTE_ORDER == __BIG_ENDIAN) expected = sizeof fpsimd->vregs[0] - 1 - expected; - ksft_test_result(p[i] == expected, "p[%d] == expected\n", i); + ksft_test_result(p[i] == expected, "buf[%d] == expected\n", i); if (p[i] != expected) goto error; } From patchwork Mon Sep 13 12:55:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B52BC433EF for ; Mon, 13 Sep 2021 13:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F87861155 for ; Mon, 13 Sep 2021 13:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240667AbhIMNXG (ORCPT ); Mon, 13 Sep 2021 09:23:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:35020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239450AbhIMNUy (ORCPT ); Mon, 13 Sep 2021 09:20:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A07461242; Mon, 13 Sep 2021 13:19:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539142; bh=X8xv6IhDmCpAV7VXVZkOxAjGP99z74IVeoo0V7Z/c4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyDiVMfplM+huBEwD5Gz+t7NEZTlXDQixdBZ8jShbeWuMTTV1zRPp5btB9EBQ2QwM j7JiHamYQw+BuYlYhiBGXzf0va+twpvEOrvBwIWPAQYMsru1qw5y4k7dxdU8KQ73Yq ySuWf/vWT5VpKrhR/DXw5aXWDIpXdKcAzeddH93Mh2LG1fdaDanYs6GASB9F/M4ToL 0W+HNlUpi2V7OwNrsk+U1Fsd0uTVxT2rzkfalylSR43DI9866ZKuXl1HtyO5ieYz0l dnaPHhh5BquFQVlWO3XkSdMS8PxZ/oUv2FD0vjBKiP8+EjPuxzeGb94XSoSLA/a3ST w4h6/7FVTYBSQ== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 6/8] selftests: arm64: Verify interoperation of SVE and FPSIMD register sets Date: Mon, 13 Sep 2021 13:55:03 +0100 Message-Id: <20210913125505.52619-7-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2060; h=from:subject; bh=X8xv6IhDmCpAV7VXVZkOxAjGP99z74IVeoo0V7Z/c4g=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0on4TOj9LdR5rFhDpLxeddoMFb9MuRaFRBSTZIZ Ck4OLe2JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KJwAKCRAk1otyXVSH0NEOB/ 9+M2GNcWCemczC/iZISUMtVAYSzRtNnOoqzXXznP1P2vTa2ZiXQDfPJQWAKVlnicYwSHuIpwQPv7Te 1pe+K15xcfaMXehSoJ0ri9SppRS/w7tIqLMI5qObFsccXDtJHEHnwg5x7DStbclIDBLVsveSHFn+EV UU2CovngjVOxtU5jNBVc/3uazsoJSV0OZvWPKuHVH6T2VgFgB+EYU1/ha0aUEfUKtAoZk+N7SN7M3A 5qMtJI07OrVkIYheNPR3miA5GVUhFES31TNuc6gNvgfChJc8JititdjpaLUOxKnM8xu4GznjwwC2HE VYo4rHsfITeNwdEmG91fQOmjbUv0UO X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org After setting the FPSIMD registers via the SVE register set read them back via the FPSIMD register set, validating that the two register sets are interoperating and that the values we thought we set made it into the child process. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 2d130fedc019..31a2c2fc529d 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -46,6 +46,15 @@ static int do_child(void) return EXIT_SUCCESS; } +static int get_fpsimd(pid_t pid, struct user_fpsimd_state *fpsimd) +{ + struct iovec iov; + + iov.iov_base = fpsimd; + iov.iov_len = sizeof(*fpsimd); + return ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov); +} + static struct user_sve_header *get_sve(pid_t pid, void **buf, size_t *size) { struct user_sve_header *sve; @@ -122,7 +131,7 @@ static int do_parent(pid_t child) void *svebuf = NULL, *newsvebuf; size_t svebufsz = 0, newsvebufsz; struct user_sve_header *sve, *new_sve; - struct user_fpsimd_state *fpsimd; + struct user_fpsimd_state *fpsimd, new_fpsimd; unsigned int i, j; unsigned char *p; unsigned int vq; @@ -221,7 +230,22 @@ static int do_parent(pid_t child) goto error; } - /* Zero the first SVE Z register */ + /* Verify via the FPSIMD regset */ + if (get_fpsimd(pid, &new_fpsimd)) { + int e = errno; + + ksft_test_result_fail("get_fpsimd(): %s\n", + strerror(errno)); + if (e == ESRCH) + goto disappeared; + + goto error; + } + if (memcmp(fpsimd, &new_fpsimd, sizeof(*fpsimd)) == 0) + ksft_test_result_pass("get_fpsimd() gave same state\n"); + else + ksft_test_result_fail("get_fpsimd() gave different state\n"); + vq = sve_vq_from_vl(sve->vl); newsvebufsz = SVE_PT_SVE_ZREG_OFFSET(vq, 1); From patchwork Mon Sep 13 12:55:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A57EEC433FE for ; Mon, 13 Sep 2021 13:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90A2F61222 for ; Mon, 13 Sep 2021 13:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240800AbhIMNXE (ORCPT ); Mon, 13 Sep 2021 09:23:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:34834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240291AbhIMNUz (ORCPT ); Mon, 13 Sep 2021 09:20:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC35061244; Mon, 13 Sep 2021 13:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539145; bh=AK5MU1Vtin6zPAr5TSyB+Mpt+EqnKSSIEA8U+75XCbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bqw7Wni5VRnrIcknq4q252Hr7TpA5iV8k6p/MDsCVykJ4evqYFlRMAtk4+uH5nJLj gZRYqYliXDcOoC0q8S94FV7IUVaXwfLKoNDbbZtQ4qhO9hCEYl2WiitD3iGJWSj75z FpEc0V6wwN4A/V7G07CJcsw3ECDCSRs/R5gA84icxxyvrH3uFYGpfHFkeSPKCha8QL PD0aaGaj53vqai1MnojBF9zC6UvAxPUSysSWRqDgdZ+NYR+hzv/w4O/2YoWS0bX2rp yu2Zr38aFoWysEXB/9SD4L7ZB813pPGKNXZ/HQTK1O5NPniUO+E6+v7XlwHhnhldI5 z2L2H7OkvaFMg== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 7/8] selftests: arm64: More comprehensively test the SVE ptrace interface Date: Mon, 13 Sep 2021 13:55:04 +0100 Message-Id: <20210913125505.52619-8-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=13348; h=from:subject; bh=AK5MU1Vtin6zPAr5TSyB+Mpt+EqnKSSIEA8U+75XCbU=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0onARW8FifMGIpjmcNioeHVa31VR4GF2WFGRGY4 OSbfIvCJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KJwAKCRAk1otyXVSH0JXEB/ wKGkvW2tsfCuCQ1M551LqB985W32RX++UtCsP1KS5VrCjIUJtWmM9oLKFF2rfdpjFV1AlcnlgEp1xw UDoR4jfU6YCDK7vDdfC8HXnxhn6Cc4SNZvbGYZ/rYVvuVYdb4JAXTvxXNRM/mNdDyl+cjl2HAPwJ/s lKbnU4biMpZ1gmkMmi3o4EVjJ6rJyp1n/O7rG6TY0bhXrP/HP0k48G0UCXcE3XomeOtM4PB1KILatr h5V9ZuHrFUGiVG/Zda62LcSO54NfMzELO0PRGIFG+rsEbnsYykrYMD8HzyCjynbM4tHRE+PJgqMTPU 6unu4theEPUBKuWJYYVriHO9wrDOpS X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently the selftest for the SVE register set is not quite as thorough as is desirable - it only validates that the value of a single Z register is not modified by a partial write to a lower numbered Z register after having previously been set through the FPSIMD regset. Make this more thorough: - Test the ability to set vector lengths and enumerate those supported in the system. - Validate data in all Z and P registers, plus FPSR and FPCR. - Test reads via the FPSIMD regset after set via the SVE regset. There's still some oversights, the main one being that due to the need to generate a pattern in FFR and the fact that this rewrite is primarily motivated by SME's streaming SVE which doesn't have FFR we don't currently test FFR. Update the TODO to reflect those that occurred to me (and fix an adjacent typo in there). Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/TODO | 9 +- tools/testing/selftests/arm64/fp/sve-ptrace.c | 327 +++++++++++++----- 2 files changed, 254 insertions(+), 82 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/TODO b/tools/testing/selftests/arm64/fp/TODO index b6b7ebfcf362..44004e53da33 100644 --- a/tools/testing/selftests/arm64/fp/TODO +++ b/tools/testing/selftests/arm64/fp/TODO @@ -1,4 +1,7 @@ - Test unsupported values in the ABIs. -- More coverage for ptrace (eg, vector length conversions). -- Coverage for signals. -- Test PR_SVE_VL_INHERITY after a double fork. +- More coverage for ptrace: + - Get/set of FFR. + - Ensure ptraced processes actually see the register state visible through + the ptrace interface. + - Big endian. +- Test PR_SVE_VL_INHERIT after a double fork. diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 31a2c2fc529d..199710ba65c7 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -1,15 +1,17 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (C) 2015-2020 ARM Limited. + * Copyright (C) 2015-2021 ARM Limited. * Original author: Dave Martin */ #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -19,20 +21,22 @@ #include "../../kselftest.h" -#define EXPECTED_TESTS 19 +#define VL_TESTS (((SVE_VQ_MAX - SVE_VQ_MIN) + 1) * 3) +#define FPSIMD_TESTS 3 + +#define EXPECTED_TESTS (VL_TESTS + FPSIMD_TESTS) /* and don't like each other, so: */ #ifndef NT_ARM_SVE #define NT_ARM_SVE 0x405 #endif -static void dump(const void *buf, size_t size) +static void fill_buf(char *buf, size_t size) { - size_t i; - const unsigned char *p = buf; + int i; - for (i = 0; i < size; ++i) - printf(" %.2x", *p++); + for (i = 0; i < size; i++) + buf[i] = random(); } static int do_child(void) @@ -101,25 +105,228 @@ static int set_sve(pid_t pid, const struct user_sve_header *sve) return ptrace(PTRACE_SETREGSET, pid, NT_ARM_SVE, &iov); } -static void dump_sve_regs(const struct user_sve_header *sve, unsigned int num, - unsigned int vlmax) +/* Validate attempting to set the specfied VL via ptrace */ +static void ptrace_set_get_vl(pid_t child, unsigned int vl, bool *supported) +{ + struct user_sve_header sve; + struct user_sve_header *new_sve = NULL; + size_t new_sve_size = 0; + int ret, prctl_vl; + + *supported = false; + + /* Check if the VL is supported in this process */ + prctl_vl = prctl(PR_SVE_SET_VL, vl); + if (prctl_vl == -1) + ksft_exit_fail_msg("prctl(PR_SVE_SET_VL) failed: %s (%d)\n", + strerror(errno), errno); + + /* If the VL is not supported then a supported VL will be returned */ + *supported = (prctl_vl == vl); + + /* Set the VL by doing a set with no register payload */ + memset(&sve, 0, sizeof(sve)); + sve.size = sizeof(sve); + sve.vl = vl; + ret = set_sve(child, &sve); + if (ret != 0) { + ksft_test_result_fail("Failed to set VL %u\n", vl); + return; + } + + /* + * Read back the new register state and verify that we have the + * same VL that we got from prctl() on ourselves. + */ + if (!get_sve(child, (void **)&new_sve, &new_sve_size)) { + ksft_test_result_fail("Failed to read VL %u\n", vl); + return; + } + + ksft_test_result(new_sve->vl = prctl_vl, "Set VL %u\n", vl); + + free(new_sve); +} + +static void check_u32(unsigned int vl, const char *reg, + uint32_t *in, uint32_t *out, int *errors) +{ + if (*in != *out) { + printf("# VL %d %s wrote %x read %x\n", + vl, reg, *in, *out); + (*errors)++; + } +} + +/* Validate attempting to set SVE data and read SVE data */ +static void ptrace_set_sve_get_sve_data(pid_t child, unsigned int vl) +{ + void *write_buf; + void *read_buf = NULL; + struct user_sve_header *write_sve; + struct user_sve_header *read_sve; + size_t read_sve_size = 0; + unsigned int vq = sve_vq_from_vl(vl); + int ret, i; + size_t data_size; + int errors = 0; + + data_size = SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, SVE_PT_REGS_SVE); + write_buf = malloc(data_size); + if (!write_buf) { + ksft_test_result_fail("Error allocating %d byte buffer for VL %u\n", + data_size, vl); + return; + } + write_sve = write_buf; + + /* Set up some data and write it out */ + memset(write_sve, 0, data_size); + write_sve->size = data_size; + write_sve->vl = vl; + write_sve->flags = SVE_PT_REGS_SVE; + + for (i = 0; i < __SVE_NUM_ZREGS; i++) + fill_buf(write_buf + SVE_PT_SVE_ZREG_OFFSET(vq, i), + SVE_PT_SVE_ZREG_SIZE(vq)); + + for (i = 0; i < __SVE_NUM_PREGS; i++) + fill_buf(write_buf + SVE_PT_SVE_PREG_OFFSET(vq, i), + SVE_PT_SVE_PREG_SIZE(vq)); + + fill_buf(write_buf + SVE_PT_SVE_FPSR_OFFSET(vq), SVE_PT_SVE_FPSR_SIZE); + fill_buf(write_buf + SVE_PT_SVE_FPCR_OFFSET(vq), SVE_PT_SVE_FPCR_SIZE); + + /* TODO: Generate a valid FFR pattern */ + + ret = set_sve(child, write_sve); + if (ret != 0) { + ksft_test_result_fail("Failed to set VL %u data\n", vl); + goto out; + } + + /* Read the data back */ + if (!get_sve(child, (void **)&read_buf, &read_sve_size)) { + ksft_test_result_fail("Failed to read VL %u data\n", vl); + goto out; + } + read_sve = read_buf; + + /* We might read more data if there's extensions we don't know */ + if (read_sve->size < write_sve->size) { + ksft_test_result_fail("Wrote %d bytes, only read %d\n", + write_sve->size, read_sve->size); + goto out_read; + } + + for (i = 0; i < __SVE_NUM_ZREGS; i++) { + if (memcmp(write_buf + SVE_PT_SVE_ZREG_OFFSET(vq, i), + read_buf + SVE_PT_SVE_ZREG_OFFSET(vq, i), + SVE_PT_SVE_ZREG_SIZE(vq)) != 0) { + printf("# Mismatch in %u Z%d\n", vl, i); + errors++; + } + } + + for (i = 0; i < __SVE_NUM_PREGS; i++) { + if (memcmp(write_buf + SVE_PT_SVE_PREG_OFFSET(vq, i), + read_buf + SVE_PT_SVE_PREG_OFFSET(vq, i), + SVE_PT_SVE_PREG_SIZE(vq)) != 0) { + printf("# Mismatch in %u P%d\n", vl, i); + errors++; + } + } + + check_u32(vl, "FPSR", write_buf + SVE_PT_SVE_FPSR_OFFSET(vq), + read_buf + SVE_PT_SVE_FPSR_OFFSET(vq), &errors); + check_u32(vl, "FPCR", write_buf + SVE_PT_SVE_FPCR_OFFSET(vq), + read_buf + SVE_PT_SVE_FPCR_OFFSET(vq), &errors); + + ksft_test_result(errors == 0, "Set and get SVE data for VL %u\n", vl); + +out_read: + free(read_buf); +out: + free(write_buf); +} + +/* Validate attempting to set SVE data and read SVE data */ +static void ptrace_set_sve_get_fpsimd_data(pid_t child, unsigned int vl) { - unsigned int vq; - unsigned int i; + void *write_buf; + struct user_sve_header *write_sve; + unsigned int vq = sve_vq_from_vl(vl); + struct user_fpsimd_state fpsimd_state; + int ret, i; + size_t data_size; + int errors = 0; + + if (__BYTE_ORDER == __BIG_ENDIAN) { + ksft_test_result_skip("Big endian not supported\n"); + return; + } + + data_size = SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, SVE_PT_REGS_SVE); + write_buf = malloc(data_size); + if (!write_buf) { + ksft_test_result_fail("Error allocating %d byte buffer for VL %u\n", + data_size, vl); + return; + } + write_sve = write_buf; - if ((sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_SVE) - ksft_exit_fail_msg("Dumping non-SVE register\n"); + /* Set up some data and write it out */ + memset(write_sve, 0, data_size); + write_sve->size = data_size; + write_sve->vl = vl; + write_sve->flags = SVE_PT_REGS_SVE; - if (vlmax > sve->vl) - vlmax = sve->vl; + for (i = 0; i < __SVE_NUM_ZREGS; i++) + fill_buf(write_buf + SVE_PT_SVE_ZREG_OFFSET(vq, i), + SVE_PT_SVE_ZREG_SIZE(vq)); - vq = sve_vq_from_vl(sve->vl); - for (i = 0; i < num; ++i) { - printf("# z%u:", i); - dump((const char *)sve + SVE_PT_SVE_ZREG_OFFSET(vq, i), - vlmax); - printf("%s\n", vlmax == sve->vl ? "" : " ..."); + fill_buf(write_buf + SVE_PT_SVE_FPSR_OFFSET(vq), SVE_PT_SVE_FPSR_SIZE); + fill_buf(write_buf + SVE_PT_SVE_FPCR_OFFSET(vq), SVE_PT_SVE_FPCR_SIZE); + + ret = set_sve(child, write_sve); + if (ret != 0) { + ksft_test_result_fail("Failed to set VL %u data\n", vl); + goto out; + } + + /* Read the data back */ + if (get_fpsimd(child, &fpsimd_state)) { + ksft_test_result_fail("Failed to read VL %u FPSIMD data\n", + vl); + goto out; + } + + for (i = 0; i < __SVE_NUM_ZREGS; i++) { + __uint128_t tmp = 0; + + /* + * Z regs are stored endianness invariant, this won't + * work for big endian + */ + memcpy(&tmp, write_buf + SVE_PT_SVE_ZREG_OFFSET(vq, i), + sizeof(tmp)); + + if (tmp != fpsimd_state.vregs[i]) { + printf("# Mismatch in FPSIMD for VL %u Z%d\n", vl, i); + errors++; + } } + + check_u32(vl, "FPSR", write_buf + SVE_PT_SVE_FPSR_OFFSET(vq), + &fpsimd_state.fpsr, &errors); + check_u32(vl, "FPCR", write_buf + SVE_PT_SVE_FPCR_OFFSET(vq), + &fpsimd_state.fpcr, &errors); + + ksft_test_result(errors == 0, "Set and get FPSIMD data for VL %u\n", + vl); + +out: + free(write_buf); } static int do_parent(pid_t child) @@ -128,13 +335,14 @@ static int do_parent(pid_t child) pid_t pid; int status; siginfo_t si; - void *svebuf = NULL, *newsvebuf; - size_t svebufsz = 0, newsvebufsz; - struct user_sve_header *sve, *new_sve; + void *svebuf = NULL; + size_t svebufsz = 0; + struct user_sve_header *sve; struct user_fpsimd_state *fpsimd, new_fpsimd; unsigned int i, j; unsigned char *p; - unsigned int vq; + unsigned int vq, vl; + bool vl_supported; /* Attach to the child */ while (1) { @@ -246,62 +454,21 @@ static int do_parent(pid_t child) else ksft_test_result_fail("get_fpsimd() gave different state\n"); - vq = sve_vq_from_vl(sve->vl); - - newsvebufsz = SVE_PT_SVE_ZREG_OFFSET(vq, 1); - new_sve = newsvebuf = malloc(newsvebufsz); - if (!new_sve) { - errno = ENOMEM; - perror(NULL); - goto error; - } - - *new_sve = *sve; - new_sve->flags &= ~SVE_PT_REGS_MASK; - new_sve->flags |= SVE_PT_REGS_SVE; - memset((char *)new_sve + SVE_PT_SVE_ZREG_OFFSET(vq, 0), - 0, SVE_PT_SVE_ZREG_SIZE(vq)); - new_sve->size = SVE_PT_SVE_ZREG_OFFSET(vq, 1); - if (set_sve(pid, new_sve)) { - int e = errno; - - ksft_test_result_fail("set_sve(ZREG): %s\n", strerror(errno)); - if (e == ESRCH) - goto disappeared; - - goto error; - } - - /* Try to read back the value we just set */ - new_sve = get_sve(pid, &newsvebuf, &newsvebufsz); - if (!new_sve) { - int e = errno; - - ksft_test_result_fail("get_sve(ZREG): %s\n", strerror(errno)); - if (e == ESRCH) - goto disappeared; + /* Step through every possible VQ */ + for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) { + vl = sve_vl_from_vq(vq); - goto error; - } - - ksft_test_result((new_sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE, - "Get SVE registers\n"); - if ((new_sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_SVE) - goto error; - - dump_sve_regs(new_sve, 3, sizeof fpsimd->vregs[0]); + /* First, try to set this vector length */ + ptrace_set_get_vl(child, vl, &vl_supported); - /* Verify that the register we set has the value we expected */ - p = (unsigned char *)new_sve + SVE_PT_SVE_ZREG_OFFSET(vq, 1); - for (i = 0; i < sizeof fpsimd->vregs[0]; ++i) { - unsigned char expected = i; - - if (__BYTE_ORDER == __BIG_ENDIAN) - expected = sizeof fpsimd->vregs[0] - 1 - expected; - - ksft_test_result(p[i] == expected, "buf[%d] == expected\n", i); - if (p[i] != expected) - goto error; + /* If the VL is supported validate data set/get */ + if (vl_supported) { + ptrace_set_sve_get_sve_data(child, vl); + ptrace_set_sve_get_fpsimd_data(child, vl); + } else { + ksft_test_result_skip("set SVE get SVE for VL %d\n", vl); + ksft_test_result_skip("set SVE get FPSIMD for VL %d\n", vl); + } } ret = EXIT_SUCCESS; @@ -318,6 +485,8 @@ int main(void) int ret = EXIT_SUCCESS; pid_t child; + srandom(getpid()); + ksft_print_header(); ksft_set_plan(EXPECTED_TESTS); From patchwork Mon Sep 13 12:55:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12489197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E9A4C433FE for ; Mon, 13 Sep 2021 13:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3165561108 for ; Mon, 13 Sep 2021 13:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240987AbhIMNW1 (ORCPT ); Mon, 13 Sep 2021 09:22:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240371AbhIMNUz (ORCPT ); Mon, 13 Sep 2021 09:20:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 753C46121E; Mon, 13 Sep 2021 13:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631539148; bh=19LgCb0jNuyXWq8SS9WLfTnJwPtwQWgyfCl8AU5M2vw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HAbtVzUmx1iUkdV/v3oNuS7K9gsBnwC6mmcdeFX7d/rmWwA/58ZEoAx925pq178N3 l28tz0iU+/CgcDKutgycjYmwv1HT0rvJSifVxJmlLpcX2F7wSRdf2Z79RG8w90F+dQ O8uE02193sRslJM11jdVBsJpUXkMAcWAlJgRO/16H+FJVxrk63lge/Lik9dApMBwJY 8iEom3leKHjXt2X/Z6nLkm1naXy6hKz77pzpp8p/yY4nC60Mfk5RFK+tOX63+7QIN6 /21dWSL42g5XCQzp7S94xi4ktE42Sl1b/3LnJ2X5MJLMdFg0n9DSH6VdC8lfCQudZO pdVBjpVW430mg== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v1 8/8] selftests: arm64: Move FPSIMD in SVE ptrace test into a function Date: Mon, 13 Sep 2021 13:55:05 +0100 Message-Id: <20210913125505.52619-9-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210913125505.52619-1-broonie@kernel.org> References: <20210913125505.52619-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4457; h=from:subject; bh=19LgCb0jNuyXWq8SS9WLfTnJwPtwQWgyfCl8AU5M2vw=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhP0ooWOgJwwkTSHtiHMRDt9lwHtGMZLxP9rmNDEjB E8ksnFOJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYT9KKAAKCRAk1otyXVSH0JIqB/ 4tJv0ZPlsao1/1W57eiGm/csE8cjOsTPyt8h5+XC2LWHjXC5H8/06uJdqogPHzBY4ufqN0T5iK7eK/ vYDwIzSYqBcEhwkzcRWXj88YVpgI2HnFZCJFFAq0NuxWLalcfmT1nKdnTNcRu+d86Q274bCKl06Ivl 9bHtLz64Ed+1hXE9iH6LHKPeeh8tgyxVI3FncFAmsbpzYQ8zcEyNG2seNV+KNLVBzoJdVqYWuuSuG7 tT9KPqEPHQ+A0VjrH9w3s53p/zKpi4eMgalVJAGUIAX/KWbE+Xue03H9D4Atk0yX1olehD5VSRoUsD sQlPleuu6hCjKeijDSvpegnFjnSQ2z X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Now that all the other tests are in functions rather than inline in the main parent process function also move the test for accessing the FPSIMD registers via the SVE regset out into their own function. Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 120 +++++++++--------- 1 file changed, 59 insertions(+), 61 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 199710ba65c7..ac0629f05365 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -158,6 +158,63 @@ static void check_u32(unsigned int vl, const char *reg, } } +/* Access the FPSIMD registers via the SVE regset */ +static void ptrace_sve_fpsimd(pid_t child) +{ + void *svebuf = NULL; + size_t svebufsz = 0; + struct user_sve_header *sve; + struct user_fpsimd_state *fpsimd, new_fpsimd; + unsigned int i, j; + unsigned char *p; + + /* New process should start with FPSIMD registers only */ + sve = get_sve(child, &svebuf, &svebufsz); + if (!sve) { + ksft_test_result_fail("get_sve: %s\n", strerror(errno)); + + return; + } else { + ksft_test_result_pass("get_sve(FPSIMD)\n"); + } + + ksft_test_result((sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD, + "Set FPSIMD registers\n"); + if ((sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_FPSIMD) + goto out; + + /* Try to set a known FPSIMD state via PT_REGS_SVE */ + fpsimd = (struct user_fpsimd_state *)((char *)sve + + SVE_PT_FPSIMD_OFFSET); + for (i = 0; i < 32; ++i) { + p = (unsigned char *)&fpsimd->vregs[i]; + + for (j = 0; j < sizeof(fpsimd->vregs[i]); ++j) + p[j] = j; + } + + if (set_sve(child, sve)) { + ksft_test_result_fail("set_sve(FPSIMD): %s\n", + strerror(errno)); + + goto out; + } + + /* Verify via the FPSIMD regset */ + if (get_fpsimd(child, &new_fpsimd)) { + ksft_test_result_fail("get_fpsimd(): %s\n", + strerror(errno)); + goto out; + } + if (memcmp(fpsimd, &new_fpsimd, sizeof(*fpsimd)) == 0) + ksft_test_result_pass("get_fpsimd() gave same state\n"); + else + ksft_test_result_fail("get_fpsimd() gave different state\n"); + +out: + free(svebuf); +} + /* Validate attempting to set SVE data and read SVE data */ static void ptrace_set_sve_get_sve_data(pid_t child, unsigned int vl) { @@ -335,12 +392,6 @@ static int do_parent(pid_t child) pid_t pid; int status; siginfo_t si; - void *svebuf = NULL; - size_t svebufsz = 0; - struct user_sve_header *sve; - struct user_fpsimd_state *fpsimd, new_fpsimd; - unsigned int i, j; - unsigned char *p; unsigned int vq, vl; bool vl_supported; @@ -398,61 +449,8 @@ static int do_parent(pid_t child) } } - /* New process should start with FPSIMD registers only */ - sve = get_sve(pid, &svebuf, &svebufsz); - if (!sve) { - int e = errno; - - ksft_test_result_fail("get_sve: %s\n", strerror(errno)); - if (e == ESRCH) - goto disappeared; - - goto error; - } else { - ksft_test_result_pass("get_sve(FPSIMD)\n"); - } - - ksft_test_result((sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD, - "Set FPSIMD registers\n"); - if ((sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_FPSIMD) - goto error; - - /* Try to set a known FPSIMD state via PT_REGS_SVE */ - fpsimd = (struct user_fpsimd_state *)((char *)sve + - SVE_PT_FPSIMD_OFFSET); - for (i = 0; i < 32; ++i) { - p = (unsigned char *)&fpsimd->vregs[i]; - - for (j = 0; j < sizeof fpsimd->vregs[i]; ++j) - p[j] = j; - } - - if (set_sve(pid, sve)) { - int e = errno; - - ksft_test_result_fail("set_sve(FPSIMD): %s\n", - strerror(errno)); - if (e == ESRCH) - goto disappeared; - - goto error; - } - - /* Verify via the FPSIMD regset */ - if (get_fpsimd(pid, &new_fpsimd)) { - int e = errno; - - ksft_test_result_fail("get_fpsimd(): %s\n", - strerror(errno)); - if (e == ESRCH) - goto disappeared; - - goto error; - } - if (memcmp(fpsimd, &new_fpsimd, sizeof(*fpsimd)) == 0) - ksft_test_result_pass("get_fpsimd() gave same state\n"); - else - ksft_test_result_fail("get_fpsimd() gave different state\n"); + /* FPSIMD via SVE regset */ + ptrace_sve_fpsimd(child); /* Step through every possible VQ */ for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; vq++) {