[edk2] [PATCH 2/2] OvmfPkg: AcpiS3SaveDxe: do not load if S3 is unsupported/disabled in qemu

Subject: [edk2] [PATCH 2/2] OvmfPkg: AcpiS3SaveDxe: do not load if S3 is unsupported/disabled in qemu

From: Laszlo Ersek <lersek@redhat.com>

To: edk2-devel@lists.sourceforge.net

Date: 2014-03-27 07:23:12

The previous patch ensures that the LockBox is protected during DXE (but
the OS can still drop it) if S3 is unsupported or disabled. However, S3
related drivers not only save data in the lockbox, they allocate objects
with Reserved and AcpiNVS memory types too, which the OS can't (must not)
release. This is a waste when S3 is unsupported or disabled.

In OVMF a good "choke point" for these drivers is the entry point of
AcpiS3SaveDxe. The messages of the following commits are relevant to the
data and control flow:

- SVN r15290 (git commit 8f5ca05b)
- SVN r15305 (git commit 5a217a06)
- SVN r15306 (git commit d4ba06df)

Prevent AcpiS3SaveDxe from loading when S3 is unsupported or disabled.
This should keep away (most of the) dependent drivers too.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf | 2 ++
 OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c      | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf b/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
index fd26a05..b53e785 100644
--- a/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
+++ b/OvmfPkg/AcpiS3SaveDxe/AcpiS3SaveDxe.inf
@@ -38,6 +38,7 @@
   MdeModulePkg/MdeModulePkg.dec
   IntelFrameworkPkg/IntelFrameworkPkg.dec
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+  OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   PcdLib
@@ -50,6 +51,7 @@
   LockBoxLib
   DebugLib
   DxeServicesLib
+  QemuFwCfgLib
 
 [Guids]
   gEfiAcpiVariableGuid                          # ALWAYS_CONSUMED
diff --git a/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c b/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
index a4de911..f322981 100644
--- a/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
+++ b/OvmfPkg/AcpiS3SaveDxe/AcpiS3Save.c
@@ -24,6 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -586,6 +587,10 @@ InstallAcpiS3Save (
 {
   EFI_STATUS        Status;
 
+  if (!QemuFwCfgS3Enabled()) {
+    return EFI_LOAD_ERROR;
+  }
+
   if (!FeaturePcdGet(PcdPlatformCsmSupport)) {
     //
     // More memory for no CSM tip, because GDT need relocation
-- 
1.8.3.1


------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel