diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/charset.c | 4 | ||||
-rw-r--r-- | lib/efi_loader/efi_bootmgr.c | 141 | ||||
-rw-r--r-- | lib/efi_loader/efi_disk.c | 52 | ||||
-rw-r--r-- | lib/efi_loader/efi_tcg2.c | 19 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_tcg2.c | 97 | ||||
-rw-r--r-- | lib/smbios-parser.c | 9 | ||||
-rw-r--r-- | lib/uuid.c | 4 |
7 files changed, 215 insertions, 111 deletions
diff --git a/lib/charset.c b/lib/charset.c index 89057ef7ce..2b43175b1d 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -570,6 +570,10 @@ int utf8_to_utf32_stream(u8 c, char *buffer) } if (pos == end) return 0; + /* + * Appending the byte lead to an invalid UTF-8 byte sequence. + * Consider it as the start of a new code sequence. + */ *buffer = 0; } } diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 68d7db5ea3..4ac519228a 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -294,14 +294,17 @@ err: } /** - * check_disk_has_default_file() - load the default file + * fill_default_file_path() - get fallback boot device path for block device + * + * Provide the device path to the fallback UEFI boot file, e.g. + * EFI/BOOT/BOOTAA64.EFI if that file exists on the block device @blk. * * @blk: pointer to the UCLASS_BLK udevice - * @dp: pointer to default file device path + * @dp: pointer to store the fallback boot device path * Return: status code */ -static efi_status_t check_disk_has_default_file(struct udevice *blk, - struct efi_device_path **dp) +static efi_status_t fill_default_file_path(struct udevice *blk, + struct efi_device_path **dp) { efi_status_t ret; struct udevice *partition; @@ -348,7 +351,7 @@ static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size, if (!ramdisk_blk) return EFI_LOAD_ERROR; - ret = check_disk_has_default_file(ramdisk_blk, dp); + ret = fill_default_file_path(ramdisk_blk, dp); if (ret != EFI_SUCCESS) { log_info("Cannot boot from downloaded image\n"); goto err; @@ -547,6 +550,50 @@ err: } /** + * try_load_from_media() - load file from media + * + * @file_path: file path + * @handle_img: on return handle for the newly installed image + * + * If @file_path contains a file name, load the file. + * If @file_path does not have a file name, search the architecture-specific + * fallback boot file and load it. + * TODO: If the FilePathList[0] device does not support + * EFI_SIMPLE_FILE_SYSTEM_PROTOCOL but supports EFI_BLOCK_IO_PROTOCOL, + * call EFI_BOOT_SERVICES.ConnectController() + * TODO: FilePathList[0] device supports the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL + * not based on EFI_BLOCK_IO_PROTOCOL + * + * Return: status code + */ +static efi_status_t try_load_from_media(struct efi_device_path *file_path, + efi_handle_t *handle_img) +{ + efi_handle_t handle_blkdev; + efi_status_t ret = EFI_SUCCESS; + struct efi_device_path *rem, *dp = NULL; + struct efi_device_path *final_dp = file_path; + + handle_blkdev = efi_dp_find_obj(file_path, &efi_block_io_guid, &rem); + if (handle_blkdev) { + if (rem->type == DEVICE_PATH_TYPE_END) { + /* no file name present, try default file */ + ret = fill_default_file_path(handle_blkdev->dev, &dp); + if (ret != EFI_SUCCESS) + return ret; + + final_dp = dp; + } + } + + ret = EFI_CALL(efi_load_image(true, efi_root, final_dp, NULL, 0, handle_img)); + + efi_free_pool(dp); + + return ret; +} + +/** * try_load_entry() - try to load image for boot option * * Attempt to load load-option number 'n', returning device_path and file_path @@ -580,7 +627,6 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, } if (lo.attributes & LOAD_OPTION_ACTIVE) { - struct efi_device_path *file_path; u32 attributes; log_debug("trying to load \"%ls\" from %pD\n", lo.label, @@ -597,10 +643,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, else ret = EFI_LOAD_ERROR; } else { - file_path = expand_media_path(lo.file_path); - ret = EFI_CALL(efi_load_image(true, efi_root, file_path, - NULL, 0, handle)); - efi_free_pool(file_path); + ret = try_load_from_media(lo.file_path, handle); } if (ret != EFI_SUCCESS) { log_warning("Loading %ls '%ls' failed\n", @@ -731,22 +774,26 @@ error: } /** - * efi_bootmgr_enumerate_boot_option() - enumerate the possible bootable media + * efi_bootmgr_enumerate_boot_options() - enumerate the possible bootable media * * @opt: pointer to the media boot option structure - * @volume_handles: pointer to the efi handles - * @count: number of efi handle + * @index: index of the opt array to store the boot option + * @handles: pointer to block device handles + * @count: On entry number of handles to block devices. + * On exit number of boot options. + * @removable: flag to parse removable only * Return: status code */ -static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boot_option *opt, - efi_handle_t *volume_handles, - efi_status_t count) +static efi_status_t +efi_bootmgr_enumerate_boot_options(struct eficonfig_media_boot_option *opt, + efi_uintn_t index, efi_handle_t *handles, + efi_uintn_t *count, bool removable) { - u32 i; + u32 i, num = index; struct efi_handler *handler; efi_status_t ret = EFI_SUCCESS; - for (i = 0; i < count; i++) { + for (i = 0; i < *count; i++) { u16 *p; u16 dev_name[BOOTMENU_DEVICE_NAME_MAX]; char *optional_data; @@ -754,8 +801,18 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo char buf[BOOTMENU_DEVICE_NAME_MAX]; struct efi_device_path *device_path; struct efi_device_path *short_dp; + struct efi_block_io *blkio; + + ret = efi_search_protocol(handles[i], &efi_block_io_guid, &handler); + blkio = handler->protocol_interface; + + if (blkio->media->logical_partition) + continue; - ret = efi_search_protocol(volume_handles[i], &efi_guid_device_path, &handler); + if (removable != (blkio->media->removable_media != 0)) + continue; + + ret = efi_search_protocol(handles[i], &efi_guid_device_path, &handler); if (ret != EFI_SUCCESS) continue; ret = efi_protocol_open(handler, (void **)&device_path, @@ -763,7 +820,7 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo if (ret != EFI_SUCCESS) continue; - ret = efi_disk_get_device_name(volume_handles[i], buf, BOOTMENU_DEVICE_NAME_MAX); + ret = efi_disk_get_device_name(handles[i], buf, BOOTMENU_DEVICE_NAME_MAX); if (ret != EFI_SUCCESS) continue; @@ -787,17 +844,23 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo * to store guid, instead of realloc the load_option. */ lo.optional_data = "1234567"; - opt[i].size = efi_serialize_load_option(&lo, (u8 **)&opt[i].lo); - if (!opt[i].size) { + opt[num].size = efi_serialize_load_option(&lo, (u8 **)&opt[num].lo); + if (!opt[num].size) { ret = EFI_OUT_OF_RESOURCES; goto out; } /* set the guid */ - optional_data = (char *)opt[i].lo + (opt[i].size - u16_strsize(u"1234567")); + optional_data = (char *)opt[num].lo + (opt[num].size - u16_strsize(u"1234567")); memcpy(optional_data, &efi_guid_bootmenu_auto_generated, sizeof(efi_guid_t)); + num++; + + if (num >= *count) + break; } out: + *count = num; + return ret; } @@ -1026,8 +1089,7 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index) /** * efi_bootmgr_update_media_device_boot_option() - generate the media device boot option * - * This function enumerates all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL - * and generate the bootmenu entries. + * This function enumerates all BlockIo devices and add the boot option for it. * This function also provide the BOOT#### variable maintenance for * the media device entries. * - Automatically create the BOOT#### variable for the newly detected device, @@ -1042,14 +1104,14 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) { u32 i; efi_status_t ret; - efi_uintn_t count; - efi_handle_t *volume_handles = NULL; + efi_uintn_t count, num, total; + efi_handle_t *handles = NULL; struct eficonfig_media_boot_option *opt = NULL; ret = efi_locate_handle_buffer_int(BY_PROTOCOL, - &efi_simple_file_system_protocol_guid, + &efi_block_io_guid, NULL, &count, - (efi_handle_t **)&volume_handles); + (efi_handle_t **)&handles); if (ret != EFI_SUCCESS) goto out; @@ -1059,23 +1121,32 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) goto out; } - /* enumerate all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */ - ret = efi_bootmgr_enumerate_boot_option(opt, volume_handles, count); + /* parse removable block io followed by fixed block io */ + num = count; + ret = efi_bootmgr_enumerate_boot_options(opt, 0, handles, &num, true); if (ret != EFI_SUCCESS) goto out; + total = num; + num = count; + ret = efi_bootmgr_enumerate_boot_options(opt, total, handles, &num, false); + if (ret != EFI_SUCCESS) + goto out; + + total = num; + /* * System hardware configuration may vary depending on the user setup. * The boot option is automatically added by the bootmenu. * If the device is not attached to the system, the boot option needs * to be deleted. */ - ret = efi_bootmgr_delete_invalid_boot_option(opt, count); + ret = efi_bootmgr_delete_invalid_boot_option(opt, total); if (ret != EFI_SUCCESS) goto out; /* add non-existent boot option */ - for (i = 0; i < count; i++) { + for (i = 0; i < total; i++) { u32 boot_index; u16 var_name[9]; @@ -1104,11 +1175,11 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) out: if (opt) { - for (i = 0; i < count; i++) + for (i = 0; i < total; i++) free(opt[i].lo); } free(opt); - efi_free_pool(volume_handles); + efi_free_pool(handles); if (ret == EFI_NOT_FOUND) return EFI_SUCCESS; diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 013842f077..b1739d9920 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -371,6 +371,20 @@ static int efi_fs_exists(struct blk_desc *desc, int part) return 1; } +static void efi_disk_free_diskobj(struct efi_disk_obj *diskobj) +{ + struct efi_device_path *dp = diskobj->dp; + struct efi_simple_file_system_protocol *volume = diskobj->volume; + + /* + * ignore error of efi_delete_handle() since this function + * is expected to be called in error path. + */ + efi_delete_handle(&diskobj->header); + efi_free_pool(dp); + free(volume); +} + /** * efi_disk_add_dev() - create a handle for a partition or disk * @@ -528,9 +542,7 @@ static efi_status_t efi_disk_add_dev( } return EFI_SUCCESS; error: - efi_delete_handle(&diskobj->header); - free(diskobj->volume); - free(diskobj); + efi_disk_free_diskobj(diskobj); return ret; } @@ -569,8 +581,7 @@ static int efi_disk_create_raw(struct udevice *dev, efi_handle_t agent_handle) return ret; } if (efi_link_dev(&disk->header, dev)) { - efi_free_pool(disk->dp); - efi_delete_handle(&disk->header); + efi_disk_free_diskobj(disk); return -EINVAL; } @@ -624,8 +635,9 @@ static int efi_disk_create_part(struct udevice *dev, efi_handle_t agent_handle) return -1; } if (efi_link_dev(&disk->header, dev)) { - efi_free_pool(disk->dp); - efi_delete_handle(&disk->header); + efi_disk_free_diskobj(disk); + + /* TODO: closing the parent EFI_BLOCK_IO_PROTOCOL is missing. */ return -1; } @@ -707,7 +719,9 @@ int efi_disk_remove(void *ctx, struct event *event) struct udevice *dev = event->data.dm.dev; efi_handle_t handle; struct blk_desc *desc; + struct efi_device_path *dp = NULL; struct efi_disk_obj *diskobj = NULL; + struct efi_simple_file_system_protocol *volume = NULL; efi_status_t ret; if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) @@ -717,25 +731,35 @@ int efi_disk_remove(void *ctx, struct event *event) switch (id) { case UCLASS_BLK: desc = dev_get_uclass_plat(dev); - if (desc && desc->uclass_id != UCLASS_EFI_LOADER) - diskobj = container_of(handle, struct efi_disk_obj, - header); + if (desc && desc->uclass_id == UCLASS_EFI_LOADER) + /* + * EFI application/driver manages the EFI handle, + * no need to delete EFI handle. + */ + return 0; + + diskobj = (struct efi_disk_obj *)handle; break; case UCLASS_PARTITION: - diskobj = container_of(handle, struct efi_disk_obj, header); + diskobj = (struct efi_disk_obj *)handle; + + /* TODO: closing the parent EFI_BLOCK_IO_PROTOCOL is missing. */ + break; default: return 0; } + dp = diskobj->dp; + volume = diskobj->volume; + ret = efi_delete_handle(handle); /* Do not delete DM device if there are still EFI drivers attached. */ if (ret != EFI_SUCCESS) return -1; - if (diskobj) - efi_free_pool(diskobj->dp); - + efi_free_pool(dp); + free(volume); dev_tag_del(dev, DM_TAG_EFI); return 0; diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 8db35d0b3c..85562c50a1 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1075,12 +1075,17 @@ error: */ static efi_status_t tcg2_measure_smbios(struct udevice *dev, - const struct smbios_entry *entry) + const struct smbios3_entry *entry) { efi_status_t ret; struct smbios_header *smbios_copy; struct smbios_handoff_table_pointers2 *event = NULL; u32 event_size; + const char smbios3_anchor[] = "_SM3_"; + + /* We only support SMBIOS 3.0 Entry Point structure */ + if (memcmp(entry->anchor, smbios3_anchor, sizeof(smbios3_anchor) - 1)) + return EFI_UNSUPPORTED; /* * TCG PC Client PFP Spec says @@ -1093,7 +1098,7 @@ tcg2_measure_smbios(struct udevice *dev, */ event_size = sizeof(struct smbios_handoff_table_pointers2) + FIELD_SIZEOF(struct efi_configuration_table, guid) + - entry->struct_table_length; + entry->max_struct_size; event = calloc(1, event_size); if (!event) { ret = EFI_OUT_OF_RESOURCES; @@ -1104,11 +1109,11 @@ tcg2_measure_smbios(struct udevice *dev, memcpy(event->table_description, SMBIOS_HANDOFF_TABLE_DESC, sizeof(SMBIOS_HANDOFF_TABLE_DESC)); put_unaligned_le64(1, &event->number_of_tables); - guidcpy(&event->table_entry[0].guid, &smbios_guid); + guidcpy(&event->table_entry[0].guid, &smbios3_guid); smbios_copy = (struct smbios_header *)((uintptr_t)&event->table_entry[0].table); memcpy(&event->table_entry[0].table, (void *)((uintptr_t)entry->struct_table_address), - entry->struct_table_length); + entry->max_struct_size); smbios_prepare_measurement(entry, smbios_copy); @@ -1133,7 +1138,7 @@ static void *find_smbios_table(void) u32 i; for (i = 0; i < systab.nr_tables; i++) { - if (!guidcmp(&smbios_guid, &systab.tables[i].guid)) + if (!guidcmp(&smbios3_guid, &systab.tables[i].guid)) return systab.tables[i].table; } @@ -1360,7 +1365,7 @@ efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *ha u32 pcr_index; struct udevice *dev; u32 event = 0; - struct smbios_entry *entry; + struct smbios3_entry *entry; if (!is_tcg2_protocol_installed()) return EFI_SUCCESS; @@ -1382,7 +1387,7 @@ efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *ha if (ret != EFI_SUCCESS) goto out; - entry = (struct smbios_entry *)find_smbios_table(); + entry = (struct smbios3_entry *)find_smbios_table(); if (entry) { ret = tcg2_measure_smbios(dev, entry); if (ret != EFI_SUCCESS) diff --git a/lib/efi_selftest/efi_selftest_tcg2.c b/lib/efi_selftest/efi_selftest_tcg2.c index 67a886efaa..fb8b997653 100644 --- a/lib/efi_selftest/efi_selftest_tcg2.c +++ b/lib/efi_selftest/efi_selftest_tcg2.c @@ -126,41 +126,40 @@ static u8 boot_order[] = {0x02, 0x10, 0x00, 0x10, 0x01, 0x10}; static void *orig_smbios_table; static u64 dmi_addr = U32_MAX; -#define SMBIOS_ENTRY_HEADER_SIZE 0x20 +#define SMBIOS3_ENTRY_HEADER_SIZE 0x18 /* smbios table for the measurement test */ -static u8 smbios_table_test[] = { -0x5f, 0x53, 0x4d, 0x5f, 0x2c, 0x1f, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x5f, 0x44, 0x4d, 0x49, 0x5f, 0xe4, 0x5c, 0x01, -0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, -0x01, 0x02, 0x00, 0x00, 0x03, 0x00, 0x80, 0x08, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0c, 0x15, 0x0a, 0xff, 0xff, 0x55, 0x2d, 0x42, 0x6f, -0x6f, 0x74, 0x00, 0x32, 0x30, 0x32, 0x31, 0x2e, 0x31, 0x30, 0x2d, 0x72, -0x63, 0x34, 0x2d, 0x30, 0x30, 0x30, 0x30, 0x35, 0x2d, 0x67, 0x37, 0x32, -0x37, 0x63, 0x33, 0x66, 0x33, 0x32, 0x35, 0x39, 0x2d, 0x64, 0x69, 0x72, -0x74, 0x79, 0x00, 0x31, 0x30, 0x2f, 0x30, 0x31, 0x2f, 0x32, 0x30, 0x32, -0x31, 0x00, 0x00, 0x01, 0x1b, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x31, -0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, -0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x50, 0x72, -0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, -0x37, 0x38, 0x00, 0x00, 0x02, 0x0e, 0x02, 0x00, 0x01, 0x02, 0x00, 0x04, -0x03, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, -0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x50, 0x72, -0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, -0x33, 0x33, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, -0x00, 0x03, 0x15, 0x03, 0x00, 0x01, 0x03, 0x00, 0x02, 0x03, 0x03, 0x03, -0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x6e, -0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, -0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, -0x00, 0x04, 0x30, 0x04, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x01, 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, 0x04, -0x04, 0x04, 0x08, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, -0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, 0x33, -0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, -0x33, 0x33, 0x00, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x00, -0x00, 0x20, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x7f, 0x04, 0x06, 0x00, 0x00, 0x00 +static u8 smbios3_table_test[] = { +0x5f, 0x53, 0x4d, 0x33, 0x5f, 0x00, 0x18, 0x03, 0x07, 0x00, 0x01, 0x00, +0x5c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x18, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x03, 0x00, 0x80, 0x08, +0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x15, 0x0a, 0xff, 0xff, +0x55, 0x2d, 0x42, 0x6f, 0x6f, 0x74, 0x00, 0x32, 0x30, 0x32, 0x31, 0x2e, +0x31, 0x30, 0x2d, 0x72, 0x63, 0x34, 0x2d, 0x30, 0x30, 0x30, 0x30, 0x35, +0x2d, 0x67, 0x37, 0x32, 0x37, 0x63, 0x33, 0x66, 0x33, 0x32, 0x35, 0x39, +0x2d, 0x64, 0x69, 0x72, 0x74, 0x79, 0x00, 0x31, 0x30, 0x2f, 0x30, 0x31, +0x2f, 0x32, 0x30, 0x32, 0x31, 0x00, 0x00, 0x01, 0x1b, 0x01, 0x00, 0x01, +0x02, 0x00, 0x03, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x55, 0x6e, +0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, +0x6e, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x31, 0x32, +0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x00, 0x02, 0x0e, 0x02, 0x00, +0x01, 0x02, 0x00, 0x04, 0x03, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x55, 0x6e, +0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, +0x6e, 0x20, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x33, 0x33, +0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, +0x36, 0x37, 0x38, 0x00, 0x00, 0x03, 0x15, 0x03, 0x00, 0x01, 0x03, 0x00, +0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, +0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, +0x33, 0x33, 0x33, 0x00, 0x00, 0x04, 0x30, 0x04, 0x00, 0x00, 0x03, 0x02, +0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0x02, 0x03, 0x04, 0x04, 0x04, 0x08, 0x00, 0x00, 0x02, 0x00, 0x08, +0x00, 0x08, 0x00, 0x01, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, +0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x33, 0x33, +0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x35, 0x35, 0x35, 0x35, 0x35, +0x35, 0x35, 0x35, 0x00, 0x00, 0x20, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x04, 0x06, 0x00, 0x00, 0x00 }; #define IDX_ARRAY_SZ 3 /* support 24 PCRs */ @@ -179,10 +178,10 @@ static u8 expected_pcrs[EFI_TCG2_MAX_PCR_INDEX + 1][TPM2_SHA256_DIGEST_SIZE] = { 0x7b, 0xb9, 0xfe, 0xa1, 0xcd, 0x64, 0x49, 0xdd, 0xed, 0xe2, 0x65, 0x82, 0xc5, 0x3e, 0xf4, 0xc4}, - {0xf5, 0x79, 0xf3, 0x20, 0x62, 0x6e, 0x8b, 0x58, - 0x62, 0xa3, 0x4e, 0x2f, 0xb7, 0x10, 0xac, 0x34, - 0x4e, 0x68, 0x94, 0x37, 0x87, 0x29, 0xc4, 0xbe, - 0xa3, 0xc4, 0xd9, 0x14, 0x2b, 0x66, 0x79, 0x9b}, + {0x75, 0xb5, 0x91, 0x54, 0x12, 0xa8, 0xa4, 0x25, + 0x73, 0x79, 0xa7, 0x47, 0xd9, 0x32, 0x54, 0x78, + 0x9a, 0x80, 0x3f, 0xa8, 0x34, 0xfe, 0xd2, 0xae, + 0x76, 0xd3, 0x16, 0x4a, 0xb2, 0x03, 0xac, 0xe6}, {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea, 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d, @@ -543,7 +542,7 @@ static void *find_smbios_table(const struct efi_system_table *systable) u32 i; for (i = 0; i < systable->nr_tables; i++) { - if (!guidcmp(&smbios_guid, &systable->tables[i].guid)) + if (!guidcmp(&smbios3_guid, &systable->tables[i].guid)) return systable->tables[i].table; } @@ -558,14 +557,12 @@ static void *find_smbios_table(const struct efi_system_table *systable) */ static efi_status_t setup_smbios_table(const struct efi_system_table *systable) { - struct smbios_entry *se; + struct smbios3_entry *se; efi_status_t ret; /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */ void *dmi; - char *istart; - int isize; - if (sizeof(smbios_table_test) > EFI_PAGE_SIZE) + if (sizeof(smbios3_table_test) > EFI_PAGE_SIZE) return EFI_OUT_OF_RESOURCES; orig_smbios_table = find_smbios_table(systable); @@ -586,19 +583,15 @@ static efi_status_t setup_smbios_table(const struct efi_system_table *systable) dmi = (void *)(uintptr_t)dmi_addr; se = dmi; - boottime->copy_mem(se, smbios_table_test, sizeof(smbios_table_test)); + boottime->copy_mem(se, smbios3_table_test, sizeof(smbios3_table_test)); /* update smbios table start address */ - se->struct_table_address = (uintptr_t)((u8 *)dmi + SMBIOS_ENTRY_HEADER_SIZE); + se->struct_table_address = (uintptr_t)((u8 *)dmi + SMBIOS3_ENTRY_HEADER_SIZE); - /* calculate checksums */ - istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; - isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET; - se->intermediate_checksum = table_compute_checksum(istart, isize); - se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); + se->checksum = table_compute_checksum(se, sizeof(struct smbios3_entry)); /* Install SMBIOS information as configuration table */ - ret = boottime->install_configuration_table(&smbios_guid, dmi); + ret = boottime->install_configuration_table(&smbios3_guid, dmi); if (ret != EFI_SUCCESS) { efi_st_error("Cannot install SMBIOS table\n"); boottime->free_pages(dmi_addr, 1); @@ -992,7 +985,7 @@ static int efi_st_tcg2_teardown(void) * If orig_smbios_table is NULL, calling install_configuration_table() * removes dummy SMBIOS table form systab. */ - r = boottime->install_configuration_table(&smbios_guid, orig_smbios_table); + r = boottime->install_configuration_table(&smbios3_guid, orig_smbios_table); if (r != EFI_SUCCESS) { efi_st_error("Failed to restore SMBOIS table\n"); return EFI_ST_FAILURE; diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c index ac9a367a87..f48d743657 100644 --- a/lib/smbios-parser.c +++ b/lib/smbios-parser.c @@ -223,21 +223,24 @@ static void clear_smbios_table(struct smbios_header *header, } } -void smbios_prepare_measurement(const struct smbios_entry *entry, +void smbios_prepare_measurement(const struct smbios3_entry *entry, struct smbios_header *smbios_copy) { u32 i, j; + void *table_end; struct smbios_header *header; + table_end = (void *)((u8 *)smbios_copy + entry->max_struct_size); + for (i = 0; i < ARRAY_SIZE(smbios_filter_tables); i++) { header = smbios_copy; - for (j = 0; j < entry->struct_count; j++) { + for (j = 0; (void *)header < table_end; j++) { if (header->type == smbios_filter_tables[i].type) break; header = get_next_header(header); } - if (j >= entry->struct_count) + if ((void *)header >= table_end) continue; clear_smbios_table(header, diff --git a/lib/uuid.c b/lib/uuid.c index 0be22bc05f..2d7d99535e 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -177,6 +177,10 @@ static const struct { SMBIOS_TABLE_GUID, }, { + "SMBIOS3 table", + SMBIOS3_TABLE_GUID, + }, + { "Runtime properties", EFI_RT_PROPERTIES_TABLE_GUID, }, |