From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.11563.1641584224830185774 for ; Fri, 07 Jan 2022 11:37:05 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=CnfVzkcG; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: stacy.howell@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641584224; x=1673120224; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3tuqdfve97LMqm86Tvhs00gfJNOUjvBOIrQvaFMU9FM=; b=CnfVzkcGRC7zW5s57CGnC+3bF+WZqOeA+n35Myk2999uddGw26mSrIg/ rFkS7kMcbh32gvC1K3OrO3IK4R2iLbDsWbtELUUvB4EwaAxvHxjCqgVgb aszqL0wPUZgeVGJvxgxf2mogI3/UIxjYbTQK01+Wot0NujTQZ07/mtuM5 fU9r7YTM2+mPqFlgGQBw8a2cQW0i1Dvj2qiJYB7Zaa3g6Dfizc0NxDr9N QesB82nNVsNagg23DQ04FkSogH14teMEvS2YeojkSJkpKYvMx3F+hEv8L K/AKqlPwC5fiSTJNYaSBAHtM19TYE0bfWiwYhiDhYiHH/xMeyZfPtaMtF Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10220"; a="303673726" X-IronPort-AV: E=Sophos;i="5.88,270,1635231600"; d="scan'208";a="303673726" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2022 11:37:03 -0800 X-IronPort-AV: E=Sophos;i="5.88,270,1635231600"; d="scan'208";a="513912145" Received: from sfe-showell1x.amr.corp.intel.com ([10.54.22.121]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jan 2022 11:37:03 -0800 From: Stacy Howell To: devel@edk2.groups.io Cc: Stacy Howell , Dandan Bi , Liming Gao Subject: [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory Date: Fri, 7 Jan 2022 14:36:12 -0500 Message-Id: <20220107193612.1350-1-stacy.howell@intel.com> X-Mailer: git-send-email 2.32.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://https://bugzilla.tianocore.org/show_bug.cgi?id=3795 CC: Dandan Bi CC: Liming Gao Updated CoreInternalAllocatePages() to call PromoteMemoryResource() and re-attempt the allocation if unable to convert the specified memory range Signed-off-by: Stacy Howell --- MdeModulePkg/Core/Dxe/Mem/Page.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 47d4c5d92e..cc0b90ac0d 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1417,6 +1417,20 @@ CoreInternalAllocatePages ( Status = CoreConvertPages (Start, NumberOfPages, MemoryType); } + if (EFI_ERROR (Status)) { + // + // If requested memory region is unavailable it may be untested memory + // Attempt to promote memory resources, then re-attempt the allocation + // + if (PromoteMemoryResource ()) { + if (NeedGuard) { + Status = CoreConvertPagesWithGuard (Start, NumberOfPages, MemoryType); + } else { + Status = CoreConvertPages (Start, NumberOfPages, MemoryType); + } + } + } + Done: CoreReleaseMemoryLock (); -- 2.32.0.windows.2