Commit b349abbfe95972ee7770d8ffef0eaf45cc84f419

Authored by Maxime Ripard
Committed by Tom Rini
1 parent b6b1b44586

gpt: Fix the protective MBR partition size

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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -342,7 +342,7 @@
342 342 p_mbr->signature = MSDOS_MBR_SIGNATURE;
343 343 p_mbr->partition_record[0].sys_ind = EFI_PMBR_OSTYPE_EFI_GPT;
344 344 p_mbr->partition_record[0].start_sect = 1;
345   - p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba;
  345 + p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba - 1;
346 346  
347 347 /* Write MBR sector to the MMC device */
348 348 if (dev_desc->block_write(dev_desc->dev, 0, 1, p_mbr) != 1) {