diff mbox series

[U-Boot,RFC,v2,03/11] efi_loader: device_path: handle special case of loading

Message ID 20190327044042.13707-4-takahiro.akashi@linaro.org
State Changes Requested, archived
Delegated to: Heinrich Schuchardt
Headers show
Series efi_loader: rework bootefi/bootmgr | expand

Commit Message

AKASHI Takahiro March 27, 2019, 4:40 a.m. UTC
This is a preparatory patch.

efi_dp_split_file_path() is used to create device_path and file_path
from file_path for efi_setup_loaded_image().
In a special case, however, of HARDWARE_DEVICE/MEMORY, it doesn't
work expectedly since this path doesn't contain any FILE_PATH sub-type.

This patch makes a workaround.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 lib/efi_loader/efi_device_path.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Heinrich Schuchardt March 27, 2019, 6:17 a.m. UTC | #1
On 3/27/19 5:40 AM, AKASHI Takahiro wrote:
> This is a preparatory patch.
>
> efi_dp_split_file_path() is used to create device_path and file_path
> from file_path for efi_setup_loaded_image().
> In a special case, however, of HARDWARE_DEVICE/MEMORY, it doesn't
> work expectedly since this path doesn't contain any FILE_PATH sub-type.

As already mentioned in a comment to patch 1/11 I would prefer that we
pass the original device path to efi_setup_loaded_image() instead of
recombining device path and file path there again.

This would avoid special treatment here with possible side effects in
efi_fs_from_path().

Best regards

Heinrich

>
> This patch makes a workaround.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  lib/efi_loader/efi_device_path.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index 53b40c8c3c2d..e283fad767ed 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -933,6 +933,14 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path,
>  	dp = efi_dp_dup(full_path);
>  	if (!dp)
>  		return EFI_OUT_OF_RESOURCES;
> +
> +	if (EFI_DP_TYPE(dp, HARDWARE_DEVICE, MEMORY)) {
> +		/* no FILE_PATH */
> +		*device_path = dp;
> +
> +		return EFI_SUCCESS;
> +	}
> +
>  	p = dp;
>  	while (!EFI_DP_TYPE(p, MEDIA_DEVICE, FILE_PATH)) {
>  		p = efi_dp_next(p);
>
AKASHI Takahiro March 28, 2019, 1:17 a.m. UTC | #2
On Wed, Mar 27, 2019 at 07:17:02AM +0100, Heinrich Schuchardt wrote:
> On 3/27/19 5:40 AM, AKASHI Takahiro wrote:
> > This is a preparatory patch.
> >
> > efi_dp_split_file_path() is used to create device_path and file_path
> > from file_path for efi_setup_loaded_image().
> > In a special case, however, of HARDWARE_DEVICE/MEMORY, it doesn't
> > work expectedly since this path doesn't contain any FILE_PATH sub-type.
> 
> As already mentioned in a comment to patch 1/11 I would prefer that we
> pass the original device path to efi_setup_loaded_image() instead of
> recombining device path and file path there again.

This change would only come, as I said, after do_efi_selftest() is
also refactored.

Thanks,
-Takahiro Akashi

> This would avoid special treatment here with possible side effects in
> efi_fs_from_path().
> 
> Best regards
> 
> Heinrich
> 
> >
> > This patch makes a workaround.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  lib/efi_loader/efi_device_path.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> > index 53b40c8c3c2d..e283fad767ed 100644
> > --- a/lib/efi_loader/efi_device_path.c
> > +++ b/lib/efi_loader/efi_device_path.c
> > @@ -933,6 +933,14 @@ efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path,
> >  	dp = efi_dp_dup(full_path);
> >  	if (!dp)
> >  		return EFI_OUT_OF_RESOURCES;
> > +
> > +	if (EFI_DP_TYPE(dp, HARDWARE_DEVICE, MEMORY)) {
> > +		/* no FILE_PATH */
> > +		*device_path = dp;
> > +
> > +		return EFI_SUCCESS;
> > +	}
> > +
> >  	p = dp;
> >  	while (!EFI_DP_TYPE(p, MEDIA_DEVICE, FILE_PATH)) {
> >  		p = efi_dp_next(p);
> >
> 
> 
> 
>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 53b40c8c3c2d..e283fad767ed 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -933,6 +933,14 @@  efi_status_t efi_dp_split_file_path(struct efi_device_path *full_path,
 	dp = efi_dp_dup(full_path);
 	if (!dp)
 		return EFI_OUT_OF_RESOURCES;
+
+	if (EFI_DP_TYPE(dp, HARDWARE_DEVICE, MEMORY)) {
+		/* no FILE_PATH */
+		*device_path = dp;
+
+		return EFI_SUCCESS;
+	}
+
 	p = dp;
 	while (!EFI_DP_TYPE(p, MEDIA_DEVICE, FILE_PATH)) {
 		p = efi_dp_next(p);