Revision: 18037
http://sourceforge.net/p/edk2/code/18037
Author: jljusten
Date: 2015-07-26 08:02:24 +0000 (Sun, 26 Jul 2015)
Log Message:
-----------
OvmfPkg: install DxeSmmReadyToLock in PlatformBdsLib
Currently we have the following call chain in OVMF:
PlatformBdsPolicyBehavior()
[OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c]
//
// signals End-of-Dxe
//
OnEndOfDxe() [OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c]
S3Ready() [OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c]
//
// 1. saves S3 state
//
SaveS3BootScript() [OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c]
//
// 2. saves INFO opcode in S3 boot script
// 3. installs DxeSmmReadyToLockProtocol
//
The bottom of this call chain was introduced in git commit 5a217a06 (SVN
r15305, "OvmfPkg: S3 Suspend: save boot script after ACPI context"). That
patch was necessary because there was no other way, due to GenericBdsLib
calling S3Save() from BdsLibBootViaBootOption(), to perform the necessary
steps in the right order:
- save S3 system information,
- save a final (well, only) boot script opcode,
- signal DxeSmmReadyToLock, closing the boot script, and locking down
LockBox and SMM.
The GenericBdsLib bug has been fixed in the previous patch -- the call in
BdsLibBootViaBootOption() has been eliminated.
Therefore, hoist the SaveS3BootScript() code, and call, from
OvmfPkg/AcpiS3SaveDxe, to PlatformBdsLib:
PlatformBdsPolicyBehavior()
[OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c]
//
// signals End-of-Dxe
//
OnEndOfDxe() [OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c]
S3Ready() [OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c]
//
// 1. saves S3 state
//
<---
SaveS3BootScript() [OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c]
//
// 2. saves INFO opcode in S3 boot script
// 3. installs DxeSmmReadyToLockProtocol
//
The installation of DxeSmmReadyToLockProtocol belongs with Platform BDS,
not AcpiS3SaveDxe, and we can now undo the hack in SVN r15305, without
upsetting the relative order of the steps.
Cc: Jordan Justen <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Revision Links:
--------------
http://sourceforge.net/p/edk2/code/15305
http://sourceforge.net/p/edk2/code/15305
Modified Paths:
--------------
trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
trunk/edk2/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
Modified: trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
===================================================================
--- trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c 2015-07-26 08:02:19 UTC
(rev 18036)
+++ trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c 2015-07-26 08:02:24 UTC
(rev 18037)
@@ -31,8 +31,6 @@
#include <Guid/Acpi.h>
#include <Guid/EventGroup.h>
#include <Protocol/AcpiS3Save.h>
-#include <Protocol/S3SaveState.h>
-#include <Protocol/DxeSmmReadyToLock.h>
#include <Protocol/LockBox.h>
#include <IndustryStandard/Acpi.h>
@@ -415,48 +413,6 @@
}
/**
- Save the S3 boot script.
-
- Note that we trigger DxeSmmReadyToLock here -- otherwise the script wouldn't
- be saved actually. Triggering this protocol installation event in turn locks
- down SMM, so no further changes to LockBoxes or SMRAM are possible
- afterwards.
-**/
-STATIC
-VOID
-EFIAPI
-SaveS3BootScript (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
- EFI_HANDLE Handle;
- STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
-
- Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, NULL,
- (VOID **) &BootScript);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Despite the opcode documentation in the PI spec, the protocol
- // implementation embeds a deep copy of the info in the boot script, rather
- // than storing just a pointer to runtime or NVS storage.
- //
- Status = BootScript->Write(BootScript, EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
- (UINT32) sizeof Info,
- (EFI_PHYSICAL_ADDRESS)(UINTN) &Info);
- ASSERT_EFI_ERROR (Status);
-
- Handle = NULL;
- Status = gBS->InstallProtocolInterface (&Handle,
- &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
- NULL);
- ASSERT_EFI_ERROR (Status);
-}
-
-
-/**
Prepares all information that is needed in the S3 resume boot path.
Allocate the resources or prepare informations and save in ACPI variable set
for S3 resume boot path
@@ -563,11 +519,6 @@
Status = SetLockBoxAttributes (&gEfiAcpiS3ContextGuid,
LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
ASSERT_EFI_ERROR (Status);
- //
- // Save the boot script too. Note that this requires/includes emitting the
- // DxeSmmReadyToLock event, which in turn locks down SMM.
- //
- SaveS3BootScript ();
return EFI_SUCCESS;
}
Modified: trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
===================================================================
--- trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf 2015-07-26 08:02:19 UTC
(rev 18036)
+++ trunk/edk2/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf 2015-07-26 08:02:24 UTC
(rev 18037)
@@ -66,8 +66,6 @@
gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiLegacyRegion2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gFrameworkEfiMpServiceProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiS3SaveStateProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_PRODUCED
[FeaturePcd]
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformCsmSupport ##
CONSUMES
@@ -79,4 +77,4 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
[Depex]
- gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid AND
gEfiS3SaveStateProtocolGuid
+ gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
Modified: trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
===================================================================
--- trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c 2015-07-26
08:02:19 UTC (rev 18036)
+++ trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c 2015-07-26
08:02:24 UTC (rev 18037)
@@ -1184,7 +1184,48 @@
}
+/**
+ Save the S3 boot script.
+
+ Note that we trigger DxeSmmReadyToLock here -- otherwise the script wouldn't
+ be saved actually. Triggering this protocol installation event in turn locks
+ down SMM, so no further changes to LockBoxes or SMRAM are possible
+ afterwards.
+**/
+STATIC
VOID
+SaveS3BootScript (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_S3_SAVE_STATE_PROTOCOL *BootScript;
+ EFI_HANDLE Handle;
+ STATIC CONST UINT8 Info[] = { 0xDE, 0xAD, 0xBE, 0xEF };
+
+ Status = gBS->LocateProtocol (&gEfiS3SaveStateProtocolGuid, NULL,
+ (VOID **) &BootScript);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Despite the opcode documentation in the PI spec, the protocol
+ // implementation embeds a deep copy of the info in the boot script, rather
+ // than storing just a pointer to runtime or NVS storage.
+ //
+ Status = BootScript->Write(BootScript, EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
+ (UINT32) sizeof Info,
+ (EFI_PHYSICAL_ADDRESS)(UINTN) &Info);
+ ASSERT_EFI_ERROR (Status);
+
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (&Handle,
+ &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
+ NULL);
+ ASSERT_EFI_ERROR (Status);
+}
+
+
+VOID
EFIAPI
PlatformBdsPolicyBehavior (
IN OUT LIST_ENTRY *DriverOptionList,
@@ -1240,6 +1281,14 @@
gBS->CloseEvent (EndOfDxeEvent);
}
+ if (QemuFwCfgS3Enabled ()) {
+ //
+ // Save the boot script too. Note that this requires/includes emitting the
+ // DxeSmmReadyToLock event, which in turn locks down SMM.
+ //
+ SaveS3BootScript ();
+ }
+
if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
"from disk since flash variables appear to be supported.\n"));
Modified: trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h
===================================================================
--- trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h 2015-07-26
08:02:19 UTC (rev 18036)
+++ trunk/edk2/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.h 2015-07-26
08:02:24 UTC (rev 18037)
@@ -47,12 +47,15 @@
#include <Library/DevicePathLib.h>
#include <Library/IoLib.h>
#include <Library/NvVarsFileLib.h>
+#include <Library/QemuFwCfgLib.h>
#include <Protocol/Decompress.h>
#include <Protocol/PciIo.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/S3SaveState.h>
+#include <Protocol/DxeSmmReadyToLock.h>
#include <Guid/Acpi.h>
#include <Guid/SmBios.h>
Modified: trunk/edk2/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
===================================================================
--- trunk/edk2/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
2015-07-26 08:02:19 UTC (rev 18036)
+++ trunk/edk2/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
2015-07-26 08:02:24 UTC (rev 18037)
@@ -65,6 +65,8 @@
[Protocols]
gEfiDecompressProtocolGuid
gEfiPciRootBridgeIoProtocolGuid
+ gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
+ gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
[Guids]
gEfiEndOfDxeEventGroupGuid
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits