[PATCH] accel/hvf: fix double hv_vcpu_destroy() causing teardown error

Matheus Tavares Bernardino posted 1 patch 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/70cca2a5cdde3e6531e5c8f1e399e0b584d51ad6.1776096073.git.matheus.bernardino@oss.qualcomm.com
Maintainers: Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>
accel/hvf/hvf-accel-ops.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] accel/hvf: fix double hv_vcpu_destroy() causing teardown error
Posted by Matheus Tavares Bernardino 2 weeks, 2 days ago
The following callstack causes hv_vcpu_destroy() to be called twice,
producing HV_BAD_ARGUMENT on the already-destroyed handler:

hvf_vcpu_destroy
 |
 |_ hv_vcpu_destroy
 |
 |_ hvf_arch_vcpu_destroy
     |
     |_ hv_vcpu_destroy

Let's remove the redundant call at first function.

Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
---
 accel/hvf/hvf-accel-ops.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index b74a5779c3..d1c532f7e0 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -113,9 +113,6 @@ static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
 
 static void hvf_vcpu_destroy(CPUState *cpu)
 {
-    hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
-    assert_hvf_ok(ret);
-
     hvf_arch_vcpu_destroy(cpu);
     g_free(cpu->accel);
     cpu->accel = NULL;
-- 
2.37.2
Re: [PATCH] accel/hvf: fix double hv_vcpu_destroy() causing teardown error
Posted by Philippe Mathieu-Daudé 2 weeks, 2 days ago
Hi Matheus,

On 13/4/26 18:01, Matheus Tavares Bernardino wrote:
> The following callstack causes hv_vcpu_destroy() to be called twice,
> producing HV_BAD_ARGUMENT on the already-destroyed handler:
> 
> hvf_vcpu_destroy
>   |
>   |_ hv_vcpu_destroy
>   |
>   |_ hvf_arch_vcpu_destroy
>       |
>       |_ hv_vcpu_destroy
> 
> Let's remove the redundant call at first function.
> 
> Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
> ---
>   accel/hvf/hvf-accel-ops.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
> index b74a5779c3..d1c532f7e0 100644
> --- a/accel/hvf/hvf-accel-ops.c
> +++ b/accel/hvf/hvf-accel-ops.c
> @@ -113,9 +113,6 @@ static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
>   
>   static void hvf_vcpu_destroy(CPUState *cpu)
>   {
> -    hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
> -    assert_hvf_ok(ret);

That would break x86. I suppose I screwed something in commit
feee55d36a1 ("accel/hvf: Implement hvf_arch_vcpu_destroy"). This
was part of my split-accel work which as of today I flushed out
of my head so don't recall well.

At any rate, better to remove the duplicate call in ARM's
hvf_arch_vcpu_destroy(), WDYT?

>       hvf_arch_vcpu_destroy(cpu);
>       g_free(cpu->accel);
>       cpu->accel = NULL;
Re: [PATCH] accel/hvf: fix double hv_vcpu_destroy() causing teardown error
Posted by Matheus Bernardino 2 weeks, 1 day ago
On Mon, Apr 13, 2026 at 7:06 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Hi Matheus,
>
> On 13/4/26 18:01, Matheus Tavares Bernardino wrote:
>
> > @@ -113,9 +113,6 @@ static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
> >
> >   static void hvf_vcpu_destroy(CPUState *cpu)
> >   {
> > -    hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
> > -    assert_hvf_ok(ret);
>
> That would break x86. I suppose I screwed something in commit
> feee55d36a1 ("accel/hvf: Implement hvf_arch_vcpu_destroy"). This
> was part of my split-accel work which as of today I flushed out
> of my head so don't recall well.
>
> At any rate, better to remove the duplicate call in ARM's
> hvf_arch_vcpu_destroy(), WDYT?

Ah, indeed, I hadn't noticed x86's callstack. Let's do that, I'll send a re-roll