Received: by 10.223.185.116 with SMTP id b49csp5728026wrg; Tue, 27 Feb 2018 20:01:31 -0800 (PST) X-Google-Smtp-Source: AH8x227fLpsvscf2zAnAYcHZ1Ux8CIF844w/DSntMvON/LmIha7tygEZaRZ0deugiq063kZHzzJT X-Received: by 10.101.66.1 with SMTP id c1mr13133693pgq.137.1519790491078; Tue, 27 Feb 2018 20:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519790491; cv=none; d=google.com; s=arc-20160816; b=V50t0JFBpLGFtpQlCc1nD6ufbReH7pKJHXJRsnBJ+q5B7rrJ+UWzTVU0c/r8BrWBSY uBKBVEehEbY2HiKLz9ESW+z7f3YtBcASA6RzbA76nhVAixozLszPIoEz3vky764MJ2oc j7jeYW20U2vbKEYNH3APY2J7JoSiDZ5vs4RjkjlXIE43YUD66ytiQfb/rMmSEhyleWQH jVKhow2NgfbOYg8vEK/e5SeiOSEhSYnZZrRAd89bzEXjxDfYlg/k8LhziLfAyHBdsu4/ hiTjVDn66oZ8wZx29L+OtHr9bh0ronBFk6dh3562JBCkaqXDlAFmAVxHghyd5io382G1 wXyQ== 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=OMOLk3BE6r9QGQmIu+rjUcCTZUD9wK3TDcxdkw1PHjk=; b=uO2OkedMNXi3FZpedOA5TQHu1afEIfkuMbYgmKSpAPNURWVULtWdbHyyDLUZJCkbRm a2r6qXF1uCJsc7+NEACpRbfOpyyaTrISAbk8ID1RXoQXmVdWBBuB2x2aUo+sK+x1NPMM 2W42aKWK3utDsbrCjLh2RezNdVbtMwx7oox084w//rvWB+AfnPkr+/RhRZb1vep0ulXH CBU2CHgfT2gtmvpoeg5jMPrCmOhGHtW8D4VhtlH3XHS6O2aC36NxDKYIOJaMWVzgBCdM AX2DM6bxK2PrdLSdEws7fTMd76/FBK0+Mnzpe0TZDt6DeI/0h5/fkLMYjXmsydi0Z7bk JLyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZujYVB5w; 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 k5si449639pgp.751.2018.02.27.20.01.16; Tue, 27 Feb 2018 20:01:31 -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=ZujYVB5w; 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 S932240AbeB1EAD (ORCPT + 99 others); Tue, 27 Feb 2018 23:00:03 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37608 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751863AbeB1D77 (ORCPT ); Tue, 27 Feb 2018 22:59:59 -0500 Received: by mail-pg0-f67.google.com with SMTP id y26so486349pgv.4 for ; Tue, 27 Feb 2018 19:59:59 -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=OMOLk3BE6r9QGQmIu+rjUcCTZUD9wK3TDcxdkw1PHjk=; b=ZujYVB5wMdevtAjc3qrHnnQuXTTYa6SjTqsk4vDArOAJWfStlc1mbwGsFT7HPwS7Ik OgRVPXh4YlGwfUzk6VQRoxmRkbDWtoB59rtOQvL1NixYxMT9E79ycRiED6KobVDCjsQn qAdDq1l1eEhENqJ89keRIM6kzvS0PeRI6War0= 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=OMOLk3BE6r9QGQmIu+rjUcCTZUD9wK3TDcxdkw1PHjk=; b=VJBS7FclaVUY6RqqgdqGdYgXpmLDZiTeCQrI/2cIf5Y4vLkKZ4w/5zNUIyRY8fQR4X 1/3DWp1pIVEabgPcDfEiXMf9xq1rDv2wWViiAjsoEU/SNBFA4sFxfBkBhOVBo2kzlsJo QQAAiDInU9Pw/ZqGQZ3IvIZtTY1UU+X2aj66MgolF27FvFFbUfG2xwEtPin7HJQ8d9m9 fw4UASX3wvXfF8sq55nQr4RTW3GhAN53AAonUX5fiLu1cKeAiLgmL2pUKDyznGYXJ6Z5 OCakC+GG9yiPoL1VRpSgUqwAvLFtC5lV5qHqpohDJ8DabT3Oh03l3G878236RUnH3BZo FGxw== X-Gm-Message-State: APf1xPDhHX+Hp/uCx+dydOii8mdlR96gpC7FbGOs0w5rK2XKgU2Vw904 xFN0H6WhXBRlc9j2G17ReIT0tg== X-Received: by 10.98.202.138 with SMTP id y10mr16234337pfk.184.1519790398714; Tue, 27 Feb 2018 19:59:58 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id q17sm739911pgt.7.2018.02.27.19.59.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 19:59:58 -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: Alex Shi Subject: [PATCH 20/29] arm64: Allow checking of a CPU-local erratum Date: Wed, 28 Feb 2018 11:56:42 +0800 Message-Id: <1519790211-16582-21-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> References: <1519790211-16582-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: 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 --- arch/arm64/kernel/cpufeature.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 3ec6517..4e5dff1 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; -- 2.7.4