Skip to contentSkip to conversation

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

PATCH Superseded Simon Glass 4 participants 30 messages Aug 6, 2016 – Nov 7, 2016

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

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

---

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 71 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 +++++++++++++++
 3 files changed, 96 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 +71 -0

71 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 2/6 efi: Fix missing EFIAPI specifiers

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

---

 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 d66892e..0536b63 100644
@@ -14,6 +14,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;
 
@@ -51,7 +53,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)
 {
@@ -144,7 +146,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 c434c92..0a35d53 100644
@@ -33,9 +33,10 @@ struct efi_disk_obj {
 	lbaint_t offset;
 };
 
-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;
 
@@ -44,7 +45,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)
 {
@@ -107,7 +108,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)
 {
@@ -142,7 +143,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
#2 lore raw

PATCH 2/6 efi: Fix missing EFIAPI specifiers

Quoted 12 lines · Simon Glass

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

---

 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(-)
#4 lore raw

PATCH 2/6 efi: Fix missing EFIAPI specifiers

Hi Alex,

Quoted 11 lines · Alexander Graf
Quoted 4 lines · Simon Glass

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

Is there any way to change the EFIAPI definition so that we get build warnings for non matching function types on aarch64 as well?

It might be possible to add a bogus attribute that does nothing. Perhaps regparm(0)?

Regards,
Simon

#5 lore raw

PATCH 3/6 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.

---

 arch/arm/lib/HelloWorld32.efi  | Bin 0 -> 11712 bytes
 arch/arm/lib/Makefile          |   6 ++++++
 cmd/Kconfig                    |  10 ++++++++++
 cmd/bootefi.c                  |  26 ++++++++++++++++++++------
 include/asm-generic/sections.h |   2 ++
 scripts/Makefile.lib           |  19 +++++++++++++++++++
 6 files changed, 57 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%g6Be^YlJNs?gQ@2 zfRlg)Z%7B*szJ%#g_3jd;5O}^@bpxe88DpUPv(;G$~Jnr*DMS+t#4}dbB^$yk3)p z{*S_{Z4>)+82K<dA~SE+C@}JFmWrgA0r-q1$k>06Y?qQTTos{AwASbMafhyDt~i zZ-P1(@?_?GjSSTP0BZGc5P186_aR{IC&BVKK8f$)!_z+sYll|SZ1!!ECcT8aCrI@ z=s$~>y}!s at smVs47k$Towc<jCxk{6Xo>#+}HOpF<;+IGXJo?m^GVtjJ#_|hE<|jlO z4}=SNmS4|TVEo{haeUEc4%J<o#Vdhm6O7AEcz?I<oMz1!EQ40d+20bLdZ5i8{i0R zd<A9l8}T*q=VX7M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7{&~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 +6 -0
index a8d1557..0f3ea0c 100644
@@ -29,6 +29,12 @@ obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTM) += 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.
+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 d69b817..8df80b6 100644
@@ -172,6 +172,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 0536b63..ecf9968 100644
@@ -229,13 +229,22 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	if (argc < 2)
 		return 1;
-	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);
@@ -253,7 +262,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 e720562..07469f0 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
#6 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Hi Simon,

Quoted 15 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.

---

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

[snip]

arch/arm/lib/Makefile obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o · line 33

Quoted 10 lines
arch/arm/lib/Makefile +2 -0
index a8d1557..0f3ea0c 100644
@@ -29,6 +29,12 @@ obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTM) += 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.

If so, can we just remove this for arm64?

Quoted 13 lines
arch/arm/lib/Makefile +4 -0
+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 d69b817..8df80b6 100644
@@ -172,6 +172,16 @@ config CMD_BOOTEFI
        help

cmd/Kconfig config CMD_BOOTEFI · line 182

Quoted 10 lines
cmd/Kconfig +8 -0
          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

typo: working, bringing

Quoted 38 lines
cmd/Kconfig +2 -0
+         up EFI support on a new architecture.
+
 config CMD_ELF
        bool "bootelf, bootvx"
        default y
cmd/bootefi.c +14 -5
index 0536b63..ecf9968 100644
@@ -229,13 +229,22 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        if (argc < 2)
                return 1;
-       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);

cmd/bootefi.c static char bootefi_help_text[] = · line 268

Quoted 8 lines
cmd/bootefi.c +4 -1
@@ -253,7 +262,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"

typo: World

Quoted 26 lines
cmd/bootefi.c +2 -0
+#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 +0 -0
index e720562..07469f0 100644
@@ -321,6 +321,25 @@ cmd_S_ttf=                                         \
 $(obj)/%.S: $(src)/%.ttf
        $(call cmd,S_ttf)
 

scripts/Makefile.lib cmd_S_ttf= \ · line 333

Quoted 10 lines
scripts/Makefile.lib +10 -0
+# 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:';                        \

nits: the ending \ is not aligned with other lines

scripts/Makefile.lib cmd_S_ttf= \ · line 336

Quoted 3 lines
scripts/Makefile.lib +3 -0
+       echo '.incbin "$<" ';                           \
+       echo '__efi_hello_world_end:';                  \
+       echo '.global __efi_hello_world_end';                   \

nits: the ending \ is not aligned with other lines

scripts/Makefile.lib cmd_S_ttf= \

Quoted 10 lines
scripts/Makefile.lib +6 -1
+       echo '.balign 16';                              \
+) > $@
+
+$(obj)/%.S: $(src)/%.efi
+       $(call cmd,S_efi)
+
 # ACPI
 # ---------------------------------------------------------------------------
 quiet_cmd_acpi_c_asl= ASL     $<
--

Regards,
Bin

#7 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 15 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.

---

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

[snip]

Quoted 12 lines

arch/arm/lib/Makefile obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o · line 33

Quoted 10 lines
arch/arm/lib/Makefile +2 -0
index a8d1557..0f3ea0c 100644
@@ -29,6 +29,12 @@ obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTM) += 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.

If so, can we just remove this for arm64?

Actually I was hoping that Alexander might have a suitable arm64 HelloWorld.efi lying around. When I tried building UEFI for arm64, for some reason it did not create it.

Quoted 8 lines

arch/arm/lib/Makefile obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o · line 40

Quoted 8 lines
arch/arm/lib/Makefile +4 -0
+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

[...]

Regards,
Simon

#8 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Quoted 40 lines

Am 09.08.2016 um 20:16 schrieb Simon Glass <[email protected]>:

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 15 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.

---

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

create mode 100644 arch/arm/lib/HelloWorld32.efi

[snip]

Quoted 12 lines

arch/arm/lib/Makefile obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o · line 33

Quoted 10 lines
arch/arm/lib/Makefile +0 -0
index a8d1557..0f3ea0c 100644
@@ -29,6 +29,12 @@ obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o

obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-$(CONFIG_CMD_BOOTM) += zimage.o
obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o

arch/arm/lib/Makefile +2 -0
+ifdef CONFIG_ARM64
+# This option does not work for arm64, as there is no binary.

If so, can we just remove this for arm64?

Quoted 3 lines

Actually I was hoping that Alexander might have a suitable arm64 HelloWorld.efi lying around. When I tried building UEFI for arm64, for some reason it did not create it.

Is it part of edk2? If so, Leif (CC'ed) might have one :). I usually use grub as my hello world application.

Alex

#9 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Quoted 40 lines · Alexander Graf
Quoted 40 lines

Am 09.08.2016 um 20:16 schrieb Simon Glass <[email protected]>:

Hi Bin,

Quoted 33 lines · Bin Meng

Hi Simon,

Quoted 15 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.

---

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

create mode 100644 arch/arm/lib/HelloWorld32.efi

[snip]

arch/arm/lib/Makefile obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o · line 33

Quoted 10 lines
arch/arm/lib/Makefile +0 -0
index a8d1557..0f3ea0c 100644
@@ -29,6 +29,12 @@ obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o

obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-$(CONFIG_CMD_BOOTM) += zimage.o
obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o

arch/arm/lib/Makefile +2 -0
+ifdef CONFIG_ARM64
+# This option does not work for arm64, as there is no binary.

If so, can we just remove this for arm64?

Quoted 6 lines
Quoted 3 lines

Actually I was hoping that Alexander might have a suitable arm64 HelloWorld.efi lying around. When I tried building UEFI for arm64, for some reason it did not create it.

Is it part of edk2? If so, Leif (CC'ed) might have one :). I usually use grub as my hello world application.

There is a hello world application in EDK2, but it does not get built as part of a normal platform build.
Currently it also fails to build for ARM* on its own :| See
http://patchew.org/EDK2/1471021908-3509-1-git-send-email-leif.lindholm%40linaro.org/
for a hack of how to build one before upstream is resolved.

If cross compiling, prepend GCC5_AARCH64_PREFIX=aarch64-linux-gnu- to build command line.

/
Leif

#10 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Hi Leif,

Quoted 55 lines · Leif Lindholm
Quoted 40 lines · Alexander Graf
Quoted 40 lines

Am 09.08.2016 um 20:16 schrieb Simon Glass <[email protected]>:

Hi Bin,

Quoted 33 lines · Bin Meng

Hi Simon,

Quoted 15 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.

---

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

create mode 100644 arch/arm/lib/HelloWorld32.efi

[snip]

arch/arm/lib/Makefile obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o · line 33

Quoted 10 lines
arch/arm/lib/Makefile +0 -0
index a8d1557..0f3ea0c 100644
@@ -29,6 +29,12 @@ obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o

obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-$(CONFIG_CMD_BOOTM) += zimage.o
obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o

arch/arm/lib/Makefile +2 -0
+ifdef CONFIG_ARM64
+# This option does not work for arm64, as there is no binary.

If so, can we just remove this for arm64?

Quoted 6 lines
Quoted 3 lines

Actually I was hoping that Alexander might have a suitable arm64 HelloWorld.efi lying around. When I tried building UEFI for arm64, for some reason it did not create it.

Is it part of edk2? If so, Leif (CC'ed) might have one :). I usually use grub as my hello world application.

There is a hello world application in EDK2, but it does not get built as part of a normal platform build.
Currently it also fails to build for ARM* on its own :| See
http://patchew.org/EDK2/1471021908-3509-1-git-send-email-leif.lindholm%40linaro.org/
for a hack of how to build one before upstream is resolved.

Quoted 2 lines

If cross compiling, prepend GCC5_AARCH64_PREFIX=aarch64-linux-gnu- to build command line.

Thanks for the pointer. Unfortunately that patch appears to make no differences for me. Are you able to build and send me a 64-bit HelloWorld.efi please?

Quoted 3 lines

/
Leif

Regards,
Simon

#11 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Quoted 16 lines · Simon Glass
Quoted 16 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

If so, can we just remove this for arm64?

Actually I was hoping that Alexander might have a suitable arm64 HelloWorld.efi lying around. When I tried building UEFI for arm64, for some reason it did not create it.

Is it part of edk2? If so, Leif (CC'ed) might have one :). I usually use grub as my hello world application.

There is a hello world application in EDK2, but it does not get built as part of a normal platform build.
Currently it also fails to build for ARM* on its own :| See
http://patchew.org/EDK2/1471021908-3509-1-git-send-email-leif.lindholm%40linaro.org/
for a hack of how to build one before upstream is resolved.

Quoted 6 lines
Quoted 2 lines

If cross compiling, prepend GCC5_AARCH64_PREFIX=aarch64-linux-gnu- to build command line.

Thanks for the pointer. Unfortunately that patch appears to make no differences for me. Are you able to build and send me a 64-bit HelloWorld.efi please?

So, I probably could, but if that isn't working for you, I'd quite like to know why.

To make that a little less painful though, I've added support for building the helloworld app to my set of scripts:
https://git.linaro.org/uefi/uefi-tools.git

This still depends on this (updated) patch.
https://lists.01.org/pipermail/edk2-devel/2016-September/002112.html

But with a current edk2, and a uefi-tools placed in the same directory as the edk2 clone, could you try executing:

../uefi-tools/uefi-build.sh -A AARCH64 hello

If the build fails and creates messy output due to being parallel, could you stick a -1 on that command line and send me the output (or pastebin)?

/
Leif

#12 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Hi Leif,

Quoted 35 lines · Leif Lindholm
Quoted 16 lines · Simon Glass
Quoted 16 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

If so, can we just remove this for arm64?

Actually I was hoping that Alexander might have a suitable arm64 HelloWorld.efi lying around. When I tried building UEFI for arm64, for some reason it did not create it.

Is it part of edk2? If so, Leif (CC'ed) might have one :). I usually use grub as my hello world application.

There is a hello world application in EDK2, but it does not get built as part of a normal platform build.
Currently it also fails to build for ARM* on its own :| See
http://patchew.org/EDK2/1471021908-3509-1-git-send-email-leif.lindholm%40linaro.org/
for a hack of how to build one before upstream is resolved.

Quoted 6 lines
Quoted 2 lines

If cross compiling, prepend GCC5_AARCH64_PREFIX=aarch64-linux-gnu- to build command line.

Thanks for the pointer. Unfortunately that patch appears to make no differences for me. Are you able to build and send me a 64-bit HelloWorld.efi please?

So, I probably could, but if that isn't working for you, I'd quite like to know why.

To make that a little less painful though, I've added support for building the helloworld app to my set of scripts:
https://git.linaro.org/uefi/uefi-tools.git

This still depends on this (updated) patch.
https://lists.01.org/pipermail/edk2-devel/2016-September/002112.html

Quoted 8 lines

But with a current edk2, and a uefi-tools placed in the same directory as the edk2 clone, could you try executing:

../uefi-tools/uefi-build.sh -A AARCH64 hello

If the build fails and creates messy output due to being parallel, could you stick a -1 on that command line and send me the output (or pastebin)?

OK thanks. Please see:

http://pastebin.com/DmixdA4C

Regards,
Simon

#13 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Quoted 22 lines · Simon Glass

Hi Leif,

Quoted 19 lines · Leif Lindholm
Quoted 3 lines

Thanks for the pointer. Unfortunately that patch appears to make no differences for me. Are you able to build and send me a 64-bit HelloWorld.efi please?

So, I probably could, but if that isn't working for you, I'd quite like to know why.

To make that a little less painful though, I've added support for building the helloworld app to my set of scripts:
https://git.linaro.org/uefi/uefi-tools.git

This still depends on this (updated) patch.
https://lists.01.org/pipermail/edk2-devel/2016-September/002112.html

But with a current edk2, and a uefi-tools placed in the same directory as the edk2 clone, could you try executing:

../uefi-tools/uefi-build.sh -A AARCH64 hello

Quoted 7 lines
Quoted 3 lines

If the build fails and creates messy output due to being parallel, could you stick a -1 on that command line and send me the output (or pastebin)?

OK thanks. Please see:

http://pastebin.com/DmixdA4C

Right ... so your terminal appears to be discarding stderr, but I'm guessing with that enabled it would look like:
---
Processing meta-data ..

build.py...
/work/git/edk2/MdeModulePkg/MdeModulePkg.dsc(...): error 4000: Instance of library class [ArmMmuLib] is not found
in [/work/git/edk2/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf] [AARCH64]
consumed by module [/work/git/edk2/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf]

- Failed -
Build end time: 16:51:18, Oct.19 2016
Build total time: 00:00:03
---

Which is what it looks without the aforementioned patch applied.

(But the no error messages thing really spooks me.)

/
Leif

#14 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Quoted 42 lines · Leif Lindholm
Quoted 22 lines · Simon Glass

Hi Leif,

Quoted 19 lines · Leif Lindholm
Quoted 3 lines

Thanks for the pointer. Unfortunately that patch appears to make no differences for me. Are you able to build and send me a 64-bit HelloWorld.efi please?

So, I probably could, but if that isn't working for you, I'd quite like to know why.

To make that a little less painful though, I've added support for building the helloworld app to my set of scripts:
https://git.linaro.org/uefi/uefi-tools.git

This still depends on this (updated) patch.
https://lists.01.org/pipermail/edk2-devel/2016-September/002112.html

But with a current edk2, and a uefi-tools placed in the same directory as the edk2 clone, could you try executing:

../uefi-tools/uefi-build.sh -A AARCH64 hello

Quoted 7 lines
Quoted 3 lines

If the build fails and creates messy output due to being parallel, could you stick a -1 on that command line and send me the output (or pastebin)?

OK thanks. Please see:

http://pastebin.com/DmixdA4C

Right ... so your terminal appears to be discarding stderr, but I'm guessing with that enabled it would look like:
---
Processing meta-data ..

build.py...
/work/git/edk2/MdeModulePkg/MdeModulePkg.dsc(...): error 4000: Instance of library class [ArmMmuLib] is not found
in [/work/git/edk2/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf] [AARCH64]
consumed by module [/work/git/edk2/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf]

Quoted 6 lines

- Failed -
Build end time: 16:51:18, Oct.19 2016
Build total time: 00:00:03
---

Which is what it looks without the aforementioned patch applied.

As a follow-up: I have now pushed the required patch to edk2, so with a fresh pull it should work without any manually added patches.

/
Leif

#15 lore raw

PATCH 3/6 arm: efi: Add a hello world test program

Hi Leif,

Quoted 43 lines · Leif Lindholm
Quoted 42 lines · Leif Lindholm
Quoted 22 lines · Simon Glass

Hi Leif,

Quoted 19 lines · Leif Lindholm
Quoted 3 lines

Thanks for the pointer. Unfortunately that patch appears to make no differences for me. Are you able to build and send me a 64-bit HelloWorld.efi please?

So, I probably could, but if that isn't working for you, I'd quite like to know why.

To make that a little less painful though, I've added support for building the helloworld app to my set of scripts:
https://git.linaro.org/uefi/uefi-tools.git

This still depends on this (updated) patch.
https://lists.01.org/pipermail/edk2-devel/2016-September/002112.html

But with a current edk2, and a uefi-tools placed in the same directory as the edk2 clone, could you try executing:

../uefi-tools/uefi-build.sh -A AARCH64 hello

Quoted 7 lines
Quoted 3 lines

If the build fails and creates messy output due to being parallel, could you stick a -1 on that command line and send me the output (or pastebin)?

OK thanks. Please see:

http://pastebin.com/DmixdA4C

Right ... so your terminal appears to be discarding stderr, but I'm guessing with that enabled it would look like:
---
Processing meta-data ..

build.py...
/work/git/edk2/MdeModulePkg/MdeModulePkg.dsc(...): error 4000: Instance of library class [ArmMmuLib] is not found
in [/work/git/edk2/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf] [AARCH64]
consumed by module [/work/git/edk2/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf]

Quoted 6 lines
Quoted 6 lines

- Failed -
Build end time: 16:51:18, Oct.19 2016
Build total time: 00:00:03
---

Which is what it looks without the aforementioned patch applied.

I really thought I applied it. But I don't understand the UEFI build system at all...

Quoted 3 lines

As a follow-up: I have now pushed the required patch to edk2, so with a fresh pull it should work without any manually added patches.

I think I'm going to build a simple hello world within the U-Boot tree, to avoiding needing to package a binary.

Regards,
Simon

#16 lore raw

PATCH 4/6 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.

---

 arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
 arch/x86/lib/Makefile         |  1 +
 arch/x86/lib/sections.c       | 12 ++++++++++++
 include/efi.h                 |  3 ++-
 lib/efi_loader/efi_boottime.c |  9 +++++++++
 lib/efi_loader/efi_runtime.c  |  4 ++++
 6 files changed, 63 insertions(+), 2 deletions(-)
 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")));
include/efi.h +2 -1
index 1dbc3b7..47b351f 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;
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
#17 lore raw

PATCH 4/6 x86: efi: Add EFI loader support for x86

Quoted 10 lines · 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.

---

Quoted 9 lines
 arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
 arch/x86/lib/Makefile         |  1 +
 arch/x86/lib/sections.c       | 12 ++++++++++++
 include/efi.h                 |  3 ++-
 lib/efi_loader/efi_boottime.c |  9 +++++++++
 lib/efi_loader/efi_runtime.c  |  4 ++++
 6 files changed, 63 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/lib/sections.c
#18 lore raw

PATCH 4/6 x86: efi: Add EFI loader support for x86

In reply to Simon Glass
Quoted 116 lines · 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.

---

  arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
  arch/x86/lib/Makefile         |  1 +
  arch/x86/lib/sections.c       | 12 ++++++++++++
  include/efi.h                 |  3 ++-
  lib/efi_loader/efi_boottime.c |  9 +++++++++
  lib/efi_loader/efi_runtime.c  |  4 ++++
  6 files changed, 63 insertions(+), 2 deletions(-)

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")));
include/efi.h +1 -0
index 1dbc3b7..47b351f 100644
@@ -15,6 +15,7 @@
  #ifndef _EFI_H
  #define _EFI_H
 
+#include <linux/linkage.h>
  #include <linux/string.h>
  #include <linux/types.h>
 

include/efi.h line 26

Quoted 5 lines
include/efi.h +1 -1
@@ -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

Ah, this should trigger what I mentioned in my previous email. Since linkage.h is now included in efi.h, we no longer have to include the header in bootefi.c explicitly. How about you just move this part of the patch between patches 1/6 and 2/6?

Quoted 16 lines
include/efi.h +0 -0
  #endif
 
  struct efi_device_path;
lib/efi_loader/efi_boottime.c +1 -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

lib/efi_loader/efi_boottime.c static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[1]; · line 50

Quoted 4 lines
lib/efi_loader/efi_boottime.c +1 -0
@@ -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

So is fs reserved for firmware use on x86?

Alex

#19 lore raw

PATCH 4/6 x86: efi: Add EFI loader support for x86

Hi Alex,

Quoted 117 lines · Alexander Graf
Quoted 116 lines · 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.

---

  arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
  arch/x86/lib/Makefile         |  1 +
  arch/x86/lib/sections.c       | 12 ++++++++++++
  include/efi.h                 |  3 ++-
  lib/efi_loader/efi_boottime.c |  9 +++++++++
  lib/efi_loader/efi_runtime.c  |  4 ++++
  6 files changed, 63 insertions(+), 2 deletions(-)

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 = .;
  diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile

index e17f0bb..e46e7f1 100644

arch/x86/lib/Makefile +1 -0
@@ -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 +7 -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")));

arch/x86/lib/sections.c new file +4 -0
+char __efi_runtime_rel_start[0]
+               __attribute__((section(".__efi_runtime_rel_start")));
+char __efi_runtime_rel_stop[0]
+               __attribute__((section(".__efi_runtime_rel_stop")));
include/efi.h +0 -0
index 1dbc3b7..47b351f 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
Quoted 8 lines

include/efi.h line 26

Quoted 2 lines
include/efi.h +1 -1
-#define EFIAPI
+#define EFIAPI asmlinkage

Ah, this should trigger what I mentioned in my previous email. Since linkage.h is now included in efi.h, we no longer have to include the header in bootefi.c explicitly. How about you just move this part of the patch between patches 1/6 and 2/6?

OK will take a look.

Quoted 19 lines
Quoted 19 lines

  #endif
    struct efi_device_path;
lib/efi_loader/efi_boottime.c +0 -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

lib/efi_loader/efi_boottime.c +0 -0
@@ -46,16 +47,20 @@ static struct efi_configuration_table EFI_RUNTIME_DATA
Quoted 8 lines

lib/efi_loader/efi_boottime.c static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[1]; · line 50

Quoted 5 lines
lib/efi_loader/efi_boottime.c +1 -0
 efi_conf_table[1];
   * EFI callback entry/exit.
   */
  static volatile void *efi_gd, *app_gd;
+#endif

So is fs reserved for firmware use on x86?

No I don't think so. The correct approach would be to save and restore the FS register, but it seems to work this way, so I haven't taken it any further.

This series was just an attempt to get the EFI loader working on x86. Since we have the 32/64-bit limitation on x86 and U-Boot runs in 32-bit at present, it's not going to be very useful yet IMO. But it is a start.

Quoted 4 lines

Alex

Regards,
Simon

#20 lore raw

PATCH 4/6 x86: efi: Add EFI loader support for x86

Quoted 153 lines · Simon Glass

Hi Alex,

Quoted 115 lines · Alexander Graf
Quoted 114 lines · 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.

---

   arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
   arch/x86/lib/Makefile         |  1 +
   arch/x86/lib/sections.c       | 12 ++++++++++++
   include/efi.h                 |  3 ++-
   lib/efi_loader/efi_boottime.c |  9 +++++++++
   lib/efi_loader/efi_runtime.c  |  4 ++++
   6 files changed, 63 insertions(+), 2 deletions(-)

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 = .;
   diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile

index e17f0bb..e46e7f1 100644

arch/x86/lib/Makefile +1 -0
@@ -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 +7 -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")));

arch/x86/lib/sections.c new file +4 -0
+char __efi_runtime_rel_start[0]
+               __attribute__((section(".__efi_runtime_rel_start")));
+char __efi_runtime_rel_stop[0]
+               __attribute__((section(".__efi_runtime_rel_stop")));
include/efi.h +0 -0
index 1dbc3b7..47b351f 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))
Quoted 8 lines

include/efi.h line 26

Quoted 3 lines
   #else
include/efi.h +1 -1
-#define EFIAPI
+#define EFIAPI asmlinkage

Ah, this should trigger what I mentioned in my previous email. Since linkage.h is now included in efi.h, we no longer have to include the header in bootefi.c explicitly. How about you just move this part of the patch between patches 1/6 and 2/6?

OK will take a look.

Quoted 17 lines
Quoted 17 lines
   #endif
     struct efi_device_path;
lib/efi_loader/efi_boottime.c +0 -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

Quoted 8 lines

lib/efi_loader/efi_boottime.c static struct efi_configuration_table EFI_RUNTIME_DATA · line 51

Quoted 6 lines
lib/efi_loader/efi_boottime.c +1 -0
@@ -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

So is fs reserved for firmware use on x86?

Quoted 3 lines

No I don't think so. The correct approach would be to save and restore the FS register, but it seems to work this way, so I haven't taken it any further.

Well, FS is a typical TLS register, so there's a good chance it is reserved for something. At least the EFI payload on x86 does explicitly not use fs, so maybe you are safe. Just double-check the spec :).

Quoted 5 lines

This series was just an attempt to get the EFI loader working on x86. Since we have the 32/64-bit limitation on x86 and U-Boot runs in 32-bit at present, it's not going to be very useful yet IMO. But it is a start.

I agree, and it makes me happy so see how little effort it is to make x86 work :). Now we just need to wrap all the tables as well and you should be able to run Linux!

Alex

#21 lore raw

PATCH 4/6 x86: efi: Add EFI loader support for x86

In reply to Simon Glass
Quoted 159 lines · Simon Glass

Hi Alex,

Quoted 117 lines · Alexander Graf
Quoted 116 lines · 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.

---

  arch/x86/cpu/u-boot.lds       | 36 +++++++++++++++++++++++++++++++++++-
  arch/x86/lib/Makefile         |  1 +
  arch/x86/lib/sections.c       | 12 ++++++++++++
  include/efi.h                 |  3 ++-
  lib/efi_loader/efi_boottime.c |  9 +++++++++
  lib/efi_loader/efi_runtime.c  |  4 ++++
  6 files changed, 63 insertions(+), 2 deletions(-)

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 = .;
  diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile

index e17f0bb..e46e7f1 100644

arch/x86/lib/Makefile +1 -0
@@ -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 +7 -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")));

arch/x86/lib/sections.c new file +4 -0
+char __efi_runtime_rel_start[0]
+               __attribute__((section(".__efi_runtime_rel_start")));
+char __efi_runtime_rel_stop[0]
+               __attribute__((section(".__efi_runtime_rel_stop")));
include/efi.h +0 -0
index 1dbc3b7..47b351f 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
Quoted 8 lines

include/efi.h line 26

Quoted 2 lines
include/efi.h +1 -1
-#define EFIAPI
+#define EFIAPI asmlinkage

Ah, this should trigger what I mentioned in my previous email. Since linkage.h is now included in efi.h, we no longer have to include the header in bootefi.c explicitly. How about you just move this part of the patch between patches 1/6 and 2/6?

OK will take a look.

Quoted 19 lines
Quoted 19 lines

  #endif
    struct efi_device_path;
lib/efi_loader/efi_boottime.c +0 -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

lib/efi_loader/efi_boottime.c +0 -0
@@ -46,16 +47,20 @@ static struct efi_configuration_table EFI_RUNTIME_DATA
Quoted 8 lines

lib/efi_loader/efi_boottime.c static struct efi_configuration_table EFI_RUNTIME_DATA efi_conf_table[1]; · line 50

Quoted 5 lines
lib/efi_loader/efi_boottime.c +1 -0
 efi_conf_table[1];
   * EFI callback entry/exit.
   */
  static volatile void *efi_gd, *app_gd;
+#endif

So is fs reserved for firmware use on x86?

Quoted 3 lines

No I don't think so. The correct approach would be to save and restore the FS register, but it seems to work this way, so I haven't taken it any further.

Can you make sure you save/restore %fs on x86 in the next round then? Finding bugs like these is very hard once the code is in.

Quoted 1 line

This series was just an attempt to get the EFI loader working on x86.

Yes, and it's very very very much appreciated :).

Quoted 3 lines

Since we have the 32/64-bit limitation on x86 and U-Boot runs in 32-bit at present, it's not going to be very useful yet IMO. But it is a start.

I agree. It's a really good start.

Alex

#22 lore raw

PATCH 4/6 x86: efi: Add EFI loader support for x86

Hi Alex,

Quoted 5 lines · Alexander Graf
Quoted 2 lines · Simon Glass

Hi Alex,

[...]

Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 17 lines
  #endif
    struct efi_device_path;
lib/efi_loader/efi_boottime.c +0 -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

lib/efi_loader/efi_boottime.c static struct efi_configuration_table EFI_RUNTIME_DATA · line 51

Quoted 5 lines
lib/efi_loader/efi_boottime.c +1 -0
@@ -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

So is fs reserved for firmware use on x86?

Quoted 6 lines
Quoted 3 lines

No I don't think so. The correct approach would be to save and restore the FS register, but it seems to work this way, so I haven't taken it any further.

Can you make sure you save/restore %fs on x86 in the next round then? Finding bugs like these is very hard once the code is in.

I still haven't done this. In fact I'm starting to wonder what other registers we might have a problem with. Looking at the setjmp()/longjmp() that I have, it doesn't save everything.

Quoted 10 lines
Quoted 2 lines

This series was just an attempt to get the EFI loader working on x86.

Yes, and it's very very very much appreciated :).

Quoted 3 lines

Since we have the 32/64-bit limitation on x86 and U-Boot runs in 32-bit at present, it's not going to be very useful yet IMO. But it is a start.

I agree. It's a really good start.

I suspect that it will be quite a bit of work to get U-Boot running in 64-bit mode. I sent a series about a month ago, but it still lacks quite a few features.

Regards,
Simon

#23 lore raw

PATCH 5/6 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.

---

 arch/x86/lib/HelloWorld.efi | Bin 0 -> 11168 bytes
 arch/x86/lib/Makefile       |   1 +
 2 files changed, 1 insertion(+)
 create mode 100644 arch/x86/lib/HelloWorld.efi
arch/x86/lib/HelloWorld.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?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Bp3-)Dc;{;&35*x$6jXK$)>RCZQ=x3ahLt;%^-rYgL(Fbu~qe}l(f z%RWo5<$$Hna?o<f(r-CpdC@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..e8172cb 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) += efi_hello_world.o
 obj-y	+= e820.o
 obj-y	+= gcc.o
 obj-y	+= init_helpers.o
Signature · 1 line
2.8.0.rc3.226.g39d4020
#24 lore raw

PATCH 5/6 x86: efi: Add a hello world test program

Quoted 10 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.

---

 arch/x86/lib/HelloWorld.efi | Bin 0 -> 11168 bytes
 arch/x86/lib/Makefile       |   1 +
 2 files changed, 1 insertion(+)
 create mode 100644 arch/x86/lib/HelloWorld.efi

Should we rename this to HelloWorld32.efi, just like ARM?

Quoted 1 line

[snip]

arch/x86/lib/Makefile obj-$(CONFIG_CMD_BOOTM) += bootm.o · line 15

Quoted 9 lines
arch/x86/lib/Makefile +1 -0
index e46e7f1..e8172cb 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) += efi_hello_world.o

This should be HelloWorld.o, or if we do like ARM, HelloWorld32.o

arch/x86/lib/Makefile obj-$(CONFIG_CMD_BOOTM) += bootm.o

Quoted 4 lines
arch/x86/lib/Makefile +0 -1
 obj-y  += e820.o
 obj-y  += gcc.o
 obj-y  += init_helpers.o
--

Regards,
Bin

#25 lore raw

PATCH 6/6 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.

---

 lib/efi_loader/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
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
#26 lore raw

PATCH 6/6 x86: Enable EFI loader support

Hi Simon,

Quoted 14 lines · Simon Glass

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

---

 lib/efi_loader/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/Kconfig +0 -0
index 37a0dd6..8e7e8a5 100644

lib/efi_loader/Kconfig

Quoted 8 lines
lib/efi_loader/Kconfig +1 -2
@@ -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)
--

Can you also update README.x86 to remove this EFI_LOADER from TODO list?

Regards,
Bin

#27 lore raw

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

In reply to Simon Glass

Hi Simon,

Quoted 51 lines · Simon Glass

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

---

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 71 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 +++++++++++++++
 3 files changed, 96 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 +19 -0
new file mode 100644
index 0000000..24e7d8a
@@ -0,0 +1,71 @@
+/*
+ * 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
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp

arch/x86/cpu/setjmp.S line 29

Quoted 10 lines
arch/x86/cpu/setjmp.S new file +10 -0
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
+
+       /*
+        * rdi - 32-bit code segment selector
+        * rsi - target address
+        * rdx - table address (0 if none)
+        */

The comment above looks irrelevant.

arch/x86/cpu/setjmp.S line 36

Quoted 7 lines
arch/x86/cpu/setjmp.S new file +7 -0
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax,%edx

nits: needs space after ",". please fix this globally in this file.

arch/x86/cpu/setjmp.S line 40

Quoted 4 lines
arch/x86/cpu/setjmp.S new file +4 -0
+#else
+       movl 4(%esp),%edx
+#endif
+       popl %ecx                       # Return address, and adjust the stack

I believe # is deprecated. We should use /* */

arch/x86/cpu/setjmp.S line 51

Quoted 11 lines
arch/x86/cpu/setjmp.S new file +11 -0
+       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
+
+       .size setjmp,.-setjmp

What is this .size for?

arch/x86/cpu/setjmp.S line 53

Quoted 2 lines
arch/x86/cpu/setjmp.S new file +2 -0
+
+       .text

nits: not necessary

Quoted 36 lines
arch/x86/cpu/setjmp.S new file +18 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax,%edx
+#else
+       movl 4(%esp),%edx               # jmp_ptr address
+       movl 8(%esp),%eax               # Return value
+#endif
+       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 +12 -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 {

arch/x86/include/asm/setjmp.h line 22

Quoted 10 lines
arch/x86/include/asm/setjmp.h new file +10 -0
+       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);

shouldn't it be void longjmp(struct jmp_buf_data *jmp_buf, int val)? I am wondering how EFI loader could work with this longjmp()?

arch/x86/include/asm/setjmp.h

Quoted 3 lines
arch/x86/include/asm/setjmp.h new file +2 -1
+
+#endif
--

Regards,
Bin

#28 lore raw

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

Hi Bin,

Quoted 58 lines · Bin Meng

Hi Simon,

Quoted 55 lines · Simon Glass

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

---

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 71 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 +++++++++++++++
 3 files changed, 96 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 +23 -0
new file mode 100644
index 0000000..24e7d8a
@@ -0,0 +1,71 @@
+/*
+ * 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
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
Quoted 8 lines

arch/x86/cpu/setjmp.S line 29

Quoted 6 lines
arch/x86/cpu/setjmp.S new file +6 -0
+
+       /*
+        * rdi - 32-bit code segment selector
+        * rsi - target address
+        * rdx - table address (0 if none)
+        */

The comment above looks irrelevant.

OK, will drop.

Quoted 11 lines

arch/x86/cpu/setjmp.S line 36

Quoted 8 lines
arch/x86/cpu/setjmp.S new file +7 -0
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax,%edx

nits: needs space after ",". please fix this globally in this file.

Quoted 6 lines

arch/x86/cpu/setjmp.S line 40

Quoted 4 lines
arch/x86/cpu/setjmp.S new file +4 -0
+#else
+       movl 4(%esp),%edx
+#endif
+       popl %ecx                       # Return address, and adjust the stack

I believe # is deprecated. We should use /* */

OK

Quoted 13 lines

arch/x86/cpu/setjmp.S line 51

Quoted 12 lines
arch/x86/cpu/setjmp.S new file +11 -0
+       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
+
+       .size setjmp,.-setjmp
Quoted 1 line

What is this .size for?

Size of the function code. It helps with nm --size-sort I think.

Quoted 47 lines

arch/x86/cpu/setjmp.S line 53

Quoted 3 lines
arch/x86/cpu/setjmp.S new file +2 -0
+
+       .text

nits: not necessary

Quoted 41 lines
arch/x86/cpu/setjmp.S new file +18 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax,%edx
+#else
+       movl 4(%esp),%edx               # jmp_ptr address
+       movl 8(%esp),%eax               # Return value
+#endif
+       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 +17 -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;
Quoted 8 lines

arch/x86/include/asm/setjmp.h line 22

Quoted 5 lines
arch/x86/include/asm/setjmp.h new file +5 -0
+       unsigned int __eip;
+};
+
+int setjmp(struct jmp_buf_data *jmp_buf);
+void longjmp(struct jmp_buf_data *jmp_buf);

shouldn't it be void longjmp(struct jmp_buf_data *jmp_buf, int val)? I am wondering how EFI loader could work with this longjmp()?

efi_exit() seems to not need the extra parameter.

Quoted 7 lines

arch/x86/include/asm/setjmp.h

Quoted 4 lines
arch/x86/include/asm/setjmp.h new file +2 -1
+
+#endif
--

Regards,
Bin

Regards,
SImon

#29 lore raw

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

Hi Simon,

Quoted 165 lines · Simon Glass

Hi Bin,

Quoted 58 lines · Bin Meng

Hi Simon,

Quoted 55 lines · Simon Glass

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

---

 arch/x86/cpu/Makefile         |  2 +-
 arch/x86/cpu/setjmp.S         | 71 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/setjmp.h | 24 +++++++++++++++
 3 files changed, 96 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 +23 -0
new file mode 100644
index 0000000..24e7d8a
@@ -0,0 +1,71 @@
+/*
+ * 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
+ */
+
+#include <asm/global_data.h>
+#include <asm/msr-index.h>
+#include <asm/processor-flags.h>
+
+#define _REGPARM
+
+/*
+ * The jmp_buf is assumed to contain the following, in order:
+ *     %ebx
+ *     %esp
+ *     %ebp
+ *     %esi
+ *     %edi
+ *     <return address>
+ */
Quoted 8 lines

arch/x86/cpu/setjmp.S line 29

Quoted 6 lines
arch/x86/cpu/setjmp.S new file +6 -0
+
+       /*
+        * rdi - 32-bit code segment selector
+        * rsi - target address
+        * rdx - table address (0 if none)
+        */

The comment above looks irrelevant.

OK, will drop.

Quoted 11 lines

arch/x86/cpu/setjmp.S line 36

Quoted 8 lines
arch/x86/cpu/setjmp.S new file +7 -0
+       .text
+       .align 4
+       .globl setjmp
+       .type setjmp, @function
+setjmp:
+#ifdef _REGPARM
+       movl %eax,%edx

nits: needs space after ",". please fix this globally in this file.

Quoted 6 lines

arch/x86/cpu/setjmp.S line 40

Quoted 4 lines
arch/x86/cpu/setjmp.S new file +4 -0
+#else
+       movl 4(%esp),%edx
+#endif
+       popl %ecx                       # Return address, and adjust the stack

I believe # is deprecated. We should use /* */

OK

Quoted 13 lines

arch/x86/cpu/setjmp.S line 51

Quoted 12 lines
arch/x86/cpu/setjmp.S new file +11 -0
+       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
+
+       .size setjmp,.-setjmp
Quoted 1 line

What is this .size for?

Size of the function code. It helps with nm --size-sort I think.

Quoted 47 lines

arch/x86/cpu/setjmp.S line 53

Quoted 3 lines
arch/x86/cpu/setjmp.S new file +2 -0
+
+       .text

nits: not necessary

Quoted 41 lines
arch/x86/cpu/setjmp.S new file +18 -0
+       .align 4
+       .globl longjmp
+       .type longjmp, @function
+longjmp:
+#ifdef _REGPARM
+       xchgl %eax,%edx
+#else
+       movl 4(%esp),%edx               # jmp_ptr address
+       movl 8(%esp),%eax               # Return value
+#endif
+       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 +17 -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;
Quoted 8 lines

arch/x86/include/asm/setjmp.h line 22

Quoted 5 lines
arch/x86/include/asm/setjmp.h new file +5 -0
+       unsigned int __eip;
+};
+
+int setjmp(struct jmp_buf_data *jmp_buf);
+void longjmp(struct jmp_buf_data *jmp_buf);

shouldn't it be void longjmp(struct jmp_buf_data *jmp_buf, int val)? I am wondering how EFI loader could work with this longjmp()?

Quoted 1 line

efi_exit() seems to not need the extra parameter.

This does not look good to me. See efi_start_image(), there is a test against return value of setjmp(), but longjmp() does not provide a return value, which means the return value is undetermined.

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

Regards,
Bin