From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1BDFD22497F20 for ; Mon, 16 Apr 2018 12:41:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5CB35EB6E1; Mon, 16 Apr 2018 19:41:08 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-213.rdu2.redhat.com [10.10.120.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id E102D2026609; Mon, 16 Apr 2018 19:41:06 +0000 (UTC) To: Ard Biesheuvel , Marcin Wojtas Cc: Hua Jing , Grzegorz Jaszczyk , "edk2-devel@lists.01.org" , Leif Lindholm , Nadav Haklai , Neta Zur Hershkovits References: <1523855353-9262-1-git-send-email-mw@semihalf.com> <1523855353-9262-2-git-send-email-mw@semihalf.com> From: Laszlo Ersek Message-ID: <487cbdc8-72f7-e990-f53b-354c88370ba8@redhat.com> Date: Mon, 16 Apr 2018 21:41:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Apr 2018 19:41:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Apr 2018 19:41:08 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [platforms PATCH 1/2] Marvell/Drivers: MvFvbDxe: Adjust to new dependencies X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2018 19:41:09 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 04/16/18 07:40, Ard Biesheuvel wrote: > (+ Laszlo) > > On 16 April 2018 at 07:09, Marcin Wojtas wrote: >> Recent changes in the EDK2 mainline resulted in breaking >> of compilation and booting of Armada platforms. >> This patch adjust the MvFvbDxe driver by: >> >> * installation of gEdkiiNvVarStoreFormattedGuid in order to signal >> NvVarStoreFormattedLib to the generic variable runtime driver >> > > Hello Marcin, > > Installing this GUID is only necessary if you update your platform > .DSC to make the generic variable runtime driver depend on it by > adding a NULL library class resolution using NvVarStoreFormattedLib. > So I think this patch is correct, but you'll need an additional change > to make it work as expected. (Otherwise, the variable runtime driver > could still be dispatched early and invoked for read access before the > variable store is reformatted) I agree. I'd also like to point out another frequent pitfall in this patch: >> * making explicit dependency to ArmPkg/Drivers/CpuDxe drivers in order >> to enable successful calling of gDS->SetMemorySpaceAttributes >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Marcin Wojtas >> --- >> Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c | 21 ++++++++++++++++++++ >> Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.inf | 7 ++----- >> 2 files changed, 23 insertions(+), 5 deletions(-) >> >> diff --git a/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c b/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c >> index 252ef67..6e583a3 100644 >> --- a/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c >> +++ b/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c >> @@ -26,6 +26,7 @@ >> #include >> #include >> >> +#include >> #include >> #include >> >> @@ -1076,6 +1077,21 @@ MvFvbEntryPoint ( >> } >> >> // >> + // The driver implementing the variable read service can now be dispatched; >> + // the varstore headers are in place. >> + // >> + Status = gBS->InstallProtocolInterface (&gImageHandle, >> + &gEdkiiNvVarStoreFormattedGuid, >> + EFI_NATIVE_INTERFACE, >> + NULL); >> + if (EFI_ERROR (Status)) { >> + DEBUG ((DEBUG_ERROR, >> + "%a: Failed to install gEdkiiNvVarStoreFormattedGuid\n", >> + __FUNCTION__)); >> + goto ErrorInstallNvVarStoreFormatted; >> + } >> + >> + // >> // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME >> // >> RuntimeMmioRegionSize = mFvbDevice->FvbSize; >> @@ -1126,6 +1142,11 @@ ErrorSetMemAttr: >> gDS->RemoveMemorySpace (RegionBaseAddress, RuntimeMmioRegionSize); >> >> ErrorAddSpace: >> + gBS->UninstallProtocolInterface (&gImageHandle, >> + &gEdkiiNvVarStoreFormattedGuid, >> + NULL); >> + While gBS->InstallProtocolInterface() takes a *pointer* to a handle (because it can *create* a handle, if the handle is NULL on input, and the first protocol interface is installed on it), gBS->UninstallProtocolInterface() takes the handle *itself*. If the last protocol interface is uninstalled from the handle, then the handle is destroyed, but gBS->UninstallProtocolInterface() does not attempt to NULL the handle itself. So, here you should pass "gImageHandle", not "&gImageHandle". There's also a bit of whitespace mangling here that's not compatible with either multiline function call style that we like in edk2, but perhaps edk2-platforms treats that more laxly. Thanks Laszlo >> +ErrorInstallNvVarStoreFormatted: >> gBS->UninstallMultipleProtocolInterfaces (&mFvbDevice->Handle, >> &gEfiDevicePathProtocolGuid, >> &gEfiFirmwareVolumeBlockProtocolGuid, >> diff --git a/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.inf b/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.inf >> index 117fe8b..fd3f2f7 100644 >> --- a/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.inf >> +++ b/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.inf >> @@ -63,6 +63,7 @@ >> UefiRuntimeServicesTableLib >> >> [Guids] >> + gEdkiiNvVarStoreFormattedGuid >> gEfiAuthenticatedVariableGuid >> gEfiEventVirtualAddressChangeGuid >> gEfiSystemNvDataFvGuid >> @@ -84,8 +85,4 @@ >> gMarvellTokenSpaceGuid.PcdSpiMemoryBase >> >> [Depex] >> - # >> - # MvFvbDxe must be loaded before VariableRuntimeDxe in case empty >> - # flash needs populating with default values. >> - # >> - BEFORE gVariableRuntimeDxeFileGuid >> + gEfiCpuArchProtocolGuid >> -- >> 2.7.4 >> > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >