All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/APIC: modify error_interrupt() to output using single printk()
@ 2023-03-17 16:10 Elliott Mitchell
  0 siblings, 0 replies; only message in thread
From: Elliott Mitchell @ 2023-03-17 16:10 UTC (permalink / raw)
  To: xen-devel; +Cc: Jan Beulich, Andrew Cooper, Roger Pau Monné, Wei Liu

This takes care of the issue of APIC errors tending to occur on multiple
cores at one.  In turn this tends to causes the error messages to be
merged together, making understanding them difficult.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 xen/arch/x86/apic.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index f71474d47d..5399488120 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1412,6 +1412,12 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)
     };
     unsigned int v, v1;
     int i;
+    char head[] = XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)";
+    char entry[] = ", %s";
+    /* header string, ", %s" for each potential entry, newline */
+    char fmt[sizeof(head) + ARRAY_SIZE(esr_fields) * (sizeof(entry) - 1) + 1];
+    const char *args[ARRAY_SIZE(esr_fields)];
+    unsigned int count = 0;
 
     /* First tickle the hardware, only then report what went on. -- REW */
     v = apic_read(APIC_ESR);
@@ -1419,12 +1425,18 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)
     v1 = apic_read(APIC_ESR);
     ack_APIC_irq();
 
-    printk(XENLOG_DEBUG "APIC error on CPU%u: %02x(%02x)",
-            smp_processor_id(), v , v1);
+    memcpy(fmt, head, sizeof(head) - 1);
+
     for ( i = 7; i >= 0; --i )
-        if ( v1 & (1 << i) )
-            printk(", %s", esr_fields[i]);
-    printk("\n");
+        if ( v1 & (1 << i) ) {
+            memcpy(fmt + sizeof(head) + (sizeof(entry) - 1) * count - 1, entry,
+                    sizeof(entry) - 1);
+            args[count++] = esr_fields[i];
+        }
+    memcpy(fmt + sizeof(head) + (sizeof(entry) - 1) * count - 1, "\n", 2);
+    /*_Static_assert(ARRAY_SIZE(args) == 8, "printk() here needs args added");*/
+    printk(fmt, smp_processor_id(), v , v1, args[0], args[1], args[2], args[3],
+            args[4], args[5], args[6], args[7]);
 }
 
 /*
-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |        ehem+sigmsg@m5p.com    PGP 87145445        |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-17 17:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 16:10 [PATCH] x86/APIC: modify error_interrupt() to output using single printk() Elliott Mitchell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.