Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory

Michael D Kinney

Hi Sean,

The auto promotion of memory was only intended as a dev/debug feature to maximize
platform boot without having to tune what memory is tested in PEI phase.

In my opinion, a production platform should never trigger any auto promotions of
untested to tested memory, and part of production validation should make sure this
event never occurs in any production boot scenarios.

The specific bug being fix here is that auto promotion was not symmetric across
all memory allocation types. It simply aligns this dev/debug feature.


-----Original Message-----
From: <> On Behalf Of Sean
Sent: Monday, January 10, 2022 6:47 PM
To:; Gao, Liming <>; Howell, Stacy <>
Cc: Bi, Dandan <>
Subject: Re: 回复: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to use untested memory

if this is auto promotion is happening in the core then what is the
value of memory testing and tracking that state. Is memory testing
state a necessary feature of the Dxe Core?

I think it makes more sense that if you platform wants to use a given
range your platform should either test it and/or mark it as tested.


The dxe core should do away with the memory testing tracking.

On most platforms i have seen in the past few years all memory is marked
as tested without doing any testing. The only value in the flag is keep
the initial memory allocations in a given low range (below 4gb).

On 1/10/2022 5:59 PM, gaoliming wrote:
This fix covers the case with AllocateAddress allocation type. I agree
this fix. Reviewed-by: Liming Gao <>

发件人: <> 代表 Stacy Howell
发送时间: 2022年1月8日 3:36
抄送: Stacy Howell <>; Dandan Bi
<>; Liming Gao <>
主题: [edk2-devel] [PATCH] MdeModulePkg\CoreDxe: Allow DXE Drivers to
use untested memory

REF: https://
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
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
+ // Attempt to promote memory resources, then re-attempt the
+ //
+ if (PromoteMemoryResource ()) {
+ if (NeedGuard) {
+ Status = CoreConvertPagesWithGuard (Start, NumberOfPages,
+ } else {
+ Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
+ }
+ }
+ }
CoreReleaseMemoryLock ();


Join to automatically receive all group messages.