]> xenbits.xensource.com Git - libvirt.git/commitdiff
virt-host-validate: Detect SMMU presence on ARMs by parsing IORT table
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 5 Apr 2023 08:57:45 +0000 (10:57 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 6 Apr 2023 10:48:22 +0000 (12:48 +0200)
In my previous commit v9.2.0-rc1~3 I've made virt-host-validate
to report host IOMMU check pass if IORT table is present. This is
not sufficient though, because IORT describes much more than just
IOMMU (well, it's called SMMU in ARM world). In fact, this can be
seen in previous commit which adds test cases: there are tables
(IORT_virt_aarch64) which does not contain any SMMU records.

But after previous commits, we can parse the table so switch to
that.

Fixes: 2c13a2a7c9c368ea81eccd4ba12d9cf34bdd331b
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2178885
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
tools/virt-host-validate-common.c

index e96986bb484de90170c1a03cb5027f704d5ac20e..c8a23e2e995d1a48dbd0c111065faa0b274780a1 100644 (file)
@@ -26,6 +26,7 @@
 #include <sys/utsname.h>
 #include <sys/stat.h>
 
+#include "viracpi.h"
 #include "viralloc.h"
 #include "vircgroup.h"
 #include "virfile.h"
@@ -389,13 +390,24 @@ int virHostValidateIOMMU(const char *hvname,
         }
         virHostMsgPass();
     } else if (ARCH_IS_ARM(arch)) {
-        if (access("/sys/firmware/acpi/tables/IORT", F_OK) == 0) {
-            virHostMsgPass();
-        } else {
+        if (access("/sys/firmware/acpi/tables/IORT", F_OK) != 0) {
             virHostMsgFail(level,
                            "No ACPI IORT table found, IOMMU not "
                            "supported by this hardware platform");
             return VIR_HOST_VALIDATE_FAILURE(level);
+        } else {
+            rc = virAcpiHasSMMU();
+            if (rc < 0) {
+                virHostMsgFail(level,
+                               "Failed to parse ACPI IORT table");
+                return VIR_HOST_VALIDATE_FAILURE(level);
+            } else if (rc == 0) {
+                virHostMsgFail(level,
+                               "No SMMU found");
+                return VIR_HOST_VALIDATE_FAILURE(level);
+            } else {
+                virHostMsgPass();
+            }
         }
     } else {
         virHostMsgFail(level,