public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Lin, Gary (HPS OE-Linux)" <gary.lin@hpe.com>
To: <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Anthony Perard <anthony.perard@citrix.com>,
	Julien Grall <julien@xen.org>, Jim Fehlig <jfehlig@suse.com>,
	Joey Li <jlee@suse.com>, Gerd Hoffmann <kraxel@redhat.com>,
	Jiewen Yao <Jiewen.yao@intel.com>
Subject: [RESEND PATCH v3 1/4] OvmfPkg/OvmfXen: set PcdAcpiS3Enable at initialization
Date: Tue, 31 Aug 2021 09:31:12 +0800	[thread overview]
Message-ID: <20210831013115.23110-2-gary.lin@hpe.com> (raw)
In-Reply-To: <20210831013115.23110-1-gary.lin@hpe.com>

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

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Cc: Jim Fehlig <jfehlig@suse.com>
Cc: Joey Li <jlee@suse.com>
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>
---
v3:
  - Update the description per Anthony's suggestion
  - Add the bugzilla link
v2:
  - Amend the description and address "HVM Direct Kernel Boot"
  - Add the comment for the conditional test of QemuFwCfgS3Enabled()
  - Remove unused QemuFwCfgLib
---
 OvmfPkg/XenPlatformPei/XenPlatformPei.inf |  2 ++
 OvmfPkg/XenPlatformPei/Platform.c         | 13 +++++++++++++
 2 files changed, 15 insertions(+)

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


  reply	other threads:[~2021-08-31  1:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-31  1:31 [RESEND PATCH v3 0/4] Fix OvmfXen boot failure due to s3 support state Lin, Gary (HPS OE-Linux)
2021-08-31  1:31 ` Lin, Gary (HPS OE-Linux) [this message]
2021-08-31  1:31 ` [RESEND PATCH v3 2/4] OvmfPkg/LockBoxLib: use PcdAcpiS3Enable to detect S3 support Lin, Gary (HPS OE-Linux)
2021-08-31  1:31 ` [RESEND PATCH v3 3/4] OvmfPkg/PlatformBootManagerLib: " Lin, Gary (HPS OE-Linux)
2021-08-31  1:31 ` [RESEND PATCH v3 4/4] OvmfPkg/SmmControl2Dxe: " Lin, Gary (HPS OE-Linux)
2021-08-31 11:08 ` [edk2-devel] [RESEND PATCH v3 0/4] Fix OvmfXen boot failure due to s3 support state Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210831013115.23110-2-gary.lin@hpe.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox