]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/MpInitLib: Fix MemTest86 failure.
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / DxeMpLib.c
index c17daa0fc0da7d59f373b440b351e685578e0c3b..cef5b49dde4be0225b2b1fec4935c5032b13b206 100644 (file)
@@ -76,7 +76,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 +91,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 +107,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 +240,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 +251,7 @@ GetProtectedModeCS (
     }\r
     GdtEntry++;\r
   }\r
-  ASSERT (Index != -1);\r
+  ASSERT (Index != GdtEntryCount);\r
   return Index * 8;\r
 }\r
 \r