[PATCH] virt-host-validate: Detect SMMU support on ARMs

Michal Privoznik posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/a1180915807953d2e34b9cd5c35b5ba1d23e2972.1679499831.git.mprivozn@redhat.com
tools/virt-host-validate-common.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] virt-host-validate: Detect SMMU support on ARMs
Posted by Michal Privoznik 1 year, 1 month ago
In vir-host-validate we do two checks related to IOMMU:

  1) hardware support, and
  2) kernel support.

While users are usually interested in the latter, the former also
makes sense. And for the former (hardware support) we have this
huge if-else block for nearly every architecture, except ARM.

Now, IOMMU is called SMMU in ARM world, and while there's
certainly a definitive way of detecting SMMU support (e.g. via
dumping some registers in asm), we can work around this - just
like we do for Intel and AMD - and check for an ACPI table
presence.

In ARM world, there's I/O Remapping Table (IORT) which describes
SMMU capabilities on given host and is exposed in sysfs
(regardless of arm_smmu module).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2178885
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tools/virt-host-validate-common.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index a41bb346d2..49d3c4083b 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -388,6 +388,15 @@ int virHostValidateIOMMU(const char *hvname,
             return VIR_HOST_VALIDATE_FAILURE(VIR_HOST_VALIDATE_NOTE);
         }
         virHostMsgPass();
+    } else if (ARCH_IS_ARM(arch)) {
+        if (access("/sys/firmware/acpi/tables/IORT", F_OK) == 0) {
+            virHostMsgPass();
+        } else {
+            virHostMsgFail(level,
+                           "No ACPI IORT table found, IOMMU not "
+                           "supported by this hardware platform");
+            return VIR_HOST_VALIDATE_FAILURE(level);
+        }
     } else {
         virHostMsgFail(level,
                        "Unknown if this platform has IOMMU support");
-- 
2.39.2
Re: [PATCH] virt-host-validate: Detect SMMU support on ARMs
Posted by Ján Tomko 1 year, 1 month ago
On a Wednesday in 2023, Michal Privoznik wrote:
>In vir-host-validate we do two checks related to IOMMU:
>
>  1) hardware support, and
>  2) kernel support.
>
>While users are usually interested in the latter, the former also
>makes sense. And for the former (hardware support) we have this
>huge if-else block for nearly every architecture, except ARM.
>
>Now, IOMMU is called SMMU in ARM world, and while there's
>certainly a definitive way of detecting SMMU support (e.g. via
>dumping some registers in asm), we can work around this - just
>like we do for Intel and AMD - and check for an ACPI table
>presence.
>
>In ARM world, there's I/O Remapping Table (IORT) which describes
>SMMU capabilities on given host and is exposed in sysfs
>(regardless of arm_smmu module).
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2178885
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> tools/virt-host-validate-common.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano