From patchwork Thu Sep 6 13:45:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146090 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp534279ljw; Thu, 6 Sep 2018 06:45:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZMPDykAr7IJ6mQ+1s3MxLmDnJUUTMtLSrjk2/mr4+exE9i9jdRiOvqVzw4BB9nvzwPeYy4 X-Received: by 2002:a62:219b:: with SMTP id o27-v6mr2831414pfj.235.1536241544448; Thu, 06 Sep 2018 06:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536241544; cv=none; d=google.com; s=arc-20160816; b=hSP+JBOvcteRMbs21BPAj/15O/yipUPF0L+nieibqPduCPVXX9wniLrSaVStWGZHa5 1oJWFE7Og3Dk0Mg1OE/XTG2zgz+kitQjom1iiEL00/6aAQIHjNI7B5YyAEW6Ss/++KrR d9CW61IGiIUI7xfiRuw3XocFxEwN+/v1yxj/Y/L62b7K2ii3+HvuRbu0JjDSNUPlf9Zk J3q3NoF6vZ26p7UP30b3rpnrgKZzLQ68O//o6P2WYEX7dKV9VQaNcEwQRLQWt57VDeEt FgNN+bT7UI5X5wy4uovKbtbh++6lM9o3C8xdOZKTsqi8FzLXMj27Z00jFaVjkX+L/VB5 ok+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=mjSHlk71egSvAYOmk/dF0D4nSZJ0upz6phVgDlIfKqY=; b=mcp0HkvTf0Hfxs2yQ77DmBFJfjl8uZgVgWtsWepeWjleayB0rAV81C8PvqMRcNW2G7 zKs0Yojb5MHuS+lj+5MdoUmDT8B3zDAZNcOZlqo8/HufHLoWCAwLNlmNezdW6QG4D/Ci OBeEAn9OEma2ZFBubrWTdxpLKvaRX1yIOEYIsCDcVBGo3axdFzGJDDISpspcrU2Ss2UI z9OgS/6UuqWxL+2EIyHWB1Ad0Rrjcit5DGJy+tcfk/u+Uttk3/R74/66ptIRpewTH9sR DuA95D6W62PK7Y0jv9db+HYnkEKoQBVWLYFS+0h9HlgxGg55ecPnu5igFf2luZ1KpW3Y mJwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hXVPChxy; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id p15-v6si5091409pgh.281.2018.09.06.06.45.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hXVPChxy; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A72A22112294B; Thu, 6 Sep 2018 06:45:43 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::541; helo=mail-ed1-x541.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 07186209831C6 for ; Thu, 6 Sep 2018 06:45:41 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id z27-v6so8927713edb.10 for ; Thu, 06 Sep 2018 06:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vPWGeCgAY7/v/bk+P1kiPnb3UCke8GYfXsqPe88CK8Q=; b=hXVPChxyUYCUZG2zRaAMK78GKOc0mlopLETbqtprfYDzZDRhA/0XQgAzchAqqwbDrK 8evrfOuv3W55JGXUB7s3+1vTYMsCLyhmApkoY/ztA3/YkpFsNj/x5+UT+miLkSXxvxhT UAMy19atSEmr0tzkqsfRLIYetFsfhu6XS/CGk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vPWGeCgAY7/v/bk+P1kiPnb3UCke8GYfXsqPe88CK8Q=; b=dywWskZrG9opuLsYnvwXQFwbXpLWGyNX359l3cGsQRT5TV7BMBjTZgLDfvJlsD64kM YKabpRwQrevvXFoKvQvQgWxbBMTUHnxkLyqBQmtuX4t7dWU7J5Y+RwBKycIqrnQ3STdC urongQxEbZR/OPKyKPvUWqulKpJS4jWJ2vehnDlE9zx+SyJI9lTXHn/Ppcjix32UWHnw YzFoI7LdTu+y3R51fAA8+MgcnOf2CsJbB2XXST0YOocTtPrpYSl6vnxONF4R05biOwu2 viFADPuKfDzMY/0Us/ZeQS3n2UwGpJV+t2zGJQ7AI+SY01NPzSUX2jryk7UMuCT7rIGN 3mxQ== X-Gm-Message-State: APzg51C5ZlUnIuABSAr5EYuaxBiK2gWBd+S56o5TnZUt3S0/nyC7Aqkn /DbkVef0F+wWPeZr5lSe1rF14WAfqOdZwrTk X-Received: by 2002:a50:f297:: with SMTP id f23-v6mr3716210edm.40.1536241540134; Thu, 06 Sep 2018 06:45:40 -0700 (PDT) Received: from rev02.home ([2a02:a212:9283:9800:24b9:e2d6:9acc:50dd]) by smtp.gmail.com with ESMTPSA id l48-v6sm2818764eda.94.2018.09.06.06.45.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:39 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 6 Sep 2018 15:45:20 +0200 Message-Id: <20180906134523.2036-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180906134523.2036-1-ard.biesheuvel@linaro.org> References: <20180906134523.2036-1-ard.biesheuvel@linaro.org> Subject: [edk2] [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: , Cc: Liming Gao , Jiewen Yao , Star Zeng , Michael D Kinney , Laszlo Ersek , Chao Zhang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- 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(-) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek Reviewed-by: Star Zeng Signed-off-by: Ard Biesheuvel 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) { From patchwork Thu Sep 6 13:45:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146091 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp534349ljw; Thu, 6 Sep 2018 06:45:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYUSiBCH7FiYfwLf1d0a8z7fji2PbR0+pDk7OQQ5SXY9QxBTsWB+aqJf0VHMefSU91DqDDj X-Received: by 2002:a62:1314:: with SMTP id b20-v6mr2933448pfj.230.1536241547830; Thu, 06 Sep 2018 06:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536241547; cv=none; d=google.com; s=arc-20160816; b=rkGOPjJBl/5cPjp+4OHS/EX/i75BaYx4ZkLSfjuiuuF/4HiyxiEJANDs/225JPWmHg LSCdp7ob/X5eslEIgYj3RDiNSfgvXJbnbBhIUAfdw+qyxLE4tAgrfWqeux3dawWAUpJU PElj3ikiT0aG8VW5KW9WvowpeJiNHaseH6Mg3KRCjXSJuUx5766SRgXac+/g7NH2fyzy b4wFIPn2JSq3UPL59KXrRJx6FudQh2uChZwJXtEvsJN+BKeuXDhDySySbyCFVKx3Z6hH 6hm4m2IPtBKmzWUyzFf/LWKnjjO8D3g8fzad1ugv6dhk/4QUmXWaLFRpLDAWoUiTnyNi JFNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=cmQsrXiPv1eKjdluMZAg2Xd5AdW3m0TANw0WqdRcjDg=; b=YyhsGrVWZiqfp4Lj69t5mIn4tzmTVC5bZ/vhyjyeA3DCoBhSlCSUkiOQp2zC9L+l3q TFxHdMYmzIC3NYCtLi8hTMziXCv//Ku575E7COElfqMUEKHA1FF2Cxxc5MUzWqWz1MRu Av/CiAqY0aC7U8oGFLqYkUdlhozPvTO5gHk1YLz1LNJMoPKvJxOV/aZnYddzC4tf2KGF aWaCMupyDO0lPrd5x7TXPLmN/x5Yf9sqhMaKERIFJGihxPN9fIuK2/rJQnXOSDnIlbR9 GV8zuR+bDWcR9zm7LbxpKDBi4f2A6AsL4HK2GDDEOOd4V0DVGZT6egKk0R29YNE12HPy nJ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iZU624Vf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id b7-v6si5038436plm.250.2018.09.06.06.45.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iZU624Vf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D3B202112294F; Thu, 6 Sep 2018 06:45:45 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::542; helo=mail-ed1-x542.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8F9CE21122948 for ; Thu, 6 Sep 2018 06:45:43 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id a20-v6so8936891edd.4 for ; Thu, 06 Sep 2018 06:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V1KGLUw0c7CE6L8x2k064030AHrw2hpPK7wcv+1NhFY=; b=iZU624VfVF6b9UJeBLMGG+5CgedrllQCiYAhFX45EtZe3Om7dGeRGVStDuA3ZyI9qc nNO2fjFMBZ/+xorJCWGVz4mGz/9hEQV0cdUZdbYOCriMqVrvG+Nf0cp7afHwd7ybb+P4 eI0ilOfzmetmUvsud3/dYzIqBTyzPgQ5/JPQg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V1KGLUw0c7CE6L8x2k064030AHrw2hpPK7wcv+1NhFY=; b=T4wReUmnOyUQMHQGLvRHaqAAUww55fntKF0fZEtqiX6HrrotybGQS9saUXKOfcJdM7 MdZ8R80NgkRSnQL1DshiVHwYpiYqiLDsGJ2kRWPSKfuOpDEu1GWaFwq5ztr0wnxcIo6O CaVnTjIdE6zxaKoI0iPHk6Y1JUz7WgkTboL4/OYKlr/YQ7uZR4vM1SrHVVg9HDQFrbN4 wSGLzSgfH9lxFcQRKGHf50m0QNA00gFeu1yhErItmIU7Km1tWxBTiU+SMhVRe7R2cKqF HRUWQQ6AzYhkZCnL0Y017l5Mfj2aMUT6+mPYlqrbyQOVeWC0q25PMF+flcC+5IpLsKbs ReqA== X-Gm-Message-State: APzg51Ax0dG4I3Cv+T4bWR61EaIQogmViv7QihgR2HyhJtgH5Ba1khj8 V/niQPRj0mof74MJcZMrs5yyd/T3tUmKDnoh X-Received: by 2002:a50:98c1:: with SMTP id j59-v6mr3785417edb.212.1536241541742; Thu, 06 Sep 2018 06:45:41 -0700 (PDT) Received: from rev02.home ([2a02:a212:9283:9800:24b9:e2d6:9acc:50dd]) by smtp.gmail.com with ESMTPSA id l48-v6sm2818764eda.94.2018.09.06.06.45.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:40 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 6 Sep 2018 15:45:21 +0200 Message-Id: <20180906134523.2036-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180906134523.2036-1-ard.biesheuvel@linaro.org> References: <20180906134523.2036-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/4] MdePkg/BasePeCoffLib: 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: , Cc: Liming Gao , Jiewen Yao , Star Zeng , Michael D Kinney , Laszlo Ersek , Chao Zhang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 61 +++----------------- 1 file changed, 9 insertions(+), 52 deletions(-) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek Reviewed-by: Star Zeng Signed-off-by: Ard Biesheuvel Reviewed-by: Liming Gao diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c index 32eca0ad2ef4..c57816a80887 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c @@ -46,36 +46,6 @@ PeCoffLoaderAdjustOffsetForTeImage ( SectionHeader->PointerToRawData -= TeStrippedOffset; } -/** - 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 -PeCoffLoaderGetPeHeaderMagicValue ( - 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 the PE or TE Header from a PE/COFF or TE image. @@ -101,7 +71,6 @@ PeCoffLoaderGetPeHeader ( EFI_IMAGE_DOS_HEADER DosHdr; UINTN Size; UINTN ReadSize; - UINT16 Magic; UINT32 SectionHeaderOffset; UINT32 Index; UINT32 HeaderWithoutDataDir; @@ -222,9 +191,7 @@ PeCoffLoaderGetPeHeader ( ImageContext->IsTeImage = FALSE; ImageContext->Machine = Hdr.Pe32->FileHeader.Machine; - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // 1. Check OptionalHeader.NumberOfRvaAndSizes filed. // @@ -339,7 +306,7 @@ PeCoffLoaderGetPeHeader ( ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; - } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { // // 1. Check FileHeader.NumberOfRvaAndSizes filed. // @@ -605,7 +572,6 @@ PeCoffLoaderGetImageInfo ( EFI_IMAGE_SECTION_HEADER SectionHeader; EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; UINT32 TeStrippedOffset; if (ImageContext == NULL) { @@ -622,14 +588,12 @@ PeCoffLoaderGetImageInfo ( return Status; } - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - // // Retrieve the base address of the image // if (!(ImageContext->IsTeImage)) { TeStrippedOffset = 0; - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -678,7 +642,7 @@ PeCoffLoaderGetImageInfo ( } if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -952,7 +916,6 @@ PeCoffLoaderRelocateImage ( CHAR8 *FixupData; PHYSICAL_ADDRESS BaseAddress; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; UINT32 TeStrippedOffset; ASSERT (ImageContext != NULL); @@ -985,9 +948,8 @@ PeCoffLoaderRelocateImage ( if (!(ImageContext->IsTeImage)) { Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); TeStrippedOffset = 0; - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1230,7 +1192,6 @@ PeCoffLoaderLoadImage ( UINTN Size; UINT32 TempDebugEntryRva; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory; EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry; EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString; @@ -1404,12 +1365,11 @@ PeCoffLoaderLoadImage ( // // Get image's entry point // - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); if (!(ImageContext->IsTeImage)) { // // Sizes of AddressOfEntryPoint are different so we need to do this safely // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1444,7 +1404,7 @@ PeCoffLoaderLoadImage ( // the optional header to verify a desired directory entry is there. // if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1565,7 +1525,7 @@ PeCoffLoaderLoadImage ( // ImageContext->HiiResourceData = 0; if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1721,7 +1681,6 @@ PeCoffLoaderRelocateImageForRuntime ( CHAR8 *FixupData; UINTN Adjust; RETURN_STATUS Status; - UINT16 Magic; OldBase = (CHAR8 *)((UINTN)ImageBase); NewBase = (CHAR8 *)((UINTN)VirtImageBase); @@ -1750,9 +1709,7 @@ PeCoffLoaderRelocateImageForRuntime ( return ; } - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // From patchwork Thu Sep 6 13:45:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146092 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp534401ljw; Thu, 6 Sep 2018 06:45:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYVkTM/fzP1Lf9MdNhiKZQXBXakt95DFzIwPBWTzrjHjBL5sN1ZwR62fmQnU/ZGn+i4mKy5 X-Received: by 2002:a62:6c85:: with SMTP id h127-v6mr2877731pfc.65.1536241551252; Thu, 06 Sep 2018 06:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536241551; cv=none; d=google.com; s=arc-20160816; b=pJj6CEYufputQmSFlQPBRiKweL12HYmtHdoySzCZTcaAQpZdYKs8R82tHgtkQSbRxq 9bhtxmo0aOWwCqlbP8DPPPsJF5WwudQEPJGbJiK9JGaO0wKzlqe0ItDHiQV8hInhoFbR tm8iPbOx1ZHsijUVGQsUu07GNw7dQVrhGyM9YW3eUuCUif6Fe0lqSOVZAsjrEAXtvFAA Ft2uHvIaHQcIRSv1FTo5pDUbDCkRGx3iLl+X2L/LbgoU2XMh/rJssga5/MjP/VXBxkg/ CwcQKZaWXiXFdANnEq8nKv+vjdt+AJvPiXiEnJunJaV4j5+l7XQhipTT2fq61sCAohHn uJlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=e1xz+w3+CupFdUyIiynevINkgIj29L2a5gCWwAsfdtc=; b=ydf/esTMD6xEUS18KnWsJxs4HHhONv0Qrd/tCGltY4cOd1wCIwFY26ei95323UwJP+ qzrsnRRt1hBqDCgJeQtd/z//OKL0nfblzTor8Pxquu+2eTLCG8QOE2sdmSbnuQ5pRfya Gqx/F7CmGPwWGQBDJZCq72PjVvnqySSNf1CCX+4QDTK9u2EwYM2y3ywb6eCOjEpE2wAz Ay8ni5FfNxs0q/miZnlTT4036SbTQeATlmMHuwTK0pN5bU7F0JNk0ATw61Bsj54KzNEM GohMahR9/qn3xMAmZ7nsM+yfiPXFCIMbfUYPNIXMx1J47fgk/05lin/BMSmXi32zOsBW i88g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bfSe4b8X; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id o4-v6si5219995pfh.168.2018.09.06.06.45.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bfSe4b8X; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 110F121122954; Thu, 6 Sep 2018 06:45:48 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::542; helo=mail-ed1-x542.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 53B7D2112294D for ; Thu, 6 Sep 2018 06:45:45 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id s10-v6so8910145edb.11 for ; Thu, 06 Sep 2018 06:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EO+7H2XXyN7SyuYrIv4agGtlMK1Dma+NS3T+AoOpAaw=; b=bfSe4b8XpD9VoNRgFsmykbe4s6YZnUfu5p0Zlq4Hz/uDRPrgOt6ZW1+WDFJZxM8mIW FVoQZLg4NAPw9VKOXmQ395dv8l/vZ3sAVM4WzgkbK8haqQpFIqInTRLN2JamDrgeQjiu tK1ASZm/nYAZ8dNHlONDnHeqbqoQuLqKLv7NE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EO+7H2XXyN7SyuYrIv4agGtlMK1Dma+NS3T+AoOpAaw=; b=PTGVc/NELdkvvz7n3kA3zUPNMdeBLafJ3ERwQvBVh4MkOr5ElNO+dHp/x1GFTH4OUY +F/ArjVJyU3Gr0/N1cpOZ70a/CFqrqYJubMgvX60bjrN9yt72GLTvk4Z19CsR1kTDznC dNYmSdmnnGPYZPDRJjkmu9cywEvXMfTxSJaHY9RTutqDu2tdWQcTD4yp1rLpaIP+ngLG aO/p8sUgCPvDsgdncQ5kiv0GiAK9sLoPN0Zg3ZkzX530YPzccBnhJew5MVGry5FmCMHR 66U9ex9dcw6sbrSb7I32P9KXTTBGZzDgTXasF/QJttr/GYGC6J5O5VG3qgqMVlx+eTYy vyxQ== X-Gm-Message-State: APzg51DPiimBs992rk5d5FTf438tC7heMRL01Qzds9q3TF+OYGrVmGVh LDEtdZ+EIjFIcLm7GRerNOD2b1PRVa4hs7+4 X-Received: by 2002:aa7:c40a:: with SMTP id j10-v6mr3745360edq.134.1536241543407; Thu, 06 Sep 2018 06:45:43 -0700 (PDT) Received: from rev02.home ([2a02:a212:9283:9800:24b9:e2d6:9acc:50dd]) by smtp.gmail.com with ESMTPSA id l48-v6sm2818764eda.94.2018.09.06.06.45.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:42 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 6 Sep 2018 15:45:22 +0200 Message-Id: <20180906134523.2036-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180906134523.2036-1-ard.biesheuvel@linaro.org> References: <20180906134523.2036-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 3/4] SecurityPkg: 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: , Cc: Liming Gao , Jiewen Yao , Star Zeng , Michael D Kinney , Laszlo Ersek , Chao Zhang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c | 47 ++++---------------- SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c | 27 +++-------- SecurityPkg/Tcg/Tcg2Dxe/MeasureBootPeCoff.c | 27 +++-------- SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c | 25 +++-------- 4 files changed, 25 insertions(+), 101 deletions(-) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c index 0f795c0af125..66d96a9396b9 100644 --- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c +++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c @@ -295,7 +295,6 @@ HashPeImage ( ) { BOOLEAN Status; - UINT16 Magic; EFI_IMAGE_SECTION_HEADER *Section; VOID *HashCtx; UINTN CtxSize; @@ -367,33 +366,19 @@ HashPeImage ( // Measuring PE/COFF Image Header; // But CheckSum field and SECURITY data directory (certificate) are excluded // - if (mNtHeader.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && mNtHeader.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 = mNtHeader.Pe32->OptionalHeader.Magic; - } // // 3. Calculate the distance from the base of the image header to the image checksum address. // 4. Hash the image header from its base to beginning of the image checksum. // HashBase = mImageBase; - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // HashSize = (UINTN) (&mNtHeader.Pe32->OptionalHeader.CheckSum) - (UINTN) HashBase; NumberOfRvaAndSizes = mNtHeader.Pe32->OptionalHeader.NumberOfRvaAndSizes; - } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + } else if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { // // Use PE32+ offset. // @@ -420,7 +405,7 @@ HashPeImage ( // 6. Since there is no Cert Directory in optional header, hash everything // from the end of the checksum to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -444,7 +429,7 @@ HashPeImage ( // // 7. Hash everything from the end of the checksum to the start of the Cert Directory. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -469,7 +454,7 @@ HashPeImage ( // 8. Skip over the Cert Directory. (It is sizeof(IMAGE_DATA_DIRECTORY) bytes.) // 9. Hash everything from the end of the Cert Directory to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -494,7 +479,7 @@ HashPeImage ( // // 10. Set the SUM_OF_BYTES_HASHED to the size of the header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -577,7 +562,7 @@ HashPeImage ( if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_SECURITY) { CertSize = 0; } else { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -1583,7 +1568,6 @@ DxeImageVerificationHandler ( ) { EFI_STATUS Status; - UINT16 Magic; EFI_IMAGE_DOS_HEADER *DosHdr; EFI_STATUS VerifyStatus; EFI_SIGNATURE_LIST *SignatureList; @@ -1723,22 +1707,7 @@ DxeImageVerificationHandler ( goto Done; } - if (mNtHeader.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && mNtHeader.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 = mNtHeader.Pe32->OptionalHeader.Magic; - } - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // diff --git a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c index c54ab62e2745..4e4a90f9da62 100644 --- a/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c +++ b/SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.c @@ -320,7 +320,6 @@ TcgMeasurePeImage ( EFI_IMAGE_SECTION_HEADER *SectionHeader; UINTN Index; UINTN Pos; - UINT16 Magic; UINT32 EventSize; UINT32 EventNumber; EFI_PHYSICAL_ADDRESS EventLogLastEntry; @@ -418,27 +417,13 @@ TcgMeasurePeImage ( // Measuring PE/COFF Image Header; // But CheckSum field and SECURITY data directory (certificate) are excluded // - 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; - } // // 3. Calculate the distance from the base of the image header to the image checksum address. // 4. Hash the image header from its base to beginning of the image checksum. // HashBase = (UINT8 *) (UINTN) ImageAddress; - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -465,7 +450,7 @@ TcgMeasurePeImage ( // 6. Since there is no Cert Directory in optional header, hash everything // from the end of the checksum to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -489,7 +474,7 @@ TcgMeasurePeImage ( // // 7. Hash everything from the end of the checksum to the start of the Cert Directory. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -514,7 +499,7 @@ TcgMeasurePeImage ( // 8. Skip over the Cert Directory. (It is sizeof(IMAGE_DATA_DIRECTORY) bytes.) // 9. Hash everything from the end of the Cert Directory to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -539,7 +524,7 @@ TcgMeasurePeImage ( // // 10. Set the SUM_OF_BYTES_HASHED to the size of the header // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -621,7 +606,7 @@ TcgMeasurePeImage ( if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_SECURITY) { CertSize = 0; } else { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // diff --git a/SecurityPkg/Tcg/Tcg2Dxe/MeasureBootPeCoff.c b/SecurityPkg/Tcg/Tcg2Dxe/MeasureBootPeCoff.c index 29da2d70e699..61195e6041f7 100644 --- a/SecurityPkg/Tcg/Tcg2Dxe/MeasureBootPeCoff.c +++ b/SecurityPkg/Tcg/Tcg2Dxe/MeasureBootPeCoff.c @@ -116,7 +116,6 @@ MeasurePeImageAndExtend ( EFI_IMAGE_SECTION_HEADER *SectionHeader; UINTN Index; UINTN Pos; - UINT16 Magic; EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr; UINT32 NumberOfRvaAndSizes; UINT32 CertSize; @@ -181,27 +180,13 @@ MeasurePeImageAndExtend ( // Measuring PE/COFF Image Header; // But CheckSum field and SECURITY data directory (certificate) are excluded // - 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; - } // // 3. Calculate the distance from the base of the image header to the image checksum address. // 4. Hash the image header from its base to beginning of the image checksum. // HashBase = (UINT8 *) (UINTN) ImageAddress; - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -228,7 +213,7 @@ MeasurePeImageAndExtend ( // 6. Since there is no Cert Directory in optional header, hash everything // from the end of the checksum to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -252,7 +237,7 @@ MeasurePeImageAndExtend ( // // 7. Hash everything from the end of the checksum to the start of the Cert Directory. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -277,7 +262,7 @@ MeasurePeImageAndExtend ( // 8. Skip over the Cert Directory. (It is sizeof(IMAGE_DATA_DIRECTORY) bytes.) // 9. Hash everything from the end of the Cert Directory to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -302,7 +287,7 @@ MeasurePeImageAndExtend ( // // 10. Set the SUM_OF_BYTES_HASHED to the size of the header // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -384,7 +369,7 @@ MeasurePeImageAndExtend ( if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_SECURITY) { CertSize = 0; } else { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // diff --git a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c index 9acaa7b97507..f96325e978a5 100644 --- a/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c +++ b/SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c @@ -1831,7 +1831,6 @@ HashPeImage ( ) { BOOLEAN Status; - UINT16 Magic; EFI_IMAGE_SECTION_HEADER *Section; VOID *HashCtx; UINTN CtxSize; @@ -1874,27 +1873,13 @@ HashPeImage ( // Measuring PE/COFF Image Header; // But CheckSum field and SECURITY data directory (certificate) are excluded // - if (mNtHeader.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && mNtHeader.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 = mNtHeader.Pe32->OptionalHeader.Magic; - } // // 3. Calculate the distance from the base of the image header to the image checksum address. // 4. Hash the image header from its base to beginning of the image checksum. // HashBase = mImageBase; - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -1915,7 +1900,7 @@ HashPeImage ( // 6. Get the address of the beginning of the Cert Directory. // 7. Hash everything from the end of the checksum to the start of the Cert Directory. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -1937,7 +1922,7 @@ HashPeImage ( // 8. Skip over the Cert Directory. (It is sizeof(IMAGE_DATA_DIRECTORY) bytes.) // 9. Hash everything from the end of the Cert Directory to the end of image header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1958,7 +1943,7 @@ HashPeImage ( // // 10. Set the SUM_OF_BYTES_HASHED to the size of the header. // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // @@ -2032,7 +2017,7 @@ HashPeImage ( // if (mImageSize > SumOfBytesHashed) { HashBase = mImageBase + SumOfBytesHashed; - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (mNtHeader.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset. // From patchwork Thu Sep 6 13:45:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146093 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp534462ljw; Thu, 6 Sep 2018 06:45:55 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda/6AUZIok2sPKA83BihB2Xt7D8kKX168iA0M5FpKCVvk4X93xxkbWNg+F10hq2XQgTBELj X-Received: by 2002:a62:ac12:: with SMTP id v18-v6mr2927573pfe.126.1536241555679; Thu, 06 Sep 2018 06:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536241555; cv=none; d=google.com; s=arc-20160816; b=LlwVMh0DseRIw1ncMEvnONeTT6HjzLeMooyak7l2KJr4wzI4wFhW6UlqV1U21ipGWl F1GID3Xk6vsykNDIEtqOB1CoIqlt4yCuZsfcuv99Xp+QGF/5U1933KfrtWfZoIh61RDH nBap37PwV+OaUPfTzPtmMlyy/fEsS7QaXQUI027w7w0Rhd/OOd2NIjPi3HrX9ZeZq+tF QMXbWZdvIiOlqId9wh2EQAfktYQ2MVQ59NTihrb1HU4uCw8u52ikVpq+39xvuDxkaQ9H 5VHs14n2ggco6OczmQXUO63z735DrrJ5n3WXlTmAV2+KfzcN/RHbI2h4i3dA/GrmUGY7 eqOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=/RPfb6bomLO26AztY9ronz8W4GH5E/RKwLo+i9KgxHY=; b=I0HK8CogyR9f7ZeS6CUvroNax7H/5i+f5W2BQS3/4LPFCyoUuLiWU+y/MdGoe1SOvi 6oJe2R7mStwREy3ZvBJrTdpSQATl71pW1g6bfD3geyPvx4SZdsaRwUANeBPzSXTaomMy f+9bY4WhzkNh6UN1X0KYg7h9srl8M+qXSdCmr77ogFMzbJI/WtvOLZqBsN3Y6cRSnRJF qQkvSH4MqCpQLXGWy7uVLTZdKVvh9i076W296tEjpBuMw4V+0haBqJVdRu1Krcq0Kgo1 Mwl2YPfUBbdqTloeoQ9omrfhxnl+VUjn5ane+GiRBV6MO2CB1heWrIO3wZ3vaEllwbJC eU2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NkcftrmI; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 93-v6si5247909plf.113.2018.09.06.06.45.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NkcftrmI; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3B8F921122958; Thu, 6 Sep 2018 06:45:48 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::544; helo=mail-ed1-x544.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AD2BF2111FE66 for ; Thu, 6 Sep 2018 06:45:46 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id a20-v6so8937125edd.4 for ; Thu, 06 Sep 2018 06:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KZSjs/tdQyoWjZtOYk8Hkp7VwR0pq0KLvwhoiiN3nVU=; b=NkcftrmI1CnXOPaV8fbgbzvuUG8JCC1nBryN9fGw/BaRtKI35N+z04zHwunEjw+JZ8 NlH4fo4F7PjZxIkjA3GJ2obTgRdM561ZaKVGEM7/8n9FIPOmsAXz36jKu7InRTzOZKSF K6tJw2TeGVqGpzPOKA3XZHDwdDUg4foBUxMnI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KZSjs/tdQyoWjZtOYk8Hkp7VwR0pq0KLvwhoiiN3nVU=; b=D+bge4SsWF3/B8S8nn4euwViyv7HZvNfMVaulOYcgV+CCOYFtp5IoUfxobRz/qRII/ Pysrc3bRpvYaw1yGmS8v7LWIPU1wKTBblICBaPUfnBV8DeTP2p4ZEpwAH/fJ+GBF4Cti HrmQpUVrN27GOULl4upseX2KJSzWV49QBjcLmP6Qhz25N+1IeI4XIrzDM8DoamZ50GlG 29T80CBm8Xl53pCkiaVZccJ078g9Ou5k7KDbwYJgBg7uw1PNZlAZV3oK7FlTSK1ZRu+r J7Pfq2rsidRJCHYlGNFuIhDIO7dS9/DVlwbb0iKFF79VD0MOBOxpCi/ZPNTMq/NynInu sYcg== X-Gm-Message-State: APzg51AQ3agMdW0d+zMTMHqO7cKvA2eP2KmwfJ9OET7sU3eHi3IsrlEo ngQrEsNaLKlLulmbsi33gz/VfeFHrFEix87k X-Received: by 2002:a50:ad0f:: with SMTP id y15-v6mr3679122edc.78.1536241545028; Thu, 06 Sep 2018 06:45:45 -0700 (PDT) Received: from rev02.home ([2a02:a212:9283:9800:24b9:e2d6:9acc:50dd]) by smtp.gmail.com with ESMTPSA id l48-v6sm2818764eda.94.2018.09.06.06.45.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:43 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 6 Sep 2018 15:45:23 +0200 Message-Id: <20180906134523.2036-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180906134523.2036-1-ard.biesheuvel@linaro.org> References: <20180906134523.2036-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/4] EdkCompatibilityPkg: 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: , Cc: Liming Gao , Jiewen Yao , Star Zeng , Michael D Kinney , Laszlo Ersek , Chao Zhang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c | 60 +++----------------- 1 file changed, 8 insertions(+), 52 deletions(-) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c index f99c23e5ee4c..28d39b342afd 100644 --- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c @@ -22,36 +22,6 @@ Abstract: #include "BasePeCoffLibInternals.h" -/** - 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 -PeCoffLoaderGetPeHeaderMagicValue ( - 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 == EFI_IMAGE_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 the PE or TE Header from a PE/COFF or TE image. @@ -71,7 +41,6 @@ GluePeCoffLoaderGetPeHeader ( RETURN_STATUS Status; EFI_IMAGE_DOS_HEADER DosHdr; UINTN Size; - UINT16 Magic; // // Read the DOS image header to check for it's existance @@ -130,9 +99,7 @@ GluePeCoffLoaderGetPeHeader ( ImageContext->IsTeImage = FALSE; ImageContext->Machine = Hdr.Pe32->FileHeader.Machine; - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -141,7 +108,7 @@ GluePeCoffLoaderGetPeHeader ( ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; - } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { // // Use PE32+ offset // @@ -209,7 +176,6 @@ GluePeCoffLoaderGetImageInfo ( EFI_IMAGE_SECTION_HEADER SectionHeader; EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; if (NULL == ImageContext) { return RETURN_INVALID_PARAMETER; @@ -225,13 +191,11 @@ GluePeCoffLoaderGetImageInfo ( return Status; } - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - // // Retrieve the base address of the image // if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -276,7 +240,7 @@ GluePeCoffLoaderGetImageInfo ( } if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -520,7 +484,6 @@ GluePeCoffLoaderRelocateImage ( CHAR8 *FixupData; PHYSICAL_ADDRESS BaseAddress; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; ASSERT (ImageContext != NULL); @@ -552,9 +515,7 @@ GluePeCoffLoaderRelocateImage ( if (!(ImageContext->IsTeImage)) { Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -777,7 +738,6 @@ GluePeCoffLoaderLoadImage ( UINTN Size; UINT32 TempDebugEntryRva; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; ASSERT (ImageContext != NULL); @@ -965,12 +925,11 @@ GluePeCoffLoaderLoadImage ( // // Get image's entry point // - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); if (!(ImageContext->IsTeImage)) { // // Sizes of AddressOfEntryPoint are different so we need to do this safely // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1004,7 +963,7 @@ GluePeCoffLoaderLoadImage ( // the optional header to verify a desired directory entry is there. // if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1172,7 +1131,6 @@ PeCoffLoaderRelocateImageForRuntime ( CHAR8 *FixupData; UINTN Adjust; RETURN_STATUS Status; - UINT16 Magic; OldBase = (CHAR8 *)((UINTN)ImageBase); NewBase = (CHAR8 *)((UINTN)VirtImageBase); @@ -1201,9 +1159,7 @@ PeCoffLoaderRelocateImageForRuntime ( return ; } - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset //