]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol
authorMin M Xu <min.m.xu@intel.com>
Wed, 11 Jan 2023 01:22:34 +0000 (09:22 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sun, 15 Jan 2023 10:26:15 +0000 (10:26 +0000)
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@redhat.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Message-Id: <20230111012235.189-6-min.m.xu@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c

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