From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 1038120355216 for ; Tue, 7 Nov 2017 20:43:00 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2017 20:47:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,362,1505804400"; d="scan'208";a="1241244720" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 07 Nov 2017 20:47:00 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 7 Nov 2017 20:47:00 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 7 Nov 2017 20:47:00 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Wed, 8 Nov 2017 12:46:57 +0800 From: "Wang, Jian J" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: Laszlo Ersek , "Yao, Jiewen" , "Dong, Eric" Thread-Topic: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of RT_CODE in memory map Thread-Index: AQHTVD7A/uDqHmlwpEW1n+2GtWyns6MJ7tvggAABKcA= Date: Wed, 8 Nov 2017 04:46:57 +0000 Message-ID: References: <20171103005729.7856-1-jian.j.wang@intel.com> <734D49CCEBEEF84792F5B80ED585239D5BAB69E5@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BAB69E5@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTM5MjdiMzctMzgzZi00Njg3LWIyOWEtZjIxZWVjZTY3ZTMwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJEcDRZVGtsdnRMY29lcjNNdU9jNDBXc3JcL1dDRWZweDhmK2dGNmRGSXZITnE2T25qYjBjVzBTdWh3bUc3cGU1eCJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action 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: Wed, 08 Nov 2017 04:43:01 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Make sense. Thanks for the comment. > -----Original Message----- > From: Ni, Ruiyu > Sent: Wednesday, November 08, 2017 12:42 PM > To: Wang, Jian J ; edk2-devel@lists.01.org > Cc: Laszlo Ersek ; Yao, Jiewen ; > Dong, Eric > Subject: RE: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of > RT_CODE in memory map >=20 > Jian, > Can you add more comments to explain why changing the capabilities of GCD > entry? >=20 > The background is clear by checking the Bugzilla. But it would be great t= o know > the issue > by just reading the code. >=20 > Thanks/Ray >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > > Jian J Wang > > Sent: Friday, November 3, 2017 8:57 AM > > To: edk2-devel@lists.01.org > > Cc: Laszlo Ersek ; Yao, Jiewen ; > > Dong, Eric > > Subject: [edk2] [PATCH v2] UefiCpuPkg/CpuDxe: Fix multiple entries of > > RT_CODE in memory map > > > > > v2 > > > a. Fix an issue which will cause setting capability failure if size i= s smaller > > > than a page. > > > > More than one entry of RT_CODE memory might cause boot problem for > > some old OSs. This patch will fix this issue to keep OS compatibility a= s much as > > possible. > > > > More detailed information, please refer to > > https://bugzilla.tianocore.org/show_bug.cgi?id=3D753 > > > > 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(-) > > > > 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; > > > > 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; > > } > > > > @@ -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; >=20 >=20 > > + Status =3D gDS->SetMemorySpaceCapabilities ( > > + BaseAddress, > > + MemorySpaceLength, > > + Capabilities > > + ); > > + ASSERT_EFI_ERROR (Status); > > + > > while (MemorySpaceLength > 0) { > > if (PageLength =3D=3D 0) { > > PageEntry =3D GetPageTableEntry (&PagingContext, BaseAddress, > > &PageAttribute); @@ -846,7 +857,6 @@ > > RefreshGcdMemoryAttributesFromPaging ( > > if (Attributes !=3D (MemorySpaceMap[Index].Attributes & > > EFI_MEMORY_PAGETYPE_MASK)) { > > DoUpdate =3D TRUE; > > Attributes |=3D (MemorySpaceMap[Index].Attributes & > > ~EFI_MEMORY_PAGETYPE_MASK); > > - Capabilities =3D Attributes | MemorySpaceMap[Index].Capabili= ties; > > } else { > > DoUpdate =3D FALSE; > > } > > @@ -854,8 +864,8 @@ RefreshGcdMemoryAttributesFromPaging ( > > > > Length =3D MIN (PageLength, MemorySpaceLength); > > if (DoUpdate) { > > - gDS->SetMemorySpaceCapabilities (BaseAddress, Length, Capabili= ties); > > - gDS->SetMemorySpaceAttributes (BaseAddress, Length, Attributes= ); > > + Status =3D gDS->SetMemorySpaceAttributes (BaseAddress, Length, > > Attributes); > > + ASSERT_EFI_ERROR (Status); > > DEBUG ((DEBUG_INFO, "Update memory space attribute: > > [%02d] %016lx - %016lx (%08lx -> %08lx)\r\n", > > Index, BaseAddress, BaseAddress + Length = - 1, > > MemorySpaceMap[Index].Attributes, Attribu= tes)); > > -- > > 2.14.1.windows.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel