]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeMain: Fix wrong sanity check in CoreTerminateMemoryMap()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 21 Jan 2015 03:11:19 +0000 (03:11 +0000)
committererictian <erictian@Edk2>
Wed, 21 Jan 2015 03:11:19 +0000 (03:11 +0000)
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 <ard.biesheuvel@linaro.org>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16630 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Mem/Page.c

index fa84e2612526ed0e15f73557f82b002cbb3b2839..84ebbca141c22810be6ed7b1d891b75c9c1f8431 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Memory page management functions.\r
 \r
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -1790,21 +1790,20 @@ CoreTerminateMemoryMap (
 \r
     for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {\r
       Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);\r
-      if ((Entry->Attribute & EFI_MEMORY_RUNTIME) != 0) {\r
-        if (Entry->Type == EfiACPIReclaimMemory || Entry->Type == EfiACPIMemoryNVS) {\r
-          DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: ACPI memory entry has RUNTIME attribute set.\n"));\r
-          Status =  EFI_INVALID_PARAMETER;\r
-          goto Done;\r
-        }\r
-        if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
-          DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));\r
-          Status =  EFI_INVALID_PARAMETER;\r
-          goto Done;\r
-        }\r
-        if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
-          DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));\r
-          Status =  EFI_INVALID_PARAMETER;\r
-          goto Done;\r
+      if (Entry->Type < EfiMaxMemoryType) {\r
+        if (mMemoryTypeStatistics[Entry->Type].Runtime) {\r
+          ASSERT (Entry->Type != EfiACPIReclaimMemory);\r
+          ASSERT (Entry->Type != EfiACPIMemoryNVS);\r
+          if ((Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
+            DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));\r
+            Status =  EFI_INVALID_PARAMETER;\r
+            goto Done;\r
+          }\r
+          if (((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) != 0) {\r
+            DEBUG((DEBUG_ERROR | DEBUG_PAGE, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));\r
+            Status =  EFI_INVALID_PARAMETER;\r
+            goto Done;\r
+          }\r
         }\r
       }\r
     }\r