Skip to content

Commit e51ce83

Browse files
Andre-ARMsashalevin
authored andcommitted
arm64: add Cortex-A57 erratum 832075 workaround
The ARM erratum 832075 applies to certain revisions of Cortex-A57, one of the workarounds is to change device loads into using load-aquire semantics. This is achieved using the alternatives framework. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Cc: <stable@vger.kernel.org> # v3.18.y (cherry picked from commit 5afaa1f) Signed-off-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 4d817d3 commit e51ce83

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

‎arch/arm64/include/asm/cpufeature.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
#define MAX_CPU_FEATURES (8 * sizeof(elf_hwcap))
2222
#define cpu_feature(x) ilog2(HWCAP_ ## x)
2323

24-
#define ARM64_WORKAROUND_CLEAN_CACHE 0
24+
#define ARM64_WORKAROUND_CLEAN_CACHE 0
25+
#define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE 1
2526

26-
#define NCAPS 1
27+
#define NCAPS 2
2728

2829
#ifndef __ASSEMBLY__
2930

‎arch/arm64/include/asm/io.h‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <asm/barrier.h>
2929
#include <asm/pgtable.h>
3030
#include <asm/early_ioremap.h>
31+
#include <asm/alternative.h>
32+
#include <asm/cpufeature.h>
3133

3234
#include <xen/xen.h>
3335

@@ -57,28 +59,41 @@ static inline void __raw_writeq(u64 val, volatile void __iomem *addr)
5759
static inline u8 __raw_readb(const volatile void __iomem *addr)
5860
{
5961
u8 val;
60-
asm volatile("ldrb %w0, [%1]" : "=r" (val) : "r" (addr));
62+
asm volatile(ALTERNATIVE("ldrb %w0, [%1]",
63+
"ldarb %w0, [%1]",
64+
ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE)
65+
: "=r" (val) : "r" (addr));
6166
return val;
6267
}
6368

6469
static inline u16 __raw_readw(const volatile void __iomem *addr)
6570
{
6671
u16 val;
67-
asm volatile("ldrh %w0, [%1]" : "=r" (val) : "r" (addr));
72+
73+
asm volatile(ALTERNATIVE("ldrh %w0, [%1]",
74+
"ldarh %w0, [%1]",
75+
ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE)
76+
: "=r" (val) : "r" (addr));
6877
return val;
6978
}
7079

7180
static inline u32 __raw_readl(const volatile void __iomem *addr)
7281
{
7382
u32 val;
74-
asm volatile("ldr %w0, [%1]" : "=r" (val) : "r" (addr));
83+
asm volatile(ALTERNATIVE("ldr %w0, [%1]",
84+
"ldar %w0, [%1]",
85+
ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE)
86+
: "=r" (val) : "r" (addr));
7587
return val;
7688
}
7789

7890
static inline u64 __raw_readq(const volatile void __iomem *addr)
7991
{
8092
u64 val;
81-
asm volatile("ldr %0, [%1]" : "=r" (val) : "r" (addr));
93+
asm volatile(ALTERNATIVE("ldr %0, [%1]",
94+
"ldar %0, [%1]",
95+
ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE)
96+
: "=r" (val) : "r" (addr));
8297
return val;
8398
}
8499

‎arch/arm64/kernel/cpu_errata.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <asm/cpufeature.h>
2525

2626
#define MIDR_CORTEX_A53 MIDR_CPU_PART(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)
27+
#define MIDR_CORTEX_A57 MIDR_CPU_PART(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57)
2728

2829
/*
2930
* Add a struct or another datatype to the union below if you need
@@ -71,6 +72,12 @@ struct arm64_cpu_capabilities arm64_errata[] = {
7172
MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x02),
7273
},
7374
{
75+
/* Cortex-A57 r0p0 - r1p2 */
76+
.desc = "ARM erratum 832075",
77+
.capability = ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE,
78+
MIDR_RANGE(MIDR_CORTEX_A57, 0x00, 0x12),
79+
},
80+
{
7481
}
7582
};
7683

0 commit comments

Comments
 (0)