Skip to contentSkip to conversation

arm64: cpufeature: Warn if we attempt to read a zero width field

PATCH Applied Mark Brown 2 participants 2 messages Mar 7, 2022 arm64

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH v2 1/1 arm64: cpufeature: Warn if we attempt to read a zero width field

Add a WARN_ON_ONCE() when extracting a field if no width is specified. This should never happen outside of development since it will be triggered with or without the feature so long as the relevant ID register is present. If the warning triggers hope that the field was the standard 4 bits wide and soldier on.

---

v2:
- Use a width of 4 if the warning triggers.

 arch/arm64/include/asm/cpufeature.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cpufeature.h +2 -0
index e2be53f74cd7..380238ae3321 100644
@@ -577,6 +577,8 @@ static inline u64 arm64_ftr_reg_user_value(const struct arm64_ftr_reg *reg)
 static inline int __attribute_const__
 cpuid_feature_extract_field_width(u64 features, int field, int width, bool sign)
 {
+	if (WARN_ON_ONCE(!width))
+		width = 4;
 	return (sign) ?
 		cpuid_feature_extract_signed_field_width(features, field, width) :
 		cpuid_feature_extract_unsigned_field_width(features, field, width);
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#1 lore raw
Quoted 8 lines · Mark Brown

Add a WARN_ON_ONCE() when extracting a field if no width is specified. This should never happen outside of development since it will be triggered with or without the feature so long as the relevant ID register is present. If the warning triggers hope that the field was the standard 4 bits wide and soldier on.

[...]

Applied to arm64 (for-next/fpsimd), thanks!

[1/1] arm64: cpufeature: Warn if we attempt to read a zero width field

      https://git.kernel.org/arm64/c/f2c281204b47

Cheers,

Signature · 10 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel