[PATCH for 4.14] libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled

Paul Durrant posted 1 patch 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20200619073315.8414-1-paul@xen.org
Maintainers: Wei Liu <wl@xen.org>, Ian Jackson <ian.jackson@eu.citrix.com>, Anthony PERARD <anthony.perard@citrix.com>
tools/libxl/libxl_create.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

[PATCH for 4.14] libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled

Posted by Paul Durrant 3 weeks ago
From: Paul Durrant <pdurrant@amazon.com>

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.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wl@xen.org>A
Cc: Anthony PERARD <anthony.perard@citrix.com>

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(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 2814818e34..f1d17cfb87 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -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) {
-- 
2.20.1


Re: [PATCH for 4.14] libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled

Posted by Ian Jackson 3 weeks ago
Paul Durrant writes ("[PATCH for 4.14] libxl: allow passthrough to PV guests regardless of whether IOMMU is enabled"):
> From: Paul Durrant <pdurrant@amazon.com>
> 
> 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.

Thanks.

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

I think this patch could have
  Reported-by: Patrik Horník <patrik@hornik.sk>
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.

> Signed-off-by: Paul Durrant <pdurrant@amazon.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wl@xen.org>A
> Cc: Anthony PERARD <anthony.perard@citrix.com>
> 
> 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.