Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 778B1C433F5 for ; Mon, 7 Mar 2022 16:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QRL8rYvMXV0NZNUHGzjxvaClzAZhh9o/lM5HIMBU3j0=; b=sIqnDPNceV65gN q7fsaviyOTIx2I6jMAs7BmjFAfXm0kmJNK8iTSqSuf0hGNIov8liMzLTKMGTtGGdxA5JTX1FOeNoR o8WXbZSv5TZEErdbq3m4b1SYZjsNqB2w2dKqcDK4qEKN0f9M3kQ19+IsHGHjXpx8tZ84vgpovwSnn 4ZKWdZCi8xT1bYJi9yHbUnmBjxX+lhrAg2atA3TCpoYoPIrprKLMAv3Mb/2y5F6Tiwf0UPXR7gFT6 Od+PbWUB7jJbukrkdgPn4Ob308gXdandx9n4pfsl1VVUnTe9OwmQGRLfSzQHzOZUFbrRjB9cX7baZ BggT2Owhzcv27FQPlTRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRGdQ-000vIk-CW; Mon, 07 Mar 2022 16:55:00 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRGdK-000vHX-Ss for linux-arm-kernel@lists.infradead.org; Mon, 07 Mar 2022 16:54:56 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EFFC9B81652; Mon, 7 Mar 2022 16:54:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99BE7C340EF; Mon, 7 Mar 2022 16:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646672091; bh=u4iLNaUhyV0gXfuZR6v0LR+sFsAholHlTbSs4BgMzWA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=L41XAQjHHJkS9fcSxjt+QacC3ebnH0fFvcbJVWYGbSUGVvLFT6BoNhuHbh1zUMSTI TdqgxPBxf9BrHSfWcLMmHewnsm3FRY8IhXtyL+FKiq/DjEwf9B0nwsmOwYK7QgjBYK wB/bAhFWSrqhStNdp71rUb+HE4E0LuFIfD6QJ9WZJM3cqfoAhS/Pc57lrfvQhRjLdq H9Ab96HW98k2pfpy5YpkSb7O21xXIWp6p7g8SO20cK0xHnNtP77qIDgkUVL+7NYEq1 tsVcNd+c2iW44N0VtfBhuWnWdM1v430QDAdasO+nHcmNg/+AhHi8VVRnlYittFGlvA FuQmXUKLIe/nQ== Date: Mon, 7 Mar 2022 16:54:46 +0000 From: Will Deacon To: Mark Brown Cc: Catalin Marinas , Marc Zyngier , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arm64: cpufeature: Warn if we attempt to read a zero width field Message-ID: <20220307165446.GA29586@willie-the-truck> References: <20220302134702.172816-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220302134702.172816-1-broonie@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220307_085455_121431_15BC8930 X-CRM114-Status: GOOD ( 18.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > Signed-off-by: Mark Brown > --- > 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