Received: by 10.223.164.202 with SMTP id h10csp4959394wrb; Wed, 29 Nov 2017 15:04:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMY6KDvY0d3K2bJnOv7NrrLlwxhFRqp4Lvq+0nnAGHTu4lLyfX/O1/GFNRq2hWTBXaTzYbay X-Received: by 10.159.204.146 with SMTP id t18mr456407plo.83.1511996667142; Wed, 29 Nov 2017 15:04:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511996667; cv=none; d=google.com; s=arc-20160816; b=I5iLIdhcqS15OdbOStJZBEXYIf4Lx5xlZnwvBI0Eui6fiY03MDIw36vhxZyn3YFxD7 wwstcACe2eCRh9RCl0NdwRWcT0RjK9Jb53ptbMrHWC31450ANIF/RiV2U58YM71pRl2j PkLq5zlcchu5f7V/rpjmMi4dsoXAmG2PYrwAGWscKxpGDA7oz7R2NTyArv0r28VjzC3F sRvLsf3JU/yDek5ing+wffm8MBIq6akgk/OAp3tN39ZNJzwWW0qXc93YrEfP4/CQwCCN ojEo+GHtUq2PXrELyiRaupldA/Wgkr65VhCI6tM0ehgRpAYl/LKFPbptaUpvlPNKKWHU 1whg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=Qe00ScaDXAhwPUPwUDHdePH9lMey2k4IlZXA/cBSAwI=; b=nsRYxUH9OiU3fQ+/snl87+zKSJdw8w7iZIgmwYdUYzi52wZV4GxnG00k+lc3Cq45qy vY7bqNm+cgPAdODpKy8ovoazBmXZzvFFNDmOkTldcy8qWzJWapZcaaJXHP5GyC2ysl/V oH+H2HFbGwcERdv4wpVlSm7G8abX0IWBwIt97f5ma1N1fczoP9/SF8t86rAxAM0nX2MR 39H7VNfSvFpet1XuzUIo8WJN2LGNubcbZegcYrovEIi7qJ/f4pF9a+1QuKP5GYLmChyD YRATEzBqtD/pAATwT45waPPKr1l5sErLzkwcZ2eLQ94Ydt1NS4gu42fMXQGDfNMowNhf /faQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=ZqI0IY9L; dkim=pass header.i=@codeaurora.org header.s=default header.b=WPhlBqfA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si2097754pfw.216.2017.11.29.15.04.11; Wed, 29 Nov 2017 15:04:27 -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=@codeaurora.org header.s=default header.b=ZqI0IY9L; dkim=pass header.i=@codeaurora.org header.s=default header.b=WPhlBqfA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbdK2XD6 (ORCPT + 99 others); Wed, 29 Nov 2017 18:03:58 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:39096 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbdK2XD4 (ORCPT ); Wed, 29 Nov 2017 18:03:56 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F1A0660718; 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=1511996636; bh=H8OmbM4NBnRwaqfXKbDAGIS1/nAcIXT/WJXrG2MyxyY=; h=From:To:Cc:Subject:Date:From; b=ZqI0IY9L6AfEl/k8MccpzIx3ZVfhn0swlkj5Do+MV+MUBOqAWrxxeLcQ7pSQewe+D zUb5N/A8X/1iMXJB9TR/XhW7fCnzAPrX0rCF+0vLHRG+/pGhbHOuXToliNJ3wsVOJo CWVbMrLT7jpK1+YiKxK7eMVETDu75JDNrRmpIJAU= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project From 1586330797307258293@xxx Sat Dec 09 18:08:58 +0000 2017 X-GM-THRID: 1586330541376420692 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread