From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 1FCAA210DC1A0 for ; Wed, 8 Aug 2018 00:04:34 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2018 00:04:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,456,1526367600"; d="scan'208";a="222879827" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga004.jf.intel.com with ESMTP; 08 Aug 2018 00:04:34 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 8 Aug 2018 00:04:34 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 8 Aug 2018 00:04:33 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by shsmsx102.ccr.corp.intel.com ([169.254.2.226]) with mapi id 14.03.0319.002; Wed, 8 Aug 2018 15:04:31 +0800 From: "Wang, Jian J" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , Laszlo Ersek Thread-Topic: [PATCH v3] IntelFrameworkModulePkg/Csm: Set CSM memory executable Thread-Index: AQHULtiCAGjr8gC65EWMg+ABwk34maS1bMMA Date: Wed, 8 Aug 2018 07:04:31 +0000 Message-ID: References: <20180808052739.85156-1-ruiyu.ni@intel.com> In-Reply-To: <20180808052739.85156-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzQ5NDFiZTAtNTEwYS00YTg4LWIxMmQtM2Q1MjA4NGYwZTI2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNmEyZlRBbXJYXC9cL2p2aWtcL01IenhzYzV3RlBmWHlIQ2pxY1diOW9HQVE4VndJbGpxQ0k0UW9zSFlmVUoyT3g5OCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v3] IntelFrameworkModulePkg/Csm: Set CSM memory executable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2018 07:04:35 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ruiyu, In function description comments, the @retval doesn't match the changes in = this patch. With those changes, Reviewed-by: Jian J Wang Regards, Jian > -----Original Message----- > From: Ni, Ruiyu > Sent: Wednesday, August 08, 2018 1:28 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Laszlo Ersek ; > Wang, Jian J > Subject: [PATCH v3] IntelFrameworkModulePkg/Csm: Set CSM memory > executable >=20 > Commit b22a62be5cdc8fd19d87ec1ecfa5b28fb9be50ad > * IntelFrameworkModule/LegacyBios:Use reserved memory for legacy data > allocates reserved memory for holding legacy code/data. >=20 > But with PcdDxeNxMemoryProtectionPolicy set to certain value to > forbid execution when code is in certain type of memory, it's > possible that a platform forbids execution when code is in reserved > memory. The patch calls GCD service to allow such case otherwise > CPU exception may occur. >=20 > Code execution in BSCode area should be enabled by platform by > default. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Star Zeng > Cc: Laszlo Ersek > Cc: Jian Wang > --- > .../Csm/LegacyBiosDxe/LegacyBios.c | 28 ++++++++++++++++= ++---- > 1 file changed, 23 insertions(+), 5 deletions(-) >=20 > diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c > b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c > index 8f14687b28..80efe40489 100644 > --- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c > +++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c > @@ -64,8 +64,9 @@ AllocateLegacyMemory ( > OUT EFI_PHYSICAL_ADDRESS *Result > ) > { > - EFI_STATUS Status; > - EFI_PHYSICAL_ADDRESS MemPage; > + EFI_STATUS Status; > + EFI_PHYSICAL_ADDRESS MemPage; > + EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc; >=20 > // > // Allocate Pages of memory less <=3D StartPageAddress > @@ -81,12 +82,29 @@ AllocateLegacyMemory ( > // Do not ASSERT on Status error but let caller decide since some case= s > // memory is already taken but that is ok. > // > + if (!EFI_ERROR (Status)) { > + if (MemoryType !=3D EfiBootServicesCode) { > + // > + // Make sure that the buffer can be used to store code. > + // > + Status =3D gDS->GetMemorySpaceDescriptor (MemPage, &MemDesc); > + if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != =3D 0) { > + Status =3D gDS->SetMemorySpaceAttributes ( > + MemPage, > + EFI_PAGES_TO_SIZE (Pages), > + MemDesc.Attributes & (~EFI_MEMORY_XP) > + ); > + } > + if (EFI_ERROR (Status)) { > + gBS->FreePages (MemPage, Pages); > + } > + } > + } > + > if (!EFI_ERROR (Status)) { > *Result =3D (EFI_PHYSICAL_ADDRESS) (UINTN) MemPage; > } > - // > - // If reach here the status =3D EFI_SUCCESS > - // > + > return Status; > } >=20 > -- > 2.16.1.windows.1