Revision: 16630
          http://sourceforge.net/p/edk2/code/16630
Author:   erictian
Date:     2015-01-21 03:11:19 +0000 (Wed, 21 Jan 2015)
Log Message:
-----------
MdeModulePkg/DxeMain: Fix wrong sanity check in CoreTerminateMemoryMap()

The function CoreTerminateMemoryMap() performs some final sanity checks on the 
runtime regions in the memory map before allowing ExitBootServices() to 
complete. 
Unfortunately, it does so by testing the EFI_MEMORY_RUNTIME bit in the 
Attribute field, which is never set anywhere in the code.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Feng Tian <[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-01-21 02:47:49 UTC (rev 
16629)
+++ trunk/edk2/MdeModulePkg/Core/Dxe/Mem/Page.c 2015-01-21 03:11:19 UTC (rev 
16630)
@@ -1,7 +1,7 @@
 /** @file
   UEFI Memory page management functions.
 
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -1790,22 +1790,21 @@
 
     for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = 
Link->ForwardLink) {
       Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
-      if ((Entry->Attribute & EFI_MEMORY_RUNTIME) != 0) {
-        if (Entry->Type == EfiACPIReclaimMemory || Entry->Type == 
EfiACPIMemoryNVS) {
-          DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: ACPI memory 
entry has RUNTIME attribute set.\n"));
-          Status =  EFI_INVALID_PARAMETER;
-          goto Done;
+      if (Entry->Type < EfiMaxMemoryType) {
+        if (mMemoryTypeStatistics[Entry->Type].Runtime) {
+          ASSERT (Entry->Type != EfiACPIReclaimMemory);
+          ASSERT (Entry->Type != EfiACPIMemoryNVS);
+          if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 
1)) != 0) {
+            DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME 
memory entry is not on a proper alignment.\n"));
+            Status =  EFI_INVALID_PARAMETER;
+            goto Done;
+          }
+          if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT 
- 1)) != 0) {
+            DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME 
memory entry is not on a proper alignment.\n"));
+            Status =  EFI_INVALID_PARAMETER;
+            goto Done;
+          }
         }
-        if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) 
!= 0) {
-          DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory 
entry is not on a proper alignment.\n"));
-          Status =  EFI_INVALID_PARAMETER;
-          goto Done;
-        }
-        if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 
1)) != 0) {
-          DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory 
entry is not on a proper alignment.\n"));
-          Status =  EFI_INVALID_PARAMETER;
-          goto Done;
-        }
       }
     }
 


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to