From patchwork Thu Mar 1 12:53:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10251445 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 27FBA60211 for ; Thu, 1 Mar 2018 13:39:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 151AD2018F for ; Thu, 1 Mar 2018 13:39:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0920E201BD; Thu, 1 Mar 2018 13:39:32 +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 7B2772018F for ; Thu, 1 Mar 2018 13:39:31 +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=NbM8I/nR7c2eiqhEc+xLdU+7FKf//FfhqSmI4gp5io4=; b=rL0qvP6eN6bKx2HBFxhGs00z2J peV58Yc3bXjkVR8kHvGKDNE2qk28tnrtp/Juxt1GsfIG7kxeDz8R3FQjDEr+LWy2kX1K4tMrdFwX5 tugq54mtUoCTPwh+MiiorI0IyhBvEHg4diNaqobDcg8/XPVOFnKGVO2Ti4djBlvTyX+T6JMH/BNcx CgxBpwVWxewLNfXrNMzbVi+Thgs1ww6r/mBsfXJuaWaa2qZx0rTGUaviCk1lTU1Rna7PWEO6cDmWi JHTq7c2F5Fl7JIVoiGYx7S3ZU1aqhRXcT5wT6fUREGVBjQ8yVI2Fi7mdBlCaJ0qIQ7y7q8J7+o8Ov GHDGCl4A==; 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 1erOQb-0001gI-GG; Thu, 01 Mar 2018 13:39:21 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erOHO-0001sV-0j for linux-arm-kernel@bombadil.infradead.org; Thu, 01 Mar 2018 13:29:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kRECNLAGvLdU50wl/x4bZ8haUF1zIORex5wijx37hoU=; b=zzpDG1tMtvEhnRjnMlvN87efG c4ISFAhPDUcGujKG1CbA9XlEHm/R/S7bkw01wHi0rlDMhLzQSBPz8uekzBgZznhvR/Uyu9/7sRgaG sb7pzaFx36KHOsn4VACqiF6yVLIAVkJBgXRCMFuXcFx8cLqQsnzFfoq5RqQQqMW7XnJISc3eVRlu+ oHvaWXRBQPhug0xxw3OHfv11x5YvtoN3wzMhnePgybXiLT7+se3+85p5Ec7eBcPW2KmaTNtNsjixl lfCQIy5BgJk40xJs2xq0GV0MgugZ5Dnyrva7ot1GukQLIgK3wicNVS6/g8akUkVoI+cbCYfSyVSJ/ NqJAJjH8g==; Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erNmL-0002G1-QS for linux-arm-kernel@lists.infradead.org; Thu, 01 Mar 2018 12:57:46 +0000 Received: by mail-pf0-x242.google.com with SMTP id f80so2399254pfa.8 for ; Thu, 01 Mar 2018 04:57:35 -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=kRECNLAGvLdU50wl/x4bZ8haUF1zIORex5wijx37hoU=; b=UAGp3y1C7/q49oNYuAlcjG3D6pnUNPdpWufRL/I4+mivfaZBj8V1kjdy/JtC+XcOmt IpWhLRm3hDx+XD874RyhGUAahjPDY86Sssfx0HsUy6gwt1rKokPBHnFdgDUQ3zDHd7CV yr5GzG64TNwh5aCEk8/EDXcneiaeoTUrR5ElM= 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=kRECNLAGvLdU50wl/x4bZ8haUF1zIORex5wijx37hoU=; b=Wsr5a6VaCMLoM7xAY0zoqvU3oY0kH98QcqFbhUdwcKHQ9GZnS29arSGNjNsZoiMJAG rpfoH5sZEyJmjucJz0oNthyXpGhFObA3JeIxP5g+7ufe2ABgCUD4KTg/wSmlD/6n0Mkh StqMKus2UJmFsleUgqbHMO3qTpvMISKg8i4w3yyVjbbjoLMUvLcb1yN5GqBj2nDsP6jf cUF+ILjoikkRm3IFoEIg+a4HNNv5+bGkA170PWVT5Dfa4xEny6nIN2ga6oD4gKJKdjB5 BfX+utz16MENI7/jzIU75pUsbfq/J5u/M7h4bpg5Rn2Y9LpA7e0vu64wZBIOS15J+ilJ 4ujg== X-Gm-Message-State: APf1xPD1vGK59mRSbLhZvcFA/gUyk+N2FiqxzaSKN0U1PmC+x6eliKMY XiMNPsPCuLn35T0ZjHEotUoX0w== X-Google-Smtp-Source: AG47ELsCPnYL+XCl7pU6hYArBj9T9s1wxd595zYUXytvisUPEYNo+/X4/9+gJ7VvoOVMY80zo44tww== X-Received: by 10.98.159.209 with SMTP id v78mr1842256pfk.49.1519909053608; Thu, 01 Mar 2018 04:57:33 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.57.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:57:33 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/45] arm64: cpufeature: __this_cpu_has_cap() shouldn't stop early Date: Thu, 1 Mar 2018 20:53:55 +0800 Message-Id: <1519908862-11425-19-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180301_075745_902352_F7712D9F X-CRM114-Status: GOOD ( 15.67 ) 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: Alex Shi , James Morse , Suzuki K Poulose 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;