* [PATCH 0/1] ShellPkg: Do not connect handles without device paths @ 2020-01-12 21:38 Vitaly Cheptsov 2020-01-12 21:38 ` [PATCH 1/1] " Vitaly Cheptsov 0 siblings, 1 reply; 11+ messages in thread From: Vitaly Cheptsov @ 2020-01-12 21:38 UTC (permalink / raw) To: devel [-- Attachment #1: Type: text/plain, Size: 512 bytes --] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2460 Doing this reduces the amount of needless work during device connection and resolves issues with firmwares that freeze when connecting handles without device paths. We request this to be merged in edk2-stable202002. Vitaly Cheptsov (1): ShellPkg: Do not connect handles without device paths ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.21.0 (Apple Git-122.2) [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 489 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-12 21:38 [PATCH 0/1] ShellPkg: Do not connect handles without device paths Vitaly Cheptsov @ 2020-01-12 21:38 ` Vitaly Cheptsov 2020-01-13 8:11 ` [edk2-devel] " Gao, Zhichao 0 siblings, 1 reply; 11+ messages in thread From: Vitaly Cheptsov @ 2020-01-12 21:38 UTC (permalink / raw) To: devel [-- Attachment #1: Type: text/plain, Size: 1043 bytes --] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2460 Doing this reduces the amount of needless work during device connection and resolves issues with firmwares that freeze when connecting handles without device paths. Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com> --- ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c index b6e7c952fa..083aac0dba 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c @@ -32,8 +32,8 @@ ConnectAllEfi ( UINTN Index; Status = gBS->LocateHandleBuffer ( - AllHandles, - NULL, + ByProtocol, + &gEfiDevicePathProtocolGuid, NULL, &HandleCount, &HandleBuffer -- 2.21.0 (Apple Git-122.2) [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 489 bytes --] ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-12 21:38 ` [PATCH 1/1] " Vitaly Cheptsov @ 2020-01-13 8:11 ` Gao, Zhichao 2020-01-13 9:19 ` Vitaly Cheptsov 0 siblings, 1 reply; 11+ messages in thread From: Gao, Zhichao @ 2020-01-13 8:11 UTC (permalink / raw) To: devel@edk2.groups.io, vit9696@protonmail.com; +Cc: Ni, Ray, Gao, Zhichao Hi, What does 'freeze' mean? System blocked for a while or it hung up forever? The change would affect the operation of the 'load' command. If some drivers need to connect to the device controller but it doesn't have a device path protocol, the behavior of 'load' may be incorrect. Is the option '-nc' working for your request? Thanks, Zhichao > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Vitaly Cheptsov via Groups.Io > Sent: Monday, January 13, 2020 5:39 AM > To: devel@edk2.groups.io > Subject: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without > device paths > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2460 > > Doing this reduces the amount of needless work during device connection > and resolves issues with firmwares that freeze when connecting handles > without device paths. > > Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com> > --- > ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > index b6e7c952fa..083aac0dba 100644 > --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > @@ -32,8 +32,8 @@ ConnectAllEfi ( > UINTN Index; > > Status = gBS->LocateHandleBuffer ( > - AllHandles, > - NULL, > + ByProtocol, > + &gEfiDevicePathProtocolGuid, > NULL, > &HandleCount, > &HandleBuffer > -- > 2.21.0 (Apple Git-122.2) > > > -=-=-=-=-=-= > Groups.io Links: You receive all messages sent to this group. > > View/Reply Online (#53170): https://edk2.groups.io/g/devel/message/53170 > Mute This Topic: https://groups.io/mt/69653841/1768756 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [zhichao.gao@intel.com] > -=-=-=-=-=-= ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-13 8:11 ` [edk2-devel] " Gao, Zhichao @ 2020-01-13 9:19 ` Vitaly Cheptsov 2020-01-13 11:56 ` Ni, Ray 0 siblings, 1 reply; 11+ messages in thread From: Vitaly Cheptsov @ 2020-01-13 9:19 UTC (permalink / raw) To: Gao, Zhichao; +Cc: devel@edk2.groups.io, Ni, Ray [-- Attachment #1: Type: text/plain, Size: 2838 bytes --] Hi, ‘Freeze’ means it is hung up forever, and we believe it is caused by an invalid memory access in the firmware code. Using loading command with ‘-nc’ (no connect) will work fine, but that is kind of expected, as the issue is caused exactly by the connect logic. We do not believe it is possible for device controller to exist without a device path protocol in the wild. Would you please provide an example? If there is something we do not know about, I can imagine introducing a PCD for this logic. Best wishes, Vitaly > 13 янв. 2020 г., в 11:11, Gao, Zhichao <zhichao.gao@intel.com> написал(а): > > > Hi, > > What does 'freeze' mean? System blocked for a while or it hung up forever? > > The change would affect the operation of the 'load' command. If some drivers need to connect to the device controller but it doesn't have a device path protocol, the behavior of 'load' may be incorrect. > Is the option '-nc' working for your request? > > Thanks, > Zhichao > >> -----Original Message----- >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >> Vitaly Cheptsov via Groups.Io >> Sent: Monday, January 13, 2020 5:39 AM >> To: devel@edk2.groups.io >> Subject: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without >> device paths >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2460 >> >> Doing this reduces the amount of needless work during device connection >> and resolves issues with firmwares that freeze when connecting handles >> without device paths. >> >> Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com> >> --- >> ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c >> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c >> index b6e7c952fa..083aac0dba 100644 >> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c >> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c >> @@ -32,8 +32,8 @@ ConnectAllEfi ( >> UINTN Index; >> >> Status = gBS->LocateHandleBuffer ( >> - AllHandles, >> - NULL, >> + ByProtocol, >> + &gEfiDevicePathProtocolGuid, >> NULL, >> &HandleCount, >> &HandleBuffer >> -- >> 2.21.0 (Apple Git-122.2) >> >> >> -=-=-=-=-=-= >> Groups.io Links: You receive all messages sent to this group. >> >> View/Reply Online (#53170): https://edk2.groups.io/g/devel/message/53170 >> Mute This Topic: https://groups.io/mt/69653841/1768756 >> Group Owner: devel+owner@edk2.groups.io >> Unsubscribe: https://edk2.groups.io/g/devel/unsub >> [zhichao.gao@intel.com] >> -=-=-=-=-=-= > [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 489 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-13 9:19 ` Vitaly Cheptsov @ 2020-01-13 11:56 ` Ni, Ray 2020-01-13 17:55 ` Laszlo Ersek 0 siblings, 1 reply; 11+ messages in thread From: Ni, Ray @ 2020-01-13 11:56 UTC (permalink / raw) To: vit9696, Gao, Zhichao; +Cc: devel@edk2.groups.io We shouldn't assume that a DriverBindingStart() can only start on a handle with device path installed. DevicePath protocol is just a special protocol. It's possible that a bus driver starts on a host controller handle and creates multiple children, each with only a Specific_IO protocol installed. Certain device driver can start on the children handle and open the Specific_IO protocol BY_DRIVER. I am not sure if certain today's network drivers may work like this. It's allowed per UEFI spec. Thanks, Ray > -----Original Message----- > From: vit9696 <vit9696@protonmail.com> > Sent: Monday, January 13, 2020 5:20 PM > To: Gao, Zhichao <zhichao.gao@intel.com> > Cc: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com> > Subject: Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths > > Hi, > > ‘Freeze’ means it is hung up forever, and we believe it is caused by an invalid memory access in the firmware code. > > Using loading command with ‘-nc’ (no connect) will work fine, but that is kind of expected, as the issue is caused exactly by > the connect logic. > > We do not believe it is possible for device controller to exist without a device path protocol in the wild. Would you please > provide an example? If there is something we do not know about, I can imagine introducing a PCD for this logic. > > Best wishes, > Vitaly > > > 13 янв. 2020 г., в 11:11, Gao, Zhichao <zhichao.gao@intel.com> написал(а): > > > > > > Hi, > > > > What does 'freeze' mean? System blocked for a while or it hung up forever? > > > > The change would affect the operation of the 'load' command. If some drivers need to connect to the device controller > but it doesn't have a device path protocol, the behavior of 'load' may be incorrect. > > Is the option '-nc' working for your request? > > > > Thanks, > > Zhichao > > > >> -----Original Message----- > >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > >> Vitaly Cheptsov via Groups.Io > >> Sent: Monday, January 13, 2020 5:39 AM > >> To: devel@edk2.groups.io > >> Subject: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without > >> device paths > >> > >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2460 > >> > >> Doing this reduces the amount of needless work during device connection > >> and resolves issues with firmwares that freeze when connecting handles > >> without device paths. > >> > >> Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com> > >> --- > >> ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > >> b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > >> index b6e7c952fa..083aac0dba 100644 > >> --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > >> +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c > >> @@ -32,8 +32,8 @@ ConnectAllEfi ( > >> UINTN Index; > >> > >> Status = gBS->LocateHandleBuffer ( > >> - AllHandles, > >> - NULL, > >> + ByProtocol, > >> + &gEfiDevicePathProtocolGuid, > >> NULL, > >> &HandleCount, > >> &HandleBuffer > >> -- > >> 2.21.0 (Apple Git-122.2) > >> > >> > >> -=-=-=-=-=-= > >> Groups.io Links: You receive all messages sent to this group. > >> > >> View/Reply Online (#53170): https://edk2.groups.io/g/devel/message/53170 > >> Mute This Topic: https://groups.io/mt/69653841/1768756 > >> Group Owner: devel+owner@edk2.groups.io > >> Unsubscribe: https://edk2.groups.io/g/devel/unsub > >> [zhichao.gao@intel.com] > >> -=-=-=-=-=-= > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-13 11:56 ` Ni, Ray @ 2020-01-13 17:55 ` Laszlo Ersek 2020-01-13 20:46 ` Vitaly Cheptsov 0 siblings, 1 reply; 11+ messages in thread From: Laszlo Ersek @ 2020-01-13 17:55 UTC (permalink / raw) To: devel, ray.ni, vit9696, Gao, Zhichao On 01/13/20 12:56, Ni, Ray wrote: > We shouldn't assume that a DriverBindingStart() can only start on a handle with device path installed. DevicePath protocol is just a special protocol. > It's possible that a bus driver starts on a host controller handle and creates multiple children, each with only a Specific_IO protocol installed. > Certain device driver can start on the children handle and open the Specific_IO protocol BY_DRIVER. > I am not sure if certain today's network drivers may work like this. It's allowed per UEFI spec. I agree. Under "10.2 EFI Device Path Protocol", the spec says, "If the handle does not logically map to a physical device, the handle may not necessarily support the device path protocol." I think gBS->ConnectController() and EFI_DRIVER_BINDING_PROTOCOL.Supported() should work on such handles. If we'd like to work around related issues in drivers, then I'd suggest new command line options for the "load", "connect", "reconnect" shell commands (maybe more), for filtering out handles that do not carry device paths. Such command line options could be added as an extension, IIUC, such as "-_option". I.e., I believe it's not necessary to start with UEFI Shell Spec updates. Thanks Laszlo ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-13 17:55 ` Laszlo Ersek @ 2020-01-13 20:46 ` Vitaly Cheptsov 2020-01-14 2:53 ` Ni, Ray 0 siblings, 1 reply; 11+ messages in thread From: Vitaly Cheptsov @ 2020-01-13 20:46 UTC (permalink / raw) To: Laszlo Ersek, devel, ray.ni, Gao, Zhichao [-- Attachment #1: Type: text/plain, Size: 2316 bytes --] Thanks all for your input, These explanations seem sufficient to us that it is not a good idea to change the behaviour for everyone. Even so, we still need this to be configurable in some way, as having to patch EDK II is impracticable. We believe there are three possible routes to approach this problem: - Introduce a separate ControllerConnectionLib library for this function. While it is small, we found several places in our code that need to call it beyond UEFI Shell. This way different implementations could be used depending on the chosen library. - Introduce a ConnectRequiresDevicePath PCD, which will choose the preferred logic. - Introduce a -dp Shell argument for affected commands the way Lazslo suggested. We believe either route or a combination of multiple routes have their own benefits, and would suggest either going with 1+2 or with 3. Any approach is fine for us. We will submit V2 of the patch after hearing the opinions. Best wishes, Vitaly On Mon, Jan 13, 2020 at 20:55, Laszlo Ersek <lersek@redhat.com> wrote: > On 01/13/20 12:56, Ni, Ray wrote: >> We shouldn't assume that a DriverBindingStart() can only start on a handle with device path installed. DevicePath protocol is just a special protocol. >> It's possible that a bus driver starts on a host controller handle and creates multiple children, each with only a Specific_IO protocol installed. >> Certain device driver can start on the children handle and open the Specific_IO protocol BY_DRIVER. >> I am not sure if certain today's network drivers may work like this. It's allowed per UEFI spec. > > I agree. > > Under "10.2 EFI Device Path Protocol", the spec says, "If the handle > does not logically map to a physical device, the handle may not > necessarily support the device path protocol." > > I think gBS->ConnectController() and > EFI_DRIVER_BINDING_PROTOCOL.Supported() should work on such handles. > > If we'd like to work around related issues in drivers, then I'd suggest > new command line options for the "load", "connect", "reconnect" shell > commands (maybe more), for filtering out handles that do not carry > device paths. Such command line options could be added as an extension, > IIUC, such as "-_option". I.e., I believe it's not necessary to start > with UEFI Shell Spec updates. > > Thanks > Laszlo [-- Attachment #2: Type: text/html, Size: 6118 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-13 20:46 ` Vitaly Cheptsov @ 2020-01-14 2:53 ` Ni, Ray 2020-01-14 8:36 ` Vitaly Cheptsov 0 siblings, 1 reply; 11+ messages in thread From: Ni, Ray @ 2020-01-14 2:53 UTC (permalink / raw) To: devel@edk2.groups.io, vit9696@protonmail.com, Laszlo Ersek, Gao, Zhichao [-- Attachment #1: Type: text/plain, Size: 2894 bytes --] Vitaly, I still have concern to modify the EDKII code to workaround a firmware bug. Can you just change in your local version? Thanks, Ray From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Vitaly Cheptsov via Groups.Io Sent: Tuesday, January 14, 2020 4:47 AM To: Laszlo Ersek <lersek@redhat.com>; devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com> Subject: Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths Thanks all for your input, These explanations seem sufficient to us that it is not a good idea to change the behaviour for everyone. Even so, we still need this to be configurable in some way, as having to patch EDK II is impracticable. We believe there are three possible routes to approach this problem: 1. Introduce a separate ControllerConnectionLib library for this function. While it is small, we found several places in our code that need to call it beyond UEFI Shell. This way different implementations could be used depending on the chosen library. 2. Introduce a ConnectRequiresDevicePath PCD, which will choose the preferred logic. 3. Introduce a -dp Shell argument for affected commands the way Lazslo suggested. We believe either route or a combination of multiple routes have their own benefits, and would suggest either going with 1+2 or with 3. Any approach is fine for us. We will submit V2 of the patch after hearing the opinions. Best wishes, Vitaly On Mon, Jan 13, 2020 at 20:55, Laszlo Ersek <lersek@redhat.com<mailto:lersek@redhat.com>> wrote: On 01/13/20 12:56, Ni, Ray wrote: > We shouldn't assume that a DriverBindingStart() can only start on a handle with device path installed. DevicePath protocol is just a special protocol. > It's possible that a bus driver starts on a host controller handle and creates multiple children, each with only a Specific_IO protocol installed. > Certain device driver can start on the children handle and open the Specific_IO protocol BY_DRIVER. > I am not sure if certain today's network drivers may work like this. It's allowed per UEFI spec. I agree. Under "10.2 EFI Device Path Protocol", the spec says, "If the handle does not logically map to a physical device, the handle may not necessarily support the device path protocol." I think gBS->ConnectController() and EFI_DRIVER_BINDING_PROTOCOL.Supported() should work on such handles. If we'd like to work around related issues in drivers, then I'd suggest new command line options for the "load", "connect", "reconnect" shell commands (maybe more), for filtering out handles that do not carry device paths. Such command line options could be added as an extension, IIUC, such as "-_option". I.e., I believe it's not necessary to start with UEFI Shell Spec updates. Thanks Laszlo [-- Attachment #2: Type: text/html, Size: 11053 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-14 2:53 ` Ni, Ray @ 2020-01-14 8:36 ` Vitaly Cheptsov 2020-01-14 10:34 ` Vitaly Cheptsov 0 siblings, 1 reply; 11+ messages in thread From: Vitaly Cheptsov @ 2020-01-14 8:36 UTC (permalink / raw) To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, Gao, Zhichao [-- Attachment #1: Type: text/plain, Size: 3512 bytes --] Ray, We are quite reluctant to have patches in EDK II for a large amount of widely adopted firmwares. Patches eventually break and require maintenance cost, and currently we are trying to get rid of them all. We believe that EDK II Shell is supposed to work on real world platforms and not only the ones that theoretically support the specification. It is always hard to adopt changes based on third-party bugs, and we very well understand your concern, yet it is something we have to do to stay beneficial to the end user. Best wishes, Vitaly On Tue, Jan 14, 2020 at 05:53, Ni, Ray <ray.ni@intel.com> wrote: > Vitaly, > > I still have concern to modify the EDKII code to workaround a firmware bug. > > Can you just change in your local version? > > Thanks, > > Ray > > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Vitaly Cheptsov via Groups.Io > Sent: Tuesday, January 14, 2020 4:47 AM > To: Laszlo Ersek <lersek@redhat.com>; devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com> > Subject: Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths > > Thanks all for your input, > > These explanations seem sufficient to us that it is not a good idea to change the behaviour for everyone. Even so, we still need this to be configurable in some way, as having to patch EDK II is impracticable. > > We believe there are three possible routes to approach this problem: > > - Introduce a separate ControllerConnectionLib library for this function. While it is small, we found several places in our code that need to call it beyond UEFI Shell. This way different implementations could be used depending on the chosen library. > - Introduce a ConnectRequiresDevicePath PCD, which will choose the preferred logic. > - Introduce a -dp Shell argument for affected commands the way Lazslo suggested. > > We believe either route or a combination of multiple routes have their own benefits, and would suggest either going with 1+2 or with 3. Any approach is fine for us. > > We will submit V2 of the patch after hearing the opinions. > > Best wishes, > > Vitaly > > On Mon, Jan 13, 2020 at 20:55, Laszlo Ersek <lersek@redhat.com> wrote: > >> On 01/13/20 12:56, Ni, Ray wrote: >>> We shouldn't assume that a DriverBindingStart() can only start on a handle with device path installed. DevicePath protocol is just a special protocol. >>> It's possible that a bus driver starts on a host controller handle and creates multiple children, each with only a Specific_IO protocol installed. >>> Certain device driver can start on the children handle and open the Specific_IO protocol BY_DRIVER. >>> I am not sure if certain today's network drivers may work like this. It's allowed per UEFI spec. >> >> I agree. >> >> Under "10.2 EFI Device Path Protocol", the spec says, "If the handle >> does not logically map to a physical device, the handle may not >> necessarily support the device path protocol." >> >> I think gBS->ConnectController() and >> EFI_DRIVER_BINDING_PROTOCOL.Supported() should work on such handles. >> >> If we'd like to work around related issues in drivers, then I'd suggest >> new command line options for the "load", "connect", "reconnect" shell >> commands (maybe more), for filtering out handles that do not carry >> device paths. Such command line options could be added as an extension, >> IIUC, such as "-_option". I.e., I believe it's not necessary to start >> with UEFI Shell Spec updates. >> >> Thanks >> Laszlo > > [-- Attachment #2: Type: text/html, Size: 8668 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-14 8:36 ` Vitaly Cheptsov @ 2020-01-14 10:34 ` Vitaly Cheptsov 2020-01-14 12:53 ` Laszlo Ersek 0 siblings, 1 reply; 11+ messages in thread From: Vitaly Cheptsov @ 2020-01-14 10:34 UTC (permalink / raw) To: Ni, Ray, devel@edk2.groups.io, Laszlo Ersek, Gao, Zhichao [-- Attachment #1.1: Type: text/plain, Size: 5906 bytes --] In addition to my previous letter I have to mention a couple more newly discovered details. 1. UEFI Shell (ShellPkg) actually has 3 functions dedicated to connecting controllers and essentially doing the same thing: - ConnectAllEfi ShellPkg/Library/UefiShellLevel2CommandsLib/Load.c This one locates all handles and runs connect on them. It is the one we mentioned in the bug. - LoadPciRomConnectAllDriversToAllControllers ShellPkg/Library/UefiShellDebug1CommandsLib/LoadPciRom.c This one is similar to ConnectAllEfi. The only difference is that it additionally checks for Ctrl+C via ShellGetExecutionBreakFlag. - ConnectControllers ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c This one is more complex, as it supports explicitly connecting specified controllers, however, for connecting all controllers it locates handles with gEfiDevicePathProtocolGuid. I.e. exactly what we ask. I believe that all these functions should behave the same way in correspondence to gBS->ConnectController at the very least, and most likely there should be a library responsible for connection and disconnection. 2. We also checked EFI 1.1 Shell, and confirmed that it consistently has checks for device path presence before running connect on the handle[1][2]. This makes us believe that our proposal is not really a firmware bug, but rather a limitation of the legacy specification. Considering all these discoveries, we believe our suggested change is legit depending on the minimum supported UEFI version. Therefore we propose submitting a ControllerConnection library with 5 functions: - ConnectController - DisconnectController - GetAllControllers - ConnectAllControllers - DisconnectAllControllers Adopting it throughout the code will let the distribitor to be responsible for choosing what is right for his applications (or firmwares). Best wishes, Vitaly [1] https://sourceforge.net/p/efi-shell/code/64/tree/trunk/Shell/LoadPciRom/LoadPciRom.c#l528 [2] https://sourceforge.net/p/efi-shell/code/64/tree/trunk/Shell/load/load.c#l312 > 14 янв. 2020 г., в 11:36, vit9696 <vit9696@protonmail.com> написал(а): > > Ray, > > We are quite reluctant to have patches in EDK II for a large amount of widely adopted firmwares. Patches eventually break and require maintenance cost, and currently we are trying to get rid of them all. We believe that EDK II Shell is supposed to work on real world platforms and not only the ones that theoretically support the specification. It is always hard to adopt changes based on third-party bugs, and we very well understand your concern, yet it is something we have to do to stay beneficial to the end user. > > Best wishes, > Vitaly > > On Tue, Jan 14, 2020 at 05:53, Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com>> wrote: >> >> Vitaly, >> >> I still have concern to modify the EDKII code to workaround a firmware bug. >> >> Can you just change in your local version? >> >> >> Thanks, >> >> Ray >> >> >> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Vitaly Cheptsov via Groups.Io >> Sent: Tuesday, January 14, 2020 4:47 AM >> To: Laszlo Ersek <lersek@redhat.com>; devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>; Gao, Zhichao <zhichao.gao@intel.com> >> Subject: Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths >> >> >> Thanks all for your input, >> >> These explanations seem sufficient to us that it is not a good idea to change the behaviour for everyone. Even so, we still need this to be configurable in some way, as having to patch EDK II is impracticable. >> >> We believe there are three possible routes to approach this problem: >> >> Introduce a separate ControllerConnectionLib library for this function. While it is small, we found several places in our code that need to call it beyond UEFI Shell. This way different implementations could be used depending on the chosen library. >> Introduce a ConnectRequiresDevicePath PCD, which will choose the preferred logic. >> Introduce a -dp Shell argument for affected commands the way Lazslo suggested. >> >> We believe either route or a combination of multiple routes have their own benefits, and would suggest either going with 1+2 or with 3. Any approach is fine for us. >> >> We will submit V2 of the patch after hearing the opinions. >> >> Best wishes, >> Vitaly >> >> On Mon, Jan 13, 2020 at 20:55, Laszlo Ersek <lersek@redhat.com <mailto:lersek@redhat.com>> wrote: >> >> On 01/13/20 12:56, Ni, Ray wrote: >> > We shouldn't assume that a DriverBindingStart() can only start on a handle with device path installed. DevicePath protocol is just a special protocol. >> > It's possible that a bus driver starts on a host controller handle and creates multiple children, each with only a Specific_IO protocol installed. >> > Certain device driver can start on the children handle and open the Specific_IO protocol BY_DRIVER. >> > I am not sure if certain today's network drivers may work like this. It's allowed per UEFI spec. >> >> I agree. >> >> Under "10.2 EFI Device Path Protocol", the spec says, "If the handle >> does not logically map to a physical device, the handle may not >> necessarily support the device path protocol." >> >> I think gBS->ConnectController() and >> EFI_DRIVER_BINDING_PROTOCOL.Supported() should work on such handles. >> >> If we'd like to work around related issues in drivers, then I'd suggest >> new command line options for the "load", "connect", "reconnect" shell >> commands (maybe more), for filtering out handles that do not carry >> device paths. Such command line options could be added as an extension, >> IIUC, such as "-_option". I.e., I believe it's not necessary to start >> with UEFI Shell Spec updates. >> >> Thanks >> Laszlo >> >> >> >> >> > > [-- Attachment #1.2: Type: text/html, Size: 13145 bytes --] [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 489 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [PATCH 1/1] ShellPkg: Do not connect handles without device paths 2020-01-14 10:34 ` Vitaly Cheptsov @ 2020-01-14 12:53 ` Laszlo Ersek 0 siblings, 0 replies; 11+ messages in thread From: Laszlo Ersek @ 2020-01-14 12:53 UTC (permalink / raw) To: devel, vit9696, Ni, Ray, Gao, Zhichao On 01/14/20 11:34, Vitaly Cheptsov via Groups.Io wrote: > - ConnectControllers > ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c > > This one is more complex, as it supports explicitly connecting specified controllers, however, for connecting all controllers it locates handles with gEfiDevicePathProtocolGuid. I.e. exactly what we ask. This surprised me, but I think you are right. Interestingly, the logic goes back to historical commit 4ba49616416a ("Adding Driver1 profile commands to the UEFI Shell 2.0.", 2010-11-12). Laszlo ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-01-14 12:53 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-01-12 21:38 [PATCH 0/1] ShellPkg: Do not connect handles without device paths Vitaly Cheptsov 2020-01-12 21:38 ` [PATCH 1/1] " Vitaly Cheptsov 2020-01-13 8:11 ` [edk2-devel] " Gao, Zhichao 2020-01-13 9:19 ` Vitaly Cheptsov 2020-01-13 11:56 ` Ni, Ray 2020-01-13 17:55 ` Laszlo Ersek 2020-01-13 20:46 ` Vitaly Cheptsov 2020-01-14 2:53 ` Ni, Ray 2020-01-14 8:36 ` Vitaly Cheptsov 2020-01-14 10:34 ` Vitaly Cheptsov 2020-01-14 12:53 ` Laszlo Ersek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox