mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zenghui Yu <yuzenghui@huawei.com>
To: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>, Oleg Nesterov <oleg@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	David Spickett <david.spickett@arm.com>,
	Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	Luis Machado <luis.machado.foss@gmail.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kselftest@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-doc@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] kselftst/arm64: Test NT_ARM_SVE FPSIMD format writes on non-SVE systems
Date: Mon, 16 Nov 2026 20:31:32 +0800	[thread overview]
Message-ID: <e5b40037-8314-9ad2-91e0-9347109bed31@huawei.com> (raw)
In-Reply-To: <20251015-arm64-sme-ptrace-sme-only-v2-2-33c7b2f27cbf@kernel.org>

On 2025/10/16 1:56, Mark Brown wrote:
> In order to allow exiting streaming mode on systems with SME but not SVE
> we allow writes of FPSIMD format data via NT_ARM_SVE even when SVE is not
> supported, add a test case that covers this to sve-ptrace.
> 
> We do not support reads.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  tools/testing/selftests/arm64/fp/sve-ptrace.c | 61 +++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
> 
> diff --git a/tools/testing/selftests/arm64/fp/sve-ptrace.c b/tools/testing/selftests/arm64/fp/sve-ptrace.c
> index e0fc3a001e28..f44d44618575 100644
> --- a/tools/testing/selftests/arm64/fp/sve-ptrace.c
> +++ b/tools/testing/selftests/arm64/fp/sve-ptrace.c
> @@ -394,6 +394,58 @@ static void ptrace_sve_fpsimd(pid_t child, const struct vec_type *type)
>  	free(svebuf);
>  }
>  
> +/* Write the FPSIMD registers via the SVE regset when SVE is not supported */
> +static void ptrace_sve_fpsimd_no_sve(pid_t child)
> +{
> +	void *svebuf;
> +	struct user_sve_header *sve;
> +	struct user_fpsimd_state *fpsimd, new_fpsimd;
> +	unsigned int i, j;
> +	unsigned char *p;
> +	int ret;
> +
> +	svebuf = malloc(SVE_PT_SIZE(0, SVE_PT_REGS_FPSIMD));
> +	if (!svebuf) {
> +		ksft_test_result_fail("Failed to allocate FPSIMD buffer\n");
> +		return;
> +	}
> +
> +	/* On a system without SVE the VL should be set to 0 */
> +	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 = 0;
> +
> +	/* 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;
> +	}
> +
> +	ret = set_sve(child, &vec_types[0], sve);
> +	ksft_test_result(ret == 0, "FPSIMD write via SVE\n");
> +	if (ret) {
> +		ksft_test_result_skip("Verify FPSIMD write via SVE\n");
> +		goto out;
> +	}
> +
> +	/* Verify via the FPSIMD regset */
> +	if (get_fpsimd(child, &new_fpsimd)) {
> +		ksft_test_result_skip("Verify FPSIMD write via SVE\n");
> +		goto out;
> +	}
> +	ksft_test_result(memcmp(fpsimd, &new_fpsimd, sizeof(*fpsimd)) == 0,
> +			 "Verify FPSIMD write via SVE\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,
>  					const struct vec_type *type,
> @@ -826,6 +878,15 @@ static int do_parent(pid_t child)
>  		}
>  	}
>  
> +	/* We support SVE writes of FPSMID format on SME only systems */
> +	if (!(getauxval(AT_HWCAP) & HWCAP_SVE) &&
> +	    (getauxval(AT_HWCAP2) & HWCAP2_SME)) {
> +		ptrace_sve_fpsimd_no_sve(child);
> +	} else {
> +		ksft_test_result_skip("FPSIMD write via SVE\n");
> +		ksft_test_result_skip("Verify FPSIMD write via SVE\n");
> +	}

I haven't read the patch in detail, but it seems that we should update
EXPECTED_TESTS accordingly.

  reply	other threads:[~2026-11-16 12:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 17:56 [PATCH v2 0/3] arm64/sme: Support disabling streaming mode via ptrace on SME only systems Mark Brown
2025-10-15 17:56 ` [PATCH v2 1/3] " Mark Brown
2025-10-29 15:23   ` David Spickett
2025-10-15 17:56 ` [PATCH v2 2/3] kselftst/arm64: Test NT_ARM_SVE FPSIMD format writes on non-SVE systems Mark Brown
2026-11-16 12:31   ` Zenghui Yu [this message]
2025-10-15 17:56 ` [PATCH v2 3/3] kselftest/arm64: Cover disabling streaming mode without SVE in fp-ptrace Mark Brown
2025-11-17 21:00 ` [PATCH v2 0/3] arm64/sme: Support disabling streaming mode via ptrace on SME only systems Catalin Marinas
2025-11-21 11:25   ` Luis
2025-11-21 16:30     ` Thiago Jung Bauermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5b40037-8314-9ad2-91e0-9347109bed31@huawei.com \
    --to=yuzenghui@huawei.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=david.spickett@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luis.machado.foss@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=oleg@redhat.com \
    --cc=shuah@kernel.org \
    --cc=thiago.bauermann@linaro.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®