Commit 6b02fa59 authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Linus Torvalds

partitions/efi: loosen check fot pmbr size in lba

Matt found that commit 27a7c642 ("partitions/efi: account for pmbr
size in lba") caused his GPT formatted eMMC device not to boot.  The
reason is that this commit enforced Linux to always check the lesser of
the whole disk or 2Tib for the pMBR size in LBA.  While most disk
partitioning tools out there create a pMBR with these characteristics,
Microsoft does not, as it always sets the entry to the maximum 32-bit
limitation - even though a drive may be smaller than that[1].

Loosen this check and only verify that the size is either the whole disk
or 0xFFFFFFFF.  No tool in its right mind would set it to any value
other than these.

[1] http://thestarman.pcministry.com/asm/mbr/GPT.htm#GPTPTReported-and-tested-by: default avatarMatt Porter <matt.porter@linaro.org>
Signed-off-by: default avatarDavidlohr Bueso <davidlohr@hp.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3711d86a
...@@ -186,6 +186,7 @@ static inline int pmbr_part_valid(gpt_mbr_record *part) ...@@ -186,6 +186,7 @@ static inline int pmbr_part_valid(gpt_mbr_record *part)
*/ */
static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors) static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors)
{ {
uint32_t sz = 0;
int i, part = 0, ret = 0; /* invalid by default */ int i, part = 0, ret = 0; /* invalid by default */
if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE) if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
...@@ -216,12 +217,15 @@ static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors) ...@@ -216,12 +217,15 @@ static int is_pmbr_valid(legacy_mbr *mbr, sector_t total_sectors)
/* /*
* Protective MBRs take up the lesser of the whole disk * Protective MBRs take up the lesser of the whole disk
* or 2 TiB (32bit LBA), ignoring the rest of the disk. * or 2 TiB (32bit LBA), ignoring the rest of the disk.
* Some partitioning programs, nonetheless, choose to set
* the size to the maximum 32-bit limitation, disregarding
* the disk size.
* *
* Hybrid MBRs do not necessarily comply with this. * Hybrid MBRs do not necessarily comply with this.
*/ */
if (ret == GPT_MBR_PROTECTIVE) { if (ret == GPT_MBR_PROTECTIVE) {
if (le32_to_cpu(mbr->partition_record[part].size_in_lba) != sz = le32_to_cpu(mbr->partition_record[part].size_in_lba);
min((uint32_t) total_sectors - 1, 0xFFFFFFFF)) if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF)
ret = 0; ret = 0;
} }
done: done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment