virt-host-validate: Detect SMMU presence on ARMs by parsing IORT table

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: 2c13a2a7c9
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>
This commit is contained in:
Michal Privoznik 2023-04-05 10:57:45 +02:00
parent fc216db4fb
commit d335f49c70

View 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,