mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg/CpuDxe: Guarantee GDT is below 4GB
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3233 GDT needs to be allocated below 4GB in 64bit environment because AP needs it for entering to protected mode. CPU running in big real mode cannot access above 4GB GDT. But CpuDxe driver contains below code: gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8); ..... gdtPtr.Base = (UINT32)(UINTN)(VOID*) gdt; The AllocateRuntimePool() may allocate memory above 4GB. Thus, we cannot use AllocateRuntimePool (), instead, we should use AllocatePages() to make sure GDT is below 4GB space. Signed-off-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Cc: Rahul Kumar <rahul1.kumar@intel.com>
This commit is contained in:
parent
773b0bc283
commit
313d86c956
|
@ -124,15 +124,26 @@ InitGlobalDescriptorTable (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
GDT_ENTRIES *Gdt;
|
GDT_ENTRIES *Gdt;
|
||||||
IA32_DESCRIPTOR Gdtr;
|
IA32_DESCRIPTOR Gdtr;
|
||||||
|
EFI_PHYSICAL_ADDRESS Memory;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate Runtime Data for the GDT
|
// Allocate Runtime Data below 4GB for the GDT
|
||||||
|
// AP uses the same GDT when it's waken up from real mode so
|
||||||
|
// the GDT needs to be below 4GB.
|
||||||
//
|
//
|
||||||
Gdt = AllocateRuntimePool (sizeof (mGdtTemplate) + 8);
|
Memory = SIZE_4GB - 1;
|
||||||
ASSERT (Gdt != NULL);
|
Status = gBS->AllocatePages (
|
||||||
Gdt = ALIGN_POINTER (Gdt, 8);
|
AllocateMaxAddress,
|
||||||
|
EfiRuntimeServicesData,
|
||||||
|
EFI_SIZE_TO_PAGES (sizeof (mGdtTemplate)),
|
||||||
|
&Memory
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
ASSERT ((Memory != 0) && (Memory < SIZE_4GB));
|
||||||
|
Gdt = (GDT_ENTRIES *) (UINTN) Memory;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize all GDT entries
|
// Initialize all GDT entries
|
||||||
|
|
Loading…
Reference in New Issue