[PATCH v9 04/30] arm64/fpsimd: Check enable bit for FA64 when saving EFI state

Mark Brown posted 30 patches 1 month, 2 weeks ago
[PATCH v9 04/30] arm64/fpsimd: Check enable bit for FA64 when saving EFI state
Posted by Mark Brown 1 month, 2 weeks ago
Currently when deciding if we need to save FFR when in streaming mode prior
to EFI calls we check if FA64 is supported by the system. Since KVM guest
support will mean that FA64 might be enabled and disabled at runtime switch
to checking if traps for FA64 are enabled in SMCR_EL1 instead.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/kernel/fpsimd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 887fce177c92..f4e8cee00198 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1948,6 +1948,11 @@ static bool efi_sm_state;
  * either doing something wrong or you need to propose some refactoring.
  */
 
+static bool fa64_enabled(void)
+{
+	return read_sysreg_s(SYS_SMCR_EL1) & SMCR_ELx_FA64;
+}
+
 /*
  * __efi_fpsimd_begin(): prepare FPSIMD for making an EFI runtime services call
  */
@@ -1980,7 +1985,7 @@ void __efi_fpsimd_begin(void)
 				 * Unless we have FA64 FFR does not
 				 * exist in streaming mode.
 				 */
-				if (!system_supports_fa64())
+				if (!fa64_enabled())
 					ffr = !(svcr & SVCR_SM_MASK);
 			}
 
@@ -2028,7 +2033,7 @@ void __efi_fpsimd_end(void)
 					 * Unless we have FA64 FFR does not
 					 * exist in streaming mode.
 					 */
-					if (!system_supports_fa64())
+					if (!fa64_enabled())
 						ffr = false;
 				}
 			}

-- 
2.47.3
Re: [PATCH v9 04/30] arm64/fpsimd: Check enable bit for FA64 when saving EFI state
Posted by Alex Bennée 1 week, 1 day ago
Mark Brown <broonie@kernel.org> writes:

> Currently when deciding if we need to save FFR when in streaming mode prior
> to EFI calls we check if FA64 is supported by the system. Since KVM guest
> support will mean that FA64 might be enabled and disabled at runtime switch
> to checking if traps for FA64 are enabled in SMCR_EL1 instead.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  arch/arm64/kernel/fpsimd.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index 887fce177c92..f4e8cee00198 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -1948,6 +1948,11 @@ static bool efi_sm_state;
>   * either doing something wrong or you need to propose some refactoring.
>   */
>  
> +static bool fa64_enabled(void)
> +{
> +	return read_sysreg_s(SYS_SMCR_EL1) & SMCR_ELx_FA64;
> +}
> +
>  /*
>   * __efi_fpsimd_begin(): prepare FPSIMD for making an EFI runtime services call
>   */
> @@ -1980,7 +1985,7 @@ void __efi_fpsimd_begin(void)
>  				 * Unless we have FA64 FFR does not
>  				 * exist in streaming mode.
>  				 */
> -				if (!system_supports_fa64())
> +				if (!fa64_enabled())
>  					ffr = !(svcr & SVCR_SM_MASK);
>  			}
>  
> @@ -2028,7 +2033,7 @@ void __efi_fpsimd_end(void)
>  					 * Unless we have FA64 FFR does not
>  					 * exist in streaming mode.
>  					 */
> -					if (!system_supports_fa64())
> +					if (!fa64_enabled())
>  						ffr = false;
>  				}
>  			}

This is conflicting with the now merged 63de2b3859ba1 (arm64/efi: Remove
unneeded SVE/SME fallback preserve/store handling) so I think this patch
can now be dropped?

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v9 04/30] arm64/fpsimd: Check enable bit for FA64 when saving EFI state
Posted by Mark Brown 1 week, 1 day ago
On Thu, Jan 29, 2026 at 04:39:33PM +0000, Alex Bennée wrote:
> Mark Brown <broonie@kernel.org> writes:

> > Currently when deciding if we need to save FFR when in streaming mode prior
> > to EFI calls we check if FA64 is supported by the system. Since KVM guest
> > support will mean that FA64 might be enabled and disabled at runtime switch
> > to checking if traps for FA64 are enabled in SMCR_EL1 instead.

> This is conflicting with the now merged 63de2b3859ba1 (arm64/efi: Remove
> unneeded SVE/SME fallback preserve/store handling) so I think this patch
> can now be dropped?

Yes, this should go away in the next rebase.
Re: [PATCH v9 04/30] arm64/fpsimd: Check enable bit for FA64 when saving EFI state
Posted by Alex Bennée 1 week, 1 day ago
Mark Brown <broonie@kernel.org> writes:

> On Thu, Jan 29, 2026 at 04:39:33PM +0000, Alex Bennée wrote:
>> Mark Brown <broonie@kernel.org> writes:
>
>> > Currently when deciding if we need to save FFR when in streaming mode prior
>> > to EFI calls we check if FA64 is supported by the system. Since KVM guest
>> > support will mean that FA64 might be enabled and disabled at runtime switch
>> > to checking if traps for FA64 are enabled in SMCR_EL1 instead.
>
>> This is conflicting with the now merged 63de2b3859ba1 (arm64/efi: Remove
>> unneeded SVE/SME fallback preserve/store handling) so I think this patch
>> can now be dropped?
>
> Yes, this should go away in the next rebase.

Everything else applies cleanly though so thats good ;-)

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v9 04/30] arm64/fpsimd: Check enable bit for FA64 when saving EFI state
Posted by Fuad Tabba 1 month ago
On Tue, 23 Dec 2025 at 01:21, Mark Brown <broonie@kernel.org> wrote:
>
> Currently when deciding if we need to save FFR when in streaming mode prior
> to EFI calls we check if FA64 is supported by the system. Since KVM guest
> support will mean that FA64 might be enabled and disabled at runtime switch
> to checking if traps for FA64 are enabled in SMCR_EL1 instead.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>

Reviewed-by: Fuad Tabba <tabba@google.com>

Cheers,
/fuad


> ---
>  arch/arm64/kernel/fpsimd.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index 887fce177c92..f4e8cee00198 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -1948,6 +1948,11 @@ static bool efi_sm_state;
>   * either doing something wrong or you need to propose some refactoring.
>   */
>
> +static bool fa64_enabled(void)
> +{
> +       return read_sysreg_s(SYS_SMCR_EL1) & SMCR_ELx_FA64;
> +}
> +
>  /*
>   * __efi_fpsimd_begin(): prepare FPSIMD for making an EFI runtime services call
>   */
> @@ -1980,7 +1985,7 @@ void __efi_fpsimd_begin(void)
>                                  * Unless we have FA64 FFR does not
>                                  * exist in streaming mode.
>                                  */
> -                               if (!system_supports_fa64())
> +                               if (!fa64_enabled())
>                                         ffr = !(svcr & SVCR_SM_MASK);
>                         }
>
> @@ -2028,7 +2033,7 @@ void __efi_fpsimd_end(void)
>                                          * Unless we have FA64 FFR does not
>                                          * exist in streaming mode.
>                                          */
> -                                       if (!system_supports_fa64())
> +                                       if (!fa64_enabled())
>                                                 ffr = false;
>                                 }
>                         }
>
> --
> 2.47.3
>