diff mbox series

[U-Boot] efi_loader: initialise partition_signature memory

Message ID 20171121122432.88805-1-jsg@jsg.id.au
State Superseded
Delegated to: Alexander Graf
Headers show
Series [U-Boot] efi_loader: initialise partition_signature memory | expand

Commit Message

Jonathan Gray Nov. 21, 2017, 12:24 p.m. UTC
Zero partition_signature in the efi_device_path_hard_drive_path
structure when signature_type is zero.

This is required so that efi_dp_match() will work as expected
when doing memcmp() comparisons.

Corrects a problem where the loaded image protocol would not return a
device path with MEDIA_DEVICE causing the OpenBSD bootloader to fail
on rpi_3 and other targets.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
---
 lib/efi_loader/efi_device_path.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Rob Clark Nov. 30, 2017, 2:24 p.m. UTC | #1
On Tue, Nov 21, 2017 at 7:24 AM, Jonathan Gray <jsg@jsg.id.au> wrote:
> Zero partition_signature in the efi_device_path_hard_drive_path
> structure when signature_type is zero.
>
> This is required so that efi_dp_match() will work as expected
> when doing memcmp() comparisons.
>
> Corrects a problem where the loaded image protocol would not return a
> device path with MEDIA_DEVICE causing the OpenBSD bootloader to fail
> on rpi_3 and other targets.
>
> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  lib/efi_loader/efi_device_path.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index f6e368e029..8045532a29 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -431,6 +431,9 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
>                 if (hddp->signature_type != 0)
>                         memcpy(hddp->partition_signature, &desc->guid_sig,
>                                sizeof(hddp->partition_signature));
> +               else
> +                       memset(hddp->partition_signature, 0,
> +                              sizeof(hddp->partition_signature));
>
>                 buf = &hddp[1];
>         }
> --
> 2.15.0
>
Jonathan Gray Nov. 30, 2017, 3:06 p.m. UTC | #2
On Thu, Nov 30, 2017 at 09:24:36AM -0500, Rob Clark wrote:
> On Tue, Nov 21, 2017 at 7:24 AM, Jonathan Gray <jsg@jsg.id.au> wrote:
> > Zero partition_signature in the efi_device_path_hard_drive_path
> > structure when signature_type is zero.
> >
> > This is required so that efi_dp_match() will work as expected
> > when doing memcmp() comparisons.
> >
> > Corrects a problem where the loaded image protocol would not return a
> > device path with MEDIA_DEVICE causing the OpenBSD bootloader to fail
> > on rpi_3 and other targets.
> >
> > Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
> 
> Reviewed-by: Rob Clark <robdclark@gmail.com>

Expanded v2 version of this is here:
https://patchwork.ozlabs.org/patch/840248/

> 
> > ---
> >  lib/efi_loader/efi_device_path.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> > index f6e368e029..8045532a29 100644
> > --- a/lib/efi_loader/efi_device_path.c
> > +++ b/lib/efi_loader/efi_device_path.c
> > @@ -431,6 +431,9 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
> >                 if (hddp->signature_type != 0)
> >                         memcpy(hddp->partition_signature, &desc->guid_sig,
> >                                sizeof(hddp->partition_signature));
> > +               else
> > +                       memset(hddp->partition_signature, 0,
> > +                              sizeof(hddp->partition_signature));
> >
> >                 buf = &hddp[1];
> >         }
> > --
> > 2.15.0
> >
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index f6e368e029..8045532a29 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -431,6 +431,9 @@  static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
 		if (hddp->signature_type != 0)
 			memcpy(hddp->partition_signature, &desc->guid_sig,
 			       sizeof(hddp->partition_signature));
+		else
+			memset(hddp->partition_signature, 0,
+			       sizeof(hddp->partition_signature));
 
 		buf = &hddp[1];
 	}