All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp()
@ 2016-08-06 23:23 Simon Glass
  2016-08-06 23:23 ` [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers Simon Glass
                   ` (5 more replies)
  0 siblings, 6 replies; 30+ messages in thread
From: Simon Glass @ 2016-08-06 23:23 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 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

diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile
index 2667e0b..f5b8c9e 100644
--- a/arch/x86/cpu/Makefile
+++ b/arch/x86/cpu/Makefile
@@ -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)
diff --git a/arch/x86/cpu/setjmp.S b/arch/x86/cpu/setjmp.S
new file mode 100644
index 0000000..24e7d8a
--- /dev/null
+++ b/arch/x86/cpu/setjmp.S
@@ -0,0 +1,71 @@
+/*
+ * Written by H. Peter Anvin <hpa@zytor.com>
+ * 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>
+ */
+
+	/*
+	 * rdi - 32-bit code segment selector
+	 * rsi - target address
+	 * rdx - table address (0 if none)
+	 */
+	.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
+
+	.size setjmp,.-setjmp
+
+	.text
+	.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
diff --git a/arch/x86/include/asm/setjmp.h b/arch/x86/include/asm/setjmp.h
new file mode 100644
index 0000000..deef67e
--- /dev/null
+++ b/arch/x86/include/asm/setjmp.h
@@ -0,0 +1,24 @@
+/*
+ * Written by H. Peter Anvin <hpa@zytor.com>
+ * 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
-- 
2.8.0.rc3.226.g39d4020

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

* [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers
  2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
@ 2016-08-06 23:23 ` Simon Glass
  2016-08-09  6:50   ` Bin Meng
  2016-08-10 11:40   ` Alexander Graf
  2016-08-06 23:23 ` [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program Simon Glass
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 30+ messages in thread
From: Simon Glass @ 2016-08-06 23:23 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 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(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index d66892e..0536b63 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -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 };
 
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 9738835..aa4ae0e 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -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);
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index be6f5e8..798b566 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -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,
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index c434c92..0a35d53 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -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)
 {
diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
index dd3b485..9199518 100644
--- a/lib/efi_loader/efi_net.c
+++ b/lib/efi_loader/efi_net.c
@@ -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)
 {
-- 
2.8.0.rc3.226.g39d4020

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
  2016-08-06 23:23 ` [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers Simon Glass
@ 2016-08-06 23:23 ` Simon Glass
  2016-08-09  6:50   ` Bin Meng
  2016-08-06 23:23 ` [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86 Simon Glass
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-08-06 23:23 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 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

diff --git a/arch/arm/lib/HelloWorld32.efi b/arch/arm/lib/HelloWorld32.efi
new file mode 100644
index 0000000000000000000000000000000000000000..7708451c04a99752ed468842090a9b3f3506090e
GIT binary patch
literal 11712
zcmcI~3sjS5p7-<S0wDwmH=*L?4R{Gg<qd&=78L@##G(ZOFK4H-H6;;JLxLf+XnUrh
zo%wn?dKQd3g6NpBGrQfLne)MH{XX3(2Re54%<R@(Xzd)go!!0(b+y<t6Q^`YE1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vnT;p>I(6l#ms6mdm`MI}W?
zih7EU7xfkWwn!*a8`F)7^}E+UwSLcf>-sm=pI`sx`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

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index a8d1557..0f3ea0c 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -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
diff --git a/cmd/Kconfig b/cmd/Kconfig
index d69b817..8df80b6 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -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
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 0536b63..ecf9968 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -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(
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 328bc62..54ccac9 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -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[];
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e720562..07469f0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -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     $<
-- 
2.8.0.rc3.226.g39d4020

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
  2016-08-06 23:23 ` [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers Simon Glass
  2016-08-06 23:23 ` [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program Simon Glass
@ 2016-08-06 23:23 ` Simon Glass
  2016-08-09  6:50   ` Bin Meng
  2016-08-10 11:49   ` Alexander Graf
  2016-08-06 23:23 ` [U-Boot] [PATCH 5/6] x86: efi: Add a hello world test program Simon Glass
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 30+ messages in thread
From: Simon Glass @ 2016-08-06 23:23 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 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

diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds
index 36f59ea..cca536b 100644
--- a/arch/x86/cpu/u-boot.lds
+++ b/arch/x86/cpu/u-boot.lds
@@ -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
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -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
diff --git a/arch/x86/lib/sections.c b/arch/x86/lib/sections.c
new file mode 100644
index 0000000..6455e0f
--- /dev/null
+++ b/arch/x86/lib/sections.c
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
+ *
+ * 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")));
diff --git a/include/efi.h b/include/efi.h
index 1dbc3b7..47b351f 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -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;
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 798b566..e027bd3 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -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;
 }
 
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 99b5ef1..3793471 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -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
-- 
2.8.0.rc3.226.g39d4020

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

* [U-Boot] [PATCH 5/6] x86: efi: Add a hello world test program
  2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
                   ` (2 preceding siblings ...)
  2016-08-06 23:23 ` [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86 Simon Glass
@ 2016-08-06 23:23 ` Simon Glass
  2016-08-09  6:51   ` Bin Meng
  2016-08-06 23:23 ` [U-Boot] [PATCH 6/6] x86: Enable EFI loader support Simon Glass
  2016-08-09  6:49 ` [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Bin Meng
  5 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-08-06 23:23 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 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

diff --git a/arch/x86/lib/HelloWorld.efi b/arch/x86/lib/HelloWorld.efi
new file mode 100644
index 0000000000000000000000000000000000000000..e59b84b4d1d5f5aeabb4f25094ec0724ac114b4e
GIT binary patch
literal 11168
zcmcIq3v?6LnI0KK1u+>zTxuF884^e=UY2B8wgV=9jROIJkdVn^9jaKuk|Rq*nhB=G
ziRnluOefytoGmT8C3~EO?QwVM3EOo8%}J>p5)8Ci2%EIoxF;cLI2o^Kwn+&VgjD<8
zxg%MAkTlt|&bgZV_#fZ@-~ayipCOL>nXmlU{gpY#7 at a)BtTW_~O`vy<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 oHXgx5cl1`L)7`8tfROv|
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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
zQDd~u{8ASPd69PbJ0j5?b@)U;KNpY-Wr{g+yVMbd9saO@izR13@`GMrqi70IFso2%
z0Thapj9_iYN&Yi;HtB!F+4}3DUVbfsEQb7jA8oDm4XbMX*jin_uDrSYnes#BFO;7z
z|FHaWd8w_+=CQ?WKeGLk?X>M9+t(^eDwb5(DppjiskpboTM?+}tazg0>53m#9IiNC
zak}ES71Qjq?049g+t=8g_7?kh?Xvw{`=|DsD;HHZR<5mls`BqE?NtY>p0Ao)T~h6-
z-co&~MqRb$u79|z at 2(f`(g5KfBAn>VGyk)BzNO64YzbNR+kR at hV#}|vR;;Xes^SL~
zA6BF)zF}WrFSBp3-)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

diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index e46e7f1..e8172cb 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -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
-- 
2.8.0.rc3.226.g39d4020

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

* [U-Boot] [PATCH 6/6] x86: Enable EFI loader support
  2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
                   ` (3 preceding siblings ...)
  2016-08-06 23:23 ` [U-Boot] [PATCH 5/6] x86: efi: Add a hello world test program Simon Glass
@ 2016-08-06 23:23 ` Simon Glass
  2016-08-09  6:51   ` Bin Meng
  2016-08-09  6:49 ` [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Bin Meng
  5 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-08-06 23:23 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/efi_loader/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 37a0dd6..8e7e8a5 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -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)
-- 
2.8.0.rc3.226.g39d4020

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

* [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp()
  2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
                   ` (4 preceding siblings ...)
  2016-08-06 23:23 ` [U-Boot] [PATCH 6/6] x86: Enable EFI loader support Simon Glass
@ 2016-08-09  6:49 ` Bin Meng
  2016-08-09 18:16   ` Simon Glass
  5 siblings, 1 reply; 30+ messages in thread
From: Bin Meng @ 2016-08-09  6:49 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> wrote:
> Bring in these functions from Linux v4.4. They will be needed for EFI loader
> support.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  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
>
> diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile
> index 2667e0b..f5b8c9e 100644
> --- a/arch/x86/cpu/Makefile
> +++ b/arch/x86/cpu/Makefile
> @@ -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)
> diff --git a/arch/x86/cpu/setjmp.S b/arch/x86/cpu/setjmp.S
> new file mode 100644
> index 0000000..24e7d8a
> --- /dev/null
> +++ b/arch/x86/cpu/setjmp.S
> @@ -0,0 +1,71 @@
> +/*
> + * Written by H. Peter Anvin <hpa@zytor.com>
> + * 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>
> + */
> +
> +       /*
> +        * rdi - 32-bit code segment selector
> +        * rsi - target address
> +        * rdx - table address (0 if none)
> +        */

The comment above looks irrelevant.

> +       .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.

> +#else
> +       movl 4(%esp),%edx
> +#endif
> +       popl %ecx                       # Return address, and adjust the stack

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

> +       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?

> +
> +       .text

nits: not necessary

> +       .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
> diff --git a/arch/x86/include/asm/setjmp.h b/arch/x86/include/asm/setjmp.h
> new file mode 100644
> index 0000000..deef67e
> --- /dev/null
> +++ b/arch/x86/include/asm/setjmp.h
> @@ -0,0 +1,24 @@
> +/*
> + * Written by H. Peter Anvin <hpa@zytor.com>
> + * 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);

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()?

> +
> +#endif
> --

Regards,
Bin

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

* [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers
  2016-08-06 23:23 ` [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers Simon Glass
@ 2016-08-09  6:50   ` Bin Meng
  2016-08-10 11:40   ` Alexander Graf
  1 sibling, 0 replies; 30+ messages in thread
From: Bin Meng @ 2016-08-09  6:50 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> wrote:
> These are missing in some functions. Add them to keep things consistent.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  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(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-08-06 23:23 ` [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program Simon Glass
@ 2016-08-09  6:50   ` Bin Meng
  2016-08-09 18:16     ` Simon Glass
  0 siblings, 1 reply; 30+ messages in thread
From: Bin Meng @ 2016-08-09  6:50 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> 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.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  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]

> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> index a8d1557..0f3ea0c 100644
> --- a/arch/arm/lib/Makefile
> +++ b/arch/arm/lib/Makefile
> @@ -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?

> +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
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index d69b817..8df80b6 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -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

typo: working, bringing

> +         up EFI support on a new architecture.
> +
>  config CMD_ELF
>         bool "bootelf, bootvx"
>         default y
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 0536b63..ecf9968 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -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"

typo: World

> +#endif
> +       ;
>  #endif
>
>  U_BOOT_CMD(
> diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
> index 328bc62..54ccac9 100644
> --- a/include/asm-generic/sections.h
> +++ b/include/asm-generic/sections.h
> @@ -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[];
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index e720562..07469f0 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -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:';                        \

nits: the ending \ is not aligned with other lines

> +       echo '.incbin "$<" ';                           \
> +       echo '__efi_hello_world_end:';                  \
> +       echo '.global __efi_hello_world_end';                   \

nits: the ending \ is not aligned with other lines

> +       echo '.balign 16';                              \
> +) > $@
> +
> +$(obj)/%.S: $(src)/%.efi
> +       $(call cmd,S_efi)
> +
>  # ACPI
>  # ---------------------------------------------------------------------------
>  quiet_cmd_acpi_c_asl= ASL     $<
> --

Regards,
Bin

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-08-06 23:23 ` [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86 Simon Glass
@ 2016-08-09  6:50   ` Bin Meng
  2016-08-10 11:49   ` Alexander Graf
  1 sibling, 0 replies; 30+ messages in thread
From: Bin Meng @ 2016-08-09  6:50 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> wrote:
> 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.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  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
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

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

* [U-Boot] [PATCH 5/6] x86: efi: Add a hello world test program
  2016-08-06 23:23 ` [U-Boot] [PATCH 5/6] x86: efi: Add a hello world test program Simon Glass
@ 2016-08-09  6:51   ` Bin Meng
  0 siblings, 0 replies; 30+ messages in thread
From: Bin Meng @ 2016-08-09  6:51 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> 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.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  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?

>

[snip]

> diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
> index e46e7f1..e8172cb 100644
> --- a/arch/x86/lib/Makefile
> +++ b/arch/x86/lib/Makefile
> @@ -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

>  obj-y  += e820.o
>  obj-y  += gcc.o
>  obj-y  += init_helpers.o
> --

Regards,
Bin

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

* [U-Boot] [PATCH 6/6] x86: Enable EFI loader support
  2016-08-06 23:23 ` [U-Boot] [PATCH 6/6] x86: Enable EFI loader support Simon Glass
@ 2016-08-09  6:51   ` Bin Meng
  0 siblings, 0 replies; 30+ messages in thread
From: Bin Meng @ 2016-08-09  6:51 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> wrote:
> Enable this so that EFI applications (notably grub) can be run under U-Boot
> on x86 platforms.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  lib/efi_loader/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index 37a0dd6..8e7e8a5 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -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)
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

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

Regards,
Bin

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

* [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp()
  2016-08-09  6:49 ` [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Bin Meng
@ 2016-08-09 18:16   ` Simon Glass
  2016-08-10  2:34     ` Bin Meng
  0 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-08-09 18:16 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 9 August 2016 at 00:49, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> wrote:
>> Bring in these functions from Linux v4.4. They will be needed for EFI loader
>> support.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  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
>>
>> diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile
>> index 2667e0b..f5b8c9e 100644
>> --- a/arch/x86/cpu/Makefile
>> +++ b/arch/x86/cpu/Makefile
>> @@ -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)
>> diff --git a/arch/x86/cpu/setjmp.S b/arch/x86/cpu/setjmp.S
>> new file mode 100644
>> index 0000000..24e7d8a
>> --- /dev/null
>> +++ b/arch/x86/cpu/setjmp.S
>> @@ -0,0 +1,71 @@
>> +/*
>> + * Written by H. Peter Anvin <hpa@zytor.com>
>> + * 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>
>> + */
>> +
>> +       /*
>> +        * rdi - 32-bit code segment selector
>> +        * rsi - target address
>> +        * rdx - table address (0 if none)
>> +        */
>
> The comment above looks irrelevant.

OK, will drop.

>
>> +       .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.
>
>> +#else
>> +       movl 4(%esp),%edx
>> +#endif
>> +       popl %ecx                       # Return address, and adjust the stack
>
> I believe # is deprecated. We should use /* */

OK

>
>> +       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?

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

>
>> +
>> +       .text
>
> nits: not necessary
>
>> +       .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
>> diff --git a/arch/x86/include/asm/setjmp.h b/arch/x86/include/asm/setjmp.h
>> new file mode 100644
>> index 0000000..deef67e
>> --- /dev/null
>> +++ b/arch/x86/include/asm/setjmp.h
>> @@ -0,0 +1,24 @@
>> +/*
>> + * Written by H. Peter Anvin <hpa@zytor.com>
>> + * 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);
>
> 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.

>
>> +
>> +#endif
>> --
>
> Regards,
> Bin

Regards,
SImon

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-08-09  6:50   ` Bin Meng
@ 2016-08-09 18:16     ` Simon Glass
  2016-08-09 20:55       ` Alexander Graf
  0 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-08-09 18:16 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 9 August 2016 at 00:50, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> 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.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>  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]
>
>> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
>> index a8d1557..0f3ea0c 100644
>> --- a/arch/arm/lib/Makefile
>> +++ b/arch/arm/lib/Makefile
>> @@ -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.

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

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-08-09 18:16     ` Simon Glass
@ 2016-08-09 20:55       ` Alexander Graf
  2016-08-15 12:23         ` Leif Lindholm
  0 siblings, 1 reply; 30+ messages in thread
From: Alexander Graf @ 2016-08-09 20:55 UTC (permalink / raw)
  To: u-boot



> Am 09.08.2016 um 20:16 schrieb Simon Glass <sjg@chromium.org>:
> 
> Hi Bin,
> 
>> On 9 August 2016 at 00:50, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Hi Simon,
>> 
>>> On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> 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.
>>> 
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>> 
>>> 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]
>> 
>>> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
>>> index a8d1557..0f3ea0c 100644
>>> --- a/arch/arm/lib/Makefile
>>> +++ b/arch/arm/lib/Makefile
>>> @@ -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.

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


Alex

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

* [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp()
  2016-08-09 18:16   ` Simon Glass
@ 2016-08-10  2:34     ` Bin Meng
  0 siblings, 0 replies; 30+ messages in thread
From: Bin Meng @ 2016-08-10  2:34 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Wed, Aug 10, 2016 at 2:16 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Bin,
>
> On 9 August 2016 at 00:49, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Hi Simon,
>>
>> On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> wrote:
>>> Bring in these functions from Linux v4.4. They will be needed for EFI loader
>>> support.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>  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
>>>
>>> diff --git a/arch/x86/cpu/Makefile b/arch/x86/cpu/Makefile
>>> index 2667e0b..f5b8c9e 100644
>>> --- a/arch/x86/cpu/Makefile
>>> +++ b/arch/x86/cpu/Makefile
>>> @@ -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)
>>> diff --git a/arch/x86/cpu/setjmp.S b/arch/x86/cpu/setjmp.S
>>> new file mode 100644
>>> index 0000000..24e7d8a
>>> --- /dev/null
>>> +++ b/arch/x86/cpu/setjmp.S
>>> @@ -0,0 +1,71 @@
>>> +/*
>>> + * Written by H. Peter Anvin <hpa@zytor.com>
>>> + * 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>
>>> + */
>>> +
>>> +       /*
>>> +        * rdi - 32-bit code segment selector
>>> +        * rsi - target address
>>> +        * rdx - table address (0 if none)
>>> +        */
>>
>> The comment above looks irrelevant.
>
> OK, will drop.
>
>>
>>> +       .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.
>>
>>> +#else
>>> +       movl 4(%esp),%edx
>>> +#endif
>>> +       popl %ecx                       # Return address, and adjust the stack
>>
>> I believe # is deprecated. We should use /* */
>
> OK
>
>>
>>> +       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?
>
> Size of the function code. It helps with nm --size-sort I think.
>
>>
>>> +
>>> +       .text
>>
>> nits: not necessary
>>
>>> +       .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
>>> diff --git a/arch/x86/include/asm/setjmp.h b/arch/x86/include/asm/setjmp.h
>>> new file mode 100644
>>> index 0000000..deef67e
>>> --- /dev/null
>>> +++ b/arch/x86/include/asm/setjmp.h
>>> @@ -0,0 +1,24 @@
>>> +/*
>>> + * Written by H. Peter Anvin <hpa@zytor.com>
>>> + * 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);
>>
>> 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.

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

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

* [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers
  2016-08-06 23:23 ` [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers Simon Glass
  2016-08-09  6:50   ` Bin Meng
@ 2016-08-10 11:40   ` Alexander Graf
  2016-08-12 17:20     ` Simon Glass
  1 sibling, 1 reply; 30+ messages in thread
From: Alexander Graf @ 2016-08-10 11:40 UTC (permalink / raw)
  To: u-boot

On 08/07/2016 01:23 AM, Simon Glass wrote:
> These are missing in some functions. Add them to keep things consistent.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

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

Reviewed-by: Alexander Graf <agraf@suse.de>


Alex

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-08-06 23:23 ` [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86 Simon Glass
  2016-08-09  6:50   ` Bin Meng
@ 2016-08-10 11:49   ` Alexander Graf
  2016-08-10 12:56     ` Simon Glass
  1 sibling, 1 reply; 30+ messages in thread
From: Alexander Graf @ 2016-08-10 11:49 UTC (permalink / raw)
  To: u-boot

On 08/07/2016 01:23 AM, Simon Glass wrote:
> 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.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   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
>
> diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds
> index 36f59ea..cca536b 100644
> --- a/arch/x86/cpu/u-boot.lds
> +++ b/arch/x86/cpu/u-boot.lds
> @@ -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
> --- a/arch/x86/lib/Makefile
> +++ b/arch/x86/lib/Makefile
> @@ -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
> diff --git a/arch/x86/lib/sections.c b/arch/x86/lib/sections.c
> new file mode 100644
> index 0000000..6455e0f
> --- /dev/null
> +++ b/arch/x86/lib/sections.c
> @@ -0,0 +1,12 @@
> +/*
> + * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
> + *
> + * 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")));
> diff --git a/include/efi.h b/include/efi.h
> index 1dbc3b7..47b351f 100644
> --- a/include/efi.h
> +++ b/include/efi.h
> @@ -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

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?


>   #endif
>   
>   struct efi_device_path;
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 798b566..e027bd3 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -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

So is fs reserved for firmware use on x86?


Alex

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-08-10 11:49   ` Alexander Graf
@ 2016-08-10 12:56     ` Simon Glass
  2016-08-10 13:01       ` Alexander Graf
  2016-10-25 21:33       ` Alexander Graf
  0 siblings, 2 replies; 30+ messages in thread
From: Simon Glass @ 2016-08-10 12:56 UTC (permalink / raw)
  To: u-boot

Hi Alex,

On 10 August 2016 at 05:49, Alexander Graf <agraf@suse.de> wrote:
> On 08/07/2016 01:23 AM, Simon Glass wrote:
>>
>> 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.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   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
>>
>> diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds
>> index 36f59ea..cca536b 100644
>> --- a/arch/x86/cpu/u-boot.lds
>> +++ b/arch/x86/cpu/u-boot.lds
>> @@ -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
>> --- a/arch/x86/lib/Makefile
>> +++ b/arch/x86/lib/Makefile
>> @@ -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
>> diff --git a/arch/x86/lib/sections.c b/arch/x86/lib/sections.c
>> new file mode 100644
>> index 0000000..6455e0f
>> --- /dev/null
>> +++ b/arch/x86/lib/sections.c
>> @@ -0,0 +1,12 @@
>> +/*
>> + * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
>> + *
>> + * 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")));
>> diff --git a/include/efi.h b/include/efi.h
>> index 1dbc3b7..47b351f 100644
>> --- a/include/efi.h
>> +++ b/include/efi.h
>> @@ -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
>
>
> 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.

>
>
>>   #endif
>>     struct efi_device_path;
>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>> index 798b566..e027bd3 100644
>> --- a/lib/efi_loader/efi_boottime.c
>> +++ b/lib/efi_loader/efi_boottime.c
>> @@ -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
>
>
> 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.

>
>
> Alex
>

Regards,
Simon

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-08-10 12:56     ` Simon Glass
@ 2016-08-10 13:01       ` Alexander Graf
  2016-10-25 21:33       ` Alexander Graf
  1 sibling, 0 replies; 30+ messages in thread
From: Alexander Graf @ 2016-08-10 13:01 UTC (permalink / raw)
  To: u-boot

On 08/10/2016 02:56 PM, Simon Glass wrote:
> Hi Alex,
>
> On 10 August 2016 at 05:49, Alexander Graf <agraf@suse.de> wrote:
>> On 08/07/2016 01:23 AM, Simon Glass wrote:
>>> 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.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>    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
>>>
>>> diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds
>>> index 36f59ea..cca536b 100644
>>> --- a/arch/x86/cpu/u-boot.lds
>>> +++ b/arch/x86/cpu/u-boot.lds
>>> @@ -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
>>> --- a/arch/x86/lib/Makefile
>>> +++ b/arch/x86/lib/Makefile
>>> @@ -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
>>> diff --git a/arch/x86/lib/sections.c b/arch/x86/lib/sections.c
>>> new file mode 100644
>>> index 0000000..6455e0f
>>> --- /dev/null
>>> +++ b/arch/x86/lib/sections.c
>>> @@ -0,0 +1,12 @@
>>> +/*
>>> + * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
>>> + *
>>> + * 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")));
>>> diff --git a/include/efi.h b/include/efi.h
>>> index 1dbc3b7..47b351f 100644
>>> --- a/include/efi.h
>>> +++ b/include/efi.h
>>> @@ -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
>>
>> 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.
>
>>
>>>    #endif
>>>      struct efi_device_path;
>>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>>> index 798b566..e027bd3 100644
>>> --- a/lib/efi_loader/efi_boottime.c
>>> +++ b/lib/efi_loader/efi_boottime.c
>>> @@ -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
>>
>> 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.

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 :).

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

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

* [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers
  2016-08-10 11:40   ` Alexander Graf
@ 2016-08-12 17:20     ` Simon Glass
  0 siblings, 0 replies; 30+ messages in thread
From: Simon Glass @ 2016-08-12 17:20 UTC (permalink / raw)
  To: u-boot

Hi Alex,

On 10 August 2016 at 05:40, Alexander Graf <agraf@suse.de> wrote:
> On 08/07/2016 01:23 AM, Simon Glass wrote:
>>
>> These are missing in some functions. Add them to keep things consistent.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
>
> Is there any way to change the EFIAPI definition so that we get build
> warnings for non matching function types on aarch64 as well?
>
> Reviewed-by: Alexander Graf <agraf@suse.de>

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

Regards,
Simon

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-08-09 20:55       ` Alexander Graf
@ 2016-08-15 12:23         ` Leif Lindholm
  2016-09-26 14:09           ` Simon Glass
  0 siblings, 1 reply; 30+ messages in thread
From: Leif Lindholm @ 2016-08-15 12:23 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 09, 2016 at 10:55:31PM +0200, Alexander Graf wrote:
> 
> 
> > Am 09.08.2016 um 20:16 schrieb Simon Glass <sjg@chromium.org>:
> > 
> > Hi Bin,
> > 
> >> On 9 August 2016 at 00:50, Bin Meng <bmeng.cn@gmail.com> wrote:
> >> Hi Simon,
> >> 
> >>> On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> 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.
> >>> 
> >>> Signed-off-by: Simon Glass <sjg@chromium.org>
> >>> ---
> >>> 
> >>> 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]
> >> 
> >>> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> >>> index a8d1557..0f3ea0c 100644
> >>> --- a/arch/arm/lib/Makefile
> >>> +++ b/arch/arm/lib/Makefile
> >>> @@ -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.
> 
> 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

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-08-15 12:23         ` Leif Lindholm
@ 2016-09-26 14:09           ` Simon Glass
  2016-09-27  1:53             ` Leif Lindholm
  0 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-09-26 14:09 UTC (permalink / raw)
  To: u-boot

Hi Leif,

On 15 August 2016 at 06:23, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Tue, Aug 09, 2016 at 10:55:31PM +0200, Alexander Graf wrote:
>>
>>
>> > Am 09.08.2016 um 20:16 schrieb Simon Glass <sjg@chromium.org>:
>> >
>> > Hi Bin,
>> >
>> >> On 9 August 2016 at 00:50, Bin Meng <bmeng.cn@gmail.com> wrote:
>> >> Hi Simon,
>> >>
>> >>> On Sun, Aug 7, 2016 at 7:23 AM, Simon Glass <sjg@chromium.org> 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.
>> >>>
>> >>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> >>> ---
>> >>>
>> >>> 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]
>> >>
>> >>> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
>> >>> index a8d1557..0f3ea0c 100644
>> >>> --- a/arch/arm/lib/Makefile
>> >>> +++ b/arch/arm/lib/Makefile
>> >>> @@ -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.
>>
>> 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.

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?

>
> /
>     Leif

Regards,
Simon

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-09-26 14:09           ` Simon Glass
@ 2016-09-27  1:53             ` Leif Lindholm
  2016-10-18  1:55               ` Simon Glass
  0 siblings, 1 reply; 30+ messages in thread
From: Leif Lindholm @ 2016-09-27  1:53 UTC (permalink / raw)
  To: u-boot


On Mon, Sep 26, 2016 at 08:09:40AM -0600, Simon Glass wrote:
> >> >> 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.
> >
> > 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

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-09-27  1:53             ` Leif Lindholm
@ 2016-10-18  1:55               ` Simon Glass
  2016-10-19 20:22                 ` Leif Lindholm
  0 siblings, 1 reply; 30+ messages in thread
From: Simon Glass @ 2016-10-18  1:55 UTC (permalink / raw)
  To: u-boot

Hi Leif,

On 26 September 2016 at 19:53, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
> On Mon, Sep 26, 2016 at 08:09:40AM -0600, Simon Glass wrote:
>> >> >> 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.
>> >
>> > 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)?

OK thanks. Please see:

http://pastebin.com/DmixdA4C

Regards,
Simon

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-10-18  1:55               ` Simon Glass
@ 2016-10-19 20:22                 ` Leif Lindholm
  2016-10-20  8:19                   ` Leif Lindholm
  0 siblings, 1 reply; 30+ messages in thread
From: Leif Lindholm @ 2016-10-19 20:22 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 17, 2016 at 07:55:02PM -0600, Simon Glass wrote:
> Hi Leif,
> 
> On 26 September 2016 at 19:53, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> >> 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)?
> 
> 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

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-10-19 20:22                 ` Leif Lindholm
@ 2016-10-20  8:19                   ` Leif Lindholm
  2016-11-07 15:46                     ` Simon Glass
  0 siblings, 1 reply; 30+ messages in thread
From: Leif Lindholm @ 2016-10-20  8:19 UTC (permalink / raw)
  To: u-boot

On 19 October 2016 at 21:22, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Mon, Oct 17, 2016 at 07:55:02PM -0600, Simon Glass wrote:
>> Hi Leif,
>>
>> On 26 September 2016 at 19:53, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> >> 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)?
>>
>> 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.

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

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-08-10 12:56     ` Simon Glass
  2016-08-10 13:01       ` Alexander Graf
@ 2016-10-25 21:33       ` Alexander Graf
  2016-11-07 15:46         ` Simon Glass
  1 sibling, 1 reply; 30+ messages in thread
From: Alexander Graf @ 2016-10-25 21:33 UTC (permalink / raw)
  To: u-boot



On 10/08/2016 14:56, Simon Glass wrote:
> Hi Alex,
> 
> On 10 August 2016 at 05:49, Alexander Graf <agraf@suse.de> wrote:
>> On 08/07/2016 01:23 AM, Simon Glass wrote:
>>>
>>> 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.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>>   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
>>>
>>> diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds
>>> index 36f59ea..cca536b 100644
>>> --- a/arch/x86/cpu/u-boot.lds
>>> +++ b/arch/x86/cpu/u-boot.lds
>>> @@ -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
>>> --- a/arch/x86/lib/Makefile
>>> +++ b/arch/x86/lib/Makefile
>>> @@ -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
>>> diff --git a/arch/x86/lib/sections.c b/arch/x86/lib/sections.c
>>> new file mode 100644
>>> index 0000000..6455e0f
>>> --- /dev/null
>>> +++ b/arch/x86/lib/sections.c
>>> @@ -0,0 +1,12 @@
>>> +/*
>>> + * Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net>
>>> + *
>>> + * 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")));
>>> diff --git a/include/efi.h b/include/efi.h
>>> index 1dbc3b7..47b351f 100644
>>> --- a/include/efi.h
>>> +++ b/include/efi.h
>>> @@ -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
>>
>>
>> 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.
> 
>>
>>
>>>   #endif
>>>     struct efi_device_path;
>>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>>> index 798b566..e027bd3 100644
>>> --- a/lib/efi_loader/efi_boottime.c
>>> +++ b/lib/efi_loader/efi_boottime.c
>>> @@ -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
>>
>>
>> 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.

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.

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

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

> 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

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

* [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86
  2016-10-25 21:33       ` Alexander Graf
@ 2016-11-07 15:46         ` Simon Glass
  0 siblings, 0 replies; 30+ messages in thread
From: Simon Glass @ 2016-11-07 15:46 UTC (permalink / raw)
  To: u-boot

Hi Alex,

On 25 October 2016 at 15:33, Alexander Graf <agraf@suse.de> wrote:
>
>
> On 10/08/2016 14:56, Simon Glass wrote:
>> Hi Alex,
>>
[...]

>>>>   #endif
>>>>     struct efi_device_path;
>>>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>>>> index 798b566..e027bd3 100644
>>>> --- a/lib/efi_loader/efi_boottime.c
>>>> +++ b/lib/efi_loader/efi_boottime.c
>>>> @@ -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
>>>
>>>
>>> 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.
>
> 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.

>
>> This series was just an attempt to get the EFI loader working on x86.
>
> Yes, and it's very very very much appreciated :).
>
>> 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

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

* [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program
  2016-10-20  8:19                   ` Leif Lindholm
@ 2016-11-07 15:46                     ` Simon Glass
  0 siblings, 0 replies; 30+ messages in thread
From: Simon Glass @ 2016-11-07 15:46 UTC (permalink / raw)
  To: u-boot

Hi Leif,

On 20 October 2016 at 02:19, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On 19 October 2016 at 21:22, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>> On Mon, Oct 17, 2016 at 07:55:02PM -0600, Simon Glass wrote:
>>> Hi Leif,
>>>
>>> On 26 September 2016 at 19:53, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>>> >> 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)?
>>>
>>> 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.

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

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

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

end of thread, other threads:[~2016-11-07 15:46 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-06 23:23 [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Simon Glass
2016-08-06 23:23 ` [U-Boot] [PATCH 2/6] efi: Fix missing EFIAPI specifiers Simon Glass
2016-08-09  6:50   ` Bin Meng
2016-08-10 11:40   ` Alexander Graf
2016-08-12 17:20     ` Simon Glass
2016-08-06 23:23 ` [U-Boot] [PATCH 3/6] arm: efi: Add a hello world test program Simon Glass
2016-08-09  6:50   ` Bin Meng
2016-08-09 18:16     ` Simon Glass
2016-08-09 20:55       ` Alexander Graf
2016-08-15 12:23         ` Leif Lindholm
2016-09-26 14:09           ` Simon Glass
2016-09-27  1:53             ` Leif Lindholm
2016-10-18  1:55               ` Simon Glass
2016-10-19 20:22                 ` Leif Lindholm
2016-10-20  8:19                   ` Leif Lindholm
2016-11-07 15:46                     ` Simon Glass
2016-08-06 23:23 ` [U-Boot] [PATCH 4/6] x86: efi: Add EFI loader support for x86 Simon Glass
2016-08-09  6:50   ` Bin Meng
2016-08-10 11:49   ` Alexander Graf
2016-08-10 12:56     ` Simon Glass
2016-08-10 13:01       ` Alexander Graf
2016-10-25 21:33       ` Alexander Graf
2016-11-07 15:46         ` Simon Glass
2016-08-06 23:23 ` [U-Boot] [PATCH 5/6] x86: efi: Add a hello world test program Simon Glass
2016-08-09  6:51   ` Bin Meng
2016-08-06 23:23 ` [U-Boot] [PATCH 6/6] x86: Enable EFI loader support Simon Glass
2016-08-09  6:51   ` Bin Meng
2016-08-09  6:49 ` [U-Boot] [PATCH 1/6] x86: Add implementations of setjmp() and longjmp() Bin Meng
2016-08-09 18:16   ` Simon Glass
2016-08-10  2:34     ` Bin Meng

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