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 <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Dandan Bi <dandan.bi@intel.com>
Signed-off-by: Taylor Beebe <t@taylorbeebe.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Taylor Beebe 2023-08-10 10:22:44 -07:00 committed by mergify[bot]
parent db38c7de64
commit 408e463135
1 changed files with 1 additions and 1 deletions

View File

@ -1210,7 +1210,7 @@ FindFreePages (
);
if (Start != 0) {
if (Start < mDefaultBaseAddress) {
mDefaultBaseAddress = Start;
mDefaultBaseAddress = NeedGuard ? Start - EFI_PAGE_SIZE : Start;
}
return Start;