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.88; helo=mga01.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 9509C21123E14 for ; Thu, 6 Sep 2018 22:15:05 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 22:15:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,340,1531810800"; d="scan'208";a="86752423" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 06 Sep 2018 22:15:04 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Sep 2018 22:15:04 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 6 Sep 2018 22:15:03 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.226]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0319.002; Fri, 7 Sep 2018 13:15:01 +0800 From: "Zeng, Star" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Yao, Jiewen" , "Kinney, Michael D" , Laszlo Ersek , "Zhang, Chao B" , "Zeng, Star" Thread-Topic: [edk2] [PATCH 1/4] MdeModulePkg: remove PE/COFF header workaround for ELILO on IPF Thread-Index: AQHURefuuYoJAJSfH0+kdkjOdiKPCqTkR4xg Date: Fri, 7 Sep 2018 05:15:00 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BBB6725@shsmsx102.ccr.corp.intel.com> References: <20180906134523.2036-1-ard.biesheuvel@linaro.org> <20180906134523.2036-2-ard.biesheuvel@linaro.org> In-Reply-To: <20180906134523.2036-2-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 1/4] MdeModulePkg: remove PE/COFF header workaround for ELILO on IPF 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 05:15:05 -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: Thursday, September 6, 2018 9:45 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Yao, Jiewen ;= Zeng, Star ; Kinney, Michael D ; Laszlo Ersek ; Zhang, Chao B Subject: [edk2] [PATCH 1/4] MdeModulePkg: remove PE/COFF header workaround = for ELILO on IPF Now that Itanium support has been dropped, we can remove the various occurrences of the ELILO on Itanium PE/COFF header workaround. Link: https://bugzilla.tianocore.org/show_bug.cgi?id=3D816 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c | 31 +----------------= --- MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 17 +---------- MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 17 +---------- MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c | 17 +---------- MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c | 31 +----------------= --- 5 files changed, 5 insertions(+), 108 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c b/MdeModulePkg= /Core/Dxe/Mem/MemoryProfileRecord.c index 83ed43a16e95..ff1940431c2f 100644 --- a/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c +++ b/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c @@ -254,35 +254,6 @@ GetMemoryProfileContext ( return mMemoryProfileContextPtr; } =20 -/** - Retrieves the magic value from the PE/COFF header. - - @param Hdr The buffer in which to return the PE32, PE32+, or TE heade= r. - - @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 - @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ - -**/ -UINT16 -InternalPeCoffGetPeHeaderMagicValue ( - IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr - ) -{ - // - // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magi= c value - // in the PE/COFF Header. If the MachineType is Itanium(IA64) and= the - // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR= 32_MAGIC - // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64= _MAGIC - // - if (Hdr.Pe32->FileHeader.Machine =3D=3D IMAGE_FILE_MACHINE_IA64 && Hdr.P= e32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - } - // - // Return the magic value from the PC/COFF Optional Header - // - return Hdr.Pe32->OptionalHeader.Magic; -} - /** Retrieves and returns the Subsystem of a PE/COFF image that has been loa= ded into system memory. If Pe32Data is NULL, then ASSERT(). @@ -319,7 +290,7 @@ InternalPeCoffGetSubsystem ( if (Hdr.Te->Signature =3D=3D EFI_TE_IMAGE_HEADER_SIGNATURE) { return Hdr.Te->Subsystem; } else if (Hdr.Pe32->Signature =3D=3D EFI_IMAGE_NT_SIGNATURE) { - Magic =3D InternalPeCoffGetPeHeaderMagicValue (Hdr); + Magic =3D Hdr.Pe32->OptionalHeader.Magic; if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { return Hdr.Pe32->OptionalHeader.Subsystem; } else if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/C= ore/Dxe/Misc/MemoryProtection.c index 4cd219c88efc..fa8f8fe91ac7 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c @@ -406,7 +406,6 @@ ProtectUefiImage ( IMAGE_PROPERTIES_RECORD *ImageRecord; CHAR8 *PdbPointer; IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection; - UINT16 Magic; BOOLEAN IsAligned; UINT32 ProtectionPolicy; =20 @@ -466,21 +465,7 @@ ProtectUefiImage ( // // Get SectionAlignment // - if (Hdr.Pe32->FileHeader.Machine =3D=3D IMAGE_FILE_MACHINE_IA64 && Hdr.P= e32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - // - // NOTE: Some versions of Linux ELILO for Itanium have an incorrect ma= gic value - // in the PE/COFF Header. If the MachineType is Itanium(IA64) an= d the - // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HD= R32_MAGIC - // then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_= MAGIC - // - Magic =3D EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - } else { - // - // Get the magic value from the PE/COFF Optional Header - // - Magic =3D Hdr.Pe32->OptionalHeader.Magic; - } - if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MA= GIC) { SectionAlignment =3D Hdr.Pe32->OptionalHeader.SectionAlignment; } else { SectionAlignment =3D Hdr.Pe32Plus->OptionalHeader.SectionAlignment; diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Co= re/Dxe/Misc/PropertiesTable.c index a96d442fbc64..05eb4f422b2f 100644 --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -1076,7 +1076,6 @@ InsertImageRecord ( IMAGE_PROPERTIES_RECORD *ImageRecord; CHAR8 *PdbPointer; IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection; - UINT16 Magic; =20 DEBUG ((EFI_D_VERBOSE, "InsertImageRecord - 0x%x\n", RuntimeImage)); DEBUG ((EFI_D_VERBOSE, "InsertImageRecord - 0x%016lx - 0x%016lx\n", (EFI= _PHYSICAL_ADDRESS)(UINTN)RuntimeImage->ImageBase, RuntimeImage->ImageSize))= ; @@ -1126,21 +1125,7 @@ InsertImageRecord ( // // Get SectionAlignment // - if (Hdr.Pe32->FileHeader.Machine =3D=3D IMAGE_FILE_MACHINE_IA64 && Hdr.P= e32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - // - // NOTE: Some versions of Linux ELILO for Itanium have an incorrect ma= gic value - // in the PE/COFF Header. If the MachineType is Itanium(IA64) an= d the - // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HD= R32_MAGIC - // then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_= MAGIC - // - Magic =3D EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - } else { - // - // Get the magic value from the PE/COFF Optional Header - // - Magic =3D Hdr.Pe32->OptionalHeader.Magic; - } - if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MA= GIC) { SectionAlignment =3D Hdr.Pe32->OptionalHeader.SectionAlignment; } else { SectionAlignment =3D Hdr.Pe32Plus->OptionalHeader.SectionAlignment; diff --git a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c b/MdeModul= ePkg/Core/PiSmmCore/MemoryAttributesTable.c index 1682d0f9e404..157beb1e67ff 100644 --- a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c @@ -1032,7 +1032,6 @@ SmmInsertImageRecord ( IMAGE_PROPERTIES_RECORD *ImageRecord; CHAR8 *PdbPointer; IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection; - UINT16 Magic; =20 DEBUG ((DEBUG_VERBOSE, "SMM InsertImageRecord - 0x%x\n", DriverEntry)); DEBUG ((DEBUG_VERBOSE, "SMM InsertImageRecord - 0x%016lx - 0x%08x\n", Dr= iverEntry->ImageBuffer, DriverEntry->NumberOfPage)); @@ -1076,21 +1075,7 @@ SmmInsertImageRecord ( // // Get SectionAlignment // - if (Hdr.Pe32->FileHeader.Machine =3D=3D IMAGE_FILE_MACHINE_IA64 && Hdr.P= e32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - // - // NOTE: Some versions of Linux ELILO for Itanium have an incorrect ma= gic value - // in the PE/COFF Header. If the MachineType is Itanium(IA64) an= d the - // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HD= R32_MAGIC - // then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_= MAGIC - // - Magic =3D EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - } else { - // - // Get the magic value from the PE/COFF Optional Header - // - Magic =3D Hdr.Pe32->OptionalHeader.Magic; - } - if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MA= GIC) { SectionAlignment =3D Hdr.Pe32->OptionalHeader.SectionAlignment; } else { SectionAlignment =3D Hdr.Pe32Plus->OptionalHeader.SectionAlignment; diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c b/MdeModulePk= g/Core/PiSmmCore/SmramProfileRecord.c index b586afa7948e..e8d60c2d2357 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c +++ b/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c @@ -255,35 +255,6 @@ GetSmramProfileContext ( return mSmramProfileContextPtr; } =20 -/** - Retrieves the magic value from the PE/COFF header. - - @param Hdr The buffer in which to return the PE32, PE32+, or TE heade= r. - - @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 - @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ - -**/ -UINT16 -InternalPeCoffGetPeHeaderMagicValue ( - IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr - ) -{ - // - // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magi= c value - // in the PE/COFF Header. If the MachineType is Itanium(IA64) and= the - // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR= 32_MAGIC - // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64= _MAGIC - // - if (Hdr.Pe32->FileHeader.Machine =3D=3D IMAGE_FILE_MACHINE_IA64 && Hdr.P= e32->OptionalHeader.Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - } - // - // Return the magic value from the PC/COFF Optional Header - // - return Hdr.Pe32->OptionalHeader.Magic; -} - /** Retrieves and returns the Subsystem of a PE/COFF image that has been loa= ded into system memory. If Pe32Data is NULL, then ASSERT(). @@ -320,7 +291,7 @@ InternalPeCoffGetSubsystem ( if (Hdr.Te->Signature =3D=3D EFI_TE_IMAGE_HEADER_SIGNATURE) { return Hdr.Te->Subsystem; } else if (Hdr.Pe32->Signature =3D=3D EFI_IMAGE_NT_SIGNATURE) { - Magic =3D InternalPeCoffGetPeHeaderMagicValue (Hdr); + Magic =3D Hdr.Pe32->OptionalHeader.Magic; if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { return Hdr.Pe32->OptionalHeader.Subsystem; } else if (Magic =3D=3D EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { --=20 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel