From patchwork Sun Apr 16 20:26:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 97462 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1086806qgf; Sun, 16 Apr 2017 13:28:14 -0700 (PDT) X-Received: by 10.99.147.74 with SMTP id w10mr8628177pgm.185.1492374494255; Sun, 16 Apr 2017 13:28:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b69si8923242pfl.158.2017.04.16.13.28.14; Sun, 16 Apr 2017 13:28:14 -0700 (PDT) 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; 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 S1756784AbdDPU1t (ORCPT + 15 others); Sun, 16 Apr 2017 16:27:49 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38480 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbdDPU1o (ORCPT ); Sun, 16 Apr 2017 16:27:44 -0400 Received: by mail-wm0-f47.google.com with SMTP id t189so22460564wmt.1 for ; Sun, 16 Apr 2017 13:27:43 -0700 (PDT) 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=phkZEYEsAm+Lt6l6rWGfig2TSquLlLDQR8Gb0k0X2Rw=; b=DNNTWpanjl5vlIvqoAAkVfrxQsA8CZ8Shy+utSdtCDHIEnzU0X7rq4zTCQKk3kwYGk hNvmr+wtsdPLvUdSyyTwEcNvCJAfDVmf7Jic+UYofa1ifbce2kvH+riKV5dx8I7fsGkr oeIYCVLMnnZH+UbHrOyJ9nIT0zO3uuEtutHkk= 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=phkZEYEsAm+Lt6l6rWGfig2TSquLlLDQR8Gb0k0X2Rw=; b=RHy8c2bwDXV0UDsUw95NStbFiH8oMNkzcMysK4DF6iydQvXNy/wbmxyk1tnjP0exX8 qV4vnvORB9ndrxsayc0f4/s391OvBahyZiip3QJXShg32wCmP9hPSBuvYHfZro9V3LXp w4JBJ9zH2bzEXb/DUZRzmSDrycarVHWhbL7+/qHh3sNxJBMX3e9eNn1dZ4sUe7Jbxziq h5b92yo4Mztw8mPZYRXmCn0l9UEqC9akw+tS9uf0fP7Y/Nc/qZrsYQjqz4DloaF/YG8M e5E0wBXtbOuoEYwcmYZgUZNdzUorR2opeGIK7GtVM6FtDcu94UXGn4sEsP/iTZ307TLS hWeQ== X-Gm-Message-State: AN3rC/5ypuqmgymjrr95sD0Sm7nhRl46ssxYp/ocBIRRcVQ2yicJ25DT AmtLyt8xCR26jB7k X-Received: by 10.28.165.13 with SMTP id o13mr5556971wme.139.1492374463011; Sun, 16 Apr 2017 13:27:43 -0700 (PDT) Received: from mai.lan ([2001:41d0:fe90:b800:20c0:6248:a385:db35]) by smtp.gmail.com with ESMTPSA id 81sm7732196wmj.9.2017.04.16.13.27.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Apr 2017 13:27:42 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Marc Zyngier , Catalin Marinas , Will Deacon , Suzuki K Poulose , Mark Rutland , Ard Biesheuvel , James Morse , linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)) Subject: [PATCH 01/29] arm64: Allow checking of a CPU-local erratum Date: Sun, 16 Apr 2017 22:26:51 +0200 Message-Id: <1492374441-23336-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170416202542.GV2078@mai> References: <20170416202542.GV2078@mai> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier this_cpu_has_cap() only checks the feature array, and not the errata one. In order to be able to check for a CPU-local erratum, allow it to inspect the latter as well. This is consistent with cpus_have_cap()'s behaviour, which includes errata already. Acked-by: Thomas Gleixner Acked-by: Daniel Lezcano Reviewed-by: Suzuki K Poulose Signed-off-by: Marc Zyngier --- arch/arm64/kernel/cpufeature.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index abda8e8..6eb77ae 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1090,20 +1090,29 @@ static void __init setup_feature_capabilities(void) * Check if the current CPU has a given feature capability. * Should be called from non-preemptible context. */ -bool this_cpu_has_cap(unsigned int cap) +static bool __this_cpu_has_cap(const struct arm64_cpu_capabilities *cap_array, + unsigned int cap) { const struct arm64_cpu_capabilities *caps; if (WARN_ON(preemptible())) return false; - for (caps = arm64_features; caps->desc; caps++) + for (caps = cap_array; caps->desc; caps++) if (caps->capability == cap && caps->matches) return caps->matches(caps, SCOPE_LOCAL_CPU); return false; } +extern const struct arm64_cpu_capabilities arm64_errata[]; + +bool this_cpu_has_cap(unsigned int cap) +{ + return (__this_cpu_has_cap(arm64_features, cap) || + __this_cpu_has_cap(arm64_errata, cap)); +} + void __init setup_cpu_features(void) { u32 cwg;