summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2017-01-05 09:56:11 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2017-01-06 20:46:42 +0800
commit0dc3359ac677b80475c6f4933c513089ad451ebe (patch)
tree40fa7f7d719c79490d05b0278466b96a439b6ba5 /MdeModulePkg
parent5016d46603addf62656590e83375074abc321f23 (diff)
downloadedk2-0dc3359ac677b80475c6f4933c513089ad451ebe.tar.gz
edk2-0dc3359ac677b80475c6f4933c513089ad451ebe.tar.bz2
edk2-0dc3359ac677b80475c6f4933c513089ad451ebe.zip
MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 09e4211352..e11d8428d6 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -1,7 +1,7 @@
/** @file
Misc library functions.
-Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -205,8 +205,11 @@ BmSetMemoryTypeInformationVariable (
//
return;
}
- PreviousMemoryTypeInformation = GET_GUID_HOB_DATA (GuidHob);
- VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
+ VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
+ PreviousMemoryTypeInformation = AllocateCopyPool (VariableSize, GET_GUID_HOB_DATA (GuidHob));
+ if (PreviousMemoryTypeInformation == NULL) {
+ return;
+ }
//
// Use a heuristic to adjust the Memory Type Information for the next boot
@@ -278,14 +281,18 @@ BmSetMemoryTypeInformationVariable (
// then reset the platform so the new Memory Type Information setting will be used to guarantee that an S4
// entry/resume cycle will not fail.
//
- if (MemoryTypeInformationModified && Boot && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {
- DEBUG ((EFI_D_INFO, "Memory Type Information settings change. Warm Reset!!!\n"));
- gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ if (MemoryTypeInformationModified) {
+ DEBUG ((EFI_D_INFO, "Memory Type Information settings change.\n"));
+ if (Boot && PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {
+ DEBUG ((EFI_D_INFO, "...Warm Reset!!!\n"));
+ gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+ }
}
} else {
DEBUG ((EFI_D_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));
}
}
+ FreePool (PreviousMemoryTypeInformation);
}
/**