Skip to contentSkip to conversation

tools/libxl: don't allow IOMMU usage with PoD

PATCH In review Roger Pau Monne 3 participants 3 messages Feb 17, 2022 – Feb 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 tools/libxl: don't allow IOMMU usage with PoD

Prevent libxl from creating guests that attempts to use PoD together with an IOMMU, even if no devices are actually assigned.

While the hypervisor could support using PoD together with an IOMMU as long as no devices are assigned, such usage seems doubtful. There's no guarantee the guest has PoD no longer be active, and thus a later assignment of a PCI device to such domain could fail.

Preventing the usage of PoD together with an IOMMU at guest creation avoids having to add checks for active PoD entries in the device assignment paths.

---
Cc: Jan Beulich <[email protected]>
---
Changes since v2:
- Reword error message.

Changes since v1:
- Reword commit message.

---
 tools/libs/light/libxl_create.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
tools/libs/light/libxl_create.c +7 -7
index d7a40d7550..15ed021f41 100644
@@ -1160,17 +1160,17 @@ int libxl__domain_config_setdefault(libxl__gc *gc,
     pod_enabled = (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV) &&
         (d_config->b_info.target_memkb < d_config->b_info.max_memkb);
 
-    /* We cannot have PoD and PCI device assignment at the same time
-     * for HVM guest. It was reported that IOMMU cannot work with PoD
-     * enabled because it needs to populated entire page table for
-     * guest. To stay on the safe side, we disable PCI device
-     * assignment when PoD is enabled.
+    /* We don't support having PoD and an IOMMU at the same time for HVM
+     * guests. An active IOMMU cannot work with PoD because it needs a fully
+     * populated page-table. Prevent PoD usage if the domain has an IOMMU
+     * assigned, even if not active.
      */
     if (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV &&
-        d_config->num_pcidevs && pod_enabled) {
+        d_config->c_info.passthrough != LIBXL_PASSTHROUGH_DISABLED &&
+        pod_enabled) {
         ret = ERROR_INVAL;
         LOGD(ERROR, domid,
-             "PCI device assignment for HVM guest failed due to PoD enabled");
+             "IOMMU required for device passthrough but not supported together with PoD");
         goto error_out;
     }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · Roger Pau Monne

Prevent libxl from creating guests that attempts to use PoD together with an IOMMU, even if no devices are actually assigned.

While the hypervisor could support using PoD together with an IOMMU as long as no devices are assigned, such usage seems doubtful. There's no guarantee the guest has PoD no longer be active, and thus a later assignment of a PCI device to such domain could fail.

Quoted 6 lines

Preventing the usage of PoD together with an IOMMU at guest creation avoids having to add checks for active PoD entries in the device assignment paths.

I'm inclined to queue this for the stable trees. Thoughts?

Jan

#2 lore raw
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monne

Prevent libxl from creating guests that attempts to use PoD together with an IOMMU, even if no devices are actually assigned.

While the hypervisor could support using PoD together with an IOMMU as long as no devices are assigned, such usage seems doubtful. There's no guarantee the guest has PoD no longer be active, and thus a later assignment of a PCI device to such domain could fail.

Quoted 8 lines
Quoted 6 lines

Preventing the usage of PoD together with an IOMMU at guest creation avoids having to add checks for active PoD entries in the device assignment paths.

I'm inclined to queue this for the stable trees. Thoughts?

Yes, I think that sound good.

Thanks,

Signature · 1 line
Anthony PERARD