Skip to contentSkip to conversation

arm64: cpufeature: Check the override in __read_sysreg_by_encoding()

PATCH In review Fuad Tabba 2 participants 2 messages Nov 13 – Nov 18 arm64

lore
Share & tools
lore

Fuad Tabba

author
#0 lore raw

PATCH 1/1 arm64: cpufeature: Check the override in __read_sysreg_by_encoding()

__read_sysreg_by_encoding() backs the capability checks a secondary runs before its cpuinfo is stored, and folds an ID register override into the value it reads without checking it against that CPU. A secondary whose field is below an override the boot CPU accepted passes verification and comes online without the feature.

Apply the override through arm64_ftr_reg_override(), as the cpuinfo store does, so that it only applies where it is safe against that CPU's value.

Fixes b3341ae0efa2 ("arm64: cpufeature: Use IDreg override in __read_sysreg_by_encoding()")

---

Notes:

    Based on v7.4-rc1 (6628e7d4c6b2), where arm64_ftr_reg_override() was
    added.
 arch/arm64/kernel/cpufeature.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
arch/arm64/kernel/cpufeature.c +1 -8
index 34c5c03c0c9b4..3980acdd6e1b7 100644
@@ -1415,7 +1415,6 @@ EXPORT_SYMBOL_GPL(read_sanitised_ftr_reg);
  */
 u64 __read_sysreg_by_encoding(u32 sys_id)
 {
-	struct arm64_ftr_reg *regp;
 	u64 val;
 
 	switch (sys_id) {
@@ -1468,13 +1467,7 @@ u64 __read_sysreg_by_encoding(u32 sys_id)
 		return 0;
 	}
 
-	regp  = get_arm64_ftr_reg(sys_id);
-	if (regp) {
-		val &= ~regp->override->mask;
-		val |= (regp->override->val & regp->override->mask);
-	}
-
-	return val;
+	return arm64_ftr_reg_override(sys_id, val);
 }
 
 #include <linux/irqchip/arm-gic-v3.h>

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Fuad Tabba

__read_sysreg_by_encoding() backs the capability checks a secondary runs before its cpuinfo is stored, and folds an ID register override into the value it reads without checking it against that CPU. A secondary whose field is below an override the boot CPU accepted passes verification and comes online without the feature.

Apply the override through arm64_ftr_reg_override(), as the cpuinfo store does, so that it only applies where it is safe against that CPU's value.

Quoted 5 lines
Fixes b3341ae0efa2 ("arm64: cpufeature: Use IDreg override in __read_sysreg_by_encoding()")

Patch looks fine but I don't think it's worth adding Fixes tag (or, if we do, we shouldn't add cc stable; my commit hook does this automatically).

I'd leave it for 7.5, so: