Received: by 10.223.185.116 with SMTP id b49csp3488818wrg; Mon, 26 Feb 2018 00:25:03 -0800 (PST) X-Google-Smtp-Source: AG47ELtn/zjZ+DKzsfHsL5cep3cULsd9vRdIcm4yqWt/f3/SSEQfsxuOfmU8bYOo9tySDo4YRar7 X-Received: by 10.98.11.145 with SMTP id 17mr17382pfl.150.1519633503061; Mon, 26 Feb 2018 00:25:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633503; cv=none; d=google.com; s=arc-20160816; b=CllRHwMmBilG6LtOre2Yi7sk5jpGBrf4+ykLDKIKTx+nDinIzjlI+I6wBrfh5ofB7J KRvoVAOrC+K1LG9DJZuOQg1H+ECr0jp//fK8V/Z09onF14T2VZZ1PctvhP+zNmw6AUCm ga6/aM/9fmpM+VJpDk/IqiqGdqvlnG//ECuGOPTL/M8fPNhU2yuiIgqaq3DGNhwMA0kv eG5wpXBJTjKs2PHTQPJmbaVzJytwNUAtDUlKnvna2AVhWYOXkUtgykZ6o0VyYhfj8/JG VgYC4meDtkWEDVOY/2Dg5v8r5I6dNQ/naepmfuCNZZPCQJDTBBq3a4Zbp98UCmnKnIZY Z4cw== 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=XfV6Yv3SjvB5RVvJ7haGkLOWLK58ZxDQcMshzGS5NdQ=; b=hmsFSGPn+fffwL0wioAz4/gXVCxiTOHI6LWrmbfagQ7pCBIACutE0ohWXWDBKIyJON 6zMvMF9VFvQoICn6sF6tEdLY3Xcq3SALKoXZLabHggKg+sJ1o29pHI1LeW6Rg+qUD9SC gLCUMH/O+betApqemTyFTqv2K+ZWpAzbNK4PsVB9hUy3+a68dI++fbpTIFdXe+c8LsLD uAWXNvKt/keks2TziFj5nSoLwFYJ28jFEEMXWG+jdLImBnOO1xz8H9fcAaYA8Ah60xIr 5Lx8lOyuNUsN6zq+KUxOvoFet/xsUKtoNjuPyQcWk0oG5+a9y/di29MHcmvfhp1yk3+6 zbVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GUnDuslp; 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 e17si5233482pgo.61.2018.02.26.00.24.49; Mon, 26 Feb 2018 00:25:03 -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=GUnDuslp; 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 S1752528AbeBZIXZ (ORCPT + 99 others); Mon, 26 Feb 2018 03:23:25 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38561 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751793AbeBZIXT (ORCPT ); Mon, 26 Feb 2018 03:23:19 -0500 Received: by mail-pg0-f67.google.com with SMTP id l24so5915022pgc.5 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=gNgHVCIp6WtUazM45SHsvtIttT7kGqk+zcf+jprshJFdTvu5IFzDnz5Vw3XtsbKNRb l+oaJAnc6GZLqGlRRZtXtyvmX70iLa4JcCbgEgLof8EHeNgQeSA4vPGzKjPR4Fv8ClOX 63pt3P8shhhjpSTbeKFoXlyFrSWcS1Bz28zJkGUumrm6TTOSyxoB/s7GTLtOPjkuLT4D UAaclTArmeTNZKHhc2tcTagTBDv8Az6q0n0L4zydub5a02YM4NvOyr1qtpaTc4A8r/Cl hN66MAaMAPWFh+7B5wbWSdVztjKTNQapqfcjevzXzoEKrwYsywpcqHEA/XDXK2Z86cle agzQ== X-Gm-Message-State: APf1xPCOqLBlng9E5+mX2EGisL+vlN16HMiF4opxvMmfIgMb6/iYwgay 83QTK0FtGPfTciNTeO7hDhgplA== 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) Cc: James Morse 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> 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(-) 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; -- 2.7.4