From patchwork Mon Mar 27 12:22:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96065 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1198029qgd; Mon, 27 Mar 2017 05:22:32 -0700 (PDT) X-Received: by 10.99.142.67 with SMTP id k64mr23586765pge.31.1490617352873; Mon, 27 Mar 2017 05:22:32 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id j64si471411pge.346.2017.03.27.05.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 05:22:32 -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; 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 8FEF420084757; Mon, 27 Mar 2017 05:22:32 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com [IPv6:2a00:1450:400c:c0c::233]) (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 386802008474C for ; Mon, 27 Mar 2017 05:22:31 -0700 (PDT) Received: by mail-wr0-x233.google.com with SMTP id w43so42117315wrb.0 for ; Mon, 27 Mar 2017 05:22:31 -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; bh=2ZaX4V6EaJL0czB00R+zLWjN5Uf2Tx7kdH6TPaNO31U=; b=O5OuIF9xAMKdzEy46xaQAyez3NwQliH4RkPt2t/qXSriSK/ebFp8ifUycSyxKpXHJb QYKwOPeonCuC5VZeUP0KscC9fugNHbbveB3m5nRmXPS0N8v9CZ6qIsAwJ2mawkh3pn9G QLrRqhR0PuaUd4PryvHA/VYgrLFSrMLdumBxE= 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; bh=2ZaX4V6EaJL0czB00R+zLWjN5Uf2Tx7kdH6TPaNO31U=; b=mnbhVHPSQMwsLQn3fJcrFJczUOFfWV3/vPn+6hTU2xMKClbgjw27gswxWce5LwxxCT xf0JsdoUEKK3cgGaqLIsNzesCYGsjd7y9K0DtlTzoVg7XuYNIS5yZTLdKQzhAuc1XXJa qoj8mi2nsNuyP9Fh+NW55K4jRgun5dQhiwNLziQIT2rmwUc09uTpFaZ8LYx0tq3KY8H5 NQLDk3PXvr6pkKjHASM5akWIjAoQyZ5sGiX/Igd6EhI/tq+GTuJvFOlNgqN3w2jb/ihX cg7YjsYA0k073rQfrNT9Dxqtmmgp6yWTvbAVEX8KPeSAJY6hGXBZjikpiSw/HQfs7012 xGkw== X-Gm-Message-State: AFeK/H3dK474URPxFkcvkH3Cy3ppE/L2xkniH1cVYf+KmVnyWC2q5vraNeLpl23DnpUsrN1p X-Received: by 10.223.177.154 with SMTP id q26mr2569031wra.164.1490617349297; Mon, 27 Mar 2017 05:22:29 -0700 (PDT) Received: from localhost.localdomain ([196.81.160.3]) by smtp.gmail.com with ESMTPSA id y43sm530606wrd.0.2017.03.27.05.22.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 05:22:28 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com Date: Mon, 27 Mar 2017 13:22:16 +0100 Message-Id: <20170327122216.29760-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [edk2] [PATCH] MdeModulePkg/PeiCore: avoid EFI_IMAGE_MACHINE_TYPE_SUPPORTED to check arch X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The EFI_IMAGE_MACHINE_TYPE_SUPPORTED() macro is abused in the PeiCore code to decide whether the system we are compiling for can deal with executable code being copied elsewhere and executed from there. As stated in the comment, this is fundamentally a property of the compiler target, and so this should be made dependent on MDE_CPU_xxx preprocessor defines, and not on whether or not the runtime target can deal with PE/COFF images of a certain machine type. On X86/IA32, this mostly boils down to the same thing, but not on other architectures, so let's clean this up. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Pei/Image/Image.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Liming Gao diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c index c8bb2300a0a6..198541128512 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -112,6 +112,7 @@ GetImageReadFunction ( IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext ) { +#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) PEI_CORE_INSTANCE *Private; EFI_PHYSICAL_ADDRESS MemoryBuffer; @@ -119,8 +120,7 @@ GetImageReadFunction ( MemoryBuffer = 0; if (Private->PeiMemoryInstalled && (((Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoot)) || - ((Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot))) && - (EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_X64) || EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_IA32))) { + ((Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) { // // Shadow algorithm makes lots of non ANSI C assumptions and only works for IA32 and X64 // compilers that have been tested @@ -136,7 +136,9 @@ GetImageReadFunction ( } else { ImageContext->ImageRead = PeiImageRead; } - +#else + ImageContext->ImageRead = PeiImageRead; +#endif return EFI_SUCCESS; } /**