qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
	qemu-devel@nongnu.org, philmd@redhat.com, crosa@redhat.com,
	wainersm@redhat.com
Subject: [PATCH 1/1] avocado_qemu: Add SMMUv3 tests
Date: Thu, 25 Mar 2021 10:57:12 +0100	[thread overview]
Message-ID: <20210325095712.250262-2-eric.auger@redhat.com> (raw)
In-Reply-To: <20210325095712.250262-1-eric.auger@redhat.com>

Add new tests checking the good behavior of the SMMUv3 protecting
2 virtio pci devices (block and net). We check the guest boots and
we are able to install a package. Different guest configs are tested:
standard, passthrough an strict=0. Given the version of the guest
kernel in use (5.3.7 at this moment), range invalidation is not yet
tested. This will be handled separately.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 tests/acceptance/smmu.py | 104 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
 create mode 100644 tests/acceptance/smmu.py

diff --git a/tests/acceptance/smmu.py b/tests/acceptance/smmu.py
new file mode 100644
index 0000000000..65ecac8f1a
--- /dev/null
+++ b/tests/acceptance/smmu.py
@@ -0,0 +1,104 @@
+# SMMUv3 Functional tests
+#
+# Copyright (c) 2021 Red Hat, Inc.
+#
+# Author:
+#  Eric Auger <eric.auger@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+import os
+
+from avocado_qemu import LinuxTest, BUILD_DIR
+from avocado.utils import ssh
+
+class SMMU(LinuxTest):
+
+    KERNEL_COMMON_PARAMS = ("root=UUID=b6950a44-9f3c-4076-a9c2-355e8475b0a7 ro "
+                            "earlyprintk=pl011,0x9000000 ignore_loglevel "
+                            "no_timer_check printk.time=1 rd_NO_PLYMOUTH "
+                            "console=ttyAMA0 ")
+    IOMMU_ADDON = ',iommu_platform=on,disable-modern=off,disable-legacy=on'
+    IMAGE = ("https://archives.fedoraproject.org/pub/archive/fedora/"
+             "linux/releases/31/Everything/aarch64/os/images/pxeboot/")
+    kernel_path = None
+    initrd_path = None
+    kernel_params = None
+
+    def set_up_boot(self):
+        path = self.download_boot()
+        self.vm.add_args('-device', 'virtio-blk-pci,bus=pcie.0,scsi=off,' +
+                         'drive=drv0,id=virtio-disk0,bootindex=1,'
+                         'werror=stop,rerror=stop' + self.IOMMU_ADDON)
+        self.vm.add_args('-drive',
+                         'file=%s,if=none,cache=writethrough,id=drv0' % path)
+
+    def setUp(self):
+        super(SMMU, self).setUp(None, 'virtio-net-pci' + self.IOMMU_ADDON)
+
+    def add_common_args(self):
+        self.vm.add_args("-machine", "virt")
+        self.vm.add_args('-bios', os.path.join(BUILD_DIR, 'pc-bios',
+                                      'edk2-aarch64-code.fd'))
+        self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
+        self.vm.add_args('-object',
+                         'rng-random,id=rng0,filename=/dev/urandom')
+
+    def common_vm_setup(self, custom_kernel=None):
+        self.require_accelerator("kvm")
+        self.add_common_args()
+        self.vm.add_args("-accel", "kvm")
+        self.vm.add_args("-cpu", "host")
+        self.vm.add_args("-machine", "iommu=smmuv3")
+
+        if custom_kernel is None:
+            return
+
+        kernel_url = self.IMAGE + 'vmlinuz'
+        initrd_url = self.IMAGE + 'initrd.img'
+        self.kernel_path = self.fetch_asset(kernel_url)
+        self.initrd_path = self.fetch_asset(initrd_url)
+
+    def run_and_check(self):
+        if self.kernel_path:
+            self.vm.add_args('-kernel', self.kernel_path,
+                             '-append', self.kernel_params,
+                             '-initrd', self.initrd_path)
+        self.launch_and_wait()
+        self.ssh_command('cat /proc/cmdline')
+        self.ssh_command('dnf -y install numactl-devel')
+
+    def test_smmu(self):
+        """
+        :avocado: tags=accel:kvm
+        :avocado: tags=cpu:host
+        :avocado: tags=smmu
+        """
+
+        self.common_vm_setup()
+        self.run_and_check()
+
+    def test_smmu_passthrough(self):
+        """
+        :avocado: tags=accel:kvm
+        :avocado: tags=cpu:host
+        :avocado: tags=smmu
+        """
+        self.common_vm_setup(True)
+
+        self.kernel_params = self.KERNEL_COMMON_PARAMS + 'iommu.passthrough=on'
+
+        self.run_and_check()
+
+    def test_smmu_nostrict(self):
+        """
+        :avocado: tags=accel:kvm
+        :avocado: tags=cpu:host
+        :avocado: tags=smmu
+        """
+        self.common_vm_setup(True)
+
+        self.kernel_params = self.KERNEL_COMMON_PARAMS + 'iommu.strict=0'
+
+        self.run_and_check()
-- 
2.26.2



  reply	other threads:[~2021-03-25 10:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25  9:57 [PATCH 0/1] avocado-qemu: New SMMUv3 tests Eric Auger
2021-03-25  9:57 ` Eric Auger [this message]
2021-03-25 14:36   ` [PATCH 1/1] avocado_qemu: Add " Cleber Rosa
2021-03-25 14:55     ` Auger Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210325095712.250262-2-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=crosa@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).