From patchwork Wed Feb 28 03:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10246773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79E6760211 for ; Wed, 28 Feb 2018 04:17:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67D3528AB5 for ; Wed, 28 Feb 2018 04:17:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C18828ADA; Wed, 28 Feb 2018 04:17:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E69DF28AB5 for ; Wed, 28 Feb 2018 04:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Su/woTlQ6SxyP3tVMg/Ey/eONz3h02sq5Da0ZVjLF3Y=; b=PVQirCbKbAWa2azHtL/kjBWjsg RXSjkOmfhKgZelIZkKRPE3G7kTn5DRfTkcnL84FAJf6d3HRkKOGCYa81oAwVyxXpXuMMo7fRNuwrm xwVjQ/UC6M1b54nz3dW1K/JyUho5XZfsL5YecPoeDIcyiMv/XX3Q1B+7tC3rQjTVcrbvp8/cFLJCD dfIaq8LoQF2pgKVU2bZS6jiuAK+VesFNHzDqQ6uTlQIM7FJcG6WivCaeosnsLsOc1XoFGTUE4jxJN RaqivbedXkA/WgjCa2JvJGtAxk6EDgpntDxWFntd8CqncGoDzEZIOaxuLVVw7Ud5tUp8YEqV0iRR7 Tkx4ZIkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqtAv-0004ub-LU; Wed, 28 Feb 2018 04:17:05 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqt9Q-0002b7-Ut for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Feb 2018 04:15:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OMOLk3BE6r9QGQmIu+rjUcCTZUD9wK3TDcxdkw1PHjk=; b=Ii3DnaXtk/lCoPkuDSDKyjLtP 6Fg94KsIWUQrNkWi5E5RRV9tOuMyZJLmHfKrVPiDXkA40Tt1tvRv592XOSIX2TpF99MuoncmJ7Yiz u1NFejCapnFk/imHtU/sbnxwXelODodr7KNAabDZggNpHkgVqyfgLq4DCsN1INjixD+uz6Vd0MHVm eFICg6r6v7R80yXeXaollBNxNd/9DUV/HsJps9RyYpIAt5PWeu6+b4ADDz3tDMJjTMA6/H0jz6YUX /Sp1dl8JVTfcVFE7IvqSeD+bKHVPgApyVrF4TTixt5J9BZmUd8k/lHcoRxo1vw64SLAiZiha7ymB2 934xUP8Mg==; Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqsuY-0002PV-KY for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2018 04:00:12 +0000 Received: by mail-pg0-x241.google.com with SMTP id q27so479648pgn.8 for ; Tue, 27 Feb 2018 20:00:00 -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=LOj5KzGl/2/rSOkmV4lSlf6dElXCcUerlP0SURvBtOKupHSQ10BTjI6Ck7cSlsKi/c 3jl0UckdEg7nPSP0vP5NndYpcdaDkZVVpITidjEPg+V9hJbYZzJ/yLVVT0/3sWM+01YH eQFlHOURqeJjCYwOj2xzKB/h5PWTKLbSBtPIssM7zpkjGDKowH7U20JigY4dMg3b5hnQ aPP4EfxoL/CU2jNuGHZLQinW+4tg3af86JCngtIYkyvVTXONXVRulsJx1LYEjepkjXUz PibankQNS/gV37xcImHZbDZY6AOvq6SjeET6vetcG9qRyXOrsrStf29W9u9hyakLfGTC 7ZHg== X-Gm-Message-State: APf1xPBeRn6YQ9uMbmYn8bdx0ZVjSbhBonJjpC2zrB1p3itgYN7mv+wp XonzCXDLz0pKOAL8N5wO7fQp+A== X-Google-Smtp-Source: AH8x224vJ7ofKuDglESlz3Sysd+V+ZdBUN30WfGZm0cUVTRpDGAz9QEalGXTY8mDyeaqUz3lfDQybA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180228_040010_665600_26E57F41 X-CRM114-Status: GOOD ( 16.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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;