From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.12263.1673400289090483968 for ; Tue, 10 Jan 2023 17:24:49 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=EZQTUhad; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673400289; x=1704936289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FKAXmp1M5bamcMmN6AwNa84Cgjp0alhYYL2RBFfyp/4=; b=EZQTUhad/5joP0amTqZ7NuMxFgWp1s2T+TgE+XzqWXqwvvLfsIy21Vot vA3k+g8LbImbjcts6B99V5zYOX4xXnGtcTyekPDQNuQJCKNOZl5oS4kbE 6yJmR8XP0GlWojDbkxof5TJ0gbhoM+wSfYtpbOKt9FxEaKIXUTPW1ujJ2 RogFs5fv2csWepCx9rYUoIlKa2veYXSYdR0ALlQolE5B7w8vVOpjsIN9w zZ2YltbFG4u+qiV+XdJw0ZRUdRgQ9Nwrol7mJ62YHIn8wTe/w73xc8hhu CL8jOwnDOjVSF2yTvNpRFlO9CENDxESkPaHpuPhVg0tnKIWhmpTLDvIXV Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="387764489" X-IronPort-AV: E=Sophos;i="5.96,315,1665471600"; d="scan'208";a="387764489" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2023 17:24:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="659192851" X-IronPort-AV: E=Sophos;i="5.96,315,1665471600"; d="scan'208";a="659192851" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.213.42.137]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2023 17:24:20 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Laszlo Ersek , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [PATCH V3 5/6] OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol Date: Wed, 11 Jan 2023 09:22:34 +0800 Message-Id: <20230111012235.189-6-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20230111012235.189-1-min.m.xu@intel.com> References: <20230111012235.189-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Min M Xu 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 Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Reported-by: Laszlo Ersek Signed-off-by: Min Xu --- 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