From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 32F7121BADAB6 for ; Thu, 19 Jul 2018 22:26:36 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2018 22:26:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,377,1526367600"; d="scan'208";a="76331901" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.19]) by orsmga002.jf.intel.com with ESMTP; 19 Jul 2018 22:26:32 -0700 From: Hao Wu To: edk2-devel@lists.01.org Cc: Jiewen Yao , Star Zeng Date: Fri, 20 Jul 2018 13:26:23 +0800 Message-Id: <20180720052626.24932-4-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20180720052626.24932-1-hao.a.wu@intel.com> References: <20180720052626.24932-1-hao.a.wu@intel.com> Subject: [PATCH 3/6] MdeModulePkg/DxeCore: Install UEFI mem attrib table at EndOfDxe. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2018 05:26:36 -0000 From: Jiewen Yao So that the SMM can consume it to set page protection for the UEFI runtime page with EFI_MEMORY_RO attribute. Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jiewen Yao --- MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) 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 ; } -- 2.16.2.windows.1