Skip to contentSkip to conversation

arm64: errata: Add Qualcomm CPUs to the Spectre mitigation lists

PATCH In review Douglas Anderson 5 participants 24 messages Dec 9, 2024 – Dec 16, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover arm64: errata: Add Qualcomm CPUs to the Spectre mitigation lists

Since Qualcomm CPUs are all derivatives of ARM cores they all have unique MIDR values. This means that the tables listing necessary Spectre mitigations need special entries for them. However, those entries are not present and that means that some Spectre mitigations are lacking for Qualcomm CPUs.

I've made an attempt at **GUESSING** what the right patches should be to enable mitigations for Qualcomm CPUs. This is mostly me searching the web to figure out what ARM cores various Qualcomm cores are based off of.

These patches get more and more sketchy as the series progresses and I have noted that the later patces DON'T EVEN COMPILE. I have included them to make it obvious that I think these cores are affected even if I don't have all the right information to mitigate them. Hopefully Qualcomm can come and fix this mess for me.

I'll note that I am certainly no expert on Spectre. Mostly I ended up here running lscpu on a device and noticing that it thought that it wasn't affected by Spectre v2 when I thought it was.

Douglas Anderson (6):
arm64: errata: Add QCOM_KRYO_4XX_GOLD to the spectre_bhb_k24_list
arm64: errata: Add QCOM_KRYO_2XX_GOLD to the
spectre_bhb_firmware_mitigated_list
arm64: cputype: Add QCOM_CPU_PART_KRYO_3XX_GOLD
arm64: errata: Add QCOM_KRYO_3XX_GOLD to the
spectre_bhb_firmware_mitigated_list
arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list
arm64: errata: Add QCOM_KRYO_6XX_GOLD/PRIME to the
spectre_bhb_k32_list

 arch/arm64/include/asm/cputype.h | 2 ++
 arch/arm64/kernel/proton-pack.c  | 6 ++++++
 2 files changed, 8 insertions(+)
Signature · 1 line
2.47.0.338.g60cca15819-goog
#1 lore raw

PATCH 1/6 arm64: errata: Add QCOM_KRYO_4XX_GOLD to the spectre_bhb_k24_list

Qualcomm Kryo 400-series Gold cores appear to have a derivative of an ARM Cortex A76 in them. Since A76 needs Spectre mitigation then the Kyro 400-series Gold cores also should need Spectre mitigation.

---
The "k" value here really should come from analysis by Qualcomm, but until we can get that analysis let's choose the same value as A76: 24.

Ideally someone from Qualcomm can confirm that this mitigation is needed and confirm / provide the proper "k" value.

 arch/arm64/kernel/proton-pack.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
index da53722f95d4..e149efadff20 100644
@@ -866,6 +866,7 @@ u8 spectre_bhb_loop_affected(int scope)
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_A76),
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_A77),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD),
 			{},
 		};
 		static const struct midr_range spectre_bhb_k11_list[] = {
Signature · 1 line
2.47.0.338.g60cca15819-goog
#2 lore raw

PATCH 2/6 arm64: errata: Add QCOM_KRYO_2XX_GOLD to the spectre_bhb_firmware_mitigated_list

In reply to Douglas Anderson

Qualcomm Kryo 200-series Gold cores appear to have a derivative of an ARM Cortex A73 in them. Since A73 needs Spectre mitigation then the Kyro 200-series Gold cores also should need Spectre mitigation.

---
I don't really have any good way to test this patch but it seems likely it's needed. If nothing else the claim is that that Qualcomm Kyro 280 CPU is vulnerable [1] but I don't see any mitigations in the kernel for it.

NOTE: presumably this patch won't actually do much on its own because (I believe) it requires a firmware update to go with it.

[1] https://spectreattack.com/spectre.pdf

 arch/arm64/kernel/proton-pack.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
index e149efadff20..0437be7c83bc 100644
@@ -925,6 +925,7 @@ static bool is_spectre_bhb_fw_affected(int scope)
 	static const struct midr_range spectre_bhb_firmware_mitigated_list[] = {
 		MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
 		MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
+		MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_2XX_GOLD),
 		{},
 	};
 	bool cpu_in_list = is_midr_in_range_list(read_cpuid_id(),
Signature · 1 line
2.47.0.338.g60cca15819-goog
#3 lore raw

Re: [PATCH 2/6] arm64: errata: Add QCOM_KRYO_2XX_GOLD to the spectre_bhb_firmware_mitigated_list

Quoted 5 lines · Douglas Anderson

Qualcomm Kryo 200-series Gold cores appear to have a derivative of an ARM Cortex A73 in them. Since A73 needs Spectre mitigation then the Kyro 200-series Gold cores also should need Spectre mitigation.

Quoted 8 lines

---
I don't really have any good way to test this patch but it seems likely it's needed. If nothing else the claim is that that Qualcomm Kyro 280 CPU is vulnerable [1] but I don't see any mitigations in the kernel for it.

NOTE: presumably this patch won't actually do much on its own because (I believe) it requires a firmware update to go with it.

Why? is_spectre_bhb_fw_affected() returns true if (cpu in list OR fw mitigated)

Quoted 21 lines

[1] https://spectreattack.com/spectre.pdf

 arch/arm64/kernel/proton-pack.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
index e149efadff20..0437be7c83bc 100644
@@ -925,6 +925,7 @@ static bool is_spectre_bhb_fw_affected(int scope)
 	static const struct midr_range spectre_bhb_firmware_mitigated_list[] = {
 		MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
 		MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
+		MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_2XX_GOLD),
 		{},
 	};
 	bool cpu_in_list = is_midr_in_range_list(read_cpuid_id(),
Signature · 1 line
2.47.0.338.g60cca15819-goog
Signature · 2 lines
With best wishes
Dmitry
#4 lore raw

Re: [PATCH 2/6] arm64: errata: Add QCOM_KRYO_2XX_GOLD to the spectre_bhb_firmware_mitigated_list

Quoted 5 lines
Quoted 2 lines

NOTE: presumably this patch won't actually do much on its own because (I believe) it requires a firmware update to go with it.

Why? is_spectre_bhb_fw_affected() returns true if (cpu in list OR fw mitigated)

That affects reporting, but the mitigation works by making an ARM_SMCCC_ARCH_WORKAROUND_3 Secure Monitor Call to firmware, and that only works if that call is implemented in firmware. Trusted-Firmware-A is currently the only open source firmware I'm aware of that implements this call, and it only supports Kryo 4 and 6 upstream (not 2 or 3).

So in order for this patch to actually be able to do anything other than report that the mitigation is missing, it would need to run on devices that either use a downstream fork of TF-A with added Kryo 2/3 support (I doubt this exists because AFAIK Kryo 4 was Qualcomm's first attempt to use TF-A) or use some other proprietary kind of Secure Monitor firmware that has this SMC and mitigation implemented separately. (It seems unlikely that Qualcomm did this in their QTEE firmware, since if they had they would have probably also added the MIDRs here to Linux to activate it.)

#5 lore raw

Re: [PATCH 2/6] arm64: errata: Add QCOM_KRYO_2XX_GOLD to the spectre_bhb_firmware_mitigated_list

Quoted 13 lines · Julius Werner
Quoted 5 lines
Quoted 2 lines

NOTE: presumably this patch won't actually do much on its own because (I believe) it requires a firmware update to go with it.

Why? is_spectre_bhb_fw_affected() returns true if (cpu in list OR fw mitigated)

That affects reporting, but the mitigation works by making an ARM_SMCCC_ARCH_WORKAROUND_3 Secure Monitor Call to firmware, and that only works if that call is implemented in firmware. Trusted-Firmware-A is currently the only open source firmware I'm aware of that implements this call, and it only supports Kryo 4 and 6 upstream (not 2 or 3).

Quoted 9 lines

So in order for this patch to actually be able to do anything other than report that the mitigation is missing, it would need to run on devices that either use a downstream fork of TF-A with added Kryo 2/3 support (I doubt this exists because AFAIK Kryo 4 was Qualcomm's first attempt to use TF-A) or use some other proprietary kind of Secure Monitor firmware that has this SMC and mitigation implemented separately. (It seems unlikely that Qualcomm did this in their QTEE firmware, since if they had they would have probably also added the MIDRs here to Linux to activate it.)

Ack, thanks for the detailed explanation.

Signature · 2 lines
With best wishes
Dmitry
#6 lore raw

PATCH 3/6 arm64: cputype: Add QCOM_CPU_PART_KRYO_3XX_GOLD

In reply to Douglas Anderson

Add a definition for the Qualcomm Kryo 300-series Gold cores.

---
I have no idea if this is actually right and no way to test it, but it fits the pattern of the other definitions. Someone from Qualcomm ought to confirm this.

 arch/arm64/include/asm/cputype.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
index 488f8e751349..c8058f91a5bd 100644
@@ -119,6 +119,7 @@
 #define QCOM_CPU_PART_KRYO		0x200
 #define QCOM_CPU_PART_KRYO_2XX_GOLD	0x800
 #define QCOM_CPU_PART_KRYO_2XX_SILVER	0x801
+#define QCOM_CPU_PART_KRYO_3XX_GOLD	0x802
 #define QCOM_CPU_PART_KRYO_3XX_SILVER	0x803
 #define QCOM_CPU_PART_KRYO_4XX_GOLD	0x804
 #define QCOM_CPU_PART_KRYO_4XX_SILVER	0x805
@@ -195,6 +196,7 @@
 #define MIDR_QCOM_KRYO MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO)
 #define MIDR_QCOM_KRYO_2XX_GOLD MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_2XX_GOLD)
 #define MIDR_QCOM_KRYO_2XX_SILVER MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_2XX_SILVER)
+#define MIDR_QCOM_KRYO_3XX_GOLD MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_3XX_GOLD)
 #define MIDR_QCOM_KRYO_3XX_SILVER MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_3XX_SILVER)
 #define MIDR_QCOM_KRYO_4XX_GOLD MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_4XX_GOLD)
 #define MIDR_QCOM_KRYO_4XX_SILVER MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_4XX_SILVER)
Signature · 1 line
2.47.0.338.g60cca15819-goog
Reviewed-by on v1 3/6
#7 lore raw

Re: [PATCH 3/6] arm64: cputype: Add QCOM_CPU_PART_KRYO_3XX_GOLD

Quoted 7 lines · Douglas Anderson

Add a definition for the Qualcomm Kryo 300-series Gold cores.

---
I have no idea if this is actually right and no way to test it, but it fits the pattern of the other definitions. Someone from Qualcomm ought to confirm this.

This matches what I see on SDM845.

Quoted 27 lines
 arch/arm64/include/asm/cputype.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
index 488f8e751349..c8058f91a5bd 100644
@@ -119,6 +119,7 @@
 #define QCOM_CPU_PART_KRYO		0x200
 #define QCOM_CPU_PART_KRYO_2XX_GOLD	0x800
 #define QCOM_CPU_PART_KRYO_2XX_SILVER	0x801
+#define QCOM_CPU_PART_KRYO_3XX_GOLD	0x802
 #define QCOM_CPU_PART_KRYO_3XX_SILVER	0x803
 #define QCOM_CPU_PART_KRYO_4XX_GOLD	0x804
 #define QCOM_CPU_PART_KRYO_4XX_SILVER	0x805
@@ -195,6 +196,7 @@
 #define MIDR_QCOM_KRYO MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO)
 #define MIDR_QCOM_KRYO_2XX_GOLD MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_2XX_GOLD)
 #define MIDR_QCOM_KRYO_2XX_SILVER MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_2XX_SILVER)
+#define MIDR_QCOM_KRYO_3XX_GOLD MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_3XX_GOLD)
 #define MIDR_QCOM_KRYO_3XX_SILVER MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_3XX_SILVER)
 #define MIDR_QCOM_KRYO_4XX_GOLD MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_4XX_GOLD)
 #define MIDR_QCOM_KRYO_4XX_SILVER MIDR_CPU_MODEL(ARM_CPU_IMP_QCOM, QCOM_CPU_PART_KRYO_4XX_SILVER)
Signature · 1 line
2.47.0.338.g60cca15819-goog
Signature · 2 lines
With best wishes
Dmitry
#8 lore raw

PATCH 4/6 arm64: errata: Add QCOM_KRYO_3XX_GOLD to the spectre_bhb_firmware_mitigated_list

In reply to Douglas Anderson

Qualcomm Kryo 300-series Gold cores appear to have a derivative of an ARM Cortex A75 in them. Since A75 needs Spectre mitigation then the Kyro 300-series Gold cores also should need Spectre mitigation.

---
I have no idea if this is actually needed and this patch is purely speculative. Given that A75 needs some sort of Spectre mitigation it seem hard to believe that the Qualcomm Kryo 300-series Gold cores wouldn't need it.

NOTE: presumably this patch won't actually do much on its own because (I believe) it requires a firmware update to go with it.

 arch/arm64/kernel/proton-pack.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
index 0437be7c83bc..b1881964e304 100644
@@ -926,6 +926,7 @@ static bool is_spectre_bhb_fw_affected(int scope)
 		MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
 		MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
 		MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_2XX_GOLD),
+		MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_3XX_GOLD),
 		{},
 	};
 	bool cpu_in_list = is_midr_in_range_list(read_cpuid_id(),
Signature · 1 line
2.47.0.338.g60cca15819-goog
#9 lore raw

PATCH 5/6 arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

In reply to Douglas Anderson

Qualcomm Kryo 500-series Gold cores appear to have a derivative of an ARM Cortex A77 in them. Since A77 needs Spectre mitigation then the Kyro 500-series Gold cores also should need Spectre mitigation.

---
Yes. I know. This patch DOESN'T COMPILE because MIDR_QCOM_KRYO_5XX_GOLD is not defined. That value needs to come from Qualcomm or from testing on hardware, which I don't have. Qualcomm needs to chime in to confirm that this Spectre mitigation is correct anyway, though. I'm including this patch so it's obvious that I think these cores also need the mitigation.

 arch/arm64/kernel/proton-pack.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
index b1881964e304..212481726f04 100644
@@ -867,6 +867,7 @@ u8 spectre_bhb_loop_affected(int scope)
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_A77),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
 			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
 			{},
 		};
 		static const struct midr_range spectre_bhb_k11_list[] = {
Signature · 1 line
2.47.0.338.g60cca15819-goog
#10 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

Quoted 4 lines · Douglas Anderson

Qualcomm Kryo 500-series Gold cores appear to have a derivative of an ARM Cortex A77 in them. Since A77 needs Spectre mitigation then the Kyro 500-series Gold cores also should need Spectre mitigation.

Quoted 8 lines

---
Yes. I know. This patch DOESN'T COMPILE because MIDR_QCOM_KRYO_5XX_GOLD is not defined. That value needs to come from Qualcomm or from testing on hardware, which I don't have. Qualcomm needs to chime in to confirm that this Spectre mitigation is correct anyway, though. I'm including this patch so it's obvious that I think these cores also need the mitigation.

Kryo 5xx (SM8250) identify themselves as 0x41/0xd0d (Gold, Prime) and 0x51/0x805 (Silver)

Quoted 19 lines
 arch/arm64/kernel/proton-pack.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
index b1881964e304..212481726f04 100644
@@ -867,6 +867,7 @@ u8 spectre_bhb_loop_affected(int scope)
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_A77),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
 			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
 			{},
 		};
 		static const struct midr_range spectre_bhb_k11_list[] = {
Signature · 1 line
2.47.0.338.g60cca15819-goog
Signature · 2 lines
With best wishes
Dmitry
#11 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

Hi,

Quoted 15 lines · Dmitry Baryshkov
Quoted 4 lines · Douglas Anderson

Qualcomm Kryo 500-series Gold cores appear to have a derivative of an ARM Cortex A77 in them. Since A77 needs Spectre mitigation then the Kyro 500-series Gold cores also should need Spectre mitigation.

Quoted 8 lines

---
Yes. I know. This patch DOESN'T COMPILE because MIDR_QCOM_KRYO_5XX_GOLD is not defined. That value needs to come from Qualcomm or from testing on hardware, which I don't have. Qualcomm needs to chime in to confirm that this Spectre mitigation is correct anyway, though. I'm including this patch so it's obvious that I think these cores also need the mitigation.

Quoted 2 lines

Kryo 5xx (SM8250) identify themselves as 0x41/0xd0d (Gold, Prime) and 0x51/0x805 (Silver)

Interesting. So the Gold/Prime are actually IDing themselves as straight Cortex A77. The Silver is IDing itself the same as KRYO_4XX_SILVER. ...so in that sense there's nothing to do here for those cores.

-Doug

#12 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

Quoted 4 lines

Interesting. So the Gold/Prime are actually IDing themselves as straight Cortex A77. The Silver is IDing itself the same as KRYO_4XX_SILVER. ...so in that sense there's nothing to do here for those cores.

Should we add some comments to cputype.h to record which other products are matched under the same ID?

#13 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

Quoted 7 lines · Julius Werner
Quoted 4 lines

Interesting. So the Gold/Prime are actually IDing themselves as straight Cortex A77. The Silver is IDing itself the same as KRYO_4XX_SILVER. ...so in that sense there's nothing to do here for those cores.

Should we add some comments to cputype.h to record which other products are matched under the same ID?

I'd say, yes.

Signature · 2 lines
With best wishes
Dmitry
#14 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

Hi,

Quoted 11 lines · Dmitry Baryshkov
Quoted 7 lines · Julius Werner
Quoted 4 lines

Interesting. So the Gold/Prime are actually IDing themselves as straight Cortex A77. The Silver is IDing itself the same as KRYO_4XX_SILVER. ...so in that sense there's nothing to do here for those cores.

Should we add some comments to cputype.h to record which other products are matched under the same ID?

I'd say, yes.

Sure. I'll send a v3 with this tomorrow.

-Doug

#15 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

In reply to Douglas Anderson
kernel test robot noticed the following build errors:

Hi Douglas,

kernel test robot noticed the following build errors:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on arm-perf/for-next/perf kvmarm/next soc/for-next arm/for-next arm/fixes linus/master v6.13-rc2 next-20241210] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Douglas-Anderson/arm64-errata-Add-QCOM_KRYO_4XX_GOLD-to-the-spectre_bhb_k24_list/20241210-014833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link:    https://lore.kernel.org/r/20241209094310.5.I41e227ed809ea607114027209b57d02dc0e98384%40changeid
patch subject: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list
config: arm64-allnoconfig (https://download.01.org/0day-ci/archive/20241210/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241210/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from arch/arm64/include/asm/cache.h:43,

                    from include/linux/cache.h:6,
                    from include/linux/jiffies.h:5,
                    from include/linux/ktime.h:25,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/bpf.h:10,
                    from arch/arm64/kernel/proton-pack.c:21:
   arch/arm64/kernel/proton-pack.c: In function 'spectre_bhb_loop_affected':
>> arch/arm64/kernel/proton-pack.c:870:43: error: 'MIDR_QCOM_KRYO_5XX_GOLD' undeclared (first use in this function); did you mean 'MIDR_QCOM_KRYO_4XX_GOLD'?
     870 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/cputype.h:251:26: note: in definition of macro 'MIDR_RANGE'
     251 |                 .model = m,                                     \
         |                          ^
   arch/arm64/kernel/proton-pack.c:870:25: note: in expansion of macro 'MIDR_ALL_VERSIONS'
     870 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
         |                         ^~~~~~~~~~~~~~~~~
   arch/arm64/kernel/proton-pack.c:870:43: note: each undeclared identifier is reported only once for each function it appears in
     870 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/cputype.h:251:26: note: in definition of macro 'MIDR_RANGE'
     251 |                 .model = m,                                     \
         |                          ^
   arch/arm64/kernel/proton-pack.c:870:25: note: in expansion of macro 'MIDR_ALL_VERSIONS'
     870 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
         |                         ^~~~~~~~~~~~~~~~~

vim +870 arch/arm64/kernel/proton-pack.c

843
844 /*
845 * This must be called with SCOPE_LOCAL_CPU for each type of CPU, before any
846 * SCOPE_SYSTEM call will give the right answer.
847 */
848 u8 spectre_bhb_loop_affected(int scope)
849 {
850 u8 k = 0;
851 static u8 max_bhb_k;
852
853 if (scope == SCOPE_LOCAL_CPU) {
854 static const struct midr_range spectre_bhb_k32_list[] = {
855 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78),
856 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE),
857 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C),
858 MIDR_ALL_VERSIONS(MIDR_CORTEX_X1),
859 MIDR_ALL_VERSIONS(MIDR_CORTEX_A710),
860 MIDR_ALL_VERSIONS(MIDR_CORTEX_X2),
861 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
862 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1),
863 {},
864 };
865 static const struct midr_range spectre_bhb_k24_list[] = {
866 MIDR_ALL_VERSIONS(MIDR_CORTEX_A76),
867 MIDR_ALL_VERSIONS(MIDR_CORTEX_A77),
868 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
869 MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD),

 > 870				MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),

871 {},
872 };
873 static const struct midr_range spectre_bhb_k11_list[] = {
874 MIDR_ALL_VERSIONS(MIDR_AMPERE1),
875 {},
876 };
877 static const struct midr_range spectre_bhb_k8_list[] = {
878 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
879 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
880 {},
881 };
882
883 if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list))
884 k = 32;
885 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list))
886 k = 24;
887 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list))
888 k = 11;
889 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list))
890 k = 8;
891
892 max_bhb_k = max(max_bhb_k, k);
893 } else {
894 k = max_bhb_k;
895 }
896
897 return k;
898 }
899

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#16 lore raw

Re: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list

In reply to Douglas Anderson
kernel test robot noticed the following build errors:

Hi Douglas,

kernel test robot noticed the following build errors:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on arm-perf/for-next/perf kvmarm/next soc/for-next arm/for-next arm/fixes linus/master v6.13-rc2 next-20241210] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Douglas-Anderson/arm64-errata-Add-QCOM_KRYO_4XX_GOLD-to-the-spectre_bhb_k24_list/20241210-014833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link:    https://lore.kernel.org/r/20241209094310.5.I41e227ed809ea607114027209b57d02dc0e98384%40changeid
patch subject: [PATCH 5/6] arm64: errata: Add QCOM_KRYO_5XX_GOLD to the spectre_bhb_k24_list
config: arm64-randconfig-002-20241210 (https://download.01.org/0day-ci/archive/20241210/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241210/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from arch/arm64/kernel/proton-pack.c:21:
In file included from include/linux/bpf.h:21:
In file included from include/linux/kallsyms.h:13:
In file included from include/linux/mm.h:2223:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]

     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> arch/arm64/kernel/proton-pack.c:870:22: error: use of undeclared identifier 'MIDR_QCOM_KRYO_5XX_GOLD'

870 | MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
| ^
4 warnings and 1 error generated.

vim +/MIDR_QCOM_KRYO_5XX_GOLD +870 arch/arm64/kernel/proton-pack.c

843
844 /*
845 * This must be called with SCOPE_LOCAL_CPU for each type of CPU, before any
846 * SCOPE_SYSTEM call will give the right answer.
847 */
848 u8 spectre_bhb_loop_affected(int scope)
849 {
850 u8 k = 0;
851 static u8 max_bhb_k;
852
853 if (scope == SCOPE_LOCAL_CPU) {
854 static const struct midr_range spectre_bhb_k32_list[] = {
855 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78),
856 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE),
857 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C),
858 MIDR_ALL_VERSIONS(MIDR_CORTEX_X1),
859 MIDR_ALL_VERSIONS(MIDR_CORTEX_A710),
860 MIDR_ALL_VERSIONS(MIDR_CORTEX_X2),
861 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
862 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1),
863 {},
864 };
865 static const struct midr_range spectre_bhb_k24_list[] = {
866 MIDR_ALL_VERSIONS(MIDR_CORTEX_A76),
867 MIDR_ALL_VERSIONS(MIDR_CORTEX_A77),
868 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
869 MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD),

 > 870				MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),

871 {},
872 };
873 static const struct midr_range spectre_bhb_k11_list[] = {
874 MIDR_ALL_VERSIONS(MIDR_AMPERE1),
875 {},
876 };
877 static const struct midr_range spectre_bhb_k8_list[] = {
878 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
879 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
880 {},
881 };
882
883 if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list))
884 k = 32;
885 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list))
886 k = 24;
887 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list))
888 k = 11;
889 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list))
890 k = 8;
891
892 max_bhb_k = max(max_bhb_k, k);
893 } else {
894 k = max_bhb_k;
895 }
896
897 return k;
898 }
899

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#17 lore raw

PATCH 6/6 arm64: errata: Add QCOM_KRYO_6XX_GOLD/PRIME to the spectre_bhb_k32_list

In reply to Douglas Anderson

Qualcomm Kryo 600-series Gold cores appear to have a derivative of an ARM Cortex A78 / ARM Cortex X1 in them. Since these need Spectre mitigation then the Kyro 600-series Gold/Prime cores also should need Spectre mitigation.

---
Yes. I know. This patch DOESN'T COMPILE because MIDR_QCOM_KRYO_6XX_GOLD and MIDR_QCOM_KRYO_6XX_PRIME are not defined. Those value needs to come from Qualcomm or from testing on hardware, which I don't have. Qualcomm needs to chime in to confirm that this Spectre mitigation is correct anyway, though. I'm including this patch so it's obvious that I think these cores also need the mitigation.

 arch/arm64/kernel/proton-pack.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/proton-pack.c +2 -0
index 212481726f04..67aa54017dea 100644
@@ -860,6 +860,8 @@ u8 spectre_bhb_loop_affected(int scope)
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_X2),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_PRIME),
 			{},
 		};
 		static const struct midr_range spectre_bhb_k24_list[] = {
Signature · 1 line
2.47.0.338.g60cca15819-goog
#18 lore raw

Re: [PATCH 6/6] arm64: errata: Add QCOM_KRYO_6XX_GOLD/PRIME to the spectre_bhb_k32_list

Quoted 6 lines · Douglas Anderson

Qualcomm Kryo 600-series Gold cores appear to have a derivative of an ARM Cortex A78 / ARM Cortex X1 in them. Since these need Spectre mitigation then the Kyro 600-series Gold/Prime cores also should need Spectre mitigation.

Quoted 8 lines

---
Yes. I know. This patch DOESN'T COMPILE because MIDR_QCOM_KRYO_6XX_GOLD and MIDR_QCOM_KRYO_6XX_PRIME are not defined. Those value needs to come from Qualcomm or from testing on hardware, which I don't have. Qualcomm needs to chime in to confirm that this Spectre mitigation is correct anyway, though. I'm including this patch so it's obvious that I think these cores also need the mitigation.

SM8350 (Kryo 680) identifies itself as 0x41/0xd44 (Prime), 0x41/0xd41 (Gold) and 0x41/0xd05 (Silver)

Quoted 20 lines
 arch/arm64/kernel/proton-pack.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/proton-pack.c +2 -0
index 212481726f04..67aa54017dea 100644
@@ -860,6 +860,8 @@ u8 spectre_bhb_loop_affected(int scope)
 			MIDR_ALL_VERSIONS(MIDR_CORTEX_X2),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
 			MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
+			MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_PRIME),
 			{},
 		};
 		static const struct midr_range spectre_bhb_k24_list[] = {
Signature · 1 line
2.47.0.338.g60cca15819-goog
Signature · 2 lines
With best wishes
Dmitry
#19 lore raw

Re: [PATCH 6/6] arm64: errata: Add QCOM_KRYO_6XX_GOLD/PRIME to the spectre_bhb_k32_list

Hi,

Quoted 17 lines · Dmitry Baryshkov
Quoted 6 lines · Douglas Anderson

Qualcomm Kryo 600-series Gold cores appear to have a derivative of an ARM Cortex A78 / ARM Cortex X1 in them. Since these need Spectre mitigation then the Kyro 600-series Gold/Prime cores also should need Spectre mitigation.

Quoted 8 lines

---
Yes. I know. This patch DOESN'T COMPILE because MIDR_QCOM_KRYO_6XX_GOLD and MIDR_QCOM_KRYO_6XX_PRIME are not defined. Those value needs to come from Qualcomm or from testing on hardware, which I don't have. Qualcomm needs to chime in to confirm that this Spectre mitigation is correct anyway, though. I'm including this patch so it's obvious that I think these cores also need the mitigation.

Quoted 2 lines

SM8350 (Kryo 680) identifies itself as 0x41/0xd44 (Prime), 0x41/0xd41 (Gold) and 0x41/0xd05 (Silver)

Wow, all standard ARM cores. OK, I guess we can drop this patch too then. Nice!

-Doug

#20 lore raw

Re: [PATCH 6/6] arm64: errata: Add QCOM_KRYO_6XX_GOLD/PRIME to the spectre_bhb_k32_list

In reply to Douglas Anderson
kernel test robot noticed the following build errors:

Hi Douglas,

kernel test robot noticed the following build errors:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on arm-perf/for-next/perf kvmarm/next soc/for-next arm/for-next arm/fixes linus/master v6.13-rc2 next-20241210] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Douglas-Anderson/arm64-errata-Add-QCOM_KRYO_4XX_GOLD-to-the-spectre_bhb_k24_list/20241210-014833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link:    https://lore.kernel.org/r/20241209094310.6.I722621804be859e4ae4b7479ce191c5e3367b37c%40changeid
patch subject: [PATCH 6/6] arm64: errata: Add QCOM_KRYO_6XX_GOLD/PRIME to the spectre_bhb_k32_list
config: arm64-allnoconfig (https://download.01.org/0day-ci/archive/20241211/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241211/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from arch/arm64/include/asm/cache.h:43,

                    from include/linux/cache.h:6,
                    from include/linux/jiffies.h:5,
                    from include/linux/ktime.h:25,
                    from include/linux/timer.h:6,
                    from include/linux/workqueue.h:9,
                    from include/linux/bpf.h:10,
                    from arch/arm64/kernel/proton-pack.c:21:
   arch/arm64/kernel/proton-pack.c: In function 'spectre_bhb_loop_affected':
>> arch/arm64/kernel/proton-pack.c:863:43: error: 'MIDR_QCOM_KRYO_6XX_GOLD' undeclared (first use in this function); did you mean 'MIDR_QCOM_KRYO_4XX_GOLD'?
     863 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/cputype.h:251:26: note: in definition of macro 'MIDR_RANGE'
     251 |                 .model = m,                                     \
         |                          ^
   arch/arm64/kernel/proton-pack.c:863:25: note: in expansion of macro 'MIDR_ALL_VERSIONS'
     863 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
         |                         ^~~~~~~~~~~~~~~~~
   arch/arm64/kernel/proton-pack.c:863:43: note: each undeclared identifier is reported only once for each function it appears in
     863 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/cputype.h:251:26: note: in definition of macro 'MIDR_RANGE'
     251 |                 .model = m,                                     \
         |                          ^
   arch/arm64/kernel/proton-pack.c:863:25: note: in expansion of macro 'MIDR_ALL_VERSIONS'
     863 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
         |                         ^~~~~~~~~~~~~~~~~
>> arch/arm64/kernel/proton-pack.c:864:43: error: 'MIDR_QCOM_KRYO_6XX_PRIME' undeclared (first use in this function); did you mean 'MIDR_QCOM_KRYO_3XX_SILVER'?
     864 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_PRIME),
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/cputype.h:251:26: note: in definition of macro 'MIDR_RANGE'
     251 |                 .model = m,                                     \
         |                          ^
   arch/arm64/kernel/proton-pack.c:864:25: note: in expansion of macro 'MIDR_ALL_VERSIONS'
     864 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_PRIME),
         |                         ^~~~~~~~~~~~~~~~~
   arch/arm64/kernel/proton-pack.c:872:43: error: 'MIDR_QCOM_KRYO_5XX_GOLD' undeclared (first use in this function); did you mean 'MIDR_QCOM_KRYO_4XX_GOLD'?
     872 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/cputype.h:251:26: note: in definition of macro 'MIDR_RANGE'
     251 |                 .model = m,                                     \
         |                          ^
   arch/arm64/kernel/proton-pack.c:872:25: note: in expansion of macro 'MIDR_ALL_VERSIONS'
     872 |                         MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
         |                         ^~~~~~~~~~~~~~~~~

vim +863 arch/arm64/kernel/proton-pack.c

843
844 /*
845 * This must be called with SCOPE_LOCAL_CPU for each type of CPU, before any
846 * SCOPE_SYSTEM call will give the right answer.
847 */
848 u8 spectre_bhb_loop_affected(int scope)
849 {
850 u8 k = 0;
851 static u8 max_bhb_k;
852
853 if (scope == SCOPE_LOCAL_CPU) {
854 static const struct midr_range spectre_bhb_k32_list[] = {
855 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78),
856 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE),
857 MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C),
858 MIDR_ALL_VERSIONS(MIDR_CORTEX_X1),
859 MIDR_ALL_VERSIONS(MIDR_CORTEX_A710),
860 MIDR_ALL_VERSIONS(MIDR_CORTEX_X2),
861 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
862 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1),

 > 863				MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_GOLD),
 > 864				MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_6XX_PRIME),

865 {},
866 };
867 static const struct midr_range spectre_bhb_k24_list[] = {
868 MIDR_ALL_VERSIONS(MIDR_CORTEX_A76),
869 MIDR_ALL_VERSIONS(MIDR_CORTEX_A77),
870 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1),
871 MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD),
872 MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_5XX_GOLD),
873 {},
874 };
875 static const struct midr_range spectre_bhb_k11_list[] = {
876 MIDR_ALL_VERSIONS(MIDR_AMPERE1),
877 {},
878 };
879 static const struct midr_range spectre_bhb_k8_list[] = {
880 MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
881 MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
882 {},
883 };
884
885 if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list))
886 k = 32;
887 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list))
888 k = 24;
889 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list))
890 k = 11;
891 else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list))
892 k = 8;
893
894 max_bhb_k = max(max_bhb_k, k);
895 } else {
896 k = max_bhb_k;
897 }
898
899 return k;
900 }
901

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#21 lore raw
In reply to Douglas Anderson

Hi Doug,

Quoted 18 lines · Douglas Anderson

Since Qualcomm CPUs are all derivatives of ARM cores they all have unique MIDR values. This means that the tables listing necessary Spectre mitigations need special entries for them. However, those entries are not present and that means that some Spectre mitigations are lacking for Qualcomm CPUs.

I've made an attempt at **GUESSING** what the right patches should be to enable mitigations for Qualcomm CPUs. This is mostly me searching the web to figure out what ARM cores various Qualcomm cores are based off of.

These patches get more and more sketchy as the series progresses and I have noted that the later patces DON'T EVEN COMPILE. I have included them to make it obvious that I think these cores are affected even if I don't have all the right information to mitigate them. Hopefully Qualcomm can come and fix this mess for me.

Quoted 3 lines

I'll note that I am certainly no expert on Spectre. Mostly I ended up here running lscpu on a device and noticing that it thought that it wasn't affected by Spectre v2 when I thought it was.

Whilst only Qualcomm can say definitively whether or not they are affected (and what values of 'k' are required for the loop-based workarounds), I can't help but wonder whether the current mitigation code is structured the wrong way around in this case.

It looks to me like we don't have a way to identify a "vulnerable" CPU for Spectre-BHB; either a CPU has some sort of mitigation or it's unaffected. That means that there's very little incentive for vendors to add their CPUs to one of the lists -- if they do nothing, userspace is told that everything is golden and they don't pay the performance hit of a workaround!

So I think we should consider turning this on its head and assume that CPUs we don't know about are vulnerable, having a list of unaffected cores that predate the introduction of CSV2.3 which can be queried by is_spectre_bhb_affected(). We can do that without the assistance of the CPU vendors.

Does that make sense, or did I miss something?

Will

#22 lore raw

Hi,

Quoted 38 lines · Will Deacon

Hi Doug,

Quoted 18 lines · Douglas Anderson

Since Qualcomm CPUs are all derivatives of ARM cores they all have unique MIDR values. This means that the tables listing necessary Spectre mitigations need special entries for them. However, those entries are not present and that means that some Spectre mitigations are lacking for Qualcomm CPUs.

I've made an attempt at **GUESSING** what the right patches should be to enable mitigations for Qualcomm CPUs. This is mostly me searching the web to figure out what ARM cores various Qualcomm cores are based off of.

These patches get more and more sketchy as the series progresses and I have noted that the later patces DON'T EVEN COMPILE. I have included them to make it obvious that I think these cores are affected even if I don't have all the right information to mitigate them. Hopefully Qualcomm can come and fix this mess for me.

Quoted 3 lines

I'll note that I am certainly no expert on Spectre. Mostly I ended up here running lscpu on a device and noticing that it thought that it wasn't affected by Spectre v2 when I thought it was.

Whilst only Qualcomm can say definitively whether or not they are affected (and what values of 'k' are required for the loop-based workarounds), I can't help but wonder whether the current mitigation code is structured the wrong way around in this case.

It looks to me like we don't have a way to identify a "vulnerable" CPU for Spectre-BHB; either a CPU has some sort of mitigation or it's unaffected. That means that there's very little incentive for vendors to add their CPUs to one of the lists -- if they do nothing, userspace is told that everything is golden and they don't pay the performance hit of a workaround!

Quoted 7 lines

So I think we should consider turning this on its head and assume that CPUs we don't know about are vulnerable, having a list of unaffected cores that predate the introduction of CSV2.3 which can be queried by is_spectre_bhb_affected(). We can do that without the assistance of the CPU vendors.

Does that make sense, or did I miss something?

It makes sense to me. I'm not sure I'd be the best person to actually implement that, though. Maybe someone CCed on this thread could take a stab at it? It seems like folks from ARM would know the most about the various mitigations and which pre-CSV2.3 cores were safe.

-Doug

maintainer
#23 lore raw
Quoted 42 lines · Doug Anderson
Quoted 41 lines · Will Deacon
Quoted 18 lines · Douglas Anderson

Since Qualcomm CPUs are all derivatives of ARM cores they all have unique MIDR values. This means that the tables listing necessary Spectre mitigations need special entries for them. However, those entries are not present and that means that some Spectre mitigations are lacking for Qualcomm CPUs.

I've made an attempt at **GUESSING** what the right patches should be to enable mitigations for Qualcomm CPUs. This is mostly me searching the web to figure out what ARM cores various Qualcomm cores are based off of.

These patches get more and more sketchy as the series progresses and I have noted that the later patces DON'T EVEN COMPILE. I have included them to make it obvious that I think these cores are affected even if I don't have all the right information to mitigate them. Hopefully Qualcomm can come and fix this mess for me.

Quoted 3 lines

I'll note that I am certainly no expert on Spectre. Mostly I ended up here running lscpu on a device and noticing that it thought that it wasn't affected by Spectre v2 when I thought it was.

Whilst only Qualcomm can say definitively whether or not they are affected (and what values of 'k' are required for the loop-based workarounds), I can't help but wonder whether the current mitigation code is structured the wrong way around in this case.

It looks to me like we don't have a way to identify a "vulnerable" CPU for Spectre-BHB; either a CPU has some sort of mitigation or it's unaffected. That means that there's very little incentive for vendors to add their CPUs to one of the lists -- if they do nothing, userspace is told that everything is golden and they don't pay the performance hit of a workaround!

So I think we should consider turning this on its head and assume that CPUs we don't know about are vulnerable, having a list of unaffected cores that predate the introduction of CSV2.3 which can be queried by is_spectre_bhb_affected(). We can do that without the assistance of the CPU vendors.

Quoted 6 lines
Quoted 1 line

Does that make sense, or did I miss something?

It makes sense to me. I'm not sure I'd be the best person to actually implement that, though. Maybe someone CCed on this thread could take a stab at it? It seems like folks from ARM would know the most about the various mitigations and which pre-CSV2.3 cores were safe.

I think we could start with an empty list tbh. If you take a stab at it, I'm happy to review it. Folks with knowledge about the specific CPUs can send patches on top.

Will