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

[PATCH v2] x86: show_hvm_stack() requires enabled interrupts


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 12 Aug 2022 11:07:37 +0200
  • 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=jAkNLNti5tN/FMTZtk/oG1FE7N2XTZC09fvb59IEIK4=; b=TN9mrn7x74DGuURL8zMRfcJxQQ1FH6AbXKkpWSUTcSBoiEJ/HCryI1tT45Vh7vCIp5bU5l07Pib8duFwjMVEJrLRQmtXcUDb8Z7o4J4Tv8kSj/NrPcosWd71F7mZniVHvMIpQ+40WG94Rp3vlrTjf7u4g9Tm1Qeor1PY2blGw9wzwSVo1pAWXbgzym072LcW+H2itXd3/jo6Kk4D7cI9GZxFCpfO2XeDqZhIyw2t/1/3NKTaKBcED/JeYAp+SmgpLDgFa7zTRrexPfU1APWuoyzpi6OAjlOlEoU+Ejmy1K80I+BlKQSP2sY2W+iJhTNsdW9VTR9juPulbSpdDssmIw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foRN3xhVj3qZj8RpGozm97yNse2n+uqAsoIzefBk6ElJp4bkKjkc6ARGUXeTz8gSxp4BXNBrS6Sg38SymspkBDEnBbmgfZRP6ZWmTwnI4zE4cp7lVC0Sdk4nYTtQWNrUEHI/sPXiApUjLcKkg4ZLZDpWThNZX6m0X71huZainEx/pbtaaaEvtFwPx0YngeX67dOIlEE/xqvnQ8HpbJ8+9ajMG2SYqfR85tkT2sfqd1PZK3AV3fgqHOu1yGqnWvYWdkcOIaxtDMSkB1t3/r5EWs7EdGjg41NKzNrP4LPahpbSFDycRg1T/t4RmNTuQ1wmYahTLsjo9LKnwrG0KNkjpQ==
  • 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: Fri, 12 Aug 2022 09:07:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

show_hvm_stack() requires interrupts to be enabled to avoid triggering
the consistency check in check_lock() for the p2m lock. Add a respective
check. To avoid this check triggering when coming through
spurious_interrupt() requires adding reentrancy protection / handling
there alongside transiently (re-)enabling IRQs.

Fixes: adb715db698b ("x86/HVM: also dump stacks from show_execution_state()")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Check IRQs enabled before calling show_hvm_stack(). Re-base.

--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1384,22 +1384,40 @@ void smp_send_state_dump(unsigned int cp
  */
 void cf_check 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;
     }
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -660,7 +660,9 @@ void show_execution_state(const struct c
     {
         struct vcpu *curr = current;
 
-        if ( is_hvm_vcpu(curr) )
+        if ( !is_hvm_vcpu(curr) )
+            show_guest_stack(curr, regs);
+        else if ( flags & X86_EFLAGS_IF )
         {
             /*
              * Stop interleaving prevention: The necessary P2M lookups
@@ -671,8 +673,6 @@ void show_execution_state(const struct c
             show_hvm_stack(curr, regs);
             return;
         }
-
-        show_guest_stack(curr, regs);
     }
     else
     {



 


Rackspace

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