From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.72183.1673272804664614480 for ; Mon, 09 Jan 2023 06:00:06 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=YinvKCVS; spf=pass (domain: intel.com, ip: 134.134.136.126, 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=1673272806; x=1704808806; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kO9yf1E62Ovj0Q5lAUd4tz70wASXDUzkaTDsU54CnS4=; b=YinvKCVSUcGc0IrLjyxuixx/eg8wlv2K6+Tu25bxT9c8WmJEYKA9Kd5I 5htI7A/rQB7QITMOgp6FnlQWXxhWMTkH+ohUHYaefALlKIqVov+BqT7M/ JDrXepufsfjWw5lIs9GCa8dwb0i9nP1zQY6m8+2AO6gm94fcQLzCQj7aj NfbsWIw9nD/JUozHzKwWhh81qg63p7+1jHaRHKv9oFgMVnWL0lCVmMJVA 9nDXxqG4oeniIxJZD1U6PViS7/ah2LhWO3fzu7ZtUmcEHMOg7jv5I+UE1 0CkC9UtbS8r2cgWsCs3awk9gCaMvaKnxPW+jxnA++Rlt6fDrYYt0tebb0 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="306394437" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="306394437" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 05:59:44 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="634217702" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="634217702" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.30.4]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 05:59:42 -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 V2 5/6] OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol Date: Mon, 9 Jan 2023 21:59:16 +0800 Message-Id: <20230109135917.1752-6-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20230109135917.1752-1-min.m.xu@intel.com> References: <20230109135917.1752-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 | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c index f27a95957f47..14ae13055a30 100644 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c +++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c @@ -1249,6 +1249,20 @@ InstallQemuFwCfgTables ( } } + // + // Install a protocol to notify that the ACPI table provided by Qemu is + // ready. + // + 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 @@ -1257,7 +1271,7 @@ InstallQemuFwCfgTables ( if (S3Context != NULL) { Status = TransferS3ContextToBootScript (S3Context); if (EFI_ERROR (Status)) { - goto UninstallAcpiTables; + goto UninstallQemuAcpiTableNotifyProtocol; } // @@ -1268,6 +1282,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)) { // @@ -1277,17 +1300,6 @@ UninstallAcpiTables: --Installed; AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]); } - } else { - // - // Install a protocol to notify that the ACPI table provided by Qemu is - // ready. - // - gBS->InstallProtocolInterface ( - &QemuAcpiHandle, - &gQemuAcpiTableNotifyProtocolGuid, - EFI_NATIVE_INTERFACE, - NULL - ); } for (SeenPointerEntry = OrderedCollectionMin (SeenPointers); -- 2.29.2.windows.2