Revision: 17575
          http://sourceforge.net/p/edk2/code/17575
Author:   lgao4
Date:     2015-06-08 09:24:31 +0000 (Mon, 08 Jun 2015)
Log Message:
-----------
MdeModulePkg: Fix bug of AllocatePages for large alignment

DescEnd will be clipped for alignment in CoreFindFreePagesI, and it
may fall below DescStart, when alignment is more than 16KB (included)
and both DescStart and original DescEnd fall into a single range of
such alignment. This results in a huge size (Negative number in
unsigned type) for this descriptor, fulfilling the allocation
requirement but failing to run ConvertPages; at last it causes
occasional failure of AllocatePages.

A simple comparison is added to ensure we would never get a negative
number.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Acked-by: Ard Biesheuvel <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Page.c

Modified: trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Page.c
===================================================================
--- trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Page.c 2015-06-08 08:17:15 UTC (rev 
17574)
+++ trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Page.c 2015-06-08 09:24:31 UTC (rev 
17575)
@@ -1051,6 +1051,11 @@
 
     DescEnd = ((DescEnd + 1) & (~(Alignment - 1))) - 1;
 
+    // Skip if DescEnd is less than DescStart after alignment clipping
+    if (DescEnd < DescStart) {
+      continue;
+    }
+
     //
     // Compute the number of bytes we can used from this
     // descriptor, and see it's enough to satisfy the request


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to