From 6eab8b4368f9bb7130271760b2e93f2172ed97ab Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Fri, 10 Aug 2018 10:53:45 +0800 Subject: UefiCpuPkg/CpuS3DataDxe: Remove below 4G limitation. Because PrepareApStartupVector() stores StackAddress to "mExchangeInfo->StackStart" (which has type (VOID*)), and because "UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm" reads the latter with: add edi, StackStartAddressLocation add rax, qword [edi] mov rsp, rax mov qword [edi], rax in long-mode code. So code can remove below 4G limitation. Cc: Laszlo Ersek Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong Reviewed-by: Laszlo Ersek Reviewed-by: Ruiyu Ni Tested-by: Laszlo Ersek --- UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'UefiCpuPkg') diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c index 3e8c8b3..ef98239 100644 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c @@ -47,9 +47,7 @@ typedef struct { } ACPI_CPU_DATA_EX; /** - Allocate EfiACPIMemoryNVS below 4G memory address. - - This function allocates EfiACPIMemoryNVS below 4G memory address. + Allocate EfiACPIMemoryNVS memory. @param[in] Size Size of memory to allocate. @@ -57,7 +55,7 @@ typedef struct { **/ VOID * -AllocateAcpiNvsMemoryBelow4G ( +AllocateAcpiNvsMemory ( IN UINTN Size ) { @@ -65,9 +63,8 @@ AllocateAcpiNvsMemoryBelow4G ( EFI_STATUS Status; VOID *Buffer; - Address = BASE_4GB - 1; Status = gBS->AllocatePages ( - AllocateMaxAddress, + AllocateAnyPages, EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (Size), &Address @@ -230,9 +227,13 @@ CpuS3DataInitialize ( AcpiCpuData->MtrrTable = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->MtrrTable; // - // Allocate stack space for all CPUs + // Allocate stack space for all CPUs. + // Use ACPI NVS memory type because this data will be directly used by APs + // in S3 resume phase in long mode. Also during S3 resume, the stack buffer + // will only be used as scratch space. i.e. we won't read anything from it + // before we write to it, in PiSmmCpuDxeSmm. // - Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize); + Stack = AllocateAcpiNvsMemory (NumberOfCpus * AcpiCpuData->StackSize); ASSERT (Stack != NULL); AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack; -- cgit v1.1