From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 E392D210DBE78 for ; Tue, 14 Aug 2018 22:41:34 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2018 22:41:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,241,1531810800"; d="scan'208";a="75481383" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 14 Aug 2018 22:41:03 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Aug 2018 22:41:03 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.143]) by shsmsx102.ccr.corp.intel.com ([169.254.2.226]) with mapi id 14.03.0319.002; Wed, 15 Aug 2018 13:41:00 +0800 From: "Ni, Ruiyu" To: "Dong, Eric" , "edk2-devel@lists.01.org" CC: Laszlo Ersek Thread-Topic: [edk2] [Patch v4 3/5] UefiCpuPkg/CpuS3DataDxe: Change Memory Type and address limitation. Thread-Index: AQHUND3FfYq0yEuHn02ZfxToNm+VjaTATG9A Date: Wed, 15 Aug 2018 05:40:53 +0000 Deferred-Delivery: Wed, 15 Aug 2018 05:41:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BDD522E@SHSMSX104.ccr.corp.intel.com> References: <20180815021435.13748-1-eric.dong@intel.com> <20180815021435.13748-4-eric.dong@intel.com> In-Reply-To: <20180815021435.13748-4-eric.dong@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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 05:41:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni Thanks/Ray > -----Original Message----- > From: edk2-devel On Behalf Of Eric Dong > Sent: Wednesday, August 15, 2018 10:15 AM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Ni, Ruiyu > Subject: [edk2] [Patch v4 3/5] UefiCpuPkg/CpuS3DataDxe: Change Memory > Type and address limitation. >=20 > 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 t= o > below 4G. >=20 > This change remove the limit of ACPI NVS memory type and below 4G. >=20 > V4 Changes: > 1. Create AllocateZeroPages and use it. It's easy to use than gBS->Alloca= tePages. >=20 > Pass OS boot and resume from S3 test. >=20 > Cc: Marvin H=E4user > 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(-) >=20 > 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 >=20 > #include > #include > @@ -81,6 +82,28 @@ AllocateAcpiNvsMemoryBelow4G ( > return Buffer; > } >=20 > +/** > + 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 =3D AllocatePages (EFI_SIZE_TO_PAGES (Size)); if (Buffer !=3D > + NULL) { > + ZeroMem (Buffer, Size); > + } > + > + return Buffer; > +} > /** > Callback function executed when the EndOfDxe event group is signaled. >=20 > @@ -171,10 +194,7 @@ CpuS3DataInitialize ( > // > OldAcpiCpuData =3D (ACPI_CPU_DATA *) (UINTN) PcdGet64 > (PcdCpuS3DataAddress); >=20 > - // > - // Allocate ACPI NVS memory below 4G memory for use on ACPI S3 resume. > - // > - AcpiCpuDataEx =3D AllocateAcpiNvsMemoryBelow4G (sizeof > (ACPI_CPU_DATA_EX)); > + AcpiCpuDataEx =3D AllocateZeroPages (sizeof (ACPI_CPU_DATA_EX)); > ASSERT (AcpiCpuDataEx !=3D NULL); > AcpiCpuData =3D &AcpiCpuDataEx->AcpiCpuData; >=20 > @@ -223,11 +243,11 @@ CpuS3DataInitialize ( > AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile); >=20 > // > - // Allocate GDT and IDT in ACPI NVS and copy current GDT and IDT conte= nts > + // Allocate GDT and IDT and copy current GDT and IDT contents > // > GdtSize =3D AcpiCpuDataEx->GdtrProfile.Limit + 1; > IdtSize =3D AcpiCpuDataEx->IdtrProfile.Limit + 1; > - Gdt =3D AllocateAcpiNvsMemoryBelow4G (GdtSize + IdtSize); > + Gdt =3D AllocateZeroPages (GdtSize + IdtSize); > ASSERT (Gdt !=3D NULL); > Idt =3D (VOID *)((UINTN)Gdt + GdtSize); > CopyMem (Gdt, (VOID *)AcpiCpuDataEx->GdtrProfile.Base, GdtSize); @@ - > 243,7 +263,7 @@ CpuS3DataInitialize ( > // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTab= le for > all CPUs > // > TableSize =3D 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); > - RegisterTable =3D (CPU_REGISTER_TABLE *)AllocateAcpiNvsMemoryBelow4G > (TableSize); > + RegisterTable =3D (CPU_REGISTER_TABLE *)AllocateZeroPages > + (TableSize); > ASSERT (RegisterTable !=3D NULL); >=20 > for (Index =3D 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 >=20 > [Guids] > gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event > -- > 2.15.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel