From: "Jan Beulich" Subject: [PATCH] VT-d: improve fault info logging Date: Thu, 26 Mar 2015 09:55:19 +0000 Message-ID: <5513E597020000780006DCBE@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6E5A2597.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yb4VW-0003jj-2x for xen-devel@lists.xenproject.org; Thu, 26 Mar 2015 09:55:22 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Yang Z Zhang , Kevin Tian 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. --=__Part6E5A2597.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I got repeatedly annoyed by there not getting anything logged by default on VT-d faults (and hence having to tell people to add extra command line options), and hence I think it is time to redo this code: Log basic fault information at guest-warning level (rate limited by default), and show the page walk in verbose rather than only in debug mode. Break up multi-line message so that each gets a proper log level attached, at once splitting out the common part. Also don't log "unknown" faults as interrupt-remapping ones. As a minor cleanup fix the type of the involved "fault_type" variables. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -800,7 +800,8 @@ static const char *intr_remap_fault_reas "Blocked an interrupt request due to source-id verification failure", }; =20 -static const char *iommu_get_fault_reason(u8 fault_reason, int *fault_type= ) +static const char *iommu_get_fault_reason(u8 fault_reason, + enum faulttype *fault_type) { if ( fault_reason >=3D 0x20 && ( fault_reason < 0x20 + ARRAY_SIZE(intr_remap_fault_reasons)) ) @@ -823,35 +824,48 @@ static const char *iommu_get_fault_reaso static int iommu_page_fault_do_one(struct iommu *iommu, int type, u8 fault_reason, u16 source_id, u64 = addr) { - const char *reason; - int fault_type; + const char *reason, *kind; + enum faulttype fault_type; u16 seg =3D iommu->intel->drhd->segment; - reason =3D iommu_get_fault_reason(fault_reason, &fault_type); =20 - if ( fault_type =3D=3D DMA_REMAP ) + reason =3D iommu_get_fault_reason(fault_reason, &fault_type); + switch ( fault_type ) { - INTEL_IOMMU_DEBUG( - "DMAR:[%s] Request device [%04x:%02x:%02x.%u] " - "fault addr %"PRIx64", iommu reg =3D %p\n" - "DMAR:[fault reason %02xh] %s\n", - (type ? "DMA Read" : "DMA Write"), - seg, (source_id >> 8), PCI_SLOT(source_id & 0xFF), - PCI_FUNC(source_id & 0xFF), addr, iommu->reg, - fault_reason, reason); - if (iommu_debug) - print_vtd_entries(iommu, (source_id >> 8), - (source_id & 0xff), (addr >> PAGE_SHIFT)); + case DMA_REMAP: + printk(XENLOG_G_WARNING VTDPREFIX + "DMAR:[%s] Request device [%04x:%02x:%02x.%u] " + "fault addr %"PRIx64", iommu reg =3D %p\n", + (type ? "DMA Read" : "DMA Write"), + seg, PCI_BUS(source_id), PCI_SLOT(source_id), + PCI_FUNC(source_id), addr, iommu->reg); + kind =3D "DMAR"; + break; + case INTR_REMAP: + printk(XENLOG_G_WARNING VTDPREFIX + "INTR-REMAP: Request device [%04x:%02x:%02x.%u] " + "fault index %"PRIx64", iommu reg =3D %p\n", + seg, PCI_BUS(source_id), PCI_SLOT(source_id), + PCI_FUNC(source_id), addr >> 48, iommu->reg); + kind =3D "INTR-REMAP"; + break; + default: + printk(XENLOG_G_WARNING VTDPREFIX + "UNKNOWN: Request device [%04x:%02x:%02x.%u] " + "fault addr %"PRIx64", iommu reg =3D %p\n", + seg, PCI_BUS(source_id), PCI_SLOT(source_id), + PCI_FUNC(source_id), addr, iommu->reg); + kind =3D "UNKNOWN"; + break; } - else - INTEL_IOMMU_DEBUG( - "INTR-REMAP: Request device [%04x:%02x:%02x.%u] " - "fault index %"PRIx64", iommu reg =3D %p\n" - "INTR-REMAP:[fault reason %02xh] %s\n", - seg, (source_id >> 8), PCI_SLOT(source_id & 0xFF), - PCI_FUNC(source_id & 0xFF), addr >> 48, iommu->reg, - fault_reason, reason); - return 0; =20 + gprintk(XENLOG_G_WARNING VTDPREFIX, "%s: reason %02x - %s\n", + kind, fault_reason, reason); + + if ( iommu_verbose && fault_type =3D=3D DMA_REMAP ) + print_vtd_entries(iommu, PCI_BUS(source_id), PCI_DEVFN2(source_id)= , + addr >> PAGE_SHIFT); + + return 0; } =20 static void iommu_fault_status(u32 fault_status) --=__Part6E5A2597.1__= Content-Type: text/plain; name="VT-d-fault-log.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="VT-d-fault-log.patch" VT-d: improve fault info logging=0A=0AI got repeatedly annoyed by there = not getting anything logged by=0Adefault on VT-d faults (and hence having = to tell people to add extra=0Acommand line options), and hence I think it = is time to redo this code:=0ALog basic fault information at guest-warning = level (rate limited by=0Adefault), and show the page walk in verbose = rather than only in debug=0Amode. Break up multi-line message so that each = gets a proper log level=0Aattached, at once splitting out the common part. = Also don't log=0A"unknown" faults as interrupt-remapping ones.=0A=0AAs a = minor cleanup fix the type of the involved "fault_type" variables.=0A=0ASig= ned-off-by: Jan Beulich =0A=0A--- a/xen/drivers/passthro= ugh/vtd/iommu.c=0A+++ b/xen/drivers/passthrough/vtd/iommu.c=0A@@ -800,7 = +800,8 @@ static const char *intr_remap_fault_reas=0A "Blocked an = interrupt request due to source-id verification failure",=0A };=0A = =0A-static const char *iommu_get_fault_reason(u8 fault_reason, int = *fault_type)=0A+static const char *iommu_get_fault_reason(u8 fault_reason,= =0A+ enum faulttype *fault_type)= =0A {=0A if ( fault_reason >=3D 0x20 && ( fault_reason < 0x20 +=0A = ARRAY_SIZE(intr_remap_fault_reasons)) )=0A@@ -823,35 +824,48 = @@ static const char *iommu_get_fault_reaso=0A static int iommu_page_fault_= do_one(struct iommu *iommu, int type,=0A = u8 fault_reason, u16 source_id, u64 addr)=0A {=0A- const char = *reason;=0A- int fault_type;=0A+ const char *reason, *kind;=0A+ = enum faulttype fault_type;=0A u16 seg =3D iommu->intel->drhd->segment;= =0A- reason =3D iommu_get_fault_reason(fault_reason, &fault_type);=0A = =0A- if ( fault_type =3D=3D DMA_REMAP )=0A+ reason =3D iommu_get_faul= t_reason(fault_reason, &fault_type);=0A+ switch ( fault_type )=0A = {=0A- INTEL_IOMMU_DEBUG(=0A- "DMAR:[%s] Request = device [%04x:%02x:%02x.%u] "=0A- "fault addr %"PRIx64", = iommu reg =3D %p\n"=0A- "DMAR:[fault reason %02xh] = %s\n",=0A- (type ? "DMA Read" : "DMA Write"),=0A- = seg, (source_id >> 8), PCI_SLOT(source_id & 0xFF),=0A- = PCI_FUNC(source_id & 0xFF), addr, iommu->reg,=0A- fault_reas= on, reason);=0A- if (iommu_debug)=0A- print_vtd_entries(i= ommu, (source_id >> 8),=0A- (source_id & 0xff), = (addr >> PAGE_SHIFT));=0A+ case DMA_REMAP:=0A+ printk(XENLOG_G_WA= RNING VTDPREFIX=0A+ "DMAR:[%s] Request device [%04x:%02x:%02x= .%u] "=0A+ "fault addr %"PRIx64", iommu reg =3D %p\n",=0A+ = (type ? "DMA Read" : "DMA Write"),=0A+ seg, = PCI_BUS(source_id), PCI_SLOT(source_id),=0A+ PCI_FUNC(source_= id), addr, iommu->reg);=0A+ kind =3D "DMAR";=0A+ break;=0A+ = case INTR_REMAP:=0A+ printk(XENLOG_G_WARNING VTDPREFIX=0A+ = "INTR-REMAP: Request device [%04x:%02x:%02x.%u] "=0A+ = "fault index %"PRIx64", iommu reg =3D %p\n",=0A+ seg, = PCI_BUS(source_id), PCI_SLOT(source_id),=0A+ PCI_FUNC(source_= id), addr >> 48, iommu->reg);=0A+ kind =3D "INTR-REMAP";=0A+ = break;=0A+ default:=0A+ printk(XENLOG_G_WARNING VTDPREFIX=0A+ = "UNKNOWN: Request device [%04x:%02x:%02x.%u] "=0A+ = "fault addr %"PRIx64", iommu reg =3D %p\n",=0A+ seg, = PCI_BUS(source_id), PCI_SLOT(source_id),=0A+ PCI_FUNC(source_= id), addr, iommu->reg);=0A+ kind =3D "UNKNOWN";=0A+ = break;=0A }=0A- else=0A- INTEL_IOMMU_DEBUG(=0A- = "INTR-REMAP: Request device [%04x:%02x:%02x.%u] "=0A- = "fault index %"PRIx64", iommu reg =3D %p\n"=0A- "INTR-REMAP:= [fault reason %02xh] %s\n",=0A- seg, (source_id >> 8), = PCI_SLOT(source_id & 0xFF),=0A- PCI_FUNC(source_id & 0xFF), = addr >> 48, iommu->reg,=0A- fault_reason, reason);=0A- = return 0;=0A =0A+ gprintk(XENLOG_G_WARNING VTDPREFIX, "%s: reason %02x = - %s\n",=0A+ kind, fault_reason, reason);=0A+=0A+ if ( = iommu_verbose && fault_type =3D=3D DMA_REMAP )=0A+ print_vtd_entries= (iommu, PCI_BUS(source_id), PCI_DEVFN2(source_id),=0A+ = addr >> PAGE_SHIFT);=0A+=0A+ return 0;=0A }=0A =0A static void = iommu_fault_status(u32 fault_status)=0A --=__Part6E5A2597.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part6E5A2597.1__=--