From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::436; helo=mail-pf1-x436.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 80B9121B02822 for ; Mon, 18 Mar 2019 21:14:02 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id s23so12761426pfe.13 for ; Mon, 18 Mar 2019 21:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JFtXXem5MjzLmKGYbtuV4tRafwysIcR9fQdUITVb6yc=; b=viNtaYcfNiZkQEc8XHRxItAFnSb2Uk29/UJf/HTCh5ZhSoS6HqnXCn9G0acC9m1Is/ x41FL3Vw/x/8f8jDDnOHNVT8DGinzjnH3gKqF1mQ27kAYR7bpb6I1pMdFzkUPxioFFfr d2hM08imy/uVVb+UQUmEr8WrJ9JyLDcs1t8vHYBgsQvaEdmwxlLcv0X93bxhvXKJsP3r cSOiGKRGpmwEfFVQ/ARZXUk4ywdD6itCtpFj/bQhcUd5e28CoKpOWv+aId9mGYDX8wkm zSDRbuFgPFtisS/brThQVwP1aWVptbTeMfsY956Iq5jdDazengndxSchEAxZJeN5/niV Opew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JFtXXem5MjzLmKGYbtuV4tRafwysIcR9fQdUITVb6yc=; b=LvD3deA6h8uJNbT0B74b/cUiKvv9BGh5nPNGCD257UdME5kY7YhxNEhLABneJnB6S+ PoweOZREGYqhJ/D07n476ta3b/e/q8fpS1N9Vtz3+/0uDXknLo5kWNAg5l0RlYJRplCS mti1pxiScQmLmra7oCxAbYYW9DSROKJeXf17xVFmVqIZiMu8doMyRr+AHTJ6K2euR0pY MCPQqG3M3OGBdzokQvnkLAdf8NoiFBHKA/Xy79OoaEH7SPY+ixHL/QSEGCZpbNgqEcny j3WRK8oEDweKZU+/lBQX9p535ttKACYUt/g/Lf+iiqIIyq348hfhKnRBQjkAWjgl5eKt kUHA== X-Gm-Message-State: APjAAAWqEPJDadub4An2MHx74cC7j7HNSK6S+faY21XRqlcaDWbxc0J+ iDcrupK5LDvraonPJ6wlS9hXYA== X-Google-Smtp-Source: APXvYqxaCWl6AL/LcvdvFu/GHDNXKUIaVjdPoBxA7nU8qlbZa/JCDjprzgulkVj4hXqyWaWNM0K5aA== X-Received: by 2002:a17:902:ab82:: with SMTP id f2mr22746766plr.93.1552968841691; Mon, 18 Mar 2019 21:14:01 -0700 (PDT) Received: from [10.140.0.66] ([64.64.108.204]) by smtp.gmail.com with ESMTPSA id 16sm11541646pfz.106.2019.03.18.21.13.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 21:14:01 -0700 (PDT) To: "Wu, Hao A" , Leif Lindholm Cc: "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" , "Zeng, Star" , "Dong, Eric" , "Ni, Ray" , "dann.frazier@canonical.com" , "ard.biesheuvel@linaro.org" , "Kinney, Michael D" , "Gao, Liming" , "wanghuiqiang@huawei.com" , "huangming23@huawei.com" , "zhangjinsong2@huawei.com" , "huangdaode@hisilicon.com" , "waip23@126.com" , "Wang, Jian J" References: <20190225091052.25461-1-ming.huang@linaro.org> <20190225091052.25461-2-ming.huang@linaro.org> <20190318124232.67pblu6tbdi47g2w@bivouac.eciton.net> From: Ming Huang Message-ID: <0732ee09-0955-965d-1ff1-167cbc3a1348@linaro.org> Date: Tue, 19 Mar 2019 12:13:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [MdeModulePkg/Library v1 1/1] MdeModulePkg/UefiBootManangerLib: Fix exception issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2019 04:14:02 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 3/19/2019 10:25 AM, Wu, Hao A wrote: >> -----Original Message----- >> From: Leif Lindholm [mailto:leif.lindholm@linaro.org] >> Sent: Monday, March 18, 2019 8:43 PM >> To: Ming Huang >> Cc: linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org; Zeng, Star; Dong, >> Eric; Ni, Ray; dann.frazier@canonical.com; ard.biesheuvel@linaro.org; Kinney, >> Michael D; Gao, Liming; wanghuiqiang@huawei.com; >> huangming23@huawei.com; zhangjinsong2@huawei.com; >> huangdaode@hisilicon.com; waip23@126.com; Wang, Jian J; Wu, Hao A; Ni, >> Ray >> Subject: Re: [MdeModulePkg/Library v1 1/1] >> MdeModulePkg/UefiBootManangerLib: Fix exception issue >> >> +MdeModulePkg maintainers (you added MdePkg maintainers to cc) >> >> This looks like an improvement to me. >> >> Am I correct in guessing this behaviour refers to some specific corner >> case of a USB CDROM emulated from a BMC? >> >> On Mon, Feb 25, 2019 at 05:10:52PM +0800, Ming Huang wrote: >>> The system environment: virtual-CDROM(USB interface) via BMC, insert a >>> iso file to CDROM, like ubuntu-18.04.1-server-arm64.iso, change CDROM >>> to first boot option. >>> With release version bios, disconnecting CDROM when boot to >>> "1 seconds left, Press Esc or F2 to enter Setup" >>> then system will get a exception. >>> >>> The root cause is the EFI_BLOCK_IO_PROTOCOL for UsbMass will be >> uninstalled >>> in this situation after print some transfer error. The status will be >>> invalid parameter. This line will get a exception for BlockIo not point > > Do you mean 'EFI_INVALID_PARAMETER' is returned from: > Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo); Yes. > > If so, my guess is that 'Handle' is NULL at this point. An improvement can > be adding a previous check for 'Status' after the ASSERT at: > > Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle); > ASSERT_EFI_ERROR (Status); As my debug output, this 'Status' is seccuss and Handle is not NULL, but gBS->ConnectController return:Not Found Debug output: [BmExpandMediaDevicePath]:[1056L] Handle=3E3F3D18 BlockIo=3B2757B6 Media=AFAF6C617470AFAF Status=Success EhcExecTransfer: transfer failed with 40 EhcBulkTransfer: error - Device Error, transfer - 40 ......... [UsbOnHubInterrupt]:[632L] SignalEvent (HubIf->HubNotify) UsbBotExecCommand: UsbBotSendCommand (Device Error) UsbBootExecCmd: Device Error to Exec 0x0 Cmd (Result = 1) EhcExecTransfer: transfer failed with 40 ............... [USBMassDriverBindingStop]:[1010L] Uninstall USB block io, free: 3E44F218(F0) [BmExpandMediaDevicePath]:[1064L] Connect Not Found [BmExpandMediaDevicePath]:[1076L] Handle=3E3F3D18 BlockIo=3B2757B6 Media=AFAF6C617470AFAF Status=Invalid Parameter Thanks > > And leave: > > Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo); > ASSERT_EFI_ERROR (Status); > > unchanged. > > Best Regards, > Hao Wu > >>> to right address: >>> AllocatePool (BlockIo->Media->BlockSize) >>> So, here need to judge the status not using ASSERT_EFI_ERROR. >>> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Ming Huang >>> --- >>> MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c >> b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c >>> index d5957db610d9..c2f1c651b02f 100644 >>> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c >>> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c >>> @@ -1068,7 +1068,9 @@ BmExpandMediaDevicePath ( >>> // Block IO read/write will success. >>> // >>> Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID >> **) &BlockIo); >>> - ASSERT_EFI_ERROR (Status); >>> + if (EFI_ERROR (Status)) { >> >> It would still be worth including an ASSERT here, to let DEBUG builds >> report on point of failure rather than several steps up the chain. >> >> / >> Leif >> >>> + return NULL; >>> + } >>> Buffer = AllocatePool (BlockIo->Media->BlockSize); >>> if (Buffer != NULL) { >>> BlockIo->ReadBlocks ( >>> -- >>> 2.9.5 >>>