From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 532D081E33 for ; Thu, 17 Nov 2016 16:44:27 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP; 17 Nov 2016 16:44:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,655,1473145200"; d="scan'208";a="32681514" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 17 Nov 2016 16:44:31 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 17 Nov 2016 16:44:31 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 17 Nov 2016 16:44:31 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.239]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.142]) with mapi id 14.03.0248.002; Fri, 18 Nov 2016 08:44:29 +0800 From: "Fan, Jeff" To: Laszlo Ersek , "Yao, Jiewen" , "edk2-devel@ml01.01.org" CC: "Kinney, Michael D" Thread-Topic: [edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX. Thread-Index: AQHSQNc7H0KYGm4k/EyewZXBi7i7I6DczwSAgAEY9xA= Date: Fri, 18 Nov 2016 00:44:29 +0000 Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4A2E125F@shsmsx102.ccr.corp.intel.com> References: <1479389619-16016-1-git-send-email-jiewen.yao@intel.com> <39cfaef3-e31f-6d5d-01b1-70fe3cc6057f@redhat.com> In-Reply-To: <39cfaef3-e31f-6d5d-01b1-70fe3cc6057f@redhat.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDFmYTcxOTAtMzRjNy00MGQ4LTkxMzUtNzk0NTA5OTBjN2M0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlFjZUNkTWw3d2c3SjRJWXBWQUJhTUZObzVGYmNcL1dWQWRVZGdrV21OOFlJPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set NX. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2016 00:44:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jeff Fan -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 Sent: Thursday, November 17, 2016 11:58 PM To: Yao, Jiewen; edk2-devel@ml01.01.org Cc: Kinney, Michael D; Fan, Jeff Subject: Re: [edk2] [PATCH] UefiCpuPkg/PiSmmCpu: Check XdSupport before set= NX. On 11/17/16 14:33, Jiewen Yao wrote: > When XD is not supported, the BIT63 is reserved. > We should not set BIT63 in the page table. >=20 > Test OVMF IA32/IA32X64 with XD enabled/disabled. >=20 > Analyzed-by: Laszlo Ersek > Cc: Laszlo Ersek > Cc: Jeff Fan > Cc: Michael D Kinney > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jiewen Yao > --- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpu= Pkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > index b4f8861..c85e025 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > @@ -209,10 +209,12 @@ ConvertPageEntryAttribute ( > } > } > if ((Attributes & EFI_MEMORY_XP) !=3D 0) { > - if (IsSet) { > - NewPageEntry |=3D IA32_PG_NX; > - } else { > - NewPageEntry &=3D ~IA32_PG_NX; > + if (mXdSupported) { > + if (IsSet) { > + NewPageEntry |=3D IA32_PG_NX; > + } else { > + NewPageEntry &=3D ~IA32_PG_NX; > + } > } > } > *PageEntry =3D NewPageEntry; >=20 Tested-by: Laszlo Ersek Thanks! Laszlo