Skip to contentSkip to conversation

x86: Add implementations of setjmp() and longjmp()

PATCH Superseded Simon Glass 4 participants 41 messages Sep 25, 2016 – Nov 7, 2016

Subsystems (11)
Arm (32-bit) x86 Kbuild MIPS +7 more subsystems

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y	= start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y	+= interrupts.o cpu.o cpu_x86.o call64.o
+obj-y	+= interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +66 -0

66 lines not on this page · raw message

arch/x86/include/asm/setjmp.h new file +24 -0
new file mode 100644
index 0000000..deef67e
@@ -0,0 +1,24 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef __setjmp_h
+#define __setjmp_h
+
+struct jmp_buf_data {
+	unsigned int __ebx;
+	unsigned int __esp;
+	unsigned int __ebp;
+	unsigned int __esi;
+	unsigned int __edi;
+	unsigned int __eip;
+};
+
+int setjmp(struct jmp_buf_data *jmp_buf);
+void longjmp(struct jmp_buf_data *jmp_buf);
+
+#endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v2 2/8 efi: Use asmlinkage for EFIAPI

This is required for x86 and is also correct for ARM (since it is empty).

---

Changes in v2:
- Move efi.h changes to a new patch

 arch/avr32/include/asm/linkage.h      | 0
 arch/m68k/include/asm/linkage.h       | 0
 arch/microblaze/include/asm/linkage.h | 0
 arch/mips/include/asm/linkage.h       | 0
 arch/nios2/include/asm/linkage.h      | 0
 arch/openrisc/include/asm/linkage.h   | 0
 arch/sandbox/include/asm/linkage.h    | 0
 arch/sh/include/asm/linkage.h         | 0
 arch/sparc/include/asm/linkage.h      | 0
 include/efi.h                         | 3 ++-
 10 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 arch/avr32/include/asm/linkage.h
 create mode 100644 arch/m68k/include/asm/linkage.h
 create mode 100644 arch/microblaze/include/asm/linkage.h
 create mode 100644 arch/mips/include/asm/linkage.h
 create mode 100644 arch/nios2/include/asm/linkage.h
 create mode 100644 arch/openrisc/include/asm/linkage.h
 create mode 100644 arch/sandbox/include/asm/linkage.h
 create mode 100644 arch/sh/include/asm/linkage.h
 create mode 100644 arch/sparc/include/asm/linkage.h
arch/avr32/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/m68k/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/microblaze/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/mips/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/nios2/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/openrisc/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/sandbox/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/sh/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/sparc/include/asm/linkage.h new file +0 -0
new file mode 100644
index 0000000..e69de29
include/efi.h +2 -1
index 5a3b8cf..d07187c 100644
@@ -15,6 +15,7 @@
 #ifndef _EFI_H
 #define _EFI_H
 
+#include <linux/linkage.h>
 #include <linux/string.h>
 #include <linux/types.h>
 
@@ -22,7 +23,7 @@
 /* EFI uses the Microsoft ABI which is not the default for GCC */
 #define EFIAPI __attribute__((ms_abi))
 #else
-#define EFIAPI
+#define EFIAPI asmlinkage
 #endif
 
 struct efi_device_path;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH v2 2/8 efi: Use asmlinkage for EFIAPI

Quoted 20 lines · Simon Glass

This is required for x86 and is also correct for ARM (since it is empty).

---

Changes in v2:
- Move efi.h changes to a new patch

 arch/avr32/include/asm/linkage.h      | 0
 arch/m68k/include/asm/linkage.h       | 0
 arch/microblaze/include/asm/linkage.h | 0
 arch/mips/include/asm/linkage.h       | 0
 arch/nios2/include/asm/linkage.h      | 0
 arch/openrisc/include/asm/linkage.h   | 0
 arch/sandbox/include/asm/linkage.h    | 0
 arch/sh/include/asm/linkage.h         | 0
 arch/sparc/include/asm/linkage.h      | 0
 include/efi.h                         | 3 ++-
 10 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 arch/avr32/include/asm/linkage.h
Quoted 9 lines
 create mode 100644 arch/m68k/include/asm/linkage.h
 create mode 100644 arch/microblaze/include/asm/linkage.h
 create mode 100644 arch/mips/include/asm/linkage.h
 create mode 100644 arch/nios2/include/asm/linkage.h
 create mode 100644 arch/openrisc/include/asm/linkage.h
 create mode 100644 arch/sandbox/include/asm/linkage.h
 create mode 100644 arch/sh/include/asm/linkage.h
 create mode 100644 arch/sparc/include/asm/linkage.h
#4 lore raw

PATCH v2 3/8 efi: Fix missing EFIAPI specifiers

In reply to Simon Glass

These are missing in some functions. Add them to keep things consistent.

---

Changes in v2: None

 cmd/bootefi.c                 |  7 +++++--
 include/efi_loader.h          |  2 +-
 lib/efi_loader/efi_boottime.c |  5 +++--
 lib/efi_loader/efi_disk.c     | 13 +++++++------
 lib/efi_loader/efi_net.c      |  4 ++--
 5 files changed, 18 insertions(+), 13 deletions(-)
cmd/bootefi.c +5 -2
index 21fe42c..7b2e0b5 100644
@@ -15,6 +15,8 @@
 #include <libfdt_env.h>
 #include <memalign.h>
 #include <asm/global_data.h>
+#include <asm-generic/sections.h>
+#include <linux/linkage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -52,7 +54,7 @@ static struct efi_device_path_file_path bootefi_device_path[] = {
 	}
 };
 
-static efi_status_t bootefi_open_dp(void *handle, efi_guid_t *protocol,
+static efi_status_t EFIAPI bootefi_open_dp(void *handle, efi_guid_t *protocol,
 			void **protocol_interface, void *agent_handle,
 			void *controller_handle, uint32_t attributes)
 {
@@ -145,7 +147,8 @@ static void *copy_fdt(void *fdt)
  */
 static unsigned long do_bootefi_exec(void *efi, void *fdt)
 {
-	ulong (*entry)(void *image_handle, struct efi_system_table *st);
+	ulong (*entry)(void *image_handle, struct efi_system_table *st)
+		asmlinkage;
 	ulong fdt_pages, fdt_size, fdt_start, fdt_end;
 	bootm_headers_t img = { 0 };
 
include/efi_loader.h +1 -1
index 9738835..aa4ae0e 100644
@@ -93,7 +93,7 @@ void efi_net_set_dhcp_ack(void *pkt, int len);
  * Stub implementation for a protocol opener that just returns the handle as
  * interface
  */
-efi_status_t efi_return_handle(void *handle,
+efi_status_t EFIAPI efi_return_handle(void *handle,
 		efi_guid_t *protocol, void **protocol_interface,
 		void *agent_handle, void *controller_handle,
 		uint32_t attributes);
lib/efi_loader/efi_boottime.c +3 -2
index be6f5e8..798b566 100644
@@ -159,7 +159,7 @@ static struct {
 	u32 trigger_time;
 	u64 trigger_next;
 	unsigned long notify_tpl;
-	void (*notify_function) (void *event, void *context);
+	void (EFIAPI *notify_function) (void *event, void *context);
 	void *notify_context;
 } efi_event = {
 	/* Disable timers on bootup */
@@ -168,7 +168,8 @@ static struct {
 
 static efi_status_t EFIAPI efi_create_event(
 			enum efi_event_type type, ulong notify_tpl,
-			void (*notify_function) (void *event, void *context),
+			void (EFIAPI *notify_function) (void *event,
+							void *context),
 			void *notify_context, void **event)
 {
 	EFI_ENTRY("%d, 0x%lx, %p, %p", type, notify_tpl, notify_function,
lib/efi_loader/efi_disk.c +7 -6
index d8ddcc9..1e3dca4 100644
@@ -35,9 +35,10 @@ struct efi_disk_obj {
 	const struct blk_desc *desc;
 };
 
-static efi_status_t efi_disk_open_block(void *handle, efi_guid_t *protocol,
-			void **protocol_interface, void *agent_handle,
-			void *controller_handle, uint32_t attributes)
+static efi_status_t EFIAPI efi_disk_open_block(void *handle,
+			efi_guid_t *protocol, void **protocol_interface,
+			void *agent_handle, void *controller_handle,
+			uint32_t attributes)
 {
 	struct efi_disk_obj *diskobj = handle;
 
@@ -46,7 +47,7 @@ static efi_status_t efi_disk_open_block(void *handle, efi_guid_t *protocol,
 	return EFI_SUCCESS;
 }
 
-static efi_status_t efi_disk_open_dp(void *handle, efi_guid_t *protocol,
+static efi_status_t EFIAPI efi_disk_open_dp(void *handle, efi_guid_t *protocol,
 			void **protocol_interface, void *agent_handle,
 			void *controller_handle, uint32_t attributes)
 {
@@ -108,7 +109,7 @@ static efi_status_t EFIAPI efi_disk_rw_blocks(struct efi_block_io *this,
 	return EFI_EXIT(EFI_SUCCESS);
 }
 
-static efi_status_t efi_disk_read_blocks(struct efi_block_io *this,
+static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this,
 			u32 media_id, u64 lba, unsigned long buffer_size,
 			void *buffer)
 {
@@ -143,7 +144,7 @@ static efi_status_t efi_disk_read_blocks(struct efi_block_io *this,
 	return EFI_EXIT(r);
 }
 
-static efi_status_t efi_disk_write_blocks(struct efi_block_io *this,
+static efi_status_t EFIAPI efi_disk_write_blocks(struct efi_block_io *this,
 			u32 media_id, u64 lba, unsigned long buffer_size,
 			void *buffer)
 {
lib/efi_loader/efi_net.c +2 -2
index dd3b485..9199518 100644
@@ -191,7 +191,7 @@ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this,
 	return EFI_EXIT(EFI_SUCCESS);
 }
 
-static efi_status_t efi_net_open_dp(void *handle, efi_guid_t *protocol,
+static efi_status_t EFIAPI efi_net_open_dp(void *handle, efi_guid_t *protocol,
 			void **protocol_interface, void *agent_handle,
 			void *controller_handle, uint32_t attributes)
 {
@@ -203,7 +203,7 @@ static efi_status_t efi_net_open_dp(void *handle, efi_guid_t *protocol,
 	return EFI_SUCCESS;
 }
 
-static efi_status_t efi_net_open_pxe(void *handle, efi_guid_t *protocol,
+static efi_status_t EFIAPI efi_net_open_pxe(void *handle, efi_guid_t *protocol,
 			void **protocol_interface, void *agent_handle,
 			void *controller_handle, uint32_t attributes)
 {
Signature · 1 line
2.8.0.rc3.226.g39d4020
#6 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

In reply to Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +5 -2
index d07187c..3d58780 100644
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG	BITS_PER_LONG
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)
 #undef EFI_BITS_PER_LONG
 #define EFI_BITS_PER_LONG	64
 #endif
lib/efi/Makefile +2 -2
index e32dc14..9449600 100644
@@ -9,9 +9,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi_stub.o := -fpic -fshort-wchar
+CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB
 CFLAGS_REMOVE_efi.o := -mregparm=3 \
 	$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi.o := -fpic -fshort-wchar
+CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB
 
 extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
Signature · 1 line
2.8.0.rc3.226.g39d4020
#7 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Simon,

Quoted 23 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644

include/efi.h struct efi_device_path; · line 37

Quoted 10 lines
include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

Quoted 10 lines
include/efi.h +0 -0
 #undef EFI_BITS_PER_LONG
 #define EFI_BITS_PER_LONG      64
 #endif
lib/efi/Makefile +0 -0
index e32dc14..9449600 100644
@@ -9,9 +9,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \

lib/efi/Makefile obj-$(CONFIG_EFI_STUB) += efi_info.o

Quoted 10 lines
lib/efi/Makefile +2 -3
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi_stub.o := -fpic -fshort-wchar
+CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB
 CFLAGS_REMOVE_efi.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi.o := -fpic -fshort-wchar
+CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB
 
 extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
--

Regards,
Bin

#8 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Bin,

Quoted 29 lines · Bin Meng

Hi Simon,

Quoted 26 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
Quoted 9 lines

include/efi.h struct efi_device_path; · line 37

Quoted 7 lines
include/efi.h +5 -2
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

Quoted 19 lines
Quoted 19 lines
include/efi.h +0 -0
 #undef EFI_BITS_PER_LONG
 #define EFI_BITS_PER_LONG      64
 #endif
lib/efi/Makefile +2 -2
index e32dc14..9449600 100644
@@ -9,9 +9,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi_stub.o := -fpic -fshort-wchar
+CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB
 CFLAGS_REMOVE_efi.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi.o := -fpic -fshort-wchar
+CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB
 
Quoted 5 lines

lib/efi/Makefile obj-$(CONFIG_EFI_STUB) += efi_info.o

Quoted 2 lines
lib/efi/Makefile +0 -1
 extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
--

Regards,
Bin

Regards,
Simon

#9 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Simon,

Quoted 42 lines · Simon Glass

Hi Bin,

Quoted 29 lines · Bin Meng

Hi Simon,

Quoted 26 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
Quoted 9 lines

include/efi.h struct efi_device_path; · line 37

Quoted 7 lines
include/efi.h +5 -2
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

Quoted 4 lines

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as BITS_PER_LONG which is 32.

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
include/efi.h +0 -0
 #undef EFI_BITS_PER_LONG
 #define EFI_BITS_PER_LONG      64
 #endif
lib/efi/Makefile +2 -2
index e32dc14..9449600 100644
@@ -9,9 +9,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi_stub.o := -fpic -fshort-wchar
+CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB
 CFLAGS_REMOVE_efi.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi.o := -fpic -fshort-wchar
+CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB
 
Quoted 2 lines
Quoted 2 lines

lib/efi/Makefile obj-$(CONFIG_EFI_STUB) += efi_info.o

Quoted 2 lines
lib/efi/Makefile +0 -1
 extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
--

Regards,
Bin

#10 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Bin,

Quoted 45 lines · Bin Meng

Hi Simon,

Quoted 42 lines · Simon Glass

Hi Bin,

Quoted 38 lines · Bin Meng

Hi Simon,

Quoted 23 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644

include/efi.h struct efi_device_path; · line 37

Quoted 10 lines
include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

Quoted 7 lines
Quoted 4 lines

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different from U-Boot itself. This case takes care of that.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
include/efi.h +0 -0
 #undef EFI_BITS_PER_LONG
 #define EFI_BITS_PER_LONG      64
 #endif
lib/efi/Makefile +2 -2
index e32dc14..9449600 100644
@@ -9,9 +9,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi_stub.o := -fpic -fshort-wchar
+CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB
 CFLAGS_REMOVE_efi.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
-CFLAGS_efi.o := -fpic -fshort-wchar
+CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

lib/efi/Makefile obj-$(CONFIG_EFI_STUB) += efi_info.o

Quoted 2 lines
lib/efi/Makefile +0 -1
 extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
--

Regards,
Simon

#11 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Simon,

Quoted 53 lines · Simon Glass

Hi Bin,

Quoted 50 lines · Bin Meng

Hi Simon,

Quoted 46 lines · Simon Glass

Hi Bin,

Quoted 29 lines · Bin Meng

Hi Simon,

Quoted 26 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
Quoted 9 lines

include/efi.h struct efi_device_path; · line 37

Quoted 7 lines
include/efi.h +5 -2
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

Quoted 6 lines
Quoted 2 lines

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

Regards,
Bin

#12 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Bin,

Quoted 56 lines · Bin Meng

Hi Simon,

Quoted 53 lines · Simon Glass

Hi Bin,

Quoted 50 lines · Bin Meng

Hi Simon,

Quoted 46 lines · Simon Glass

Hi Bin,

Quoted 29 lines · Bin Meng

Hi Simon,

Quoted 26 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
Quoted 9 lines

include/efi.h struct efi_device_path; · line 37

Quoted 7 lines
include/efi.h +5 -2
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

But for building U-Boot, we still want it to be 32.

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it uses 64 instead of 32.

You can try building without this commit to see the result.

Regards,
Simon

#13 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Simon,

Quoted 66 lines · Simon Glass

Hi Bin,

Quoted 63 lines · Bin Meng

Hi Simon,

Quoted 59 lines · Simon Glass

Hi Bin,

Quoted 45 lines · Bin Meng

Hi Simon,

Quoted 42 lines · Simon Glass

Hi Bin,

Quoted 38 lines · Bin Meng

Hi Simon,

Quoted 23 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

 include/efi.h    | 7 +++++--
 lib/efi/Makefile | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644

include/efi.h struct efi_device_path; · line 37

Quoted 10 lines
include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

Quoted 7 lines
Quoted 4 lines

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different from U-Boot itself. This case takes care of that.

Quoted 7 lines
Quoted 1 line

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

Quoted 2 lines

But for building U-Boot, we still want it to be 32.

Yes

Quoted 6 lines

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it uses 64 instead of 32.

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Quoted 2 lines

You can try building without this commit to see the result.

Regards,
Bin

#14 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Quoted 91 lines

Am 29.09.2016 um 05:37 schrieb Bin Meng <[email protected]>:

Hi Simon,

Quoted 67 lines · Simon Glass

Hi Bin,

Quoted 64 lines · Bin Meng

Hi Simon,

Quoted 60 lines · Simon Glass

Hi Bin,

Quoted 46 lines · Bin Meng

Hi Simon,

Quoted 43 lines · Simon Glass

Hi Bin,

Quoted 39 lines · Bin Meng

Hi Simon,

Quoted 24 lines · Simon Glass

At present we use a CONFIG option in efi.h to determine whether we are building the EFI stub or not. This means that the same header cannot be used for EFI_LOADER support. The CONFIG option will be enabled for the whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the stub.

---

Changes in v2:
- Add new patch to tidy up selection of building the EFI stub

include/efi.h | 7 +++++--
lib/efi/Makefile | 4 ++--

2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0
index d07187c..3d58780 100644

include/efi.h struct efi_device_path; · line 37

Quoted 10 lines
include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
-#ifdef CONFIG_EFI_STUB_64BIT
+/*
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
+ * in lib/efi/Makefile, when building the stub.
+ */
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

Quoted 7 lines
Quoted 4 lines

If building the 64-bit EFI stub, we need to use 64-bit ints for the stub, but 32-bits for the rest of U-Boot. So this header gets used both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different from U-Boot itself. This case takes care of that.

Quoted 7 lines
Quoted 1 line

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

Quoted 2 lines

But for building U-Boot, we still want it to be 32.

Yes

Quoted 3 lines

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if CONFIG_EFI_STUB_64BIT is enabled.

Quoted 6 lines
Quoted 3 lines

This means that EFI_LOADER support does not build properly, since it uses 64 instead of 32.

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Why not?

Alex

#15 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Alex,

Quoted 151 lines · Alexander Graf

Am 29.09.2016 um 05:37 schrieb Bin Meng <[email protected]>:

Hi Simon,

On Wed, Sep 28, 2016 at 10:43 PM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 27 September 2016 at 19:23, Bin Meng <[email protected]> wrote:

Hi Simon,

On Wed, Sep 28, 2016 at 1:55 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 20:44, Bin Meng <[email protected]> wrote:

Hi Simon,

On Tue, Sep 27, 2016 at 8:35 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 02:50, Bin Meng <[email protected]> wrote:

Hi Simon,

On Mon, Sep 26, 2016 at 5:27 AM, Simon Glass <[email protected]> wrote:

At present we use a CONFIG option in efi.h to determine whether we are

building the EFI stub or not. This means that the same header cannot be

used for EFI_LOADER support. The CONFIG option will be enabled for the

whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the

stub.

---

Changes in v2:

- Add new patch to tidy up selection of building the EFI stub

include/efi.h | 7 +++++--

lib/efi/Makefile | 4 ++--

2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0

index d07187c..3d58780 100644

--- a/include/efi.h

+++ b/include/efi.h

include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
 
-#ifdef CONFIG_EFI_STUB_64BIT
 
+/*
 
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
 
+ * in lib/efi/Makefile, when building the stub.
 
+ */
 
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the

stub, but 32-bits for the rest of U-Boot. So this header gets used

both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as

BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different

from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present

EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

But for building U-Boot, we still want it to be 32.

Yes

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if

CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it

uses 64 instead of 32.

Quoted 6 lines

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Why not?

So the board has a 64-bit UEFI BIOS, and with CONFIG_EFI_STUB_64BIT we build U-Boot as a 64-bit UEFI payload and let the UEFI BIOS boot the payload (U-Boot), then with CONFIG_EFI_LOADER we are trying to provide the UEFI runtime environment within the U-Boot. What value are we looking for? This is asking for troubles.

Regards,
Bin

#16 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Quoted 157 lines · Bin Meng

Hi Alex,

Quoted 154 lines · Alexander Graf

Am 29.09.2016 um 05:37 schrieb Bin Meng <[email protected]>:

Hi Simon,

On Wed, Sep 28, 2016 at 10:43 PM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 27 September 2016 at 19:23, Bin Meng <[email protected]> wrote:

Hi Simon,

On Wed, Sep 28, 2016 at 1:55 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 20:44, Bin Meng <[email protected]> wrote:

Hi Simon,

On Tue, Sep 27, 2016 at 8:35 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 02:50, Bin Meng <[email protected]> wrote:

Hi Simon,

On Mon, Sep 26, 2016 at 5:27 AM, Simon Glass <[email protected]> wrote:

At present we use a CONFIG option in efi.h to determine whether we are

building the EFI stub or not. This means that the same header cannot be

used for EFI_LOADER support. The CONFIG option will be enabled for the

whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the

stub.

---

Changes in v2:

- Add new patch to tidy up selection of building the EFI stub

include/efi.h | 7 +++++--

lib/efi/Makefile | 4 ++--

2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0

index d07187c..3d58780 100644

--- a/include/efi.h

+++ b/include/efi.h

include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
 
-#ifdef CONFIG_EFI_STUB_64BIT
 
+/*
 
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
 
+ * in lib/efi/Makefile, when building the stub.
 
+ */
 
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the

stub, but 32-bits for the rest of U-Boot. So this header gets used

both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as

BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different

from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present

EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

But for building U-Boot, we still want it to be 32.

Yes

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if

CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it

uses 64 instead of 32.

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Quoted 7 lines
Quoted 2 lines

Why not?

So the board has a 64-bit UEFI BIOS, and with CONFIG_EFI_STUB_64BIT we build U-Boot as a 64-bit UEFI payload and let the UEFI BIOS boot the payload (U-Boot), then with CONFIG_EFI_LOADER we are trying to provide the UEFI runtime environment within the U-Boot. What value are we looking for? This is asking for troubles.

Why is this asking for trouble? The inner uefi payload has no idea that the outer uefi firmware exists. It only ever talks to u-boot. I would argue the other way around: If we can't make it work, we have a layering problem.

Alex

#17 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Alex,

Quoted 170 lines · Alexander Graf
Quoted 160 lines · Bin Meng

Hi Alex,

Quoted 156 lines · Alexander Graf

Am 29.09.2016 um 05:37 schrieb Bin Meng <[email protected]>:

Hi Simon,

On Wed, Sep 28, 2016 at 10:43 PM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 27 September 2016 at 19:23, Bin Meng <[email protected]> wrote:

Hi Simon,

On Wed, Sep 28, 2016 at 1:55 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 20:44, Bin Meng <[email protected]> wrote:

Hi Simon,

On Tue, Sep 27, 2016 at 8:35 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 02:50, Bin Meng <[email protected]> wrote:

Hi Simon,

On Mon, Sep 26, 2016 at 5:27 AM, Simon Glass <[email protected]> wrote:

At present we use a CONFIG option in efi.h to determine whether we are

building the EFI stub or not. This means that the same header cannot be

used for EFI_LOADER support. The CONFIG option will be enabled for the

whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the

stub.

---

Changes in v2:

- Add new patch to tidy up selection of building the EFI stub

include/efi.h | 7 +++++--

lib/efi/Makefile | 4 ++--

2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0

index d07187c..3d58780 100644

--- a/include/efi.h

+++ b/include/efi.h

include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
 
-#ifdef CONFIG_EFI_STUB_64BIT
 
+/*
 
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
 
+ * in lib/efi/Makefile, when building the stub.
 
+ */
 
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the

stub, but 32-bits for the rest of U-Boot. So this header gets used

both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as

BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different

from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present

EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

But for building U-Boot, we still want it to be 32.

Yes

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if

CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it

uses 64 instead of 32.

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Quoted 7 lines
Quoted 2 lines

Why not?

So the board has a 64-bit UEFI BIOS, and with CONFIG_EFI_STUB_64BIT we build U-Boot as a 64-bit UEFI payload and let the UEFI BIOS boot the payload (U-Boot), then with CONFIG_EFI_LOADER we are trying to provide the UEFI runtime environment within the U-Boot. What value are we looking for? This is asking for troubles.

Quoted 4 lines

Why is this asking for trouble? The inner uefi payload has no idea that the outer uefi firmware exists. It only ever talks to u-boot. I would argue the other way around: If we can't make it work, we have a layering problem.

This shows no value to me. In the end, providing EFI loader in the U-Boot is to load some EFI apps. But this can be done from the original UEFI BIOS without the need to have the middle-stage U-Boot payload. What layering problem do we want to fix here? Are you saying testing EFI loader in the U-Boot is not enough, so that we should support such configuration for additional testing?

Regards,
Bin

#18 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Quoted 170 lines · Bin Meng

Hi Alex,

Quoted 167 lines · Alexander Graf
Quoted 165 lines · Bin Meng

Hi Alex,

Quoted 151 lines · Alexander Graf

Am 29.09.2016 um 05:37 schrieb Bin Meng <[email protected]>:

Hi Simon,

On Wed, Sep 28, 2016 at 10:43 PM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 27 September 2016 at 19:23, Bin Meng <[email protected]> wrote:

Hi Simon,

On Wed, Sep 28, 2016 at 1:55 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 20:44, Bin Meng <[email protected]> wrote:

Hi Simon,

On Tue, Sep 27, 2016 at 8:35 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 02:50, Bin Meng <[email protected]> wrote:

Hi Simon,

On Mon, Sep 26, 2016 at 5:27 AM, Simon Glass <[email protected]> wrote:

At present we use a CONFIG option in efi.h to determine whether we are

building the EFI stub or not. This means that the same header cannot be

used for EFI_LOADER support. The CONFIG option will be enabled for the

whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the

stub.

---

Changes in v2:

- Add new patch to tidy up selection of building the EFI stub

include/efi.h | 7 +++++--

lib/efi/Makefile | 4 ++--

2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0

index d07187c..3d58780 100644

--- a/include/efi.h

+++ b/include/efi.h

include/efi.h +5 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
 
-#ifdef CONFIG_EFI_STUB_64BIT
 
+/*
 
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set
 
+ * in lib/efi/Makefile, when building the stub.
 
+ */
 
+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the

stub, but 32-bits for the rest of U-Boot. So this header gets used

both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as

BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different

from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present

EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

But for building U-Boot, we still want it to be 32.

Yes

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if

CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it

uses 64 instead of 32.

Quoted 6 lines

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Why not?

So the board has a 64-bit UEFI BIOS, and with CONFIG_EFI_STUB_64BIT we build U-Boot as a 64-bit UEFI payload and let the UEFI BIOS boot the payload (U-Boot), then with CONFIG_EFI_LOADER we are trying to provide the UEFI runtime environment within the U-Boot. What value are we looking for? This is asking for troubles.

Quoted 8 lines
Quoted 4 lines

Why is this asking for trouble? The inner uefi payload has no idea that the outer uefi firmware exists. It only ever talks to u-boot. I would argue the other way around: If we can't make it work, we have a layering problem.

This shows no value to me. In the end, providing EFI loader in the U-Boot is to load some EFI apps. But this can be done from the original UEFI BIOS without the need to have the middle-stage U-Boot payload.

You could say the same about running U-Boot on EFI. You can as well just load your payload from the original uEFI firmware :).

Quoted 3 lines

What layering problem do we want to fix here? Are you saying testing EFI loader in the U-Boot is not enough, so that we should support such configuration for additional testing?

I'm saying that I don't see anything that speaks against it working, so why should we disable it? At least for prototyping it's a convenient option to have and in general divergence is a bad thing.

Alex

#19 lore raw

PATCH v2 4/8 x86: Tidy up selection of building the EFI stub

Hi Alex,

Quoted 183 lines · Alexander Graf
Quoted 182 lines · Bin Meng

Hi Alex,

Quoted 178 lines · Alexander Graf
Quoted 161 lines · Bin Meng

Hi Alex,

Quoted 157 lines · Alexander Graf

Am 29.09.2016 um 05:37 schrieb Bin Meng <[email protected]>:

Hi Simon,

On Wed, Sep 28, 2016 at 10:43 PM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 27 September 2016 at 19:23, Bin Meng <[email protected]> wrote:

Hi Simon,

On Wed, Sep 28, 2016 at 1:55 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 20:44, Bin Meng <[email protected]> wrote:

Hi Simon,

On Tue, Sep 27, 2016 at 8:35 AM, Simon Glass <[email protected]> wrote:

Hi Bin,

On 26 September 2016 at 02:50, Bin Meng <[email protected]> wrote:

Hi Simon,

On Mon, Sep 26, 2016 at 5:27 AM, Simon Glass <[email protected]> wrote:

At present we use a CONFIG option in efi.h to determine whether we are

building the EFI stub or not. This means that the same header cannot be

used for EFI_LOADER support. The CONFIG option will be enabled for the

whole build, even when not building the stub.

Use a different define instead, set up just for the files that make up the

stub.

---

Changes in v2:

- Add new patch to tidy up selection of building the EFI stub

include/efi.h | 7 +++++--

lib/efi/Makefile | 4 ++--

2 files changed, 7 insertions(+), 4 deletions(-)
include/efi.h +0 -0

index d07187c..3d58780 100644

--- a/include/efi.h

+++ b/include/efi.h

include/efi.h +2 -2
@@ -30,8 +30,11 @@ struct efi_device_path;
 
 
 #define EFI_BITS_PER_LONG      BITS_PER_LONG
 
 
-/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */
 
-#ifdef CONFIG_EFI_STUB_64BIT
 
+/*
 
+ * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is

set

+ * in lib/efi/Makefile, when building the stub.

+ */

+#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB)

I don't understand why this is needed?

If building the 64-bit EFI stub, we need to use 64-bit ints for the

stub, but 32-bits for the rest of U-Boot. So this header gets used

both ways.

For 32-bit EFI stub or U-Boot itself, EFI_BITS_PER_LONG is defined as

BITS_PER_LONG which is 32.

Yes that's right. But in the case of the stub, it can be different

from U-Boot itself. This case takes care of that.

Sorry but I still don't get it. What's broken without this change?

When building U-Boot with CONFIG_EFI_STUB_64BIT enabled, at present

EFI_BITS_PER_LONG will be 64.

This is fine for building the stub.

Yes

But for building U-Boot, we still want it to be 32.

Yes

At present the code overrides EFI_BITS_PER_LONG, setting it to 64 if

CONFIG_EFI_STUB_64BIT is enabled.

This means that EFI_LOADER support does not build properly, since it

uses 64 instead of 32.

So you want CONFIG_EFI_STUB_64BIT and CONFIG_EFI_LOADER both be defined? I don't think it is a valid configuration.

Quoted 7 lines
Quoted 2 lines

Why not?

So the board has a 64-bit UEFI BIOS, and with CONFIG_EFI_STUB_64BIT we build U-Boot as a 64-bit UEFI payload and let the UEFI BIOS boot the payload (U-Boot), then with CONFIG_EFI_LOADER we are trying to provide the UEFI runtime environment within the U-Boot. What value are we looking for? This is asking for troubles.

Why is this asking for trouble? The inner uefi payload has no idea that the
outer uefi firmware exists. It only ever talks to u-boot. I would argue the
other way around: If we can't make it work, we have a layering problem.

Quoted 8 lines
Quoted 4 lines

This shows no value to me. In the end, providing EFI loader in the U-Boot is to load some EFI apps. But this can be done from the original UEFI BIOS without the need to have the middle-stage U-Boot payload.

You could say the same about running U-Boot on EFI. You can as well just load your payload from the original uEFI firmware :).

Wait, they are different things. EFI loader in U-Boot assumes U-Boot is the bootloader and we want a EFI runtime environment to load EFI payload without the need to have a full UEFI BIOS. I see value in supporting EFI loader in U-Boot.

Quoted 9 lines
Quoted 4 lines

What layering problem do we want to fix here? Are you saying testing EFI loader in the U-Boot is not enough, so that we should support such configuration for additional testing?

I'm saying that I don't see anything that speaks against it working, so why should we disable it? At least for prototyping it's a convenient option to have and in general divergence is a bad thing.

But this one, value-wise, no, but yes, technically we can make such configuration work :)

Regards,
Bin

#20 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

In reply to Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

 arch/arm/lib/HelloWorld32.efi  | Bin 0 -> 11712 bytes
 arch/arm/lib/Makefile          |   7 +++++++
 cmd/Kconfig                    |  10 ++++++++++
 cmd/bootefi.c                  |  26 ++++++++++++++++++++------
 include/asm-generic/sections.h |   2 ++
 scripts/Makefile.lib           |  19 +++++++++++++++++++
 6 files changed, 58 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/lib/HelloWorld32.efi
arch/arm/lib/HelloWorld32.efi new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..7708451c04a99752ed468842090a9b3f3506090e
GIT binary patch

zkr2WH1YM-fqM&g9Z**-0kM=9?AB?uu59yz;dvpzYq01EHo|_Nh5&PD8Y at Hs^QX8pV zv2rdumXJNtQL<2odN~u5G&D~{gryo!jPcHKB|8EvmCv&SDV)Jky-!*Q%;&+Rn-O z>=qTDHuP%CNz;P&w7iBV!IY4O*P?7g87J1B4RL(iFk@~Temk3x#|Y7lq%qKhvM+< z4Ecu0y3Lyup?AAR2zgkL3c<i)^fKL0HZ0CWBw;i&J!eP2}Puw5-GniOSyZNaz~Uh zU8LkgY35&R(m+m)$3MB29BFTgF|FZI%GaROIZ at 7jN6g}jJ%NC{EkNc#PIbt=(FN{ z+b|g!T||f<V1pfP)g;KAC#2+Dd)&|%}toS-zy at Cnnjuax+s%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b84t)yIZ z5%y-MUF at f9+i>ln+OW7mw83$t5rN0LIy at p>J555sEqA!7t_aj<<aMUTPn8IMKy2a z8)H?fzN^XQm~~8(tF;XWa$ICt+<e+7b4iGJK*&L>`uGOAs*IAMSVq-qRMHdR!6LX zlDG=ntgN<Ry?EG+whTCWMiF_t!#3;xtuVU-djM{9t!-{stGykx;$$^6mRHoUeEE*8 zjT>T<QTv?Dz1QJ-p0zvKy&cXb@!GJ$vhHiVPdwz7GkXZGx3yaAPOHt0Y=TaEyGy)A z;^C0~!pcbburJ=>NIyW0zZs?Qq)8v8j8J at KzWZN$KDqlqvd)UIxC!5j5QXd8?p?G z4Q9huL!IGG!>HkH!><hQ7{&~j4I#sfffODu>?=G~=qvnT;p>I(6l#ms6mdmMI}W? zih7EU7xfkWwn!*a8F)7^}E+UwSLcf>-sm=pIsx`t%JSmtHUZv@}>cRSH3BLbNCb z^>66U>)+Im>fhG?O8<_2On=1CV>oW;Gn_Jrs<MRaM&-D%&v?q{Gyc%{y74E*LE{_7 z^Ts!gqsF(5zcRjK95Y@vUNQdGC>TFBUN?Sf3>v45A>)jZ6w8Vg#j0X;ae8r9@#12( aczLn5cug at FLO%YJ#tpkS9NEyb;lBZO+uTI}

literal 0
HcmV?d00001

arch/arm/lib/Makefile +7 -0
index caa62c6..64378e1 100644
@@ -30,6 +30,13 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
+ifdef CONFIG_ARM64
+# This option does not work for arm64, as there is no binary.
+# TODO(sjg at chromium.org): Add this once it is possible to build one
+obj-$(CONFIG_CMD_BOOTEFI_HELLO) += HelloWorld64.o
+else
+obj-$(CONFIG_CMD_BOOTEFI_HELLO) += HelloWorld32.o
+endif
 obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
cmd/Kconfig +10 -0
index d28da54..f12fcb8 100644
@@ -181,6 +181,16 @@ config CMD_BOOTEFI
 	help
 	  Boot an EFI image from memory.
 
+config CMD_BOOTEFI_HELLO
+	bool "Allow booting a standard EFI hello word for testing"
+	depends on CMD_BOOTEFI
+	default y if CMD_BOOTEFI && !ARM64
+	help
+	  This adds a standard EFI hello world application to U-Boot so that
+	  it can be used with the 'bootefi hello' command. This is useful
+	  for testing that EFI is woring at a basic level, and for brining
+	  up EFI support on a new architecture.
+
 config CMD_ELF
 	bool "bootelf, bootvx"
 	default y
cmd/bootefi.c +20 -6
index 7b2e0b5..90faf34 100644
@@ -230,13 +230,22 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
-	saddr = argv[1];
+#ifdef CONFIG_CMD_BOOTEFI_HELLO
+	if (!strcmp(argv[1], "hello")) {
+		addr = CONFIG_SYS_LOAD_ADDR;
+		memcpy((char *)addr, __efi_hello_world_begin,
+		       __efi_hello_world_end - __efi_hello_world_begin);
+	} else
+#endif
+	{
+		saddr = argv[1];
 
-	addr = simple_strtoul(saddr, NULL, 16);
+		addr = simple_strtoul(saddr, NULL, 16);
 
-	if (argc > 2) {
-		sfdt = argv[2];
-		fdt_addr = simple_strtoul(sfdt, NULL, 16);
+		if (argc > 2) {
+			sfdt = argv[2];
+			fdt_addr = simple_strtoul(sfdt, NULL, 16);
+		}
 	}
 
 	printf("## Starting EFI application at 0x%08lx ...\n", addr);
@@ -254,7 +263,12 @@ static char bootefi_help_text[] =
 	"<image address> [fdt address]\n"
 	"  - boot EFI payload stored at address <image address>.\n"
 	"    If specified, the device tree located at <fdt address> gets\n"
-	"    exposed as EFI configuration table.\n";
+	"    exposed as EFI configuration table.\n"
+#ifdef CONFIG_CMD_BOOTEFI_HELLO
+	"hello\n"
+	"  - boot a sample Hello Word application stored within U-Boot"
+#endif
+	;
 #endif
 
 U_BOOT_CMD(
include/asm-generic/sections.h +2 -0
index 328bc62..54ccac9 100644
@@ -22,6 +22,8 @@ extern char __kprobes_text_start[], __kprobes_text_end[];
 extern char __entry_text_start[], __entry_text_end[];
 extern char __initdata_begin[], __initdata_end[];
 extern char __start_rodata[], __end_rodata[];
+extern char __efi_hello_world_begin[];
+extern char __efi_hello_world_end[];
 
 /* Start and end of .ctors section - used for constructor calls. */
 extern char __ctors_start[], __ctors_end[];
scripts/Makefile.lib +19 -0
index 45a0e1d..2b31b1a 100644
@@ -321,6 +321,25 @@ cmd_S_ttf=						\
 $(obj)/%.S: $(src)/%.ttf
 	$(call cmd,S_ttf)
 
+# EFI Hello World application
+# ---------------------------------------------------------------------------
+
+# Generate an assembly file to wrap the EFI app
+cmd_S_efi=						\
+(							\
+	echo '.section .rodata.efi.init,"a"';		\
+	echo '.balign 16';				\
+	echo '.global __efi_hello_world_begin';		\
+	echo '__efi_hello_world_begin:';			\
+	echo '.incbin "$<" ';				\
+	echo '__efi_hello_world_end:';			\
+	echo '.global __efi_hello_world_end';			\
+	echo '.balign 16';				\
+) > $@
+
+$(obj)/%.S: $(src)/%.efi
+	$(call cmd,S_efi)
+
 # ACPI
 # ---------------------------------------------------------------------------
 quiet_cmd_acpi_c_asl= ASL     $<
Signature · 1 line
2.8.0.rc3.226.g39d4020
#21 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Quoted 9 lines · Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

 arch/arm/lib/HelloWorld32.efi  | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries shipped inside would also need to be GPL compatibly licensed which again means that the source code (and build instructions?) for this .efi file would need to be part of the tree, no?

Alex

#22 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Quoted 9 lines · Alexander Graf
Quoted 6 lines · Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Quoted 8 lines
Quoted 3 lines

Changes in v2: None

 arch/arm/lib/HelloWorld32.efi  | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries shipped inside would also need to be GPL compatibly licensed which again means that the source code (and build instructions?) for this .efi file would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160927/f1f71347/attachment.sig>
#23 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Hi,

Quoted 12 lines · Tom Rini
Quoted 11 lines · Alexander Graf
Quoted 8 lines · Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

Quoted 8 lines
Quoted 6 lines
Quoted 1 line
 arch/arm/lib/HelloWorld32.efi  | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries shipped inside would also need to be GPL compatibly licensed which again means that the source code (and build instructions?) for this .efi file would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Do you think we should drop these binary patches? I could always put the binaries somewhere along with instructions on how to get them.

I do think it is useful to be able to test the platform though.

Regards,
Simon

#24 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Quoted 26 lines

Am 03.10.2016 um 23:50 schrieb Simon Glass <[email protected]>:

Hi,

Quoted 20 lines · Tom Rini
Quoted 18 lines · Alexander Graf
Quoted 12 lines · Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

arch/arm/lib/HelloWorld32.efi | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries shipped inside would also need to be GPL compatibly licensed which again means that the source code (and build instructions?) for this .efi file would need to be part of the tree, no?

Quoted 4 lines
Quoted 1 line

Yeah, I'm not super comfortable with this.

Do you think we should drop these binary patches? I could always put the binaries somewhere along with instructions on how to get them.

I think that's the best option, yes. You can always just add a url to the readme to point people into the right direction.

Quoted 2 lines

I do think it is useful to be able to test the platform though.

I don't disagree, but I would argue that for the average u-boot user it brings no additional value ;). And people like you who know how to enable a new architecture probably also know how to get a file into their target's memory.

Alex

Quoted 3 lines

Regards,
Simon

#25 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Hi Alex,

Quoted 42 lines · Alexander Graf

Am 03.10.2016 um 23:50 schrieb Simon Glass <[email protected]>:

Hi,

On 27 September 2016 at 15:28, Tom Rini <[email protected]> wrote:

On Mon, Sep 26, 2016 at 09:36:19AM +0200, Alexander Graf wrote:

On 25.09.16 23:27, Simon Glass wrote:

It is useful to have a basic sanity check for EFI loader support. Add a

'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

arch/arm/lib/HelloWorld32.efi | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries

shipped inside would also need to be GPL compatibly licensed which again

means that the source code (and build instructions?) for this .efi file

would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Quoted 6 lines

Do you think we should drop these binary patches? I could always put the binaries somewhere along with instructions on how to get them.

I think that's the best option, yes. You can always just add a url to the readme to point people into the right direction.

OK. One problem is that we cannot write a test for it unless we actually run an EFI application.

Quoted 9 lines

I do think it is useful to be able to test the platform though.

I don't disagree, but I would argue that for the average u-boot user it brings no additional value ;). And people like you who know how to enable a new architecture probably also know how to get a file into their target's memory.

I wonder if we can build our own hello world application? I think I did it once. But there is EFI library code that we would need to bring in (perhaps a small amount).

Regards,
Simon

#26 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Quoted 53 lines

Am 04.10.2016 um 17:37 schrieb Simon Glass <[email protected]>:

Hi Alex,

Quoted 47 lines · Alexander Graf

Am 03.10.2016 um 23:50 schrieb Simon Glass <[email protected]>:

Hi,

On 27 September 2016 at 15:28, Tom Rini <[email protected]> wrote:

On Mon, Sep 26, 2016 at 09:36:19AM +0200, Alexander Graf wrote:

On 25.09.16 23:27, Simon Glass wrote:

It is useful to have a basic sanity check for EFI loader support. Add a

'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

arch/arm/lib/HelloWorld32.efi | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries

shipped inside would also need to be GPL compatibly licensed which again

means that the source code (and build instructions?) for this .efi file

would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Do you think we should drop these binary patches? I could always put the binaries somewhere along with instructions on how to get them.

Quoted 5 lines
Quoted 2 lines

I think that's the best option, yes. You can always just add a url to the readme to point people into the right direction.

OK. One problem is that we cannot write a test for it unless we actually run an EFI application.

Well, you could always provide a binary disk image that you run in qemu as test case. That one doesn't have to be gpl compliant thn because it's not derived work :).

Quoted 6 lines
Quoted 6 lines

I do think it is useful to be able to test the platform though.

Quoted 8 lines
Quoted 4 lines

I don't disagree, but I would argue that for the average u-boot user it brings no additional value ;). And people like you who know how to enable a new architecture probably also know how to get a file into their target's memory.

I wonder if we can build our own hello world application? I think I did it once. But there is EFI library code that we would need to bring in (perhaps a small amount).

We could. The main problem is the PE header.

Maybe we can trick around that with bincopy -O binary though. Hmm :).

Alex

Quoted 3 lines

Regards,
Simon

#27 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Hi Alex,

Quoted 101 lines · Alexander Graf

Am 04.10.2016 um 17:37 schrieb Simon Glass <[email protected]>:

Hi Alex,

On 3 October 2016 at 21:15, Alexander Graf <[email protected]> wrote:

Am 03.10.2016 um 23:50 schrieb Simon Glass <[email protected]>:

Hi,

On 27 September 2016 at 15:28, Tom Rini <[email protected]> wrote:

On Mon, Sep 26, 2016 at 09:36:19AM +0200, Alexander Graf wrote:

On 25.09.16 23:27, Simon Glass wrote:

It is useful to have a basic sanity check for EFI loader support. Add a

'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

arch/arm/lib/HelloWorld32.efi | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries

shipped inside would also need to be GPL compatibly licensed which again

means that the source code (and build instructions?) for this .efi file

would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Do you think we should drop these binary patches? I could always put

the binaries somewhere along with instructions on how to get them.

I think that's the best option, yes. You can always just add a url to the

readme to point people into the right direction.

OK. One problem is that we cannot write a test for it unless we actually run an EFI application.

Well, you could always provide a binary disk image that you run in qemu as test case. That one doesn't have to be gpl compliant thn because it's not derived work :).

I do think it is useful to be able to test the platform though.

I don't disagree, but I would argue that for the average u-boot user it

brings no additional value ;). And people like you who know how to enable a

new architecture probably also know how to get a file into their target's

memory.

Quoted 6 lines

I wonder if we can build our own hello world application? I think I did it once. But there is EFI library code that we would need to bring in (perhaps a small amount).

We could. The main problem is the PE header.

What is tricky about that?

Quoted 2 lines

Maybe we can trick around that with bincopy -O binary though. Hmm :).

Yes I think it is possible, and desirable. But for now I've gone with using an external patch. I may come back to this another time.

Regards,
Simon

#28 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Quoted 104 lines · Simon Glass

Hi Alex,

Quoted 101 lines · Alexander Graf

Am 04.10.2016 um 17:37 schrieb Simon Glass <[email protected]>:

Hi Alex,

On 3 October 2016 at 21:15, Alexander Graf <[email protected]> wrote:

Am 03.10.2016 um 23:50 schrieb Simon Glass <[email protected]>:

Hi,

On 27 September 2016 at 15:28, Tom Rini <[email protected]> wrote:

On Mon, Sep 26, 2016 at 09:36:19AM +0200, Alexander Graf wrote:

On 25.09.16 23:27, Simon Glass wrote:

It is useful to have a basic sanity check for EFI loader support. Add a

'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

arch/arm/lib/HelloWorld32.efi | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries

shipped inside would also need to be GPL compatibly licensed which again

means that the source code (and build instructions?) for this .efi file

would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Do you think we should drop these binary patches? I could always put

the binaries somewhere along with instructions on how to get them.

I think that's the best option, yes. You can always just add a url to the

readme to point people into the right direction.

OK. One problem is that we cannot write a test for it unless we actually run an EFI application.

Well, you could always provide a binary disk image that you run in qemu as test case. That one doesn't have to be gpl compliant thn because it's not derived work :).

I do think it is useful to be able to test the platform though.

I don't disagree, but I would argue that for the average u-boot user it

brings no additional value ;). And people like you who know how to enable a

new architecture probably also know how to get a file into their target's

memory.

Quoted 8 lines
Quoted 6 lines

I wonder if we can build our own hello world application? I think I did it once. But there is EFI library code that we would need to bring in (perhaps a small amount).

We could. The main problem is the PE header.

What is tricky about that?

Our compiler usually generates elf files, no PE binaries. So we'd have to assemble the PE header ourselves - or rely on a second compiler.

Alex

#29 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

Hi Alex,

Quoted 112 lines · Alexander Graf
Quoted 109 lines · Simon Glass

Hi Alex,

Quoted 106 lines · Alexander Graf

Am 04.10.2016 um 17:37 schrieb Simon Glass <[email protected]>:

Hi Alex,

On 3 October 2016 at 21:15, Alexander Graf <[email protected]> wrote:

Am 03.10.2016 um 23:50 schrieb Simon Glass <[email protected]>:

Hi,

On 27 September 2016 at 15:28, Tom Rini <[email protected]> wrote:

On Mon, Sep 26, 2016 at 09:36:19AM +0200, Alexander Graf wrote:

On 25.09.16 23:27, Simon Glass wrote:

It is useful to have a basic sanity check for EFI loader support. Add a

'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

arch/arm/lib/HelloWorld32.efi | Bin 0 -> 11712 bytes

IIRC U-Boot as a whole is GPL licensed, which means that any binaries

shipped inside would also need to be GPL compatibly licensed which again

means that the source code (and build instructions?) for this .efi file

would need to be part of the tree, no?

Yeah, I'm not super comfortable with this.

Do you think we should drop these binary patches? I could always put

the binaries somewhere along with instructions on how to get them.

I think that's the best option, yes. You can always just add a url to the

readme to point people into the right direction.

OK. One problem is that we cannot write a test for it unless we actually run an EFI application.

Well, you could always provide a binary disk image that you run in qemu as test case. That one doesn't have to be gpl compliant thn because it's not derived work :).

I do think it is useful to be able to test the platform though.

I don't disagree, but I would argue that for the average u-boot user it

brings no additional value ;). And people like you who know how to enable a

new architecture probably also know how to get a file into their target's

memory.

I wonder if we can build our own hello world application? I think I did it once. But there is EFI library code that we would need to bring in (perhaps a small amount).

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

We could. The main problem is the PE header.

What is tricky about that?

Our compiler usually generates elf files, no PE binaries. So we'd have to assemble the PE header ourselves - or rely on a second compiler.

I think I'm going to go with the first option which seems easy enough.

Regards,
Simon

#30 lore raw

PATCH v2 5/8 arm: efi: Add a hello world test program

In reply to Simon Glass

Hi Simon,

Quoted 17 lines · Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

 arch/arm/lib/HelloWorld32.efi  | Bin 0 -> 11712 bytes
 arch/arm/lib/Makefile          |   7 +++++++
 cmd/Kconfig                    |  10 ++++++++++
 cmd/bootefi.c                  |  26 ++++++++++++++++++++------
 include/asm-generic/sections.h |   2 ++
 scripts/Makefile.lib           |  19 +++++++++++++++++++
 6 files changed, 58 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/lib/HelloWorld32.efi

[snip]

Quoted 23 lines
arch/arm/lib/Makefile +7 -0
index caa62c6..64378e1 100644
@@ -30,6 +30,13 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
+ifdef CONFIG_ARM64
+# This option does not work for arm64, as there is no binary.
+# TODO(sjg at chromium.org): Add this once it is possible to build one
+obj-$(CONFIG_CMD_BOOTEFI_HELLO) += HelloWorld64.o
+else
+obj-$(CONFIG_CMD_BOOTEFI_HELLO) += HelloWorld32.o
+endif
 obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
cmd/Kconfig +0 -0
index d28da54..f12fcb8 100644

cmd/Kconfig config CMD_BOOTEFI · line 185

Quoted 5 lines
cmd/Kconfig +2 -0
@@ -181,6 +181,16 @@ config CMD_BOOTEFI
        help
          Boot an EFI image from memory.
 
+config CMD_BOOTEFI_HELLO
+       bool "Allow booting a standard EFI hello word for testing"

typo: world

Please fix all other typos which were pointed out in the v1 comment:
http://patchwork.ozlabs.org/patch/656430/

cmd/Kconfig config CMD_BOOTEFI · line 193

Quoted 8 lines
cmd/Kconfig +8 -0
+       depends on CMD_BOOTEFI
+       default y if CMD_BOOTEFI && !ARM64
+       help
+         This adds a standard EFI hello world application to U-Boot so that
+         it can be used with the 'bootefi hello' command. This is useful
+         for testing that EFI is woring at a basic level, and for brining
+         up EFI support on a new architecture.
+

[snip]

Regards,
Bin

#31 lore raw

PATCH v2 6/8 x86: efi: Add EFI loader support for x86

In reply to Simon Glass

Add the required pieces to support the EFI loader on x86.

Since U-Boot only builds for 32-bit on x86, only a 32-bit EFI application is supported. If a 64-bit kernel must be booted, U-Boot supports this directly using FIT (see doc/uImage.FIT/kernel.its). U-Boot can act as a payload for both 32-bit and 64-bit EFI.

---

Changes in v2: None

 arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
 arch/x86/lib/Makefile         |  1 +
 arch/x86/lib/sections.c       | 12 ++++++++++++
 lib/efi_loader/efi_boottime.c |  9 +++++++++
 lib/efi_loader/efi_runtime.c  |  4 ++++
 5 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/lib/sections.c
arch/x86/cpu/u-boot.lds +35 -1
index 36f59ea..cca536b 100644
@@ -28,7 +28,10 @@ SECTIONS
 	}
 
 	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+	.rodata : {
+		*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+		KEEP(*(.rodata.efi.init));
+	}
 
 	. = ALIGN(4);
 	.data : { *(.data*) }
@@ -40,6 +43,37 @@ SECTIONS
 	.got : { *(.got*) }
 
 	. = ALIGN(4);
+
+	.__efi_runtime_start : {
+		*(.__efi_runtime_start)
+	}
+
+	.efi_runtime : {
+		*(efi_runtime_text)
+		*(efi_runtime_data)
+	}
+
+	.__efi_runtime_stop : {
+		*(.__efi_runtime_stop)
+	}
+
+	.efi_runtime_rel_start :
+	{
+		*(.__efi_runtime_rel_start)
+	}
+
+	.efi_runtime_rel : {
+		*(.relefi_runtime_text)
+		*(.relefi_runtime_data)
+	}
+
+	.efi_runtime_rel_stop :
+	{
+		*(.__efi_runtime_rel_stop)
+	}
+
+	. = ALIGN(4);
+
 	__data_end = .;
 	__init_end = .;
 
arch/x86/lib/Makefile +1 -0
index e17f0bb..e46e7f1 100644
@@ -28,6 +28,7 @@ obj-y	+= pirq_routing.o
 obj-y	+= relocate.o
 obj-y += physmem.o
 obj-$(CONFIG_X86_RAMTEST) += ramtest.o
+obj-y	+= sections.o
 obj-y += sfi.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
 obj-y	+= string.o
arch/x86/lib/sections.c new file +12 -0
new file mode 100644
index 0000000..6455e0f
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2013 Albert ARIBAUD <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start")));
+char __efi_runtime_stop[0] __attribute__((section(".__efi_runtime_stop")));
+char __efi_runtime_rel_start[0]
+		__attribute__((section(".__efi_runtime_rel_start")));
+char __efi_runtime_rel_stop[0]
+		__attribute__((section(".__efi_runtime_rel_stop")));
lib/efi_loader/efi_boottime.c +9 -0
index 798b566..e027bd3 100644
@@ -39,6 +39,7 @@ static bool efi_is_direct_boot = true;
  */
 static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[1];
 
+#ifdef CONFIG_ARM
 /*
  * The "gd" pointer lives in a register on ARM and AArch64 that we declare
  * fixed when compiling U-Boot. However, the payload does not know about that
@@ -46,16 +47,20 @@ static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[1];
  * EFI callback entry/exit.
  */
 static volatile void *efi_gd, *app_gd;
+#endif
 
 /* Called from do_bootefi_exec() */
 void efi_save_gd(void)
 {
+#ifdef CONFIG_ARM
 	efi_gd = gd;
+#endif
 }
 
 /* Called on every callback entry */
 void efi_restore_gd(void)
 {
+#ifdef CONFIG_ARM
 	/* Only restore if we're already in EFI context */
 	if (!efi_gd)
 		return;
@@ -63,12 +68,16 @@ void efi_restore_gd(void)
 	if (gd != efi_gd)
 		app_gd = gd;
 	gd = efi_gd;
+#endif
 }
 
 /* Called on every callback exit */
 efi_status_t efi_exit_func(efi_status_t ret)
 {
+#ifdef CONFIG_ARM
 	gd = app_gd;
+#endif
+
 	return ret;
 }
 
lib/efi_loader/efi_runtime.c +4 -0
index 99b5ef1..3793471 100644
@@ -34,6 +34,10 @@ static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_invalid_parameter(void);
 #elif defined(CONFIG_ARM)
 #define R_RELATIVE	23
 #define R_MASK		0xffULL
+#elif defined(CONFIG_X86)
+#include <asm/elf.h>
+#define R_RELATIVE	R_386_RELATIVE
+#define R_MASK		0xffULL
 #else
 #error Need to add relocation awareness
 #endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
#32 lore raw

PATCH v2 6/8 x86: efi: Add EFI loader support for x86

Quoted 9 lines

Add the required pieces to support the EFI loader on x86.

Since U-Boot only builds for 32-bit on x86, only a 32-bit EFI application is supported. If a 64-bit kernel must be booted, U-Boot supports this directly using FIT (see doc/uImage.FIT/kernel.its). U-Boot can act as a payload for both 32-bit and 64-bit EFI.

Thanks, applied to

#33 lore raw

PATCH v2 7/8 x86: efi: Add a hello world test program

In reply to Simon Glass

It is useful to have a basic sanity check for EFI loader support. Add a 'bootefi hello' command which loads HelloWord.efi and runs it under U-Boot.

---

Changes in v2: None

 arch/x86/lib/HelloWorld32.efi | Bin 0 -> 11168 bytes
 arch/x86/lib/Makefile         |   1 +
 2 files changed, 1 insertion(+)
 create mode 100644 arch/x86/lib/HelloWorld32.efi
arch/x86/lib/HelloWorld32.efi new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e59b84b4d1d5f5aeabb4f25094ec0724ac114b4e
GIT binary patch

zxg%MAkTlt|&bgZV_#fZ@-~ayipCOL>nXmlU{gpY#7 at a)BtTW_~Ovy<x!!P{fnm6L z3{yLYF4g9tkM^x%I_B^oZQ@_=5=uwrXH8tx$A#CJpK7|-1bM)6ZZX3QOhxb&=avip zP651{jj${8%oWGM+~q#6;Kd~I1F=2x%%!UZwB=EMDAG!?W-yay?jPvtm;3w=iEY%D zj7{X3$y<<$Dh~t$mcgVyQK>S%GbI145NrfrKKQoR+v at oHXgx5cl1L)78tfROv| zL+3#_Qy#kaestHPE4^GOr+WMsA9!#}%dw2GB1J4vT8zzZwF9n^htw04GCm+U66qal zR6C|ID23ht1b3 at 8Oh6RoikzDR#8Gs9A7yj~c9E%LpbhLnPrX5(cS6U0s>3%y$61WW z={S=m7_Xy>&TpnVj%Rf|haNC(+z1^{OoJWAR3<CJkr;*@;fXpzS%M;$JI9XKsVv=& zlUW^W>3og at H7~Y|V4i_H-IifzcTE5r!3a05xM?Liu^ZsEhCnU4>g&{P$@7*0rRC~L zvH|X07YZ<&77Np2L0UBSJd^q?oel&+9$>KGRu$OtZ0|RTaa>|Rn4{F%@R;Rtxt(ce zJ}mBC3gW&(;cM!@%w?G5%sx(-t~wFGnhtFhidv*|23=u3<RWa;chl)KTs}WBEPj1s zU?-%s*988K0BywzB&$uJOz=jbyoWDzx&y?Y6rfxE36^wNg;T;Bul<aw>sNSVVtOf* zw6J>yG(c`l0nYvduu*kTOgBq4WXKR;pAcZ>fw^S))L%4U@=e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XpdD(Kp@*B$;%j=dmEx)&%v%GInEf*|*vRt&JELSaz zHQ#Eq7FY|dMb=_#iIuZ1w3b?zTFq7nobZ>2 at gB6Ri)mY5Z!zbRe15$Ae|>fu``EPH KhvIm`-~R%zH!}tR

literal 0
HcmV?d00001

arch/x86/lib/Makefile +1 -0
index e46e7f1..1d9ebc0 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y	+= cmd_boot.o
 obj-$(CONFIG_SEABIOS) += coreboot_table.o
 obj-$(CONFIG_EFI) += efi/
+obj-$(CONFIG_CMD_BOOTEFI_HELLO) += HelloWorld32.o
 obj-y	+= e820.o
 obj-y	+= gcc.o
 obj-y	+= init_helpers.o
Signature · 1 line
2.8.0.rc3.226.g39d4020
#34 lore raw

PATCH v2 8/8 x86: Enable EFI loader support

In reply to Simon Glass

Enable this so that EFI applications (notably grub) can be run under U-Boot on x86 platforms.

---

Changes in v2:
- Remove EFI support from README.x86 TODO list

 configs/efi-x86_defconfig | 1 +
 doc/README.x86            | 1 -
 lib/efi_loader/Kconfig    | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
configs/efi-x86_defconfig +1 -0
index 1cdd49d..30dfe90 100644
@@ -35,3 +35,4 @@ CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_EFI=y
+# CONFIG_EFI_LOADER is not set
doc/README.x86 +0 -1
index ba5bb99..9d3129a 100644
@@ -1070,7 +1070,6 @@ TODO List
 ---------
 - Audio
 - Chrome OS verified boot
-- Support for CONFIG_EFI_LOADER
 - Building U-Boot to run in 64-bit mode
 
 References
lib/efi_loader/Kconfig +1 -1
index 37a0dd6..8e7e8a5 100644
@@ -1,6 +1,6 @@
 config EFI_LOADER
 	bool "Support running EFI Applications in U-Boot"
-	depends on (ARM64 ||?ARM) && OF_LIBFDT
+	depends on (ARM64 || ARM || X86) && OF_LIBFDT
 	default y
 	help
 	  Select this option if you want to run EFI applications (like grub2)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#35 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

In reply to Simon Glass

Hi Simon,

Quoted 40 lines · Simon Glass

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y  += interrupts.o cpu.o cpu_x86.o call64.o
+obj-y  += interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +2 -0
new file mode 100644
index 0000000..7443274
@@ -0,0 +1,66 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>

arch/x86/cpu/setjmp.S line 12

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+

I believe the above 3 includes are not needed.

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +36 -0
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax, %edx
+#else
+       movl 4(%esp), %edx
+#endif
+       popl %ecx               /* Return address, and adjust the stack */
+       xorl %eax, %eax         /* Return value */
+       movl %ebx, (%edx)
+       movl %esp, 4(%edx)      /* Post-return %esp! */
+       pushl %ecx              /* Make the call/return stack happy */
+       movl %ebp, 8(%edx)
+       movl %esi, 12(%edx)
+       movl %edi, 16(%edx)
+       movl %ecx, 20(%edx)     /* Return address */
+       ret
+
+       /* Provide function size if needed */
+       .size setjmp, .-setjmp
+

arch/x86/cpu/setjmp.S line 58

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax, %edx
+#else
+       movl 4(%esp), %edx      /* jmp_ptr address */
+#endif
+       movl 1, %eax

This should be $1.

But I still think the setjmp/longjump codes in efi_loader is wrong. We should have longjump() to pass the return value to setjmp().

Quoted 29 lines
arch/x86/cpu/setjmp.S new file +8 -0
+       movl (%edx), %ebx
+       movl 4(%edx), %esp
+       movl 8(%edx), %ebp
+       movl 12(%edx), %esi
+       movl 16(%edx), %edi
+       jmp *20(%edx)
+
+       .size longjmp, .-longjmp
arch/x86/include/asm/setjmp.h new file +15 -0
new file mode 100644
index 0000000..deef67e
@@ -0,0 +1,24 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __setjmp_h
+#define __setjmp_h
+
+struct jmp_buf_data {
+       unsigned int __ebx;
+       unsigned int __esp;
+       unsigned int __ebp;

arch/x86/include/asm/setjmp.h

Quoted 10 lines
arch/x86/include/asm/setjmp.h new file +9 -1
+       unsigned int __esi;
+       unsigned int __edi;
+       unsigned int __eip;
+};
+
+int setjmp(struct jmp_buf_data *jmp_buf);
+void longjmp(struct jmp_buf_data *jmp_buf);
+
+#endif
--

Regards,
Bin

#36 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

Quoted 105 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y  += interrupts.o cpu.o cpu_x86.o call64.o
+obj-y  += interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +2 -0
new file mode 100644
index 0000000..7443274
@@ -0,0 +1,66 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>

arch/x86/cpu/setjmp.S line 12

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+

I believe the above 3 includes are not needed.

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +36 -0
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax, %edx
+#else
+       movl 4(%esp), %edx
+#endif
+       popl %ecx               /* Return address, and adjust the stack */
+       xorl %eax, %eax         /* Return value */
+       movl %ebx, (%edx)
+       movl %esp, 4(%edx)      /* Post-return %esp! */
+       pushl %ecx              /* Make the call/return stack happy */
+       movl %ebp, 8(%edx)
+       movl %esi, 12(%edx)
+       movl %edi, 16(%edx)
+       movl %ecx, 20(%edx)     /* Return address */
+       ret
+
+       /* Provide function size if needed */
+       .size setjmp, .-setjmp
+

arch/x86/cpu/setjmp.S line 58

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax, %edx
+#else
+       movl 4(%esp), %edx      /* jmp_ptr address */
+#endif
+       movl 1, %eax

This should be $1.

Quoted 2 lines

But I still think the setjmp/longjump codes in efi_loader is wrong. We should have longjump() to pass the return value to setjmp().

Why? Where's the difference?

Alex

#37 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

Hi Alex,

Quoted 108 lines · Alexander Graf
Quoted 105 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y  += interrupts.o cpu.o cpu_x86.o call64.o
+obj-y  += interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +2 -0
new file mode 100644
index 0000000..7443274
@@ -0,0 +1,66 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>

arch/x86/cpu/setjmp.S line 12

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+

I believe the above 3 includes are not needed.

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +36 -0
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax, %edx
+#else
+       movl 4(%esp), %edx
+#endif
+       popl %ecx               /* Return address, and adjust the stack */
+       xorl %eax, %eax         /* Return value */
+       movl %ebx, (%edx)
+       movl %esp, 4(%edx)      /* Post-return %esp! */
+       pushl %ecx              /* Make the call/return stack happy */
+       movl %ebp, 8(%edx)
+       movl %esi, 12(%edx)
+       movl %edi, 16(%edx)
+       movl %ecx, 20(%edx)     /* Return address */
+       ret
+
+       /* Provide function size if needed */
+       .size setjmp, .-setjmp
+

arch/x86/cpu/setjmp.S line 58

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax, %edx
+#else
+       movl 4(%esp), %edx      /* jmp_ptr address */
+#endif
+       movl 1, %eax

This should be $1.

Quoted 5 lines
Quoted 2 lines

But I still think the setjmp/longjump codes in efi_loader is wrong. We should have longjump() to pass the return value to setjmp().

Why? Where's the difference?

longjump() does not have the setjmp() return value as the parameter, which concerns me as it does not conform to the standard longjump() implementation. This v2 hardcoded the return value to 1, which makes the following logic work in efi_loader.

if (setjmp(&info->exit_jmp)) {
    /* We returned from the child image */
    return EFI_EXIT(info->exit_status);
}

If we want such a simplified implementation in efi_loader, we should probably rename these functions to efi_setjmp() and efi_longjump().

Regards,
Bin

#38 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

Quoted 122 lines · Bin Meng

Hi Alex,

Quoted 108 lines · Alexander Graf
Quoted 105 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y  += interrupts.o cpu.o cpu_x86.o call64.o
+obj-y  += interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +2 -0
new file mode 100644
index 0000000..7443274
@@ -0,0 +1,66 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>

arch/x86/cpu/setjmp.S line 12

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+

I believe the above 3 includes are not needed.

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +36 -0
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax, %edx
+#else
+       movl 4(%esp), %edx
+#endif
+       popl %ecx               /* Return address, and adjust the stack */
+       xorl %eax, %eax         /* Return value */
+       movl %ebx, (%edx)
+       movl %esp, 4(%edx)      /* Post-return %esp! */
+       pushl %ecx              /* Make the call/return stack happy */
+       movl %ebp, 8(%edx)
+       movl %esi, 12(%edx)
+       movl %edi, 16(%edx)
+       movl %ecx, 20(%edx)     /* Return address */
+       ret
+
+       /* Provide function size if needed */
+       .size setjmp, .-setjmp
+

arch/x86/cpu/setjmp.S line 58

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax, %edx
+#else
+       movl 4(%esp), %edx      /* jmp_ptr address */
+#endif
+       movl 1, %eax

This should be $1.

Quoted 5 lines
Quoted 2 lines

But I still think the setjmp/longjump codes in efi_loader is wrong. We should have longjump() to pass the return value to setjmp().

Why? Where's the difference?

longjump() does not have the setjmp() return value as the parameter, which concerns me as it does not conform to the standard longjump() implementation. This v2 hardcoded the return value to 1, which makes the following logic work in efi_loader.

Quoted 7 lines
if (setjmp(&info->exit_jmp)) {
    /* We returned from the child image */
    return EFI_EXIT(info->exit_status);
}

If we want such a simplified implementation in efi_loader, we should probably rename these functions to efi_setjmp() and efi_longjump().

Ah, I see. The second parameter to longjmp() should be the the return value after the jump - which the code above actually implements. And then it clobbers it with a 1.

I guess that's my fault, because I skipped the second argument bit in my longjmp header definition. Please just add it to the longjmp prototype and explicitly pass "1" as return value in (don't forget to adapt the prototypes in arch/arm/include/asm/setjmp.h). I can fix up the arm code later to actually pass the argument.

Alex

#39 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

Hi Alex,

Quoted 137 lines · Alexander Graf
Quoted 122 lines · Bin Meng

Hi Alex,

Quoted 108 lines · Alexander Graf
Quoted 105 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y  += interrupts.o cpu.o cpu_x86.o call64.o
+obj-y  += interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +2 -0
new file mode 100644
index 0000000..7443274
@@ -0,0 +1,66 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>

arch/x86/cpu/setjmp.S line 12

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+

I believe the above 3 includes are not needed.

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +36 -0
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax, %edx
+#else
+       movl 4(%esp), %edx
+#endif
+       popl %ecx               /* Return address, and adjust the stack */
+       xorl %eax, %eax         /* Return value */
+       movl %ebx, (%edx)
+       movl %esp, 4(%edx)      /* Post-return %esp! */
+       pushl %ecx              /* Make the call/return stack happy */
+       movl %ebp, 8(%edx)
+       movl %esi, 12(%edx)
+       movl %edi, 16(%edx)
+       movl %ecx, 20(%edx)     /* Return address */
+       ret
+
+       /* Provide function size if needed */
+       .size setjmp, .-setjmp
+

arch/x86/cpu/setjmp.S line 58

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax, %edx
+#else
+       movl 4(%esp), %edx      /* jmp_ptr address */
+#endif
+       movl 1, %eax

This should be $1.

Quoted 5 lines
Quoted 2 lines

But I still think the setjmp/longjump codes in efi_loader is wrong. We should have longjump() to pass the return value to setjmp().

Why? Where's the difference?

longjump() does not have the setjmp() return value as the parameter, which concerns me as it does not conform to the standard longjump() implementation. This v2 hardcoded the return value to 1, which makes the following logic work in efi_loader.

Quoted 7 lines
if (setjmp(&info->exit_jmp)) {
    /* We returned from the child image */
    return EFI_EXIT(info->exit_status);
}

If we want such a simplified implementation in efi_loader, we should probably rename these functions to efi_setjmp() and efi_longjump().

Ah, I see. The second parameter to longjmp() should be the the return value after the jump - which the code above actually implements. And then it clobbers it with a 1.

Quoted 5 lines

I guess that's my fault, because I skipped the second argument bit in my longjmp header definition. Please just add it to the longjmp prototype and explicitly pass "1" as return value in (don't forget to adapt the prototypes in arch/arm/include/asm/setjmp.h). I can fix up the arm code later to actually pass the argument.

Would you mind doing the fix-up patch? I don't think we should change the prototype separate from the ARM code.

Regards,
Simon

#40 lore raw

PATCH v2 1/8 x86: Add implementations of setjmp() and longjmp()

Quoted 140 lines · Simon Glass

Hi Alex,

Quoted 137 lines · Alexander Graf
Quoted 122 lines · Bin Meng

Hi Alex,

Quoted 108 lines · Alexander Graf
Quoted 105 lines · Bin Meng

Hi Simon,

Quoted 40 lines · Simon Glass

Bring in these functions from Linux v4.4. They will be needed for EFI loader support.

---

Changes in v2:
- Drop irrelevant comment
- Add a comment about .size
- Drop unnecessary .text directive
- Make longjmp() always cause setjmp() to return 1

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 66 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 ++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/cpu/setjmp.S
 create mode 100644 arch/x86/include/asm/setjmp.h
arch/x86/cpu/Makefile +1 -1
index 2667e0b..f5b8c9e 100644
@@ -10,7 +10,7 @@
 
 extra-y        = start.o
 obj-$(CONFIG_X86_RESET_VECTOR) += resetvec.o start16.o
-obj-y  += interrupts.o cpu.o cpu_x86.o call64.o
+obj-y  += interrupts.o cpu.o cpu_x86.o call64.o setjmp.o
 
 AFLAGS_REMOVE_call32.o := -mregparm=3 \
        $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
arch/x86/cpu/setjmp.S new file +2 -0
new file mode 100644
index 0000000..7443274
@@ -0,0 +1,66 @@
+/*
+ * Written by H. Peter Anvin <[email protected]>

arch/x86/cpu/setjmp.S line 12

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ * Brought in from Linux v4.4 and modified for U-Boot
+ * From Linux arch/um/sys-i386/setjmp.S
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+

I believe the above 3 includes are not needed.

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +36 -0
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax, %edx
+#else
+       movl 4(%esp), %edx
+#endif
+       popl %ecx               /* Return address, and adjust the stack */
+       xorl %eax, %eax         /* Return value */
+       movl %ebx, (%edx)
+       movl %esp, 4(%edx)      /* Post-return %esp! */
+       pushl %ecx              /* Make the call/return stack happy */
+       movl %ebp, 8(%edx)
+       movl %esi, 12(%edx)
+       movl %edi, 16(%edx)
+       movl %ecx, 20(%edx)     /* Return address */
+       ret
+
+       /* Provide function size if needed */
+       .size setjmp, .-setjmp
+

arch/x86/cpu/setjmp.S line 58

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax, %edx
+#else
+       movl 4(%esp), %edx      /* jmp_ptr address */
+#endif
+       movl 1, %eax

This should be $1.

Quoted 5 lines
Quoted 2 lines

But I still think the setjmp/longjump codes in efi_loader is wrong. We should have longjump() to pass the return value to setjmp().

Why? Where's the difference?

longjump() does not have the setjmp() return value as the parameter, which concerns me as it does not conform to the standard longjump() implementation. This v2 hardcoded the return value to 1, which makes the following logic work in efi_loader.

Quoted 7 lines
if (setjmp(&info->exit_jmp)) {
    /* We returned from the child image */
    return EFI_EXIT(info->exit_status);
}

If we want such a simplified implementation in efi_loader, we should probably rename these functions to efi_setjmp() and efi_longjump().

Ah, I see. The second parameter to longjmp() should be the the return value after the jump - which the code above actually implements. And then it clobbers it with a 1.

Quoted 8 lines
Quoted 5 lines

I guess that's my fault, because I skipped the second argument bit in my longjmp header definition. Please just add it to the longjmp prototype and explicitly pass "1" as return value in (don't forget to adapt the prototypes in arch/arm/include/asm/setjmp.h). I can fix up the arm code later to actually pass the argument.

Would you mind doing the fix-up patch? I don't think we should change the prototype separate from the ARM code.

Yes, we should fix the longjump() declaration as well as the ARM codes first. Then rework this x86 implementation to handle return value in the assembly codes.

Regards,
Bin