From 6ca499b7916b5ebc1c796af90a124f788729df82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 3 Oct 2025 16:19:24 +0200 Subject: [PATCH] accel/hvf: Have PSCI CPU_SUSPEND halt the vCPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return EXCP_HLT to the main loop. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Akihiko Odaki Message-ID: <20260112103034.65310-15-philmd@linaro.org> --- target/arm/hvf/hvf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index b936098d25..718414cc53 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -301,8 +301,6 @@ void hvf_arm_init_debug(void) #define TMR_CTL_IMASK (1 << 1) #define TMR_CTL_ISTATUS (1 << 2) -static int hvf_wfi(CPUState *cpu); - static uint32_t chosen_ipa_bit_size; typedef struct HVFVTimer { @@ -1008,7 +1006,7 @@ static void hvf_psci_cpu_off(ARMCPU *arm_cpu) * Returns 0 on success * -1 when the PSCI call is unknown, */ -static bool hvf_handle_psci_call(CPUState *cpu) +static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret) { ARMCPU *arm_cpu = ARM_CPU(cpu); CPUARMState *env = &arm_cpu->env; @@ -1091,9 +1089,8 @@ static bool hvf_handle_psci_call(CPUState *cpu) ret = QEMU_PSCI_RET_INVALID_PARAMS; break; } - /* Powerdown is not supported, we always go into WFI */ env->xregs[0] = 0; - hvf_wfi(cpu); + *excp_ret = EXCP_HLT; break; case QEMU_PSCI_0_1_FN_MIGRATE: case QEMU_PSCI_0_2_FN_MIGRATE: @@ -1910,7 +1907,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp) cpu_synchronize_state(cpu); if (arm_cpu->psci_conduit == QEMU_PSCI_CONDUIT_HVC) { /* Do NOT advance $pc for HVC */ - if (!hvf_handle_psci_call(cpu)) { + if (!hvf_handle_psci_call(cpu, &ret)) { trace_hvf_unknown_hvc(env->pc, env->xregs[0]); /* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */ env->xregs[0] = -1; @@ -1927,7 +1924,7 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp) /* Secure Monitor Call exception, we need to advance $pc */ advance_pc = true; - if (!hvf_handle_psci_call(cpu)) { + if (!hvf_handle_psci_call(cpu, &ret)) { trace_hvf_unknown_smc(env->xregs[0]); /* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */ env->xregs[0] = -1;