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: 9683117 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 5FBD360138 for ; Sun, 16 Apr 2017 20:28:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E00327B81 for ; Sun, 16 Apr 2017 20:28:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4108927D0C; Sun, 16 Apr 2017 20:28:13 +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 [65.50.211.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 D1B5227B81 for ; Sun, 16 Apr 2017 20:28:11 +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=e7saH4WtNvC8w7XWCkT8EIYQ8BsNseXPWSuFppOyHFI=; b=n0YaqOoxAf6JmtfrHRFLx+B4Ie pA8LEGwTtGhuLIUV6ZvNjIUZ26iY3LfMIx4dBqj14aVmhJTrIck5clF2RBjSTOAnmvcou6erxwqxl P7sCNPLWDbnH9I/J9pUZPIYeJAzw6oaPvipeA4xkNbtm+zxeRJvGe92xOneIvpRwJRxDGHNz5i5wF 5mN/2YsMoqDtu3biS+Rm/sLymuc2oXpav+0BIu+cRZbH8Ac2MWukU2W75JVS1oFzg5w1uRSYUiBUG 8UK+pBk7yFW6NeSYqfpCpnFCCPulk83h9JIROpcTy7WpBxfbuQXz2+Hy3BTRSbUAJERQqwq48lNdQ P3kozvow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1czqmH-0005uX-Ah; Sun, 16 Apr 2017 20:28:09 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1czqmC-0005rX-Up for linux-arm-kernel@lists.infradead.org; Sun, 16 Apr 2017 20:28:07 +0000 Received: by mail-wm0-x235.google.com with SMTP id t189so22460563wmt.1 for ; Sun, 16 Apr 2017 13:27:44 -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=KW7+Xr9IUAQ5SIfza8acaLc3dPAtyMBuTf/1LG43LDnz2Q+FsGuPpqfecrcqYvJdHQ Zi2CS6ZY8MxUPh041ov/iopQlUVyI2M03qGNuJaB6ZL0r0LCSs+Y+zXtYXl0lzMGUaxE 74BCl7K6syO6XduFg1J7rbOl9IDjcckUG2rE1cQ+cZtNzBFtk7HqMIDKgnHDLrV9tT9+ xvC59NeZNmial/KKrhh7TJa1+fhEIcUrjxRZOzkV5VCrkAUMWV9RRZN4Y+8jyKFU4Bbk uPIJgapphAYL8HHPaqL6neEBjKauUQujI5jLtuzMg1RHOaBrl/WU7htpWC1Z9wr9eXR+ FrIQ== X-Gm-Message-State: AN3rC/7Zgk4oCAeFw+hP133t6WndQgyYrKp5p8TwCRjst2wfPnkwCtWb hQvkbLPFq7G19pWb 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170416_132805_355812_010AAD5C X-CRM114-Status: GOOD ( 12.16 ) 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: Mark Rutland , Suzuki K Poulose , Marc Zyngier , Catalin Marinas , Ard Biesheuvel , Will Deacon , linux-kernel@vger.kernel.org, James Morse , "moderated list:ARM64 PORT AARCH64 ARCHITECTURE" 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 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(-) 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;