From patchwork Wed Nov 29 23:03:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 10083775 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 E347860353 for ; Wed, 29 Nov 2017 23:04:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D339829D16 for ; Wed, 29 Nov 2017 23:04:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7A8329D19; Wed, 29 Nov 2017 23:04:23 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable 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 1A89629D16 for ; Wed, 29 Nov 2017 23:04:22 +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: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:In-Reply-To: References:List-Owner; bh=dcQi3FCSV8sCQs8yhDMTSi4iwnVTcE3D0LFg8vYj7JI=; b=K/W /HFxYVHt+UT2t0PgGYap21bUohUzdYOL81DCYsVlrwAwXs9C9M4TlMR7pcvksyVx/WuKuLll5oDPa F+IiurC7pwxLVaEYtM9PTIPPsYcNDvftDwCYpcnX6Wn7OtXT/aZP/l955rnqoNDjmnXjoTzEvUScM hwz20HrQP0S6VjAv4Pg97s1KsM0BTsLszAqAmIrFgC6j8dgIl0u3UvFgLNTfTrIAJCs9u20dCu1/4 9iVVZMXI8H6fh9XOf6NCe9OQiRK5Hth7ZKFthwyfxw4N8BJZLq2s+mpkC2flwVF7pzZzk1HBiFmM9 bbqEZ1O1Cpgo5dhMDSOmHqaNzaW7UDQ==; 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 1eKBOv-0002CD-44; Wed, 29 Nov 2017 23:04:21 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKBOq-0001ky-Ic for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 23:04:18 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8B7E060389; Wed, 29 Nov 2017 23:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511996635; bh=H8OmbM4NBnRwaqfXKbDAGIS1/nAcIXT/WJXrG2MyxyY=; h=From:To:Cc:Subject:Date:From; b=WPhlBqfAsN30yTWJyR4ljIrh1bDpNMabGjRJJoG4BhdPD8hhEJ4chehwxgc5tWyii 2xDjdR6d+87ekcvPgdA+lnzTXmYCFxvVTm/VgbK+XFXy4Ab4O281roJOzALIOLehaP p0QCKDczod+B23C6T89/n9sOubCqBoXgQZ/Hg4c0= Received: from sboyd-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B76A76032D; Wed, 29 Nov 2017 23:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511996635; bh=H8OmbM4NBnRwaqfXKbDAGIS1/nAcIXT/WJXrG2MyxyY=; h=From:To:Cc:Subject:Date:From; b=WPhlBqfAsN30yTWJyR4ljIrh1bDpNMabGjRJJoG4BhdPD8hhEJ4chehwxgc5tWyii 2xDjdR6d+87ekcvPgdA+lnzTXmYCFxvVTm/VgbK+XFXy4Ab4O281roJOzALIOLehaP p0QCKDczod+B23C6T89/n9sOubCqBoXgQZ/Hg4c0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B76A76032D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sboyd@codeaurora.org From: Stephen Boyd To: Catalin Marinas , Will Deacon Subject: [PATCH v2] arm64: cpu_errata: Add Kryo to Falkor 1003 errata Date: Wed, 29 Nov 2017 15:03:53 -0800 Message-Id: <20171129230353.11809-1-sboyd@codeaurora.org> X-Mailer: git-send-email 2.15.0.374.g5f9953d2c365 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_150416_702009_247F27E6 X-CRM114-Status: GOOD ( 19.66 ) 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: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 The Kryo CPUs are also affected by the Falkor 1003 errata, so we need to do the same workaround on Kryo CPUs. The MIDR is slightly more complicated here, where the PART number is not always the same when looking at all the bits from 15 to 4. Drop the lower 8 bits and just look at the top 4 to see if it's '2' and then consider those as Kryo CPUs. This covers all the combinations without having to list them all out. Introduce a new hardware cap bit for the combination of hardware PAN support and this errata so that we can disable support for software PAN at runtime if this errata is present and the CPU doesn't support HW PAN. This happens on some Kryo CPUs where the HW PAN feature isn't supported but we can't prevent software PAN from being selected in the configuration. Previously, Falkor CPUs were all known to have HW PAN support, so we didn't need to worry about this case. Fixes: 38fd94b0275c ("arm64: Work around Falkor erratum 1003") Signed-off-by: Stephen Boyd --- Documentation/arm64/silicon-errata.txt | 2 +- arch/arm64/include/asm/asm-uaccess.h | 4 ++-- arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/include/asm/cpufeature.h | 2 +- arch/arm64/include/asm/cputype.h | 2 ++ arch/arm64/kernel/cpu_errata.c | 21 +++++++++++++++++++++ arch/arm64/kernel/cpufeature.c | 17 +++++++++++++++++ arch/arm64/kernel/entry.S | 4 ++-- 8 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt index 66e8ce14d23d..cd7d997063f6 100644 --- a/Documentation/arm64/silicon-errata.txt +++ b/Documentation/arm64/silicon-errata.txt @@ -71,6 +71,6 @@ stable kernels. | Hisilicon | Hip0{5,6,7} | #161010101 | HISILICON_ERRATUM_161010101 | | Hisilicon | Hip0{6,7} | #161010701 | N/A | | | | | | -| Qualcomm Tech. | Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | +| Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | | Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | | Qualcomm Tech. | QDF2400 ITS | E0065 | QCOM_QDF2400_ERRATUM_0065 | diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h index b3da6c886835..35650d1394f4 100644 --- a/arch/arm64/include/asm/asm-uaccess.h +++ b/arch/arm64/include/asm/asm-uaccess.h @@ -26,13 +26,13 @@ .endm .macro uaccess_ttbr0_disable, tmp1 -alternative_if_not ARM64_HAS_PAN +alternative_if_not ARM64_HAS_PAN_OR_FALKOR_E1003 __uaccess_ttbr0_disable \tmp1 alternative_else_nop_endif .endm .macro uaccess_ttbr0_enable, tmp1, tmp2 -alternative_if_not ARM64_HAS_PAN +alternative_if_not ARM64_HAS_PAN_OR_FALKOR_E1003 save_and_disable_irq \tmp2 // avoid preemption __uaccess_ttbr0_enable \tmp1 restore_irq \tmp2 diff --git a/arch/arm64/include/asm/cpucaps.h b/arch/arm64/include/asm/cpucaps.h index 8da621627d7c..c2938408b441 100644 --- a/arch/arm64/include/asm/cpucaps.h +++ b/arch/arm64/include/asm/cpucaps.h @@ -40,7 +40,8 @@ #define ARM64_WORKAROUND_858921 19 #define ARM64_WORKAROUND_CAVIUM_30115 20 #define ARM64_HAS_DCPOP 21 +#define ARM64_HAS_PAN_OR_FALKOR_E1003 22 -#define ARM64_NCAPS 22 +#define ARM64_NCAPS 23 #endif /* __ASM_CPUCAPS_H */ diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 428ee1f2468c..9b2957e4792a 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -259,7 +259,7 @@ static inline bool system_supports_fpsimd(void) static inline bool system_uses_ttbr0_pan(void) { return IS_ENABLED(CONFIG_ARM64_SW_TTBR0_PAN) && - !cpus_have_const_cap(ARM64_HAS_PAN); + !cpus_have_const_cap(ARM64_HAS_PAN_OR_FALKOR_E1003); } #endif /* __ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index 235e77d98261..b5afa6668646 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -91,6 +91,7 @@ #define BRCM_CPU_PART_VULCAN 0x516 #define QCOM_CPU_PART_FALKOR_V1 0x800 +#define QCOM_CPU_PART_KRYO 0x200 #define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53) #define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57) @@ -99,6 +100,7 @@ #define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX) #define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX) #define MIDR_QCOM_FALKOR_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_FALKOR_V1) +#define MIDR_QCOM_KRYO MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO) #ifndef __ASSEMBLY__ diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 0e27f86ee709..e4c78630a730 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -30,6 +30,20 @@ is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) entry->midr_range_max); } +static bool __maybe_unused +is_kryo_midr(const struct arm64_cpu_capabilities *entry, int scope) +{ + u32 model; + + WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); + + model = read_cpuid_id(); + model &= MIDR_IMPLEMENTOR_MASK | (0xf00 << MIDR_PARTNUM_SHIFT) | + MIDR_ARCHITECTURE_MASK; + + return model == entry->midr_model; +} + static bool has_mismatched_cache_line_size(const struct arm64_cpu_capabilities *entry, int scope) @@ -169,6 +183,13 @@ const struct arm64_cpu_capabilities arm64_errata[] = { MIDR_CPU_VAR_REV(0, 0), MIDR_CPU_VAR_REV(0, 0)), }, + { + .desc = "Qualcomm Technologies Kryo erratum 1003", + .capability = ARM64_WORKAROUND_QCOM_FALKOR_E1003, + .def_scope = SCOPE_LOCAL_CPU, + .midr_model = MIDR_QCOM_KRYO, + .matches = is_kryo_midr, + }, #endif #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1009 { diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 21e2c95d24e7..b3a9180294ca 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -100,6 +100,8 @@ EXPORT_SYMBOL(cpu_hwcap_keys); /* meta feature for alternatives */ static bool __maybe_unused cpufeature_pan_not_uao(const struct arm64_cpu_capabilities *entry, int __unused); +static bool __maybe_unused +cpufeature_pan_or_falkor_e1003(const struct arm64_cpu_capabilities *entry, int __unused); /* @@ -860,6 +862,13 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = cpufeature_pan_not_uao, }, #endif /* CONFIG_ARM64_PAN */ +#if defined(CONFIG_QCOM_FALKOR_ERRATUM_1003) || defined(CONFIG_ARM64_PAN) + { + .capability = ARM64_HAS_PAN_OR_FALKOR_E1003, + .def_scope = SCOPE_SYSTEM, + .matches = cpufeature_pan_or_falkor_e1003, + }, +#endif { .desc = "Virtualization Host Extensions", .capability = ARM64_HAS_VIRT_HOST_EXTN, @@ -1211,6 +1220,14 @@ cpufeature_pan_not_uao(const struct arm64_cpu_capabilities *entry, int __unused) return (cpus_have_const_cap(ARM64_HAS_PAN) && !cpus_have_const_cap(ARM64_HAS_UAO)); } +static bool __maybe_unused +cpufeature_pan_or_falkor_e1003(const struct arm64_cpu_capabilities *entry, + int __unused) +{ + return cpus_have_const_cap(ARM64_HAS_PAN) || + cpus_have_const_cap(ARM64_WORKAROUND_QCOM_FALKOR_E1003); +} + /* * We emulate only the following system register space. * Op0 = 0x3, CRn = 0x0, Op1 = 0x0, CRm = [0, 4 - 7] diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index e1c59d4008a8..0e34d5301503 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -179,7 +179,7 @@ * feature as all TTBR0_EL1 accesses are disabled, not just those to * user mappings. */ -alternative_if ARM64_HAS_PAN +alternative_if ARM64_HAS_PAN_OR_FALKOR_E1003 b 1f // skip TTBR0 PAN alternative_else_nop_endif @@ -238,7 +238,7 @@ alternative_else_nop_endif * Restore access to TTBR0_EL1. If returning to EL0, no need for SPSR * PAN bit checking. */ -alternative_if ARM64_HAS_PAN +alternative_if ARM64_HAS_PAN_OR_FALKOR_E1003 b 2f // skip TTBR0 PAN alternative_else_nop_endif