All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64
@ 2018-06-12 17:51 Ivan Gorinov
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 1/4] " Ivan Gorinov
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Ivan Gorinov @ 2018-06-12 17:51 UTC (permalink / raw)
  To: u-boot

UEFI specifies the calling convention used in Microsoft compilers;
first arguments of a function are passed in (%rcx, %rdx, %r8, %r9).

All other compilers use System V ABI by default, passing first integer
arguments of a function in (%rdi, %rsi, %rdx, %rcx, %r8, %r9).

These ABI also specify different sets of registers that must be preserved
across function calls (callee-saved).

GCC allows using the Microsoft calling convention by adding the ms_abi
attribute to a function declaration.

Current EFI implementation in U-Boot specifies EFIAPI for efi_main()
in the test apps but uses default calling convention in lib/efi.
The arguments of efi_main() are also passed as unused arguments to the
_relocate() function.

Save efi_main() arguments in the startup code on x86_64;
use EFI calling convention for _relocate() on x86_64;
remove unused _relocate() arguments;
consistently use EFI calling convention for efi_main() everywhere.

v4:
  Keeping .exit label in x86_64 startup code;
  Also removed the unused _relocate() arguments for arm, x86, riscv.

v3:
  Updated patch description.

v2:
  Added EFIABI to _relocate() declaration.

Ivan Gorinov (4):
  x86: use EFI calling convention for efi_main on x86_64
  arm: Remove unused _relocate arguments
  x86: Remove unused _relocate arguments
  riscv: Remove unused _relocate arguments

 arch/arm/lib/crt0_aarch64_efi.S  |  2 --
 arch/arm/lib/crt0_arm_efi.S      |  2 --
 arch/arm/lib/reloc_aarch64_efi.c |  3 +--
 arch/arm/lib/reloc_arm_efi.c     |  3 +--
 arch/riscv/lib/reloc_riscv_efi.c |  3 +--
 arch/x86/lib/crt0_x86_64_efi.S   | 21 ++++++++++-----------
 arch/x86/lib/reloc_ia32_efi.c    |  3 +--
 arch/x86/lib/reloc_x86_64_efi.c  |  3 +--
 lib/efi/efi_app.c                |  3 ++-
 lib/efi/efi_stub.c               |  3 ++-
 10 files changed, 19 insertions(+), 27 deletions(-)

-- 
2.7.4

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

* [U-Boot] [PATCH v4 1/4] x86: use EFI calling convention for efi_main on x86_64
  2018-06-12 17:51 [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Ivan Gorinov
@ 2018-06-12 17:52 ` Ivan Gorinov
  2018-06-13  1:36   ` Bin Meng
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 2/4] arm: Remove unused _relocate arguments Ivan Gorinov
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Ivan Gorinov @ 2018-06-12 17:52 UTC (permalink / raw)
  To: u-boot

UEFI specifies the calling convention used in Microsoft compilers;
first arguments of a function are passed in (%rcx, %rdx, %r8, %r9).

All other compilers use System V ABI by default, passing first integer
arguments of a function in (%rdi, %rsi, %rdx, %rcx, %r8, %r9).

These ABI also specify different sets of registers that must be preserved
across function calls (callee-saved).

GCC allows using the Microsoft calling convention by adding the ms_abi
attribute to a function declaration.

Current EFI implementation in U-Boot specifies EFIAPI for efi_main()
in the test apps but uses default calling convention in lib/efi.
The arguments of efi_main() are also passed as unused arguments to the
_relocate() function.

Save efi_main() arguments in the startup code on x86_64;
use EFI calling convention for _relocate() on x86_64;
remove unused _relocate() arguments;
consistently use EFI calling convention for efi_main() everywhere.

Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
 arch/x86/lib/crt0_x86_64_efi.S  | 21 ++++++++++-----------
 arch/x86/lib/reloc_x86_64_efi.c |  3 +--
 lib/efi/efi_app.c               |  3 ++-
 lib/efi/efi_stub.c              |  3 ++-
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S
index 989799f..096f347 100644
--- a/arch/x86/lib/crt0_x86_64_efi.S
+++ b/arch/x86/lib/crt0_x86_64_efi.S
@@ -3,7 +3,7 @@
  * crt0-efi-x86_64.S - x86_64 EFI startup code.
  * Copyright (C) 1999 Hewlett-Packard Co.
  * Contributed by David Mosberger <davidm@hpl.hp.com>.
- * Copyright (C) 2005 Intel Co.
+ * Copyright (C) 2005 Intel Corporation
  * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
  *
  * All rights reserved.
@@ -14,26 +14,25 @@
 	.globl _start
 _start:
 	subq $8, %rsp
+
 	pushq %rcx
 	pushq %rdx
 
-0:
-	lea image_base(%rip), %rdi
-	lea _DYNAMIC(%rip), %rsi
+	lea image_base(%rip), %rcx
+	lea _DYNAMIC(%rip), %rdx
 
-	popq %rcx
-	popq %rdx
-	pushq %rcx
-	pushq %rdx
 	call _relocate
 
-	popq %rdi
-	popq %rsi
+	popq %rdx
+	popq %rcx
+
+	testq %rax, %rax
+	jnz _exit
 
 	call efi_main
+.exit:
 	addq $8, %rsp
 
-.exit:
 	ret
 
 	/*
diff --git a/arch/x86/lib/reloc_x86_64_efi.c b/arch/x86/lib/reloc_x86_64_efi.c
index 34c5b2e..59d6f8d 100644
--- a/arch/x86/lib/reloc_x86_64_efi.c
+++ b/arch/x86/lib/reloc_x86_64_efi.c
@@ -14,8 +14,7 @@
 #include <elf.h>
 #include <asm/elf.h>
 
-efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image,
-		       struct efi_system_table *systab)
+efi_status_t EFIAPI _relocate(long ldbase, Elf64_Dyn *dyn)
 {
 	long relsz = 0, relent = 0;
 	Elf64_Rel *rel = 0;
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index c828093..3eb8eeb 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -96,7 +96,8 @@ static void free_memory(struct efi_priv *priv)
  * U-Boot. If it returns, EFI will continue. Another way to get back to EFI
  * is via reset_cpu().
  */
-efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
+efi_status_t EFIAPI efi_main(efi_handle_t image,
+			     struct efi_system_table *sys_table)
 {
 	struct efi_priv local_priv, *priv = &local_priv;
 	efi_status_t ret;
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index 3138739..399d16b 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -268,7 +268,8 @@ static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type,
  * This function is called by our EFI start-up code. It handles running
  * U-Boot. If it returns, EFI will continue.
  */
-efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
+efi_status_t EFIAPI efi_main(efi_handle_t image,
+			     struct efi_system_table *sys_table)
 {
 	struct efi_priv local_priv, *priv = &local_priv;
 	struct efi_boot_services *boot = sys_table->boottime;
-- 
2.7.4

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

* [U-Boot] [PATCH v4 2/4] arm: Remove unused _relocate arguments
  2018-06-12 17:51 [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Ivan Gorinov
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 1/4] " Ivan Gorinov
@ 2018-06-12 17:52 ` Ivan Gorinov
  2018-06-13  1:38   ` Bin Meng
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 3/4] x86: " Ivan Gorinov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Ivan Gorinov @ 2018-06-12 17:52 UTC (permalink / raw)
  To: u-boot

EFI image handle and system table are not used in _relocate().

Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
 arch/arm/lib/crt0_aarch64_efi.S  | 2 --
 arch/arm/lib/crt0_arm_efi.S      | 2 --
 arch/arm/lib/reloc_aarch64_efi.c | 3 +--
 arch/arm/lib/reloc_arm_efi.c     | 3 +--
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm/lib/crt0_aarch64_efi.S b/arch/arm/lib/crt0_aarch64_efi.S
index 5b6c384..0db4360 100644
--- a/arch/arm/lib/crt0_aarch64_efi.S
+++ b/arch/arm/lib/crt0_aarch64_efi.S
@@ -122,8 +122,6 @@ _start:
 	mov		x29, sp
 
 	stp		x0, x1, [sp, #16]
-	mov		x2, x0
-	mov		x3, x1
 	adr		x0, ImageBase
 	adrp		x1, _DYNAMIC
 	add		x1, x1, #:lo12:_DYNAMIC
diff --git a/arch/arm/lib/crt0_arm_efi.S b/arch/arm/lib/crt0_arm_efi.S
index 0f296f3..23db49f 100644
--- a/arch/arm/lib/crt0_arm_efi.S
+++ b/arch/arm/lib/crt0_arm_efi.S
@@ -119,8 +119,6 @@ section_table:
 _start:
 	stmfd		sp!, {r0-r2, lr}
 
-	mov		r2, r0
-	mov		r3, r1
 	adr		r1, .L_DYNAMIC
 	ldr		r0, [r1]
 	add		r1, r0, r1
diff --git a/arch/arm/lib/reloc_aarch64_efi.c b/arch/arm/lib/reloc_aarch64_efi.c
index 38c13d3..c648fe4 100644
--- a/arch/arm/lib/reloc_aarch64_efi.c
+++ b/arch/arm/lib/reloc_aarch64_efi.c
@@ -38,8 +38,7 @@
 
 #include <elf.h>
 
-efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image,
-		       struct efi_system_table *systab)
+efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image)
 {
 	long relsz = 0, relent = 0;
 	Elf64_Rela *rel = 0;
diff --git a/arch/arm/lib/reloc_arm_efi.c b/arch/arm/lib/reloc_arm_efi.c
index 6232e3f..336a98a 100644
--- a/arch/arm/lib/reloc_arm_efi.c
+++ b/arch/arm/lib/reloc_arm_efi.c
@@ -14,8 +14,7 @@
 #include <efi.h>
 #include <elf.h>
 
-efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image,
-		       struct efi_system_table *systab)
+efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn)
 {
 	long relsz = 0, relent = 0;
 	Elf32_Rel *rel = 0;
-- 
2.7.4

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

* [U-Boot] [PATCH v4 3/4] x86: Remove unused _relocate arguments
  2018-06-12 17:51 [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Ivan Gorinov
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 1/4] " Ivan Gorinov
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 2/4] arm: Remove unused _relocate arguments Ivan Gorinov
@ 2018-06-12 17:52 ` Ivan Gorinov
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 4/4] riscv: " Ivan Gorinov
  2018-06-12 18:56 ` [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Alexander Graf
  4 siblings, 0 replies; 10+ messages in thread
From: Ivan Gorinov @ 2018-06-12 17:52 UTC (permalink / raw)
  To: u-boot

EFI image handle and system table are not used in _relocate().

Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
 arch/x86/lib/reloc_ia32_efi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/lib/reloc_ia32_efi.c b/arch/x86/lib/reloc_ia32_efi.c
index e838af3..49a0b94 100644
--- a/arch/x86/lib/reloc_ia32_efi.c
+++ b/arch/x86/lib/reloc_ia32_efi.c
@@ -12,8 +12,7 @@
 #include <elf.h>
 #include <asm/elf.h>
 
-efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image,
-		       struct efi_system_table *systab)
+efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn)
 {
 	long relsz = 0, relent = 0;
 	Elf32_Rel *rel = 0;
-- 
2.7.4

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

* [U-Boot] [PATCH v4 4/4] riscv: Remove unused _relocate arguments
  2018-06-12 17:51 [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Ivan Gorinov
                   ` (2 preceding siblings ...)
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 3/4] x86: " Ivan Gorinov
@ 2018-06-12 17:52 ` Ivan Gorinov
  2018-06-13  1:38   ` Bin Meng
  2018-06-12 18:56 ` [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Alexander Graf
  4 siblings, 1 reply; 10+ messages in thread
From: Ivan Gorinov @ 2018-06-12 17:52 UTC (permalink / raw)
  To: u-boot

EFI image handle and system table are not used in _relocate().

Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
---
 arch/riscv/lib/reloc_riscv_efi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/riscv/lib/reloc_riscv_efi.c b/arch/riscv/lib/reloc_riscv_efi.c
index 8b4b2b1..51b7520 100644
--- a/arch/riscv/lib/reloc_riscv_efi.c
+++ b/arch/riscv/lib/reloc_riscv_efi.c
@@ -50,8 +50,7 @@
 #define ELF_R_TYPE	ELF32_R_TYPE
 #endif
 
-efi_status_t _relocate(long ldbase, Elf_Dyn *dyn, efi_handle_t image,
-		       struct efi_system_table *systab)
+efi_status_t _relocate(long ldbase, Elf_Dyn *dyn, efi_handle_t image)
 {
 	long relsz = 0, relent = 0;
 	Elf_Rela *rel = 0;
-- 
2.7.4

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

* [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64
  2018-06-12 17:51 [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Ivan Gorinov
                   ` (3 preceding siblings ...)
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 4/4] riscv: " Ivan Gorinov
@ 2018-06-12 18:56 ` Alexander Graf
  4 siblings, 0 replies; 10+ messages in thread
From: Alexander Graf @ 2018-06-12 18:56 UTC (permalink / raw)
  To: u-boot



On 12.06.18 19:51, Ivan Gorinov wrote:
> UEFI specifies the calling convention used in Microsoft compilers;
> first arguments of a function are passed in (%rcx, %rdx, %r8, %r9).
> 
> All other compilers use System V ABI by default, passing first integer
> arguments of a function in (%rdi, %rsi, %rdx, %rcx, %r8, %r9).
> 
> These ABI also specify different sets of registers that must be preserved
> across function calls (callee-saved).
> 
> GCC allows using the Microsoft calling convention by adding the ms_abi
> attribute to a function declaration.
> 
> Current EFI implementation in U-Boot specifies EFIAPI for efi_main()
> in the test apps but uses default calling convention in lib/efi.
> The arguments of efi_main() are also passed as unused arguments to the
> _relocate() function.
> 
> Save efi_main() arguments in the startup code on x86_64;
> use EFI calling convention for _relocate() on x86_64;
> remove unused _relocate() arguments;
> consistently use EFI calling convention for efi_main() everywhere.

Looks reasonable to me.

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


Alex

> 
> v4:
>   Keeping .exit label in x86_64 startup code;
>   Also removed the unused _relocate() arguments for arm, x86, riscv.
> 
> v3:
>   Updated patch description.
> 
> v2:
>   Added EFIABI to _relocate() declaration.
> 
> Ivan Gorinov (4):
>   x86: use EFI calling convention for efi_main on x86_64
>   arm: Remove unused _relocate arguments
>   x86: Remove unused _relocate arguments
>   riscv: Remove unused _relocate arguments
> 
>  arch/arm/lib/crt0_aarch64_efi.S  |  2 --
>  arch/arm/lib/crt0_arm_efi.S      |  2 --
>  arch/arm/lib/reloc_aarch64_efi.c |  3 +--
>  arch/arm/lib/reloc_arm_efi.c     |  3 +--
>  arch/riscv/lib/reloc_riscv_efi.c |  3 +--
>  arch/x86/lib/crt0_x86_64_efi.S   | 21 ++++++++++-----------
>  arch/x86/lib/reloc_ia32_efi.c    |  3 +--
>  arch/x86/lib/reloc_x86_64_efi.c  |  3 +--
>  lib/efi/efi_app.c                |  3 ++-
>  lib/efi/efi_stub.c               |  3 ++-
>  10 files changed, 19 insertions(+), 27 deletions(-)
> 

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

* [U-Boot] [PATCH v4 1/4] x86: use EFI calling convention for efi_main on x86_64
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 1/4] " Ivan Gorinov
@ 2018-06-13  1:36   ` Bin Meng
  2018-06-22  1:44     ` Bin Meng
  0 siblings, 1 reply; 10+ messages in thread
From: Bin Meng @ 2018-06-13  1:36 UTC (permalink / raw)
  To: u-boot

Hi Ivan,

On Wed, Jun 13, 2018 at 1:52 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
> UEFI specifies the calling convention used in Microsoft compilers;
> first arguments of a function are passed in (%rcx, %rdx, %r8, %r9).
>
> All other compilers use System V ABI by default, passing first integer
> arguments of a function in (%rdi, %rsi, %rdx, %rcx, %r8, %r9).
>
> These ABI also specify different sets of registers that must be preserved
> across function calls (callee-saved).
>
> GCC allows using the Microsoft calling convention by adding the ms_abi
> attribute to a function declaration.
>
> Current EFI implementation in U-Boot specifies EFIAPI for efi_main()
> in the test apps but uses default calling convention in lib/efi.
> The arguments of efi_main() are also passed as unused arguments to the
> _relocate() function.
>
> Save efi_main() arguments in the startup code on x86_64;
> use EFI calling convention for _relocate() on x86_64;
> remove unused _relocate() arguments;

Thanks for working on this. But as I mentioned previously, the removal
of _relocate() arguments should be in a separate patch. This patch
should only deal with the calling convention changes.

So we should have 4 patches:
[1/4]: efi: calling convention changes for x86_64
[2/4]: x86: remove unused _relocate() arguments
[3/4]: arm: remove unused _relocate() arguments
[4/4]: riscv: remove unused _relocate() arguments

> consistently use EFI calling convention for efi_main() everywhere.
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
>  arch/x86/lib/crt0_x86_64_efi.S  | 21 ++++++++++-----------
>  arch/x86/lib/reloc_x86_64_efi.c |  3 +--
>  lib/efi/efi_app.c               |  3 ++-
>  lib/efi/efi_stub.c              |  3 ++-
>  4 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S
> index 989799f..096f347 100644
> --- a/arch/x86/lib/crt0_x86_64_efi.S
> +++ b/arch/x86/lib/crt0_x86_64_efi.S
> @@ -3,7 +3,7 @@
>   * crt0-efi-x86_64.S - x86_64 EFI startup code.
>   * Copyright (C) 1999 Hewlett-Packard Co.
>   * Contributed by David Mosberger <davidm@hpl.hp.com>.
> - * Copyright (C) 2005 Intel Co.
> + * Copyright (C) 2005 Intel Corporation
>   * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
>   *
>   * All rights reserved.
> @@ -14,26 +14,25 @@
>         .globl _start
>  _start:
>         subq $8, %rsp
> +
>         pushq %rcx
>         pushq %rdx
>
> -0:
> -       lea image_base(%rip), %rdi
> -       lea _DYNAMIC(%rip), %rsi
> +       lea image_base(%rip), %rcx
> +       lea _DYNAMIC(%rip), %rdx
>
> -       popq %rcx
> -       popq %rdx
> -       pushq %rcx
> -       pushq %rdx
>         call _relocate
>
> -       popq %rdi
> -       popq %rsi
> +       popq %rdx
> +       popq %rcx
> +
> +       testq %rax, %rax
> +       jnz _exit

not "jnz .exit"?

>
>         call efi_main
> +.exit:
>         addq $8, %rsp
>
> -.exit:
>         ret
>
>         /*
> diff --git a/arch/x86/lib/reloc_x86_64_efi.c b/arch/x86/lib/reloc_x86_64_efi.c
> index 34c5b2e..59d6f8d 100644
> --- a/arch/x86/lib/reloc_x86_64_efi.c
> +++ b/arch/x86/lib/reloc_x86_64_efi.c
> @@ -14,8 +14,7 @@
>  #include <elf.h>
>  #include <asm/elf.h>
>
> -efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image,
> -                      struct efi_system_table *systab)
> +efi_status_t EFIAPI _relocate(long ldbase, Elf64_Dyn *dyn)
>  {
>         long relsz = 0, relent = 0;
>         Elf64_Rel *rel = 0;
> diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> index c828093..3eb8eeb 100644
> --- a/lib/efi/efi_app.c
> +++ b/lib/efi/efi_app.c
> @@ -96,7 +96,8 @@ static void free_memory(struct efi_priv *priv)
>   * U-Boot. If it returns, EFI will continue. Another way to get back to EFI
>   * is via reset_cpu().
>   */
> -efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
> +efi_status_t EFIAPI efi_main(efi_handle_t image,
> +                            struct efi_system_table *sys_table)
>  {
>         struct efi_priv local_priv, *priv = &local_priv;
>         efi_status_t ret;
> diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
> index 3138739..399d16b 100644
> --- a/lib/efi/efi_stub.c
> +++ b/lib/efi/efi_stub.c
> @@ -268,7 +268,8 @@ static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type,
>   * This function is called by our EFI start-up code. It handles running
>   * U-Boot. If it returns, EFI will continue.
>   */
> -efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
> +efi_status_t EFIAPI efi_main(efi_handle_t image,
> +                            struct efi_system_table *sys_table)
>  {
>         struct efi_priv local_priv, *priv = &local_priv;
>         struct efi_boot_services *boot = sys_table->boottime;
> --

Regards,
Bin

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

* [U-Boot] [PATCH v4 2/4] arm: Remove unused _relocate arguments
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 2/4] arm: Remove unused _relocate arguments Ivan Gorinov
@ 2018-06-13  1:38   ` Bin Meng
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Meng @ 2018-06-13  1:38 UTC (permalink / raw)
  To: u-boot

Hi Ivan,

On Wed, Jun 13, 2018 at 1:52 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
> EFI image handle and system table are not used in _relocate().
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
>  arch/arm/lib/crt0_aarch64_efi.S  | 2 --
>  arch/arm/lib/crt0_arm_efi.S      | 2 --
>  arch/arm/lib/reloc_aarch64_efi.c | 3 +--
>  arch/arm/lib/reloc_arm_efi.c     | 3 +--
>  4 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arm/lib/crt0_aarch64_efi.S b/arch/arm/lib/crt0_aarch64_efi.S
> index 5b6c384..0db4360 100644
> --- a/arch/arm/lib/crt0_aarch64_efi.S
> +++ b/arch/arm/lib/crt0_aarch64_efi.S
> @@ -122,8 +122,6 @@ _start:
>         mov             x29, sp
>
>         stp             x0, x1, [sp, #16]
> -       mov             x2, x0
> -       mov             x3, x1
>         adr             x0, ImageBase
>         adrp            x1, _DYNAMIC
>         add             x1, x1, #:lo12:_DYNAMIC
> diff --git a/arch/arm/lib/crt0_arm_efi.S b/arch/arm/lib/crt0_arm_efi.S
> index 0f296f3..23db49f 100644
> --- a/arch/arm/lib/crt0_arm_efi.S
> +++ b/arch/arm/lib/crt0_arm_efi.S
> @@ -119,8 +119,6 @@ section_table:
>  _start:
>         stmfd           sp!, {r0-r2, lr}
>
> -       mov             r2, r0
> -       mov             r3, r1
>         adr             r1, .L_DYNAMIC
>         ldr             r0, [r1]
>         add             r1, r0, r1
> diff --git a/arch/arm/lib/reloc_aarch64_efi.c b/arch/arm/lib/reloc_aarch64_efi.c
> index 38c13d3..c648fe4 100644
> --- a/arch/arm/lib/reloc_aarch64_efi.c
> +++ b/arch/arm/lib/reloc_aarch64_efi.c
> @@ -38,8 +38,7 @@
>
>  #include <elf.h>
>
> -efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image,
> -                      struct efi_system_table *systab)
> +efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image)

This still has the image argument.

>  {
>         long relsz = 0, relent = 0;
>         Elf64_Rela *rel = 0;
> diff --git a/arch/arm/lib/reloc_arm_efi.c b/arch/arm/lib/reloc_arm_efi.c
> index 6232e3f..336a98a 100644
> --- a/arch/arm/lib/reloc_arm_efi.c
> +++ b/arch/arm/lib/reloc_arm_efi.c
> @@ -14,8 +14,7 @@
>  #include <efi.h>
>  #include <elf.h>
>
> -efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image,
> -                      struct efi_system_table *systab)
> +efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn)
>  {
>         long relsz = 0, relent = 0;
>         Elf32_Rel *rel = 0;
> --

Regards,
Bin

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

* [U-Boot] [PATCH v4 4/4] riscv: Remove unused _relocate arguments
  2018-06-12 17:52 ` [U-Boot] [PATCH v4 4/4] riscv: " Ivan Gorinov
@ 2018-06-13  1:38   ` Bin Meng
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Meng @ 2018-06-13  1:38 UTC (permalink / raw)
  To: u-boot

Hi Ivan,

On Wed, Jun 13, 2018 at 1:52 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
> EFI image handle and system table are not used in _relocate().
>
> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
> ---
>  arch/riscv/lib/reloc_riscv_efi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/riscv/lib/reloc_riscv_efi.c b/arch/riscv/lib/reloc_riscv_efi.c
> index 8b4b2b1..51b7520 100644
> --- a/arch/riscv/lib/reloc_riscv_efi.c
> +++ b/arch/riscv/lib/reloc_riscv_efi.c
> @@ -50,8 +50,7 @@
>  #define ELF_R_TYPE     ELF32_R_TYPE
>  #endif
>
> -efi_status_t _relocate(long ldbase, Elf_Dyn *dyn, efi_handle_t image,
> -                      struct efi_system_table *systab)
> +efi_status_t _relocate(long ldbase, Elf_Dyn *dyn, efi_handle_t image)

This still has the image argument.

>  {
>         long relsz = 0, relent = 0;
>         Elf_Rela *rel = 0;
> --

Regards,
Bin

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

* [U-Boot] [PATCH v4 1/4] x86: use EFI calling convention for efi_main on x86_64
  2018-06-13  1:36   ` Bin Meng
@ 2018-06-22  1:44     ` Bin Meng
  0 siblings, 0 replies; 10+ messages in thread
From: Bin Meng @ 2018-06-22  1:44 UTC (permalink / raw)
  To: u-boot

Hi Ivan,

On Wed, Jun 13, 2018 at 9:36 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Ivan,
>
> On Wed, Jun 13, 2018 at 1:52 AM, Ivan Gorinov <ivan.gorinov@intel.com> wrote:
>> UEFI specifies the calling convention used in Microsoft compilers;
>> first arguments of a function are passed in (%rcx, %rdx, %r8, %r9).
>>
>> All other compilers use System V ABI by default, passing first integer
>> arguments of a function in (%rdi, %rsi, %rdx, %rcx, %r8, %r9).
>>
>> These ABI also specify different sets of registers that must be preserved
>> across function calls (callee-saved).
>>
>> GCC allows using the Microsoft calling convention by adding the ms_abi
>> attribute to a function declaration.
>>
>> Current EFI implementation in U-Boot specifies EFIAPI for efi_main()
>> in the test apps but uses default calling convention in lib/efi.
>> The arguments of efi_main() are also passed as unused arguments to the
>> _relocate() function.
>>
>> Save efi_main() arguments in the startup code on x86_64;
>> use EFI calling convention for _relocate() on x86_64;
>> remove unused _relocate() arguments;
>
> Thanks for working on this. But as I mentioned previously, the removal
> of _relocate() arguments should be in a separate patch. This patch
> should only deal with the calling convention changes.
>
> So we should have 4 patches:
> [1/4]: efi: calling convention changes for x86_64
> [2/4]: x86: remove unused _relocate() arguments
> [3/4]: arm: remove unused _relocate() arguments
> [4/4]: riscv: remove unused _relocate() arguments
>

So far I did not see you posted a newer version of patch series to
remove unused _relocate() arguments for x86/arm/riscv. Will you do
that?

>> consistently use EFI calling convention for efi_main() everywhere.
>>
>> Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com>
>> ---
>>  arch/x86/lib/crt0_x86_64_efi.S  | 21 ++++++++++-----------
>>  arch/x86/lib/reloc_x86_64_efi.c |  3 +--
>>  lib/efi/efi_app.c               |  3 ++-
>>  lib/efi/efi_stub.c              |  3 ++-
>>  4 files changed, 15 insertions(+), 15 deletions(-)
>>

Regards,
Bin

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

end of thread, other threads:[~2018-06-22  1:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 17:51 [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Ivan Gorinov
2018-06-12 17:52 ` [U-Boot] [PATCH v4 1/4] " Ivan Gorinov
2018-06-13  1:36   ` Bin Meng
2018-06-22  1:44     ` Bin Meng
2018-06-12 17:52 ` [U-Boot] [PATCH v4 2/4] arm: Remove unused _relocate arguments Ivan Gorinov
2018-06-13  1:38   ` Bin Meng
2018-06-12 17:52 ` [U-Boot] [PATCH v4 3/4] x86: " Ivan Gorinov
2018-06-12 17:52 ` [U-Boot] [PATCH v4 4/4] riscv: " Ivan Gorinov
2018-06-13  1:38   ` Bin Meng
2018-06-12 18:56 ` [U-Boot] [PATCH v4 0/4] x86: use EFI calling convention for efi_main on x86_64 Alexander Graf

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.