From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: liming.gao@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Sat, 10 Aug 2019 07:16:23 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Aug 2019 07:16:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,369,1559545200"; d="scan'208";a="199669112" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 10 Aug 2019 07:16:22 -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.439.0; Sat, 10 Aug 2019 07:16:22 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 10 Aug 2019 07:16:21 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.163]) with mapi id 14.03.0439.000; Sat, 10 Aug 2019 22:16:05 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "Gao, Liming" CC: Mike Turner , "Wang, Jian J" , "Wu, Hao A" , "Bi, Dandan" Subject: Re: [edk2-devel] [Patch] MdeModulePkg DxeCore: Fix for missing MAT update Thread-Topic: [edk2-devel] [Patch] MdeModulePkg DxeCore: Fix for missing MAT update Thread-Index: AQHVT4VjqnavFFiMDECnpfoJbqgILqb0bCDg Date: Sat, 10 Aug 2019 14:16:04 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4CDF9C@SHSMSX104.ccr.corp.intel.com> References: <15B9950E072DB087.17773@groups.io> In-Reply-To: <15B9950E072DB087.17773@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTE0MzlkNTQtY2I3OC00NmQ2LWJiYTctOGQ0NDNkZDcxNGMyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiejVONWNZbXIwNWw3VExYVFU3VFNuclJ3VHFTUWw0WU50WjdnRlBEWVhiSnRYWDNHSTdhdjY0dlpPN3NyNGtzSCJ9 dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, all This is one bug fix. I plan to catch it for 201808 stable tag.=20 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1978 Thanks Liming > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Li= ming Gao > Sent: Saturday, August 10, 2019 10:10 PM > To: devel@edk2.groups.io > Cc: Mike Turner ; Wang, Jian J ; Wu, Hao A ; Bi, Dandan > > Subject: [edk2-devel] [Patch] MdeModulePkg DxeCore: Fix for missing MAT = update >=20 > From: Mike Turner >=20 > The Fpdt driver (FirmwarePerformanceDxe) saves a memory address across > reboots, and then does an AllocatePage for that memory address. > If, on this boot, that memory comes from a Runtime memory bucket, > the MAT table is not updated. This causes Windows to boot into Recovery. >=20 > This patch blocks the memory manager from changing the page > from a special bucket to a different memory type. Once the buckets are > allocated, we freeze the memory ranges for the OS, and fragmenting > the special buckets will cause errors resuming from hibernate. >=20 > This patch is cherry pick from Project Mu: > https://github.com/microsoft/mu_basecore/commit/a9be767d9be96af94016ebd3= 91ea6f340920735a > With the minor change, > 1. Update commit message format to keep the message in 80 characters one= line. > 2. Remove // MU_CHANGE comments in source code. >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Dandan Bi > Signed-off-by: Liming Gao > --- > MdeModulePkg/Core/Dxe/Mem/Page.c | 43 +++++++++++++++++++++++++++++++++= +------ > 1 file changed, 37 insertions(+), 6 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Me= m/Page.c > index bd9e116aa5..637518889d 100644 > --- a/MdeModulePkg/Core/Dxe/Mem/Page.c > +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c > @@ -1265,12 +1265,13 @@ CoreInternalAllocatePages ( > IN BOOLEAN NeedGuard > ) > { > - EFI_STATUS Status; > - UINT64 Start; > - UINT64 NumberOfBytes; > - UINT64 End; > - UINT64 MaxAddress; > - UINTN Alignment; > + EFI_STATUS Status; > + UINT64 Start; > + UINT64 NumberOfBytes; > + UINT64 End; > + UINT64 MaxAddress; > + UINTN Alignment; > + EFI_MEMORY_TYPE CheckType; >=20 > if ((UINT32)Type >=3D MaxAllocateType) { > return EFI_INVALID_PARAMETER; > @@ -1321,6 +1322,7 @@ CoreInternalAllocatePages ( > // if (Start + NumberOfBytes) rolls over 0 or > // if Start is above MAX_ALLOC_ADDRESS or > // if End is above MAX_ALLOC_ADDRESS, > + // if Start..End overlaps any tracked MemoryTypeStatistics range > // return EFI_NOT_FOUND. > // > if (Type =3D=3D AllocateAddress) { > @@ -1336,6 +1338,35 @@ CoreInternalAllocatePages ( > (End > MaxAddress)) { > return EFI_NOT_FOUND; > } > + > + // Problem summary > + > + /* > + A driver is allowed to call AllocatePages using an AllocateAddress = type. This type of > + AllocatePage request the exact physical address if it is not used. = The existing code > + will allow this request even in 'special' pages. The problem with = this is that the > + reason to have 'special' pages for OS hibernate/resume is defeated = as memory is > + fragmented. > + */ > + > + for (CheckType =3D (EFI_MEMORY_TYPE) 0; CheckType < EfiMaxMemoryTyp= e; CheckType++) { > + if (MemoryType !=3D CheckType && > + mMemoryTypeStatistics[CheckType].Special && > + mMemoryTypeStatistics[CheckType].NumberOfPages > 0) { > + if (Start >=3D mMemoryTypeStatistics[CheckType].BaseAddress && > + Start <=3D mMemoryTypeStatistics[CheckType].MaximumAddress)= { > + return EFI_NOT_FOUND; > + } > + if (End >=3D mMemoryTypeStatistics[CheckType].BaseAddress && > + End <=3D mMemoryTypeStatistics[CheckType].MaximumAddress) { > + return EFI_NOT_FOUND; > + } > + if (Start < mMemoryTypeStatistics[CheckType].BaseAddress && > + End > mMemoryTypeStatistics[CheckType].MaximumAddress) { > + return EFI_NOT_FOUND; > + } > + } > + } > } >=20 > if (Type =3D=3D AllocateMaxAddress) { > -- > 2.13.0.windows.1 >=20 >=20 >=20