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 <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
index 5b99a6e759..d18f33a5b8 100644
--- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
+++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c
@@ -46,9 +46,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.
@@ -56,7 +54,7 @@ typedef struct {
**/
VOID *
-AllocateAcpiNvsMemoryBelow4G (
+AllocateAcpiNvsMemory (
IN UINTN Size
)
{
@@ -64,9 +62,8 @@ AllocateAcpiNvsMemoryBelow4G (
EFI_STATUS Status;
VOID *Buffer;
- Address = BASE_4GB - 1;
Status = gBS->AllocatePages (
- AllocateMaxAddress,
+ AllocateAnyPages,
EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES (Size),
&Address
@@ -239,9 +236,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 PiSmmCpuDxeSemm.
//
- Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize);
+ Stack = AllocateAcpiNvsMemory (NumberOfCpus * AcpiCpuData->StackSize);
ASSERT (Stack != NULL);
AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack;
--
2.15.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
On 08/10/18 06:19, Eric Dong wrote: > 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 <lersek@redhat.com> > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > --- > UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > index 5b99a6e759..d18f33a5b8 100644 > --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > @@ -46,9 +46,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. > > @@ -56,7 +54,7 @@ typedef struct { > > **/ > VOID * > -AllocateAcpiNvsMemoryBelow4G ( > +AllocateAcpiNvsMemory ( > IN UINTN Size > ) > { > @@ -64,9 +62,8 @@ AllocateAcpiNvsMemoryBelow4G ( > EFI_STATUS Status; > VOID *Buffer; > > - Address = BASE_4GB - 1; > Status = gBS->AllocatePages ( > - AllocateMaxAddress, > + AllocateAnyPages, > EfiACPIMemoryNVS, > EFI_SIZE_TO_PAGES (Size), > &Address > @@ -239,9 +236,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 PiSmmCpuDxeSemm. Please fix the typo: "PiSmmCpuDxeSemm" --> "PiSmmCpuDxeSmm". With that: Reviewed-by: Laszlo Ersek <lersek@redhat.com> Thanks Laszlo > // > - Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize); > + Stack = AllocateAcpiNvsMemory (NumberOfCpus * AcpiCpuData->StackSize); > ASSERT (Stack != NULL); > AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack; > > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Thanks/Ray > -----Original Message----- > From: Dong, Eric > Sent: Friday, August 10, 2018 12:19 PM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek <lersek@redhat.com>; Ni, Ruiyu <ruiyu.ni@intel.com> > Subject: [Patch v3 4/5] 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 <lersek@redhat.com> > Cc: Ruiyu Ni <ruiyu.ni@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong <eric.dong@intel.com> > --- > UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > index 5b99a6e759..d18f33a5b8 100644 > --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > @@ -46,9 +46,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. > > @@ -56,7 +54,7 @@ typedef struct { > > **/ > VOID * > -AllocateAcpiNvsMemoryBelow4G ( > +AllocateAcpiNvsMemory ( > IN UINTN Size > ) > { > @@ -64,9 +62,8 @@ AllocateAcpiNvsMemoryBelow4G ( > EFI_STATUS Status; > VOID *Buffer; > > - Address = BASE_4GB - 1; > Status = gBS->AllocatePages ( > - AllocateMaxAddress, > + AllocateAnyPages, > EfiACPIMemoryNVS, > EFI_SIZE_TO_PAGES (Size), > &Address > @@ -239,9 +236,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 PiSmmCpuDxeSemm. > // > - Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData- > >StackSize); > + Stack = AllocateAcpiNvsMemory (NumberOfCpus * > + AcpiCpuData->StackSize); > ASSERT (Stack != NULL); > AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack; > > -- > 2.15.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.