Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1909272imm; Thu, 24 May 2018 02:45:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrz8a4zvugtVA7QMEgrun0mnIZ9SfRxenC0JZyqQK0cg/ECeQHF0taArhYonMr/iZzvq8db X-Received: by 2002:a17:902:7d09:: with SMTP id z9-v6mr6725242pll.4.1527155135825; Thu, 24 May 2018 02:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155135; cv=none; d=google.com; s=arc-20160816; b=tQo9UsirniKhFmR3EGgevfTZubmV5ao+Jyzu1noBtPo+ns5RLCCj3iWb90OF+8kcAO Ii9C+jWTxtcfjXB8YMqULbuSck/urivOe+lxbepm+1jJdZf1dl6h+Kaj54igCBzXsy9M Z09sfKzZUZUO5pk2+Il7eXIJJLEfG00DVOWc36nP1CLZIXgWd9oVZ++92KyKUj4QI8UA 0F83gH7BokxC+PrYlknoae8TsCYiRPfKUQBjk+GaFU5wKAYJo0FggJnG3gyRA6w3OUDP yknPeIE+1PkwTLBgpPn5Ra5PS2ASRH9umjLX/1+1ubG1sMj7ePGvIExyPtQwQP8evfki 49bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=JVqHVSStl05rRMf4wy47ad6sqlqichJCXdEePG8PY3w=; b=xio8o/JI4MYeIQMHGP3EpKpCVUCJe+0MUfucyWG4KvTJdpf6hseO7PHDchfaameJ9F 4q36GSoxJnq0AUbx1vW7coXgLNFXbS1ALiPnHg56+ujtBP/39AxoWHluHfD3YwiK7E3G m4UdaXSKd2XJBhDJEg0JqlJPJedmgxK2j2ClAhIansUxHYcV+Q5EsRHx62om66Dh0B3P YzsH1uQuNsfX1EZ9gsMeGoR+IvDNBbQcVfGF+XYbxSJ+a/NXV5+0flnnvf635CP19xI6 ifiMSWhx0nn2YHD0c+IEwiYRAQg9Y4w8Zw0KSFraajrNx/dXprmhg1vaFNqStQzr8nAH YTxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Np8e6OdZ; 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 l125-v6si10129300pgl.410.2018.05.24.02.45.21; Thu, 24 May 2018 02:45:35 -0700 (PDT) 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=@kernel.org header.s=default header.b=Np8e6OdZ; 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 S966512AbeEXJni (ORCPT + 99 others); Thu, 24 May 2018 05:43:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966470AbeEXJnc (ORCPT ); Thu, 24 May 2018 05:43:32 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75D7B208B9; Thu, 24 May 2018 09:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155011; bh=SmAkS8CmO8BNdumfuv3cgugl3mjm8BkSbCKoGlc/c/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Np8e6OdZoYHh9STv+b5mjNfv1Xv9I2VQ4HJNm/unv/Mlgrv3WX2H8kUgLDe3o4tNZ whO+hg/g5TIKSJgt7hjL7jhBNF3UnkD2CoEE0wiGV7S5rBra+Wqo747MFCz+yEXfUL iRStV2+BXw8HS60Uo2TtSIov3BAgm8XSFd8+lxBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , ckadabi@codeaurora.org, Dave Martin , Suzuki K Poulose , Will Deacon Subject: [PATCH 4.4 23/92] arm64: Add work around for Arm Cortex-A55 Erratum 1024718 Date: Thu, 24 May 2018 11:38:00 +0200 Message-Id: <20180524093201.194544645@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Suzuki K Poulose commit ece1397cbc89c51914fae1aec729539cfd8bd62b upstream. Some variants of the Arm Cortex-55 cores (r0p0, r0p1, r1p0) suffer from an erratum 1024718, which causes incorrect updates when DBM/AP bits in a page table entry is modified without a break-before-make sequence. The work around is to skip enabling the hardware DBM feature on the affected cores. The hardware Access Flag management features is not affected. There are some other cores suffering from this errata, which could be added to the midr_list to trigger the work around. Cc: Catalin Marinas Cc: ckadabi@codeaurora.org Reviewed-by: Dave Martin Signed-off-by: Suzuki K Poulose Signed-off-by: Will Deacon Signed-off-by: Suzuki K Poulose Signed-off-by: Greg Kroah-Hartman --- arch/arm64/Kconfig | 14 ++++++++++++ arch/arm64/include/asm/assembler.h | 40 +++++++++++++++++++++++++++++++++++++ arch/arm64/include/asm/cputype.h | 11 ++++++++++ arch/arm64/mm/proc.S | 5 ++++ 4 files changed, 70 insertions(+) --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -375,6 +375,20 @@ config ARM64_ERRATUM_843419 If unsure, say Y. +config ARM64_ERRATUM_1024718 + bool "Cortex-A55: 1024718: Update of DBM/AP bits without break before make might result in incorrect update" + default y + help + This option adds work around for Arm Cortex-A55 Erratum 1024718. + + Affected Cortex-A55 cores (r0p0, r0p1, r1p0) could cause incorrect + update of the hardware dirty bit when the DBM/AP bits are updated + without a break-before-make. The work around is to disable the usage + of hardware DBM locally on the affected cores. CPUs not affected by + erratum will continue to use the feature. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -23,6 +23,7 @@ #ifndef __ASM_ASSEMBLER_H #define __ASM_ASSEMBLER_H +#include #include #include @@ -224,4 +225,43 @@ lr .req x30 // link register movk \reg, :abs_g0_nc:\val .endm +/* + * Check the MIDR_EL1 of the current CPU for a given model and a range of + * variant/revision. See asm/cputype.h for the macros used below. + * + * model: MIDR_CPU_PART of CPU + * rv_min: Minimum of MIDR_CPU_VAR_REV() + * rv_max: Maximum of MIDR_CPU_VAR_REV() + * res: Result register. + * tmp1, tmp2, tmp3: Temporary registers + * + * Corrupts: res, tmp1, tmp2, tmp3 + * Returns: 0, if the CPU id doesn't match. Non-zero otherwise + */ + .macro cpu_midr_match model, rv_min, rv_max, res, tmp1, tmp2, tmp3 + mrs \res, midr_el1 + mov_q \tmp1, (MIDR_REVISION_MASK | MIDR_VARIANT_MASK) + mov_q \tmp2, MIDR_CPU_PART_MASK + and \tmp3, \res, \tmp2 // Extract model + and \tmp1, \res, \tmp1 // rev & variant + mov_q \tmp2, \model + cmp \tmp3, \tmp2 + cset \res, eq + cbz \res, .Ldone\@ // Model matches ? + + .if (\rv_min != 0) // Skip min check if rv_min == 0 + mov_q \tmp3, \rv_min + cmp \tmp1, \tmp3 + cset \res, ge + .endif // \rv_min != 0 + /* Skip rv_max check if rv_min == rv_max && rv_min != 0 */ + .if ((\rv_min != \rv_max) || \rv_min == 0) + mov_q \tmp2, \rv_max + cmp \tmp1, \tmp2 + cset \tmp2, le + and \res, \res, \tmp2 + .endif +.Ldone\@: + .endm + #endif /* __ASM_ASSEMBLER_H */ --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -57,6 +57,14 @@ #define MIDR_IMPLEMENTOR(midr) \ (((midr) & MIDR_IMPLEMENTOR_MASK) >> MIDR_IMPLEMENTOR_SHIFT) +#define MIDR_CPU_VAR_REV(var, rev) \ + (((var) << MIDR_VARIANT_SHIFT) | (rev)) + +#define MIDR_CPU_PART_MASK \ + (MIDR_IMPLEMENTOR_MASK | \ + MIDR_ARCHITECTURE_MASK | \ + MIDR_PARTNUM_MASK) + #define MIDR_CPU_PART(imp, partnum) \ (((imp) << MIDR_IMPLEMENTOR_SHIFT) | \ (0xf << MIDR_ARCHITECTURE_SHIFT) | \ @@ -70,11 +78,14 @@ #define ARM_CPU_PART_FOUNDATION 0xD00 #define ARM_CPU_PART_CORTEX_A57 0xD07 #define ARM_CPU_PART_CORTEX_A53 0xD03 +#define ARM_CPU_PART_CORTEX_A55 0xD05 #define APM_CPU_PART_POTENZA 0x000 #define CAVIUM_CPU_PART_THUNDERX 0x0A1 +#define MIDR_CORTEX_A55 MIDR_CPU_PART(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A55) + #ifndef __ASSEMBLY__ /* --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -221,6 +221,11 @@ ENTRY(__cpu_setup) cbz x9, 2f cmp x9, #2 b.lt 1f +#ifdef CONFIG_ARM64_ERRATUM_1024718 + /* Disable hardware DBM on Cortex-A55 r0p0, r0p1 & r1p0 */ + cpu_midr_match MIDR_CORTEX_A55, MIDR_CPU_VAR_REV(0, 0), MIDR_CPU_VAR_REV(1, 0), x1, x2, x3, x4 + cbnz x1, 1f +#endif orr x10, x10, #TCR_HD // hardware Dirty flag update 1: orr x10, x10, #TCR_HA // hardware Access flag update 2: