gpt: Fix the protective MBR partition size
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Thu, 8 Jan 2015 11:26:44 +0000 (12:26 +0100)
committerChanho Park <chanho61.park@samsung.com>
Tue, 11 Aug 2015 13:25:40 +0000 (22:25 +0900)
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

index 94219ce7f1e37cffdc48a716004569d6c253befb..1a2620a6a59295665d877e4e2e535dc1297bbaf6 100644 (file)
@@ -256,7 +256,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) {