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

[PATCH] x86: enable interrupts around dump_execstate()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 13 Dec 2021 16:12:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NepYqSw68L1IRVa08bjwitG1A/t4bjNDpTEkt8BFYlw=; b=LtkRbHp9Qd1pyp7K1ZV43bXmBbSvS8VF2nfuTDRE88zNhPXhS5xhvAML2JH7O5K4C3zUfbX9lC6e0QbPPXdb4MZx8M5PYdTPvgWMlLOHxsTlZ0VYLnYCyYwXj09bEIe7fQqhSKYes9MwbpowFHVGxUc+rVgfec20RViwzYCl00ppEl7SRDaiAWysNVTbugeMVVpGU0adguB9jO7io59GWY3RKnhU3AzK2M+J6zMb6aryUIXtm7G3FnuwhXr7GZa0YwuiPdDSqjnJU+tKCCHCHO5rwS+/ZlfA6QXfAovRbKAZ0uzyMLFsKgtyy/rdJiwGGgihXRM+q5xZRwY/9oaGRw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0LTYVJnXGmRcet1cRVBdWO6PWLuKw2pnI/vau6kvr4VH5yf4CaWvKWB0F1hYjcKHc4fVqwzia0DHjciOb8kU8kP3XJKSbgiqF2kXcxNt1rYaP3X/i2zvKGfg65BfskqYlBavX/yaPrBkvqF9+ITYChGNDxMY5ZUEi7LvtpvOQyi2mp87M86gmQM8AlAXV/vK79PjtQd8Mm+YiRO21QMRKMOuAggYXua3/z0WG+keLjUT/tj0JzB99DG1X379L5AmD//ljC7rWWj7xfW0whyy9dCOHikl5RoKqiUYRR9oOdj+MEigCkW1inUYFhElLVxKNta8JYq7IEwWTvpC+RWUQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 13 Dec 2021 15:13:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>
---
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;
     }




 


Rackspace

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