- ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE);\r
+ if (IsTableEntry (*Entry, Level)) {\r
+ //\r
+ // We are replacing a table entry with a block entry. This is only\r
+ // possible if we are keeping none of the original attributes.\r
+ // We can free the table entry's page table, and all the ones below\r
+ // it, since we are dropping the only possible reference to it.\r
+ //\r
+ ASSERT (AttributeClearMask == 0);\r
+ TranslationTable = (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOCK_ENTRY);\r
+ ReplaceTableEntry (Entry, EntryValue, RegionStart, TRUE);\r
+ FreePageTablesRecursive (TranslationTable, Level + 1);\r
+ } else {\r
+ ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE);\r
+ }\r