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: 130197 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2762220edc; Thu, 1 Mar 2018 04:57:39 -0800 (PST) X-Google-Smtp-Source: AG47ELudxr3/gzIInr46S+mQzwTWzOSMLMG/ZrdwC8mwQh04J4Nco9hxT5jyGvJaxw89o6F+AeZZ X-Received: by 2002:a17:902:a504:: with SMTP id s4-v6mr1908737plq.43.1519909059604; Thu, 01 Mar 2018 04:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909059; cv=none; d=google.com; s=arc-20160816; b=SmyXZMP4cfxMLH0zUdtf76nyxpQz0POIDVvkEBYtEhnaO36zqNbY9MsafOtTcm6aKz TjNV9exBLJG7sOlkKZ4M6Sg8F8rglkUqcovvBJtcT8+HMMjEe9xrl4shP7L2GqQ3Kcci CEDTlVBAQK5kcDrq9TLZJEAnIkmdGzmxWF1xTQpjtIev8G6wuGn2orMrDtDDafjk+ekF LkD2bf3OMNS0OMbrdyIAil9Edi72fuDav6fT1lV8h5VJ6hreje7UpUjlWQfgAC1KsfVj /0hXMaLd9CIMz1Y7VuOmQj31tq/UzoXiXFhrs635tlrhtgwHNhjfgav/VswjWXaoz5zG 9GpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kRECNLAGvLdU50wl/x4bZ8haUF1zIORex5wijx37hoU=; b=AesveFIxDDf4L9ORzO0RlyPbNatGVT+pNoiJe92rd0lsJEQ4CBe4sYFihwehjYF7WR DgTzciDFIpJAi+PREKAhG1ZSDXm/aoXjTZ/ptFbz9mwE1SoncHSv8/0fAPCFfb+fkCjc UD45BLzED8mmbBwktFRJLtLUm1LljNfvCgTiuFE3lrV9UbnnEPdaDhQm2yj4QS/I41M9 2o16GWeGUCNgEcK7yrKEszYjOwDbf8UUIkJaj9Fx4DzjPaZFQq5EqI/gb61ACYSf/eR/ d1qZamBZ7Xvc0v7TfA+4ZDdzJ9CWD5OzsLHRP9J8J1g6mRE3FkrODEHk3esvAsEGzDk/ bijQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UAGp3y1C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si2967984pfb.394.2018.03.01.04.57.39; Thu, 01 Mar 2018 04:57:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UAGp3y1C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030884AbeCAM5g (ORCPT + 28 others); Thu, 1 Mar 2018 07:57:36 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:46052 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030790AbeCAM5e (ORCPT ); Thu, 1 Mar 2018 07:57:34 -0500 Received: by mail-pf0-f193.google.com with SMTP id h19so1520044pfd.12 for ; Thu, 01 Mar 2018 04:57:33 -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=a8YsNGLe6qWLIbcHqNOf5lkanF9wMYsqxMH/YJQqPewjKL+9uLJM687JfPcgAqt9Ag ZBsFitb3xqNRf1YVakIWP+eJLUD4ZZYd87KKaAQj56z3t1P4PZP/pIz+KoTUO2V/zYSO MAyACOK8tY5ZPLGS2uI04VjJAd8kY+bMWGag45DoMTBAD92DaRjRHa8lAlgYq5zZyDlD 60soDntyUv4KIBDkXv7phUiWh3q/F8HVIeuF5m0G/uFg9VF8Im9km9FEPa0jmBk/X+U9 x0eHdPTBsYYB3swzN4Euu/C+g3I3ilqnsGEF7I+Zk5UDNLL4EqaBF13UQEBbQ03ZBFPx k6kQ== X-Gm-Message-State: APf1xPA9Ak5KAGPZnE8LG2kjuZ5vNrtqEHtsY4KgTbSGeb+204FQC6FJ J597j8B9S7X71p5/nqwzFTGjtg== 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 Cc: James Morse , Suzuki K Poulose , Alex Shi 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 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;