Skip to contentSkip to conversation

mx5: Implement Spectre v2 workaround for Cortex-A8

PATCH Superseded Fabio Estevam 2 participants 2 messages Jul 11, 2018 – Jul 12, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 mx5: Implement Spectre v2 workaround for Cortex-A8

Since 4.18-rc1 kernel the following warning is seen on i.MX51 and i.MX53:

CPU0: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable

Implement the suggested workaround by setting the IBE bit in the auxiliary control register.

Based on commit 7b37a9c732bf ("ARM: Introduce ability to enable ACR::IBE on Cortex-A8 for CVE-2017-5715") from U-Boot.

With this patch applied the kernel now reports:

CPU0: Spectre v2: using BPIALL workaround

Tested on a imx51 babbage.

---
 arch/arm/include/asm/errata.h | 9 +++++++++
 arch/arm/mach-imx/cpu_init.c  | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)
arch/arm/include/asm/errata.h +9 -0
index 98137b5..c0e0f5a 100644
@@ -86,3 +86,12 @@ static inline void enable_arm_errata_845369_war(void)
 		"mcr	p15, 0, r0, c15, c0, 1\n"
 	);
 }
+
+static inline void enable_arm_errata_cortexa8_cve_2017_5715(void)
+{
+	__asm__ __volatile__ (
+		"mrc	p15, 0, r0, c1, c0, 1\n"
+		"orr	r0, r0, #1 << 6\n"
+		"mcr	p15, 0, r0, c1, c0, 1\n"
+	);
+}
arch/arm/mach-imx/cpu_init.c +2 -1
index 5b93d12..e1d88c7 100644
@@ -22,6 +22,7 @@ void imx5_cpu_lowlevel_init(void)
 	arm_cpu_lowlevel_init();
 
 	enable_arm_errata_709718_war();
+	enable_arm_errata_cortexa8_cve_2017_5715();
 }
 
 void imx6_cpu_lowlevel_init(void)
@@ -51,4 +52,4 @@ void vf610_cpu_lowlevel_init(void)
 {
 	arm_cpu_lowlevel_init();
 }
-#endif
\ No newline at end of file
+#endif
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

Hi Fabio

Am Mittwoch, den 11.07.2018, 19:29 -0300 schrieb Fabio Estevam:

Quoted 31 lines

Since 4.18-rc1 kernel the following warning is seen on i.MX51 and
i.MX53:

CPU0: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
Implement the suggested workaround by setting the IBE bit in the
auxiliary control register.

Based on commit 7b37a9c732bf ("ARM: Introduce ability to enable ACR::IBE on Cortex-A8 for CVE-2017-5715") from U-Boot.

With this patch applied the kernel now reports:

CPU0: Spectre v2: using BPIALL workaround

Tested on a imx51 babbage.

Quoted 1 line

---
 arch/arm/include/asm/errata.h | 9 +++++++++
 arch/arm/mach-imx/cpu_init.c  | 3 ++-

 2 files changed, 11 insertions(+), 1 deletion(-)
arch/arm/include/asm/errata.h +0 -0
index 98137b5..c0e0f5a 100644
@@ -86,3 +86,12 @@ static inline void enable_arm_errata_845369_war(void)
Quoted 2 lines
Quoted 1 line

  "mcr p15, 0, r0, c15, c0, 1\n"

  );

 }

arch/arm/include/asm/errata.h static inline void enable_arm_errata_845369_war(void) · line 90

Quoted 2 lines
arch/arm/include/asm/errata.h +2 -0
+
+static inline void enable_arm_errata_cortexa8_cve_2017_5715(void)

Patch looks mostly good, but I don't like the naming here. CVE 2017- 5715 doesn't have a direct correlation with the Cortex A8. Maybe just name this _cortexa8_enable_ibe? A comment that this allows the kernel to flush the BTB properly might also help.

Regards,
Lucas

Quoted 20 lines

+{

Quoted 5 lines
arch/arm/include/asm/errata.h +1 -0
+	__asm__ __volatile__ (
Quoted 3 lines
arch/arm/include/asm/errata.h +3 -0
+		"mrc	p15, 0, r0, c1, c0, 1\n"
+		"orr	r0, r0, #1 << 6\n"
+		"mcr	p15, 0, r0, c1, c0, 1\n"
arch/arm/include/asm/errata.h +1 -0
+	);
arch/arm/include/asm/errata.h +1 -0
+}
arch/arm/mach-imx/cpu_init.c +0 -0
index 5b93d12..e1d88c7 100644
@@ -22,6 +22,7 @@ void imx5_cpu_lowlevel_init(void)
 >  	arm_cpu_lowlevel_init();

arch/arm/mach-imx/cpu_init.c void imx5_cpu_lowlevel_init(void) · line 25

Quoted 2 lines

  enable_arm_errata_709718_war();

arch/arm/mach-imx/cpu_init.c +1 -0
+	enable_arm_errata_cortexa8_cve_2017_5715();

 }

 void imx6_cpu_lowlevel_init(void)

arch/arm/mach-imx/cpu_init.c void vf610_cpu_lowlevel_init(void) · line 55

Quoted 6 lines
arch/arm/mach-imx/cpu_init.c +1 -1
@@ -51,4 +52,4 @@ void vf610_cpu_lowlevel_init(void)
  {
 >  	arm_cpu_lowlevel_init();
  }
-#endif
\ No newline at end of file
+#endif

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox