All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: use sanitized feature registers for conditional ZCR_EL1 and SMCR_EL1 reads
@ 2022-07-13 18:18 Peter Collingbourne
  2022-07-13 18:41 ` Mark Brown
  2022-07-14  6:47 ` Marc Zyngier
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Collingbourne @ 2022-07-13 18:18 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Peter Collingbourne, linux-arm-kernel, Will Deacon,
	Catalin Marinas, Mark Rutland, Ard Biesheuvel, broonie,
	danielmentz, saravanak

With arm64.nosve we would still read ZCR_EL1 in __cpuinfo_store_cpu
because the condition for reading it was based on the unsanitized feature
register value info->reg_id_aa64pfr0. Fix the problem by moving the reads
to init_cpu_features after we have computed the sanitized value. Fix
the SMCR_EL1 read for SME similarly.

Fixes: 504ee23611c4 ("arm64: Add the arm64.nosve command line option")
Signed-off-by: Peter Collingbourne <pcc@google.com>
---
 arch/arm64/kernel/cpufeature.c | 11 +++++++----
 arch/arm64/kernel/cpuinfo.c    |  8 --------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index e5afa9eba85d..71d290fec36f 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -999,15 +999,18 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
 	if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0))
 		init_32bit_cpu_features(&info->aarch32);
 
-	if (id_aa64pfr0_sve(info->reg_id_aa64pfr0)) {
+	if (IS_ENABLED(CONFIG_ARM64_SVE) &&
+	    id_aa64pfr0_sve(read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1))) {
+		info->reg_zcr = read_zcr_features();
 		init_cpu_ftr_reg(SYS_ZCR_EL1, info->reg_zcr);
 		vec_init_vq_map(ARM64_VEC_SVE);
 	}
 
-	if (id_aa64pfr1_sme(info->reg_id_aa64pfr1)) {
+	if (IS_ENABLED(CONFIG_ARM64_SME) &&
+	    id_aa64pfr1_sme(read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1))) {
+		info->reg_smcr = read_smcr_features();
 		init_cpu_ftr_reg(SYS_SMCR_EL1, info->reg_smcr);
-		if (IS_ENABLED(CONFIG_ARM64_SME))
-			vec_init_vq_map(ARM64_VEC_SME);
+		vec_init_vq_map(ARM64_VEC_SME);
 	}
 
 	if (id_aa64pfr1_mte(info->reg_id_aa64pfr1))
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index 8eff0a34ffd4..66bc6f25d3b4 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -418,14 +418,6 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
 	if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0))
 		__cpuinfo_store_cpu_32bit(&info->aarch32);
 
-	if (IS_ENABLED(CONFIG_ARM64_SVE) &&
-	    id_aa64pfr0_sve(info->reg_id_aa64pfr0))
-		info->reg_zcr = read_zcr_features();
-
-	if (IS_ENABLED(CONFIG_ARM64_SME) &&
-	    id_aa64pfr1_sme(info->reg_id_aa64pfr1))
-		info->reg_smcr = read_smcr_features();
-
 	cpuinfo_detect_icache_policy(info);
 }
 
-- 
2.37.0.144.g8ac04bfd2-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-07-14 17:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-13 18:18 [PATCH] arm64: use sanitized feature registers for conditional ZCR_EL1 and SMCR_EL1 reads Peter Collingbourne
2022-07-13 18:41 ` Mark Brown
2022-07-14  6:47 ` Marc Zyngier
2022-07-14 13:25   ` Mark Brown
2022-07-14 17:47   ` Peter Collingbourne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.