From nobody Sat Nov 2 10:33:41 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1490617353684853.272773434881; Mon, 27 Mar 2017 05:22:33 -0700 (PDT) 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) 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) 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) X-Original-To: edk2-devel@lists.01.org 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) 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 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Liming Gao --- MdeModulePkg/Core/Pei/Image/Image.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Im= age/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; =20 @@ -119,8 +120,7 @@ GetImageReadFunction ( MemoryBuffer =3D 0; =20 if (Private->PeiMemoryInstalled && (((Private->HobList.HandoffInformati= onTable->BootMode !=3D BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoo= t)) ||=20 - ((Private->HobList.HandoffInformationTable->BootMode =3D=3D BOOT_ON_= S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot))) && - (EFI_IMAGE_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_X64) || EFI_IMAG= E_MACHINE_TYPE_SUPPORTED(EFI_IMAGE_MACHINE_IA32))) { + ((Private->HobList.HandoffInformationTable->BootMode =3D=3D BOOT_ON_= S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) { //=20 // Shadow algorithm makes lots of non ANSI C assumptions and only work= s for IA32 and X64=20 // compilers that have been tested @@ -136,7 +136,9 @@ GetImageReadFunction ( } else { ImageContext->ImageRead =3D PeiImageRead; } - +#else + ImageContext->ImageRead =3D PeiImageRead; +#endif return EFI_SUCCESS; } /** --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel