mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
This fixes the EFI BIOS boot problems introduced with cgpt.
There were two changes. First, we need to pack the GPT header to make it match the spec (duh). Second, there's a subtle bug in how the BIOS recovers from corrupted headers. The EFI spec says that the primary GPT header must be at sector 1 (counting from zero) and the secondary GPT header must be at the last sector on the drive. The BIOS correctly looks in those locations to find the headers. However, if the secondary GPT header is invalid (as it usually is due to our build process), the BIOS is supposed to update it from the primary header. In this case, rather than write to the last sector on the drive where it just looked, the BIOS trusts the alternate_lba field of the primary header. That field is supposed to point to the secondary header location, but the BIOS just blindly uses it no matter where it points. The cgpt tool wasn't initializing that field, so it pointed to sector 0, which is the PMBR. The BIOS overwrote that, resulting in an unbootable drive. Review URL: http://codereview.chromium.org/2844006
This commit is contained in:
@@ -88,6 +88,7 @@ int cmd_create(int argc, char *argv[]) {
|
||||
h->revision = GPT_HEADER_REVISION;
|
||||
h->size = sizeof(GptHeader);
|
||||
h->my_lba = 1;
|
||||
h->alternate_lba = drive.gpt.drive_sectors - 1;
|
||||
h->first_usable_lba = 1 + 1 + GPT_ENTRIES_SECTORS;
|
||||
h->last_usable_lba = drive.gpt.drive_sectors - 1 - GPT_ENTRIES_SECTORS - 1;
|
||||
uuid_generate((uint8_t *)&h->disk_uuid);
|
||||
|
||||
Reference in New Issue
Block a user