From: Andrew Cooper Date: Tue, 26 Nov 2019 14:08:01 +0000 (+0000) Subject: AMD/IOMMU: Always print IOMMU errors X-Git-Tag: temptemp~1061 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b0282a69f42209f18e21be7dbfb4d8c1c6c7b902;p=people%2Fhx242%2Fxen.git AMD/IOMMU: Always print IOMMU errors Unhandled IOMMU errors (i.e. not IO_PAGE_FAULT) should still be printed, and not hidden behind iommu=debug. While adjusting this, factor out the symbolic name handling to just one location exposing its off-by-one nature. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné Acked-by: Jan Beulich --- diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c index 566e6defa1..4b1a394b3c 100644 --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -530,6 +530,7 @@ static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) EVENT_STR(INVALID_DEV_REQUEST) #undef EVENT_STR }; + const char *code_str = "event"; code = get_field_from_reg_u32(entry[1], IOMMU_EVENT_CODE_MASK, IOMMU_EVENT_CODE_SHIFT); @@ -553,6 +554,10 @@ static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) IOMMU_EVENT_CODE_SHIFT); } + /* Look up the symbolic name for code. */ + if ( code <= ARRAY_SIZE(event_str) ) + code_str = event_str[code - 1]; + if ( code == IOMMU_EVENT_IO_PAGE_FAULT ) { device_id = iommu_get_devid_from_event(entry[0]); @@ -566,7 +571,7 @@ static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) printk(XENLOG_ERR "AMD-Vi: " "%s: domain = %d, device id = %#x, " "fault address = %#"PRIx64", flags = %#x\n", - event_str[code-1], domain_id, device_id, *addr, flags); + code_str, domain_id, device_id, *addr, flags); for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ ) if ( get_dma_requestor_id(iommu->seg, bdf) == device_id ) @@ -574,12 +579,8 @@ static void parse_event_log_entry(struct amd_iommu *iommu, u32 entry[]) PCI_DEVFN2(bdf)); } else - { - AMD_IOMMU_DEBUG("%s %08x %08x %08x %08x\n", - code <= ARRAY_SIZE(event_str) ? event_str[code - 1] - : "event", - entry[0], entry[1], entry[2], entry[3]); - } + printk(XENLOG_ERR "%s %08x %08x %08x %08x\n", + code_str, entry[0], entry[1], entry[2], entry[3]); memset(entry, 0, IOMMU_EVENT_LOG_ENTRY_SIZE); }