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

Matheus Tavares Bernardino posted 1 patch 2 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/ee6f642af1dab29aaf99f86ac9254ddd25765bf8.1776172276.git.matheus.bernardino@oss.qualcomm.com
Maintainers: Alexander Graf <agraf@csgraf.de>, Peter Maydell <peter.maydell@linaro.org>
target/arm/hvf/hvf.c | 4 ----
1 file changed, 4 deletions(-)
[PATCH v2] accel/hvf: fix double hv_vcpu_destroy() causing teardown error on ARM
Posted by Matheus Tavares Bernardino 2 weeks, 1 day 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

The first hv_vcpu_destroy call covers both x86 and arm. Let's remove the
second one, as it is redundant.

Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
---
v1: https://lore.kernel.org/qemu-devel/70cca2a5cdde3e6531e5c8f1e399e0b584d51ad6.1776096073.git.matheus.bernardino@oss.qualcomm.com/

Changed in v2: removed second call instead of first one to avoid
breaking x86 (thanks Philippe!)

 target/arm/hvf/hvf.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 5fc8f6bbbd..2ee653f08e 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1212,10 +1212,6 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu)
 
 void hvf_arch_vcpu_destroy(CPUState *cpu)
 {
-    hv_return_t ret;
-
-    ret = hv_vcpu_destroy(cpu->accel->fd);
-    assert_hvf_ok(ret);
 }
 
 hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
-- 
2.37.2
Re: [PATCH v2] accel/hvf: fix double hv_vcpu_destroy() causing teardown error on ARM
Posted by Pierrick Bouvier 2 weeks ago
On 4/14/2026 6:11 AM, 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
> 
> The first hv_vcpu_destroy call covers both x86 and arm. Let's remove the
> second one, as it is redundant.
> 
> Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
> ---
> v1: https://lore.kernel.org/qemu-devel/70cca2a5cdde3e6531e5c8f1e399e0b584d51ad6.1776096073.git.matheus.bernardino@oss.qualcomm.com/
> 
> Changed in v2: removed second call instead of first one to avoid
> breaking x86 (thanks Philippe!)
> 
>   target/arm/hvf/hvf.c | 4 ----
>   1 file changed, 4 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Re: [PATCH v2] accel/hvf: fix double hv_vcpu_destroy() causing teardown error on ARM
Posted by Philippe Mathieu-Daudé 2 weeks, 1 day ago
On 14/4/26 15:11, 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
> 
> The first hv_vcpu_destroy call covers both x86 and arm. Let's remove the
> second one, as it is redundant.
> 
> Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
> ---
> v1: https://lore.kernel.org/qemu-devel/70cca2a5cdde3e6531e5c8f1e399e0b584d51ad6.1776096073.git.matheus.bernardino@oss.qualcomm.com/
> 
> Changed in v2: removed second call instead of first one to avoid
> breaking x86 (thanks Philippe!)
> 
>   target/arm/hvf/hvf.c | 4 ----
>   1 file changed, 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Re: [PATCH v2] accel/hvf: fix double hv_vcpu_destroy() causing teardown error on ARM
Posted by Philippe Mathieu-Daudé 1 week ago
On 14/4/26 15:23, Philippe Mathieu-Daudé wrote:
> On 14/4/26 15:11, 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
>>
>> The first hv_vcpu_destroy call covers both x86 and arm. Let's remove the
>> second one, as it is redundant.
>>
>> Signed-off-by: Matheus Tavares Bernardino 
>> <matheus.bernardino@oss.qualcomm.com>
>> ---
>> v1: https://lore.kernel.org/qemu- 
>> devel/70cca2a5cdde3e6531e5c8f1e399e0b584d51ad6.1776096073.git.matheus.bernardino@oss.qualcomm.com/
>>
>> Changed in v2: removed second call instead of first one to avoid
>> breaking x86 (thanks Philippe!)
>>
>>   target/arm/hvf/hvf.c | 4 ----
>>   1 file changed, 4 deletions(-)
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>