aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2013-07-01 15:20:28 +0100
committerIan Jackson <Ian.Jackson@eu.citrix.com>2013-07-01 15:20:28 +0100
commit826eb17271d3c647516d9944c47b0779afedea25 (patch)
tree71424308841e6b461b7c366e40c2afb4a0eaf617 /tools/libxl
parentbcb49301c21ed69b4e8c164fa215efe9db30621a (diff)
downloadxen-826eb17271d3c647516d9944c47b0779afedea25.tar.gz
xen-826eb17271d3c647516d9944c47b0779afedea25.tar.bz2
xen-826eb17271d3c647516d9944c47b0779afedea25.zip
libxl: suppress device assignment to HVM guest when there is no IOMMU
This in effect copies similar logic from xend: While there's no way to check whether a device is assigned to a particular guest, XEN_DOMCTL_test_assign_device at least allows checking whether an IOMMU is there and whether a device has been assign to _some_ guest. For the time being, this should be enough to cover for the missing error checking/recovery in other parts of libxl's device assignment paths. There remains a (functionality-, but not security-related) race in that the iommu should be set up earlier, but this is too risky a change for this stage of the 4.3 release. This is a security issue, XSA-61. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/libxl_pci.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 2f9f010cb3..88bf91ebbf 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1036,6 +1036,18 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcide
int num_assigned, i, rc;
int stubdomid = 0;
+ if (libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM) {
+ rc = xc_test_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
+ if (rc) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "PCI device %04x:%02x:%02x.%u %s?",
+ pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func,
+ errno == ENOSYS ? "cannot be assigned - no IOMMU"
+ : "already assigned to a different guest");
+ goto out;
+ }
+ }
+
rc = libxl__device_pci_setdefault(gc, pcidev);
if (rc) goto out;