Ensure GDT for APs is under 4G, in order to secure that APs can safely use it to...
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Mar 2010 09:22:28 +0000 (09:22 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 19 Mar 2010 09:22:28 +0000 (09:22 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@10290 6f19259b-4bc3-4df7-8a09-765794883524

edk2/EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/MpServicesOnFrameworkMpServicesThunk.c

index 9005670..4d0918f 100644 (file)
@@ -1444,6 +1444,8 @@ PrepareAPStartupVector (
 {\r
   MP_ASSEMBLY_ADDRESS_MAP   AddressMap;\r
   IA32_DESCRIPTOR           GdtrForBSP;\r
+  EFI_PHYSICAL_ADDRESS      GdtForAP;\r
+  EFI_STATUS                Status;\r
 \r
   //\r
   // Get the address map of startup code for AP,\r
@@ -1481,7 +1483,22 @@ PrepareAPStartupVector (
   mExchangeInfo->StackSize  = AP_STACK_SIZE;\r
 \r
   AsmReadGdtr (&GdtrForBSP);\r
-  mExchangeInfo->GdtrProfile.Base  = GdtrForBSP.Base;\r
+\r
+  //\r
+  // Allocate memory under 4G to hold GDT for APs\r
+  //\r
+  GdtForAP = 0xffffffff;\r
+  Status   = gBS->AllocatePages (\r
+                    AllocateMaxAddress,\r
+                    EfiBootServicesData,\r
+                    EFI_SIZE_TO_PAGES (GdtrForBSP.Limit + 1),\r
+                    &GdtForAP\r
+                    );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  CopyMem ((VOID *) (UINTN) GdtForAP, (VOID *) GdtrForBSP.Base, GdtrForBSP.Limit + 1);\r
+\r
+  mExchangeInfo->GdtrProfile.Base  = (UINTN) GdtForAP;\r
   mExchangeInfo->GdtrProfile.Limit = GdtrForBSP.Limit;\r
 \r
   mExchangeInfo->BufferStart = (UINT32) mStartupVector;\r