summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/AcpiPlatformDxe
diff options
context:
space:
mode:
authorMin M Xu <min.m.xu@intel.com>2023-01-11 09:22:34 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-01-15 10:26:15 +0000
commit66f18fde49c7fe65818db0801cdaf63015e875e5 (patch)
tree1c4185833079cd4efa8f42cfbb057f28281f2b2a /OvmfPkg/AcpiPlatformDxe
parent2ef0ff39e53d2d2af3859b783882eea6f0beda64 (diff)
downloadedk2-66f18fde49c7fe65818db0801cdaf63015e875e5.tar.gz
edk2-66f18fde49c7fe65818db0801cdaf63015e875e5.tar.bz2
edk2-66f18fde49c7fe65818db0801cdaf63015e875e5.zip
OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol
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>
Diffstat (limited to 'OvmfPkg/AcpiPlatformDxe')
-rw-r--r--OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
index 4629214666..f0d81d6fd7 100644
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
+++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c
@@ -1248,6 +1248,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
// if it succeeds, it cannot be undone.
@@ -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);