From: Artturi Alm <artturi.alm@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] efi_loader: initialise partition_signature memory
Date: Fri, 24 Nov 2017 06:04:58 +0200 [thread overview]
Message-ID: <20171124040458.GA4221@gmail.com> (raw)
In-Reply-To: <20171122031859.12600-1-jsg@jsg.id.au>
On Wed, Nov 22, 2017 at 02:18:59PM +1100, Jonathan Gray wrote:
> Zero partition_signature in the efi_device_path_hard_drive_path
> structure when signature_type is 0 (no signature) as required by the
> UEFI specification.
>
> This is required so that efi_dp_match() will work as expected
> when doing memcmp() comparisons. Previously uninitialised memory
> would cause it not match nodes when it should have when the signature
> type was not GUID.
>
> 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.
>
> v2: Also handle signature_type 1 (MBR) as described in the specification
>
> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Tested-by: Artturi Alm <artturi.alm@gmail.com>
Tested with Marsboard_A10_defconfig.
Thanks,
-Artturi
> ---
> lib/efi_loader/efi_device_path.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index f6e368e029..12a81d311c 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -427,10 +427,27 @@ static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
> hddp->partmap_type = 2;
> else
> hddp->partmap_type = 1;
> - hddp->signature_type = desc->sig_type;
> - if (hddp->signature_type != 0)
> +
> + switch (desc->sig_type) {
> + case SIG_TYPE_NONE:
> + default:
> + hddp->signature_type = 0;
> + memset(hddp->partition_signature, 0,
> + sizeof(hddp->partition_signature));
> + break;
> + case SIG_TYPE_MBR:
> + hddp->signature_type = 1;
> + memset(hddp->partition_signature, 0,
> + sizeof(hddp->partition_signature));
> + memcpy(hddp->partition_signature, &desc->mbr_sig,
> + sizeof(desc->mbr_sig));
> + break;
> + case SIG_TYPE_GUID:
> + hddp->signature_type = 2;
> memcpy(hddp->partition_signature, &desc->guid_sig,
> sizeof(hddp->partition_signature));
> + break;
> + }
>
> buf = &hddp[1];
> }
> --
> 2.15.0
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
next prev parent reply other threads:[~2017-11-24 4:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 3:18 [U-Boot] [PATCH v2] efi_loader: initialise partition_signature memory Jonathan Gray
2017-11-24 4:04 ` Artturi Alm [this message]
2017-12-04 8:59 ` [U-Boot] [U-Boot, " Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171124040458.GA4221@gmail.com \
--to=artturi.alm@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.