MdeModulePkg: Remove other attribute protection in UnsetGuardPage

In UnsetGuardPage(), before SmmReadyToLock, remove NX and RO
memory attribute protection for guarded page since
EfiConventionalMemory in SMRAM is RW and executable before
SmmReadyToLock. If UnsetGuardPage() happens after SmmReadyToLock,
then apply EFI_MEMORY_XP to the guarded page to make sure
EfiConventionalMemory in SMRAM is NX since EfiConventionalMemory
in SMRAM is marked as NX in PiSmmCpuDxe driver when SmmReadyToLock.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
This commit is contained in:
Dun Tan 2023-05-16 15:51:50 +08:00 committed by Ray Ni
parent a78938f274
commit 8c99839776

View File

@ -553,9 +553,23 @@ UnsetGuardPage (
mSmmMemoryAttribute,
BaseAddress,
EFI_PAGE_SIZE,
EFI_MEMORY_RP
EFI_MEMORY_RP|EFI_MEMORY_RO|EFI_MEMORY_XP
);
ASSERT_EFI_ERROR (Status);
if (gST == NULL) {
//
// Make sure EfiConventionalMemory is NX after SmmReadyToLock
//
Status = mSmmMemoryAttribute->SetMemoryAttributes (
mSmmMemoryAttribute,
BaseAddress,
EFI_PAGE_SIZE,
EFI_MEMORY_XP
);
ASSERT_EFI_ERROR (Status);
}
mOnGuarding = FALSE;
}
}