From patchwork Tue Nov 26 15:01:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11262617 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F8116C1 for ; Tue, 26 Nov 2019 15:02:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5CFEE2071A for ; Tue, 26 Nov 2019 15:02:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="SB9c0uTC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CFEE2071A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZcLI-0004fW-5I; Tue, 26 Nov 2019 15:01:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZcLH-0004fM-CB for xen-devel@lists.xenproject.org; Tue, 26 Nov 2019 15:01:27 +0000 X-Inumbo-ID: 9aa26f22-105d-11ea-b155-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9aa26f22-105d-11ea-b155-bc764e2007e4; Tue, 26 Nov 2019 15:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1574780480; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HNlKx18vjebKMmIi8xn45ZqgWiMS9KAO5NsQ8yvRUkc=; b=SB9c0uTCKYO7DCobWLrVpCJiAlbDQ+ESfGZRfk5ejDvOTogFM4NTqX0B uP8DI7B1MPRf0BFvG8bwgBxJu++f/Wxy1gVFFGURtqGdg9vHV3FHh6nHU g7PhOIkvILvlEXhDeTGU8CNVMMRt10tCPDRQPukpcw9Vw166c8cO1rcA3 k=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: UxL7Gm3yInMccSq9i1bCAzHmOBBj0ZXVkp5VvejHpkPkeDeX9tyd+jxtO2doxORe+7MLBsEHCt SHmkShHCDeaMrLu11A1HZErUrqKtu7pEYwlXdipnlMOq9gjU2i6Zwb1cY0yQXePVejP4TVxlLe cDakyEaNBZqiaX0vUqIdd/M47NPr+c1SAZABSJlq6i+yW45q4Emp+l83xs97tnaTSbpBQlHegE pNscz5gqQPvf08FFrt3nlOUIBCNnQXUGONvWCZz4P4oTimhhoFjs2bu33sv6gfId7+EJc8t836 wYw= X-SBRS: 2.7 X-MesageID: 9263891 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,246,1571716800"; d="scan'208";a="9263891" From: Andrew Cooper To: Xen-devel Date: Tue, 26 Nov 2019 15:01:12 +0000 Message-ID: <20191126150112.12704-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191126150112.12704-1-andrew.cooper3@citrix.com> References: <20191126150112.12704-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/2] AMD/IOMMU: Render IO_PAGE_FAULT errors in a more useful manner X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Andrew Cooper , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Print the PCI coordinates in its common format and use d%u notation for the domain. As well as printing flags, decode them. IO_PAGE_FAULT is used for interrupt remapping errors as well as DMA remapping errors. Before: (XEN) AMD-Vi: IO_PAGE_FAULT: domain = 0, device id = 0xa1, fault address = 0xbf695000, flags = 0x10 (XEN) AMD-Vi: IO_PAGE_FAULT: domain = 0, device id = 0xa1, fault address = 0xbf695040, flags = 0x10 (XEN) AMD-Vi: IO_PAGE_FAULT: domain = 0, device id = 0xa1, fault address = 0xfffffff0, flags = 0x30 (XEN) AMD-Vi: IO_PAGE_FAULT: domain = 0, device id = 0xa1, fault address = 0x100000000, flags = 0x30 (XEN) AMD-Vi: IO_PAGE_FAULT: domain = 0, device id = 0xa1, fault address = 0x100000040, flags = 0x30 After: (XEN) AMD-Vi: IO_PAGE_FAULT: 0000:00:14.1 d0 addr 00000000bf5fc000 flags 0x10 PR (XEN) AMD-Vi: IO_PAGE_FAULT: 0000:00:14.1 d0 addr 00000000bf5fc040 flags 0x10 PR (XEN) AMD-Vi: IO_PAGE_FAULT: 0000:00:14.1 d0 addr 00000000fffffff0 flags 0x30 RW PR (XEN) AMD-Vi: IO_PAGE_FAULT: 0000:00:14.1 d0 addr 0000000100000000 flags 0x30 RW PR (XEN) AMD-Vi: IO_PAGE_FAULT: 0000:00:14.1 d0 addr 0000000100000040 flags 0x30 RW PR No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné Acked-by: Jan Beulich --- CC: Jan Beulich CC: Juergen Gross --- xen/drivers/passthrough/amd/iommu_init.c | 35 +++++++++++++++------------ xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 3 --- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c index 8aa8788797..cd4e6e16b8 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -513,10 +513,7 @@ static hw_irq_controller iommu_x2apic_type = { static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) { - u16 domain_id, device_id, flags; - unsigned int bdf; u32 code; - u64 *addr; int count = 0; static const char *const event_str[] = { #define EVENT_STR(name) [IOMMU_EVENT_##name - 1] = #name @@ -560,18 +557,26 @@ static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) if ( code == IOMMU_EVENT_IO_PAGE_FAULT ) { - device_id = iommu_get_devid_from_event(entry[0]); - domain_id = get_field_from_reg_u32(entry[1], - IOMMU_EVENT_DOMAIN_ID_MASK, - IOMMU_EVENT_DOMAIN_ID_SHIFT); - flags = get_field_from_reg_u32(entry[1], - IOMMU_EVENT_FLAGS_MASK, - IOMMU_EVENT_FLAGS_SHIFT); - addr= (u64*) (entry + 2); - printk(XENLOG_ERR "AMD-Vi: " - "%s: domain = %d, device id = %#x, " - "fault address = %#"PRIx64", flags = %#x\n", - code_str, domain_id, device_id, *addr, flags); + unsigned int bdf; + uint16_t device_id = MASK_EXTR(entry[0], IOMMU_CMD_DEVICE_ID_MASK); + uint16_t domain_id = MASK_EXTR(entry[1], IOMMU_EVENT_DOMAIN_ID_MASK); + uint16_t flags = MASK_EXTR(entry[1], IOMMU_EVENT_FLAGS_MASK); + uint64_t addr = *(uint64_t *)(entry + 2); + + printk(XENLOG_ERR "AMD-Vi: %s: %04x:%02x:%02x.%u d%d addr %016"PRIx64 + " flags %#x%s%s%s%s%s%s%s%s%s%s\n", + code_str, iommu->seg, PCI_BUS(device_id), PCI_SLOT(device_id), + PCI_FUNC(device_id), domain_id, addr, flags, + (flags & 0xe00) ? " ??" : "", + (flags & 0x100) ? " TR" : "", + (flags & 0x080) ? " RZ" : "", + (flags & 0x040) ? " PE" : "", + (flags & 0x020) ? " RW" : "", + (flags & 0x010) ? " PR" : "", + (flags & 0x008) ? " I" : "", + (flags & 0x004) ? " US" : "", + (flags & 0x002) ? " NX" : "", + (flags & 0x001) ? " GN" : ""); for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ ) if ( get_dma_requestor_id(iommu->seg, bdf) == device_id ) diff --git a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h index 8ed9482791..53900cd60c 100644 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h @@ -265,9 +265,6 @@ static inline uint32_t iommu_get_addr_hi_from_cmd(uint32_t cmd) IOMMU_CMD_ADDR_HIGH_SHIFT); } -/* access address field from event log entry */ -#define iommu_get_devid_from_event iommu_get_devid_from_cmd - /* access iommu base addresses field from mmio regs */ static inline void iommu_set_addr_lo_to_reg(uint32_t *reg, uint32_t addr) {