On 08/10/18 06:19, Eric Dong wrote:
> Because CpuS3Data memory will be copy to smram at SmmReadyToLock point,
> the memory type no need to be ACPI NVS type, also the address not
> limit to below 4G.
>
> This change remove the limit of ACPI NVS memory type and below 4G.
>
> Pass OS boot and resume from S3 test.
>
> Cc: Marvin Häuser <[email protected]>
> Cc: Fan Jeff <[email protected]>
> Cc: Laszlo Ersek <[email protected]>
> Cc: Ruiyu Ni <[email protected]>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <[email protected]>
> ---
> UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 43
> +++++++++++++++++++++++++++++++------
> 1 file changed, 36 insertions(+), 7 deletions(-)
>
> diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
> b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
> index dccb406b8d..5b99a6e759 100644
> --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
> +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
> @@ -81,6 +81,38 @@ AllocateAcpiNvsMemoryBelow4G (
> return Buffer;
> }
>
> +/**
> + Allocate EfiBootService memory.
> +
> + @param[in] Size Size of memory to allocate.
> +
> + @return Allocated address for output.
> +
> +**/
> +VOID *
> +AllocateBootServiceMemory (
> + IN UINTN Size
> + )
> +{
> + EFI_PHYSICAL_ADDRESS Address;
> + EFI_STATUS Status;
> + VOID *Buffer;
> +
> + Status = gBS->AllocatePages (
> + AllocateAnyPages,
> + EfiBootServicesData,
> + EFI_SIZE_TO_PAGES (Size),
> + &Address
> + );
> + if (EFI_ERROR (Status)) {
> + return NULL;
> + }
> +
> + Buffer = (VOID *)(UINTN)Address;
> + ZeroMem (Buffer, Size);
> +
> + return Buffer;
> +}
(1) If I remember correctly, we discussed AllocateZeroPages() for this.
Why did you decide against it?
CpuS3DataDxe is a DXE_DRIVER, and the matching MemoryAllocationLib
instance would allocate Boot Services Data type memory.
> /**
> Callback function executed when the EndOfDxe event group is signaled.
>
> @@ -171,10 +203,7 @@ CpuS3DataInitialize (
> //
> OldAcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress);
>
> - //
> - // Allocate ACPI NVS memory below 4G memory for use on ACPI S3 resume.
> - //
> - AcpiCpuDataEx = AllocateAcpiNvsMemoryBelow4G (sizeof (ACPI_CPU_DATA_EX));
> + AcpiCpuDataEx = AllocateBootServiceMemory (sizeof (ACPI_CPU_DATA_EX));
> ASSERT (AcpiCpuDataEx != NULL);
> AcpiCpuData = &AcpiCpuDataEx->AcpiCpuData;
>
> @@ -223,11 +252,11 @@ CpuS3DataInitialize (
> AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile);
>
(2) In the previous patch, we lifted the 4GB limitation on the stack
address (while preserving the memory type restriction as AcpiNVS).
However, you continue to allocate the stack with
AllocateAcpiNvsMemoryBelow4G().
I don't think that's consistent with the purpose of this patch set, or
with the documentation change in the previous patch. We should allocate
the stack as AcpiNVS without address limitation.
And then we can remove the AllocateAcpiNvsMemoryBelow4G() function
altogether.
> //
> - // Allocate GDT and IDT in ACPI NVS and copy current GDT and IDT contents
> + // Allocate GDT and IDT and copy current GDT and IDT contents
> //
> GdtSize = AcpiCpuDataEx->GdtrProfile.Limit + 1;
> IdtSize = AcpiCpuDataEx->IdtrProfile.Limit + 1;
> - Gdt = AllocateAcpiNvsMemoryBelow4G (GdtSize + IdtSize);
> + Gdt = AllocateBootServiceMemory (GdtSize + IdtSize);
> ASSERT (Gdt != NULL);
> Idt = (VOID *)((UINTN)Gdt + GdtSize);
> CopyMem (Gdt, (VOID *)AcpiCpuDataEx->GdtrProfile.Base, GdtSize);
> @@ -243,7 +272,7 @@ CpuS3DataInitialize (
> // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable
> for all CPUs
> //
> TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);
> - RegisterTable = (CPU_REGISTER_TABLE *)AllocateAcpiNvsMemoryBelow4G
> (TableSize);
> + RegisterTable = (CPU_REGISTER_TABLE *)AllocateBootServiceMemory
> (TableSize);
> ASSERT (RegisterTable != NULL);
>
> for (Index = 0; Index < NumberOfCpus; Index++) {
>
Thanks,
Laszlo
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel