From: Quan Xu Date: Fri, 8 Jul 2016 06:45:13 +0000 (-0600) Subject: IOMMU: add domain crash logic X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~759 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ecb38915edbb394bf4d1c46778b844a30baec8c1;p=xen.git IOMMU: add domain crash logic Add domain crash logic to the generic IOMMU layer to benefit all platforms. No spamming of the log can occur. For DomU, we avoid logging any message for already dying domains. For Dom0, that'll still be more verbose than we'd really like, but it at least wouldn't outright flood the console. Signed-off-by: Quan Xu Acked-by: Kevin Tian Reviewed-by: Jan Beulich Tested-by: Quan Xu --- diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 7656aebe35..d793f5de1a 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 1f8f7325b7..ce19362e60 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1848,6 +1848,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; }