MdeModulePkg/DxeCore: Install UEFI mem attrib table at EndOfDxe.
authorJiewen Yao <jiewen.yao@intel.com>
Wed, 22 Nov 2017 14:05:07 +0000 (22:05 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Thu, 26 Jul 2018 14:51:23 +0000 (22:51 +0800)
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 <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c

index 43e5be8..60557fa 100644 (file)
@@ -240,6 +240,23 @@ InstallMemoryAttributesTableOnReadyToBoot (
   mMemoryAttributesTableReadyToBoot = TRUE;\r
 }\r
 \r
+/**\r
+  Install initial MemoryAttributesTable on EndOfDxe.\r
+  Then SMM can consume this information.\r
+\r
+  @param[in] Event      The Event this notify function registered to.\r
+  @param[in] Context    Pointer to the context data registered to the Event.\r
+**/\r
+VOID\r
+EFIAPI\r
+InstallMemoryAttributesTableOnEndOfDxe (\r
+  IN EFI_EVENT          Event,\r
+  IN VOID               *Context\r
+  )\r
+{\r
+  InstallMemoryAttributesTable ();\r
+}\r
+\r
 /**\r
   Initialize MemoryAttrubutesTable support.\r
 **/\r
@@ -251,18 +268,35 @@ CoreInitializeMemoryAttributesTable (
 {\r
   EFI_STATUS  Status;\r
   EFI_EVENT   ReadyToBootEvent;\r
+  EFI_EVENT   EndOfDxeEvent;\r
 \r
   //\r
   // Construct the table at ReadyToBoot.\r
   //\r
   Status = CoreCreateEventInternal (\r
              EVT_NOTIFY_SIGNAL,\r
-             TPL_CALLBACK - 1,\r
+             TPL_CALLBACK,\r
              InstallMemoryAttributesTableOnReadyToBoot,\r
              NULL,\r
              &gEfiEventReadyToBootGuid,\r
              &ReadyToBootEvent\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Construct the initial table at EndOfDxe,\r
+  // then SMM can consume this information.\r
+  // Use TPL_NOTIFY here, as such SMM code (TPL_CALLBACK)\r
+  // can run after it.\r
+  //\r
+  Status = CoreCreateEventInternal (\r
+             EVT_NOTIFY_SIGNAL,\r
+             TPL_NOTIFY,\r
+             InstallMemoryAttributesTableOnEndOfDxe,\r
+             NULL,\r
+             &gEfiEndOfDxeEventGroupGuid,\r
+             &EndOfDxeEvent\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
   return ;\r
 }\r