diff mbox series

[v3,26/26] tests/functional: Expand Aarch64 SMMU tests to run on HVF accelerator

Message ID 20250623121845.7214-27-philmd@linaro.org
State New
Headers show
Series arm: Fixes and preparatory cleanups for split-accel | expand

Commit Message

Philippe Mathieu-Daudé June 23, 2025, 12:18 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tests/functional/test_aarch64_smmu.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Thomas Huth June 23, 2025, 1:01 p.m. UTC | #1
On 23/06/2025 14.18, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tests/functional/test_aarch64_smmu.py | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/functional/test_aarch64_smmu.py b/tests/functional/test_aarch64_smmu.py
> index c65d0f28178..e0f4a922176 100755
> --- a/tests/functional/test_aarch64_smmu.py
> +++ b/tests/functional/test_aarch64_smmu.py
> @@ -17,7 +17,7 @@
>   
>   from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
>   from qemu_test import BUILD_DIR
> -from qemu.utils import kvm_available
> +from qemu.utils import kvm_available, hvf_available
>   
>   
>   class SMMU(LinuxKernelTest):
> @@ -45,11 +45,17 @@ def set_up_boot(self, path):
>           self.vm.add_args('-device', 'virtio-net,netdev=n1' + self.IOMMU_ADDON)
>   
>       def common_vm_setup(self, kernel, initrd, disk):
> -        self.require_accelerator("kvm")
> +        if hvf_available(self.qemu_bin):
> +            accel = "hvf"
> +        elif kvm_available(self.qemu_bin):
> +            accel = "kvm"
> +        else:
> +            self.skipTest("Neither HVF nor KVM accelerator is available")
> +        self.require_accelerator(accel)
>           self.require_netdev('user')
>           self.set_machine("virt")
>           self.vm.add_args('-m', '1G')
> -        self.vm.add_args("-accel", "kvm")
> +        self.vm.add_args("-accel", accel)
>           self.vm.add_args("-cpu", "host")
>           self.vm.add_args("-machine", "iommu=smmuv3")
>           self.vm.add_args("-d", "guest_errors")

Reviewed-by: Thomas Huth <thuth@redhat.com>
Alex Bennée June 23, 2025, 3:04 p.m. UTC | #2
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  tests/functional/test_aarch64_smmu.py | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/tests/functional/test_aarch64_smmu.py b/tests/functional/test_aarch64_smmu.py
> index c65d0f28178..e0f4a922176 100755
> --- a/tests/functional/test_aarch64_smmu.py
> +++ b/tests/functional/test_aarch64_smmu.py
> @@ -17,7 +17,7 @@
>  
>  from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
>  from qemu_test import BUILD_DIR
> -from qemu.utils import kvm_available
> +from qemu.utils import kvm_available, hvf_available
>  
>  
>  class SMMU(LinuxKernelTest):
> @@ -45,11 +45,17 @@ def set_up_boot(self, path):
>          self.vm.add_args('-device', 'virtio-net,netdev=n1' + self.IOMMU_ADDON)
>  
>      def common_vm_setup(self, kernel, initrd, disk):
> -        self.require_accelerator("kvm")
> +        if hvf_available(self.qemu_bin):
> +            accel = "hvf"
> +        elif kvm_available(self.qemu_bin):
> +            accel = "kvm"
> +        else:
> +            self.skipTest("Neither HVF nor KVM accelerator is available")
> +        self.require_accelerator(accel)

I think this is fine so:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

However I wonder if something like:

        hwaccel = self.require_hw_accelerator() 

Could fetch the appropriate platform accelerator for use in -accel bellow?

>          self.require_netdev('user')
>          self.set_machine("virt")
>          self.vm.add_args('-m', '1G')
> -        self.vm.add_args("-accel", "kvm")
> +        self.vm.add_args("-accel", accel)
>          self.vm.add_args("-cpu", "host")
>          self.vm.add_args("-machine", "iommu=smmuv3")
>          self.vm.add_args("-d", "guest_errors")
Philippe Mathieu-Daudé June 23, 2025, 3:18 p.m. UTC | #3
On 23/6/25 17:04, Alex Bennée wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   tests/functional/test_aarch64_smmu.py | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/functional/test_aarch64_smmu.py b/tests/functional/test_aarch64_smmu.py
>> index c65d0f28178..e0f4a922176 100755
>> --- a/tests/functional/test_aarch64_smmu.py
>> +++ b/tests/functional/test_aarch64_smmu.py
>> @@ -17,7 +17,7 @@
>>   
>>   from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
>>   from qemu_test import BUILD_DIR
>> -from qemu.utils import kvm_available
>> +from qemu.utils import kvm_available, hvf_available
>>   
>>   
>>   class SMMU(LinuxKernelTest):
>> @@ -45,11 +45,17 @@ def set_up_boot(self, path):
>>           self.vm.add_args('-device', 'virtio-net,netdev=n1' + self.IOMMU_ADDON)
>>   
>>       def common_vm_setup(self, kernel, initrd, disk):
>> -        self.require_accelerator("kvm")
>> +        if hvf_available(self.qemu_bin):
>> +            accel = "hvf"
>> +        elif kvm_available(self.qemu_bin):
>> +            accel = "kvm"
>> +        else:
>> +            self.skipTest("Neither HVF nor KVM accelerator is available")
>> +        self.require_accelerator(accel)
> 
> I think this is fine so:
> 
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

Thanks.

> However I wonder if something like:
> 
>          hwaccel = self.require_hw_accelerator()
> 
> Could fetch the appropriate platform accelerator for use in -accel bellow?

Then we'd need to make it per-host arch, and I'm pretty sure hw
accelerators don't support the same features. So I'd expect a
rather painful experience. WDYT?
Alex Bennée June 23, 2025, 4:01 p.m. UTC | #4
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 23/6/25 17:04, Alex Bennée wrote:
>> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>> 
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>>   tests/functional/test_aarch64_smmu.py | 12 +++++++++---
>>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/tests/functional/test_aarch64_smmu.py b/tests/functional/test_aarch64_smmu.py
>>> index c65d0f28178..e0f4a922176 100755
>>> --- a/tests/functional/test_aarch64_smmu.py
>>> +++ b/tests/functional/test_aarch64_smmu.py
>>> @@ -17,7 +17,7 @@
>>>     from qemu_test import LinuxKernelTest, Asset,
>>> exec_command_and_wait_for_pattern
>>>   from qemu_test import BUILD_DIR
>>> -from qemu.utils import kvm_available
>>> +from qemu.utils import kvm_available, hvf_available
>>>       class SMMU(LinuxKernelTest):
>>> @@ -45,11 +45,17 @@ def set_up_boot(self, path):
>>>           self.vm.add_args('-device', 'virtio-net,netdev=n1' + self.IOMMU_ADDON)
>>>         def common_vm_setup(self, kernel, initrd, disk):
>>> -        self.require_accelerator("kvm")
>>> +        if hvf_available(self.qemu_bin):
>>> +            accel = "hvf"
>>> +        elif kvm_available(self.qemu_bin):
>>> +            accel = "kvm"
>>> +        else:
>>> +            self.skipTest("Neither HVF nor KVM accelerator is available")
>>> +        self.require_accelerator(accel)
>> I think this is fine so:
>> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>
> Thanks.
>
>> However I wonder if something like:
>>          hwaccel = self.require_hw_accelerator()
>> Could fetch the appropriate platform accelerator for use in -accel
>> bellow?
>
> Then we'd need to make it per-host arch, and I'm pretty sure hw
> accelerators don't support the same features. So I'd expect a
> rather painful experience. WDYT?

Aren't the features a function of the machine type rather than the host?
Shouldn't an -M virt machine look the same on TCG, KVM and HVF
regardless of the underlying accelerator?

I guess there are cases like split-irqchip which affect the
implementation but hopefully not the guest view of things.

Do you have an example?
diff mbox series

Patch

diff --git a/tests/functional/test_aarch64_smmu.py b/tests/functional/test_aarch64_smmu.py
index c65d0f28178..e0f4a922176 100755
--- a/tests/functional/test_aarch64_smmu.py
+++ b/tests/functional/test_aarch64_smmu.py
@@ -17,7 +17,7 @@ 
 
 from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
 from qemu_test import BUILD_DIR
-from qemu.utils import kvm_available
+from qemu.utils import kvm_available, hvf_available
 
 
 class SMMU(LinuxKernelTest):
@@ -45,11 +45,17 @@  def set_up_boot(self, path):
         self.vm.add_args('-device', 'virtio-net,netdev=n1' + self.IOMMU_ADDON)
 
     def common_vm_setup(self, kernel, initrd, disk):
-        self.require_accelerator("kvm")
+        if hvf_available(self.qemu_bin):
+            accel = "hvf"
+        elif kvm_available(self.qemu_bin):
+            accel = "kvm"
+        else:
+            self.skipTest("Neither HVF nor KVM accelerator is available")
+        self.require_accelerator(accel)
         self.require_netdev('user')
         self.set_machine("virt")
         self.vm.add_args('-m', '1G')
-        self.vm.add_args("-accel", "kvm")
+        self.vm.add_args("-accel", accel)
         self.vm.add_args("-cpu", "host")
         self.vm.add_args("-machine", "iommu=smmuv3")
         self.vm.add_args("-d", "guest_errors")