On Mon, Feb 07, 2022 at 03:20:39PM +0000, Mark Brown wrote: > diff --git a/Documentation/arm64/elf_hwcaps.rst b/Documentation/arm64/elf_hwcaps.rst > index b72ff17d600a..5626cf208000 100644 > --- a/Documentation/arm64/elf_hwcaps.rst > +++ b/Documentation/arm64/elf_hwcaps.rst > @@ -259,6 +259,39 @@ HWCAP2_RPRES > > Functionality implied by ID_AA64ISAR2_EL1.RPRES == 0b0001. > > +HWCAP2_SME > + > + Functionality implied by ID_AA64PFR1_EL1.SME == 0b0001, as described > + by Documentation/arm64/sme.rst. > + > +HWCAP2_SME_I16I64 > + > + Functionality implied by ID_AA64SMFR0_EL1.I16I64 == 0b1111. > + > +HWCAP2_SME_F64F64 > + > + Functionality implied by ID_AA64SMFR0_EL1.F64F64 == 0b1. > + > +HWCAP2_SME_I8I32 > + > + Functionality implied by ID_AA64SMFR0_EL1.I8I32 == 0b1111. > + > +HWCAP2_SME_F16F32 > + > + Functionality implied by ID_AA64SMFR0_EL1.F16F32 == 0b1. > + > +HWCAP2_SME_B16F32 > + > + Functionality implied by ID_AA64SMFR0_EL1.B16F32 == 0b1. > + > +HWCAP2_SME_F32F32 > + > + Functionality implied by ID_AA64SMFR0_EL1.F32F32 == 0b1. > + > +HWCAP2_SME_FA64 > + > + Functionality implied by ID_AA64SMFR0_EL1.FA64 == 0b1. More of a question for the libc people: should we drop the fine-grained HWCAP corresponding to the new ID_AA64SMFR0_EL1 register (only keep HWCAP2_SME) and get the user space to use the MRS emulation? Would any ifunc resolver be affected? > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 64a748c2b351..2634e32bbfb9 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -251,6 +251,7 @@ static const struct arm64_ftr_bits ftr_id_aa64pfr0[] = { > }; > > static const struct arm64_ftr_bits ftr_id_aa64pfr1[] = { > + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64PFR1_SME_SHIFT, 4, 0), Shouldn't this field also be visible (if SME is enabled)? > diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c > index 5280e098cfb5..576490be3c2b 100644 > --- a/arch/arm64/kernel/fpsimd.c > +++ b/arch/arm64/kernel/fpsimd.c > @@ -987,6 +987,32 @@ void fpsimd_release_task(struct task_struct *dead_task) > > #endif /* CONFIG_ARM64_SVE */ > > +#ifdef CONFIG_ARM64_SME > + > +void sme_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p) > +{ > + /* Set priority for all PEs to architecturally defined minimum */ > + write_sysreg_s(read_sysreg_s(SYS_SMPRI_EL1) & ~SMPRI_EL1_PRIORITY_MASK, > + SYS_SMPRI_EL1); > + > + /* Allow SME in kernel */ > + write_sysreg(read_sysreg(CPACR_EL1) | CPACR_EL1_SMEN_EL1EN, CPACR_EL1); > + isb(); > +} > + > +/* > + * This must be called after sme_kernel_enable(), we rely on the > + * feature table being sorted to ensure this. > + */ > +void fa64_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p) > +{ > + /* Allow use of FA64 */ > + write_sysreg_s(read_sysreg_s(SYS_SMCR_EL1) | SMCR_ELx_FA64_MASK, > + SYS_SMCR_EL1); > +} > + > +#endif /* CONFIG_ARM64_SVE */ I think instead of worrying about the order, we could check the sanitised register value in sme_kernel_enable() and set the FA64 bit. Also to me 'fa64_kernel_enable' somehow implies that the kernel cares about FA64 for itself but AFAICT we never run the kernel in streaming mode. -- Catalin