Factor hvf_handle_vmexit() out of hvf_vcpu_exec().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/hvf/hvf.c | 51 ++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 3db0a8e288c..0cfe3066c23 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2111,10 +2111,34 @@ static int hvf_handle_exception(CPUState *cpu, hv_vcpu_exit_exception_t *excp)
return ret;
}
-int hvf_arch_vcpu_exec(CPUState *cpu)
+/* Must be called by the owning thread */
+static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_exit_t *exit)
{
ARMCPU *arm_cpu = ARM_CPU(cpu);
- hv_vcpu_exit_t *hvf_exit = cpu->accel->exit;
+ 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)
+{
+ int ret;
hv_return_t r;
if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
@@ -2133,6 +2157,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();
@@ -2141,27 +2166,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.51.0