]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Move save/restore interrupt to SwitchBSPWorker()
authorJeff Fan <jeff.fan@intel.com>
Mon, 26 Dec 2016 08:52:48 +0000 (16:52 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 28 Dec 2016 07:38:07 +0000 (15:38 +0800)
During switching BSP phase, we need to disable CPU interruput to prevent stack
crashed by Timer interrupt handle. But when we enabled source debugging feature,
debug timer interrupt handler (existing on both PEI and DXE) also could crash
the stack used during switching BSP. So,we need to move save/restore interrupt
to SwitchBSPWorker().

Cc: Feng Tian <feng.tian@intel.com>
Cc: Kinney Michael D <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.c

index 1204abd577b2fdd5425d761f0edf0d0764dbace1..733a9fb7be9401098ca959b0a57451971c8d3b76 100644 (file)
@@ -646,29 +646,10 @@ MpInitLibSwitchBSP (
   )\r
 {\r
   EFI_STATUS            Status;\r
-  BOOLEAN               OldInterruptState;\r
 \r
-  //\r
-  // Before send both BSP and AP to a procedure to exchange their roles,\r
-  // interrupt must be disabled. This is because during the exchange role\r
-  // process, 2 CPU may use 1 stack. If interrupt happens, the stack will\r
-  // be corrupted, since interrupt return address will be pushed to stack\r
-  // by hardware.\r
-  //\r
-  OldInterruptState = SaveAndDisableInterrupts ();\r
-\r
-  //\r
-  // Mask LINT0 & LINT1 for the old BSP\r
-  //\r
-  DisableLvtInterrupts ();\r
 \r
   Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP);\r
 \r
-  //\r
-  // Restore interrupt state.\r
-  //\r
-  SetInterruptState (OldInterruptState);\r
-\r
   return Status;\r
 }\r
 \r
index e5842ef505dc7864cc08c81f04f44b571de48d86..9dae827306d50f392679de78f210345cb0208c97 100644 (file)
@@ -1511,6 +1511,21 @@ SwitchBSPWorker (
   UINTN                        CallerNumber;\r
   CPU_STATE                    State;\r
   MSR_IA32_APIC_BASE_REGISTER  ApicBaseMsr;\r
+  BOOLEAN                      OldInterruptState;\r
+\r
+  //\r
+  // Before send both BSP and AP to a procedure to exchange their roles,\r
+  // interrupt must be disabled. This is because during the exchange role\r
+  // process, 2 CPU may use 1 stack. If interrupt happens, the stack will\r
+  // be corrupted, since interrupt return address will be pushed to stack\r
+  // by hardware.\r
+  //\r
+  OldInterruptState = SaveAndDisableInterrupts ();\r
+\r
+  //\r
+  // Mask LINT0 & LINT1 for the old BSP\r
+  //\r
+  DisableLvtInterrupts ();\r
 \r
   CpuMpData = GetCpuMpData ();\r
 \r
@@ -1593,6 +1608,12 @@ SwitchBSPWorker (
   //\r
   CpuMpData->BspNumber = (UINT32) ProcessorNumber;\r
 \r
+  //\r
+  // Restore interrupt state.\r
+  //\r
+  SetInterruptState (OldInterruptState);\r
+\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r