From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id F04B1AC06D3 for ; Mon, 29 Jan 2024 03:45:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UhVmJo1dj0dMWAED6omMxRT4uQCYZet6qwHUtKu3Q6M=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1706499939; v=1; b=NK37rwFmqXSkwTLD89y09sLKQ94KwIle0uwFdPdpgzhBxUKzrHItIrkRz+EqddqawDkuag+g N8iWxIWNF9E0IO1uLeJB81Pke7zQQ18nqp1q/wxrySrDGWoR3L2OPCSqERiKl7wH+7++NcB6iXL kxGgfwYDqNK0tGgIe6Usfe6E= X-Received: by 127.0.0.2 with SMTP id K8apYY7687511x9f9GKiKI5C; Sun, 28 Jan 2024 19:45:39 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.6721.1706499938782819105 for ; Sun, 28 Jan 2024 19:45:38 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="406565623" X-IronPort-AV: E=Sophos;i="6.05,226,1701158400"; d="scan'208";a="406565623" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2024 19:45:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="960774668" X-IronPort-AV: E=Sophos;i="6.05,226,1701158400"; d="scan'208";a="960774668" X-Received: from mdkinney-mobl.amr.corp.intel.com ([10.209.52.235]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2024 19:45:20 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Aaron Li , Liu Yun , Andrew Fish Subject: [edk2-devel] [Patch v2 1/2] MdeModulePkg/Core/Dxe: Initialize GCD before RT memory allocations Date: Sun, 28 Jan 2024 19:45:13 -0800 Message-Id: <20240129034514.1898-2-michael.d.kinney@intel.com> In-Reply-To: <20240129034514.1898-1-michael.d.kinney@intel.com> References: <20240129034514.1898-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rXC6geLGzAg7rofsE049rgHdx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=NK37rwFm; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Update the DxeMain initialization order to initialize GCD services before any runtime allocations are performed. This is required to prevent runtime data fragmentation when the UEFI System Table and UEFI Runtime Service Table are allocated before both the memory and GCD services are initialized. Cc: Liming Gao Cc: Aaron Li Cc: Liu Yun Cc: Andrew Fish Signed-off-by: Michael D Kinney --- MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 23 ++++++++++++++--------- MdeModulePkg/Core/Dxe/Image/Image.c | 1 - 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 0e0f9769b99d..17d510a287e5 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -276,6 +276,18 @@ DxeMain ( MemoryProfileInit (HobStart); + // + // Start the Image Services. + // + Status = CoreInitializeImageServices (HobStart); + ASSERT_EFI_ERROR (Status); + + // + // Initialize the Global Coherency Domain Services + // + Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength); + ASSERT_EFI_ERROR (Status); + // // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table @@ -289,16 +301,9 @@ DxeMain ( gDxeCoreST->RuntimeServices = gDxeCoreRT; // - // Start the Image Services. + // Update DXE Core Loaded Image Protocol with allocated UEFI System Table // - Status = CoreInitializeImageServices (HobStart); - ASSERT_EFI_ERROR (Status); - - // - // Initialize the Global Coherency Domain Services - // - Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength); - ASSERT_EFI_ERROR (Status); + gDxeCoreLoadedImage->SystemTable = gDxeCoreST; // // Call constructor for all libraries diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 6bc3a549ae5e..3fc74eb9fd6b 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -222,7 +222,6 @@ CoreInitializeImageServices ( Image->ImageBasePage = DxeCoreImageBaseAddress; Image->NumberOfPages = (UINTN)(EFI_SIZE_TO_PAGES ((UINTN)(DxeCoreImageLength))); Image->Tpl = gEfiCurrentTpl; - Image->Info.SystemTable = gDxeCoreST; Image->Info.ImageBase = (VOID *)(UINTN)DxeCoreImageBaseAddress; Image->Info.ImageSize = DxeCoreImageLength; -- 2.40.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114668): https://edk2.groups.io/g/devel/message/114668 Mute This Topic: https://groups.io/mt/104025661/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-