Skip to contentSkip to conversation

target/arm/hvf: Break loop if guest halted vCPU during hv_vcpu_run()

PATCH-for-10.2 Philippe Mathieu-Daudé 1 participant 2 messages Dec 2, 2025 – Dec 3, 2025

lore
Share & tools
lore
#0 lore raw

Since commit 93ac765076a we try to call hv_vcpu_run() many times in a row, but we missed the guest could have halted a vCPU; if so we need to return to outer loop.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3228
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3230

Fixes 93ac765076a ("target/arm/hvf: Keep calling hv_vcpu_run() in loop")
---
 target/arm/hvf/hvf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/hvf/hvf.c +4 -4
index de1e8fb8a05..10ac5559ca1 100644
@@ -2029,10 +2029,6 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
     int ret;
     hv_return_t r;
 
-    if (cpu->halted) {
-        return EXCP_HLT;
-    }
-
     flush_cpu_state(cpu);
 
     do {
@@ -2041,6 +2037,10 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
             return EXCP_INTERRUPT;
         }
 
+        if (cpu->halted) {
+            return EXCP_HLT;
+        }
+
         bql_unlock();
         cpu_exec_start(cpu);
         r = hv_vcpu_run(cpu->accel->fd);
Signature · 1 line
2.51.0
#1 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé

Since commit 93ac765076a we try to call hv_vcpu_run() many times in a row, but we missed the guest could have halted a vCPU; if so we need to return to outer loop.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3228
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3230

Fixes 93ac765076a ("target/arm/hvf: Keep calling hv_vcpu_run() in loop")
---
  target/arm/hvf/hvf.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

Per https://gitlab.com/qemu-project/qemu/-/issues/3228#note_2928617511,
this doesn't work; so self-NAck.