Revision: 17204
          http://sourceforge.net/p/edk2/code/17204
Author:   vanjeff
Date:     2015-04-27 05:23:43 +0000 (Mon, 27 Apr 2015)
Log Message:
-----------
SourceLevelDebugPkg/DebugAgent: Clear/Restore EFLAGS.IF

Clear EFLAGS.IF before executing Stepping command and save original
value in DEBUG_AGENT_FLAG. It could avoid pending interrupt issued
during executing Stepping command. Restore EFLAGS.IF after Stepping
command execution finished.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>

Modified Paths:
--------------
    
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c

Modified: 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
===================================================================
--- 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c 
    2015-04-27 05:21:17 UTC (rev 17203)
+++ 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c 
    2015-04-27 05:23:43 UTC (rev 17204)
@@ -785,7 +785,7 @@
 }
 
 /**
-  Exectue Stepping command.
+  Execute Stepping command.
 
   @param[in] CpuContext        Pointer to saved CPU context.
 
@@ -800,9 +800,42 @@
   Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
   Eflags->Bits.TF = 1;
   Eflags->Bits.RF = 1;
+  //
+  // Save and clear EFLAGS.IF to avoid interrupt happen when executing Stepping
+  //
+  SetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG, Eflags->Bits.IF);
+  Eflags->Bits.IF = 0;
+  //
+  // Set Stepping Flag
+  //
+  SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);
 }
 
 /**
+  Do some cleanup after Stepping command done.
+
+  @param[in] CpuContext        Pointer to saved CPU context.
+
+**/
+VOID
+CommandSteppingCleanup (
+  IN DEBUG_CPU_CONTEXT          *CpuContext
+  )
+{
+  IA32_EFLAGS32                *Eflags;
+
+  Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
+  //
+  // Restore EFLAGS.IF
+  //
+  Eflags->Bits.IF = GetDebugFlag (DEBUG_AGENT_FLAG_INTERRUPT_FLAG);
+  //
+  // Clear Stepping flag
+  //
+  SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);
+}
+
+/**
   Set debug register for hardware breakpoint.
 
   @param[in] CpuContext      Pointer to saved CPU context.
@@ -2066,10 +2099,6 @@
       }
 
       mDebugMpContext.BreakAtCpuIndex = (UINT32) (-1);
-      //
-      // Set Stepping Flag
-      //
-      SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 1);
       ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
       //
       // Executing stepping command directly without sending ACK packet,
@@ -2405,11 +2434,11 @@
       if (MultiProcessorDebugSupport()) {
         mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
       }
-      SendAckPacket (DEBUG_COMMAND_OK);
       //
-      // Clear Stepping Flag
+      // Clear Stepping Flag and restore EFLAGS.IF
       //
-      SetDebugFlag (DEBUG_AGENT_FLAG_STEPPING, 0);
+      CommandSteppingCleanup (CpuContext);
+      SendAckPacket (DEBUG_COMMAND_OK);
       CommandCommunication (Vector, CpuContext, BreakReceived);
       break;
 
@@ -2582,6 +2611,10 @@
         if (MultiProcessorDebugSupport()) {
           mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
         }
+        //
+        // Clear Stepping flag and restore EFLAGS.IF
+        //
+        CommandSteppingCleanup (CpuContext);
         SendAckPacket (DEBUG_COMMAND_OK);
       } else {
         //


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to