]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/OvmfXen: set PcdAcpiS3Enable at initialization
authorLin, Gary (HPS OE-Linux) <gary.lin@hpe.com>
Tue, 31 Aug 2021 01:31:12 +0000 (09:31 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 31 Aug 2021 11:07:16 +0000 (11:07 +0000)
There are several functions in OvmfPkg/Library using
QemuFwCfgS3Enabled() to detect the S3 support status. However, in
MdeModulePkg, PcdAcpiS3Enable is used to check S3 support. Since
InitializeXenPlatform() didn't set PcdAcpiS3Enable as
InitializePlatform() did, this made the inconsistency between
drivers/functions.

For example, S3SaveStateDxe checked PcdAcpiS3Enable and skipped
S3BootScript because the default value is FALSE. On the other hand,
PlatformBootManagerBeforeConsole() from OvmfPkg/Library called
QemuFwCfgS3Enabled() and found it returned TRUE, so it invoked
SaveS3BootScript(). However, S3SaveStateDxe skipped S3BootScript, so
SaveS3BootScript() asserted due to EFI_NOT_FOUND.

This issue mainly affects "HVM Direct Kernel Boot". When used,
"fw_cfg" is enabled in QEMU and QemuFwCfgS3Enabled() returns true in
that case.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3573
Signed-off-by: Gary Lin <gary.lin@hpe.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
OvmfPkg/XenPlatformPei/Platform.c
OvmfPkg/XenPlatformPei/XenPlatformPei.inf

index a811e72ee3018d26f0794838149de8d8cbdc7afd..e60478fdb493b3e5909107e5b46bb1c8cb92cb34 100644 (file)
@@ -26,6 +26,7 @@
 #include <Library/PciLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/PeiServicesLib.h>\r
+#include <Library/QemuFwCfgS3Lib.h>\r
 #include <Library/ResourcePublicationLib.h>\r
 #include <Guid/MemoryTypeInformation.h>\r
 #include <Ppi/MasterBootMode.h>\r
@@ -423,6 +424,8 @@ InitializeXenPlatform (
   IN CONST EFI_PEI_SERVICES     **PeiServices\r
   )\r
 {\r
+  EFI_STATUS    Status;\r
+\r
   DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));\r
 \r
   DebugDumpCmos ();\r
@@ -433,6 +436,16 @@ InitializeXenPlatform (
     CpuDeadLoop ();\r
   }\r
 \r
+  //\r
+  // This S3 conditional test is mainly for HVM Direct Kernel Boot since\r
+  // QEMU fwcfg isn't really supported other than that.\r
+  //\r
+  if (QemuFwCfgS3Enabled ()) {\r
+    DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));\r
+    Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
   XenConnect ();\r
 \r
   BootModeInitialization ();\r
index 597cb6fcd7ff91fe516301e0e55dacf5e3bebc1c..20c27ff34b6c8e99bedcc0e21a85e706edf0557a 100644 (file)
@@ -57,6 +57,7 @@
   ResourcePublicationLib\r
   PeiServicesLib\r
   PeimEntryPoint\r
+  QemuFwCfgS3Lib\r
   MtrrLib\r
   MemEncryptSevLib\r
   PcdLib\r
@@ -79,6 +80,7 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base\r
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size\r
   gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode\r