From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.29401.1673456014830773106 for ; Wed, 11 Jan 2023 08:53:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D0Ck62LU; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673456014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GfY1czxzqvmxD+u4rAUeXLdDmRBqhUg08TIqU7AaIAg=; b=D0Ck62LUPRukP/3ruQN69CUFy0OEbrwkEgBORagesz3AsmTjDkHjn6MCQjdCl4cNpspG+O uYfzcxw0u9MaJnvciVdtJGr/qoFh/Pk1ODU64qK5swH/fBWZQeYrkuL5YQhywftDgdkccn lhy+cy5n6qRKxt50seXc19TaA3BndCk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-7sigKbvYNNiL1O2_ChrMog-1; Wed, 11 Jan 2023 11:53:33 -0500 X-MC-Unique: 7sigKbvYNNiL1O2_ChrMog-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3794985D06C; Wed, 11 Jan 2023 16:53:32 +0000 (UTC) Received: from [10.39.192.40] (unknown [10.39.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F044D492C14; Wed, 11 Jan 2023 16:53:30 +0000 (UTC) Message-ID: Date: Wed, 11 Jan 2023 17:53:29 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH V3 5/6] OvmfPkg/AcpiPlatformDxe: Refactor QemuAcpiTableNotifyProtocol To: devel@edk2.groups.io, min.m.xu@intel.com Cc: Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky References: <20230111012235.189-1-min.m.xu@intel.com> <20230111012235.189-6-min.m.xu@intel.com> From: "Laszlo Ersek" In-Reply-To: <20230111012235.189-6-min.m.xu@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/11/23 02:22, Min Xu wrote: > 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); Reviewed-by: Laszlo Ersek