From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 61BE2210F201A for ; Wed, 15 Aug 2018 06:11:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BAB140216EB; Wed, 15 Aug 2018 13:11:57 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-100.rdu2.redhat.com [10.10.120.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9287D7C4B; Wed, 15 Aug 2018 13:11:56 +0000 (UTC) To: Eric Dong , edk2-devel@lists.01.org Cc: =?UTF-8?Q?Marvin_H=c3=a4user?= , Fan Jeff , Ruiyu Ni References: <20180815021435.13748-1-eric.dong@intel.com> <20180815021435.13748-4-eric.dong@intel.com> From: Laszlo Ersek Message-ID: <3db35ec2-c1c8-de51-1ae9-1886dc530e4d@redhat.com> Date: Wed, 15 Aug 2018 15:11:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180815021435.13748-4-eric.dong@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 15 Aug 2018 13:11:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 15 Aug 2018 13:11:57 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [Patch v4 3/5] UefiCpuPkg/CpuS3DataDxe: Change Memory Type and address limitation. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 13:11:58 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 08/15/18 04:14, 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. > > V4 Changes: > 1. Create AllocateZeroPages and use it. It's easy to use than gBS->AllocatePages. > > Pass OS boot and resume from S3 test. > > Cc: Marvin Häuser > Cc: Fan Jeff > Cc: Laszlo Ersek > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 34 +++++++++++++++++++++++++------- > UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf | 1 + > 2 files changed, 28 insertions(+), 7 deletions(-) Reviewed-by: Laszlo Ersek Thanks, Laszlo > diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > index dccb406b8d..3e8c8b383c 100644 > --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > @@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > #include > #include > #include > +#include > > #include > #include > @@ -81,6 +82,28 @@ AllocateAcpiNvsMemoryBelow4G ( > return Buffer; > } > > +/** > + Allocate memory and clean it with zero. > + > + @param[in] Size Size of memory to allocate. > + > + @return Allocated address for output. > + > +**/ > +VOID * > +AllocateZeroPages ( > + IN UINTN Size > + ) > +{ > + VOID *Buffer; > + > + Buffer = AllocatePages (EFI_SIZE_TO_PAGES (Size)); > + if (Buffer != NULL) { > + ZeroMem (Buffer, Size); > + } > + > + return Buffer; > +} > /** > Callback function executed when the EndOfDxe event group is signaled. > > @@ -171,10 +194,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 = AllocateZeroPages (sizeof (ACPI_CPU_DATA_EX)); > ASSERT (AcpiCpuDataEx != NULL); > AcpiCpuData = &AcpiCpuDataEx->AcpiCpuData; > > @@ -223,11 +243,11 @@ CpuS3DataInitialize ( > AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile); > > // > - // 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 = AllocateZeroPages (GdtSize + IdtSize); > ASSERT (Gdt != NULL); > Idt = (VOID *)((UINTN)Gdt + GdtSize); > CopyMem (Gdt, (VOID *)AcpiCpuDataEx->GdtrProfile.Base, GdtSize); > @@ -243,7 +263,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 *)AllocateZeroPages (TableSize); > ASSERT (RegisterTable != NULL); > > for (Index = 0; Index < NumberOfCpus; Index++) { > diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > index 480c98ebcd..c16731529c 100644 > --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf > @@ -51,6 +51,7 @@ > DebugLib > BaseLib > MtrrLib > + MemoryAllocationLib > > [Guids] > gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event >