From patchwork Wed Mar 9 11:59:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12774992 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 BD46FC433F5 for ; Wed, 9 Mar 2022 12:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbiCIMBF (ORCPT ); Wed, 9 Mar 2022 07:01:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232563AbiCIMBD (ORCPT ); Wed, 9 Mar 2022 07:01:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B3E310075C for ; Wed, 9 Mar 2022 04:00:05 -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 1C3D06190D for ; Wed, 9 Mar 2022 12:00:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FAB1C340F5; Wed, 9 Mar 2022 12:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646827204; bh=ShIBATOODCLF6f7ab34iknbp1vswlDy8eIw8Vvx7nl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ulu0LLrD8e2xNBkaXDnfqt/aAPW2SyMLJM4FB7CkpNTRl7qh3wqo5cNqidWAfYJ+q TZJXhHAjK1YIgTFa8w2NBaM2acvue70Xmo7NvqSEBiDb7XYgDSA23zXQ7gz97AeG4v wReeG2ahEo1eoFtGpH55B244HzMexVh9IedaWfzFdP7ur//jkXoVZwFiOrkeUzobR6 89q8r22r69OFdPIStf1xlfcEB20qI6YrR46uPUw6iiltZfCPLIvV+KQUuEg7BpaLRj NV+FmKvOEXiF3aW1QozFzWhsz3NUZsRwNw6vkC1tMUoJXG8ZPt58n1VUXW84DQ8adR FWmueHPdPWJJg== 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/3] kselftest/arm64: Fix comment for ptrace_sve_get_fpsimd_data() Date: Wed, 9 Mar 2022 11:59:16 +0000 Message-Id: <20220309115918.22469-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220309115918.22469-1-broonie@kernel.org> References: <20220309115918.22469-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=894; h=from:subject; bh=ShIBATOODCLF6f7ab34iknbp1vswlDy8eIw8Vvx7nl0=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiKJaTxnXbzoI6bSlH27xH6SBI5RY/EfC3j2GtSasI myU2UI6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYiiWkwAKCRAk1otyXVSH0F3aB/ 9Y4laTrOBcGmGGx7/JSK5sZlfLqdJyzyLcn9C6T2UUTiah2Mzd90iqwoEHV1c+C7QCPvbBoXkifKD9 kEYZFZhRsI02V1DxJzAAEZDAPfVIL+Rt3kaKUCQ72XQpWR92y6iPM45CZKxE2RVdjMRzHPfSyvXl3u RVF2CE8WN0UCbVAumWDbhgIG8By8QvQSBpP0eLkPsgcIX5hsT5fB74BHBqLUYa+Q4Pc3cKv7zp+pfu pskro6G4TBmNepdfOjsqjbHkznUwtmJGw5LZ/jpOctybHp1FOX2PXK/cXawuU32wnVdwdXxkHt/MBq DldHnVvPNWVclcZ/a1gByiP8wM4zfO X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The comment for ptrace_sve_get_fpsimd_data() doesn't describe what the test does at all, fix that. Signed-off-by: Mark Brown Reviewed-by: Shuah Khan --- 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 a3c1e67441f9..6b139d5f67f1 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -397,7 +397,7 @@ static void ptrace_set_sve_get_sve_data(pid_t child, free(write_buf); } -/* Validate attempting to set SVE data and read SVE data */ +/* Validate attempting to set SVE data and read it via the FPSIMD regset */ static void ptrace_set_sve_get_fpsimd_data(pid_t child, const struct vec_type *type, unsigned int vl) From patchwork Wed Mar 9 11:59:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12774993 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 0B9FBC433F5 for ; Wed, 9 Mar 2022 12:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232556AbiCIMBL (ORCPT ); Wed, 9 Mar 2022 07:01:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbiCIMBJ (ORCPT ); Wed, 9 Mar 2022 07:01:09 -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 D213A101F0F for ; Wed, 9 Mar 2022 04:00:09 -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 2E240B8210E for ; Wed, 9 Mar 2022 12:00:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15488C340F3; Wed, 9 Mar 2022 12:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646827207; bh=2E7uIWYZCN8xmFIKClu5aTL1Cz8xGvqQNKDpgLwojB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YIaPG2itm+d1Cq3Hsu3ishi6xLMK+D2Nl/7QfUq1tiTsuLeIbRoT61oAf1GP+y2Jl AcjharWr1bEGsfTj9iPioy+6BuRlntL+X/nW+kwqP/yMYATrw29c7qnvjVPjjMPh06 qL/FYJlmdBdcC31x2SSxrm6IsH39rL4AO4w8wEZutVtTBXXlFWOqnTxjYhd1chg9Rv MiG4xIbkOgSpnMmtbXGzYEJc4qTR8RScVXt7VNuPX+/2z6xu0BilZU5TDyIqgiWK2k q8AYIZw9N6VVwcn9+ywlIgBRaDNudtJuWKCbdYyiG3Iz/YiMyyhy+ry/rBtFeG1Wuu iCsgFV1JHAlZg== 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/3] kselftest/arm64: Remove assumption that tasks start FPSIMD only Date: Wed, 9 Mar 2022 11:59:17 +0000 Message-Id: <20220309115918.22469-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220309115918.22469-1-broonie@kernel.org> References: <20220309115918.22469-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3664; h=from:subject; bh=2E7uIWYZCN8xmFIKClu5aTL1Cz8xGvqQNKDpgLwojB0=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiKJaU0Ers4ZA/fEotvJMU9VjcJZERn1z0mR+qPTRR CTXvcfiJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYiiWlAAKCRAk1otyXVSH0C/0B/ 9BkdjiX2NsN2ez4+qj7rn2gEkXLmjPgXPoUBtlam3O1FOb/BHpKg6C3UN2V0jneFGeMCQPZWfxbFvS KrzGCBrDjSWN0dDLvj/9I3O3/Ntb0ddoqI/2d89AGd+YRj9PUFSvD0kHApY0pBwub3sFajH2nHZhbP s3KHBRmCIU3Kgh93sUHLQhSaUTbXt8e+fgcCDwdvwCDpIqyJ+J3UOjIjtJKXostXbXcRkhQsSeEYIW VnK828iLsn7Ur6ysBjYfTx3m6wX+Hw2AbiZfQuK2w8N1NpaGQ6CJEG0moqC97LN4jIeC4F8mJlOB0M BGDV3VdZERE/C7FfsmfQOqNjUCU+1Y 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 sve-ptrace test for setting and reading FPSIMD data assumes that the child will start off in FPSIMD only mode and that it can use this to read some FPSIMD mode SVE ptrace data, skipping the test if it can't. This isn't an assumption guaranteed by the ABI and also limits how we can use this testcase within the program. Instead skip the initial read and just generate a FPSIMD format buffer for the write part of the test, making the coverage more robust in the face of future kernel and test program changes. Signed-off-by: Mark Brown Reviewed-by: Shuah Khan --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index 6b139d5f67f1..ccd3ff1e8c06 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -48,7 +48,7 @@ static const struct vec_type vec_types[] = { #define VL_TESTS (((SVE_VQ_MAX - SVE_VQ_MIN) + 1) * 3) #define FLAG_TESTS 2 -#define FPSIMD_TESTS 3 +#define FPSIMD_TESTS 2 #define EXPECTED_TESTS ((VL_TESTS + FLAG_TESTS + FPSIMD_TESTS) * ARRAY_SIZE(vec_types)) @@ -242,28 +242,24 @@ 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, const struct vec_type *type) { - void *svebuf = NULL; - size_t svebufsz = 0; + void *svebuf; struct user_sve_header *sve; struct user_fpsimd_state *fpsimd, new_fpsimd; unsigned int i, j; unsigned char *p; + int ret; - /* New process should start with FPSIMD registers only */ - sve = get_sve(child, type, &svebuf, &svebufsz); - if (!sve) { - ksft_test_result_fail("get_sve(%s): %s\n", - type->name, strerror(errno)); - + svebuf = malloc(SVE_PT_SIZE(0, SVE_PT_REGS_FPSIMD)); + if (!svebuf) { + ksft_test_result_fail("Failed to allocate FPSIMD buffer\n"); return; - } else { - ksft_test_result_pass("get_sve(%s FPSIMD)\n", type->name); } - ksft_test_result((sve->flags & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD, - "Got FPSIMD registers via %s\n", type->name); - if ((sve->flags & SVE_PT_REGS_MASK) != SVE_PT_REGS_FPSIMD) - goto out; + memset(svebuf, 0, SVE_PT_SIZE(0, SVE_PT_REGS_FPSIMD)); + sve = svebuf; + sve->flags = SVE_PT_REGS_FPSIMD; + sve->size = SVE_PT_SIZE(0, SVE_PT_REGS_FPSIMD); + sve->vl = 16; /* We don't care what the VL is */ /* Try to set a known FPSIMD state via PT_REGS_SVE */ fpsimd = (struct user_fpsimd_state *)((char *)sve + @@ -275,12 +271,11 @@ static void ptrace_sve_fpsimd(pid_t child, const struct vec_type *type) p[j] = j; } - if (set_sve(child, type, sve)) { - ksft_test_result_fail("set_sve(%s FPSIMD): %s\n", - type->name, strerror(errno)); - + ret = set_sve(child, type, sve); + ksft_test_result(ret == 0, "%s FPSIMD set via SVE: %d\n", + type->name, ret); + if (ret) goto out; - } /* Verify via the FPSIMD regset */ if (get_fpsimd(child, &new_fpsimd)) { @@ -548,11 +543,9 @@ static int do_parent(pid_t child) if (getauxval(vec_types[i].hwcap_type) & vec_types[i].hwcap) { ptrace_sve_fpsimd(child, &vec_types[i]); } else { - ksft_test_result_skip("%s FPSIMD get via SVE\n", - vec_types[i].name); ksft_test_result_skip("%s FPSIMD set via SVE\n", vec_types[i].name); - ksft_test_result_skip("%s set read via FPSIMD\n", + ksft_test_result_skip("%s FPSIMD read\n", vec_types[i].name); } From patchwork Wed Mar 9 11:59:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12774994 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 8F484C433EF for ; Wed, 9 Mar 2022 12:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232559AbiCIMBM (ORCPT ); Wed, 9 Mar 2022 07:01:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232504AbiCIMBK (ORCPT ); Wed, 9 Mar 2022 07:01:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 803BB101F1F for ; Wed, 9 Mar 2022 04:00:11 -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 1CE9D61900 for ; Wed, 9 Mar 2022 12:00:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81643C340F5; Wed, 9 Mar 2022 12:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646827210; bh=Vlup48Xgnsiv7OUsMwoDzP6QOt9jogCej0lZhuCOeX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVGKDytz8Dn6b85MNydpKd6tbs1rxMb9C1ENxay+VvuocM20fYoI7TqbWmqY6MbZ8 gfD/Q0/J2mycv8Lw90pL5dUlt/5THjNMBOYPrUXvyPxBnRabTTnZo106dMQtJJstoA ZvXhg7Ha58VgacVrOnso1SXbtayyL0shHeLvhcpcq8fXvgtsCnRHw32DrE3Ox1euY8 miPmU9zd3cf2d6qznuHjvKsWTQNlcpNIa1PEOAIAcWzs1VZkTFgYAxw3jgN224bZjV r2+UrkwvuoEjph3/+iKpt23I+K4niTZKNGlcH46mH8cMyw4wH86eSSoMX8mV+sOBRp 4P8dma9S0yCuw== 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/3] kselftest/arm64: Validate setting via FPSIMD and read via SVE regsets Date: Wed, 9 Mar 2022 11:59:18 +0000 Message-Id: <20220309115918.22469-4-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220309115918.22469-1-broonie@kernel.org> References: <20220309115918.22469-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5345; h=from:subject; bh=Vlup48Xgnsiv7OUsMwoDzP6QOt9jogCej0lZhuCOeX4=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiKJaUdVzNxXsur79b5JVRLjrtkNxCJ6glZwyldm7f GItPLZ+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYiiWlAAKCRAk1otyXVSH0BEHB/ 4y/G3CLl0XoeL35UUo1FI2WKZhIjM6GWVMaANvfJpuDGh3xiBiqtfQtJwtO1HMaFfYbEddNUmGnDu8 ioYAoIAkgB03OywUFO4XTouyolPR8ZrryrWldu5hSsuhjxVLDzXH+eF5FVHynAN2V9MLvOWWfEjJJl u5zHum+pdT46DYT0HIHiPum6HCy6GP8/vn/KoayGyonTeFvOfpR6fVnS8dY0KkmZpeOfVd/OZ+KiYm i2g61a3T2jkP6TKMrBHxvcROPj1m5ltBD1ZYNp9rdGsRp2K94h2VCywY5s/YAsL/306TE1uKvhKSAq 6QvSTJ9lAJ4TtUs4hmJrqjY2Pv22Xc 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 validate that we can set the floating point state via the SVE regset and read the data via the FPSIMD regset but we do not valiate that the opposite case works as expected. Add a test that covers this case, noting that when reading via SVE regset the kernel has the option of returning either SVE or FPSIMD data so we need to accept both formats. Signed-off-by: Mark Brown Reviewed-by: Shuah Khan --- tools/testing/selftests/arm64/fp/sve-ptrace.c | 123 +++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c index ccd3ff1e8c06..cdfb5107fd0c 100644 --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c @@ -46,7 +46,7 @@ static const struct vec_type vec_types[] = { }, }; -#define VL_TESTS (((SVE_VQ_MAX - SVE_VQ_MIN) + 1) * 3) +#define VL_TESTS (((SVE_VQ_MAX - SVE_VQ_MIN) + 1) * 4) #define FLAG_TESTS 2 #define FPSIMD_TESTS 2 @@ -80,6 +80,15 @@ static int get_fpsimd(pid_t pid, struct user_fpsimd_state *fpsimd) return ptrace(PTRACE_GETREGSET, pid, NT_PRFPREG, &iov); } +static int set_fpsimd(pid_t pid, struct user_fpsimd_state *fpsimd) +{ + struct iovec iov; + + iov.iov_base = fpsimd; + iov.iov_len = sizeof(*fpsimd); + return ptrace(PTRACE_SETREGSET, pid, NT_PRFPREG, &iov); +} + static struct user_sve_header *get_sve(pid_t pid, const struct vec_type *type, void **buf, size_t *size) { @@ -475,6 +484,115 @@ static void ptrace_set_sve_get_fpsimd_data(pid_t child, free(write_buf); } +/* Validate attempting to set FPSIMD data and read it via the SVE regset */ +static void ptrace_set_fpsimd_get_sve_data(pid_t child, + const struct vec_type *type, + unsigned int vl) +{ + void *read_buf = NULL; + unsigned char *p; + struct user_sve_header *read_sve; + unsigned int vq = sve_vq_from_vl(vl); + struct user_fpsimd_state write_fpsimd; + int ret, i, j; + size_t read_sve_size = 0; + size_t expected_size; + int errors = 0; + + if (__BYTE_ORDER == __BIG_ENDIAN) { + ksft_test_result_skip("Big endian not supported\n"); + return; + } + + for (i = 0; i < 32; ++i) { + p = (unsigned char *)&write_fpsimd.vregs[i]; + + for (j = 0; j < sizeof(write_fpsimd.vregs[i]); ++j) + p[j] = j; + } + + ret = set_fpsimd(child, &write_fpsimd); + if (ret != 0) { + ksft_test_result_fail("Failed to set FPSIMD state: %d\n)", + ret); + return; + } + + if (!get_sve(child, type, (void **)&read_buf, &read_sve_size)) { + ksft_test_result_fail("Failed to read %s VL %u data\n", + type->name, vl); + return; + } + read_sve = read_buf; + + if (read_sve->vl != vl) { + ksft_test_result_fail("Child VL != expected VL %d\n", + read_sve->vl, vl); + goto out; + } + + /* The kernel may return either SVE or FPSIMD format */ + switch (read_sve->flags & SVE_PT_REGS_MASK) { + case SVE_PT_REGS_FPSIMD: + expected_size = SVE_PT_FPSIMD_SIZE(vq, SVE_PT_REGS_FPSIMD); + if (read_sve_size < expected_size) { + ksft_test_result_fail("Read %d bytes, expected %d\n", + read_sve_size, expected_size); + goto out; + } + + ret = memcmp(&write_fpsimd, read_buf + SVE_PT_FPSIMD_OFFSET, + sizeof(write_fpsimd)); + if (ret != 0) { + ksft_print_msg("Read FPSIMD data mismatch\n"); + errors++; + } + break; + + case SVE_PT_REGS_SVE: + expected_size = SVE_PT_SVE_SIZE(vq, SVE_PT_REGS_SVE); + if (read_sve_size < expected_size) { + ksft_test_result_fail("Read %d bytes, expected %d\n", + read_sve_size, expected_size); + 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, read_buf + SVE_PT_SVE_ZREG_OFFSET(vq, i), + sizeof(tmp)); + + if (tmp != write_fpsimd.vregs[i]) { + ksft_print_msg("Mismatch in FPSIMD for %s VL %u Z%d/V%d\n", + type->name, vl, i, i); + errors++; + } + } + + check_u32(vl, "FPSR", &write_fpsimd.fpsr, + read_buf + SVE_PT_SVE_FPSR_OFFSET(vq), &errors); + check_u32(vl, "FPCR", &write_fpsimd.fpcr, + read_buf + SVE_PT_SVE_FPCR_OFFSET(vq), &errors); + break; + default: + ksft_print_msg("Unexpected regs type %d\n", + read_sve->flags & SVE_PT_REGS_MASK); + errors++; + break; + } + + ksft_test_result(errors == 0, "Set FPSIMD, read via SVE for %s VL %u\n", + type->name, vl); + +out: + free(read_buf); +} + static int do_parent(pid_t child) { int ret = EXIT_FAILURE; @@ -578,11 +696,14 @@ static int do_parent(pid_t child) if (vl_supported) { ptrace_set_sve_get_sve_data(child, &vec_types[i], vl); ptrace_set_sve_get_fpsimd_data(child, &vec_types[i], vl); + ptrace_set_fpsimd_get_sve_data(child, &vec_types[i], vl); } else { ksft_test_result_skip("%s set SVE get SVE for VL %d\n", vec_types[i].name, vl); ksft_test_result_skip("%s set SVE get FPSIMD for VL %d\n", vec_types[i].name, vl); + ksft_test_result_skip("%s set FPSIMD get SVE for VL %d\n", + vec_types[i].name, vl); } } }