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) {