mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 18:25:10 +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:
@@ -79,13 +79,12 @@ typedef struct {
|
||||
uint64_t first_usable_lba;
|
||||
uint64_t last_usable_lba;
|
||||
Guid disk_uuid;
|
||||
|
||||
uint64_t entries_lba;
|
||||
uint32_t number_of_entries;
|
||||
uint32_t size_of_entry;
|
||||
uint32_t entries_crc32;
|
||||
uint8_t reserved_padding[]; /* entire sector reserved for header */
|
||||
} GptHeader;
|
||||
} __attribute__((packed)) GptHeader;
|
||||
|
||||
/* GPT partition entry defines the starting and ending LBAs of a partition.
|
||||
* It also contains the unique GUID, type, and attribute bits.
|
||||
@@ -100,6 +99,6 @@ typedef struct {
|
||||
uint64_t attributes;
|
||||
uint16_t name[36]; /* UTF-16 encoded partition name */
|
||||
uint8_t reserved[]; /* nothing, really */
|
||||
} GptEntry;
|
||||
} __attribute__((packed)) GptEntry;
|
||||
|
||||
#endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */
|
||||
|
||||
Reference in New Issue
Block a user