From patchwork Tue Apr 3 11:09:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 132726 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3666270ljb; Tue, 3 Apr 2018 04:10:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+9qJLqANur7SXy+XPxL78suZKqzFWUt5iCnf7gl5g41VfOUXo5HrUCmtUkbifjAiMC/FAL X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr7205573plp.367.1522753827891; Tue, 03 Apr 2018 04:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522753827; cv=none; d=google.com; s=arc-20160816; b=qNWFL5gTtcS4vnbfcINY9MtwRDSNObzqIzrh2VgOghumK7UFRj2kB4Plg4XAmtgIP6 0F+LVRU9Bxxozh7obgMZJNOq5lmTNowJuB52MV7Ne5JuQOcvKz+hV9SG2JajLhuftglz J68m0lX0gvVM8vVIfD2d3wFTsc5TgMygOrG6kUGn5CUdW6n0bfxOSh+G2B7xhY52ttlr U/8jS3NyCRI5fsIPfx/8trG9lnhWI8iFPQEwKUX0slbWQg5uOFljcPl7B9ONlSSOd9CV VwjTdB4nsSQPRkp+N2ekab3V7zpm6dhFFC4LXHRfbFLs6szB3UPuD1NV6fgiCrrp53iR 2j6Q== 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:arc-authentication-results; bh=nugr1gNs2+A6YmEXb5yDYTJgZC1y4wCv/9OtCfTQelA=; b=pah7HWjP5pErBzYv7rGUw78kfzoQOe37g+RRkmCI3cN6TR4d1UK2cik5XGOpkjYGrc ZHCTynsh3decUiTLVxkmGC4YDGgjKBJ/ULSEr79g4ZPLkpVZzv4PGxP/C5sqe7DQ/SRx G0Pb4QbGqAx3V54iLUFqzF9UOkR60sZ7T+NyAkNyFV6lzLoONK/r3jKdD+anv8NBPMIO qsKXi9hd1SbfDSlfOdORY9ytpnGHrOnudZiBcqHi0TVVZv+zsE2ENRTyN3/Ob09du9Ec eu77PSXHnVWTtrpYeBnqee1on4tiNpy/4zhNhEbaPog94tLT0+zH+a9xlYTIzFxxGYS4 F18Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l91-v6si306341plb.301.2018.04.03.04.10.27; Tue, 03 Apr 2018 04:10:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755410AbeDCLKZ (ORCPT + 11 others); Tue, 3 Apr 2018 07:10:25 -0400 Received: from foss.arm.com ([217.140.101.70]:59388 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755312AbeDCLKX (ORCPT ); Tue, 3 Apr 2018 07:10:23 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABE3F1596; Tue, 3 Apr 2018 04:10:23 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7B8FC3F587; Tue, 3 Apr 2018 04:10:22 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com Subject: [PATCH v4.9.y 19/27] arm64: Allow checking of a CPU-local erratum Date: Tue, 3 Apr 2018 12:09:15 +0100 Message-Id: <20180403110923.43575-20-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403110923.43575-1-mark.rutland@arm.com> References: <20180403110923.43575-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 8f4137588261d7504f4aa022dc9d1a1fd1940e8e upstream. 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 Signed-off-by: Alex Shi [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] --- arch/arm64/kernel/cpufeature.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index d24e59cedae5..810f8bf7c57f 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1103,20 +1103,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;