From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH v15 2/3] IOMMU: add domain crash logic Date: Fri, 08 Jul 2016 00:45:13 -0600 Message-ID: <577F681902000078000FC752@prv-mh.provo.novell.com> References: <577F66BC02000078000FC743@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE2D4C7E9.1__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLPXH-00044T-Fs for xen-devel@lists.xenproject.org; Fri, 08 Jul 2016 06:45:15 +0000 In-Reply-To: <577F66BC02000078000FC743@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Kevin Tian , Feng Wu List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartE2D4C7E9.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline From: Quan Xu 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 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -318,21 +318,47 @@ int iommu_iotlb_flush(struct domain *d, unsigned int page_count) { const struct domain_iommu *hd =3D dom_iommu(d); + int rc; =20 if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_f= lush ) return 0; =20 - return hd->platform_ops->iotlb_flush(d, gfn, page_count); + rc =3D 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; } =20 int iommu_iotlb_flush_all(struct domain *d) { const struct domain_iommu *hd =3D dom_iommu(d); + int rc; =20 if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_f= lush_all ) return 0; =20 - return hd->platform_ops->iotlb_flush_all(d); + rc =3D 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; } =20 int __init iommu_setup(void) --- 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, u6 } } =20 + 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; } =20 --=__PartE2D4C7E9.1__= Content-Type: text/plain; name="IOMMU-crash-guest-upon-flush-failure.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="IOMMU-crash-guest-upon-flush-failure.patch" IOMMU: add domain crash logic=0A=0AFrom: Quan Xu =0A=0AA= dd domain crash logic to the generic IOMMU layer to benefit=0Aall = platforms.=0A=0ANo spamming of the log can occur. For DomU, we avoid = logging any=0Amessage for already dying domains. For Dom0, that'll still = be more=0Averbose than we'd really like, but it at least wouldn't = outright=0Aflood the console.=0A=0ASigned-off-by: Quan Xu =0AAcked-by: Kevin Tian =0AReviewed-by: Jan = Beulich =0A=0A--- a/xen/drivers/passthrough/iommu.c=0A++= + b/xen/drivers/passthrough/iommu.c=0A@@ -318,21 +318,47 @@ int iommu_iotlb= _flush(struct domain *d,=0A unsigned int page_count)= =0A {=0A const struct domain_iommu *hd =3D dom_iommu(d);=0A+ int = rc;=0A =0A if ( !iommu_enabled || !hd->platform_ops || !hd->platform_op= s->iotlb_flush )=0A return 0;=0A =0A- return hd->platform_ops->i= otlb_flush(d, gfn, page_count);=0A+ rc =3D hd->platform_ops->iotlb_flush= (d, gfn, page_count);=0A+ if ( unlikely(rc) )=0A+ {=0A+ if ( = !d->is_shutting_down && printk_ratelimit() )=0A+ printk(XENLOG_E= RR=0A+ "d%d: IOMMU IOTLB flush failed: %d, gfn %#lx, = page count %u\n",=0A+ d->domain_id, rc, gfn, page_count);= =0A+=0A+ if ( !is_hardware_domain(d) )=0A+ domain_crash(d= );=0A+ }=0A+=0A+ return rc;=0A }=0A =0A int iommu_iotlb_flush_all(str= uct domain *d)=0A {=0A const struct domain_iommu *hd =3D dom_iommu(d);= =0A+ int rc;=0A =0A if ( !iommu_enabled || !hd->platform_ops || = !hd->platform_ops->iotlb_flush_all )=0A return 0;=0A =0A- = return hd->platform_ops->iotlb_flush_all(d);=0A+ rc =3D hd->platform_ops= ->iotlb_flush_all(d);=0A+ if ( unlikely(rc) )=0A+ {=0A+ if ( = !d->is_shutting_down && printk_ratelimit() )=0A+ printk(XENLOG_E= RR=0A+ "d%d: IOMMU IOTLB flush all failed: %d\n",=0A+ = d->domain_id, rc);=0A+=0A+ if ( !is_hardware_domain(d= ) )=0A+ domain_crash(d);=0A+ }=0A+=0A+ return rc;=0A }=0A = =0A int __init iommu_setup(void)=0A--- a/xen/drivers/passthrough/vtd/iommu.= c=0A+++ b/xen/drivers/passthrough/vtd/iommu.c=0A@@ -1848,6 +1848,17 @@ int = iommu_pte_flush(struct domain *d, u6=0A }=0A }=0A =0A+ if ( = unlikely(rc) )=0A+ {=0A+ if ( !d->is_shutting_down && printk_rate= limit() )=0A+ printk(XENLOG_ERR VTDPREFIX=0A+ = " d%d: IOMMU pages flush failed: %d\n",=0A+ d->domain_id,= rc);=0A+=0A+ if ( !is_hardware_domain(d) )=0A+ = domain_crash(d);=0A+ }=0A+=0A return rc;=0A }=0A =0A --=__PartE2D4C7E9.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__PartE2D4C7E9.1__=--