public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Star Zeng <star.zeng@intel.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Chao Zhang <chao.b.zhang@intel.com>
Subject: Re: [PATCH 1/4] MdeModulePkg: remove PE/COFF header workaround for ELILO on IPF
Date: Thu, 6 Sep 2018 18:29:22 +0200	[thread overview]
Message-ID: <d7009c1d-4f25-287d-61bc-ff739e58d9c3@redhat.com> (raw)
In-Reply-To: <20180906134523.2036-2-ard.biesheuvel@linaro.org>

On 09/06/18 15:45, Ard Biesheuvel wrote:
> 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=816
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  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;
>  }
>  
> -/**
> -  Retrieves the magic value from the PE/COFF header.
> -
> -  @param Hdr    The buffer in which to return the PE32, PE32+, or TE header.
> -
> -  @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 magic value
> -  //       in the PE/COFF Header.  If the MachineType is Itanium(IA64) and the
> -  //       Magic value in the OptionalHeader is  EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
> -  //       then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
> -  //
> -  if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == 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 loaded into system memory.
>    If Pe32Data is NULL, then ASSERT().
> @@ -319,7 +290,7 @@ InternalPeCoffGetSubsystem (
>    if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
>      return Hdr.Te->Subsystem;
>    } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {
> -    Magic = InternalPeCoffGetPeHeaderMagicValue (Hdr);
> +    Magic = Hdr.Pe32->OptionalHeader.Magic;
>      if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>        return Hdr.Pe32->OptionalHeader.Subsystem;
>      } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
> diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/Core/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;
>  
> @@ -466,21 +465,7 @@ ProtectUefiImage (
>    //
>    // Get SectionAlignment
>    //
> -  if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> -    //
> -    // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
> -    //       in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
> -    //       Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
> -    //       then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
> -    //
> -    Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
> -  } else {
> -    //
> -    // Get the magic value from the PE/COFF Optional Header
> -    //
> -    Magic = Hdr.Pe32->OptionalHeader.Magic;
> -  }
> -  if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> +  if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>      SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;
>    } else {
>      SectionAlignment  = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
> diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/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;
>  
>    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 == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> -    //
> -    // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
> -    //       in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
> -    //       Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
> -    //       then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
> -    //
> -    Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
> -  } else {
> -    //
> -    // Get the magic value from the PE/COFF Optional Header
> -    //
> -    Magic = Hdr.Pe32->OptionalHeader.Magic;
> -  }
> -  if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> +  if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>      SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;
>    } else {
>      SectionAlignment  = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
> diff --git a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c b/MdeModulePkg/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;
>  
>    DEBUG ((DEBUG_VERBOSE, "SMM InsertImageRecord - 0x%x\n", DriverEntry));
>    DEBUG ((DEBUG_VERBOSE, "SMM InsertImageRecord - 0x%016lx - 0x%08x\n", DriverEntry->ImageBuffer, DriverEntry->NumberOfPage));
> @@ -1076,21 +1075,7 @@ SmmInsertImageRecord (
>    //
>    // Get SectionAlignment
>    //
> -  if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> -    //
> -    // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
> -    //       in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
> -    //       Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
> -    //       then override the magic value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
> -    //
> -    Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
> -  } else {
> -    //
> -    // Get the magic value from the PE/COFF Optional Header
> -    //
> -    Magic = Hdr.Pe32->OptionalHeader.Magic;
> -  }
> -  if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
> +  if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>      SectionAlignment  = Hdr.Pe32->OptionalHeader.SectionAlignment;
>    } else {
>      SectionAlignment  = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
> diff --git a/MdeModulePkg/Core/PiSmmCore/SmramProfileRecord.c b/MdeModulePkg/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;
>  }
>  
> -/**
> -  Retrieves the magic value from the PE/COFF header.
> -
> -  @param Hdr    The buffer in which to return the PE32, PE32+, or TE header.
> -
> -  @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 magic value
> -  //       in the PE/COFF Header.  If the MachineType is Itanium(IA64) and the
> -  //       Magic value in the OptionalHeader is  EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
> -  //       then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
> -  //
> -  if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == 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 loaded into system memory.
>    If Pe32Data is NULL, then ASSERT().
> @@ -320,7 +291,7 @@ InternalPeCoffGetSubsystem (
>    if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
>      return Hdr.Te->Subsystem;
>    } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE)  {
> -    Magic = InternalPeCoffGetPeHeaderMagicValue (Hdr);
> +    Magic = Hdr.Pe32->OptionalHeader.Magic;
>      if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
>        return Hdr.Pe32->OptionalHeader.Subsystem;
>      } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>


  reply	other threads:[~2018-09-06 16:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 13:45 [PATCH 0/4] remove all 11 occurrences of ELILO on IPF PE/COFF header hack Ard Biesheuvel
2018-09-06 13:45 ` [PATCH 1/4] MdeModulePkg: remove PE/COFF header workaround for ELILO on IPF Ard Biesheuvel
2018-09-06 16:29   ` Laszlo Ersek [this message]
2018-09-07  5:15   ` Zeng, Star
2018-09-06 13:45 ` [PATCH 2/4] MdePkg/BasePeCoffLib: " Ard Biesheuvel
2018-09-06 16:31   ` Laszlo Ersek
2018-09-07  5:15   ` Zeng, Star
2018-09-07  5:36     ` Gao, Liming
2018-09-06 13:45 ` [PATCH 3/4] SecurityPkg: " Ard Biesheuvel
2018-09-06 16:47   ` Laszlo Ersek
2018-09-06 17:25     ` Ard Biesheuvel
2018-09-06 18:22       ` Laszlo Ersek
2018-09-06 13:45 ` [PATCH 4/4] EdkCompatibilityPkg: " Ard Biesheuvel
2018-09-06 16:53   ` Laszlo Ersek
2018-09-06 17:27     ` Ard Biesheuvel
2018-09-06 18:01       ` Carsey, Jaben
2018-09-06 18:15         ` Laszlo Ersek
2018-09-06 14:05 ` [PATCH 0/4] remove all 11 occurrences of ELILO on IPF PE/COFF header hack Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7009c1d-4f25-287d-61bc-ff739e58d9c3@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox