xen/arm: fix spurious SMT warning on CPUs with MT=1 encoding convention
PATCH 1/1 xen/arm: fix spurious SMT warning on CPUs with MT=1 encoding convention
From: Peng Fan <[email protected]>
Some ARM processors, such as Cortex-A55, set MPIDR.MT=1 as a topology encoding convention to indicate that Aff0 represents thread IDs, without actually implementing multithreading (SMT). This caused Xen to unconditionally emit a security warning and incur a 3-second boot delay via warning_print() on all such platforms.
Fix the detection by verifying that at least one CPU has a non-zero Aff0 affinity level in its cpu_logical_map entry. A non-zero Aff0 is the only reliable indication that multiple threads share a physical core. Platforms like Cortex-A55 where all CPUs have Aff0=0 will no longer trigger the warning.
--- xen/arch/arm/smpboot.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
xen/arch/arm/smpboot.c +24 -3
@@ -309,9 +309,30 @@ void __init smp_init_cpus(void)"It has implications on the security and stability of the system,\n" "unless the cpu affinity of all domains is specified.\n"); -if ( system_cpuinfo.mpidr.mt ==1 ) -warning_add ("WARNING: MULTITHREADING HAS BEEN DETECTED ON THE PROCESSOR.\n" -"It might impact the security of the system.\n" ); +/* +* MT=1 means Aff0 encodes thread IDs, but some CPUs (e.g. Cortex-A55) +* set MT=1 as a topology encoding convention without implementing SMT. +* Only warn if Aff0 is non-zero for any CPU, indicating real threads. +*/ +if ( system_cpuinfo.mpidr.mt ) + { +unsigned int cpu; +bool real_smt = false; + +for_each_possible_cpu ( cpu ) + { +if (MPIDR_AFFINITY_LEVEL (cpu_logical_map (cpu),0 ) !=0 ) + { + real_smt = true; +break ; + } + } + +if ( real_smt ) +warning_add ("WARNING: MULTITHREADING HAS BEEN DETECTED ON THE PROCESSOR.\n" +"It might impact the security of the system.\n" ); + } + }unsigned int __init smp_get_max_cpus (void )
---
base-commit: a1bb3efd35c2ea04c861f53df602795abb52038a
change-id: 20261204-a55-mt-e5950b5392ef
Best regards,
Signature · 1 line
Peng Fan <[email protected]>
Quoted 3 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Some ARM processors, such as Cortex-A55, set MPIDR.MT=1 as a topology
NIT: Some is underselling. A lot of modern ARM CPUs set MT=1 but do not use SMT. The only CPUs using SMT are Cortex-A65 and Neoverse-E1.
Quoted 6 lines
encoding convention to indicate that Aff0 represents thread IDs, without actually implementing multithreading (SMT). This caused Xen to unconditionally emit a security warning and incur a 3-second boot delay via
warning_print()on all such platforms.Fix the detection by verifying that at least one CPU has a non-zero Aff0
Add "also verifying" so that it's clear that the .MT bit check is still in place
Quoted 4 lines
affinity level in its
cpu_logical_mapentry. A non-zero Aff0 is the only reliable indication that multiple threads share a physical core. Platforms like Cortex-A55 where all CPUs have Aff0=0 will no longer trigger the warning.
A few days ago I mentioned this issue and that is should be fixed while reviewing this patch:
https://lore.kernel.org/xen-devel/[email protected]/
Was this perhaps the input for this patch?
Quoted 16 lines
Signed-off-by Peng Fan <[email protected]>--- xen/arch/arm/smpboot.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)xen/arch/arm/smpboot.c +0
-2@@ -309,9 +309,30 @@ void __init smp_init_cpus(void)"It has implications on the security and stability of the system,\n" "unless the cpu affinity of all domains is specified.\n"); -if ( system_cpuinfo.mpidr.mt ==1 ) - warning_add("WARNING: MULTITHREADING HAS BEEN DETECTED ON THE PROCESSOR.\n"
xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 320
Quoted 10 lines
xen/arch/arm/smpboot.c +9
-1- "It might impact the security of the system.\n"); +/* +* MT=1 means Aff0 encodes thread IDs, but some CPUs (e.g. Cortex-A55) +* set MT=1 as a topology encoding convention without implementing SMT. +* Only warn if Aff0 is non-zero for any CPU, indicating real threads. +*/ +if ( system_cpuinfo.mpidr.mt ) + { +unsigned int cpu; +bool real_smt = false;
Do we need this variable? We could call warning_add and break right away.
xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 322
Quoted 2 lines
xen/arch/arm/smpboot.c +2
-0+ +for_each_possible_cpu ( cpu )
No need for extra spaces. It should be for_each_possible_cpu(cpu).
xen/arch/arm/smpboot.c void __init smp_init_cpus(void) · line 335
Quoted 13 lines
xen/arch/arm/smpboot.c +13
-0+ { +if (MPIDR_AFFINITY_LEVEL (cpu_logical_map (cpu),0 ) !=0 ) + { + real_smt = true; +break ; + } + } + +if ( real_smt ) +warning_add ("WARNING: MULTITHREADING HAS BEEN DETECTED ON THE PROCESSOR.\n" +"It might impact the security of the system.\n" ); + } +
Stray blank line.
Quoted 11 lines
xen/arch/arm/smpboot.c +0
-1}unsigned int __init smp_get_max_cpus (void ) ---base-commit:
a1bb3efd35c2ea04c861f53df602795abb52038a
change-id: 20261204-a55-mt-e5950b5392efBest regards,
Signature · 1 line
Peng Fan <[email protected]>
With the remarks addressed:
~Michal