* [PATCH] arm64: cpufeature: Warn if we attempt to read a zero width field
@ 2022-03-02 13:47 Mark Brown
2022-03-07 16:54 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2022-03-02 13:47 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon
Cc: Marc Zyngier, Suzuki K Poulose, linux-arm-kernel, 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.
Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
arch/arm64/include/asm/cpufeature.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 2fe54369ac3f..4c8badfa9e8b 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -577,6 +577,7 @@ 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)
{
+ WARN_ON_ONCE(!width);
return (sign) ?
cpuid_feature_extract_signed_field_width(features, field, width) :
cpuid_feature_extract_unsigned_field_width(features, field, width);
--
2.30.2
_______________________________________________
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] 2+ messages in thread
* Re: [PATCH] arm64: cpufeature: Warn if we attempt to read a zero width field
2022-03-02 13:47 [PATCH] arm64: cpufeature: Warn if we attempt to read a zero width field Mark Brown
@ 2022-03-07 16:54 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2022-03-07 16:54 UTC (permalink / raw)
To: Mark Brown
Cc: Catalin Marinas, Marc Zyngier, Suzuki K Poulose, linux-arm-kernel
On Wed, Mar 02, 2022 at 01:47:02PM +0000, Mark Brown wrote:
> 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.
>
> Suggested-by: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> arch/arm64/include/asm/cpufeature.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 2fe54369ac3f..4c8badfa9e8b 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -577,6 +577,7 @@ 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)
> {
> + WARN_ON_ONCE(!width);
I think this makes sense, but lets also override width to be 4 in this case,
as that is much more likely to "work" than 0. i.e.
if (WARN_ON_ONCE(!width))
width = 4;
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-07 16:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-02 13:47 [PATCH] arm64: cpufeature: Warn if we attempt to read a zero width field Mark Brown
2022-03-07 16:54 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).