From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.29704.1605496726136635553 for ; Sun, 15 Nov 2020 19:18:46 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: w.sheng@intel.com) IronPort-SDR: bOdQoBW0rL39QyqpapECe7vv7s7JJS4s3+Tpv1vfho1AYeVMvgnHDEN8KvslHsiGOBla+nCP7Y uPxloUEmYplg== X-IronPort-AV: E=McAfee;i="6000,8403,9806"; a="157720773" X-IronPort-AV: E=Sophos;i="5.77,481,1596524400"; d="scan'208";a="157720773" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2020 19:18:43 -0800 IronPort-SDR: QU2OtJ9ds/PaDeLmYSMnnErO4v/RpwBCuct07hTXTO+hW0aH3gY2JVKxVAvXdI8N9XcjStyT4U /r0/9YFMKwzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,481,1596524400"; d="scan'208";a="475389800" Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.46]) by orsmga004.jf.intel.com with ESMTP; 15 Nov 2020 19:18:41 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar , Jiewen Yao Subject: [PATCH v8 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reflect page table depth with page table address Date: Mon, 16 Nov 2020 11:18:31 +0800 Message-Id: <20201116031833.14324-1-w.sheng@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 When trying to get page table base, if mInternalCr3 is zero, it will use the page table from CR3, and reflect the page table depth by CR4 LA57 bit. If mInternalCr3 is non zero, it will use the page table from mInternalCr3 and reflect the page table depth of mInternalCr3 at same time. In the case of X64, we use m5LevelPagingNeeded to reflect the depth of the page table. And in the case of IA32, it will not the page table depth information. This patch is a bug fix when enable CET feature with 5 level paging. The SMM page tables are allocated / initialized in PiCpuSmmEntry(). When CET is enabled, PiCpuSmmEntry() must further modify the attribute of shadow stack pages. This page table is not set to CR3 in PiCpuSmmEntry(). So the page table base address is set to mInternalCr3 for modifty the page table attribute. It could not use CR4 LA57 bit to reflect the page table depth for mInternalCr3. So we create a architecture-specific implementation GetPageTable() with 2 output parameters. One parameter is used to output the page table address. Another parameter is used to reflect if it is 5 level paging or not. Correct the Cr3 typo REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3015 Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Jiewen Yao Sheng Wei (2): UefiCpuPkg/PiSmmCpuDxeSmm: Correct the Cr3 typo UefiCpuPkg/PiSmmCpuDxeSmm: Reflect page table depth with page table address UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c | 26 ++++++++++++- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 ++++--- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 35 +++++------------- UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 43 ++++++++++++++++++---- 4 files changed, 77 insertions(+), 40 deletions(-) -- 2.16.2.windows.1