Skip to content

Commit 3e32131

Browse files
fj-zhang-leictmarinas
authored andcommitted
arm64: Add workaround for Fujitsu A64FX erratum 010001
On the Fujitsu-A64FX cores ver(1.0, 1.1), memory access may cause an undefined fault (Data abort, DFSC=0b111111). This fault occurs under a specific hardware condition when a load/store instruction performs an address translation. Any load/store instruction, except non-fault access including Armv8 and SVE might cause this undefined fault. The TCR_ELx.NFD1 bit is used by the kernel when CONFIG_RANDOMIZE_BASE is enabled to mitigate timing attacks against KASLR where the kernel address space could be probed using the FFR and suppressed fault on SVE loads. Since this erratum causes spurious exceptions, which may corrupt the exception registers, we clear the TCR_ELx.NFDx=1 bits when booting on an affected CPU. Signed-off-by: Zhang Lei <zhang.lei@jp.fujitsu.com> [Generated MIDR value/mask for __cpu_setup(), removed spurious-fault handler and always disabled the NFDx bits on affected CPUs] Signed-off-by: James Morse <james.morse@arm.com> Tested-by: zhang.lei <zhang.lei@jp.fujitsu.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 4caf875 commit 3e32131

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

Documentation/arm64/silicon-errata.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ stable kernels.
8080
| Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 |
8181
| Qualcomm Tech. | QDF2400 ITS | E0065 | QCOM_QDF2400_ERRATUM_0065 |
8282
| Qualcomm Tech. | Falkor v{1,2} | E1041 | QCOM_FALKOR_ERRATUM_1041 |
83+
| Fujitsu | A64FX | E#010001 | FUJITSU_ERRATUM_010001 |

arch/arm64/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,25 @@ config QCOM_FALKOR_ERRATUM_E1041
643643

644644
If unsure, say Y.
645645

646+
config FUJITSU_ERRATUM_010001
647+
bool "Fujitsu-A64FX erratum E#010001: Undefined fault may occur wrongly"
648+
default y
649+
help
650+
This option adds workaround for Fujitsu-A64FX erratum E#010001.
651+
On some variants of the Fujitsu-A64FX cores ver(1.0, 1.1), memory
652+
accesses may cause undefined fault (Data abort, DFSC=0b111111).
653+
This fault occurs under a specific hardware condition when a
654+
load/store instruction performs an address translation using:
655+
case-1 TTBR0_EL1 with TCR_EL1.NFD0 == 1.
656+
case-2 TTBR0_EL2 with TCR_EL2.NFD0 == 1.
657+
case-3 TTBR1_EL1 with TCR_EL1.NFD1 == 1.
658+
case-4 TTBR1_EL2 with TCR_EL2.NFD1 == 1.
659+
660+
The workaround is to ensure these bits are clear in TCR_ELx.
661+
The workaround only affect the Fujitsu-A64FX.
662+
663+
If unsure, say Y.
664+
646665
endmenu
647666

648667

arch/arm64/include/asm/assembler.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <asm/asm-offsets.h>
2929
#include <asm/cpufeature.h>
30+
#include <asm/cputype.h>
3031
#include <asm/debug-monitors.h>
3132
#include <asm/page.h>
3233
#include <asm/pgtable-hwdef.h>
@@ -596,6 +597,25 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU
596597
#endif
597598
.endm
598599

600+
/*
601+
* tcr_clear_errata_bits - Clear TCR bits that trigger an errata on this CPU.
602+
*/
603+
.macro tcr_clear_errata_bits, tcr, tmp1, tmp2
604+
#ifdef CONFIG_FUJITSU_ERRATUM_010001
605+
mrs \tmp1, midr_el1
606+
607+
mov_q \tmp2, MIDR_FUJITSU_ERRATUM_010001_MASK
608+
and \tmp1, \tmp1, \tmp2
609+
mov_q \tmp2, MIDR_FUJITSU_ERRATUM_010001
610+
cmp \tmp1, \tmp2
611+
b.ne 10f
612+
613+
mov_q \tmp2, TCR_CLEAR_FUJITSU_ERRATUM_010001
614+
bic \tcr, \tcr, \tmp2
615+
10:
616+
#endif /* CONFIG_FUJITSU_ERRATUM_010001 */
617+
.endm
618+
599619
/**
600620
* Errata workaround prior to disable MMU. Insert an ISB immediately prior
601621
* to executing the MSR that will change SCTLR_ELn[M] from a value of 1 to 0.

arch/arm64/include/asm/cputype.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define ARM_CPU_IMP_BRCM 0x42
7777
#define ARM_CPU_IMP_QCOM 0x51
7878
#define ARM_CPU_IMP_NVIDIA 0x4E
79+
#define ARM_CPU_IMP_FUJITSU 0x46
7980

8081
#define ARM_CPU_PART_AEM_V8 0xD0F
8182
#define ARM_CPU_PART_FOUNDATION 0xD00
@@ -104,6 +105,8 @@
104105
#define NVIDIA_CPU_PART_DENVER 0x003
105106
#define NVIDIA_CPU_PART_CARMEL 0x004
106107

108+
#define FUJITSU_CPU_PART_A64FX 0x001
109+
107110
#define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)
108111
#define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57)
109112
#define MIDR_CORTEX_A72 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72)
@@ -122,6 +125,12 @@
122125
#define MIDR_QCOM_KRYO MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO)
123126
#define MIDR_NVIDIA_DENVER MIDR_CPU_MODEL(ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_DENVER)
124127
#define MIDR_NVIDIA_CARMEL MIDR_CPU_MODEL(ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_CARMEL)
128+
#define MIDR_FUJITSU_A64FX MIDR_CPU_MODEL(ARM_CPU_IMP_FUJITSU, FUJITSU_CPU_PART_A64FX)
129+
130+
/* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */
131+
#define MIDR_FUJITSU_ERRATUM_010001 MIDR_FUJITSU_A64FX
132+
#define MIDR_FUJITSU_ERRATUM_010001_MASK (~MIDR_VARIANT(1))
133+
#define TCR_CLEAR_FUJITSU_ERRATUM_010001 (TCR_NFD1 | TCR_NFD0)
125134

126135
#ifndef __ASSEMBLY__
127136

arch/arm64/include/asm/pgtable-hwdef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
#define TCR_TBI1 (UL(1) << 38)
303303
#define TCR_HA (UL(1) << 39)
304304
#define TCR_HD (UL(1) << 40)
305+
#define TCR_NFD0 (UL(1) << 53)
305306
#define TCR_NFD1 (UL(1) << 54)
306307

307308
/*

arch/arm64/mm/proc.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ ENTRY(__cpu_setup)
445445
ldr x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \
446446
TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \
447447
TCR_TBI0 | TCR_A1 | TCR_KASAN_FLAGS
448+
tcr_clear_errata_bits x10, x9, x5
448449

449450
#ifdef CONFIG_ARM64_USER_VA_BITS_52
450451
ldr_l x9, vabits_user

0 commit comments

Comments
 (0)