]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c
EdkCompatibilityPkg: Use ImageContext.ImageSize to allocate memory for PE image
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / BootScriptSaveOnS3SaveStateThunk / ScriptSave.c
index 4d1013caf00e02ad33d8f7413e8927bb140945e5..03e7ea60c3b00f986c7be4a719e4c44188fa1499 100644 (file)
@@ -2,7 +2,7 @@
   Implementation for S3 Boot Script Save thunk driver.\r
   This thunk driver consumes PI S3SaveState protocol to produce framework S3BootScriptSave Protocol \r
   \r
-  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 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
@@ -899,7 +899,11 @@ InitializeScriptSaveOnS3SaveState (
     ASSERT_EFI_ERROR (Status);\r
 \r
     MemoryAddress = SIZE_4GB - 1;\r
-    PageNumber    = EFI_SIZE_TO_PAGES (BufferSize + ImageContext.SectionAlignment);\r
+    if (ImageContext.SectionAlignment > EFI_PAGE_SIZE) {\r
+      PageNumber = EFI_SIZE_TO_PAGES (ImageContext.ImageSize + ImageContext.SectionAlignment);\r
+    } else {\r
+      PageNumber = EFI_SIZE_TO_PAGES (ImageContext.ImageSize);\r
+    }\r
     Status  = gBS->AllocatePages (\r
                      AllocateMaxAddress,\r
                      EfiReservedMemoryType,\r