From patchwork Mon Feb 26 08:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10241493 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 AF503602DC for ; Mon, 26 Feb 2018 08:27:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9965429AD5 for ; Mon, 26 Feb 2018 08:27:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DF2129ADE; Mon, 26 Feb 2018 08:27:42 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 123C329AD5 for ; Mon, 26 Feb 2018 08:27:41 +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=scaEJBhUL/3je/ehaiIsGTjFkD/gTHBDuBwj5ShPILU=; b=Gzt1hyOnU5c3q7/SSKLAnjh6Nz qOyNNfKLr9hTClxDPYnFHbojdXpjgqkIgAOZ0OQOVDLGePLB0sw33FkxEepu/tFK2Yy8Fc4LaUiKD j3TdPIAU1sPMyin6E+5qVsTKzryHdN4LcLBMMEygMbbAYdxtCcn+WloyhoEzr2kMNxJ5iHJkCNj99 PA73LWA22YBAtK2V7z/nQGMFWgmZG5Txq//6nSe69d3uJqx4yB3nsNgVrqFyaAKF/WgLV1DZXnJgg v/fOr3b4EArqebC1W7pmdCKg7ieGSYleQkzGl+Q+C2Q3BbyzVMtA3g2WrDTipeK0v7PQFstso+WIa iNxLhIqQ==; 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 1eqE8A-0004sL-Be; Mon, 26 Feb 2018 08:27:30 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE4H-0001J4-Qe for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:24:26 +0000 Received: by mail-pg0-x242.google.com with SMTP id g12so5911697pgs.0 for ; Mon, 26 Feb 2018 00:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XfV6Yv3SjvB5RVvJ7haGkLOWLK58ZxDQcMshzGS5NdQ=; b=GUnDuslpSiChZ+QIgEJzPMtjXw0pn/sfSRH6ZkzKshR10JThMZJJjWh/Zb7/BWrS+U /I68OuzXRLS5btS73LM3MYhwx0Mxltux2/+dOlXJQborMenSXZwjwBfN2CrttmqMVs78 p8WRyf6jWZok/ewRYnJESmK4NpvAdfpUpDgSw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XfV6Yv3SjvB5RVvJ7haGkLOWLK58ZxDQcMshzGS5NdQ=; b=lCXLpZWm3lLvO4JWkIfgEQXOWVEL0dygNrofgEqDmxpzEu8CHxAbMdD3WUXWpsEzSB no0FciiZE0gPBgs7ByBC4pmI2uQ1f8o5DOOBRwrJdX7vfywIK3FAiuAFvUMAkMW4M6Qj eee3EgYszosKQyf6ymJMvNvVLSgPqZu2Vt7WLs+UegCA83loQFfNsvOMr9hY/L2l4Z+4 phy/BN/gokty1gPcHLzVfCHjV8YcIDOm6BNqsEDmdOvw+PNl03q2ityumtK3qGwAbzjt GsG19o3A8RQH7VFlrfhexOjfJj+/ZCCffBFRUHVROeAwDspisX6/x8UmMkaBGoeimY5u Djkw== X-Gm-Message-State: APf1xPCG+pOuipzzRJGs8uuY0UBYarB7gkzUs4agpmZi1VQ7NBUcQSFf /ujcjMDUufMWxeTi6GNf5KCNEA== X-Google-Smtp-Source: AH8x2268NzAetSUpA0ot47O8YLJiHqyCJ0/DrSnxNvRlT5UzI+fGUtw6VuPS5lFsPgGcUNNHBM4wTA== X-Received: by 10.98.91.5 with SMTP id p5mr9794882pfb.163.1519633399033; Mon, 26 Feb 2018 00:23:19 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:23:18 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 18/52] arm64: cpufeature: __this_cpu_has_cap() shouldn't stop early Date: Mon, 26 Feb 2018 16:19:52 +0800 Message-Id: <1519633227-29832-19-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_002330_663476_B832424F X-CRM114-Status: GOOD ( 14.58 ) 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: James Morse 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 From: James Morse commit edf298cfce47 upstream. Alex Shi rewrite this commit on func this_cpu_has_cap(). The following commit log is still meaningful. 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 Reviewed-by: Suzuki K Poulose Acked-by: Marc Zyngier Signed-off-by: James Morse Signed-off-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- arch/arm64/include/asm/futex.h | 1 + arch/arm64/kernel/cpufeature.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h index 1943cf6..718140a 100644 --- a/arch/arm64/include/asm/futex.h +++ b/arch/arm64/include/asm/futex.h @@ -20,6 +20,7 @@ #include #include +#include #include diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 3a129d4..fcb67e0 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1063,8 +1063,8 @@ bool this_cpu_has_cap(unsigned int cap) if (WARN_ON(preemptible())) return false; - for (caps = arm64_features; caps->desc; caps++) - if (caps->capability == cap && caps->matches) + for (caps = arm64_features; caps->matches; caps++) + if (caps->capability == cap) return caps->matches(caps, SCOPE_LOCAL_CPU); return false;