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=-5.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 BFFFCC4338F for ; Fri, 30 Jul 2021 06:22:35 +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 14BD960F4B for ; Fri, 30 Jul 2021 06:22:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 14BD960F4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 435DC831E3; Fri, 30 Jul 2021 08:22:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com 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; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="Ouo4z/fC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 88D9A831EB; Fri, 30 Jul 2021 08:22:30 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::62c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1FB4483134 for ; Fri, 30 Jul 2021 08:22:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michals@xilinx.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hpXJyGdphyEeViSgoM2QjM4T2HPrqU4vRBInl9daddig4BvKQI04w6+fRYi/fd7n7EosCIkSHrhDgIwzKpBsq+IFN52GgKOMgw8DHeBYDwCRz+EpRbTZJXvn12rnjQ+/kKCOQvsu2Ce5s+vZUNHPyZxm4wI/wR9V230UWv7/nuxTP8V81Zht0wVLjxM3EYxOg27ifmLla/9cD+/7WeY5DuYJOScUFCOYE80lmt+Ag+diA0AGMgCPQZYKKwWCCjM+WO5gvDrNEBubWlH0ht8yjz+999tmgZCbgKcBmNnyhbbNsAB7mnAU3oTfE0+wR2Om+J52M4wF+WzDou65zE/Svw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9E/wieolp5FXfYb4QeSaHUmg4OwS859ynXOqXLRUOnE=; b=Rns4ev6UOPr+UY4ratyIt0PU2nhj1HTXgaNe4KfDWX9aWQf1u1OwpPjmgETwcBeyHJX8FXNkQfdjEHmrOuJ+I2CxDQ5eJWiqjRaaf4BdMNdAb23ClBGoSPM6ji6u5bVGLIjU/Vld8jc/2erGOLVUdw/Ci4NMuzsjWwvNXrSY13s/L1aWwX+NlrI9wXHBJsLLy6N0O7kiNSivsXf24Sye24ytrCJK+dkntcScxzaTxj6cQPcH+ciu4srv3kEhqydkI3686GxUb2tEvvAZ7b1Ivu8crq3BY1iN84glX+Py0RlQXqwbm/lGZcDPnMDG/HkoKisAFqvAcv5oDtLncB7idg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=arm.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9E/wieolp5FXfYb4QeSaHUmg4OwS859ynXOqXLRUOnE=; b=Ouo4z/fC3MYyn1GdOk+hdv5w1otevgyzoroc6UWnNxcxSu0G8VhsR8AD+z1cPbFbx+O1VO5m4Qt/O7TD/9virhfFvEqNkjdeYEvSsJeDRhyysFipjzak/VJdGdyb8rAis7k2mmr1wanuUJCaRB1E/bAIcrlKrLQ3n0rAwRKHFbQ= Received: from DM6PR02CA0092.namprd02.prod.outlook.com (2603:10b6:5:1f4::33) by BN7PR02MB4132.namprd02.prod.outlook.com (2603:10b6:406:fb::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Fri, 30 Jul 2021 06:22:21 +0000 Received: from DM3NAM02FT063.eop-nam02.prod.protection.outlook.com (2603:10b6:5:1f4:cafe::af) by DM6PR02CA0092.outlook.office365.com (2603:10b6:5:1f4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Fri, 30 Jul 2021 06:22:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT063.mail.protection.outlook.com (10.13.5.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4373.18 via Frontend Transport; Fri, 30 Jul 2021 06:22:21 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 29 Jul 2021 23:22:21 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Thu, 29 Jul 2021 23:22:21 -0700 Envelope-to: Vincent.Stehle@arm.com, sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de, sughosh.ganu@linaro.org, xypron.glpk@gmx.de, takahiro.akashi@linaro.org Received: from [172.30.17.109] (port=56502) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1m9LuW-0000vR-Pd; Thu, 29 Jul 2021 23:22:21 -0700 Subject: Re: EFI from usb HDD To: AKASHI Takahiro , Michal Simek , Heinrich Schuchardt , Sughosh Ganu , U-Boot Mailing List , Ilias Apalodimas , Simon Glass , Vincent Stehle References: <9c57a3c7-e609-91e8-cf33-5637ce4f9340@xilinx.com> <20210610125915.GA96492@laputa> <6d4a2a7e-a295-f3e1-1ad8-445f40df334e@xilinx.com> <20210730023507.GA150924@laputa> <20210730053344.GB150924@laputa> From: Michal Simek Message-ID: <65818adc-728c-8a84-973d-0333e3c6e8b2@xilinx.com> Date: Fri, 30 Jul 2021 08:22:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210730053344.GB150924@laputa> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53e36e86-e189-47c4-ba52-08d9532263c9 X-MS-TrafficTypeDiagnostic: BN7PR02MB4132: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PZtRliPVkWcBLg0T/R+20FaNly+Hx7ChsfM6OIIBC3eKklJc02GI1/xLnTY3wZ/JbevewHjpR28jS508n3+dDF0LDr51vXXEw9hzcsOGADhgd93/GWl7ROjkfCYJd7zL/vGS50TLvtrYMTLSXQWLJz/Mv+9AcEKYTiVvLIsokQFHFn7GHftHA4sDZ6gc76JjAVAxMECslw9kTQf8fVCzI/MExTRDpI5nEWRsmOdZrXTPtKnBcJiSpYYyh2QcC+JFXRF7i14QFWUNbqj/i3VfliQkZDrbx7Z6g7yoFUujuC0ZtCYW5DRa8s2CDxY0v9QBr8OgVwqHkWmspwKAAFv+Nslid+h0botSj/jXapPUNkQAFLmyySrprwl+PbYCxN3Ey2yjIvC50qi4wLUPNsnZIugyJAJG+3DrJvQ3mecJS3BKBmnQq9oqGPLhn6tf+Ilt/0t8pKjVE5KF0iBExY2ERahTgLzWf/wgoXtRcjQpq97/fFBXRXvEk2TkOHFaLgvjR7ntnEjtAo8bbyTJvhoud4bQIpYqi6n62Nq55wz68nJUF/LwQ05qpCFUlHUj8OBQ/isjOkEOEMwFEXB5rS6sxKXu8IsY4or0B9p9YiOKYXXH7OIzd/1iup1Pn3FTCkQbulOIvm30ftDNYvGDDQuCSHxwsEY2h5wnWftTno88Jb7K3sJfQGwTVoKAogQeNP0QxlPlu34T/M2Soi/u5132Jnrj8HBWDpz20TmbdmyOgYSWVoiD6rgTWud93FXtaODmpu4b+yhOkb3V1BNxDmncmeRobzh9xjlh+dCfP9o/NCbem7pZ0MDff5EkfvtSEJ6HWR2q01ReVq6vmjEB+OTJluECYVPVS1Y2G23MBIRNWb1NSIi/Jl4BFxdkqr8GHOxk X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(136003)(346002)(376002)(396003)(39860400002)(46966006)(36840700001)(31686004)(2616005)(5660300002)(316002)(356005)(82310400003)(26005)(82740400003)(110136005)(31696002)(53546011)(36906005)(83380400001)(966005)(186003)(36860700001)(8676002)(44832011)(45080400002)(336012)(47076005)(70586007)(9786002)(70206006)(426003)(6666004)(36756003)(2906002)(478600001)(8936002)(7636003)(3480700007)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2021 06:22:21.6884 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53e36e86-e189-47c4-ba52-08d9532263c9 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT063.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR02MB4132 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.103.2 at phobos.denx.de X-Virus-Status: Clean On 7/30/21 7:33 AM, AKASHI Takahiro wrote: > On Fri, Jul 30, 2021 at 06:41:01AM +0200, Michal Simek wrote: >> >> >> On 7/30/21 4:35 AM, AKASHI Takahiro wrote: >>> On Thu, Jul 29, 2021 at 04:09:32PM +0200, Michal Simek wrote: >>>> Hi, >>>> >>>> On 6/10/21 2:59 PM, AKASHI Takahiro wrote: >>>>> On Thu, Jun 10, 2021 at 02:31:46PM +0200, Michal Simek wrote: >>>>>> >>>>>> >>>>>> On 6/10/21 12:51 PM, Heinrich Schuchardt wrote: >>>>>>> On 6/10/21 12:04 PM, Michal Simek wrote: >>>>>>>> Hi, >>>>>>>> >>>>>>>> On 6/10/21 11:47 AM, Heinrich Schuchardt wrote: >>>>>>>>> On 6/10/21 10:44 AM, Michal Simek wrote: >>>>>>>>>> Hi, >>>>>>>>>> >>>>>>>>>> I am playing with booting from USB via EFI. And I see very weird >>>>>>>>>> behavior. I have burnt image with grub to USB flashdisk and I have >>>>>>>>>> tested it on 3 zynqmp boards. zcu102, zcu104 and SOM Kria board. >>>>>>>>>> On zcu102 grub is going to boot menu and everything is working fine as >>>>>>>>>> expected. >>>>>>>>>> On zcu104 and SOM Kria I am able to get grub not to menu. When I list >>>>>>>>>> partitions in grub I see that only SDs are listed: >>>>>>>>>> grub> ls >>>>>>>>>> (hd0) (hd0,msdos1) (hd1) (hd1,msdos1) >>>>>>>>> >>>>>>>>> Hello Michal, >>>>>>>>> >>>>>>>>> thanks for sharing your observations. >>>>>>>>> >>>>>>>>> What devices do hd0 and hd1 relate to? >>>>>>>>> >>>>>>>>>> >>>>>>>>>> On zcu102(working board) I also see usb(gpt) partitions and SD. >>>>>>>>>> grub> ls >>>>>>>>>> (hd0) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,msdos1) >>>>>>>>>> >>>>>>>>> >>>>>>>>> GPT and MBR partitioning are independent of the device type. >>>>>>>>> >>>>>>>>>> >>>>>>>>>> On zcu104 I see one more error message >>>>>>>>>> "PE image measurement failed" >>>>>>>>> >>>>>>>>> This is related to CONFIG_EFI_TCG2_PROTOCOL=y. Do you have a TPMv2? This >>>>>>>>> will not stop disk enumeration. >>>>>>>>> >>>>>>>>>> But I can't see it on SOM. >>>>>>>>>> >>>>>>>>>> U-Boot image is just the same for all boards. I am using generic >>>>>>>>>> xilinx_zynqmp_virt_defconfig. >>>>>>>>>> >>>>>>>>>> When I compare DT description for USB between zcu102 and zcu104 they >>>>>>>>>> are >>>>>>>>>> the same. SOM doesn't have usb enabled by default (but I enabled it) >>>>>>>>>> but >>>>>>>>>> grub starts which means that communication with USB is fine. >>>>>>>>>> >>>>>>>>>> It is based on my latest patches available here. >>>>>>>>>> u-boot/custodians/u-boot-microblaze.git (usb-efi-issue branch) >>>>>>>>>> >>>>>>>>>> Also when I list usb I see all partitions just fine. >>>>>>>>>> ZynqMP> part list usb 0 >>>>>>>>>> >>>>>>>>>> Partition Map for USB device 0  --   Partition Type: EFI >>>>>>>>>> >>>>>>>>>> Part    Start LBA       End LBA         Name >>>>>>>>>>           Attributes >>>>>>>>>>           Type GUID >>>>>>>>>>           Partition GUID >>>>>>>>>>     1     0x00000800      0x001007fe      "Microsoft basic data" >>>>>>>>>>           attrs:  0x0000000000000000 >>>>>>>>>>           type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 >>>>>>>>>>           type:   data >>>>>>>>>>           guid:   0e7f8b3d-296b-4720-be9d-c4687d3c4a77 >>>>>>>>>>     2     0x00100800      0x001197fe      "Microsoft basic data" >>>>>>>>>>           attrs:  0x0000000000000000 >>>>>>>>>>           type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 >>>>>>>>>>           type:   data >>>>>>>>>>           guid:   8892eddc-231a-4e6e-a5e1-c310f4482fb7 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Do you have any idea why on one system is working fine to get to menu >>>>>>>>>> and on others there is an issue to get all partitions even u-boot is >>>>>>>>>> able to see them and can work with them. >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> Michal >>>>>>>>>> >>>>>>>>> >>>>>>>>> Where is the GRUB binary? - If it is in EFI/boot/bootaa64.efi, it could >>>>>>>>> be that the USB sub-system is simply not initialized yet when the boot >>>>>>>>> manager is called by distroboot. >>>>>>>>> >>>>>>>>> For testing partition detection in the UEFI sub-system it is enough >>>>>>>>> to run >>>>>>>>> >>>>>>>>>      efidebug devices >>>>>>>>> >>>>>>>>> Until yesterday we had a problem with partition numbers >= 10, cf. >>>>>>>>> >>>>>>>>> efi_loader: partition numbers are hexadecimal >>>>>>>>> https://source.denx.de/u-boot/u-boot/-/commit/3dca77b1dc1b6dbf9c8b51572fe4b0553cef009f >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> Block devices are enumerated in efi_disk_register(). Please, try to add >>>>>>>>> debug output there to elucidate the problem. >>>>>>>> >>>>>>>> I found where the problem is. First of all zcu102 didn't use the same >>>>>>>> image as others (it wasn't updated properly). >>>>>>>> When you have CONFIG_EFI_CAPSULE_ON_DISK_EARLY that efi_disk_register() >>>>>>>> is called before usb block devices are detected and registered that's >>>>>>>> why grub doesn't see them. >>>>>>> >>>>>>> The problem is CONFIG_EFI_SETUP_EARLY=y required by >>>>>>> CONFIG_EFI_CAPSULE_ON_DISK_EARLY. >>>>>>> >>>>>>> Why is USB initialized later then MMC? >>>>>> >>>>>> It is not just usb. SCSI/sata are behaving in the same way too. >>>>>> >>>>>>> >>>>>>> Overall we have a deficiency in the UEFI implementation in that we >>>>>>> cannot deal with block devices added or removed after initialization. >>>>>>> >>>>>>> Here integration with the driver model is missing. >>>>>> >>>>>> Right. And also there are commands which can create MBR partitions and I >>>>>> expect when you write image to SD and then run rescan or so you could >>>>>> get other partitions too. >>>>>> Maybe hook via part_init()? with removing efi_disk_register. >>>>> >>>>> For the record, I have proposed my ideas several times[1], [2]. >>>>> I'm, however, no longer working on this issue as I have shifted >>>>> my focus to UEFI secure boot and capsule update. >>>>> >>>>> -Takahiro Akashi >>>>> >>>>> [1] https://lists.denx.de/pipermail/u-boot/2018-November/347491.html >>>>> [2] https://lists.denx.de/pipermail/u-boot/2019-February/357923.html >>>> >>>> I want to continue on this thread. I have disabled >>>> EFI_CAPSULE_ON_DISK_EARLY some time ago and trying to workaround that >>>> usb/scsi detection by simply calling usb reset and scsi reset as the >>>> part of PREBOOT. Then all disks are recorded and visible by grub. >>>> >>>> But I found another issue which is kind of weird. We are using >>>> distroboot with soft of fixed sequence. Important part of sequence is >>>> sd, usb, scsi. >>>> >>>> I have added grub on scsi and when I boot directly via run bootcmd_scsi0 >>>> everything is working fine. When I let distroboot to do the job it or >>>> run printenv -e before bootcmd_scsi0 I am getting exception. >>>> From debug it is visible that it is exception called from >>>> efi_disk_read_blocks. >>>> >>>> 0 0x7ff5d188 hang()+20: include/bootstage.h, line 389 >>>> 1 0x7ff5f908 __assert_fail(): lib/panic.c, line 25 >>>> 2 0x7fe976a8 do_irq(): arch/arm/lib/interrupts_64.c, line 123 >>>> 3 0x7fe96a0c _restore_regs()+124: arch/arm/cpu/armv8/exceptions.S, >>>> line 141 >>>> 4 0x7ff43740 efi_disk_read_blocks()+160: lib/efi_loader/efi_disk.c, >>>> line 102 >>> >>> How and when did you get this stack trace? >> >> When Abort happened I connected Xilinx debugger via jtag and look at cpu >> backtrace. > > OK, but we are already in grub here and such a trace (in U-Boot) > doesn't make sense. Right? Correct grub already started. But I expect it is still using U-Boot drivers and all exception handlers are still in place from u-boot. Maybe it is just sata/scsi related issue in EFI but weird is that when disks are scan just before command everything is working fine. Should I try to initialize and populate EFI object list all the time? (Remove this code for testing) /* Initialize once only */ if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) return efi_obj_list_initialized; Or based on this thread to try your series pointed above? Thanks, Michal