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.93; helo=mga11.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 332CB211D619A for ; Thu, 7 Mar 2019 06:38:27 -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 fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2019 06:38:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,451,1544515200"; d="scan'208";a="139961490" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 07 Mar 2019 06:38:26 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 7 Mar 2019 06:38:26 -0800 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 7 Mar 2019 06:38:26 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.163]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.57]) with mapi id 14.03.0415.000; Thu, 7 Mar 2019 22:38:24 +0800 From: "Yao, Jiewen" To: "Vanguput, Narendra K" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Ni, Ray" , "Laszlo Ersek" Thread-Topic: [PATCH v2] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand paging in SMM Thread-Index: AQHU1NcHlqgWC5K1/kOmDj6tLi2Sb6YAPRkA Date: Thu, 7 Mar 2019 14:38:23 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503F558690@shsmsx102.ccr.corp.intel.com> References: <20190307111439.32344-1-narendra.k.vanguput@intel.com> In-Reply-To: <20190307111439.32344-1-narendra.k.vanguput@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmE1M2Q1MTgtYjE5Yi00YTBkLWE0MTItZmZjYjY5ZmJjMThjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieFNEYUhsSHhDWDZWcnBTTWdVa0UwMUEzQlYzRDlhTXRGeGdPVHdMUmE3ZXQ2THpWVjEwZmJxVFc4c2F3UUV1KyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand paging in SMM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Mar 2019 14:38:28 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Vanguput, Narendra K > Sent: Thursday, March 7, 2019 3:15 AM > To: edk2-devel@lists.01.org > Cc: Vanguput, Narendra K ; Dong, Eric > ; Ni, Ray ; Laszlo Ersek > ; Yao, Jiewen > Subject: [PATCH v2] UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand > paging in SMM >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1593 >=20 > For every SMI occurrence, save and restore CR2 register only when SMM > on-demand paging support is enabled in 64 bit operation mode. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Vanguput Narendra K > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Yao Jiewen > --- > UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > index 3b0b3b52ac..5be4a2b020 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c > @@ -1111,10 +1111,12 @@ SmiRendezvous ( >=20 > ASSERT(CpuIndex < mMaxNumberOfCpus); >=20 > - // > - // Save Cr2 because Page Fault exception in SMM may override its value > - // > - Cr2 =3D AsmReadCr2 (); > + if ((sizeof (UINTN) =3D=3D sizeof (UINT64)) && (!PcdGetBool > (PcdCpuSmmStaticPageTable))) { > + // > + // Save Cr2 because Page Fault exception in SMM may override its > value > + // > + Cr2 =3D AsmReadCr2 (); > + } >=20 > // > // Perform CPU specific entry hooks > @@ -1253,10 +1255,12 @@ SmiRendezvous ( >=20 > Exit: > SmmCpuFeaturesRendezvousExit (CpuIndex); > - // > - // Restore Cr2 > - // > - AsmWriteCr2 (Cr2); > + if ((sizeof (UINTN) =3D=3D sizeof (UINT64)) && (!PcdGetBool > (PcdCpuSmmStaticPageTable))) { > + // > + // Restore Cr2 > + // > + AsmWriteCr2 (Cr2); > + } > } >=20 > /** > -- > 2.16.2.windows.1