target/arm/arm-powerctl: Restrict to ARM cores
v2 cover target/arm/arm-powerctl: Restrict to ARM cores
Since v1:
- Factor cpu_is_of_type() out
Philippe Mathieu-Daudé (2):
cpus: Introduce cpu_is_of_type() helper
target/arm/arm-powerctl: Restrict to ARM cores
include/hw/core/cpu.h | 9 +++++++++ cpu-common.c | 5 +++++ target/arm/arm-powerctl.c | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.1
PATCH v2 1/2 cpus: Introduce cpu_is_of_type() helper
Introduce a helper to check whether a vCPU instance is from a certain QOM parent type.
We don't need to use the type-safe QOM cast macros and can directly access the cached CPUClass (see commit 6fbdff87062 "cpu: cache CPUClass in CPUState for hot code paths").
--- include/hw/core/cpu.h | 9 +++++++++ cpu-common.c | 5 +++++ 2 files changed, 14 insertions(+)
include/hw/core/cpu.h +9 -0
@@ -795,6 +795,15 @@ ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);*/ char *cpu_model_from_type (const char *typename); +/** +* cpu_is_of_type: Check if a CPU instance implement a QOM type +* @cpu: The CPU to be added to the list of CPUs. +* @typename: The CPU type. +* +* Returns: %true if @cpu is a QOM child of type @typename. +*/ +bool cpu_is_of_type (CPUState *cpu,const char *typename); +/** * cpu_create: * @typename: The CPU type.
cpu-common.c +5 -0
@@ -455,3 +455,8 @@ void cpu_breakpoint_remove_all(CPUState *cpu, int mask) } } } + +bool cpu_is_of_type (CPUState *cpu,const char *typename) +{ +return !!object_class_dynamic_cast ((ObjectClass *)cpu->cc, typename); +}
Signature · 1 line
2.47.1
PATCH v2 2/2 target/arm/arm-powerctl: Restrict to ARM cores
In reply to Philippe Mathieu-Daudé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.
--- target/arm/arm-powerctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/arm/arm-powerctl.c +4 -2
@@ -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; } }
Signature · 1 line
2.47.1
Quoted 12 lines · Philippe Mathieu-Daudé
Since v1:
- Factorcpu_is_of_type()outPhilippe Mathieu-Daudé (2):
cpus: Introducecpu_is_of_type()helper
target/arm/arm-powerctl: Restrict to ARM coresinclude/hw/core/cpu.h | 9 +++++++++ cpu-common.c | 5 +++++ target/arm/arm-powerctl.c | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-)
r~