[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] amd iommu: improve parse_event_log_entry()


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Wed, 23 May 2012 22:11:08 +0000
  • Delivery-date: Wed, 23 May 2012 22:11:19 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1337786418 -7200
# Node ID 69c3ae25bb1ddcb0ea44b7566d36d34e9d6a70aa
# Parent  af559b5afbecba1048ad690347455ad54098f935
amd iommu: improve parse_event_log_entry()

- message table should be static (no need to set it up each time the
  function gets executed)
- don't bail on out-of-range event code values
- use message table also to print the kind of otherwise unhandled
  event codes

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Wei Wang <wei.wang2@xxxxxxx>
---


diff -r af559b5afbec -r 69c3ae25bb1d xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c  Wed May 23 17:18:06 2012 +0200
+++ b/xen/drivers/passthrough/amd/iommu_init.c  Wed May 23 17:20:18 2012 +0200
@@ -568,14 +568,18 @@ static void parse_event_log_entry(struct
     u32 code;
     u64 *addr;
     int count = 0;
-    char * event_str[] = {"ILLEGAL_DEV_TABLE_ENTRY",
-                          "IO_PAGE_FAULT",
-                          "DEV_TABLE_HW_ERROR",
-                          "PAGE_TABLE_HW_ERROR",
-                          "ILLEGAL_COMMAND_ERROR",
-                          "COMMAND_HW_ERROR",
-                          "IOTLB_INV_TIMEOUT",
-                          "INVALID_DEV_REQUEST"};
+    static const char *const event_str[] = {
+#define EVENT_STR(name) [IOMMU_EVENT_##name - 1] = #name
+        EVENT_STR(ILLEGAL_DEV_TABLE_ENTRY),
+        EVENT_STR(IO_PAGE_FAULT),
+        EVENT_STR(DEV_TABLE_HW_ERROR),
+        EVENT_STR(PAGE_TABLE_HW_ERROR),
+        EVENT_STR(ILLEGAL_COMMAND_ERROR),
+        EVENT_STR(COMMAND_HW_ERROR),
+        EVENT_STR(IOTLB_INV_TIMEOUT),
+        EVENT_STR(INVALID_DEV_REQUEST)
+#undef EVENT_STR
+    };
 
     code = get_field_from_reg_u32(entry[1], IOMMU_EVENT_CODE_MASK,
                                             IOMMU_EVENT_CODE_SHIFT);
@@ -599,13 +603,6 @@ static void parse_event_log_entry(struct
                                       IOMMU_EVENT_CODE_SHIFT);
     }
 
-    if ( (code > IOMMU_EVENT_INVALID_DEV_REQUEST) ||
-        (code < IOMMU_EVENT_ILLEGAL_DEV_TABLE_ENTRY) )
-    {
-        AMD_IOMMU_DEBUG("Invalid event log entry!\n");
-        return;
-    }
-
     if ( code == IOMMU_EVENT_IO_PAGE_FAULT )
     {
         device_id = iommu_get_devid_from_event(entry[0]);
@@ -633,8 +630,10 @@ static void parse_event_log_entry(struct
     }
     else
     {
-        AMD_IOMMU_DEBUG("event 0x%08x 0x%08x 0x%08x 0x%08x\n", entry[0],
-                        entry[1], entry[2], entry[3]);
+        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]);
     }
 
     memset(entry, 0, IOMMU_EVENT_LOG_ENTRY_SIZE);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.