Philippe Mathieu-Daudé <[email protected]> writes:
> Hi,
>
> On 10/6/26 18:11, Peter Maydell wrote:
>> From: Alex Bennée <[email protected]>
>> With the advent of WFE and WFI we need to pay closer attention to
>> the
>> reason why the vCPU may be sleeping to figure out if we should wake
>> it up.
>> Create env->halt_reason to track this and then re-order the tests so
>> we:
>> - ignore everything is the vCPU is powered off
>> - wake up if the event_register is set and we were in a WFE
>> - otherwise any IRQ event does wake the vCPU up.
>> Reviewed-by: Richard Henderson <[email protected]>
>> Signed-off-by: Alex Bennée <[email protected]>
>> Message-id: [email protected]
>> Signed-off-by: Peter Maydell <[email protected]>
>> ---
>> target/arm/arm-powerctl.c | 6 +++---
>> target/arm/cpu.c | 40 +++++++++++++++++++++++++++-----------
>> target/arm/cpu.h | 16 +++++++++++++++
>> target/arm/internals.h | 11 +++++++++++
>> target/arm/kvm.c | 5 +++--
>> target/arm/machine.c | 2 +-
>> target/arm/tcg/op_helper.c | 3 +++
>> 7 files changed, 66 insertions(+), 17 deletions(-)
>
> This patch updated TCG and KVM but missed HVF and WHPX:
>
> - target/arm/hvf/hvf.c
> - target/arm/whpx/whpx-all.c
Do they need it if they implement cpus_accel->cpu_thread_is_idle?
>
>
>> diff --git a/target/arm/internals.h b/target/arm/internals.h
>> index 21cbd2b1db..b2035b9417 100644
>> --- a/target/arm/internals.h
>> +++ b/target/arm/internals.h
>> @@ -2063,4 +2063,15 @@ bool arm_cpu_match_cpreg_mig_tolerance(ARMCPU *cpu,
>> uint64_t kvmidx,
>> ARMCPRegMigToleranceType type);
>> +/**
>> + * arm_set_cpu_power_state() - set power state synced with halt_reason
>> + */
>> +static inline void arm_set_cpu_power_state(ARMCPU *cpu, ARMPSCIState state)
>> +{
>> + CPUARMState *env = &cpu->env;
>> +
>> + cpu->power_state = state;
>> + env->halt_reason = state == PSCI_OFF ? HALT_PSCI : NOT_HALTED;
>> +}
>> +
>> #endif
> Why not add/use a getter()?
How do you mean? Add it as a CPUClass API? Seems overkill for what is
currently handled internally by Arm.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro