arm64: errata: Remove AES hwcap for COMPAT tasks
Subsystems (2)
PATCH 1/1 arm64: errata: Remove AES hwcap for COMPAT tasks
From: James Morse <[email protected]>
commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream
Cortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
--- Documentation/arm64/silicon-errata.txt | 2 ++ arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 16 ++++++++++++++++ arch/arm64/kernel/cpufeature.c | 13 ++++++++++++- 5 files changed, 48 insertions(+), 2 deletions(-)
Documentation/arm64/silicon-errata.txt +2 -0
@@ -53,7 +53,9 @@ stable kernels. | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | | ARM | Cortex-A57 | #852523 | N/A | | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | +| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 | | ARM | Cortex-A72 | #853709 | N/A | +| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 | | ARM | Cortex-A55 | #1024718 | ARM64_ERRATUM_1024718 | | ARM | Cortex-A76 | #1188873 | ARM64_ERRATUM_1188873 | | ARM | MMU-500 | #841119,#826419 | N/A |
arch/arm64/Kconfig +16 -0
@@ -455,6 +455,22 @@ config ARM64_ERRATUM_1188873 If unsure, say Y. +config ARM64_ERRATUM_1742098 + bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" + depends on COMPAT + default y + help + This option removes the AES hwcap for aarch32 user-space to + workaround erratum 1742098 on Cortex-A57 and Cortex-A72. + + Affected parts may corrupt the AES state if an interrupt is + taken between a pair of AES instructions. These instructions + are only present if the cryptography extensions are present. + All software should have a fallback implementation for CPUs + that don't implement the cryptography extensions. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -40,7 +40,8 @@#define ARM64_MISMATCHED_CACHE_TYPE 19#define ARM64_WORKAROUND_1188873 20#define ARM64_SPECTRE_BHB 21 +#define ARM64_WORKAROUND_1742098 22 -#define ARM64_NCAPS 22 +#define ARM64_NCAPS 23#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +16 -0
@@ -448,6 +448,14 @@ static const struct midr_range arm64_bp_harden_smccc_cpus[] = {#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 +static struct midr_range broken_aarch32_aes[] = { +MIDR_RANGE (MIDR_CORTEX_A57 ,0 ,1 ,0xf ,0xf ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A72 ), + {}, +}; +#endif + const struct arm64_cpu_capabilities arm64_errata[] = { #if defined(CONFIG_ARM64_ERRATUM_826319) || \ defined(CONFIG_ARM64_ERRATUM_827319) || \
@@ -567,6 +575,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .cpu_enable = spectre_bhb_enable_mitigation,#endif }, +#ifdef CONFIG_ARM64_ERRATUM_1742098 + { + .desc = "ARM erratum 1742098", + .capability = ARM64_WORKAROUND_1742098, + CAP_MIDR_RANGE_LIST(broken_aarch32_aes), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + }, +#endif { } };
arch/arm64/kernel/cpufeature.c +12 -1
@@ -28,6 +28,7 @@#include <asm/cpu.h> #include <asm/cpufeature.h> #include <asm/cpu_ops.h> +#include <asm/hwcap.h> #include <asm/mmu_context.h> #include <asm/processor.h> #include <asm/sysreg.h>
@@ -885,6 +886,14 @@ static void cpu_copy_el2regs(const struct arm64_cpu_capabilities *__unused)write_sysreg (read_sysreg (tpidr_el1), tpidr_el2); } +static void elf_hwcap_fixup (void ) +{ +#ifdef CONFIG_ARM64_ERRATUM_1742098 +if (cpus_have_const_cap (ARM64_WORKAROUND_1742098 )) + compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES ; +#endif /* ARM64_ERRATUM_1742098 */ +} +static const struct arm64_cpu_capabilities arm64_features[] = { { .desc ="GIC system register CPU interface" ,
@@ -1304,8 +1313,10 @@ void __init setup_cpu_features(void)mark_const_caps_ready ();setup_elf_hwcaps (arm64_elf_hwcaps); -if (system_supports_32bit_el0 ()) +if (system_supports_32bit_el0 ()) {setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup (); + }/* Advertise that we have computed the system capabilities */ set_sys_caps_initialised ();
Signature · 1 line
2.25.1
PATCH 1/1 arm64: errata: Remove AES hwcap for COMPAT tasks
From: James Morse <[email protected]>
commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream
Cortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
--- Documentation/arm64/silicon-errata.txt | 2 ++ arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 16 ++++++++++++++++ arch/arm64/kernel/cpufeature.c | 13 ++++++++++++- 5 files changed, 48 insertions(+), 2 deletions(-)
Documentation/arm64/silicon-errata.txt +2 -0
@@ -53,7 +53,9 @@ stable kernels. | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | | ARM | Cortex-A57 | #852523 | N/A | | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | +| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 | | ARM | Cortex-A72 | #853709 | N/A | +| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 | | ARM | Cortex-A73 | #858921 | ARM64_ERRATUM_858921 | | ARM | Cortex-A55 | #1024718 | ARM64_ERRATUM_1024718 | | ARM | Cortex-A76 | #1188873 | ARM64_ERRATUM_1188873 |
arch/arm64/Kconfig +16 -0
@@ -472,6 +472,22 @@ config ARM64_ERRATUM_1188873 If unsure, say Y. +config ARM64_ERRATUM_1742098 + bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" + depends on COMPAT + default y + help + This option removes the AES hwcap for aarch32 user-space to + workaround erratum 1742098 on Cortex-A57 and Cortex-A72. + + Affected parts may corrupt the AES state if an interrupt is + taken between a pair of AES instructions. These instructions + are only present if the cryptography extensions are present. + All software should have a fallback implementation for CPUs + that don't implement the cryptography extensions. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -47,7 +47,8 @@#define ARM64_SSBS 27#define ARM64_WORKAROUND_1188873 28#define ARM64_SPECTRE_BHB 29 +#define ARM64_WORKAROUND_1742098 30 -#define ARM64_NCAPS 30 +#define ARM64_NCAPS 31#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +16 -0
@@ -576,6 +576,14 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope)return (need_wa >0 ); } +#ifdef CONFIG_ARM64_ERRATUM_1742098 +static struct midr_range broken_aarch32_aes[] = { +MIDR_RANGE (MIDR_CORTEX_A57 ,0 ,1 ,0xf ,0xf ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A72 ), + {}, +}; +#endif + const struct arm64_cpu_capabilities arm64_errata[] = { #if defined(CONFIG_ARM64_ERRATUM_826319) || \ defined(CONFIG_ARM64_ERRATUM_827319) || \
@@ -741,6 +749,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .matches = is_spectre_bhb_affected, .cpu_enable = spectre_bhb_enable_mitigation, }, +#ifdef CONFIG_ARM64_ERRATUM_1742098 + { + .desc = "ARM erratum 1742098", + .capability = ARM64_WORKAROUND_1742098, + CAP_MIDR_RANGE_LIST(broken_aarch32_aes), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + }, +#endif { } };
arch/arm64/kernel/cpufeature.c +12 -1
@@ -30,6 +30,7 @@#include <asm/cpu.h> #include <asm/cpufeature.h> #include <asm/cpu_ops.h> +#include <asm/hwcap.h> #include <asm/mmu_context.h> #include <asm/processor.h> #include <asm/sysreg.h>
@@ -1010,6 +1011,14 @@ static void cpu_enable_ssbs(const struct arm64_cpu_capabilities *__unused) }#endif /* CONFIG_ARM64_SSBD */ +static void elf_hwcap_fixup (void ) +{ +#ifdef CONFIG_ARM64_ERRATUM_1742098 +if (cpus_have_const_cap (ARM64_WORKAROUND_1742098 )) + compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES ; +#endif /* ARM64_ERRATUM_1742098 */ +} +static const struct arm64_cpu_capabilities arm64_features[] = { { .desc ="GIC system register CPU interface" ,
@@ -1588,8 +1597,10 @@ void __init setup_cpu_features(void)mark_const_caps_ready ();setup_elf_hwcaps (arm64_elf_hwcaps); -if (system_supports_32bit_el0 ()) +if (system_supports_32bit_el0 ()) {setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup (); + }/* Advertise that we have computed the system capabilities */ set_sys_caps_initialised ();
Signature · 1 line
2.25.1
PATCH 1/1 arm64: errata: Remove AES hwcap for COMPAT tasks
In reply to Florian FainelliFrom: James Morse <[email protected]>
commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream
Cortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
--- Documentation/arm64/silicon-errata.txt | 2 ++ arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 17 +++++++++++++++++ arch/arm64/kernel/cpufeature.c | 13 ++++++++++++- 5 files changed, 49 insertions(+), 2 deletions(-)
Documentation/arm64/silicon-errata.txt +2 -0
@@ -55,7 +55,9 @@ stable kernels. | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | | ARM | Cortex-A57 | #852523 | N/A | | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | +| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 | | ARM | Cortex-A72 | #853709 | N/A | +| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 | | ARM | Cortex-A73 | #858921 | ARM64_ERRATUM_858921 | | ARM | Cortex-A55 | #1024718 | ARM64_ERRATUM_1024718 | | ARM | Cortex-A76 | #1463225 | ARM64_ERRATUM_1463225 |
arch/arm64/Kconfig +16 -0
@@ -515,6 +515,22 @@ config ARM64_ERRATUM_1542419 If unsure, say Y. +config ARM64_ERRATUM_1742098 + bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" + depends on COMPAT + default y + help + This option removes the AES hwcap for aarch32 user-space to + workaround erratum 1742098 on Cortex-A57 and Cortex-A72. + + Affected parts may corrupt the AES state if an interrupt is + taken between a pair of AES instructions. These instructions + are only present if the cryptography extensions are present. + All software should have a fallback implementation for CPUs + that don't implement the cryptography extensions. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -55,7 +55,8 @@#define ARM64_SSBS 34#define ARM64_WORKAROUND_1542419 35#define ARM64_SPECTRE_BHB 36 +#define ARM64_WORKAROUND_1742098 37 -#define ARM64_NCAPS 37 +#define ARM64_NCAPS 38#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +17 -0
@@ -683,6 +683,15 @@ static const struct midr_range arm64_harden_el2_vectors[] = {#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 +static struct midr_range broken_aarch32_aes[] = { +MIDR_RANGE (MIDR_CORTEX_A57 ,0 ,1 ,0xf ,0xf ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A72 ), + {}, +}; +#endif + + const struct arm64_cpu_capabilities arm64_errata[] = { #if defined(CONFIG_ARM64_ERRATUM_826319) || \ defined(CONFIG_ARM64_ERRATUM_827319) || \
@@ -883,6 +892,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .matches = has_neoverse_n1_erratum_1542419, .cpu_enable = cpu_enable_trap_ctr_access, }, +#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 + { + .desc = "ARM erratum 1742098", + .capability = ARM64_WORKAROUND_1742098, + CAP_MIDR_RANGE_LIST(broken_aarch32_aes), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + }, #endif { }
arch/arm64/kernel/cpufeature.c +12 -1
@@ -31,6 +31,7 @@#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/fpsimd.h> +#include <asm/hwcap.h> #include <asm/mmu_context.h> #include <asm/processor.h> #include <asm/sysreg.h>
@@ -1154,6 +1155,14 @@ static void cpu_enable_ssbs(const struct arm64_cpu_capabilities *__unused) }#endif /* CONFIG_ARM64_SSBD */ +static void elf_hwcap_fixup (void ) +{ +#ifdef CONFIG_ARM64_ERRATUM_1742098 +if (cpus_have_const_cap (ARM64_WORKAROUND_1742098 )) + compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES ; +#endif /* ARM64_ERRATUM_1742098 */ +} +static const struct arm64_cpu_capabilities arm64_features[] = { { .desc ="GIC system register CPU interface" ,
@@ -1802,8 +1811,10 @@ void __init setup_cpu_features(void)mark_const_caps_ready ();setup_elf_hwcaps (arm64_elf_hwcaps); -if (system_supports_32bit_el0 ()) +if (system_supports_32bit_el0 ()) {setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup (); + }if (system_uses_ttbr0_pan ())pr_info ("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerQuoted 16 lines · Florian Fainelli
From: James Morse <[email protected]>
commit
44b3834b2eed595af07021b1c64e6f9bc396398bupstreamCortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
Quoted 7 lines
Acked-by Ard Biesheuvel <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Will Deacon <[email protected]>[florian: resolved conflicts in arch/arm64/tools/cpucaps and cpu_errata.c]Signed-off-by Florian Fainelli <[email protected]>Change-Id I651a0db2e9d2f304d210ae979ae586e7dcc9744d
No need for Change-Id: in upstream patches :)
Quoted 25 lines · Greg Kroah-Hartman
Quoted 16 lines · Florian Fainelli
From: James Morse <[email protected]>
commit
44b3834b2eed595af07021b1c64e6f9bc396398bupstreamCortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
Quoted 7 lines
Acked-by Ard Biesheuvel <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Will Deacon <[email protected]>[florian: resolved conflicts in arch/arm64/tools/cpucaps and cpu_errata.c]Signed-off-by Florian Fainelli <[email protected]>Change-Id I651a0db2e9d2f304d210ae979ae586e7dcc9744d
Quoted 1 line
No need for Change-Id: in upstream patches :)
Meh, the perils of working with Gerrit in the same tree.. do you need me to resubmit or can you strip those when you apply the patches?
Signature · 1 line
Florian
Greg Kroah-Hartman
maintainerQuoted 28 lines · Florian Fainelli
Quoted 25 lines · Greg Kroah-Hartman
Quoted 23 lines · Florian Fainelli
From: James Morse <[email protected]>
commit
44b3834b2eed595af07021b1c64e6f9bc396398bupstreamCortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
Acked-by Ard Biesheuvel <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Will Deacon <[email protected]>[florian: resolved conflicts in arch/arm64/tools/cpucaps and cpu_errata.c]Signed-off-by Florian Fainelli <[email protected]>Change-Id I651a0db2e9d2f304d210ae979ae586e7dcc9744d
Quoted 4 lines
Quoted 1 line
No need for Change-Id: in upstream patches :)
Meh, the perils of working with Gerrit in the same tree.. do you need me to resubmit or can you strip those when you apply the patches?
I stripped them all, no worries.
PATCH 1/1 arm64: errata: Remove AES hwcap for COMPAT tasks
In reply to Florian FainelliFrom: James Morse <[email protected]>
commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream
Cortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
--- Documentation/arm64/silicon-errata.rst | 4 ++++ arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 16 ++++++++++++++++ arch/arm64/kernel/cpufeature.c | 13 ++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-)
Documentation/arm64/silicon-errata.rst +4 -0
@@ -70,8 +70,12 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A72 | #853709 | N/A | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A73 | #858921 | ARM64_ERRATUM_858921 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A55 | #1024718 | ARM64_ERRATUM_1024718 |
arch/arm64/Kconfig +16 -0
@@ -574,6 +574,22 @@ config ARM64_ERRATUM_1542419 If unsure, say Y. +config ARM64_ERRATUM_1742098 + bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" + depends on COMPAT + default y + help + This option removes the AES hwcap for aarch32 user-space to + workaround erratum 1742098 on Cortex-A57 and Cortex-A72. + + Affected parts may corrupt the AES state if an interrupt is + taken between a pair of AES instructions. These instructions + are only present if the cryptography extensions are present. + All software should have a fallback implementation for CPUs + that don't implement the cryptography extensions. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -56,7 +56,8 @@#define ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM 46#define ARM64_WORKAROUND_1542419 47#define ARM64_SPECTRE_BHB 48 +#define ARM64_WORKAROUND_1742098 49 -#define ARM64_NCAPS 49 +#define ARM64_NCAPS 50#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +16 -0
@@ -817,6 +817,14 @@ static const struct arm64_cpu_capabilities erratum_843419_list[] = { };#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 +static struct midr_range broken_aarch32_aes[] = { +MIDR_RANGE (MIDR_CORTEX_A57 ,0 ,1 ,0xf ,0xf ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A72 ), + {}, +}; +#endif + const struct arm64_cpu_capabilities arm64_errata[] = {#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE {
@@ -997,6 +1005,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .matches = has_neoverse_n1_erratum_1542419, .cpu_enable = cpu_enable_trap_ctr_access, }, +#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 + { + .desc = "ARM erratum 1742098", + .capability = ARM64_WORKAROUND_1742098, + CAP_MIDR_RANGE_LIST(broken_aarch32_aes), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + }, #endif { }
arch/arm64/kernel/cpufeature.c +12 -1
@@ -21,6 +21,7 @@#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/fpsimd.h> +#include <asm/hwcap.h> #include <asm/mmu_context.h> #include <asm/processor.h> #include <asm/sysreg.h>
@@ -1280,6 +1281,14 @@ static bool can_use_gic_priorities(const struct arm64_cpu_capabilities *entry, }#endif +static void elf_hwcap_fixup (void ) +{ +#ifdef CONFIG_ARM64_ERRATUM_1742098 +if (cpus_have_const_cap (ARM64_WORKAROUND_1742098 )) + compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES ; +#endif /* ARM64_ERRATUM_1742098 */ +} +static const struct arm64_cpu_capabilities arm64_features[] = { { .desc ="GIC system register CPU interface" ,
@@ -2103,8 +2112,10 @@ void __init setup_cpu_features(void)mark_const_caps_ready ();setup_elf_hwcaps (arm64_elf_hwcaps); -if (system_supports_32bit_el0 ()) +if (system_supports_32bit_el0 ()) {setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup (); + }if (system_uses_ttbr0_pan ())pr_info ("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n" );
Signature · 1 line
2.25.1
PATCH 1/1 arm64: errata: Remove AES hwcap for COMPAT tasks
In reply to Florian FainelliFrom: James Morse <[email protected]>
commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream
Cortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
--- Documentation/arm64/silicon-errata.rst | 4 ++++ arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 16 ++++++++++++++++ arch/arm64/kernel/cpufeature.c | 13 ++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-)
Documentation/arm64/silicon-errata.rst +4 -0
@@ -76,10 +76,14 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A57 | #1319537 | ARM64_ERRATUM_1319367 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A72 | #853709 | N/A | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A72 | #1319367 | ARM64_ERRATUM_1319367 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A73 | #858921 | ARM64_ERRATUM_858921 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A76 | #1188873,1418040| ARM64_ERRATUM_1418040 |
arch/arm64/Kconfig +16 -0
@@ -481,6 +481,22 @@ config ARM64_ERRATUM_834220 If unsure, say Y. +config ARM64_ERRATUM_1742098 + bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" + depends on COMPAT + default y + help + This option removes the AES hwcap for aarch32 user-space to + workaround erratum 1742098 on Cortex-A57 and Cortex-A72. + + Affected parts may corrupt the AES state if an interrupt is + taken between a pair of AES instructions. These instructions + are only present if the cryptography extensions are present. + All software should have a fallback implementation for CPUs + that don't implement the cryptography extensions. + + If unsure, say Y. + config ARM64_ERRATUM_845719 bool "Cortex-A53: 845719: a load might read incorrect data" depends on COMPAT
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -68,7 +68,8 @@#define ARM64_WORKAROUND_1508412 58#define ARM64_SPECTRE_BHB 59#define ARM64_WORKAROUND_2457168 60 +#define ARM64_WORKAROUND_1742098 61 -#define ARM64_NCAPS 61 +#define ARM64_NCAPS 62#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +16 -0
@@ -356,6 +356,14 @@ static const struct midr_range erratum_1463225[] = { };#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 +static struct midr_range broken_aarch32_aes[] = { +MIDR_RANGE (MIDR_CORTEX_A57 ,0 ,1 ,0xf ,0xf ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A72 ), + {}, +}; +#endif + const struct arm64_cpu_capabilities arm64_errata[] = {#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE {
@@ -554,6 +562,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {/* Cortex-A510 r0p0-r1p1 */ CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) }, +#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 + { + .desc = "ARM erratum 1742098", + .capability = ARM64_WORKAROUND_1742098, + CAP_MIDR_RANGE_LIST(broken_aarch32_aes), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + }, #endif { }
arch/arm64/kernel/cpufeature.c +12 -1
@@ -76,6 +76,7 @@#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/fpsimd.h> +#include <asm/hwcap.h> #include <asm/mmu_context.h> #include <asm/mte.h> #include <asm/processor.h>
@@ -1730,6 +1731,14 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap) }#endif /* CONFIG_ARM64_MTE */ +static void elf_hwcap_fixup (void ) +{ +#ifdef CONFIG_ARM64_ERRATUM_1742098 +if (cpus_have_const_cap (ARM64_WORKAROUND_1742098 )) + compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES ; +#endif /* ARM64_ERRATUM_1742098 */ +} +/* Internal helper functions to match cpu capability type */ static bool cpucap_late_cpu_optional (const struct arm64_cpu_capabilities *cap)
@@ -2735,8 +2744,10 @@ void __init setup_cpu_features(void)setup_system_capabilities ();setup_elf_hwcaps (arm64_elf_hwcaps); -if (system_supports_32bit_el0 ()) +if (system_supports_32bit_el0 ()) {setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup (); + }if (system_uses_ttbr0_pan ())pr_info ("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n" );
Signature · 1 line
2.25.1
PATCH 1/1 arm64: errata: Remove AES hwcap for COMPAT tasks
In reply to Florian FainelliFrom: James Morse <[email protected]>
commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream
Cortex-A57 and Cortex-A72 have an erratum where an interrupt that occurs between a pair of AES instructions in aarch32 mode may corrupt the ELR. The task will subsequently produce the wrong AES result.
The AES instructions are part of the cryptographic extensions, which are optional. User-space software will detect the support for these instructions from the hwcaps. If the platform doesn't support these instructions a software implementation should be used.
Remove the hwcap bits on affected parts to indicate user-space should not use the AES instructions.
--- Documentation/arm64/silicon-errata.rst | 4 ++++ arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 16 ++++++++++++++++ arch/arm64/kernel/cpufeature.c | 14 +++++++++++++- arch/arm64/tools/cpucaps | 1 + 5 files changed, 50 insertions(+), 1 deletion(-)
Documentation/arm64/silicon-errata.rst +4 -0
@@ -76,10 +76,14 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A57 | #1319537 | ARM64_ERRATUM_1319367 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A57 | #1742098 | ARM64_ERRATUM_1742098 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A72 | #853709 | N/A | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A72 | #1319367 | ARM64_ERRATUM_1319367 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A72 | #1655431 | ARM64_ERRATUM_1742098 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A73 | #858921 | ARM64_ERRATUM_858921 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A76 | #1188873,1418040| ARM64_ERRATUM_1418040 |
arch/arm64/Kconfig +16 -0
@@ -487,6 +487,22 @@ config ARM64_ERRATUM_834220 If unsure, say Y. +config ARM64_ERRATUM_1742098 + bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" + depends on COMPAT + default y + help + This option removes the AES hwcap for aarch32 user-space to + workaround erratum 1742098 on Cortex-A57 and Cortex-A72. + + Affected parts may corrupt the AES state if an interrupt is + taken between a pair of AES instructions. These instructions + are only present if the cryptography extensions are present. + All software should have a fallback implementation for CPUs + that don't implement the cryptography extensions. + + If unsure, say Y. + config ARM64_ERRATUM_845719 bool "Cortex-A53: 845719: a load might read incorrect data" depends on COMPAT
arch/arm64/kernel/cpu_errata.c +16 -0
@@ -350,6 +350,14 @@ static const struct midr_range erratum_1463225[] = { };#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 +static struct midr_range broken_aarch32_aes[] = { +MIDR_RANGE (MIDR_CORTEX_A57 ,0 ,1 ,0xf ,0xf ), +MIDR_ALL_VERSIONS (MIDR_CORTEX_A72 ), + {}, +}; +#endif + const struct arm64_cpu_capabilities arm64_errata[] = {#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE {
@@ -559,6 +567,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {/* Cortex-A510 r0p0-r1p1 */ CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) }, +#endif +#ifdef CONFIG_ARM64_ERRATUM_1742098 + { + .desc = "ARM erratum 1742098", + .capability = ARM64_WORKAROUND_1742098, + CAP_MIDR_RANGE_LIST(broken_aarch32_aes), + .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, + }, #endif { }
arch/arm64/kernel/cpufeature.c +13 -1
@@ -79,6 +79,7 @@#include <asm/cpufeature.h> #include <asm/cpu_ops.h> #include <asm/fpsimd.h> +#include <asm/hwcap.h> #include <asm/insn.h> #include <asm/kvm_host.h> #include <asm/mmu_context.h>
@@ -1915,6 +1916,14 @@ static void cpu_enable_mte(struct arm64_cpu_capabilities const *cap) }#endif /* CONFIG_ARM64_MTE */ +static void elf_hwcap_fixup (void ) +{ +#ifdef CONFIG_ARM64_ERRATUM_1742098 +if (cpus_have_const_cap (ARM64_WORKAROUND_1742098 )) + compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES ; +#endif /* ARM64_ERRATUM_1742098 */ +} +#ifdef CONFIG_KVM static bool is_kvm_protected_mode (const struct arm64_cpu_capabilities *entry,int __unused) {
@@ -2942,8 +2951,10 @@ void __init setup_cpu_features(void)setup_system_capabilities ();setup_elf_hwcaps (arm64_elf_hwcaps); -if (system_supports_32bit_el0 ()) +if (system_supports_32bit_el0 ()) {setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup (); + }if (system_uses_ttbr0_pan ())pr_info ("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n" );
@@ -2995,6 +3006,7 @@ static int enable_mismatched_32bit_el0(unsigned int cpu) cpu_active_mask);get_cpu_device (lucky_winner)->offline_disabled = true;setup_elf_hwcaps (compat_elf_hwcaps); +elf_hwcap_fixup ();pr_info ("Asymmetric 32-bit EL0 support detected on CPU %u; CPU hot-unplug disabled on CPU %u\n" , cpu, lucky_winner);return 0 ;
arch/arm64/tools/cpucaps +1 -0
@@ -54,6 +54,7 @@ WORKAROUND_1418040 WORKAROUND_1463225 WORKAROUND_1508412 WORKAROUND_1542419 +WORKAROUND_1742098 WORKAROUND_2457168 WORKAROUND_CAVIUM_23154 WORKAROUND_CAVIUM_27456
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerQuoted 3 lines · Florian Fainelli
From: James Morse <[email protected]>
commit
44b3834b2eed595af07021b1c64e6f9bc396398bupstream
All now queued up, thanks.
greg k-h