kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Zhang Lei <zhang.lei@jp.fujitsu.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 5/7] arm64/fpsimd: Load FP state based on recorded data type
Date: Tue, 20 Sep 2022 19:19:57 +0100	[thread overview]
Message-ID: <87tu51kiwi.wl-maz@kernel.org> (raw)
In-Reply-To: <20220815225529.930315-6-broonie@kernel.org>

On Mon, 15 Aug 2022 23:55:27 +0100,
Mark Brown <broonie@kernel.org> wrote:
> 
> Now that we are recording the type of floating point register state we
> are saving when we save it we can use that information when we load to
> decide which register state is required and bring the TIF_SVE state into
> sync with the loaded register state.

Really, this sentence makes zero sense to me. Please at least add some
punctuation, because the only words that spring to mind here are "DOES
NOT COMPUTE".

> 
> The SME state detauls are already recorded directly in the saved
> SVCR and handled based on the information there.
> 
> Since we are not changing any of the save paths there should be no
> functional change from this patch, further patches will make use of this
> to optimise and clarify the code.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  arch/arm64/kernel/fpsimd.c | 39 ++++++++++++++++++++++++++++++--------
>  1 file changed, 31 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index aaea2dc02cbd..4096530dd4c6 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -392,11 +392,36 @@ static void task_fpsimd_load(void)
>  	WARN_ON(!system_supports_fpsimd());
>  	WARN_ON(!have_cpu_fpsimd_context());
>  
> -	/* Check if we should restore SVE first */
> -	if (IS_ENABLED(CONFIG_ARM64_SVE) && test_thread_flag(TIF_SVE)) {
> -		sve_set_vq(sve_vq_from_vl(task_get_sve_vl(current)) - 1);
> -		restore_sve_regs = true;
> -		restore_ffr = true;
> +	if (system_supports_sve()) {
> +		switch (current->thread.fp_type) {
> +		case FP_STATE_FPSIMD:
> +			/* Stop tracking SVE for this task until next use. */
> +			if (test_and_clear_thread_flag(TIF_SVE))
> +				sve_user_disable();
> +			break;
> +		case FP_STATE_SVE:
> +			if (!thread_sm_enabled(&current->thread) &&
> +			    !WARN_ON_ONCE(!test_and_set_thread_flag(TIF_SVE)))
> +				sve_user_enable();
> +
> +			if (test_thread_flag(TIF_SVE))
> +				sve_set_vq(sve_vq_from_vl(task_get_sve_vl(current)) - 1);
> +
> +			restore_sve_regs = true;
> +			restore_ffr = true;
> +			break;
> +		default:
> +			/*
> +			 * This should never happen, we should always
> +			 * record what we saved when we save. We
> +			 * always at least have the memory allocated
> +			 * for FPSMID registers so try that and hope
> +			 * for the best.
> +			 */
> +			WARN_ON_ONCE(1);
> +			clear_thread_flag(TIF_SVE);
> +			break;

What makes it impossible for FP_STATE_TASK to reach this point? If
that's indeed an impossible case, please document it.

> +		}
>  	}
>  
>  	/* Restore SME, override SVE register configuration if needed */
> @@ -412,10 +437,8 @@ static void task_fpsimd_load(void)
>  		if (thread_za_enabled(&current->thread))
>  			za_load_state(current->thread.za_state);
>  
> -		if (thread_sm_enabled(&current->thread)) {
> -			restore_sve_regs = true;
> +		if (thread_sm_enabled(&current->thread))
>  			restore_ffr = system_supports_fa64();
> -		}
>  	}
>  
>  	if (restore_sve_regs) {

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  reply	other threads:[~2022-09-20 18:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 22:55 [PATCH v3 0/7] arm64/sve: Clean up KVM integration and optimise syscalls Mark Brown
2022-08-15 22:55 ` [PATCH v3 1/7] KVM: arm64: Discard any SVE state when entering KVM guests Mark Brown
2022-09-20 16:44   ` Marc Zyngier
2022-09-20 20:21     ` Mark Brown
2022-09-21 17:31       ` Marc Zyngier
2022-09-22 11:44         ` Mark Brown
2022-08-15 22:55 ` [PATCH v3 2/7] arm64/fpsimd: Track the saved FPSIMD state type separately to TIF_SVE Mark Brown
2022-09-20 17:14   ` Marc Zyngier
2022-09-20 18:09     ` Mark Brown
2022-09-20 18:30       ` Marc Zyngier
2022-08-15 22:55 ` [PATCH v3 3/7] arm64/fpsimd: Have KVM explicitly say which FP registers to save Mark Brown
2022-09-20 17:52   ` Marc Zyngier
2022-09-20 18:32     ` Mark Brown
2022-09-21 17:47       ` Marc Zyngier
2022-09-22 12:18         ` Mark Brown
2022-08-15 22:55 ` [PATCH v3 4/7] arm64/fpsimd: Stop using TIF_SVE to manage register saving in KVM Mark Brown
2022-09-20 18:04   ` Marc Zyngier
2022-09-20 18:53     ` Mark Brown
2022-08-15 22:55 ` [PATCH v3 5/7] arm64/fpsimd: Load FP state based on recorded data type Mark Brown
2022-09-20 18:19   ` Marc Zyngier [this message]
2022-09-20 19:02     ` Mark Brown
2022-08-15 22:55 ` [PATCH v3 6/7] arm64/fpsimd: SME no longer requires SVE register state Mark Brown
2022-08-15 22:55 ` [PATCH v3 7/7] arm64/sve: Leave SVE enabled on syscall if we don't context switch 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=87tu51kiwi.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.org \
    --cc=zhang.lei@jp.fujitsu.com \
    /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;
as well as URLs for NNTP newsgroup(s).