From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: Ard Biesheuvel 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: [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: , X-List-Received-Date: Mon, 27 Mar 2017 12:22:31 -0000 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(-) 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; } /** -- 2.9.3