diff mbox series

[v2,2/2] target/arm/arm-powerctl: Restrict to ARM cores

Message ID 20250107135739.48324-3-philmd@linaro.org (mailing list archive)
State New
Headers show
Series target/arm/arm-powerctl: Restrict to ARM cores | expand

Commit Message

Philippe Mathieu-Daudé Jan. 7, 2025, 1:57 p.m. UTC
When running on a heterogeneous setup, the CPU_FOREACH()
macro in arm_get_cpu_by_id() iterates on all vCPUs,
regardless they are ARM or not. Check the CPU class type
and skip the non-ARM instances.

Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/arm-powerctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
index 20c70c7d6bb..07529ab096e 100644
--- a/target/arm/arm-powerctl.c
+++ b/target/arm/arm-powerctl.c
@@ -36,9 +36,11 @@  CPUState *arm_get_cpu_by_id(uint64_t id)
     DPRINTF("cpu %" PRId64 "\n", id);
 
     CPU_FOREACH(cpu) {
-        ARMCPU *armcpu = ARM_CPU(cpu);
+        if (!cpu_is_of_type(cpu, TYPE_ARM_CPU)) {
+            continue;
+        }
 
-        if (arm_cpu_mp_affinity(armcpu) == id) {
+        if (arm_cpu_mp_affinity((ARMCPU *)cpu) == id) {
             return cpu;
         }
     }