summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-06-28 12:45:31 +0200
committerAlexander Graf <agraf@suse.de>2018-07-25 15:00:24 +0200
commit640adadf811e9c229ddec597595a00db3f5304b0 (patch)
tree5bc66727594be4185571bede4c91d8cf437d6380 /lib
parent0b386537a51d5ac6e2da022ade49424ecc50ffa1 (diff)
efi_loader: calculate crc32 for EFI tables
For the boot and runtime services tables and for the system table the crc32 has to be set in the header. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_boottime.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index c5d45dcc95..5fea8b1dbd 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -164,6 +164,18 @@ const char *__efi_nesting_dec(void)
}
/**
+ * efi_update_table_header_crc32() - Update CRC32 in table header
+ *
+ * @table: EFI table
+ */
+static void efi_update_table_header_crc32(struct efi_table_hdr *table)
+{
+ table->crc32 = 0;
+ table->crc32 = crc32(0, (const unsigned char *)table,
+ table->headersize);
+}
+
+/**
* efi_queue_event() - queue an EFI event
* @event: event to signal
* @check_tpl: check the TPL level
@@ -1901,9 +1913,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
systab.boottime = NULL;
/* Recalculate CRC32 */
- systab.hdr.crc32 = 0;
- systab.hdr.crc32 = crc32(0, (const unsigned char *)&systab,
- sizeof(struct efi_system_table));
+ efi_update_table_header_crc32(&systab.hdr);
/* Give the payload some time to boot */
efi_set_watchdog(0);
@@ -3056,7 +3066,7 @@ out:
return EFI_EXIT(r);
}
-static const struct efi_boot_services efi_boot_services = {
+static struct efi_boot_services efi_boot_services = {
.hdr = {
.signature = EFI_BOOT_SERVICES_SIGNATURE,
.revision = EFI_SPECIFICATION_VERSION,
@@ -3128,3 +3138,17 @@ struct efi_system_table __efi_runtime_data systab = {
.nr_tables = 0,
.tables = (void *)efi_conf_table,
};
+
+/**
+ * efi_initialize_system_table() - Initialize system table
+ *
+ * Return Value: status code
+ */
+efi_status_t efi_initialize_system_table(void)
+{
+ /* Set crc32 field in table headers */
+ efi_update_table_header_crc32(&systab.hdr);
+ efi_update_table_header_crc32(&efi_runtime_services.hdr);
+ efi_update_table_header_crc32(&efi_boot_services.hdr);
+ return EFI_SUCCESS;
+}