All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: enable interrupts around dump_execstate()
@ 2021-12-13 15:12 Jan Beulich
  2021-12-16 11:54 ` Andrew Cooper
  2022-09-13 14:50 ` Roger Pau Monné
  0 siblings, 2 replies; 17+ messages in thread
From: Jan Beulich @ 2021-12-13 15:12 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Roger Pau Monné

show_hvm_stack() requires interrupts to be enabled to avoids triggering
the consistency check in check_lock() for the p2m lock. To do so in
spurious_interrupt() requires adding reentrancy protection / handling
there.

Fixes: adb715db698b ("x86/HVM: also dump stacks from show_execution_state()")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
The obvious (but imo undesirable) alternative is to suppress the call to
show_hvm_stack() when interrupts are disabled.

--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1386,22 +1386,40 @@ void smp_send_state_dump(unsigned int cp
  */
 void spurious_interrupt(struct cpu_user_regs *regs)
 {
+    static DEFINE_PER_CPU(unsigned int, recursed);
+    unsigned int cpu = smp_processor_id();
+
     /*
      * Check if this is a vectored interrupt (most likely, as this is probably
      * a request to dump local CPU state or to continue NMI handling).
      * Vectored interrupts are ACKed; spurious interrupts are not.
      */
-    if (apic_isr_read(SPURIOUS_APIC_VECTOR)) {
+    while ( apic_isr_read(SPURIOUS_APIC_VECTOR) )
+    {
         bool is_spurious;
 
+        if ( per_cpu(recursed, cpu)++ )
+            return;
+
         ack_APIC_irq();
         is_spurious = !nmi_check_continuation();
-        if (this_cpu(state_dump_pending)) {
-            this_cpu(state_dump_pending) = false;
+
+        if ( per_cpu(state_dump_pending, cpu) )
+        {
+            per_cpu(state_dump_pending, cpu) = false;
+
+            local_irq_enable();
+
             dump_execstate(regs);
-            is_spurious = false;
+
+            local_irq_disable();
+
+            /* (Ab)use is_spurious to arrange for loop continuation. */
+            is_spurious = per_cpu(recursed, cpu) > 1;
         }
 
+        per_cpu(recursed, cpu) = 0;
+
         if ( !is_spurious )
             return;
     }



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-09-15 15:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 15:12 [PATCH] x86: enable interrupts around dump_execstate() Jan Beulich
2021-12-16 11:54 ` Andrew Cooper
2021-12-16 13:33   ` Jan Beulich
2022-01-11 10:08     ` Ping: " Jan Beulich
2022-07-05 16:19       ` Ping²: " Jan Beulich
2022-07-19 10:59         ` Fwd: " Jan Beulich
2022-07-19 12:54           ` Henry Wang
2022-07-19 11:22     ` Andrew Cooper
2022-07-19 12:53       ` Jan Beulich
2022-09-13 14:50 ` Roger Pau Monné
2022-09-14  8:14   ` Jan Beulich
2022-09-14  8:31     ` Jan Beulich
2022-09-14  9:13       ` Roger Pau Monné
2022-09-14 10:13         ` Jan Beulich
2022-09-14 14:23           ` Roger Pau Monné
2022-09-15  8:01             ` Jan Beulich
2022-09-15 15:43               ` Roger Pau Monné

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.