From nobody Tue Apr 23 15:51:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1533874780171830.2723101602586; Thu, 9 Aug 2018 21:19:40 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CC108210EB11E; Thu, 9 Aug 2018 21:19:28 -0700 (PDT) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 C244921BADAB9 for ; Thu, 9 Aug 2018 21:19:26 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2018 21:19:24 -0700 Received: from ydong10-win10.ccr.corp.intel.com ([10.239.9.125]) by orsmga003.jf.intel.com with ESMTP; 09 Aug 2018 21:19:17 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,218,1531810800"; d="scan'208";a="74234300" From: Eric Dong To: edk2-devel@lists.01.org Date: Fri, 10 Aug 2018 12:19:07 +0800 Message-Id: <20180810041909.12776-4-eric.dong@intel.com> X-Mailer: git-send-email 2.15.0.windows.1 In-Reply-To: <20180810041909.12776-1-eric.dong@intel.com> References: <20180810041909.12776-1-eric.dong@intel.com> MIME-Version: 1.0 Subject: [edk2] [Patch v3 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: , Cc: Laszlo Ersek , Ruiyu Ni Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RDMRC_1 RSF_4 Z_629925259 SPT_0 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=C3=A4user Cc: Fan Jeff Cc: Laszlo Ersek Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong Reviewed-by: Laszlo Ersek --- 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; } =20 +/** + 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 =3D gBS->AllocatePages ( + AllocateAnyPages, + EfiBootServicesData, + EFI_SIZE_TO_PAGES (Size), + &Address + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + Buffer =3D (VOID *)(UINTN)Address; + ZeroMem (Buffer, Size); + + return Buffer; +} /** Callback function executed when the EndOfDxe event group is signaled. =20 @@ -171,10 +203,7 @@ CpuS3DataInitialize ( // OldAcpiCpuData =3D (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddre= ss); =20 - // - // Allocate ACPI NVS memory below 4G memory for use on ACPI S3 resume. - // - AcpiCpuDataEx =3D AllocateAcpiNvsMemoryBelow4G (sizeof (ACPI_CPU_DATA_EX= )); + AcpiCpuDataEx =3D AllocateBootServiceMemory (sizeof (ACPI_CPU_DATA_EX)); ASSERT (AcpiCpuDataEx !=3D NULL); AcpiCpuData =3D &AcpiCpuDataEx->AcpiCpuData; =20 @@ -223,11 +252,11 @@ CpuS3DataInitialize ( AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile); =20 // - // 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 =3D AcpiCpuDataEx->GdtrProfile.Limit + 1; IdtSize =3D AcpiCpuDataEx->IdtrProfile.Limit + 1; - Gdt =3D AllocateAcpiNvsMemoryBelow4G (GdtSize + IdtSize); + Gdt =3D AllocateBootServiceMemory (GdtSize + IdtSize); ASSERT (Gdt !=3D NULL); Idt =3D (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 =3D 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); - RegisterTable =3D (CPU_REGISTER_TABLE *)AllocateAcpiNvsMemoryBelow4G (= TableSize); + RegisterTable =3D (CPU_REGISTER_TABLE *)AllocateBootServiceMemory (Tab= leSize); ASSERT (RegisterTable !=3D NULL); =20 for (Index =3D 0; Index < NumberOfCpus; Index++) { --=20 2.15.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel