diff options
author | Andre Przywara <andre.przywara@arm.com> | 2014-11-14 10:54:10 -0500 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2014-11-25 10:56:21 -0500 |
commit | 301bcfac42897dbd1b0b3c1be49f24654a1bc49e (patch) | |
tree | bd42ce2fcf06bc99fb2b553969cdc2dba3cb1c0b /arch/arm64/kernel | |
parent | e116a375423393cdb94714e90a96857005d58428 (diff) |
arm64: add Cortex-A53 cache errata workaround
The ARM errata 819472, 826319, 827319 and 824069 define the same
workaround for these hardware issues in certain Cortex-A53 parts.
Use the new alternatives framework and the CPU MIDR detection to
patch "cache clean" into "cache clean and invalidate" instructions if
an affected CPU is detected at runtime.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
[will: add __maybe_unused to squash gcc warning]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel')
-rw-r--r-- | arch/arm64/kernel/cpu_errata.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 9332cf7c0826..e107ed2d66dc 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <asm/cputype.h> | 23 | #include <asm/cputype.h> |
24 | #include <asm/cpufeature.h> | 24 | #include <asm/cpufeature.h> |
25 | 25 | ||
26 | #define MIDR_CORTEX_A53 MIDR_CPU_PART(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53) | ||
27 | |||
26 | /* | 28 | /* |
27 | * Add a struct or another datatype to the union below if you need | 29 | * Add a struct or another datatype to the union below if you need |
28 | * different means to detect an affected CPU. | 30 | * different means to detect an affected CPU. |
@@ -39,8 +41,37 @@ struct arm64_cpu_capabilities { | |||
39 | }; | 41 | }; |
40 | }; | 42 | }; |
41 | 43 | ||
44 | #define CPU_MODEL_MASK (MIDR_IMPLEMENTOR_MASK | MIDR_PARTNUM_MASK | \ | ||
45 | MIDR_ARCHITECTURE_MASK) | ||
46 | |||
47 | static bool __maybe_unused | ||
48 | is_affected_midr_range(struct arm64_cpu_capabilities *entry) | ||
49 | { | ||
50 | u32 midr = read_cpuid_id(); | ||
51 | |||
52 | if ((midr & CPU_MODEL_MASK) != entry->midr_model) | ||
53 | return false; | ||
54 | |||
55 | midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK; | ||
56 | |||
57 | return (midr >= entry->midr_range_min && midr <= entry->midr_range_max); | ||
58 | } | ||
59 | |||
60 | #define MIDR_RANGE(model, min, max) \ | ||
61 | .is_affected = is_affected_midr_range, \ | ||
62 | .midr_model = model, \ | ||
63 | .midr_range_min = min, \ | ||
64 | .midr_range_max = max | ||
65 | |||
42 | struct arm64_cpu_capabilities arm64_errata[] = { | 66 | struct arm64_cpu_capabilities arm64_errata[] = { |
43 | {} | 67 | { |
68 | /* Cortex-A53 r0p[012] */ | ||
69 | .desc = "ARM errata 826319, 827319, 824069", | ||
70 | .capability = ARM64_WORKAROUND_CLEAN_CACHE, | ||
71 | MIDR_RANGE(MIDR_CORTEX_A53, 0x00, 0x02), | ||
72 | }, | ||
73 | { | ||
74 | } | ||
44 | }; | 75 | }; |
45 | 76 | ||
46 | void check_local_cpu_errata(void) | 77 | void check_local_cpu_errata(void) |