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.65; helo=mga03.intel.com; envelope-from=narendra.k.vanguput@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 441A521A00AE6 for ; Thu, 7 Mar 2019 03:14:48 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2019 03:14:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,451,1544515200"; d="scan'208";a="132319032" Received: from nkvangup-desk4.gar.corp.intel.com ([10.223.18.122]) by fmsmga007.fm.intel.com with ESMTP; 07 Mar 2019 03:14:45 -0800 From: nkvangup To: edk2-devel@lists.01.org Cc: Vanguput Narendra K , Eric Dong , Ray Ni , Laszlo Ersek , Yao Jiewen Date: Thu, 7 Mar 2019 16:44:39 +0530 Message-Id: <20190307111439.32344-1-narendra.k.vanguput@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Subject: [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 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 X-List-Received-Date: Thu, 07 Mar 2019 11:14:50 -0000 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1593 For every SMI occurrence, save and restore CR2 register only when SMM on-demand paging support is enabled in 64 bit operation mode. 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(-) 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 ( ASSERT(CpuIndex < mMaxNumberOfCpus); - // - // Save Cr2 because Page Fault exception in SMM may override its value - // - Cr2 = AsmReadCr2 (); + if ((sizeof (UINTN) == sizeof (UINT64)) && (!PcdGetBool (PcdCpuSmmStaticPageTable))) { + // + // Save Cr2 because Page Fault exception in SMM may override its value + // + Cr2 = AsmReadCr2 (); + } // // Perform CPU specific entry hooks @@ -1253,10 +1255,12 @@ SmiRendezvous ( Exit: SmmCpuFeaturesRendezvousExit (CpuIndex); - // - // Restore Cr2 - // - AsmWriteCr2 (Cr2); + if ((sizeof (UINTN) == sizeof (UINT64)) && (!PcdGetBool (PcdCpuSmmStaticPageTable))) { + // + // Restore Cr2 + // + AsmWriteCr2 (Cr2); + } } /** -- 2.16.2.windows.1