From patchwork Mon Jan 15 19:38:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10165279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA25F60325 for ; Mon, 15 Jan 2018 19:41:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A817024603 for ; Mon, 15 Jan 2018 19:41:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B91725D99; Mon, 15 Jan 2018 19:41:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23E0A24603 for ; Mon, 15 Jan 2018 19:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lrp+hz0P6bYGYPluh1/J1a/VBO5rsQcGHVFBoyDWxjM=; b=F+xvpf7vUpHPzedaBYSaBVsDHs GAkkw5HYxJOs3yQkMv2fS4BgUHQUnzurJDGexPQDu5foWnh682dqSSdQ3TaWpAwkkjL+7tYXqnZNo Nzbv8+4Jc8lo3+W96msDGL3kpsoBKThuTCxL9gHw672zcc3hSq06n9S01Fc5K5rr3rLVceEQeaq5U WlW5EOMMEKCDkXmbr/DZdZ+7i+ZxAJTJna9zEuiX1oBiYoX6Fyxn459NH3R7MFrrGMm+gzf4yUgqh O9eXWbn87e1URxjXHLwRFwDcLCwImfOPl1sLTi17OnW+RmikoKccrDqrvLr8pqRe8r6HhGS84Ownz FlJpMHFQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebAde-0003tt-9R; Mon, 15 Jan 2018 19:41:46 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebAda-0003r9-LL for linux-arm-kernel@lists.infradead.org; Mon, 15 Jan 2018 19:41:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A19171596; Mon, 15 Jan 2018 11:41:35 -0800 (PST) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.207.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B2E9F3F557; Mon, 15 Jan 2018 11:41:33 -0800 (PST) From: James Morse To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 01/13] arm64: cpufeature: __this_cpu_has_cap() shouldn't stop early Date: Mon, 15 Jan 2018 19:38:54 +0000 Message-Id: <20180115193906.30053-2-james.morse@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180115193906.30053-1-james.morse@arm.com> References: <20180115193906.30053-1-james.morse@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180115_114142_728811_899ECBDB X-CRM114-Status: GOOD ( 10.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan.Zhang@cavium.com, Xie XiuQi , Marc Zyngier , Catalin Marinas , Suzuki K Poulose , Will Deacon , Dongjiu Geng , James Morse , kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP this_cpu_has_cap() tests caps->desc not caps->matches, so it stops walking the list when it finds a 'silent' feature, instead of walking to the end of the list. Prior to v4.6's 644c2ae198412 ("arm64: cpufeature: Test 'matches' pointer to find the end of the list") we always tested desc to find the end of a capability list. This was changed for dubious things like PAN_NOT_UAO. v4.7's e3661b128e53e ("arm64: Allow a capability to be checked on single CPU") added this_cpu_has_cap() using the old desc style test. CC: Suzuki K Poulose CC: Marc Zyngier Signed-off-by: James Morse Reviewed-by: Suzuki K Poulose Acked-by: Marc Zyngier --- So far only ARM64_HAS_SYSREG_GIC_CPUIF and errata use this_cpu_has_cap(), all the errata have descriptions, and the GIC_CPUIF feature is first in the list, so its not possible to hit this with mainline. I don't think this should go to stable - this is not intended as a fix. arch/arm64/kernel/cpufeature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 9ef84d0def9a..d88cd0e88606 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1303,8 +1303,8 @@ static bool __this_cpu_has_cap(const struct arm64_cpu_capabilities *cap_array, if (WARN_ON(preemptible())) return false; - for (caps = cap_array; caps->desc; caps++) - if (caps->capability == cap && caps->matches) + for (caps = cap_array; caps->matches; caps++) + if (caps->capability == cap) return caps->matches(caps, SCOPE_LOCAL_CPU); return false;