Re: Regression parsing GPT (EFI) partition tables

From: Bill Richardson
Date: Thu Oct 10 2013 - 17:53:59 EST


I'm about to go offline for a week, but here are some thoughts.

The GPT spec is over-constrained. It says that the secondary GPT
header must be in the last LBA of the disk, yet it also says that both
primary and secondary headers must point to each other using their
AlternateLBA fields. We don't need both of those rules - and the spec
is unclear what it means if the headers *don't* point to each other,
or if they do but from the wrong place.

Chrome OS install images are created in a binary file, so the ending
LBAs are just the last LBA in the binary image, and that's where the
primary GPT header's AlternateLBA field points. When we dd that image
onto a USB or SD card and boot it, the secondary GPT header is not at
the end of the disk. The primary GPT header is otherwise valid, so we
boot it anyway and the chromeos-install process creates valid primary
and secondary headers (with cross-pointing AlternateLBA fields) on the
fixed drive.

That bootable binary image does have a protective MBR (partition type
0xEE), but again the extent of it is only that of the original binary,
not the USB drive it was copied onto.

Chrome OS BIOS pays no attention *at all* to the legacy MBR, or to the
AlternateLBA fields of either GPT header. It only looks for the GPT
headers in LBA 1 and LBA <last>.

The tool that we use to create the partition tables is called "cgpt". To build:

git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference
cd vboot_reference
make
./build/cgpt/cgpt help

We wrote cgpt ourselves because we wanted to use the same small
GPT-aware library in the BIOS that we use to create and test disk
images.


Bill
--
Art for Art's Sake
Engineering for Money
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/