Skip to content

Commit f2c2812

Browse files
brooniewilldeacon
authored andcommitted
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. Suggested-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220307180900.3045812-1-broonie@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent b8fc780 commit f2c2812

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

arch/arm64/include/asm/cpufeature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ static inline u64 arm64_ftr_reg_user_value(const struct arm64_ftr_reg *reg)
577577
static inline int __attribute_const__
578578
cpuid_feature_extract_field_width(u64 features, int field, int width, bool sign)
579579
{
580+
if (WARN_ON_ONCE(!width))
581+
width = 4;
580582
return (sign) ?
581583
cpuid_feature_extract_signed_field_width(features, field, width) :
582584
cpuid_feature_extract_unsigned_field_width(features, field, width);

0 commit comments

Comments
 (0)