UefiCpuPkg: remove unnecessary manipulation for smm page table

In this commit, we only set some special bits in paging entry
content when SMM profile is enabled.

Previously, we set Pml4Entry sub-entries number and set the
IA32_PG_PMNT bit for first 4 PdptEntry. It's to make sure that
the paging structures cover [0, 4G] won't be reclaimed during
dynamic page table creation.
In last commit, we always create full mapping SMM page table
regardless PcdCpuSmmRestrictedMemoryAccess. With this change,
we only need to dynamic create SMM page table in smm PF handler
when PcdCpuSmmProfileEnable is TRUE.

So the sub-entries number and IA32_PG_PMNT bit in paging entry
is only needed to set when PcdCpuSmmProfileEnable is TRUE.

Signed-off-by: Dun Tan <dun.tan@intel.com>
This commit is contained in:
Dun Tan 2024-07-25 13:58:38 +08:00 committed by mergify[bot]
parent 9f29fbd33b
commit b3631ca944

View File

@ -228,26 +228,26 @@ SmmInitPageTable (
//
PageTable = GenSmmPageTable (mPagingMode, mPhysicalAddressBits);
if (m5LevelPagingNeeded) {
Pml5Entry = (UINT64 *)PageTable;
//
// Set Pml5Entry sub-entries number for smm PF handler usage.
//
SetSubEntriesNum (Pml5Entry, 1);
Pml4Entry = (UINT64 *)((*Pml5Entry) & ~mAddressEncMask & gPhyMask);
} else {
Pml4Entry = (UINT64 *)PageTable;
}
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
if (m5LevelPagingNeeded) {
Pml5Entry = (UINT64 *)PageTable;
//
// Set Pml5Entry sub-entries number for smm PF handler usage.
//
SetSubEntriesNum (Pml5Entry, 1);
Pml4Entry = (UINT64 *)((*Pml5Entry) & ~mAddressEncMask & gPhyMask);
} else {
Pml4Entry = (UINT64 *)PageTable;
}
//
// Set IA32_PG_PMNT bit to mask first 4 PdptEntry.
//
PdptEntry = (UINT64 *)((*Pml4Entry) & ~mAddressEncMask & gPhyMask);
for (Index = 0; Index < 4; Index++) {
PdptEntry[Index] |= IA32_PG_PMNT;
}
//
// Set IA32_PG_PMNT bit to mask first 4 PdptEntry.
//
PdptEntry = (UINT64 *)((*Pml4Entry) & ~mAddressEncMask & gPhyMask);
for (Index = 0; Index < 4; Index++) {
PdptEntry[Index] |= IA32_PG_PMNT;
}
if (!mCpuSmmRestrictedMemoryAccess) {
//
// Set Pml4Entry sub-entries number for smm PF handler usage.
//