diff mbox

[v12,5/6] IOMMU: move the domain crash logic up to the generic IOMMU layer

Message ID 1466747518-54402-6-git-send-email-quan.xu@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Quan Xu June 24, 2016, 5:51 a.m. UTC
From: Quan Xu <quan.xu@intel.com>

Signed-off-by: Quan Xu <quan.xu@intel.com>

CC: Julien Grall <julien.grall@arm.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Feng Wu <feng.wu@intel.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 xen/drivers/passthrough/iommu.c     | 30 ++++++++++++++++++++++++++++--
 xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

Comments

Tian, Kevin June 24, 2016, 11:48 a.m. UTC | #1
> From: Xu, Quan
> Sent: Friday, June 24, 2016 1:52 PM
> 
> From: Quan Xu <quan.xu@intel.com>
> 
> Signed-off-by: Quan Xu <quan.xu@intel.com>
> 
> CC: Julien Grall <julien.grall@arm.com>
> CC: Kevin Tian <kevin.tian@intel.com>
> CC: Feng Wu <feng.wu@intel.com>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>  xen/drivers/passthrough/iommu.c     | 30
> ++++++++++++++++++++++++++++--
>  xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++
>  2 files changed, 39 insertions(+), 2 deletions(-)

when you say "moving the logic up", I don't see any lines being
deleted. Looks you are just "adding the domain crash logic"?
Quan Xu June 26, 2016, 8:58 a.m. UTC | #2
On June 24, 2016 7:48 PM, Tian, Kevin <kevin.tian@intel.com> wrote:
> > From: Xu, Quan
> > Sent: Friday, June 24, 2016 1:52 PM
> >
> > From: Quan Xu <quan.xu@intel.com>
> >
> > Signed-off-by: Quan Xu <quan.xu@intel.com>
> >
> > CC: Julien Grall <julien.grall@arm.com>
> > CC: Kevin Tian <kevin.tian@intel.com>
> > CC: Feng Wu <feng.wu@intel.com>
> > CC: Jan Beulich <jbeulich@suse.com>
> > CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> > ---
> >  xen/drivers/passthrough/iommu.c     | 30
> > ++++++++++++++++++++++++++++--
> >  xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++
> >  2 files changed, 39 insertions(+), 2 deletions(-)
> 
> when you say "moving the logic up", I don't see any lines being deleted. Looks
> you are just "adding the domain crash logic"?

Yes, it is 'adding'..

Quan
Jan Beulich June 27, 2016, 8:18 a.m. UTC | #3
>>> On 26.06.16 at 10:58, <quan.xu@intel.com> wrote:
> On June 24, 2016 7:48 PM, Tian, Kevin <kevin.tian@intel.com> wrote:
>> > From: Xu, Quan
>> > Sent: Friday, June 24, 2016 1:52 PM
>> >
>> > From: Quan Xu <quan.xu@intel.com>
>> >
>> > Signed-off-by: Quan Xu <quan.xu@intel.com>
>> >
>> > CC: Julien Grall <julien.grall@arm.com>
>> > CC: Kevin Tian <kevin.tian@intel.com>
>> > CC: Feng Wu <feng.wu@intel.com>
>> > CC: Jan Beulich <jbeulich@suse.com>
>> > CC: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> > ---
>> >  xen/drivers/passthrough/iommu.c     | 30
>> > ++++++++++++++++++++++++++++--
>> >  xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++
>> >  2 files changed, 39 insertions(+), 2 deletions(-)
>> 
>> when you say "moving the logic up", I don't see any lines being deleted. Looks
>> you are just "adding the domain crash logic"?
> 
> Yes, it is 'adding'..

But why don't you do here what the title says?

Jan
diff mbox

Patch

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 7656aeb..d793f5d 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -318,21 +318,47 @@  int iommu_iotlb_flush(struct domain *d, unsigned long gfn,
                       unsigned int page_count)
 {
     const struct domain_iommu *hd = dom_iommu(d);
+    int rc;
 
     if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush )
         return 0;
 
-    return hd->platform_ops->iotlb_flush(d, gfn, page_count);
+    rc = hd->platform_ops->iotlb_flush(d, gfn, page_count);
+    if ( unlikely(rc) )
+    {
+        if ( !d->is_shutting_down && printk_ratelimit() )
+            printk(XENLOG_ERR
+                   "d%d: IOMMU IOTLB flush failed: %d, gfn %#lx, page count %u\n",
+                   d->domain_id, rc, gfn, page_count);
+
+        if ( !is_hardware_domain(d) )
+            domain_crash(d);
+    }
+
+    return rc;
 }
 
 int iommu_iotlb_flush_all(struct domain *d)
 {
     const struct domain_iommu *hd = dom_iommu(d);
+    int rc;
 
     if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush_all )
         return 0;
 
-    return hd->platform_ops->iotlb_flush_all(d);
+    rc = hd->platform_ops->iotlb_flush_all(d);
+    if ( unlikely(rc) )
+    {
+        if ( !d->is_shutting_down && printk_ratelimit() )
+            printk(XENLOG_ERR
+                   "d%d: IOMMU IOTLB flush all failed: %d\n",
+                   d->domain_id, rc);
+
+        if ( !is_hardware_domain(d) )
+            domain_crash(d);
+    }
+
+    return rc;
 }
 
 int __init iommu_setup(void)
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 1b0a0f0..82332c8 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1847,6 +1847,17 @@  int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte,
         }
     }
 
+    if ( unlikely(rc) )
+    {
+        if ( !d->is_shutting_down && printk_ratelimit() )
+            printk(XENLOG_ERR VTDPREFIX
+                   " d%d: IOMMU pages flush failed: %d\n",
+                   d->domain_id, rc);
+
+        if ( !is_hardware_domain(d) )
+            domain_crash(d);
+    }
+
     return rc;
 }