diff --git a/firmware/include/load_kernel_fw.h b/firmware/include/load_kernel_fw.h index 31c3081835..4cca8bd57b 100644 --- a/firmware/include/load_kernel_fw.h +++ b/firmware/include/load_kernel_fw.h @@ -44,6 +44,7 @@ typedef struct LoadKernelParams { * (1...M) */ uint64_t bootloader_address; /* Address of bootloader image in RAM */ uint64_t bootloader_size; /* Size of bootloader image in bytes */ + uint8_t partition_guid[16]; /* UniquePartitionGuid for boot partition */ } LoadKernelParams; int LoadKernel(LoadKernelParams* params); @@ -62,6 +63,7 @@ typedef struct KernelBootloaderOptions { uint64_t original_address; /* Absolute bootloader start adddress, * as returned from LoadKernel() in * LoadKernelParams.bootloader_start */ + uint8_t partition_guid[16]; /* UniquePartitionGuid for boot partition */ } KernelBootloaderOptions; diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c index c3fd1f3225..a0c1688649 100644 --- a/firmware/lib/cgptlib/cgptlib_internal.c +++ b/firmware/lib/cgptlib/cgptlib_internal.c @@ -346,3 +346,9 @@ void SetEntryTries(GptEntry* e, int tries) { e->attrs.fields.gpt_att |= (tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & CGPT_ATTRIBUTE_TRIES_MASK; } + +void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest) { + GptEntry* entries = (GptEntry*)gpt->primary_entries; + GptEntry* e = entries + gpt->current_kernel; + Memcpy(dest, &e->unique, sizeof(Guid)); +} diff --git a/firmware/lib/cgptlib/include/cgptlib_internal.h b/firmware/lib/cgptlib/include/cgptlib_internal.h index 95e5b4e75e..66ceef1388 100644 --- a/firmware/lib/cgptlib/include/cgptlib_internal.h +++ b/firmware/lib/cgptlib/include/cgptlib_internal.h @@ -112,4 +112,7 @@ int IsUnusedEntry(const GptEntry* e); /* Returns 1 if the entry is a Chrome OS kernel partition, else 0. */ int IsKernelEntry(const GptEntry* e); +/* Copies the current kernel partition's UniquePartitionGuid to the dest */ +void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest); + #endif /* VBOOT_REFERENCE_CGPTLIB_INTERNAL_H_ */ diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c index c04538039b..0420f2554f 100644 --- a/firmware/lib/vboot_kernel.c +++ b/firmware/lib/vboot_kernel.c @@ -10,12 +10,12 @@ #include "boot_device.h" #include "cgptlib.h" +#include "cgptlib_internal.h" #include "load_kernel_fw.h" #include "rollback_index.h" #include "utility.h" #include "vboot_common.h" - #define KBUF_SIZE 65536 /* Bytes to read at start of kernel partition */ @@ -131,7 +131,6 @@ int LoadKernel(LoadKernelParams* params) { /* Sanity Checks */ if (!params || - !params->header_sign_key_blob || !params->bytes_per_lba || !params->ending_lba || !params->kernel_buffer || @@ -350,6 +349,7 @@ int LoadKernel(LoadKernelParams* params) { * Adjust here, until cgptlib is fixed. */ good_partition = gpt.current_kernel + 1; params->partition_number = gpt.current_kernel + 1; + GetCurrentKernelUniqueGuid(&gpt, ¶ms->partition_guid); params->bootloader_address = preamble->bootloader_address; params->bootloader_size = preamble->bootloader_size; /* If we're in developer or recovery mode, there's no rollback diff --git a/firmware/version.c b/firmware/version.c index b5d9dca93d..e246bd94d3 100644 --- a/firmware/version.c +++ b/firmware/version.c @@ -1 +1 @@ -char* VbootVersion = "VBOOv=0249c1a3"; +char* VbootVersion = "VBOOv=5d5d1959"; diff --git a/utility/load_kernel_test.c b/utility/load_kernel_test.c index c391c61cdf..4ac9330b12 100644 --- a/utility/load_kernel_test.c +++ b/utility/load_kernel_test.c @@ -135,6 +135,25 @@ int main(int argc, char* argv[]) { printf("Partition number: %" PRIu64 "\n", lkp.partition_number); printf("Bootloader address: %" PRIu64 "\n", lkp.bootloader_address); printf("Bootloader size: %" PRIu64 "\n", lkp.bootloader_size); + printf("Partition guid: " + "%02x%02x%02x%02x-%02x%02x-%02x%02x" + "-%02x%02x-%02x%02x%02x%02x%02x%02x\n", + lkp.partition_guid[3], + lkp.partition_guid[2], + lkp.partition_guid[1], + lkp.partition_guid[0], + lkp.partition_guid[5], + lkp.partition_guid[4], + lkp.partition_guid[7], + lkp.partition_guid[6], + lkp.partition_guid[8], + lkp.partition_guid[9], + lkp.partition_guid[10], + lkp.partition_guid[11], + lkp.partition_guid[12], + lkp.partition_guid[13], + lkp.partition_guid[14], + lkp.partition_guid[15]); } fclose(image_file);