From patchwork Tue Jun 7 16:06:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 69529 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2056663qgf; Tue, 7 Jun 2016 09:08:34 -0700 (PDT) X-Received: by 10.140.157.4 with SMTP id d4mr177301qhd.77.1465315694308; Tue, 07 Jun 2016 09:08:14 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k137si15527729qhc.67.2016.06.07.09.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 09:08:14 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAJWn-0002Yj-1e; Tue, 07 Jun 2016 16:06:53 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAJWm-0002Wc-JL for xen-devel@lists.xen.org; Tue, 07 Jun 2016 16:06:52 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id E9/52-15969-B11F6575; Tue, 07 Jun 2016 16:06:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTVf6Y1i 4wZo3YhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bv+e/MBdONK3ac6WZpYLys1sXIxSEksIFR YnXjJhYI5zSjxLWv39m6GDk52AQ0Je58/sQEYosISEtc+3yZEcRmFmhmlFh4wA/EFhYIkjj34 TcziM0ioCqxbe4xsF5eAReJA61/WUBsCQE5iZPHJrOC2JxA8bYHj8BqhAScJZb+amCcwMi9gJ FhFaNGcWpRWWqRrqGpXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGoIcZgGAH45r tnocYJTmYlER5Pz8LCxfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwVv4DignWJSanlqRlpkDDDWY tAQHj5IIbxZImre4IDG3ODMdInWKUVFKnFcHJCEAksgozYNrg4X3JUZZKWFeRqBDhHgKUotyM 0tQ5V8xinMwKgnzmoFM4cnMK4Gb/gpoMRPQ4mXXgkEWlyQipKQaGJmWX8tNshI6rvbLfMuUHI 4Ki1VZlZ3qnF5BRqfSsxfMk8v6mW7ON/0z6xLBz9JPGNfeOVLyIOtx0eZjR1lCxNWyNs075+V 8JLjWcvrM+OMLp61ZeE0rNXoR2/+X07aY5Fw2FdrJZXsxP6KIWbWd2YNpwR2PLlW/50/+cqwq Pew/f8Ik1c2PvimxFGckGmoxFxUnAgB4CX85agIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1465315610!36677420!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11206 invoked from network); 7 Jun 2016 16:06:50 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-31.messagelabs.com with SMTP; 7 Jun 2016 16:06:50 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E9841F; Tue, 7 Jun 2016 09:07:24 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 66F6B3F21A; Tue, 7 Jun 2016 09:06:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 7 Jun 2016 17:06:21 +0100 Message-Id: <1465315583-1278-15-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465315583-1278-1-git-send-email-julien.grall@arm.com> References: <1465315583-1278-1-git-send-email-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, wei.chen@arm.com, steve.capper@arm.com Subject: [Xen-devel] [PATCH v3 14/16] xen/arm: arm64: Add cortex-A57 erratum 832075 workaround X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The ARM erratum 832075 applies to certain revisions of Cortex-A57, one of the workarounds is to change device loads into using load-acquire semantics. Use the alternative framework to enable the workaround only on affected cores. Whilst a guest could trigger the deadlock, it can be broken when the processor is receiving an interrupt. As the Xen scheduler will always setup a timer (firing to every 1ms to 300ms depending on the running time slice) on each processor, the deadlock would last only few milliseconds and only affects the guest time slice. Therefore a malicious guest could only hurt itself. Note that all the guests should implement/enable the workaround for the affected cores. Signed-off-by: Julien Grall --- Changes in v2: - Update the commit message to explain why it is not necessary to take care of possible deadlock from the guest. --- docs/misc/arm/silicon-errata.txt | 1 + xen/arch/arm/Kconfig | 20 ++++++++++++++++++++ xen/arch/arm/cpuerrata.c | 9 +++++++++ xen/include/asm-arm/arm64/io.h | 21 +++++++++++++++++---- xen/include/asm-arm/cpufeature.h | 3 ++- xen/include/asm-arm/processor.h | 2 ++ 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/docs/misc/arm/silicon-errata.txt b/docs/misc/arm/silicon-errata.txt index fe9f52e..4b2c7c6 100644 --- a/docs/misc/arm/silicon-errata.txt +++ b/docs/misc/arm/silicon-errata.txt @@ -46,3 +46,4 @@ stable hypervisors. | ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 | | ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 | | ARM | Cortex-A57 | #852523 | N/A | +| ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index a473d9c..e26c4c8 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -122,6 +122,26 @@ config ARM64_ERRATUM_819472 the kernel if an affected CPU is detected. If unsure, say Y. + +config ARM64_ERRATUM_832075 + bool "Cortex-A57: 832075: possible deadlock on mixing exclusive memory accesses with device loads" + default y + depends on ARM_64 + help + This option adds an alternative code sequence to work around ARM + erratum 832075 on Cortex-A57 parts up to r1p2. + + Affected Cortex-A57 parts might deadlock when exclusive load/store + instructions to Write-Back memory are mixed with Device loads. + + The workaround is to promote device loads to use Load-Acquire + semantics. + Please note that this does not necessarily enable the workaround, + as it depends on the alternative framework, which will only patch + the kernel if an affected CPU is detected. + + If unsure, say Y. + endmenu source "common/Kconfig" diff --git a/xen/arch/arm/cpuerrata.c b/xen/arch/arm/cpuerrata.c index 211b520..48fc87a 100644 --- a/xen/arch/arm/cpuerrata.c +++ b/xen/arch/arm/cpuerrata.c @@ -34,6 +34,15 @@ static const struct arm_cpu_capabilities arm_errata[] = { MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x01), }, #endif +#ifdef CONFIG_ARM64_ERRATUM_832075 + { + /* Cortex-A57 r0p0 - r1p2 */ + .desc = "ARM erratum 832075", + .capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE, + MIDR_RANGE(MIDR_CORTEX_A57, 0x00, + (1 << MIDR_VARIANT_SHIFT) | 2), + }, +#endif {}, }; diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h index f80156f..30bfc78 100644 --- a/xen/include/asm-arm/arm64/io.h +++ b/xen/include/asm-arm/arm64/io.h @@ -22,6 +22,7 @@ #include #include +#include /* * Generic IO read/write. These perform native-endian accesses. @@ -49,28 +50,40 @@ static inline void __raw_writeq(u64 val, volatile void __iomem *addr) static inline u8 __raw_readb(const volatile void __iomem *addr) { u8 val; - asm volatile("ldrb %w0, [%1]" : "=r" (val) : "r" (addr)); + asm volatile(ALTERNATIVE("ldrb %w0, [%1]", + "ldarb %w0, [%1]", + ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) + : "=r" (val) : "r" (addr)); return val; } static inline u16 __raw_readw(const volatile void __iomem *addr) { u16 val; - asm volatile("ldrh %w0, [%1]" : "=r" (val) : "r" (addr)); + asm volatile(ALTERNATIVE("ldrh %w0, [%1]", + "ldarh %w0, [%1]", + ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) + : "=r" (val) : "r" (addr)); return val; } static inline u32 __raw_readl(const volatile void __iomem *addr) { u32 val; - asm volatile("ldr %w0, [%1]" : "=r" (val) : "r" (addr)); + asm volatile(ALTERNATIVE("ldr %w0, [%1]", + "ldar %w0, [%1]", + ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) + : "=r" (val) : "r" (addr)); return val; } static inline u64 __raw_readq(const volatile void __iomem *addr) { u64 val; - asm volatile("ldr %0, [%1]" : "=r" (val) : "r" (addr)); + asm volatile(ALTERNATIVE("ldr %0, [%1]", + "ldar %0, [%1]", + ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) + : "=r" (val) : "r" (addr)); return val; } diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h index 474a778..78e2263 100644 --- a/xen/include/asm-arm/cpufeature.h +++ b/xen/include/asm-arm/cpufeature.h @@ -36,8 +36,9 @@ #define cpu_has_security (boot_cpu_feature32(security) > 0) #define ARM64_WORKAROUND_CLEAN_CACHE 0 +#define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE 1 -#define ARM_NCAPS 1 +#define ARM_NCAPS 2 #ifndef __ASSEMBLY__ diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h index 5089bfd..1708253 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -47,8 +47,10 @@ #define ARM_CPU_IMP_ARM 0x41 #define ARM_CPU_PART_CORTEX_A53 0xD03 +#define ARM_CPU_PART_CORTEX_A57 0xD07 #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) /* MPIDR Multiprocessor Affinity Register */ #define _MPIDR_UP (30)