From 408e4631359d3e67633b36f6adf9a13a7cc573d3 Mon Sep 17 00:00:00 2001 From: Taylor Beebe Date: Thu, 10 Aug 2023 10:22:44 -0700 Subject: MdeModulePkg: Memory Bin Range Update Accounts for Guard Page When finding a free page range for allocation, if the found range starts below the tracked memory bin address range, the lowest memory bin address is updated which will not include the guard page if present. When CoreConvertPagesWithGuard() is called on the range being allocated, the memory range is adjusted to include guard pages which can push it out of the memory bin address range and cause the memory type statistics to be unaltered. This patch updates the lowest memory bin address range to account for the guard page if NeedGuard is TRUE so the memory type statistics are updated correctly. Cc: Jian J Wang Cc: Liming Gao Cc: Dandan Bi Signed-off-by: Taylor Beebe Reviewed-by: Liming Gao --- MdeModulePkg/Core/Dxe/Mem/Page.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 41af50b3d5..6497af5733 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -1210,7 +1210,7 @@ FindFreePages ( ); if (Start != 0) { if (Start < mDefaultBaseAddress) { - mDefaultBaseAddress = Start; + mDefaultBaseAddress = NeedGuard ? Start - EFI_PAGE_SIZE : Start; } return Start; -- cgit v1.2.3