1 # SMMUv3 Functional tests
3 # Copyright (c) 2021 Red Hat, Inc.
6 # Eric Auger <eric.auger@redhat.com>
8 # This work is licensed under the terms of the GNU GPL, version 2 or
9 # later. See the COPYING file in the top-level directory.
12 from avocado
import skipIf
13 from avocado_qemu
import LinuxTest
, BUILD_DIR
15 @skipIf(os
.getenv('GITLAB_CI'), 'Running on GitLab')
16 class SMMU(LinuxTest
):
18 :avocado: tags=accel:kvm
19 :avocado: tags=cpu:host
20 :avocado: tags=arch:aarch64
21 :avocado: tags=machine:virt
22 :avocado: tags=distro:fedora
26 IOMMU_ADDON
= ',iommu_platform=on,disable-modern=off,disable-legacy=on'
31 def set_up_boot(self
):
32 path
= self
.download_boot()
33 self
.vm
.add_args('-device', 'virtio-blk-pci,bus=pcie.0,scsi=off,' +
34 'drive=drv0,id=virtio-disk0,bootindex=1,'
35 'werror=stop,rerror=stop' + self
.IOMMU_ADDON
)
36 self
.vm
.add_args('-drive',
37 'file=%s,if=none,cache=writethrough,id=drv0' % path
)
40 super(SMMU
, self
).setUp(None, 'virtio-net-pci' + self
.IOMMU_ADDON
)
42 def common_vm_setup(self
, custom_kernel
=False):
43 self
.require_accelerator("kvm")
44 self
.vm
.add_args("-accel", "kvm")
45 self
.vm
.add_args("-cpu", "host")
46 self
.vm
.add_args("-machine", "iommu=smmuv3")
47 self
.vm
.add_args("-d", "guest_errors")
48 self
.vm
.add_args('-bios', os
.path
.join(BUILD_DIR
, 'pc-bios',
49 'edk2-aarch64-code.fd'))
50 self
.vm
.add_args('-device', 'virtio-rng-pci,rng=rng0')
51 self
.vm
.add_args('-object',
52 'rng-random,id=rng0,filename=/dev/urandom')
54 if custom_kernel
is False:
57 kernel_url
= self
.distro
.pxeboot_url
+ 'vmlinuz'
58 initrd_url
= self
.distro
.pxeboot_url
+ 'initrd.img'
59 self
.kernel_path
= self
.fetch_asset(kernel_url
)
60 self
.initrd_path
= self
.fetch_asset(initrd_url
)
62 def run_and_check(self
):
64 self
.vm
.add_args('-kernel', self
.kernel_path
,
65 '-append', self
.kernel_params
,
66 '-initrd', self
.initrd_path
)
67 self
.launch_and_wait()
68 self
.ssh_command('cat /proc/cmdline')
69 self
.ssh_command('dnf -y install numactl-devel')
72 # 5.3 kernel without RIL #
74 def test_smmu_noril(self
):
76 :avocado: tags=smmu_noril
77 :avocado: tags=smmu_noril_tests
78 :avocado: tags=distro_version:31
80 self
.common_vm_setup()
83 def test_smmu_noril_passthrough(self
):
85 :avocado: tags=smmu_noril_passthrough
86 :avocado: tags=smmu_noril_tests
87 :avocado: tags=distro_version:31
89 self
.common_vm_setup(True)
90 self
.kernel_params
= (self
.distro
.default_kernel_params
+
91 ' iommu.passthrough=on')
94 def test_smmu_noril_nostrict(self
):
96 :avocado: tags=smmu_noril_nostrict
97 :avocado: tags=smmu_noril_tests
98 :avocado: tags=distro_version:31
100 self
.common_vm_setup(True)
101 self
.kernel_params
= (self
.distro
.default_kernel_params
+
105 # 5.8 kernel featuring range invalidation
108 def test_smmu_ril(self
):
110 :avocado: tags=smmu_ril
111 :avocado: tags=smmu_ril_tests
112 :avocado: tags=distro_version:33
114 self
.common_vm_setup()
117 def test_smmu_ril_passthrough(self
):
119 :avocado: tags=smmu_ril_passthrough
120 :avocado: tags=smmu_ril_tests
121 :avocado: tags=distro_version:33
123 self
.common_vm_setup(True)
124 self
.kernel_params
= (self
.distro
.default_kernel_params
+
125 ' iommu.passthrough=on')
128 def test_smmu_ril_nostrict(self
):
130 :avocado: tags=smmu_ril_nostrict
131 :avocado: tags=smmu_ril_tests
132 :avocado: tags=distro_version:33
134 self
.common_vm_setup(True)
135 self
.kernel_params
= (self
.distro
.default_kernel_params
+