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

Re: [Xen-devel] [PATCH v4 02/10] IOMMU: handle IOMMU mapping and unmapping failures



On May 12, 2016 11:06 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
> >>> On 12.05.16 at 16:28, <quan.xu@xxxxxxxxx> wrote:
> > On May 10, 2016 2:54 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
> >> >>> On 10.05.16 at 05:41, <quan.xu@xxxxxxxxx> wrote:
> >> > On May 10, 2016 12:14 AM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
> >> >> >>> On 06.05.16 at 10:54, <quan.xu@xxxxxxxxx> wrote:

Jan,

Try it again, I hope I have got it. If not, could you write some sample code 
for me as an exception? :)

--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -240,21 +240,63 @@ int iommu_map_page(struct domain *d, unsigned long gfn, 
unsigned long mfn,
                    unsigned int flags)
 {
     const struct domain_iommu *hd = dom_iommu(d);
+    static int printed = 0;
+    int rc;

     if ( !iommu_enabled || !hd->platform_ops )
         return 0;

-    return hd->platform_ops->map_page(d, gfn, mfn, flags);
+    rc = hd->platform_ops->map_page(d, gfn, mfn, flags);
+
+    if ( unlikely(rc) )
+    {
+        if ( is_hardware_domain(d) )
+        {
+            if ( !printed )
+            {
+                printk(XENLOG_ERR
+                       "d%d: IOMMU mapping gfn %#lx mfn %#lx failed %d.",
+                       d->domain_id, gfn, mfn, rc);
+
+                printed = 1;
+            }
+        }
+        else
+            domain_crash(d);
+    }
+
+    return rc;
 }

 int iommu_unmap_page(struct domain *d, unsigned long gfn)
 {
     const struct domain_iommu *hd = dom_iommu(d);
+    static int printed = 0;
+    int rc;

     if ( !iommu_enabled || !hd->platform_ops )
         return 0;

-    return hd->platform_ops->unmap_page(d, gfn);
+    rc = hd->platform_ops->unmap_page(d, gfn);
+
+    if ( unlikely(rc) )
+    {
+        if ( is_hardware_domain(d) )
+        {
+            if ( !printed )
+            {
+                printk(XENLOG_ERR
+                       "d%d: IOMMU unmapping gfn %#lx failed %d.",
+                       d->domain_id, gfn, rc);
+
+                printed = 1;
+            }
+        }
+        else
+            domain_crash(d);
+    }
+
+    return rc;
 }


Thanks again!!
Quan

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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