diff options
author | Mark Brown <broonie@kernel.org> | 2022-03-07 18:08:59 +0000 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2022-03-07 21:40:52 +0000 |
commit | f2c281204b47309534f26dc63cee2a130c2b497b (patch) | |
tree | a958791bf1f12cf21b72ac0ffe877bc4f2034b4a /arch/arm64 | |
parent | b8fc780137b4b2d7b84d75488b429fd882e0dd3b (diff) | |
download | linux-f2c281204b47309534f26dc63cee2a130c2b497b.tar.bz2 |
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>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/include/asm/cpufeature.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 2728abd9cae4..2b407fbccdfb 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -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); |