[edk2-devel] [PATCH V3 5/6] OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol

Min Xu min.m.xu at intel.com
Wed Jan 11 01:22:34 UTC 2023


From: Min M Xu <min.m.xu at intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4237

Commit 9fdc70af6ba8 install the QemuAcpiTableNotifyProtocol at a
wrong positioin. It should be called before TransferS3ContextToBootScript
because TransferS3ContextToBootScript is the last operation in
InstallQemuFwCfgTables(). Another error is that we should check the
returned value after installing the QemuAcpiTableNotifyProtocol.

This patch refactors the installation and error handling of
QemuAcpiTableNotifyProtocol in InstallQemuFwCfgTables ().

Cc: Laszlo Ersek <lersek at redhat.com>
Cc: Erdem Aktas <erdemaktas at google.com>
Cc: James Bottomley <jejb at linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao at intel.com>
Cc: Gerd Hoffmann <kraxel at redhat.com>
Cc: Tom Lendacky <thomas.lendacky at amd.com>
Reported-by: Laszlo Ersek <lersek at redhat.com>
Signed-off-by: Min Xu <min.m.xu at intel.com>
---
 OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c | 38 ++++++++++++++++---------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
index 462921466604..f0d81d6fd73d 100644
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
+++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
@@ -1247,6 +1247,21 @@ InstallQemuFwCfgTables (
     }
   }
 
+  //
+  // Install a protocol to notify that the ACPI table provided by Qemu is
+  // ready.
+  //
+  QemuAcpiHandle = NULL;
+  Status         = gBS->InstallProtocolInterface (
+                          &QemuAcpiHandle,
+                          &gQemuAcpiTableNotifyProtocolGuid,
+                          EFI_NATIVE_INTERFACE,
+                          NULL
+                          );
+  if (EFI_ERROR (Status)) {
+    goto UninstallAcpiTables;
+  }
+
   //
   // Translating the condensed QEMU_LOADER_WRITE_POINTER commands to ACPI S3
   // Boot Script opcodes has to be the last operation in this function, because
@@ -1255,7 +1270,7 @@ InstallQemuFwCfgTables (
   if (S3Context != NULL) {
     Status = TransferS3ContextToBootScript (S3Context);
     if (EFI_ERROR (Status)) {
-      goto UninstallAcpiTables;
+      goto UninstallQemuAcpiTableNotifyProtocol;
     }
 
     //
@@ -1266,6 +1281,15 @@ InstallQemuFwCfgTables (
 
   DEBUG ((DEBUG_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed));
 
+UninstallQemuAcpiTableNotifyProtocol:
+  if (EFI_ERROR (Status)) {
+    gBS->UninstallProtocolInterface (
+           QemuAcpiHandle,
+           &gQemuAcpiTableNotifyProtocolGuid,
+           NULL
+           );
+  }
+
 UninstallAcpiTables:
   if (EFI_ERROR (Status)) {
     //
@@ -1275,18 +1299,6 @@ UninstallAcpiTables:
       --Installed;
       AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]);
     }
-  } else {
-    //
-    // Install a protocol to notify that the ACPI table provided by Qemu is
-    // ready.
-    //
-    QemuAcpiHandle = NULL;
-    gBS->InstallProtocolInterface (
-           &QemuAcpiHandle,
-           &gQemuAcpiTableNotifyProtocolGuid,
-           EFI_NATIVE_INTERFACE,
-           NULL
-           );
   }
 
   for (SeenPointerEntry = OrderedCollectionMin (SeenPointers);
-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#98263): https://edk2.groups.io/g/devel/message/98263
Mute This Topic: https://groups.io/mt/96191601/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list