]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Avoid DEBUG_CLEAR_MEMORY clearing MemoryMap internal structure.
authorjgong5 <jgong5@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 3 Apr 2010 05:34:16 +0000 (05:34 +0000)
committerjgong5 <jgong5@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 3 Apr 2010 05:34:16 +0000 (05:34 +0000)
In CoreFreePages(), the following sequence might break the MemoryMap internal structure:
CoreConvertPages() -> CoreFreeMemoryMapStack() -> AllocateMemoryMapEntry() -> CoreAllocatePoolPages() -> DEBUG_CLEAR_MEMORY()

CoreConvertPages() will call CoreFreeMemoryMapStack() after it adds the freed memory range, so the latter might use the just freed memory range when calling AllocateMemoryMapEntry(). But CoreFreePages() will call DEBUG_CLEAR_MEMORY() after CoreConvertPages(). This might clear up the memory map entry structure.

The fix calls DEBUG_CLEAR_MEMORY() just after freed memory range is added in CoreConvertPages(), which is safe.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10335 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Mem/Page.c

index b0cf1ece1e6545c50fcda28b67baead29c4164c7..9a78698df9aa8c82511b1a5100f365cb6a4e680a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory page management functions.\r
 \r
-Copyright (c) 2007 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2007 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -829,6 +829,9 @@ CoreConvertPages (
     // Add our new range in\r
     //\r
     CoreAddRange (NewType, Start, RangeEnd, Attribute);\r
+    if (NewType == EfiConventionalMemory) {\r
+      DEBUG_CLEAR_MEMORY ((VOID *)(UINTN)Start, RangeEnd - Start + 1);\r
+    }\r
 \r
     //\r
     // Move any map descriptor stack to general pool\r
@@ -1198,13 +1201,6 @@ CoreFreePages (
     goto Done;\r
   }\r
 \r
-  //\r
-  // Destroy the contents\r
-  //\r
-  if (Memory < MAX_ADDRESS) {\r
-    DEBUG_CLEAR_MEMORY ((VOID *)(UINTN)Memory, NumberOfPages << EFI_PAGE_SHIFT);\r
-  }\r
-\r
 Done:\r
   CoreReleaseMemoryLock ();\r
   return Status;\r