Re: [PATCH v3 05/35] efi: Create a 64-bit app

2021-10-28 Thread Simon Glass
Hi Heinrich,

On Wed, 27 Oct 2021 at 23:58, Heinrich Schuchardt  wrote:
>
> On 10/26/21 5:30 AM, Simon Glass wrote:
> > Most modern platforms use 64-bit EFI so it is useful to have a U-Boot app
> > that runs under that. Add a (non-functional) build for this.
> >
> > Note that --whole-archive causes the gcc 9.2 linker to crash, so disable
> > this for now. Once this is resolved, things should work.
> >
> > For now, avoid mentioning the documentation for the 64-bit app, since it
> > does not work.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v3:
> > - Default to 256MB of RAM for U-Boot instead of 32MB
> >
> > Changes in v2:
> > - Add MAINTAINERS entry
> > - Add a work-around to avoid a toolchain crash
> >
> >   MAINTAINERS   |  3 ++
> >   Makefile  |  8 +++-
> >   arch/x86/cpu/u-boot-64.lds|  2 +
> >   arch/x86/cpu/x86_64/Makefile  |  4 ++
> >   arch/x86/cpu/x86_64/cpu.c | 17 
> >   arch/x86/cpu/x86_64/misc.c| 25 
> >   board/efi/Kconfig | 15 ++-
> >   board/efi/efi-x86_app/Kconfig |  2 +-
> >   board/efi/efi-x86_app/MAINTAINERS | 11 +-
> >   ..._app_defconfig => efi-x86_app32_defconfig} |  2 +-
> >   configs/efi-x86_app64_defconfig   | 39 +++
> >   doc/develop/uefi/u-boot_on_efi.rst|  6 +--
> >   12 files changed, 106 insertions(+), 28 deletions(-)
> >   create mode 100644 arch/x86/cpu/x86_64/misc.c
> >   rename configs/{efi-x86_app_defconfig => efi-x86_app32_defconfig} (97%)
> >   create mode 100644 configs/efi-x86_app64_defconfig

> If CONFIG_EFI_LOADER generally does not work with the app shouldn't we
> put this into a Kconfig condition (in a separate patch)?

Yes I can send a patch for that. It would be yet another EFI case
(pass-through) I think, if we do implement it.

>
> Reviewed-by: Heinrich Schuchardt 
>
> > diff --git a/doc/develop/uefi/u-boot_on_efi.rst 
> > b/doc/develop/uefi/u-boot_on_efi.rst
> > index 4b2a733076d..d049f429fdc 100644
> > --- a/doc/develop/uefi/u-boot_on_efi.rst
> > +++ b/doc/develop/uefi/u-boot_on_efi.rst
> > @@ -48,10 +48,10 @@ for that board. It will be either 32-bit or 64-bit. 
> > Alternatively, you can
> >   opt for using QEMU [1] and the OVMF [2], as detailed below.
> >
> >   To build U-Boot as an EFI application (32-bit EFI required), enable 
> > CONFIG_EFI
> > -and CONFIG_EFI_APP. The efi-x86_app config (efi-x86_app_defconfig) is set 
> > up
> > +and CONFIG_EFI_APP. The efi-x86_app config (efi-x86_app32_defconfig) is 
> > set up
> >   for this. Just build U-Boot as normal, e.g.::
> >
> > -   make efi-x86_app_defconfig
> > +   make efi-x86_app32_defconfig
> >  make
> >
> >   To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), 
> > enable
> > @@ -259,7 +259,7 @@ This work could be extended in a number of ways:
> >
> >   - Add ARM support
> >
> > -- Add 64-bit application support
> > +- Add 64-bit application support (in progress)
> >
> >   - Figure out how to solve the interrupt problem
> >
> >
>
[..]

Regards,
Simon


Re: [PATCH v3 05/35] efi: Create a 64-bit app

2021-10-27 Thread Heinrich Schuchardt

On 10/26/21 5:30 AM, Simon Glass wrote:

Most modern platforms use 64-bit EFI so it is useful to have a U-Boot app
that runs under that. Add a (non-functional) build for this.

Note that --whole-archive causes the gcc 9.2 linker to crash, so disable
this for now. Once this is resolved, things should work.

For now, avoid mentioning the documentation for the 64-bit app, since it
does not work.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Default to 256MB of RAM for U-Boot instead of 32MB

Changes in v2:
- Add MAINTAINERS entry
- Add a work-around to avoid a toolchain crash

  MAINTAINERS   |  3 ++
  Makefile  |  8 +++-
  arch/x86/cpu/u-boot-64.lds|  2 +
  arch/x86/cpu/x86_64/Makefile  |  4 ++
  arch/x86/cpu/x86_64/cpu.c | 17 
  arch/x86/cpu/x86_64/misc.c| 25 
  board/efi/Kconfig | 15 ++-
  board/efi/efi-x86_app/Kconfig |  2 +-
  board/efi/efi-x86_app/MAINTAINERS | 11 +-
  ..._app_defconfig => efi-x86_app32_defconfig} |  2 +-
  configs/efi-x86_app64_defconfig   | 39 +++
  doc/develop/uefi/u-boot_on_efi.rst|  6 +--
  12 files changed, 106 insertions(+), 28 deletions(-)
  create mode 100644 arch/x86/cpu/x86_64/misc.c
  rename configs/{efi-x86_app_defconfig => efi-x86_app32_defconfig} (97%)
  create mode 100644 configs/efi-x86_app64_defconfig

diff --git a/MAINTAINERS b/MAINTAINERS
index a46ef70d3cd..ca015e3f3e3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -698,6 +698,9 @@ M:  Simon Glass 
  M:Heinrich Schuchardt 
  S:Maintained
  W:https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html
+F: board/efi/efi-x86_app
+F: configs/efi-x86_app*
+F: doc/develop/uefi/u-boot_on_efi.rst
  F:lib/efi/efi_app.c
  F:scripts/build-efi.sh

diff --git a/Makefile b/Makefile
index fd2b328e021..1f043c380a5 100644
--- a/Makefile
+++ b/Makefile
@@ -1753,12 +1753,16 @@ quiet_cmd_u-boot__ ?= LTO $@
-Wl,-Map,u-boot.map;
\
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
  else
+# Note: Linking efi-x86_app64 causes a segfault in the linker at present
+# when using x86_64-linux-gnu-ld.bfd
+# For now, disable --whole-archive which makes things link, although not
+# correctly
  quiet_cmd_u-boot__ ?= LD  $@
cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ 
\
-T u-boot.lds $(u-boot-init)
\
-   --whole-archive 
\
+   $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive)  
\
$(u-boot-main)  
\
-   --no-whole-archive  
\
+   $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive)   
\
$(PLATFORM_LIBS) -Map u-boot.map;   
\
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
  endif
diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds
index ee0812aefbc..92a30c2a387 100644
--- a/arch/x86/cpu/u-boot-64.lds
+++ b/arch/x86/cpu/u-boot-64.lds
@@ -15,7 +15,9 @@ SECTIONS
/DISCARD/ : { *(.u_boot_list_2_cmd_*) }
  #endif

+#ifdef CONFIG_SYS_TEXT_BASE
. = CONFIG_SYS_TEXT_BASE;   /* Location of bootcode in flash */
+#endif
__text_start = .;

.text.start : { *(.text.start); }
diff --git a/arch/x86/cpu/x86_64/Makefile b/arch/x86/cpu/x86_64/Makefile
index 400f0ffe397..e929563b2c1 100644
--- a/arch/x86/cpu/x86_64/Makefile
+++ b/arch/x86/cpu/x86_64/Makefile
@@ -4,3 +4,7 @@
  #

  obj-y += cpu.o interrupts.o setjmp.o
+
+ifndef CONFIG_EFI
+obj-y += misc.o
+endif
diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index 90a766c3c57..8f72c9951a1 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -49,23 +49,6 @@ int x86_mp_init(void)
return 0;
  }

-int misc_init_r(void)
-{
-   return 0;
-}
-
-#ifndef CONFIG_SYS_COREBOOT
-int checkcpu(void)
-{
-   return 0;
-}
-
-int print_cpuinfo(void)
-{
-   return 0;
-}
-#endif
-
  int x86_cpu_reinit_f(void)
  {
return 0;
diff --git a/arch/x86/cpu/x86_64/misc.c b/arch/x86/cpu/x86_64/misc.c
new file mode 100644
index 000..02587ff0c50
--- /dev/null
+++ b/arch/x86/cpu/x86_64/misc.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Google, Inc
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+
+int misc_init_r(void)
+{
+   return 0;
+}
+
+#ifndef CONFIG_SYS_COREBOOT
+int checkcpu(void)
+{
+   return 0;
+}
+
+int print_cpuinfo(void)
+{
+   return 0;
+}
+#endif
diff --git a/board/efi/Kco

[PATCH v3 05/35] efi: Create a 64-bit app

2021-10-25 Thread Simon Glass
Most modern platforms use 64-bit EFI so it is useful to have a U-Boot app
that runs under that. Add a (non-functional) build for this.

Note that --whole-archive causes the gcc 9.2 linker to crash, so disable
this for now. Once this is resolved, things should work.

For now, avoid mentioning the documentation for the 64-bit app, since it
does not work.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Default to 256MB of RAM for U-Boot instead of 32MB

Changes in v2:
- Add MAINTAINERS entry
- Add a work-around to avoid a toolchain crash

 MAINTAINERS   |  3 ++
 Makefile  |  8 +++-
 arch/x86/cpu/u-boot-64.lds|  2 +
 arch/x86/cpu/x86_64/Makefile  |  4 ++
 arch/x86/cpu/x86_64/cpu.c | 17 
 arch/x86/cpu/x86_64/misc.c| 25 
 board/efi/Kconfig | 15 ++-
 board/efi/efi-x86_app/Kconfig |  2 +-
 board/efi/efi-x86_app/MAINTAINERS | 11 +-
 ..._app_defconfig => efi-x86_app32_defconfig} |  2 +-
 configs/efi-x86_app64_defconfig   | 39 +++
 doc/develop/uefi/u-boot_on_efi.rst|  6 +--
 12 files changed, 106 insertions(+), 28 deletions(-)
 create mode 100644 arch/x86/cpu/x86_64/misc.c
 rename configs/{efi-x86_app_defconfig => efi-x86_app32_defconfig} (97%)
 create mode 100644 configs/efi-x86_app64_defconfig

diff --git a/MAINTAINERS b/MAINTAINERS
index a46ef70d3cd..ca015e3f3e3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -698,6 +698,9 @@ M:  Simon Glass 
 M: Heinrich Schuchardt 
 S: Maintained
 W: https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html
+F: board/efi/efi-x86_app
+F: configs/efi-x86_app*
+F: doc/develop/uefi/u-boot_on_efi.rst
 F: lib/efi/efi_app.c
 F: scripts/build-efi.sh
 
diff --git a/Makefile b/Makefile
index fd2b328e021..1f043c380a5 100644
--- a/Makefile
+++ b/Makefile
@@ -1753,12 +1753,16 @@ quiet_cmd_u-boot__ ?= LTO $@
-Wl,-Map,u-boot.map;
\
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 else
+# Note: Linking efi-x86_app64 causes a segfault in the linker at present
+# when using x86_64-linux-gnu-ld.bfd
+# For now, disable --whole-archive which makes things link, although not
+# correctly
 quiet_cmd_u-boot__ ?= LD  $@
   cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@  
\
-T u-boot.lds $(u-boot-init)
\
-   --whole-archive 
\
+   $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive)  
\
$(u-boot-main)  
\
-   --no-whole-archive  
\
+   $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive)   
\
$(PLATFORM_LIBS) -Map u-boot.map;   
\
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 endif
diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds
index ee0812aefbc..92a30c2a387 100644
--- a/arch/x86/cpu/u-boot-64.lds
+++ b/arch/x86/cpu/u-boot-64.lds
@@ -15,7 +15,9 @@ SECTIONS
/DISCARD/ : { *(.u_boot_list_2_cmd_*) }
 #endif
 
+#ifdef CONFIG_SYS_TEXT_BASE
. = CONFIG_SYS_TEXT_BASE;   /* Location of bootcode in flash */
+#endif
__text_start = .;
 
.text.start : { *(.text.start); }
diff --git a/arch/x86/cpu/x86_64/Makefile b/arch/x86/cpu/x86_64/Makefile
index 400f0ffe397..e929563b2c1 100644
--- a/arch/x86/cpu/x86_64/Makefile
+++ b/arch/x86/cpu/x86_64/Makefile
@@ -4,3 +4,7 @@
 #
 
 obj-y += cpu.o interrupts.o setjmp.o
+
+ifndef CONFIG_EFI
+obj-y += misc.o
+endif
diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index 90a766c3c57..8f72c9951a1 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -49,23 +49,6 @@ int x86_mp_init(void)
return 0;
 }
 
-int misc_init_r(void)
-{
-   return 0;
-}
-
-#ifndef CONFIG_SYS_COREBOOT
-int checkcpu(void)
-{
-   return 0;
-}
-
-int print_cpuinfo(void)
-{
-   return 0;
-}
-#endif
-
 int x86_cpu_reinit_f(void)
 {
return 0;
diff --git a/arch/x86/cpu/x86_64/misc.c b/arch/x86/cpu/x86_64/misc.c
new file mode 100644
index 000..02587ff0c50
--- /dev/null
+++ b/arch/x86/cpu/x86_64/misc.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Google, Inc
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+
+int misc_init_r(void)
+{
+   return 0;
+}
+
+#ifndef CONFIG_SYS_COREBOOT
+int checkcpu(void)
+{
+   return 0;
+}
+
+int print_cpuinfo(void)
+{
+   return 0;
+}
+#endif
diff --git a/board/efi/Kconfig b/board/efi/Kconfig
index 291bd2ca154..3df6e31c8ba 100644