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.93; helo=mga11.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 523EE2194D387 for ; Fri, 18 Jan 2019 07:35:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2019 07:35:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,491,1539673200"; d="scan'208";a="136899487" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 18 Jan 2019 07:35:02 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 18 Jan 2019 07:35:02 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 18 Jan 2019 07:35:02 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.63]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.196]) with mapi id 14.03.0415.000; Fri, 18 Jan 2019 23:34:59 +0800 From: "Yao, Jiewen" To: Ard Biesheuvel , "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2 09/11] StandaloneMmPkg/Core/Dispatcher: don't copy dispatched image twice Thread-Index: AQHUrdlG28u7zKMr+EGS53BiEpf/FaW1Kuag Date: Fri, 18 Jan 2019 15:34:38 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503F4B19F9@shsmsx102.ccr.corp.intel.com> References: <20190116202236.6977-1-ard.biesheuvel@linaro.org> <20190116202236.6977-10-ard.biesheuvel@linaro.org> In-Reply-To: <20190116202236.6977-10-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDFiM2Y2M2QtYjJjNi00MWQxLWI3NzYtOTQ0ODkyM2VmODRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU1R3VzRvQ0N2czkyaFNPQjQwb0VSb1Z1WkxBdWdWcWZiWmtleGppdlBhTU1hbHE5UklYWjdMOGZBWWQ0R3BqZSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 09/11] StandaloneMmPkg/Core/Dispatcher: don't copy dispatched image twice 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, 18 Jan 2019 15:35:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Wednesday, January 16, 2019 12:23 PM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Achin Gupta > ; Yao, Jiewen ; Supreeth > Venkatesh ; Leif Lindholm > ; Jagadeesh Ujja ; > Thomas Panakamattam Abraham ; Sami > Mujawar > Subject: [PATCH v2 09/11] StandaloneMmPkg/Core/Dispatcher: don't copy > dispatched image twice >=20 > The dispatcher uses the PE/COFF loader to load images into the heap, > but only does so after copying the entire image first, leading to > two copies being made for no good reason. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > StandaloneMmPkg/Core/Dispatcher.c | 30 +------------------- > 1 file changed, 1 insertion(+), 29 deletions(-) >=20 > diff --git a/StandaloneMmPkg/Core/Dispatcher.c > b/StandaloneMmPkg/Core/Dispatcher.c > index 8d009b4f80c1..8a2ad5118d92 100644 > --- a/StandaloneMmPkg/Core/Dispatcher.c > +++ b/StandaloneMmPkg/Core/Dispatcher.c > @@ -294,7 +294,6 @@ MmLoadImage ( > IN OUT EFI_MM_DRIVER_ENTRY *DriverEntry > ) > { > - VOID *Buffer; > UINTN PageCount; > EFI_STATUS Status; > EFI_PHYSICAL_ADDRESS DstBuffer; > @@ -302,17 +301,12 @@ MmLoadImage ( >=20 > DEBUG ((DEBUG_INFO, "MmLoadImage - %g\n", > &DriverEntry->FileName)); >=20 > - Buffer =3D AllocateCopyPool (DriverEntry->Pe32DataSize, > DriverEntry->Pe32Data); > - if (Buffer =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > Status =3D EFI_SUCCESS; >=20 > // > // Initialize ImageContext > // > - ImageContext.Handle =3D Buffer; > + ImageContext.Handle =3D DriverEntry->Pe32Data; > ImageContext.ImageRead =3D PeCoffLoaderImageReadFromMemory; >=20 > // > @@ -320,9 +314,6 @@ MmLoadImage ( > // > Status =3D PeCoffLoaderGetImageInfo (&ImageContext); > if (EFI_ERROR (Status)) { > - if (Buffer !=3D NULL) { > - MmFreePool (Buffer); > - } > return Status; > } >=20 > @@ -336,9 +327,6 @@ MmLoadImage ( > &DstBuffer > ); > if (EFI_ERROR (Status)) { > - if (Buffer !=3D NULL) { > - MmFreePool (Buffer); > - } > return Status; > } >=20 > @@ -355,9 +343,6 @@ MmLoadImage ( > // > Status =3D PeCoffLoaderLoadImage (&ImageContext); > if (EFI_ERROR (Status)) { > - if (Buffer !=3D NULL) { > - MmFreePool (Buffer); > - } > MmFreePages (DstBuffer, PageCount); > return Status; > } > @@ -367,9 +352,6 @@ MmLoadImage ( > // > Status =3D PeCoffLoaderRelocateImage (&ImageContext); > if (EFI_ERROR (Status)) { > - if (Buffer !=3D NULL) { > - MmFreePool (Buffer); > - } > MmFreePages (DstBuffer, PageCount); > return Status; > } > @@ -393,9 +375,6 @@ MmLoadImage ( > (VOID > **)&DriverEntry->LoadedImage > ); > if (EFI_ERROR (Status)) { > - if (Buffer !=3D NULL) { > - MmFreePool (Buffer); > - } > MmFreePages (DstBuffer, PageCount); > return Status; > } > @@ -482,13 +461,6 @@ MmLoadImage ( >=20 > DEBUG_CODE_END (); >=20 > - // > - // Free buffer allocated by Fv->ReadSection. > - // > - // The UEFI Boot Services FreePool() function must be used because > Fv->ReadSection > - // used the UEFI Boot Services AllocatePool() function > - // > - MmFreePool (Buffer); > return Status; > } >=20 > -- > 2.17.1