All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 0/2] efi_loader: correctly initialize system table crc32
@ 2018-07-29  7:49 Heinrich Schuchardt
  2018-07-29  7:49 ` [U-Boot] [PATCH v4 1/2] lib: crc32: mark function crc32() as __efi_runtime Heinrich Schuchardt
  2018-07-29  7:49 ` [U-Boot] [PATCH v4 2/2] efi_loader: update runtime services table crc32 Heinrich Schuchardt
  0 siblings, 2 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-07-29  7:49 UTC (permalink / raw)
  To: u-boot

Update the crc32 of the runtime services table when detaching.

Travis results where ok except for two file size limits exceeded:
https://travis-ci.org/xypron2/u-boot/builds/409390055

v4:
	Remove patches accepted for efi-next
	Rebase on current master
	Do not put functions into runtime data

Heinrich Schuchardt (2):
  lib: crc32: mark function crc32() as __efi_runtime
  efi_loader: update runtime services table crc32

 include/efi_loader.h          |  3 +++
 lib/crc32.c                   | 26 ++++++++++++++------------
 lib/efi_loader/efi_boottime.c | 12 ------------
 lib/efi_loader/efi_runtime.c  | 15 +++++++++++++++
 4 files changed, 32 insertions(+), 24 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v4 1/2] lib: crc32: mark function crc32() as __efi_runtime
  2018-07-29  7:49 [U-Boot] [PATCH v4 0/2] efi_loader: correctly initialize system table crc32 Heinrich Schuchardt
@ 2018-07-29  7:49 ` Heinrich Schuchardt
  2018-07-29  7:52   ` Bin Meng
  2018-07-29  7:49 ` [U-Boot] [PATCH v4 2/2] efi_loader: update runtime services table crc32 Heinrich Schuchardt
  1 sibling, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-07-29  7:49 UTC (permalink / raw)
  To: u-boot

The function crc32() is needed by the EFI subsystem at runtime. So it has
to be linked into the runtime section together with all dependencies.

Eliminate empty defines local and ZEXPORT.

Mark variables as static which are not exported.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v4:
	put all relevant functions into the runtime code section
	put none into the runtime data section
v3
	new patch
---
 lib/crc32.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/crc32.c b/lib/crc32.c
index 7f545fde4a0..4dab6226427 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -12,6 +12,7 @@
 #include <arpa/inet.h>
 #else
 #include <common.h>
+#include <efi_loader.h>
 #endif
 #include <compiler.h>
 #include <u-boot/crc.h>
@@ -21,16 +22,18 @@
 #endif
 #include "u-boot/zlib.h"
 
-#define local static
-#define ZEXPORT	/* empty */
+#ifdef USE_HOSTCC
+#define __efi_runtime
+#define __efi_runtime_data
+#endif
 
 #define tole(x) cpu_to_le32(x)
 
 #ifdef CONFIG_DYNAMIC_CRC_TABLE
 
-local int crc_table_empty = 1;
-local uint32_t crc_table[256];
-local void make_crc_table OF((void));
+static int __efi_runtime_data crc_table_empty = 1;
+static uint32_t __efi_runtime_data crc_table[256];
+static void __efi_runtime make_crc_table OF((void));
 
 /*
   Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
@@ -56,7 +59,7 @@ local void make_crc_table OF((void));
   the information needed to generate CRC's on data a byte at a time for all
   combinations of CRC register values and incoming bytes.
 */
-local void make_crc_table()
+static void __efi_runtime make_crc_table(void)
 {
   uint32_t c;
   int n, k;
@@ -83,7 +86,7 @@ local void make_crc_table()
  * Table of CRC-32's of all single-byte values (made by make_crc_table)
  */
 
-local const uint32_t crc_table[256] = {
+static const uint32_t __efi_runtime_data crc_table[256] = {
 tole(0x00000000L), tole(0x77073096L), tole(0xee0e612cL), tole(0x990951baL),
 tole(0x076dc419L), tole(0x706af48fL), tole(0xe963a535L), tole(0x9e6495a3L),
 tole(0x0edb8832L), tole(0x79dcb8a4L), tole(0xe0d5e91eL), tole(0x97d2d988L),
@@ -176,7 +179,7 @@ const uint32_t * ZEXPORT get_crc_table()
 /* No ones complement version. JFFS2 (and other things ?)
  * don't use ones compliment in their CRC calculations.
  */
-uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
+uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
 {
     const uint32_t *tab = crc_table;
     const uint32_t *b =(const uint32_t *)buf;
@@ -218,7 +221,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len)
 }
 #undef DO_CRC
 
-uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
+uint32_t __efi_runtime crc32(uint32_t crc, const Bytef *p, uInt len)
 {
      return crc32_no_comp(crc ^ 0xffffffffL, p, len) ^ 0xffffffffL;
 }
@@ -227,9 +230,8 @@ uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
  * Calculate the crc32 checksum triggering the watchdog every 'chunk_sz' bytes
  * of input.
  */
-uint32_t ZEXPORT crc32_wd (uint32_t crc,
-			   const unsigned char *buf,
-			   uInt len, uInt chunk_sz)
+uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len,
+		  uInt chunk_sz)
 {
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
 	const unsigned char *end, *curr;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v4 2/2] efi_loader: update runtime services table crc32
  2018-07-29  7:49 [U-Boot] [PATCH v4 0/2] efi_loader: correctly initialize system table crc32 Heinrich Schuchardt
  2018-07-29  7:49 ` [U-Boot] [PATCH v4 1/2] lib: crc32: mark function crc32() as __efi_runtime Heinrich Schuchardt
@ 2018-07-29  7:49 ` Heinrich Schuchardt
  1 sibling, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-07-29  7:49 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v4 1/2] lib: crc32: mark function crc32() as __efi_runtime
  2018-07-29  7:49 ` [U-Boot] [PATCH v4 1/2] lib: crc32: mark function crc32() as __efi_runtime Heinrich Schuchardt
@ 2018-07-29  7:52   ` Bin Meng
  0 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2018-07-29  7:52 UTC (permalink / raw)
  To: u-boot

Hi Heinrich,

On Sun, Jul 29, 2018 at 3:49 PM, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> The function crc32() is needed by the EFI subsystem at runtime. So it has
> to be linked into the runtime section together with all dependencies.
>
> Eliminate empty defines local and ZEXPORT.
>
> Mark variables as static which are not exported.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v4:
>         put all relevant functions into the runtime code section
>         put none into the runtime data section
> v3
>         new patch
> ---
>  lib/crc32.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
>

Is it possible to use linux kernel's lib/crc32.c? This way we can
future sync U-Boot's crc32 implementation with kernel's. Thanks!

Regards,
Bin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-29  7:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-29  7:49 [U-Boot] [PATCH v4 0/2] efi_loader: correctly initialize system table crc32 Heinrich Schuchardt
2018-07-29  7:49 ` [U-Boot] [PATCH v4 1/2] lib: crc32: mark function crc32() as __efi_runtime Heinrich Schuchardt
2018-07-29  7:52   ` Bin Meng
2018-07-29  7:49 ` [U-Boot] [PATCH v4 2/2] efi_loader: update runtime services table crc32 Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.