]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/MpInitLib: Not pass microcode info between archs in CPU_MP_DATA
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / DxeMpLib.c
index d82e9aea45c0c0a4bfc607c691b7f23350606068..b17e287bbf49c2e079fbbfd1f10fae75b076886c 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   MP initialize support functions for DXE phase.\r
 \r
-  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -76,7 +70,7 @@ SaveCpuMpData (
 }\r
 \r
 /**\r
-  Get available system memory below 1MB by specified size.\r
+  Get available system memory below 0x88000 by specified size.\r
 \r
   @param[in] WakeupBufferSize   Wakeup buffer size required\r
 \r
@@ -91,7 +85,15 @@ GetWakeupBuffer (
   EFI_STATUS              Status;\r
   EFI_PHYSICAL_ADDRESS    StartAddress;\r
 \r
-  StartAddress = BASE_1MB;\r
+  //\r
+  // Try to allocate buffer below 1M for waking vector.\r
+  // LegacyBios driver only reports warning when page allocation in range\r
+  // [0x60000, 0x88000) fails.\r
+  // This library is consumed by CpuDxe driver to produce CPU Arch protocol.\r
+  // LagacyBios driver depends on CPU Arch protocol which guarantees below\r
+  // allocation runs earlier than LegacyBios driver.\r
+  //\r
+  StartAddress = 0x88000;\r
   Status = gBS->AllocatePages (\r
                   AllocateMaxAddress,\r
                   EfiBootServicesData,\r
@@ -99,17 +101,13 @@ GetWakeupBuffer (
                   &StartAddress\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
-  if (!EFI_ERROR (Status)) {\r
-    Status = gBS->FreePages(\r
-               StartAddress,\r
-               EFI_SIZE_TO_PAGES (WakeupBufferSize)\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-    DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r
-                        (UINTN) StartAddress, WakeupBufferSize));\r
-  } else {\r
+  if (EFI_ERROR (Status)) {\r
     StartAddress = (EFI_PHYSICAL_ADDRESS) -1;\r
   }\r
+\r
+  DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r
+                      (UINTN) StartAddress, WakeupBufferSize));\r
+\r
   return (UINTN) StartAddress;\r
 }\r
 \r
@@ -236,7 +234,6 @@ GetProtectedModeCS (
   UINTN                    GdtEntryCount;\r
   UINT16                   Index;\r
 \r
-  Index = (UINT16) -1;\r
   AsmReadGdtr (&GdtrDesc);\r
   GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR);\r
   GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base;\r
@@ -248,7 +245,7 @@ GetProtectedModeCS (
     }\r
     GdtEntry++;\r
   }\r
-  ASSERT (Index != -1);\r
+  ASSERT (Index != GdtEntryCount);\r
   return Index * 8;\r
 }\r
 \r
@@ -306,7 +303,7 @@ MpInitChangeApLoopCallback (
   CpuMpData->PmCodeSegment = GetProtectedModeCS ();\r
   CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode);\r
   mNumberToFinish = CpuMpData->CpuCount - 1;\r
-  WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, NULL);\r
+  WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, NULL, TRUE);\r
   while (mNumberToFinish > 0) {\r
     CpuPause ();\r
   }\r
@@ -571,9 +568,10 @@ MpInitLibStartupAllAPs (
   //\r
   mStopCheckAllApsStatus = TRUE;\r
 \r
-  Status = StartupAllAPsWorker (\r
+  Status = StartupAllCPUsWorker (\r
              Procedure,\r
              SingleThread,\r
+             TRUE,\r
              WaitEvent,\r
              TimeoutInMicroseconds,\r
              ProcedureArgument,\r