{\r
UINTN AlignedMemBase;\r
\r
+ //\r
+ // Do not add memory regions that is already allocated, needs testing, or needs ECC initialization\r
+ //\r
+ if ((Attributes & (EFI_ALLOCATED | EFI_NEEDS_TESTING | EFI_NEEDS_ECC_INITIALIZATION)) != 0) {\r
+ return;\r
+ }\r
+ \r
+ //\r
+ // Align range on an EFI_PAGE_SIZE boundary\r
+ // \r
AlignedMemBase = (UINTN)(MemBase + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;\r
MemLength -= AlignedMemBase - MemBase;\r
SmmFreePages (AlignedMemBase, TRUNCATE_TO_PAGES ((UINTN)MemLength));\r