linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Add AMPERE1 to the Spectre-BHB affected list
@ 2022-10-11  2:21 D Scott Phillips
  2022-10-12 16:28 ` James Morse
  2022-10-12 16:36 ` Catalin Marinas
  0 siblings, 2 replies; 3+ messages in thread
From: D Scott Phillips @ 2022-10-11  2:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: James Morse, Catalin Marinas, Will Deacon, Darren Hart, patches

Per AmpereOne erratum AC03_CPU_12, "Branch history may allow control of
speculative execution across software contexts," the AMPERE1 core needs the
bhb clearing loop to mitigate Spectre-BHB, with a loop iteration count of
11.

Signed-off-by: D Scott Phillips <scott@os.amperecomputing.com>
---
 arch/arm64/include/asm/cputype.h | 4 ++++
 arch/arm64/kernel/proton-pack.c  | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index 8aa0d276a636..abc418650fec 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -60,6 +60,7 @@
 #define ARM_CPU_IMP_FUJITSU		0x46
 #define ARM_CPU_IMP_HISI		0x48
 #define ARM_CPU_IMP_APPLE		0x61
+#define ARM_CPU_IMP_AMPERE		0xC0
 
 #define ARM_CPU_PART_AEM_V8		0xD0F
 #define ARM_CPU_PART_FOUNDATION		0xD00
@@ -123,6 +124,8 @@
 #define APPLE_CPU_PART_M1_ICESTORM_MAX	0x028
 #define APPLE_CPU_PART_M1_FIRESTORM_MAX	0x029
 
+#define AMPERE_CPU_PART_AMPERE1		0xAC3
+
 #define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)
 #define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57)
 #define MIDR_CORTEX_A72 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72)
@@ -172,6 +175,7 @@
 #define MIDR_APPLE_M1_FIRESTORM_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_PRO)
 #define MIDR_APPLE_M1_ICESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_MAX)
 #define MIDR_APPLE_M1_FIRESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX)
+#define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1)
 
 /* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */
 #define MIDR_FUJITSU_ERRATUM_010001		MIDR_FUJITSU_A64FX
diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
index a8ea1637b137..bfce41c2a53b 100644
--- a/arch/arm64/kernel/proton-pack.c
+++ b/arch/arm64/kernel/proton-pack.c
@@ -868,6 +868,10 @@ u8 spectre_bhb_loop_affected(int scope)
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
 			{},
 		};
+		static const struct midr_range spectre_bhb_k11_list[] = {
+			MIDR_ALL_VERSIONS(MIDR_AMPERE1),
+			{},
+		};
 		static const struct midr_range spectre_bhb_k8_list[] = {
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
@@ -878,6 +882,8 @@ u8 spectre_bhb_loop_affected(int scope)
 			k = 32;
 		else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list))
 			k = 24;
+		else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list))
+			k = 11;
 		else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list))
 			k =  8;
 
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: Add AMPERE1 to the Spectre-BHB affected list
  2022-10-11  2:21 [PATCH] arm64: Add AMPERE1 to the Spectre-BHB affected list D Scott Phillips
@ 2022-10-12 16:28 ` James Morse
  2022-10-12 16:36 ` Catalin Marinas
  1 sibling, 0 replies; 3+ messages in thread
From: James Morse @ 2022-10-12 16:28 UTC (permalink / raw)
  To: D Scott Phillips, linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, Darren Hart, patches

Hi Scott,

On 11/10/2022 03:21, D Scott Phillips wrote:
> Per AmpereOne erratum AC03_CPU_12, "Branch history may allow control of
> speculative execution across software contexts," the AMPERE1 core needs the
> bhb clearing loop to mitigate Spectre-BHB, with a loop iteration count of
> 11.

Reviewed-by: James Morse <james.morse@arm.com>

I tried googling for 'AC03_CPU_12', but didn't find anything. Is there a public document
for things like this?


Thanks,

James

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: Add AMPERE1 to the Spectre-BHB affected list
  2022-10-11  2:21 [PATCH] arm64: Add AMPERE1 to the Spectre-BHB affected list D Scott Phillips
  2022-10-12 16:28 ` James Morse
@ 2022-10-12 16:36 ` Catalin Marinas
  1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2022-10-12 16:36 UTC (permalink / raw)
  To: D Scott Phillips, linux-arm-kernel
  Cc: Will Deacon, Darren Hart, patches, James Morse

On Mon, 10 Oct 2022 19:21:40 -0700, D Scott Phillips wrote:
> Per AmpereOne erratum AC03_CPU_12, "Branch history may allow control of
> speculative execution across software contexts," the AMPERE1 core needs the
> bhb clearing loop to mitigate Spectre-BHB, with a loop iteration count of
> 11.
> 
> 

Applied to arm64 (for-next/core), thanks!

[1/1] arm64: Add AMPERE1 to the Spectre-BHB affected list
      https://git.kernel.org/arm64/c/0e5d5ae837c8

-- 
Catalin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-12 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-11  2:21 [PATCH] arm64: Add AMPERE1 to the Spectre-BHB affected list D Scott Phillips
2022-10-12 16:28 ` James Morse
2022-10-12 16:36 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).