public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <Catalin.Marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved SVE state
Date: Fri, 19 Jan 2024 16:31:13 +0000	[thread overview]
Message-ID: <Zaqj0V82LD8wu6g+@e133380.arm.com> (raw)
In-Reply-To: <20240119-arm64-sve-signal-regs-v1-1-b9fd61b0289a@kernel.org>

On Fri, Jan 19, 2024 at 12:29:13PM +0000, Mark Brown wrote:
> When we are in a syscall we will only save the FPSIMD subset even though
> the task still has access to the full register set, and on context switch

(Pedantic nit: "A even if B" (= "A applies even in that subset of cases
where B"), instead of "A even though B" (= "A applies notwithstanding
that it is always the case that B") (?)  If the SVE trapping were
ripped out altogether, it would be a different and rather simpler
story...)

> we will only remove TIF_SVE when loading the register state. This means
> that the signal handling code should not assume that TIF_SVE means that
> the register state is stored in SVE format, it should instead check the
> format that was recorded during save.
> 
> Fixes: 8c845e273104 ("arm64/sve: Leave SVE enabled on syscall if we don't context switch")
> Signed-off-by: Mark Brown <broonie@kernel.org>
> Cc:  <stable@vger.kernel.org>
> ---
>  arch/arm64/kernel/fpsimd.c | 2 +-
>  arch/arm64/kernel/signal.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index 1559c706d32d..80133c190136 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -1626,7 +1626,7 @@ void fpsimd_preserve_current_state(void)
>  void fpsimd_signal_preserve_current_state(void)
>  {
>  	fpsimd_preserve_current_state();
> -	if (test_thread_flag(TIF_SVE))
> +	if (current->thread.fp_type == FP_STATE_SVE)
>  		sve_to_fpsimd(current);
>  }
>  
> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index 0e8beb3349ea..425b1bc17a3f 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
> @@ -242,7 +242,7 @@ static int preserve_sve_context(struct sve_context __user *ctx)
>  		vl = task_get_sme_vl(current);
>  		vq = sve_vq_from_vl(vl);
>  		flags |= SVE_SIG_FLAG_SM;
> -	} else if (test_thread_flag(TIF_SVE)) {
> +	} else if (current->thread.fp_type == FP_STATE_SVE) {
>  		vq = sve_vq_from_vl(vl);
>  	}
>  
> @@ -878,7 +878,7 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user,
>  	if (system_supports_sve() || system_supports_sme()) {
>  		unsigned int vq = 0;
>  
> -		if (add_all || test_thread_flag(TIF_SVE) ||
> +		if (add_all || current->thread.fp_type == FP_STATE_SVE ||
>  		    thread_sm_enabled(&current->thread)) {
>  			int vl = max(sve_max_vl(), sme_max_vl());
>  
> 
> ---
> base-commit: 0dd3ee31125508cd67f7e7172247f05b7fd1753a
> change-id: 20240118-arm64-sve-signal-regs-5711e0d10425
> 
> Best regards,
> -- 
> Mark Brown <broonie@kernel.org>
> 

[...]

If the historical meanings of TIF_SVE have been split up (which seems a
good idea), does that resolve all of the "bare"
test_thread_flag(TIF_SVE) that were still there?

If there are any others remaining, they may need looking at if there is
any question over what condition they are trying to test for...

Cheers
---Dave

  reply	other threads:[~2024-01-19 16:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 12:29 [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved SVE state Mark Brown
2024-01-19 16:31 ` Dave Martin [this message]
2024-01-19 17:47   ` Mark Brown
2024-01-23 15:15     ` Dave Martin
2024-01-23 18:55       ` Mark Brown
2024-01-30 11:51 ` Will Deacon
2024-01-30 14:09   ` Mark Brown
2024-01-30 14:44     ` Dave Martin
2024-01-30 14:53       ` Mark Brown
2024-01-30 15:47         ` Dave Martin
2024-01-30 15:42       ` Mark Brown

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=Zaqj0V82LD8wu6g+@e133380.arm.com \
    --to=dave.martin@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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