* [PATCH] MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume
@ 2017-01-05 3:18 Ruiyu Ni
2017-01-05 4:40 ` Yao, Jiewen
2017-01-05 10:10 ` Wang, Sunny (HPS SW)
0 siblings, 2 replies; 3+ messages in thread
From: Ruiyu Ni @ 2017-01-05 3:18 UTC (permalink / raw)
To: edk2-devel; +Cc: Jiewen Yao
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>
Cc: Jiewen Yao <jiewen.yao@intel.com>
---
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 09e4211..cf0455f 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 - 2016, 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);
}
/**
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume
2017-01-05 3:18 [PATCH] MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume Ruiyu Ni
@ 2017-01-05 4:40 ` Yao, Jiewen
2017-01-05 10:10 ` Wang, Sunny (HPS SW)
1 sibling, 0 replies; 3+ messages in thread
From: Yao, Jiewen @ 2017-01-05 4:40 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org
Reviewed-by: Jiewen.yao@intel.com
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Thursday, January 5, 2017 11:18 AM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] 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>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> ---
> MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 19
> +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
> index 09e4211..cf0455f 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 - 2016, 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);
> }
>
> /**
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume
2017-01-05 3:18 [PATCH] MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume Ruiyu Ni
2017-01-05 4:40 ` Yao, Jiewen
@ 2017-01-05 10:10 ` Wang, Sunny (HPS SW)
1 sibling, 0 replies; 3+ messages in thread
From: Wang, Sunny (HPS SW) @ 2017-01-05 10:10 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel@lists.01.org; +Cc: Jiewen Yao, Wang, Sunny (HPS SW)
Looks good to me.
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, January 05, 2017 11:18 AM
To: edk2-devel@lists.01.org
Cc: Jiewen Yao <jiewen.yao@intel.com>
Subject: [edk2] [PATCH] 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>
Cc: Jiewen Yao <jiewen.yao@intel.com>
---
MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index 09e4211..cf0455f 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 - 2016, 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);
}
/**
--
2.9.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-05 10:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-05 3:18 [PATCH] MdeModulePkg/Bds: Fix a bug that may causes S4 fails to resume Ruiyu Ni
2017-01-05 4:40 ` Yao, Jiewen
2017-01-05 10:10 ` Wang, Sunny (HPS SW)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox