From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: eric.dong@intel.com) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Mon, 29 Jul 2019 04:34:00 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jul 2019 04:34:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,322,1559545200"; d="scan'208";a="322825803" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 29 Jul 2019 04:34:00 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 29 Jul 2019 04:33:58 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 29 Jul 2019 04:33:58 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.19]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.163]) with mapi id 14.03.0439.000; Mon, 29 Jul 2019 19:33:56 +0800 From: "Dong, Eric" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Yao, Jiewen" , "Wang, Jian J" Subject: Re: [PATCH 3/3] UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF Thread-Topic: [PATCH 3/3] UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF Thread-Index: AQHVRCuCOSYvbS4DJ0WZrEryKETjiabhepxA Date: Mon, 29 Jul 2019 11:33:56 +0000 Message-ID: References: <20190727032850.337840-1-ray.ni@intel.com> <20190727032850.337840-4-ray.ni@intel.com> In-Reply-To: <20190727032850.337840-4-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: Ni, Ray > Sent: Saturday, July 27, 2019 11:29 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Yao, Jiewen ; > Wang, Jian J > Subject: [PATCH 3/3] UefiCpuPkg/PiSmmCpu: Allow SMM access-out when > static paging is OFF >=20 > Commit c60d36b4d1ee1f69b7cca897d3621dfa951895c2 > * UefiCpuPkg/SmmCpu: Block access-out only when static paging is used >=20 > updated page fault handler to treat SMM access-out as allowed address > when static paging is not used. >=20 > But that commit is not complete because the page table is still updated i= n > SetUefiMemMapAttributes() for non-SMRAM memory. When SMM code > accesses non-SMRAM memory, page fault is still generated. >=20 > This patch skips to update page table for non-SMRAM memory and page > table itself. >=20 > Signed-off-by: Ray Ni > Cc: Eric Dong > Cc: Jiewen Yao > Cc: Jian J Wang > --- > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 21 > +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > index 69a04dfb23..d7d94c8b6d 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > @@ -1121,6 +1121,9 @@ FindSmramInfo ( > *SmrrBase =3D (UINT32)CurrentSmramRange->CpuStart; > *SmrrSize =3D (UINT32)CurrentSmramRange->PhysicalSize; >=20 > + // > + // Extend *SmrrBase/*SmrrSize to include adjacent SMRAM ranges // > do { > Found =3D FALSE; > for (Index =3D 0; Index < mSmmCpuSmramRangeCount; Index++) { @@ - > 1432,14 +1435,20 @@ PerformRemainingTasks ( > SetMemMapAttributes (); >=20 > // > - // For outside SMRAM, we only map SMM communication buffer or > MMIO. > + // Protect memory outside SMRAM when SMM Static Page Table is > enabled. > // > - SetUefiMemMapAttributes (); > + if (IsStaticPageTableEnabled ()) { >=20 > - // > - // Set page table itself to be read-only > - // > - SetPageTableAttributes (); > + // > + // For outside SMRAM, we only map SMM communication buffer or > MMIO. > + // > + SetUefiMemMapAttributes (); > + > + // > + // Set page table itself to be read-only > + // > + SetPageTableAttributes (); > + } >=20 > // > // Configure SMM Code Access Check feature if available. > -- > 2.21.0.windows.1