* [U-Boot] [PATCH] gpt: Fix the protective MBR partition size
@ 2015-01-08 11:26 Maxime Ripard
2015-01-08 21:23 ` Steve Rae
2015-01-09 13:34 ` [U-Boot] " Tom Rini
0 siblings, 2 replies; 4+ messages in thread
From: Maxime Ripard @ 2015-01-08 11:26 UTC (permalink / raw)
To: u-boot
According to the UEFI Spec (Table 16, section 5.2.3 of the version 2.4 Errata
B), the protective MBR partition record size must be set to the size of the
disk minus one, in LBAs.
However, the current code was setting the size as the total number of LBAs on
the disk, resulting in an off-by-one error.
This confused the AM335x ROM code, and will probably confuse other tools as
well.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
disk/part_efi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 612f0926b62b..5ca17c138e96 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -240,7 +240,7 @@ static int set_protective_mbr(block_dev_desc_t *dev_desc)
p_mbr->signature = MSDOS_MBR_SIGNATURE;
p_mbr->partition_record[0].sys_ind = EFI_PMBR_OSTYPE_EFI_GPT;
p_mbr->partition_record[0].start_sect = 1;
- p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba;
+ p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba - 1;
/* Write MBR sector to the MMC device */
if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) != 1) {
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] gpt: Fix the protective MBR partition size
2015-01-08 11:26 [U-Boot] [PATCH] gpt: Fix the protective MBR partition size Maxime Ripard
@ 2015-01-08 21:23 ` Steve Rae
2015-01-13 8:36 ` Lukasz Majewski
2015-01-09 13:34 ` [U-Boot] " Tom Rini
1 sibling, 1 reply; 4+ messages in thread
From: Steve Rae @ 2015-01-08 21:23 UTC (permalink / raw)
To: u-boot
(+ Lukasz)
Interesting - I'll defer to Lukasz...
Thanks, Steve
On 15-01-08 03:26 AM, Maxime Ripard wrote:
> According to the UEFI Spec (Table 16, section 5.2.3 of the version 2.4 Errata
> B), the protective MBR partition record size must be set to the size of the
> disk minus one, in LBAs.
>
> However, the current code was setting the size as the total number of LBAs on
> the disk, resulting in an off-by-one error.
>
> This confused the AM335x ROM code, and will probably confuse other tools as
> well.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> disk/part_efi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index 612f0926b62b..5ca17c138e96 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -240,7 +240,7 @@ static int set_protective_mbr(block_dev_desc_t *dev_desc)
> p_mbr->signature = MSDOS_MBR_SIGNATURE;
> p_mbr->partition_record[0].sys_ind = EFI_PMBR_OSTYPE_EFI_GPT;
> p_mbr->partition_record[0].start_sect = 1;
> - p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba;
> + p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba - 1;
>
> /* Write MBR sector to the MMC device */
> if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) != 1) {
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] gpt: Fix the protective MBR partition size
2015-01-08 11:26 [U-Boot] [PATCH] gpt: Fix the protective MBR partition size Maxime Ripard
2015-01-08 21:23 ` Steve Rae
@ 2015-01-09 13:34 ` Tom Rini
1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2015-01-09 13:34 UTC (permalink / raw)
To: u-boot
On Thu, Jan 08, 2015 at 12:26:44PM +0100, Maxime Ripard wrote:
> According to the UEFI Spec (Table 16, section 5.2.3 of the version 2.4 Errata
> B), the protective MBR partition record size must be set to the size of the
> disk minus one, in LBAs.
>
> However, the current code was setting the size as the total number of LBAs on
> the disk, resulting in an off-by-one error.
>
> This confused the AM335x ROM code, and will probably confuse other tools as
> well.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150109/9aa3b759/attachment.pgp>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] gpt: Fix the protective MBR partition size
2015-01-08 21:23 ` Steve Rae
@ 2015-01-13 8:36 ` Lukasz Majewski
0 siblings, 0 replies; 4+ messages in thread
From: Lukasz Majewski @ 2015-01-13 8:36 UTC (permalink / raw)
To: u-boot
Hi Steve,
> (+ Lukasz)
> Interesting - I'll defer to Lukasz...
> Thanks, Steve
Thanks guys for spotting the mistake and sorry for a late reply
(holidays time).
I'm glad that this patch was included to v2015.01
>
> On 15-01-08 03:26 AM, Maxime Ripard wrote:
> > According to the UEFI Spec (Table 16, section 5.2.3 of the version
> > 2.4 Errata B), the protective MBR partition record size must be set
> > to the size of the disk minus one, in LBAs.
> >
> > However, the current code was setting the size as the total number
> > of LBAs on the disk, resulting in an off-by-one error.
> >
> > This confused the AM335x ROM code, and will probably confuse other
> > tools as well.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> > disk/part_efi.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/disk/part_efi.c b/disk/part_efi.c
> > index 612f0926b62b..5ca17c138e96 100644
> > --- a/disk/part_efi.c
> > +++ b/disk/part_efi.c
> > @@ -240,7 +240,7 @@ static int set_protective_mbr(block_dev_desc_t
> > *dev_desc) p_mbr->signature = MSDOS_MBR_SIGNATURE;
> > p_mbr->partition_record[0].sys_ind =
> > EFI_PMBR_OSTYPE_EFI_GPT; p_mbr->partition_record[0].start_sect = 1;
> > - p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba;
> > + p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba
> > - 1;
> >
> > /* Write MBR sector to the MMC device */
> > if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) !=
> > 1) {
> >
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-13 8:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 11:26 [U-Boot] [PATCH] gpt: Fix the protective MBR partition size Maxime Ripard
2015-01-08 21:23 ` Steve Rae
2015-01-13 8:36 ` Lukasz Majewski
2015-01-09 13:34 ` [U-Boot] " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox