From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53C17C48BDF for ; Thu, 10 Jun 2021 21:02:55 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0FDB56100A for ; Thu, 10 Jun 2021 21:02:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FDB56100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A41FA82B71; Thu, 10 Jun 2021 23:02:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="bsNmuR+k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5EB2B82CBE; Thu, 10 Jun 2021 23:02:50 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12F3282052 for ; Thu, 10 Jun 2021 23:02:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1623358965; bh=mkt5Sis/5LDXeV10duvzM61xItt10d1DYFUyLj/w3FI=; h=X-UI-Sender-Class:Subject:From:To:Cc:References:Date:In-Reply-To; b=bsNmuR+k4tZ68zj+lCxiAaMcetPrAs9/zRR4/ku1jzEvg/W9a2dgm8vEs6rpN7eIZ p/iPgl13JvxWvx2R3RZEYGcgN8hPE/IILbUhpUB19gczoqAvu3Pe+7osxmPRR5RFaE nV86zHnJ+6MJDEv7SfE3G5fWZLcLtGe/nd36D/dA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([62.143.247.63]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MMofW-1lasLJ2oIm-00IoEM; Thu, 10 Jun 2021 23:02:45 +0200 Subject: Re: BISECTED f3866909e350 ("distro_bootcmd: call EFI bootmgr even without having /EFI/boot") From: Heinrich Schuchardt To: "Matwey V. Kornilov" Cc: michael@walle.cc, U-Boot Mailing List References: <5e1f6595-3371-8d56-ebfa-916d10b5aad4@gmx.de> <8d847043-ab5d-a627-ed71-5f8829bcad8c@gmx.de> <6683bdcc-d83b-de80-b0b2-4d0b8df268f0@gmx.de> Message-ID: <2597f573-2d7c-3390-8260-c9856944f102@gmx.de> Date: Thu, 10 Jun 2021 23:02:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:NqiGahn7HfXrWsJp54OaAdzuDdmy9PeMmTTpWwz3ViZRm2AD4pB WQejhxMyLMFvjjLmBiqK+prCFShiloeL3Z+nUJ7bvtuLs4wQE79MFAs0I3Y7D5slE2BjFjo 0jfMR1QL51swiRD6EjCRS/mfM509o2OGP5zsbGdHgMXzg4Q12sAWJ8J8Z32CBtHVehHGid4 aDg5BWgzSUP3Lv8FcDxBw== X-UI-Out-Filterresults: notjunk:1;V03:K0:3HiVH2iD+vQ=:jUu4AHyc8D7peMWEzUfoBC BnZ3B/UKcAeRmSPQ1gm/BOBr584iIRqYy0vPB/IOJhwQiv2P7Ed8COzLQjvR5sroS620U6a7u kgEISe0Czh1wJd5DRiByJ4Y4hebHuoxq1afpBBFsdbzcsvmbrOgv6fMmaEKJayMX4lNwSeAK3 ol8QxvJtDNcIugHkfQY/nYVUKwDlRrYFtrN+knQl+AEYJEX8dusSUagxUDDhQmHYBn0BpDjGY ZzTsB01uXR6td5qGRZQGoKE5JrvE0u/zufxayjjc2uBtu8yQCw9FB2VKTznH2W0SEWnz7vU5M 24g9lh6gqkvqJqHsiifUnhV0VZ9uBkgZSWaz6sam8jvRlQKYTLHAIPG8jksfhL8zd8elM4xQc jsY1N9SaUAOXv4bJ2H1iYFYHPUHuuP4W8VumyDR9h5c1acDMUt/tt8VeeJUqC0MoJyrv2cUMK 5wHa3l+t7fT300c8MH81sYYiL/7Dmvfses+QH4M7CVlBFqNQ/ZgG+7C/mbvvTP3LIzTHWOggm 4lCirBrF9aGDG4KPFGVZyZ4Rj4l+vGN3e0sA/IIjBVgcu5q0m3RqZLMOL8rVfh7hbhXws1ELY ACsDlxJtCtEGcxDM4Tg9keFKhtJtSuivvBlg9gB/XcsHE/7/kFDFMc5G0uBGfSg/UzIZpjskg U/NEhKwMUijfRfHNFywEXfrBGNE7Gnqqn1eQqMt49+8pH+dPw992AIww2nhG554Hz6I7lC0TJ 07AleLfmMrRxMxEvvGQvxdmJBvYSCUl4OLowrgoaVqty7S/wNm/oCkQTjFMYIb7h+rqg5Ggj7 D1GuPbjpeKXtGALbSt00BehIhmidWsfJaf1ZwnZe6WpKAW0aunGTQ5y5D3ssjbz8EvGpiR2Az 8wsuwqZnZDQmSlwt/y4yTCOKjky7p1TV2Mbv/G3mfqnC314/oYBRi8fzsFod44ey1YynCv3RI n5RjT0Ohe6UoX82Y8WDpCzGvI95wlDRxDghPTHmVoyd0AHLPwPrqy2tAFwwOE28lFilUYSBie AwYpuYMyT0E3mCDeRMnrrbU4YERUzK3/dintesUqwZ+gcnoq6i5884SAXR7UBVhE8cK5AouVK B2vJnn/PrE9lXtrmq2n5k5irKqLydoq5DG7 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean On 6/10/21 10:05 PM, Heinrich Schuchardt wrote: > On 6/7/21 7:51 PM, Matwey V. Kornilov wrote: >> =D0=B2=D1=81, 6 =D0=B8=D1=8E=D0=BD. 2021 =D0=B3. =D0=B2 19:47, Heinrich= Schuchardt : >>> >>> On 6/6/21 6:21 PM, Heinrich Schuchardt wrote: >>>> On 6/6/21 5:42 PM, Matwey V. Kornilov wrote: >>>>> =D0=B2=D1=81, 6 =D0=B8=D1=8E=D0=BD. 2021 =D0=B3. =D0=B2 18:20, Heinr= ich Schuchardt : >>>>>> >>>>>> On 6/6/21 4:37 PM, Matwey V. Kornilov wrote: >>>>>>> Hi, >>>>>>> >>>>>>> I've found that >>>>>>> >>>>>>> f3866909e350 ("distro_bootcmd: call EFI bootmgr even without havin= g >>>>>>> /EFI/boot") >>>>>>> >>>>>>> breaks running EFI application from USB device on BeagleBone Black >>>>>>> (am335x) device. >>>>>>> >>>>>>> With this patch I see the following: >>>>>>> >>>>>>> Booting /efi\boot\bootarm.efi >>>>>>> Welcome to GRUB! >>>>>>> >>>>>>> data abort >>>>>>> pc : [<9ce0b6d0>]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 lr : [<9ffab7c7>] >>>>>>> reloc pc : [<7d69d6d0>]=C2=A0=C2=A0=C2=A0 lr : [<8083d7c7>] >>>>>>> sp : 9df44e28=C2=A0 ip : 9ffdfe90=C2=A0=C2=A0=C2=A0=C2=A0 fp : 000= 00003 >>>>>>> r10: 9ffe3300=C2=A0 r9 : 00000000=C2=A0=C2=A0=C2=A0=C2=A0 r8 : 9df= 6fe88 >>>>>>> r7 : 00000000=C2=A0 r6 : 9ce5da08=C2=A0=C2=A0=C2=A0=C2=A0 r5 : 9ce= 571f8=C2=A0 r4 : 9ce2c040 >>>>>>> r3 : 00000000=C2=A0 r2 : 00000001=C2=A0=C2=A0=C2=A0=C2=A0 r1 : 9ce= 56598=C2=A0 r0 : 00000000 >>>>>>> Flags: NzCv=C2=A0 IRQs off=C2=A0 FIQs on=C2=A0 Mode SVC_32 >>>>>>> Code: e3500000 0a000015 e590000c eb00f96e (e5d03000) >>>>>> =C2=A0=C2=A0 > UEFI image [0x9ce46000:0x9cf28fff] '/efi\boot\bootar= m.efi' >>>>>> =C2=A0=C2=A0 > Resetting CPU ... >>>>>> >>>>>> Hello Matwey, >>>>>> >>>>>> thank you for reporting the issue. >>>>>> >>>>>> $ echo 'Code: e3500000 0a000015 e590000c eb00f96e (e5d03000)' | >>>>>> CROSS_COMPILE=3Darm-linux-gnueabihf- ARCH=3Darm scripts/decodecode >>>>>> >>>>>> Code: e3500000 0a000015 e590000c eb00f96e (e5d03000) >>>>>> All code >>>>>> =3D=3D=3D=3D=3D=3D=3D=3D >>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0:=C2=A0=C2=A0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>>>>>> Looking at the disassembly above we see that reading memory locatio= n >>>>>> NULL fails. >>>>>> >>>>>> We need to find out where the exception occurs. The code position i= s >>>>>> neither in bootarm.efi nor in U-Boot (9ce0b6d0 is lower than the lo= ad >>>>>> position of bootarm.efi, so it is below the relocated U-Boot code). >>>>>> >>>>>> Please, add the following line at the start of grub.cfg to get more >>>>>> output from GRUB: >>>>>> >>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 debug=3Dall >>>>> >>>>> This doesn't provide any additional output from GRUB :( >>>>> >>>>>> >>>>>> When building U-Boot, please, add >>>>>> >>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #define DEBU= G 1 >>>>>> >>>>>> in lib/efi_loader/efi_disk.c and lib/efi_loader_file.c a line befor= e >>>>>> #include . >>>>> >>>>> >>>>> This doesn't provide much output as well: >>>>> >>>>> Scanning disk mmc@48060000.blk... >>>>> EFI: Call: efi_install_multiple_protocol_interfaces( &handle, >>>>> &efi_guid_device_path, diskobj->dp, &efi_block_io_guid, &diskobj->op= s, >>>>> NULL) >>>>> EFI: 0 returned by efi_install_multiple_protocol_interfaces( &handle= , >>>>> &efi_guid_device_path, diskobj->dp, &efi_block_io_guid, &diskobj->op= s, >>>>> NULL) >>>>> ** Unrecognized filesystem type ** >>>>> Scanning disk mmc@481d8000.blk... >>>>> EFI: Call: efi_install_multiple_protocol_interfaces( &handle, >>>>> &efi_guid_device_path, diskobj->dp, &efi_block_io_guid, &diskobj->op= s, >>>>> NULL) >>>>> EFI: 0 returned by efi_install_multiple_protocol_interfaces( &handle= , >>>>> &efi_guid_device_path, diskobj->dp, &efi_block_io_guid, &diskobj->op= s, >>>>> NULL) >>>>> EFI: Call: efi_install_multiple_protocol_interfaces( &handle, >>>>> &efi_guid_device_path, diskobj->dp, &efi_block_io_guid, &diskobj->op= s, >>>>> NULL) >>>>> EFI: 0 returned by efi_install_multiple_protocol_interfaces( &handle= , >>>>> &efi_guid_device_path, diskobj->dp, &efi_block_io_guid, &diskobj->op= s, >>>>> NULL) >>>>> Found 3 disks >>>> >>>> This implies that GRUB is crashing before even accessing the file >>>> system >>>> (including grub.cfg). >>>> >>>> On an OrangePi PC I deleted /boot.scr and moved grubarm.efi to >>>> /EFI/boot/bootarm.efi. It boots without problem. >>>> >>>> What version of GRUB are you using? >>>> How were you booting before updating U-Boot? >>>> What version of U-Boot are you using where the error occurs? >>>> Why do you have grub in /EFI/boot/bootarm.efi and not in a distro >>>> specific path, e.g. /EFI/debian/grubarm.efi? /EFI/boot is typically >>>> only >>>> used by installers. >>>> >>>> If the boot manager is started by distroboot it may not have an >>>> appropriate device path. It tries to load the file given by environme= nt >>>> variable $fdtfile from the boot device. >>>> >>>> =C2=A0 From the U-Boot console could you, please, try: >>>> >>>> 1) >>>> load usb 0:1 $kernel_addr_r EFI/boot/bootarm.efi >>>> bootefi bootmgr >>>> >>>> >>>> 2) >>>> load usb 0:1 $kernel_addr_r EFI/boot/bootarm.efi >>>> load usb 0:2 $fdt_addr_r dtb >>>> bootefi bootmgr $fdt_addr_r >>>> >>>> where you need to replace dtb by the correct device tree file and >>>> adjust >>>> the partition numbers. >>>> >>>> Best regards >>>> >>>> Heinrich >>> >>> To catch the earlier EFI API calls you can add >>> >>> #define DEBUG 1 >>> >>> to lib/efi_loader/efi_boottime.c >> >> >> Welcome to GRUB! >> >> =C2=A0=C2=A0=C2=A0=C2=A0 EFI: Entry efi_locate_handle_ext(2, >> 9042a9de-23dc-4a38-96fb-7aded080516a, 00000000, 9df40dfc, 9ce2d660) > > EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID > > This call could be from grub-core/video/efi_gop.c, check_protocol(). > >> =C2=A0=C2=A0=C2=A0=C2=A0 EFI: Exit: efi_locate_handle_ext: 14 > > EFI_NOT_FOUND > >> =C2=A0=C2=A0=C2=A0=C2=A0 EFI: Entry efi_open_protocol(9df5f298, >> 5b1b31a1-9562-11d2-8e3f-00a0c969723b, 9df40e14, 9df5f298, 00000000, >> 0x2) > > EFI_LOADED_IMAGE_PROTOCOL_GUID > > This call could be from grub-core/kern/efi/efi.c, > grub_efi_get_loaded_image(). > >> =C2=A0=C2=A0=C2=A0=C2=A0 EFI: Exit: efi_open_protocol: 0 >> =C2=A0=C2=A0=C2=A0=C2=A0 EFI: Entry efi_open_protocol(00000000, > > The parameter @handle must not be NULL. > >> 09576e91-6d3f-11d2-8e39-00a0c969723b, 9df40e14, 9df5f298, 00000000, > > EFI_DEVICE_PATH_PROTOCOL_GUID > > This could be called from grub-core/kern/efi/efi.c, > grub_efi_get_device_path() which is invoked from > grub_machine_get_bootlocation(). > >> 0x2) > > EFI_INVALID_PARAMETER is returned because the handle is NULL. > > I could partially reproduce the problem by setting > > =C2=A0 info->device_handle =3D NULL; > > at the end of efi_setup_loaded_image(): > > Welcome to GRUB! > > =C2=A0=C2=A0 EFI: Entry efi_open_protocol(79fdea40, > 5b1b31a1-9562-11d2-8e3f-00a0c969723b, 79f570e4, 79fdea40, 00000000, 0x2) > =C2=A0=C2=A0 EFI: Exit: efi_open_protocol: 0 > =C2=A0=C2=A0 EFI: Entry efi_open_protocol(00000000, > 09576e91-6d3f-11d2-8e39-00a0c969723b, 79f570b4, 79fdea40, 00000000, 0x2) > =C2=A0=C2=A0 EFI: Exit: efi_open_protocol: 2 > error: disk `,msdos2' not found. > grub rescue> > > > This leaves me with two questions: > > Why does GRUB not handle > > =C2=A0=C2=A0 *device =3D grub_efidisk_get_device_name (NULL); > > gracefully? Maybe it is because it tries to print via the graphical > output protocol which does not exist? You wrote that you are using Suse JeOS. In grub.cfg you could replace with_gfx=3D1 gfxmode=3Dauto by with_gfx=3D0 set textmode=3Dtrue This should give you output on the serial console and avoid the crash. Best regards Heinrich > > Why is image->device_handle NULL? > > Next step is to verify that image->device_handle is really NULL. > > Please apply the following change to efi/efi_loader/efi_boottime.c > > @@ -2060,6 +2069,7 @@ efi_status_t EFIAPI efi_load_image(bool boot_polic= y, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 free(info); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > error: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 printf("*** %p\n", info->device_ha= ndle); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return EFI_EXIT(ret); > } > > Best regards > > Heinrich > >> =C2=A0=C2=A0=C2=A0=C2=A0 EFI: Exit: efi_open_protocol: 2 >> data abort >> pc : [<9ce076d0>]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= lr : [<9ffa85b3>] >> reloc pc : [<7d69d6d0>]=C2=A0=C2=A0=C2=A0 lr : [<8083e5b3>] >> sp : 9df40e28=C2=A0 ip : 00000000=C2=A0=C2=A0=C2=A0=C2=A0 fp : 00000003 >> r10: 9ffe2df8=C2=A0 r9 : 00000000=C2=A0=C2=A0=C2=A0=C2=A0 r8 : 9df5f298 >> r7 : 00000000=C2=A0 r6 : 9ce59a08=C2=A0=C2=A0=C2=A0=C2=A0 r5 : 9ce531f8= =C2=A0 r4 : 9ce28040 >> r3 : 00000000=C2=A0 r2 : 9ffeb328=C2=A0=C2=A0=C2=A0=C2=A0 r1 : 00000000= =C2=A0 r0 : 00000000 >> Flags: NzCv=C2=A0 IRQs off=C2=A0 FIQs on=C2=A0 Mode SVC_32 >> Code: e3500000 0a000015 e590000c eb00f96e (e5d03000) >> UEFI image [0x9ce42000:0x9cf24fff] '/efi\boot\bootarm.efi' >> Resetting CPU ... >> >> >>> >>> Best regards >>> >>> Heinrich >>> >>> >> >> > >