Skip to contentSkip to conversation

libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled

PATCH In review Paul Durrant 2 participants 2 messages Jun 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled

From: Paul Durrant <[email protected]>

Commit babde47a "introduce a 'passthrough' configuration option to xl.cfg..." added a check to xl_parse.c:parse_config_data() to make sure that an IOMMU was present and enabled in the system before allowing devices to be passed through to a guest. This check was then subsequently moved into libxl_create.c:libxl__domain_config_setdefault() by commit ad011ad0 "libxl/xl:
Overhaul passthrough setting logic".

Prior to this check being added, it was possible (although not in any way safe or supported) to pass devices through to a PV guest without an IOMMU being enabled in the system. This patch relaxes the check for PV guests to restore that possibility, emitting a warning instead.

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>A
Cc: Anthony PERARD <[email protected]>

This patch ought to be in 4.14 as it as very obvious change, restoring lost functionality that has affected a user.

---
 tools/libxl/libxl_create.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tools/libxl/libxl_create.c +8 -4
index 2814818e34..f1d17cfb87 100644
@@ -1104,10 +1104,14 @@ int libxl__domain_config_setdefault(libxl__gc *gc,
 
     bool iommu_enabled = physinfo.cap_hvm_directio;
     if (c_info->passthrough != LIBXL_PASSTHROUGH_DISABLED && !iommu_enabled) {
-        LOGD(ERROR, domid,
-             "passthrough not supported on this platform\n");
-        ret = ERROR_INVAL;
-        goto error_out;
+        if (c_info->type != LIBXL_DOMAIN_TYPE_PV) {
+            LOGD(ERROR, domid,
+                 "passthrough not supported on this platform\n");
+            ret = ERROR_INVAL;
+            goto error_out;
+        }
+        LOGD(WARN, domid,
+             "passthrough is enabled but IOMMU is not present/enabled\n");
     }
 
     if (c_info->passthrough == LIBXL_PASSTHROUGH_DISABLED && need_pt) {
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw

Paul Durrant writes ("[PATCH for 4.14] libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled"):

Quoted 9 lines

From: Paul Durrant <[email protected]>

Commit babde47a "introduce a 'passthrough' configuration option to xl.cfg..." added a check to xl_parse.c:parse_config_data() to make sure that an IOMMU was present and enabled in the system before allowing devices to be passed through to a guest. This check was then subsequently moved into libxl_create.c:libxl__domain_config_setdefault() by commit ad011ad0 "libxl/xl:
Overhaul passthrough setting logic".

Quoted 4 lines

Prior to this check being added, it was possible (although not in any way safe or supported) to pass devices through to a PV guest without an IOMMU being enabled in the system. This patch relaxes the check for PV guests to restore that possibility, emitting a warning instead.

Thanks.

I think this patch could have

Patrik, if we put your credit in like this it will be permanently recorded in our git history, as part of our code traceability etc. Please let us know what you would prefer.

Quoted 8 lines

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>A
Cc: Anthony PERARD <[email protected]>

This patch ought to be in 4.14 as it as very obvious change, restoring lost functionality that has affected a user.

Thanks. I'll take that as a release-ack :-).

Also, I will add this tag too when I commit this:

Backport: 4.13+

Ian.