[PATCH-for-10.2] target/arm/hvf: Break loop if guest halted vCPU during hv_vcpu_run()

Philippe Mathieu-Daudé posted 1 patch 1 week, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251202175146.20331-1-philmd@linaro.org
Maintainers: Alexander Graf <agraf@csgraf.de>, Mads Ynddal <mads@ynddal.dk>, Peter Maydell <peter.maydell@linaro.org>
target/arm/hvf/hvf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH-for-10.2] target/arm/hvf: Break loop if guest halted vCPU during hv_vcpu_run()
Posted by Philippe Mathieu-Daudé 1 week, 4 days ago
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")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/hvf/hvf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index de1e8fb8a05..10ac5559ca1 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -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);
-- 
2.51.0


Re: [PATCH-for-10.2] target/arm/hvf: Break loop if guest halted vCPU during hv_vcpu_run()
Posted by Philippe Mathieu-Daudé 1 week, 3 days ago
On 2/12/25 18:51, Philippe Mathieu-Daudé wrote:
> 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")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   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.