[U-Boot] [PATCH v4 2/2] efi_loader: update runtime services table crc32

Heinrich Schuchardt xypron.glpk at gmx.de
Sun Jul 29 07:49:04 UTC 2018


The crc32 of the runtime services table must be updated after detaching.

efi_update_table_header_crc32() must be __efi_runtime. So move it to
efi_runtime.c

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
v3
	new patch
v4:
	rebase on current master
---
 include/efi_loader.h          |  3 +++
 lib/efi_loader/efi_boottime.c | 12 ------------
 lib/efi_loader/efi_runtime.c  | 15 +++++++++++++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 57ca5502726..f162adfff7e 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -417,6 +417,9 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2)
 #define __efi_runtime_data __attribute__ ((section (".data.efi_runtime")))
 #define __efi_runtime __attribute__ ((section (".text.efi_runtime")))
 
+/* Update CRC32 in table header */
+void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table);
+
 /* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region
  * to make it available at runtime */
 efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len);
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index b9e54f551a4..618e8a8d8cf 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -153,18 +153,6 @@ const char *__efi_nesting_dec(void)
 	return indent_string(--nesting_level);
 }
 
-/**
- * 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
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 06958f23fa1..351db8d8ed5 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -84,6 +84,18 @@ struct elf_rela {
  * handle a good number of runtime callbacks
  */
 
+/**
+ * efi_update_table_header_crc32() - Update crc32 in table header
+ *
+ * @table:	EFI table
+ */
+void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table)
+{
+	table->crc32 = 0;
+	table->crc32 = crc32(0, (const unsigned char *)table,
+			     table->headersize);
+}
+
 static void EFIAPI efi_reset_system_boottime(
 			enum efi_reset_type reset_type,
 			efi_status_t reset_status,
@@ -273,6 +285,9 @@ static void efi_runtime_detach(ulong offset)
 		debug("%s: Setting %p to %lx\n", __func__, p, newaddr);
 		*p = newaddr;
 	}
+
+	/* Update crc32 */
+	efi_update_table_header_crc32(&efi_runtime_services.hdr);
 }
 
 /* Relocate EFI runtime to uboot_reloc_base = offset */
-- 
2.18.0



More information about the U-Boot mailing list