[PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value

Philippe Mathieu-Daudé posted 24 patches 3 days, 4 hours ago
[PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value
Posted by Philippe Mathieu-Daudé 3 days, 4 hours ago
hv_vcpus_exit() returns a hv_return_t enum type (defined
in <Hypervisor/hv_error.h>). Assert we succeeded, as we
are not ready to handle any error path.

Suggested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/hvf/hvf.c        | 5 ++++-
 target/arm/hvf/trace-events | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index d67372218de..65ac0bd71aa 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1086,8 +1086,11 @@ int hvf_arch_init_vcpu(CPUState *cpu)
 
 void hvf_kick_vcpu_thread(CPUState *cpu)
 {
+    hv_return_t ret;
+    trace_hvf_kick_vcpu_thread(cpu->cpu_index, cpu->stop);
     cpus_kick_thread(cpu);
-    hv_vcpus_exit(&cpu->accel->fd, 1);
+    ret = hv_vcpus_exit(&cpu->accel->fd, 1);
+    assert_hvf_ok(ret);
 }
 
 static void hvf_raise_exception(CPUState *cpu, uint32_t excp,
diff --git a/target/arm/hvf/trace-events b/target/arm/hvf/trace-events
index b29a995f3d3..538af6e0707 100644
--- a/target/arm/hvf/trace-events
+++ b/target/arm/hvf/trace-events
@@ -12,3 +12,4 @@ hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid
 hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]"
 hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]"
 hvf_illegal_guest_state(void) "HV_ILLEGAL_GUEST_STATE"
+hvf_kick_vcpu_thread(unsigned cpuidx, bool stop) "cpu:%u stop:%u"
-- 
2.51.0


Re: [PATCH 02/24] target/arm/hvf: Check hv_vcpus_exit() returned value
Posted by Richard Henderson 3 days, 2 hours ago
On 9/3/25 12:06, Philippe Mathieu-Daudé wrote:
> hv_vcpus_exit() returns a hv_return_t enum type (defined
> in <Hypervisor/hv_error.h>). Assert we succeeded, as we
> are not ready to handle any error path.
> 
> Suggested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/hvf/hvf.c        | 5 ++++-
>   target/arm/hvf/trace-events | 1 +
>   2 files changed, 5 insertions(+), 1 deletion(-)

Tracing change not mentioned in commit message.
Split to a separate patch?

r~

> 
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index d67372218de..65ac0bd71aa 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -1086,8 +1086,11 @@ int hvf_arch_init_vcpu(CPUState *cpu)
>   
>   void hvf_kick_vcpu_thread(CPUState *cpu)
>   {
> +    hv_return_t ret;
> +    trace_hvf_kick_vcpu_thread(cpu->cpu_index, cpu->stop);
>       cpus_kick_thread(cpu);
> -    hv_vcpus_exit(&cpu->accel->fd, 1);
> +    ret = hv_vcpus_exit(&cpu->accel->fd, 1);
> +    assert_hvf_ok(ret);
>   }
>   
>   static void hvf_raise_exception(CPUState *cpu, uint32_t excp,
> diff --git a/target/arm/hvf/trace-events b/target/arm/hvf/trace-events
> index b29a995f3d3..538af6e0707 100644
> --- a/target/arm/hvf/trace-events
> +++ b/target/arm/hvf/trace-events
> @@ -12,3 +12,4 @@ hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid
>   hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]"
>   hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]"
>   hvf_illegal_guest_state(void) "HV_ILLEGAL_GUEST_STATE"
> +hvf_kick_vcpu_thread(unsigned cpuidx, bool stop) "cpu:%u stop:%u"