]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 5 Jan 2017 01:56:11 +0000 (09:56 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 6 Jan 2017 12:46:42 +0000 (20:46 +0800)
When firmware boots to UiApp, the memory type information settings
are saved to NV storage and the settings in HOB are changed as well.
Because UiApp is an APPLICATION type of boot option, system doesn't
reset when settings change.
But when user selects OS to boot in UiApp, because the settings in HOB
was updated when booting to UiApp, the BDS doesn't think the settings
change, expected reset doesn't happen.

The patch fixes this issue to not update the settings in HOB.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c

index 09e421135205d2fcc166840243e4a314e18a67e6..e11d8428d63b4466bd297710e13e7be615f796cd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Misc library functions.\r
 \r
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -205,8 +205,11 @@ BmSetMemoryTypeInformationVariable (
     //\r
     return;\r
   }\r
-  PreviousMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);\r
-  VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);\r
+  VariableSize                  = GET_GUID_HOB_DATA_SIZE (GuidHob);\r
+  PreviousMemoryTypeInformation = AllocateCopyPool (VariableSize, GET_GUID_HOB_DATA (GuidHob));\r
+  if (PreviousMemoryTypeInformation == NULL) {\r
+    return;\r
+  }\r
 \r
   //\r
   // Use a heuristic to adjust the Memory Type Information for the next boot\r
@@ -278,14 +281,18 @@ BmSetMemoryTypeInformationVariable (
       // then reset the platform so the new Memory Type Information setting will be used to guarantee that an S4\r
       // entry/resume cycle will not fail.\r
       //\r
-      if (MemoryTypeInformationModified && Boot && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {\r
-        DEBUG ((EFI_D_INFO, "Memory Type Information settings change. Warm Reset!!!\n"));\r
-        gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+      if (MemoryTypeInformationModified) {\r
+        DEBUG ((EFI_D_INFO, "Memory Type Information settings change.\n"));\r
+        if (Boot && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {\r
+          DEBUG ((EFI_D_INFO, "...Warm Reset!!!\n"));\r
+          gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+        }\r
       }\r
     } else {\r
       DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));\r
     }\r
   }\r
+  FreePool (PreviousMemoryTypeInformation);\r
 }\r
 \r
 /**\r