Browse Source

target/arm/hvf: Factor hvf_handle_vmexit() out

Factor hvf_handle_vmexit() out of hvf_vcpu_exec().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
pull/307/head
Philippe Mathieu-Daudé 5 months ago
committed by Peter Maydell
parent
commit
4d03dca568
  1. 50
      target/arm/hvf/hvf.c

50
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 = {

Loading…
Cancel
Save