From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.15340.1605235842508583164 for ; Thu, 12 Nov 2020 18:50:42 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: w.sheng@intel.com) IronPort-SDR: J7zxvpplB82GK8soIhTy+L5g35WkKedZk88cR+w8IDKkZmHUiXqJkqhbDn/gd24F1n07fr8cf1 RVvmuMp7Hqqg== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="255127466" X-IronPort-AV: E=Sophos;i="5.77,473,1596524400"; d="scan'208";a="255127466" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 18:50:41 -0800 IronPort-SDR: ElO4xRiqNH09Q7p0r0W+/8dNn5Igohvq9zGYAEg2+ip0ueVwuqRrCm5ZRi4yX2rEVZyGWh5xUz OS8NLKAgt7Nw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,473,1596524400"; d="scan'208";a="357348119" Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.46]) by fmsmga004.fm.intel.com with ESMTP; 12 Nov 2020 18:50:40 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar , Jiewen Yao Subject: [PATCH v7 0/2] UefiCpuPkg/PiSmmCpuDxeSmm: Reflect page table depth with page table address Date: Fri, 13 Nov 2020 10:50:35 +0800 Message-Id: <20201113025037.14192-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 | 40 ++++++++++++++++++---- 4 files changed, 75 insertions(+), 39 deletions(-) -- 2.16.2.windows.1