[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] VT-d: properly reserve DID 0 for caching mode IOMMUs



commit b111a41acd383c42c35707dbb1849d366ca43cce
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Nov 24 11:05:36 2021 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 24 11:05:36 2021 +0100

    VT-d: properly reserve DID 0 for caching mode IOMMUs
    
    Merely setting bit 0 in the bitmap is insufficient, as then Dom0 will
    still have DID 0 allocated to it, because of the zero-filling of
    domid_map[]. Set slot 0 to DOMID_INVALID to keep DID 0 from getting
    used.
    
    Fixes: b9c20c78789f ("VT-d: per-iommu domain-id")
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
---
 xen/drivers/passthrough/vtd/iommu.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c 
b/xen/drivers/passthrough/vtd/iommu.c
index 5de9a73f56..643db07cf0 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1259,16 +1259,19 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd)
     if ( !iommu->domid_bitmap )
         return -ENOMEM;
 
+    iommu->domid_map = xzalloc_array(u16, nr_dom);
+    if ( !iommu->domid_map )
+        return -ENOMEM;
+
     /*
-     * if Caching mode is set, then invalid translations are tagged with
-     * domain id 0, Hence reserve bit 0 for it
+     * If Caching mode is set, then invalid translations are tagged with
+     * domain id 0. Hence reserve bit/slot 0.
      */
     if ( cap_caching_mode(iommu->cap) )
+    {
+        iommu->domid_map[0] = DOMID_INVALID;
         __set_bit(0, iommu->domid_bitmap);
-
-    iommu->domid_map = xzalloc_array(u16, nr_dom);
-    if ( !iommu->domid_map )
-        return -ENOMEM;
+    }
 
     return 0;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.