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.100; helo=mga07.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 79034221F93C1 for ; Tue, 16 Jan 2018 05:57:23 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2018 06:02:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,368,1511856000"; d="scan'208";a="26872409" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 16 Jan 2018 06:02:42 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 Jan 2018 06:02:42 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 Jan 2018 06:02:41 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 16 Jan 2018 22:02:40 +0800 From: "Dong, Eric" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , Laszlo Ersek , "Yao, Jiewen" Thread-Topic: [edk2] [PATCH 3/6] UefiCpuPkg/CpuDxe: clear NX attr for page directory Thread-Index: AQHTjd6Jv+QdbnzeGEC/ymiXmwYkfKN2iYcQ Date: Tue, 16 Jan 2018 14:02:39 +0000 Message-ID: References: <20180115085433.25008-1-jian.j.wang@intel.com> <20180115085433.25008-4-jian.j.wang@intel.com> In-Reply-To: <20180115085433.25008-4-jian.j.wang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDM4Y2YzYTctOTk5NC00ZTYxLWI1NjctYzVlODgwNGEyMTY4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJGRVoyclFpVnltcnhwK05yeWJ2RFwveUVJVGtTSGhQMU1MaVZtbW04eU1RVytRZUYxVlNtdFR1Q1NHcWYzVUhuSCJ9 x-ctpclassification: CTP_NT 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 3/6] UefiCpuPkg/CpuDxe: clear NX attr for page directory X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jan 2018 13:57:23 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Jian J Wang > Sent: Monday, January 15, 2018 4:55 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Laszlo Ersek ; Yao= , > Jiewen ; Dong, Eric > Subject: [edk2] [PATCH 3/6] UefiCpuPkg/CpuDxe: clear NX attr for page > directory >=20 > If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory > of EfiBootServicesCode, EfiConventionalMemory and > EfiReservedMemoryType, the BIOS will hang at a page fault exception > randomly. >=20 > The root cause is that the memory allocation for driver images (actually = a > memory type conversion from free memory, type of EfiConventionalMemory, > to code memory, type of EfiBootServicesCode/EfiRuntimeServicesCode) > will get memory with NX set, because the CpuDxe driver will keep the NX > attribute (with free memory) in page directory during page table splittin= g and > then override the NX attribute of all its entries. >=20 > This patch fixes this issue by not inheriting NX attribute when turning a= page > entry into a page directory during page granularity split. >=20 > Cc: Jiewen Yao > Cc: Ruiyu Ni > Cc: Eric Dong > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > UefiCpuPkg/CpuDxe/CpuPageTable.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/UefiCpuPkg/CpuDxe/CpuPageTable.c > b/UefiCpuPkg/CpuDxe/CpuPageTable.c > index a9c9bc9d5e..1654e71103 100644 > --- a/UefiCpuPkg/CpuDxe/CpuPageTable.c > +++ b/UefiCpuPkg/CpuDxe/CpuPageTable.c > @@ -528,7 +528,7 @@ SplitPage ( > for (Index =3D 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { > NewPageEntry[Index] =3D (BaseAddress + SIZE_4KB * Index) | > AddressEncMask | ((*PageEntry) & PAGE_PROGATE_BITS); > } > - (*PageEntry) =3D (UINT64)(UINTN)NewPageEntry | AddressEncMask | > ((*PageEntry) & PAGE_PROGATE_BITS); > + (*PageEntry) =3D (UINT64)(UINTN)NewPageEntry | AddressEncMask | > + ((*PageEntry) & PAGE_ATTRIBUTE_BITS); > return RETURN_SUCCESS; > } else { > return RETURN_UNSUPPORTED; > @@ -549,7 +549,7 @@ SplitPage ( > for (Index =3D 0; Index < SIZE_4KB / sizeof(UINT64); Index++) { > NewPageEntry[Index] =3D (BaseAddress + SIZE_2MB * Index) | > AddressEncMask | IA32_PG_PS | ((*PageEntry) & PAGE_PROGATE_BITS); > } > - (*PageEntry) =3D (UINT64)(UINTN)NewPageEntry | AddressEncMask | > ((*PageEntry) & PAGE_PROGATE_BITS); > + (*PageEntry) =3D (UINT64)(UINTN)NewPageEntry | AddressEncMask | > + ((*PageEntry) & PAGE_ATTRIBUTE_BITS); > return RETURN_SUCCESS; > } else { > return RETURN_UNSUPPORTED; > @@ -979,7 +979,7 @@ RefreshGcdMemoryAttributesFromPaging ( > ); > ASSERT_EFI_ERROR (Status); > DEBUG (( > - DEBUG_INFO, > + DEBUG_VERBOSE, > "Updated memory space attribute: [%lu] %016lx - %016lx (%016lx= - > > %016lx)\r\n", > (UINT64)Index, BaseAddress, BaseAddress + Length - 1, > MemorySpaceMap[Index].Attributes, > -- > 2.15.1.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel