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 B7282C433F5 for ; Wed, 2 Mar 2022 13:48:13 +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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=VfPqCwb1j/KIFB0r/rALgfFMJa8gpVVBB5A773x/8hM=; b=gP/qVvqMCvUXKV moe4dJikSfLVXicSUStsKfgPJhJPsm8Iql8tZu3JY0FwHonYn5+mlHUdrmUopyLtZvMNV5QqxU1xu jxbCBHNp7UiEJ2IVZddgusqdMghOLyDoMgbWuwHMyNsbczCjOsUu358GmXtzr7yksJ21S6Wd3u/gS rggHbUOAppKHfAKKqPyKFcgMIqvl0oKc7jUwXaDvi6lL8jechhahfLiEnHyi2eKauVWtN+xkGHtqa 3m6WqFG4Q8TzylPcYi2RCwTC4xOWWJPPRUOxVFOJV/KhGP73AWXuBQbUyKG2b6ng8OwkjNMO2wvO4 oGDcBWTAOQ0hUy8f6QFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nPPJv-002s2R-7y; Wed, 02 Mar 2022 13:47:11 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nPPJs-002s1b-5f for linux-arm-kernel@lists.infradead.org; Wed, 02 Mar 2022 13:47:09 +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 dfw.source.kernel.org (Postfix) with ESMTPS id B41A960AFF; Wed, 2 Mar 2022 13:47:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B25EAC340ED; Wed, 2 Mar 2022 13:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646228827; bh=AYJw1KgD10Xo1BDHRt9M9modL2x+M6UtzbubyiMQw4k=; h=From:To:Cc:Subject:Date:From; b=T5Ud5V9dcBY1oc/xIg9M5jTSzOaBqkTGDzkJL//3KwXnD9ONR0gPQ/Ri+gnz+WYkk UZ2g7DgtXoUgpp9IQx23fUgPEotLlY4glram3/ZuBzmjLSJFZxz3YKi0hs1mbVuWcR LAcqYkfEjWKcnDuggm6hkksZ/R0dwq5zggzfnSUTtjh3S1fq+L5IVxzEERbOvCwIWQ Ee2+H4cl1LxzmZrgnqMKd0mpt+xNt62gNw5URxCL2gccufzvG6U7rox/psjzts3HQm dJRQ4FWq+tednvjy5kpz6m+bkB+P0DckHZvq5ztjxt978DUg0LbaB7qjbJnNl70L9y IyX5AHkNsSQdQ== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Marc Zyngier , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH] arm64: cpufeature: Warn if we attempt to read a zero width field Date: Wed, 2 Mar 2022 13:47:02 +0000 Message-Id: <20220302134702.172816-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1043; h=from:subject; bh=AYJw1KgD10Xo1BDHRt9M9modL2x+M6UtzbubyiMQw4k=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiH3RUIQBcE6ubgvTnyq8cKnMAwBZ+GmUi9F0490P6 +kAdGlKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYh90VAAKCRAk1otyXVSH0OhkB/ 9A+kjCDaiyV+hm5PougUpHz3lkmAu45Awa4fA6uNbDBzEvLdI4CfA+fsXUCe07N95dqlZz6TiTBv+H 4kxTLJnbL2ZeoC170oye1cWaXoqeLPo99op/X0QvrDWXq551LP1HIJXvzMjEc2NDBxic10HEPhJxZM qXqJ78/f3GJbnbQLjCjXiL5Ipx4rJH9SfVl45MJ1vDeGL05FVfgVAPgoBjZjcT2nKCmQZQcfgRKhqm tEHcZuSIEB4fLWaOb3v11dEgEJGSEqzZtHTBX4g2495Vss4VIZ8laUhiQkvBBfuybPa9IjF/Ary93O EXNnqMOD1M7VIT1gT8DMZ83MlEn4cp X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220302_054708_276790_22E6E412 X-CRM114-Status: GOOD ( 11.24 ) 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 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); 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