From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 920FD1A1E1B for ; Wed, 5 Oct 2016 13:48:03 -0700 (PDT) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 139EDC0528A1; Wed, 5 Oct 2016 20:48:03 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-104.phx2.redhat.com [10.3.116.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u95Km0o1006132; Wed, 5 Oct 2016 16:48:01 -0400 To: "Shah, Tapan" , Andrew Fish , Daniil Egranov References: <93F01BC9-4B02-467E-B900-65C6775BB0F3@apple.com> <618fd786-24d4-653c-d6b8-cb774654c644@redhat.com> Cc: "Carsey, Jaben" , edk2-devel-01 , Leif Lindholm From: Laszlo Ersek Message-ID: <80225187-8a2c-19fa-80e2-d86a6f18bf66@redhat.com> Date: Wed, 5 Oct 2016 22:48:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 05 Oct 2016 20:48:03 +0000 (UTC) Subject: Re: Assert in ShellPkg with latest tianocore edk2 source on the Reference Platform X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 20:48:03 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 10/05/16 22:24, Shah, Tapan wrote: > How about moving protocol locate from constructor to the actual function level and returning an error if it fails to locate (See attached patch file). What function is that precisely? The hunk headers in the patch don't show. If it is a function that is part of some file operation, then, although the patch is an improvement because the shell won't ASSERT(), it's still not perfect, because lack of the protocol will break that file operation completely. ... The containing function seems to be ShellOpenFileByName(). Seems like a quite central function to render inoperable if the collation protocol is not present. Actually, I'm quite confused about conformance to specific versions of the UEFI spec. In UEFI v2.6, section "2.6.2 Platform-Specific Elements", point 5, we have If a platform includes the ability to boot from a disk device, then the EFI_BLOCK_IO_PROTOCOL, the EFI_DISK_IO_PROTOCOL, the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, and the EFI_UNICODE_COLLATION_PROTOCOL are required. In fact this requirement goes back to UEFI v2.3.1c at least. (I didn't bother to check earlier releases of the spec.) By depending on the protocol in the shell, we say that the current upstream shell is not required to open files by name on pre-v2.3.1c systems (or perhaps on systems older than v2.3.1c), and on systems that cannot boot from a disk device. Is this something we can say? How is this kind of compatibility tracked in edk2? Thanks Laszlo > > Tapan > > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Wednesday, October 05, 2016 3:18 PM > To: Andrew Fish ; Daniil Egranov > Cc: Carsey, Jaben ; edk2-devel-01 ; Leif Lindholm ; Shah, Tapan > Subject: Re: [edk2] Assert in ShellPkg with latest tianocore edk2 source on the Reference Platform > > On 10/05/16 21:48, Andrew Fish wrote: >> > >>> >> On Oct 5, 2016, at 12:24 PM, Daniil Egranov wrote: >>> >> >>> >> I have the same ASSERT issue on Juno platform even the EnglishDxe.inf is included to the platform build. If UefiShellLib has such dependency on the protocol then according to EDKII Module Writer's Guide you need to specify the dependency on protocol in the module .inf to ensure the drivers proper load sequence. >>> >> >>> >> 8.6 Dependency Expressions >>> >> A dependency expression specifies the protocols that the DXE driver >>> >> requires to execute. In EDK II, it is specified in the [Depex] section of INF file. >>> >> >> > >> > The Dependency Expression is for DXE Drivers that are dispatched by the DXE Core. A UEFI Driver from an option ROM or an Application does not get dispatched by the dispatch and the Depex will not help. The Depex ends up being a section in the FV and it has nothing to do with the PE/COFF image of the an application or option ROM. >> > >> > IMHO the shell should try as hard as possible to function and should not ASSERT if some newer Protocol is missing. > (Background: commit 583448b441650.) > > In this specific case, the protocol dependency seems possible to eliminate: > > - Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c > includes the CharToUpper() function, which is minimal -- could even be copied or moved over -- and can translate the ASCII subset of UCS-2, > > - once the ASCII characters of the input string have been translated to upper case, the result could be searched for / compared against L"NULL" > using BaseLib.h APIs. > > (Given that L"NULL" only contains characters from the ASCII subset, it suffices to upper-case ASCII chars in the input string. No non-ASCII character in the BMP can translate to ASCII N/U/L via upcasing, even with the real collation protocol (I trust), and no other ASCII characters than n/u/l will translate to N/U/L. This means that we won't miss an instance of NULL because we didn't upcate it (because it was non-ascii), and it also means we won't mistakenly match something non-NULL as NULL.) > > Just my two cents. > > Laszlo > > > uefishelllib_fix.diff > > > Index: ShellPkg/Library/UefiShellLib/UefiShellLib.c > =================================================================== > --- ShellPkg/Library/UefiShellLib/UefiShellLib.c (revision 22692) > +++ ShellPkg/Library/UefiShellLib/UefiShellLib.c (working copy) > @@ -292,8 +292,6 @@ > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - EFI_STATUS Status; > - > mEfiShellEnvironment2 = NULL; > gEfiShellProtocol = NULL; > gEfiShellParametersProtocol = NULL; > @@ -300,11 +298,6 @@ > mEfiShellInterface = NULL; > mEfiShellEnvironment2Handle = NULL; > > - if (mUnicodeCollationProtocol == NULL) { > - Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); > - ASSERT_EFI_ERROR (Status); > - } > - > // > // verify that auto initialize is not set false > // > @@ -730,6 +723,14 @@ > FileHandle, > OpenMode); > > + if (mUnicodeCollationProtocol == NULL) { > + Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); > + if (EFI_ERROR (Status)) { > + gEfiShellProtocol->CloseFile (*FileHandle); > + return Status; > + } > + } > + > if ((mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NUL") != 0) && > (mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NULL") != 0) && > !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){ >