From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 5877F21123E14 for ; Thu, 6 Sep 2018 20:24:01 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 20:24:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,340,1531810800"; d="scan'208";a="68194692" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga007.fm.intel.com with ESMTP; 06 Sep 2018 20:23:50 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Sep 2018 20:23:50 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Sep 2018 20:23:50 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.226]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.143]) with mapi id 14.03.0319.002; Fri, 7 Sep 2018 11:23:48 +0800 From: "Zeng, Star" To: "Gao, Liming" , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg PeiCore: Always use PeiImageRead() function to load PEI image Thread-Index: AQHURSNZU3rR/xyJE0Cj3+PFZ4pWvaTkKgDQ Date: Fri, 7 Sep 2018 03:23:47 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BBB66AC@shsmsx102.ccr.corp.intel.com> References: <20180905141744.11480-1-liming.gao@intel.com> In-Reply-To: <20180905141744.11480-1-liming.gao@intel.com> 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 v2] MdeModulePkg PeiCore: Always use PeiImageRead() function to load PEI image X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2018 03:24:02 -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 Limi= ng Gao Sent: Wednesday, September 5, 2018 10:18 PM To: edk2-devel@lists.01.org Subject: [edk2] [PATCH v2] MdeModulePkg PeiCore: Always use PeiImageRead() = function to load PEI image In V2, Remove GetImageReadFunction(), directly use PeiImageRead(). The copy PeiImageReadForShadow function doesn't improve the boot performanc= e. This patch removes this copy logic to simplify the code logic. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao --- MdeModulePkg/Core/Pei/Image/Image.c | 85 +--------------------------------= ---- 1 file changed, 1 insertion(+), 84 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Im= age/Image.c index f84f2c7..315b551 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -61,87 +61,6 @@ PeiImageRead ( } =20 /** - - Support routine for the PE/COFF Loader that reads a buffer from a PE/COF= F file. - The function is implemented as PIC so as to support shadowing. - - @param FileHandle - The handle to the PE/COFF file - @param FileOffset - The offset, in bytes, into the file to read - @param ReadSize - The number of bytes to read from the file start= ing at FileOffset - @param Buffer - A pointer to the buffer to read the data into. - - @return EFI_SUCCESS - ReadSize bytes of data were read into Buffer from = the PE/COFF file starting at FileOffset - -**/ -EFI_STATUS -EFIAPI -PeiImageReadForShadow ( - IN VOID *FileHandle, - IN UINTN FileOffset, - IN UINTN *ReadSize, - OUT VOID *Buffer - ) -{ - volatile CHAR8 *Destination8; - CHAR8 *Source8; - UINTN Length; - - Destination8 =3D Buffer; - Source8 =3D (CHAR8 *) ((UINTN) FileHandle + FileOffset); - if (Destination8 !=3D Source8) { - Length =3D *ReadSize; - while ((Length--) > 0) { - *(Destination8++) =3D *(Source8++); - } - } - - return EFI_SUCCESS; -} - -/** - - Support routine to get the Image read file function. - - @param ImageContext - The context of the image being loaded - - @retval EFI_SUCCESS - If Image function location is found - -**/ -EFI_STATUS -GetImageReadFunction ( - IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -{ -#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) - PEI_CORE_INSTANCE *Private; - EFI_PHYSICAL_ADDRESS MemoryBuffer; - - Private =3D PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer (= )); - MemoryBuffer =3D 0; - - if (Private->PeiMemoryInstalled && (((Private->HobList.HandoffInformati= onTable->BootMode !=3D BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoo= t)) || - ((Private->HobList.HandoffInformationTable->BootMode =3D=3D BOOT_ON_= S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) { - // - // Shadow algorithm makes lots of non ANSI C assumptions and only work= s for IA32 and X64 - // compilers that have been tested - // - if (Private->ShadowedImageRead =3D=3D NULL) { - PeiServicesAllocatePages (EfiBootServicesCode, 0x400 / EFI_PAGE_SIZE= + 1, &MemoryBuffer); - ASSERT (MemoryBuffer !=3D 0); - CopyMem ((VOID *)(UINTN)MemoryBuffer, (CONST VOID *) (UINTN) PeiImag= eReadForShadow, 0x400); - Private->ShadowedImageRead =3D (PE_COFF_LOADER_READ_FILE) (UINTN) Me= moryBuffer; - } - - ImageContext->ImageRead =3D Private->ShadowedImageRead; - } else { - ImageContext->ImageRead =3D PeiImageRead; - } -#else - ImageContext->ImageRead =3D PeiImageRead; -#endif - return EFI_SUCCESS; -} -/** To check memory usage bit map array to figure out if the memory range th= e image will be loaded in is available or not. If memory range is available, the function will mark the corresponding bits= to 1 which indicates the memory range is used. The function is only invoked when load modules at fixed address feature = is enabled. @@ -369,9 +288,7 @@ LoadAndRelocatePeCoffImage ( IsXipImage =3D FALSE; ZeroMem (&ImageContext, sizeof (ImageContext)); ImageContext.Handle =3D Pe32Data; - Status =3D GetImageReadFunction (&ImageContext); - - ASSERT_EFI_ERROR (Status); + ImageContext.ImageRead =3D PeiImageRead; =20 Status =3D PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { -- 2.10.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel