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.136; helo=mga12.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 0410B207E36CD for ; Mon, 28 May 2018 21:44:25 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 May 2018 21:44:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,455,1520924400"; d="scan'208";a="42940305" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga007.fm.intel.com with ESMTP; 28 May 2018 21:44:25 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 28 May 2018 20:08:31 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 28 May 2018 18:33:00 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.87]) with mapi id 14.03.0319.002; Tue, 29 May 2018 09:32:48 +0800 From: "Zeng, Star" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [edk2] [PATCH v3 5/5] MdeModulePkg/FirmwarePerformanceDataTableDxe: use AllocatePeiAccessiblePages Thread-Index: AQHT9pHoQQKXUfJygkiEKTlZvrnXAKRF7K+A Date: Tue, 29 May 2018 01:32:48 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB47F0E@shsmsx102.ccr.corp.intel.com> References: <20180528144024.10809-1-ard.biesheuvel@linaro.org> <20180528144024.10809-6-ard.biesheuvel@linaro.org> In-Reply-To: <20180528144024.10809-6-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v3 5/5] MdeModulePkg/FirmwarePerformanceDataTableDxe: use AllocatePeiAccessiblePages X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 04:44:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ard = Biesheuvel Sent: Monday, May 28, 2018 10:40 PM To: edk2-devel@lists.01.org Cc: Ard Biesheuvel Subject: [edk2] [PATCH v3 5/5] MdeModulePkg/FirmwarePerformanceDataTableDxe= : use AllocatePeiAccessiblePages Replace the call to and implementation of the function FpdtAllocateReservedMemoryBelow4G() with a call to AllocatePeiAccessiblePag= es, which boils down to the same on X64, but does not crash non-X64 systems= that lack memory below 4 GB. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerfor= manceDxe.c | 51 ++++---------------- MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerfor= manceDxe.inf | 1 + 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/Fi= rmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDat= aTableDxe/FirmwarePerformanceDxe.c index e719e9e482cb..ded817f37301 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwareP= erformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/Firmwa +++ rePerformanceDxe.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -179,46 +180,6 @@ FpdtAcpiTabl= eChecksum ( Buffer[ChecksumOffset] =3D CalculateCheckSum8 (Buffer, Size); } =20 -/** - Allocate EfiReservedMemoryType below 4G memory address. - - This function allocates EfiReservedMemoryType below 4G memory address. - - @param[in] Size Size of memory to allocate. - - @return Allocated address for output. - -**/ -VOID * -FpdtAllocateReservedMemoryBelow4G ( - IN UINTN Size - ) -{ - UINTN Pages; - EFI_PHYSICAL_ADDRESS Address; - EFI_STATUS Status; - VOID *Buffer; - - Buffer =3D NULL; - Pages =3D EFI_SIZE_TO_PAGES (Size); - Address =3D 0xffffffff; - - Status =3D gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - Pages, - &Address - ); - ASSERT_EFI_ERROR (Status); - - if (!EFI_ERROR (Status)) { - Buffer =3D (VOID *) (UINTN) Address; - ZeroMem (Buffer, Size); - } - - return Buffer; -} - /** Callback function upon VariableArchProtocol and LockBoxProtocol to allocate S3 performance table memory and save the pointer to LockBox. @@ -287,7 +248,10 @@ FpdtAllocateS3PerformanceTableMemory ( // // Fail to allocate at specified address, continue to allocate at = any address. // - mAcpiS3PerformanceTable =3D (S3_PERFORMANCE_TABLE *) FpdtAllocateR= eservedMemoryBelow4G (sizeof (S3_PERFORMANCE_TABLE)); + mAcpiS3PerformanceTable =3D (S3_PERFORMANCE_TABLE *) AllocatePeiAc= cessiblePages ( + EfiReservedMe= moryType, + EFI_SIZE_TO_P= AGES (sizeof (S3_PERFORMANCE_TABLE)) + ); } DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address =3D 0x%= x\n", mAcpiS3PerformanceTable)); if (mAcpiS3PerformanceTable !=3D NULL) { @@ -368,7 +332,10 @@ Instal= lFirmwarePerformanceDataTable ( // // Fail to allocate at specified address, continue to allocate at an= y address. // - mAcpiBootPerformanceTable =3D (BOOT_PERFORMANCE_TABLE *) FpdtAllocat= eReservedMemoryBelow4G (BootPerformanceDataSize); + mAcpiBootPerformanceTable =3D (BOOT_PERFORMANCE_TABLE *) AllocatePei= AccessiblePages ( + EfiReserved= MemoryType, + EFI_SIZE_TO= _PAGES (BootPerformanceDataSize) + ); } DEBUG ((DEBUG_INFO, "FPDT: ACPI Boot Performance Table address =3D 0x%= x\n", mAcpiBootPerformanceTable)); if (mAcpiBootPerformanceTable =3D=3D NULL) { diff --git a/MdeModulePkg= /Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf = b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerfo= rmanceDxe.inf index 8757bbd0aaa9..3d2dd6eb732f 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwareP= erformanceDxe.inf +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/Firmwa +++ rePerformanceDxe.inf @@ -44,6 +44,7 @@ [LibraryClasses] UefiRuntimeServicesTableLib BaseLib DebugLib + DxeServicesLib TimerLib BaseMemoryLib MemoryAllocationLib -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel