From 50684330f5dbaeb3d50550e3c18d59b7cc85bcc9 Mon Sep 17 00:00:00 2001 From: xli24 Date: Fri, 19 Mar 2010 09:22:28 +0000 Subject: Ensure GDT for APs is under 4G, in order to secure that APs can safely use it to switch from real mode to protected mode, as well as from protected mode to long mode. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10290 6f19259b-4bc3-4df7-8a09-765794883524 --- .../MpServicesOnFrameworkMpServicesThunk.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'EdkCompatibilityPkg/Compatibility') diff --git a/EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/MpServicesOnFrameworkMpServicesThunk.c b/EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/MpServicesOnFrameworkMpServicesThunk.c index 9005670bae..4d0918fa78 100644 --- a/EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/MpServicesOnFrameworkMpServicesThunk.c +++ b/EdkCompatibilityPkg/Compatibility/MpServicesOnFrameworkMpServicesThunk/MpServicesOnFrameworkMpServicesThunk.c @@ -1444,6 +1444,8 @@ PrepareAPStartupVector ( { MP_ASSEMBLY_ADDRESS_MAP AddressMap; IA32_DESCRIPTOR GdtrForBSP; + EFI_PHYSICAL_ADDRESS GdtForAP; + EFI_STATUS Status; // // Get the address map of startup code for AP, @@ -1481,7 +1483,22 @@ PrepareAPStartupVector ( mExchangeInfo->StackSize = AP_STACK_SIZE; AsmReadGdtr (&GdtrForBSP); - mExchangeInfo->GdtrProfile.Base = GdtrForBSP.Base; + + // + // Allocate memory under 4G to hold GDT for APs + // + GdtForAP = 0xffffffff; + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiBootServicesData, + EFI_SIZE_TO_PAGES (GdtrForBSP.Limit + 1), + &GdtForAP + ); + ASSERT_EFI_ERROR (Status); + + CopyMem ((VOID *) (UINTN) GdtForAP, (VOID *) GdtrForBSP.Base, GdtrForBSP.Limit + 1); + + mExchangeInfo->GdtrProfile.Base = (UINTN) GdtForAP; mExchangeInfo->GdtrProfile.Limit = GdtrForBSP.Limit; mExchangeInfo->BufferStart = (UINT32) mStartupVector; -- cgit v1.2.3