From: Jiewen Yao Date: Wed, 22 Nov 2017 14:05:07 +0000 (+0800) Subject: MdeModulePkg/DxeCore: Install UEFI mem attrib table at EndOfDxe. X-Git-Tag: edk2-stable201903~1345 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=b2305dd277ba678027ed67f9a34c41c6a2eb519c MdeModulePkg/DxeCore: Install UEFI mem attrib table at EndOfDxe. So that the SMM can consume it to set page protection for the UEFI runtime page with EFI_MEMORY_RO attribute. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jiewen Yao Reviewed-by: Star Zeng --- diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c index 43e5be8b54..60557faa1c 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c @@ -240,6 +240,23 @@ InstallMemoryAttributesTableOnReadyToBoot ( mMemoryAttributesTableReadyToBoot = TRUE; } +/** + Install initial MemoryAttributesTable on EndOfDxe. + Then SMM can consume this information. + + @param[in] Event The Event this notify function registered to. + @param[in] Context Pointer to the context data registered to the Event. +**/ +VOID +EFIAPI +InstallMemoryAttributesTableOnEndOfDxe ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + InstallMemoryAttributesTable (); +} + /** Initialize MemoryAttrubutesTable support. **/ @@ -251,18 +268,35 @@ CoreInitializeMemoryAttributesTable ( { EFI_STATUS Status; EFI_EVENT ReadyToBootEvent; + EFI_EVENT EndOfDxeEvent; // // Construct the table at ReadyToBoot. // Status = CoreCreateEventInternal ( EVT_NOTIFY_SIGNAL, - TPL_CALLBACK - 1, + TPL_CALLBACK, InstallMemoryAttributesTableOnReadyToBoot, NULL, &gEfiEventReadyToBootGuid, &ReadyToBootEvent ); ASSERT_EFI_ERROR (Status); + + // + // Construct the initial table at EndOfDxe, + // then SMM can consume this information. + // Use TPL_NOTIFY here, as such SMM code (TPL_CALLBACK) + // can run after it. + // + Status = CoreCreateEventInternal ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + InstallMemoryAttributesTableOnEndOfDxe, + NULL, + &gEfiEndOfDxeEventGroupGuid, + &EndOfDxeEvent + ); + ASSERT_EFI_ERROR (Status); return ; }