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.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 AC8342034EE09 for ; Mon, 6 Nov 2017 17:09:54 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 06 Nov 2017 17:13:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,355,1505804400"; d="scan'208";a="1215050084" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 06 Nov 2017 17:12:59 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 6 Nov 2017 17:12:59 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 6 Nov 2017 17:12:58 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 7 Nov 2017 09:12:56 +0800 From: "Zeng, Star" To: Laszlo Ersek , "Yao, Jiewen" , "Dong, Eric" CC: "edk2-devel@lists.01.org" , "Zeng, Star" Thread-Topic: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map Thread-Index: AQHTVD7B/uDqHmlwpEW1n+2GtWyns6MHE7vwgAEI0ZCAAAP0wA== Date: Tue, 7 Nov 2017 01:12:56 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B23A7@shsmsx102.ccr.corp.intel.com> References: <20171103005729.7856-1-jian.j.wang@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B9B20B5@shsmsx102.ccr.corp.intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map 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: Tue, 07 Nov 2017 01:09:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Do you have further concern to this patch and have a RB? If no, I am happy to help push this patch with my AB. Thanks, Star -----Original Message----- From: Wang, Jian J=20 Sent: Tuesday, November 7, 2017 8:55 AM To: Zeng, Star ; edk2-devel@lists.01.org Cc: Laszlo Ersek ; Yao, Jiewen ; D= ong, Eric Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of R= T_CODE in memory map Thanks for the review. And I agree that GCD.SetMemoryAttributes should be u= sed all the time in DxeCore. Let's fix it in another patch. > -----Original Message----- > From: Zeng, Star > Sent: Monday, November 06, 2017 5:16 PM > To: Wang, Jian J ; edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Yao, Jiewen=20 > ; Dong, Eric ; Zeng, Star=20 > > Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries=20 > of RT_CODE in memory map >=20 > I am ok to this code approach. >=20 > Acknowledged-by: Star Zeng >=20 > Besides, I think except GCD services, DxeCore should not call gCpu- > >SetMemoryAttributes() directly, for example=20 > >ApplyMemoryProtectionPolicy(), it > should have no assumption of the CPU code (to set capabilities), and=20 > call GCD setcapabilities first, and then call GCD setattributes since > 14dde9e903bb9a719ebb8f3381da72b19509bc36 "MdeModulePkg/Core: Fix out-=20 > of-sync issue in GCD", otherwise there may be mismatch of page=20 > attributes between GCD and gCPU after=20 > RefreshGcdMemoryAttributesFromPaging() by the calling gCpu->SetMemoryAttr= ibutes() in ApplyMemoryProtectionPolicy(). >=20 > Anyway, that could be in a separated patch. :) >=20 > Thanks, > Star > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Jian J Wang > Sent: Friday, November 3, 2017 8:57 AM > To: edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Yao, Jiewen=20 > ; Dong, Eric > Subject: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of=20 > RT_CODE in memory map >=20 > > v2 > > a. Fix an issue which will cause setting capability failure if size is = smaller > > than a page. >=20 > More than one entry of RT_CODE memory might cause boot problem for=20 > some old OSs. This patch will fix this issue to keep OS compatibility as = much as possible. >=20 > More detailed information, please refer to > https://bugzilla.tianocore.org/show_bug.cgi?id=3D753 >=20 > Cc: Eric Dong > Cc: Jiewen Yao > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > UefiCpuPkg/CpuDxe/CpuPageTable.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) >=20 > diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c > b/UefiCpuPkg/CpuDxe/CpuPageTable.c > index d312eb66f8..4a7827ebc9 100644 > --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c > +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c > @@ -809,7 +809,9 @@ RefreshGcdMemoryAttributesFromPaging ( > PageLength =3D 0; >=20 > for (Index =3D 0; Index < NumberOfDescriptors; Index++) { > - if (MemorySpaceMap[Index].GcdMemoryType =3D=3D > EfiGcdMemoryTypeNonExistent) { > + if (MemorySpaceMap[Index].GcdMemoryType =3D=3D > EfiGcdMemoryTypeNonExistent > + || (MemorySpaceMap[Index].BaseAddress & EFI_PAGE_MASK) !=3D 0 > + || (MemorySpaceMap[Index].Length & EFI_PAGE_MASK) !=3D 0) { > continue; > } >=20 > @@ -829,6 +831,15 @@ RefreshGcdMemoryAttributesFromPaging ( > // Sync real page attributes to GCD > BaseAddress =3D MemorySpaceMap[Index].BaseAddress; > MemorySpaceLength =3D MemorySpaceMap[Index].Length; > + Capabilities =3D MemorySpaceMap[Index].Capabilities | > + EFI_MEMORY_PAGETYPE_MASK; > + Status =3D gDS->SetMemorySpaceCapabilities ( > + BaseAddress, > + MemorySpaceLength, > + Capabilities > + ); > + ASSERT_EFI_ERROR (Status); > + > while (MemorySpaceLength > 0) { > if (PageLength =3D=3D 0) { > PageEntry =3D GetPageTableEntry (&PagingContext, BaseAddress,=20 > &PageAttribute); @@ -846,7 +857,6 @@=20 > RefreshGcdMemoryAttributesFromPaging ( > if (Attributes !=3D (MemorySpaceMap[Index].Attributes & > EFI_MEMORY_PAGETYPE_MASK)) { > DoUpdate =3D TRUE; > Attributes |=3D (MemorySpaceMap[Index].Attributes &=20 > ~EFI_MEMORY_PAGETYPE_MASK); > - Capabilities =3D Attributes | MemorySpaceMap[Index].Capabiliti= es; > } else { > DoUpdate =3D FALSE; > } > @@ -854,8 +864,8 @@ RefreshGcdMemoryAttributesFromPaging ( >=20 > Length =3D MIN (PageLength, MemorySpaceLength); > if (DoUpdate) { > - gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabiliti= es); > - gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes); > + Status =3D gDS->SetMemorySpaceAttributes (BaseAddress, Length, > Attributes); > + ASSERT_EFI_ERROR (Status); > DEBUG ((DEBUG_INFO, "Update memory space attribute: [%02d]=20 > %016lx - %016lx (%08lx -> %08lx)\r\n", > Index, BaseAddress, BaseAddress + Length - = 1, > MemorySpaceMap[Index].Attributes,=20 > Attributes)); > -- > 2.14.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel