From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D20E021DFA91C for ; Wed, 29 Mar 2017 01:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490776751; x=1522312751; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=Y4bPrKbMU6jbDT4s+0VwDXhnY90lCalOjAI7Bdzj2BA=; b=azD4mFGbEz1qcfFL6eWSDuFt0MQnM6VPtzynE9a22P8Zppv9dVmXkzB7 +yNFR75e4yGUTf8XhZ0YVr/zTy0SNQ==; Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2017 01:39:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,240,1486454400"; d="scan'208";a="81807257" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 29 Mar 2017 01:39:11 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Mar 2017 01:39:11 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Mar 2017 01:39:10 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.212]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.42]) with mapi id 14.03.0248.002; Wed, 29 Mar 2017 16:39:09 +0800 From: "Gao, Liming" To: Ard Biesheuvel , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] MdeModulePkg/PeiCore: avoid EFI_IMAGE_MACHINE_TYPE_SUPPORTED to check arch Thread-Index: AQHSpvTZTm4ovevnpEWtUlWktuL+cKGrgfCA Date: Wed, 29 Mar 2017 08:39:08 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D706197@shsmsx102.ccr.corp.intel.com> References: <20170327122216.29760-1-ard.biesheuvel@linaro.org> In-Reply-To: <20170327122216.29760-1-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Wed, 29 Mar 2017 08:39:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ard >Biesheuvel >Sent: Monday, March 27, 2017 8:22 PM >To: edk2-devel@lists.01.org; Gao, Liming >Cc: Ard Biesheuvel >Subject: [edk2] [PATCH] MdeModulePkg/PeiCore: avoid >EFI_IMAGE_MACHINE_TYPE_SUPPORTED to check arch > >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 =3D 0; > > if (Private->PeiMemoryInstalled && (((Private- >>HobList.HandoffInformationTable->BootMode !=3D BOOT_ON_S3_RESUME) >&& PcdGetBool (PcdShadowPeimOnBoot)) || >- ((Private->HobList.HandoffInformationTable->BootMode =3D=3D >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 =3D=3D >BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)))) { > // > // Shadow algorithm makes lots of non ANSI C assumptions and only wor= ks >for IA32 and X64 > // compilers that have been tested >@@ -136,7 +136,9 @@ GetImageReadFunction ( > } else { > ImageContext->ImageRead =3D PeiImageRead; > } >- >+#else >+ ImageContext->ImageRead =3D PeiImageRead; >+#endif > return EFI_SUCCESS; > } > /** >-- >2.9.3 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel