[PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop

Philippe Mathieu-Daudé posted 24 patches 3 days, 4 hours ago
[PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop
Posted by Philippe Mathieu-Daudé 3 days, 4 hours ago
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/hvf/hvf.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 0cfe3066c23..b60efdc1769 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2141,30 +2141,32 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
     int ret;
     hv_return_t r;
 
-    if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
-        hvf_inject_interrupts(cpu)) {
-        return EXCP_INTERRUPT;
-    }
-
     if (cpu->halted) {
         return EXCP_HLT;
     }
 
-    flush_cpu_state(cpu);
+    do {
+        if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
+            hvf_inject_interrupts(cpu)) {
+            return EXCP_INTERRUPT;
+        }
 
-    bql_unlock();
-    r = hv_vcpu_run(cpu->accel->fd);
-    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();
-        /* fall through */
-    default:
-        g_assert_not_reached();
-    }
+        flush_cpu_state(cpu);
+
+        bql_unlock();
+        r = hv_vcpu_run(cpu->accel->fd);
+        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();
+            /* fall through */
+        default:
+            g_assert_not_reached();
+        }
+    } while (ret == 0);
 
     return ret;
 }
-- 
2.51.0


Re: [PATCH 18/24] target/arm/hvf: Keep calling hv_vcpu_run() in loop
Posted by Richard Henderson 3 days, 1 hour ago
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/hvf/hvf.c | 40 +++++++++++++++++++++-------------------
>   1 file changed, 21 insertions(+), 19 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

> 
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 0cfe3066c23..b60efdc1769 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -2141,30 +2141,32 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
>       int ret;
>       hv_return_t r;
>   
> -    if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
> -        hvf_inject_interrupts(cpu)) {
> -        return EXCP_INTERRUPT;
> -    }
> -
>       if (cpu->halted) {
>           return EXCP_HLT;
>       }
>   
> -    flush_cpu_state(cpu);
> +    do {
> +        if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
> +            hvf_inject_interrupts(cpu)) {
> +            return EXCP_INTERRUPT;
> +        }
>   
> -    bql_unlock();
> -    r = hv_vcpu_run(cpu->accel->fd);
> -    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();
> -        /* fall through */
> -    default:
> -        g_assert_not_reached();
> -    }
> +        flush_cpu_state(cpu);
> +
> +        bql_unlock();
> +        r = hv_vcpu_run(cpu->accel->fd);
> +        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();
> +            /* fall through */
> +        default:
> +            g_assert_not_reached();
> +        }
> +    } while (ret == 0);
>   
>       return ret;
>   }
r~