69 lines
2.3 KiB
Diff
69 lines
2.3 KiB
Diff
From patchwork Wed Nov 22 03:18:59 2017
|
|
Content-Type: text/plain; charset="utf-8"
|
|
MIME-Version: 1.0
|
|
Content-Transfer-Encoding: 7bit
|
|
Subject: [U-Boot,v2] efi_loader: initialise partition_signature memory
|
|
X-Patchwork-Submitter: Jonathan Gray <jsg@jsg.id.au>
|
|
X-Patchwork-Id: 840248
|
|
Message-Id: <20171122031859.12600-1-jsg@jsg.id.au>
|
|
To: u-boot@lists.denx.de
|
|
Cc: kettenis@openbsd.org, agraf@suse.de
|
|
Date: Wed, 22 Nov 2017 14:18:59 +1100
|
|
From: Jonathan Gray <jsg@jsg.id.au>
|
|
List-Id: U-Boot discussion <u-boot.lists.denx.de>
|
|
|
|
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>
|
|
---
|
|
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];
|
|
}
|