linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension)
@ 2025-06-27 17:20 Mark Brown
  2025-06-27 17:20 ` [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE Mark Brown
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Mark Brown @ 2025-06-27 17:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Jonathan Corbet, Marc Zyngier,
	Oliver Upton, Joey Gouly, Suzuki K Poulose, Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest, Mark Brown

FEAT_LSFE is optional from v9.5, it adds new instructions for atomic
memory operations with floating point values.  We have no immediate use
for it in kernel, provide a hwcap so userspace can discover it and allow
the ID register field to be exposed to KVM guests.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
Mark Brown (3):
      arm64/hwcap: Add hwcap for FEAT_LSFE
      KVM: arm64: Expose FEAT_LSFE to guests
      kselftest/arm64: Add lsfe to the hwcaps test

 Documentation/arch/arm64/elf_hwcaps.rst   |  4 ++++
 arch/arm64/include/asm/hwcap.h            |  1 +
 arch/arm64/include/uapi/asm/hwcap.h       |  1 +
 arch/arm64/kernel/cpufeature.c            |  2 ++
 arch/arm64/kernel/cpuinfo.c               |  1 +
 arch/arm64/kvm/sys_regs.c                 |  4 +++-
 tools/testing/selftests/arm64/abi/hwcap.c | 21 +++++++++++++++++++++
 7 files changed, 33 insertions(+), 1 deletion(-)
---
base-commit: 86731a2a651e58953fc949573895f2fa6d456841
change-id: 20250625-arm64-lsfe-0810cf98adc2

Best regards,
--  
Mark Brown <broonie@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE
  2025-06-27 17:20 [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Mark Brown
@ 2025-06-27 17:20 ` Mark Brown
  2025-06-30 10:05   ` Ben Horgan
  2025-06-27 17:20 ` [PATCH 2/3] KVM: arm64: Expose FEAT_LSFE to guests Mark Brown
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2025-06-27 17:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Jonathan Corbet, Marc Zyngier,
	Oliver Upton, Joey Gouly, Suzuki K Poulose, Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest, Mark Brown

FEAT_LSFE (Large System Float Extension), providing atomic floating point
memory operations, is optional from v9.5. This feature adds no new
architectural stare and we have no immediate use for it in the kernel so
simply provide a hwcap for it to support discovery by userspace.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 Documentation/arch/arm64/elf_hwcaps.rst | 4 ++++
 arch/arm64/include/asm/hwcap.h          | 1 +
 arch/arm64/include/uapi/asm/hwcap.h     | 1 +
 arch/arm64/kernel/cpufeature.c          | 2 ++
 arch/arm64/kernel/cpuinfo.c             | 1 +
 5 files changed, 9 insertions(+)

diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst
index 69d7afe56853..aafb969ca263 100644
--- a/Documentation/arch/arm64/elf_hwcaps.rst
+++ b/Documentation/arch/arm64/elf_hwcaps.rst
@@ -435,6 +435,10 @@ HWCAP2_SME_SF8DP4
 HWCAP2_POE
     Functionality implied by ID_AA64MMFR3_EL1.S1POE == 0b0001.
 
+HWCAP3_LSFE
+    Functionality implied by ID_AA64ISAR3_EL1.LSFE == 0b0001
+
+
 4. Unused AT_HWCAP bits
 -----------------------
 
diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h
index 1c3f9617d54f..f8d02c14e5a2 100644
--- a/arch/arm64/include/asm/hwcap.h
+++ b/arch/arm64/include/asm/hwcap.h
@@ -176,6 +176,7 @@
 #define KERNEL_HWCAP_POE		__khwcap2_feature(POE)
 
 #define __khwcap3_feature(x)		(const_ilog2(HWCAP3_ ## x) + 128)
+#define KERNEL_HWCAP_LSFE		__khwcap3_feature(LSFE)
 
 /*
  * This yields a mask that user programs can use to figure out what
diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h
index 705a7afa8e58..339b9dbf7cfc 100644
--- a/arch/arm64/include/uapi/asm/hwcap.h
+++ b/arch/arm64/include/uapi/asm/hwcap.h
@@ -143,5 +143,6 @@
 /*
  * HWCAP3 flags - for AT_HWCAP3
  */
+#define HWCAP3_LSFE		(1 << 0)
 
 #endif /* _UAPI__ASM_HWCAP_H */
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index b34044e20128..726054ac8091 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -278,6 +278,7 @@ static const struct arm64_ftr_bits ftr_id_aa64isar2[] = {
 
 static const struct arm64_ftr_bits ftr_id_aa64isar3[] = {
 	ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64ISAR3_EL1_FPRCVT_SHIFT, 4, 0),
+	ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64ISAR3_EL1_LSFE_SHIFT, 4, 0),
 	ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64ISAR3_EL1_FAMINMAX_SHIFT, 4, 0),
 	ARM64_FTR_END,
 };
@@ -3175,6 +3176,7 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
 	HWCAP_CAP(ID_AA64ISAR1_EL1, I8MM, IMP, CAP_HWCAP, KERNEL_HWCAP_I8MM),
 	HWCAP_CAP(ID_AA64ISAR2_EL1, LUT, IMP, CAP_HWCAP, KERNEL_HWCAP_LUT),
 	HWCAP_CAP(ID_AA64ISAR3_EL1, FAMINMAX, IMP, CAP_HWCAP, KERNEL_HWCAP_FAMINMAX),
+	HWCAP_CAP(ID_AA64ISAR3_EL1, LSFE, IMP, CAP_HWCAP, KERNEL_HWCAP_LSFE),
 	HWCAP_CAP(ID_AA64MMFR2_EL1, AT, IMP, CAP_HWCAP, KERNEL_HWCAP_USCAT),
 #ifdef CONFIG_ARM64_SVE
 	HWCAP_CAP(ID_AA64PFR0_EL1, SVE, IMP, CAP_HWCAP, KERNEL_HWCAP_SVE),
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index c1f2b6b04b41..2a1efe8e1fdf 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -160,6 +160,7 @@ static const char *const hwcap_str[] = {
 	[KERNEL_HWCAP_SME_SFEXPA]	= "smesfexpa",
 	[KERNEL_HWCAP_SME_STMOP]	= "smestmop",
 	[KERNEL_HWCAP_SME_SMOP4]	= "smesmop4",
+	[KERNEL_HWCAP_LSFE]		= "lsfe",
 };
 
 #ifdef CONFIG_COMPAT

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] KVM: arm64: Expose FEAT_LSFE to guests
  2025-06-27 17:20 [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Mark Brown
  2025-06-27 17:20 ` [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE Mark Brown
@ 2025-06-27 17:20 ` Mark Brown
  2025-06-27 17:20 ` [PATCH 3/3] kselftest/arm64: Add lsfe to the hwcaps test Mark Brown
  2025-06-30 10:21 ` [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Ben Horgan
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-06-27 17:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Jonathan Corbet, Marc Zyngier,
	Oliver Upton, Joey Gouly, Suzuki K Poulose, Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest, Mark Brown

FEAT_LSFE (Large System Float Extension), providing atomic floating point
memory operations, is optional from v9.5. This feature adds no new
architectural state, expose the relevant ID register field to guests so
they can discover it.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/kvm/sys_regs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 76c2f0da821f..be685422bf9b 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -1636,7 +1636,8 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu,
 			val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_WFxT);
 		break;
 	case SYS_ID_AA64ISAR3_EL1:
-		val &= ID_AA64ISAR3_EL1_FPRCVT | ID_AA64ISAR3_EL1_FAMINMAX;
+		val &= ID_AA64ISAR3_EL1_FPRCVT | ID_AA64ISAR3_EL1_LSFE |
+			ID_AA64ISAR3_EL1_FAMINMAX;
 		break;
 	case SYS_ID_AA64MMFR2_EL1:
 		val &= ~ID_AA64MMFR2_EL1_CCIDX_MASK;
@@ -2921,6 +2922,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
 					ID_AA64ISAR2_EL1_APA3 |
 					ID_AA64ISAR2_EL1_GPA3)),
 	ID_WRITABLE(ID_AA64ISAR3_EL1, (ID_AA64ISAR3_EL1_FPRCVT |
+				       ID_AA64ISAR3_EL1_LSFE |
 				       ID_AA64ISAR3_EL1_FAMINMAX)),
 	ID_UNALLOCATED(6,4),
 	ID_UNALLOCATED(6,5),

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] kselftest/arm64: Add lsfe to the hwcaps test
  2025-06-27 17:20 [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Mark Brown
  2025-06-27 17:20 ` [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE Mark Brown
  2025-06-27 17:20 ` [PATCH 2/3] KVM: arm64: Expose FEAT_LSFE to guests Mark Brown
@ 2025-06-27 17:20 ` Mark Brown
  2025-06-30 10:08   ` Ben Horgan
  2025-06-30 10:21 ` [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Ben Horgan
  3 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2025-06-27 17:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Jonathan Corbet, Marc Zyngier,
	Oliver Upton, Joey Gouly, Suzuki K Poulose, Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest, Mark Brown

This feature has no traps associated with it so the SIGILL is not reliable.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/abi/hwcap.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
index 35f521e5f41c..9dfca2eb7c41 100644
--- a/tools/testing/selftests/arm64/abi/hwcap.c
+++ b/tools/testing/selftests/arm64/abi/hwcap.c
@@ -17,6 +17,8 @@
 #include <asm/sigcontext.h>
 #include <asm/unistd.h>
 
+#include <linux/auxvec.h>
+
 #include "../../kselftest.h"
 
 #define TESTS_PER_HWCAP 3
@@ -165,6 +167,18 @@ static void lse128_sigill(void)
 		     : "cc", "memory");
 }
 
+static void lsfe_sigill(void)
+{
+	float __attribute__ ((aligned (16))) mem = 0;
+	register float *memp asm ("x0") = &mem;
+
+	/* LDFADD H0, H0, [X0] */
+	asm volatile(".inst 0x7c600000"
+		     : "+r" (memp)
+		     :
+		     : "cc", "memory");
+}
+
 static void lut_sigill(void)
 {
 	/* LUTI2 V0.16B, { V0.16B }, V[0] */
@@ -758,6 +772,13 @@ static const struct hwcap_data {
 		.cpuinfo = "lse128",
 		.sigill_fn = lse128_sigill,
 	},
+	{
+		.name = "LSFE",
+		.at_hwcap = AT_HWCAP3,
+		.hwcap_bit = HWCAP3_LSFE,
+		.cpuinfo = "lsfe",
+		.sigill_fn = lsfe_sigill,
+	},
 	{
 		.name = "LUT",
 		.at_hwcap = AT_HWCAP2,

-- 
2.39.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE
  2025-06-27 17:20 ` [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE Mark Brown
@ 2025-06-30 10:05   ` Ben Horgan
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Horgan @ 2025-06-30 10:05 UTC (permalink / raw)
  To: Mark Brown, Catalin Marinas, Will Deacon, Jonathan Corbet,
	Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
	Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest



On 6/27/25 18:20, Mark Brown wrote:
> FEAT_LSFE (Large System Float Extension), providing atomic floating point
> memory operations, is optional from v9.5. This feature adds no new
> architectural stare and we have no immediate use for it in the kernel so
> simply provide a hwcap for it to support discovery by userspace.

nit: s/stare/state/

Thanks,

Ben


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] kselftest/arm64: Add lsfe to the hwcaps test
  2025-06-27 17:20 ` [PATCH 3/3] kselftest/arm64: Add lsfe to the hwcaps test Mark Brown
@ 2025-06-30 10:08   ` Ben Horgan
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Horgan @ 2025-06-30 10:08 UTC (permalink / raw)
  To: Mark Brown, Catalin Marinas, Will Deacon, Jonathan Corbet,
	Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
	Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest

Hi Mark,

On 6/27/25 18:20, Mark Brown wrote:
> This feature has no traps associated with it so the SIGILL is not reliable.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>   tools/testing/selftests/arm64/abi/hwcap.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
> 
> diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
> index 35f521e5f41c..9dfca2eb7c41 100644
> --- a/tools/testing/selftests/arm64/abi/hwcap.c
> +++ b/tools/testing/selftests/arm64/abi/hwcap.c
> @@ -17,6 +17,8 @@
>   #include <asm/sigcontext.h>
>   #include <asm/unistd.h>
>   
> +#include <linux/auxvec.h>
> +
>   #include "../../kselftest.h"
>   
>   #define TESTS_PER_HWCAP 3
> @@ -165,6 +167,18 @@ static void lse128_sigill(void)
>   		     : "cc", "memory");
>   }
>   
> +static void lsfe_sigill(void)
> +{
> +	float __attribute__ ((aligned (16))) mem = 0;
> +	register float *memp asm ("x0") = &mem;
> +
> +	/* LDFADD H0, H0, [X0] */
> +	asm volatile(".inst 0x7c600000"
Same effect, but isn't this the release variant, LDFADDL?
> +		     : "+r" (memp)
> +		     :
> +		     : "cc", "memory");
> +}
> +
>   static void lut_sigill(void)
>   {
>   	/* LUTI2 V0.16B, { V0.16B }, V[0] */
> @@ -758,6 +772,13 @@ static const struct hwcap_data {
>   		.cpuinfo = "lse128",
>   		.sigill_fn = lse128_sigill,
>   	},
> +	{
> +		.name = "LSFE",
> +		.at_hwcap = AT_HWCAP3,
> +		.hwcap_bit = HWCAP3_LSFE,
> +		.cpuinfo = "lsfe",
> +		.sigill_fn = lsfe_sigill,
> +	},
>   	{
>   		.name = "LUT",
>   		.at_hwcap = AT_HWCAP2,
> 

Thanks,

Ben


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension)
  2025-06-27 17:20 [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Mark Brown
                   ` (2 preceding siblings ...)
  2025-06-27 17:20 ` [PATCH 3/3] kselftest/arm64: Add lsfe to the hwcaps test Mark Brown
@ 2025-06-30 10:21 ` Ben Horgan
  3 siblings, 0 replies; 7+ messages in thread
From: Ben Horgan @ 2025-06-30 10:21 UTC (permalink / raw)
  To: Mark Brown, Catalin Marinas, Will Deacon, Jonathan Corbet,
	Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
	Shuah Khan
  Cc: linux-arm-kernel, linux-doc, linux-kernel, kvmarm,
	linux-kselftest

Hi Mark,

On 6/27/25 18:20, Mark Brown wrote:
> FEAT_LSFE is optional from v9.5, it adds new instructions for atomic
> memory operations with floating point values.  We have no immediate use
> for it in kernel, provide a hwcap so userspace can discover it and allow
> the ID register field to be exposed to KVM guests.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> Mark Brown (3):
>        arm64/hwcap: Add hwcap for FEAT_LSFE
>        KVM: arm64: Expose FEAT_LSFE to guests
>        kselftest/arm64: Add lsfe to the hwcaps test
> 
>   Documentation/arch/arm64/elf_hwcaps.rst   |  4 ++++
>   arch/arm64/include/asm/hwcap.h            |  1 +
>   arch/arm64/include/uapi/asm/hwcap.h       |  1 +
>   arch/arm64/kernel/cpufeature.c            |  2 ++
>   arch/arm64/kernel/cpuinfo.c               |  1 +
>   arch/arm64/kvm/sys_regs.c                 |  4 +++-
>   tools/testing/selftests/arm64/abi/hwcap.c | 21 +++++++++++++++++++++
>   7 files changed, 33 insertions(+), 1 deletion(-)


I have looked through the series and it looks good to me modulo a couple 
of minor comments left on the patches. Bare in mind fairly new here and 
this is the first use of hwcap3 so I expect more experienced review is 
required.

Reviewed-by: Ben Horgan <ben.horgan@arm.com>

> ---
> base-commit: 86731a2a651e58953fc949573895f2fa6d456841
> change-id: 20250625-arm64-lsfe-0810cf98adc2
> 
> Best regards,
> --
> Mark Brown <broonie@kernel.org>
> 
> 


Thanks,

Ben


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-30 10:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 17:20 [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Mark Brown
2025-06-27 17:20 ` [PATCH 1/3] arm64/hwcap: Add hwcap for FEAT_LSFE Mark Brown
2025-06-30 10:05   ` Ben Horgan
2025-06-27 17:20 ` [PATCH 2/3] KVM: arm64: Expose FEAT_LSFE to guests Mark Brown
2025-06-27 17:20 ` [PATCH 3/3] kselftest/arm64: Add lsfe to the hwcaps test Mark Brown
2025-06-30 10:08   ` Ben Horgan
2025-06-30 10:21 ` [PATCH 0/3] arm64: Support FEAT_LSFE (Large System Float Extension) Ben Horgan

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).