From patchwork Tue Nov 17 05:05:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 56701 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1717783lbb; Mon, 16 Nov 2015 21:08:02 -0800 (PST) X-Received: by 10.68.216.36 with SMTP id on4mr61193080pbc.12.1447736882179; Mon, 16 Nov 2015 21:08:02 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id cc4si55438018pbc.36.2015.11.16.21.08.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 21:08:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyYTb-0006db-36; Tue, 17 Nov 2015 05:06:43 +0000 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyYTX-0006bo-Gu for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 05:06:40 +0000 Received: by pabfh17 with SMTP id fh17so202111435pab.0 for ; Mon, 16 Nov 2015 21:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=v2i7Ehc6yWCe7Mu49GDg8vZiUKnfU0h259CAr5g1ehk=; b=iP/xlXhZG8xBnSlFNmS8P1qlI3UoeSR5ixK49f1WlHJIhBXs9MYaG32KmXHpj+LyVd cKW6W2ADXKBD+weX4BG/QDkbtUI6bMjyvxiIw+GbCLXUQqpaSmpHx+z1Ko1Ty4cGqJj0 POX5EVf7mdXX/4aztteNtyZtRdL/OBuryDJrPbJMvGGL0tXs62qATrsZbVqPETHgTfss rWYdl8paDkUHI+Ry+gS3UC6cQwPUhTA/ip3mVl83ZJo9AdjHJNmKDhiRGFCAHH+PoX1S AHIZwEoaCaSsL5eMlF2I7iC6Av2YeUdkUrkT9iu4CEJ7ojFXfjEGJanWmJ3o/ItcV8bi j2ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=v2i7Ehc6yWCe7Mu49GDg8vZiUKnfU0h259CAr5g1ehk=; b=ZXjzuS1nyf87s9+Ry9OeC5VrLTBrWphQK1EmMcuKHiSvTK1SFgPLmHOzalSsJgA3qz LUlnYUon3njtv4h45PvyoJqXcuDZFZ8wISuKRpsdrhVJTKs4HtCFifZSiT2SYlnz//k1 5C/UW+9uqh0Xo53dv1RFbM6WN52DlcBIWeD5ulV338aCLs+uwvWwBhW5fK1ovwQPQOUf cPTCJmLFs+ZGyHiIWpqZLakc8kWKr7NS/LIlDyYmU+6KNg8HngHFjzq3ldppM3JD2kkp 9DtR8C9i1xzkAEk3mWrAMeVzg9vHsZtQFDSTWeEf5x9/dFX3ct30yhZ/DVcSByHeDqan mUWA== X-Gm-Message-State: ALoCoQkv0kd+whstgPb241EfjTLPx5kM2ihYfncHtvmihWzlTs2ISFeno79ObhIuGNdjOUPincbo X-Received: by 10.66.102.101 with SMTP id fn5mr61404533pab.66.1447736778134; Mon, 16 Nov 2015 21:06:18 -0800 (PST) Received: from localhost.localdomain (61-205-7-47m5.grp1.mineo.jp. [61.205.7.47]) by smtp.googlemail.com with ESMTPSA id pa4sm39751891pbc.0.2015.11.16.21.06.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 21:06:16 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH] arm64: extract a field correctly in cpuid_feature_extract_field() Date: Tue, 17 Nov 2015 14:05:39 +0900 Message-Id: <1447736739-4131-1-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_210639_600455_5772D6BC X-CRM114-Status: GOOD ( 14.72 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:230 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: AKASHI Takahiro , broonie@kernel.org, david.griego@linaro.org, linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Basically, cpuid_feature_extract_field() does shift-left and then shift-right to extract a specific field in an operand. But a shift-left'ed value is casted to 's64' and so a succeeding shift-right operation results in creating a sign-extended (and bogus) value. For example, commit 3085bb01b406 ("arm64/debug: Make use of the system wide safe value") changed get_num_brps() using this function, and so we cannot identify the correct number of hw breakpoints available: > hw-breakpoint: found 0 breakpoint and 0 watchpoint registers. ID_AARCH64DFR0_EL1 is 0xf0f0f106 (on fast model), but get_num_brps() returns zero. This patch fixes the issue by removing the casting. I think that cpuid_featuer_extract_field(), arm64_ftr_value() and others should return an unsigned value as an extracted field. Signed-off-by: AKASHI Takahiro --- arch/arm64/include/asm/cpufeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 11d5bb0f..ab01508 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -114,7 +114,7 @@ static inline void cpus_set_cap(unsigned int num) static inline int __attribute_const__ cpuid_feature_extract_field_width(u64 features, int field, int width) { - return (s64)(features << (64 - width - field)) >> (64 - width); + return (features << (64 - width - field)) >> (64 - width); } static inline int __attribute_const__