From: Philippe Mathieu-Daudé <[email protected]> Factor hvf_handle_vmexit() out of hvf_vcpu_exec().
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Mads Ynddal <[email protected]> Signed-off-by: Peter Maydell <[email protected]> --- target/arm/hvf/hvf.c | 50 ++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 8553ce6adc2..27c600148f9 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1984,10 +1984,33 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp) return ret; } +static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_exit_t *exit) +{ + ARMCPU *arm_cpu = env_archcpu(cpu_env(cpu)); + int ret = 0; + + switch (exit->reason) { + case HV_EXIT_REASON_EXCEPTION: + hvf_sync_vtimer(cpu); + ret = hvf_handle_exception(cpu, &exit->exception); + break; + case HV_EXIT_REASON_VTIMER_ACTIVATED: + qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1); + cpu->accel->vtimer_masked = true; + break; + case HV_EXIT_REASON_CANCELED: + /* we got kicked, no exit to process */ + break; + default: + g_assert_not_reached(); + } + + return ret; +} + int hvf_arch_vcpu_exec(CPUState *cpu) { - ARMCPU *arm_cpu = ARM_CPU(cpu); - hv_vcpu_exit_t *hvf_exit = cpu->accel->exit; + int ret; hv_return_t r; if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) && @@ -2006,6 +2029,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu) bql_lock(); switch (r) { case HV_SUCCESS: + ret = hvf_handle_vmexit(cpu, cpu->accel->exit); break; case HV_ILLEGAL_GUEST_STATE: trace_hvf_illegal_guest_state(); @@ -2014,27 +2038,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu) g_assert_not_reached(); } - /* handle VMEXIT */ - uint64_t exit_reason = hvf_exit->reason; - - switch (exit_reason) { - case HV_EXIT_REASON_EXCEPTION: - /* This is the main one, handle below. */ - break; - case HV_EXIT_REASON_VTIMER_ACTIVATED: - qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1); - cpu->accel->vtimer_masked = true; - return 0; - case HV_EXIT_REASON_CANCELED: - /* we got kicked, no exit to process */ - return 0; - default: - g_assert_not_reached(); - } - - hvf_sync_vtimer(cpu); - - return hvf_handle_exception(cpu, &hvf_exit->exception); + return ret; } static const VMStateDescription vmstate_hvf_vtimer = { -- 2.43.0
