Skip to contentSkip to conversation

arm: Support building as an EFI app

PATCH Superseded Simon Glass 4 participants 97 messages Feb 3, 2025 – Feb 25, 2025

Subsystems (8)
Arm (32-bit) x86 Kbuild PCI +4 more subsystems

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover arm: Support building as an EFI app

The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).

Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.

EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.

EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.

As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.

So this series adds an EFI app for 64-bit ARM.

Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.

Simon Glass (32):
Convert build-efi script to Python
Makefile: Avoid using TEXT_BASE if not present
video: Move vesa_setup_video_priv() into its own file
video: Use a local mode_info struct in the EFI driver
lib: Provide fdtdec_get_pci_bar32() only with PCI enabled
scripts: Update build-efi to support building U-Boot
scripts: Update build-efi to support arm64
efi: Rename app and payload to include x86
efi: Allow board/efi Kconfig to be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
efi: x86: Rework VENDOR_EFI option to permit other archs
efi: x86: Allow setting the global_data pointer with EFI
efi: Tidy up setup of global_data
efi: Rename ImageBase to image_base
efi: lmb: Avoid access to _start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access to global_data for EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception code when running as an EFI app
efi: arm: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Select the EFI linker script for the app
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: Disable STATIC_RELA for the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64

 Kconfig                               |   1 +
 MAINTAINERS                           |   6 +-
 Makefile                              |   8 +-
 arch/Kconfig                          |   2 +
 arch/arm/Kconfig                      |   6 +-
 arch/arm/Makefile                     |   2 +
 arch/arm/config.mk                    |  12 ++
 arch/arm/cpu/armv8/Makefile           |   4 +-
 arch/arm/cpu/armv8/config.mk          |   7 +-
 arch/arm/dts/efi-arm_app.dts          |  31 +++
 arch/arm/include/asm/global_data.h    |  16 +-
 arch/arm/lib/Makefile                 |  12 +-
 arch/arm/lib/bootm.c                  |   7 +-
 arch/arm/lib/cache.c                  |   3 +
 arch/arm/lib/crt0_aarch64_efi.S       | 158 +++-----------
 arch/arm/lib/elf_aarch64_efi.lds      |  49 +++--
 arch/riscv/lib/crt0_riscv_efi.S       |  28 +--
 arch/x86/Kconfig                      |   4 +-
 arch/x86/cpu/efi/Makefile             |   1 -
 arch/x86/include/asm/global_data.h    |   7 +
 board/efi/Kconfig                     |  41 +++-
 board/efi/efi-arm_app/Kconfig         |  16 ++
 board/efi/efi-arm_app/MAINTAINERS     |  13 ++
 board/efi/efi-arm_app/Makefile        |   5 +
 board/efi/efi-arm_app/board.c         |  18 ++
 board/efi/efi-arm_app/efi-arm_app.env |  11 +
 board/efi/efi-x86_payload/Kconfig     |   2 +-
 common/board_f.c                      |   4 +-
 common/board_r.c                      |   9 +-
 configs/efi-arm_app64_defconfig       |  51 +++++
 configs/efi-x86_app32_defconfig       |   4 +-
 configs/efi-x86_app64_defconfig       |   4 +-
 configs/efi-x86_payload32_defconfig   |   4 +-
 configs/efi-x86_payload64_defconfig   |   4 +-
 doc/develop/uefi/u-boot_on_efi.rst    |  21 +-
 drivers/pci/pci_rom.c                 |  32 ---
 drivers/video/Makefile                |   2 +
 drivers/video/efi.c                   |   1 +
 drivers/video/vesa_helper.c           |  41 ++++
 include/asm-generic/sections.h        |   2 +
 include/vesa.h                        |   2 +
 lib/efi/Kconfig                       |   2 +-
 lib/efi/Makefile                      |   1 +
 lib/efi/efi_app.c                     |  13 +-
 {arch/x86/cpu => lib}/efi/sdram.c     |   1 -
 lib/fdtdec.c                          |   2 +
 lib/lmb.c                             |   3 +-
 scripts/build-efi.py                  | 293 ++++++++++++++++++++++++++
 scripts/build-efi.sh                  | 207 ------------------
 49 files changed, 719 insertions(+), 454 deletions(-)
 create mode 100644 arch/arm/dts/efi-arm_app.dts
 create mode 100644 board/efi/efi-arm_app/Kconfig
 create mode 100644 board/efi/efi-arm_app/MAINTAINERS
 create mode 100644 board/efi/efi-arm_app/Makefile
 create mode 100644 board/efi/efi-arm_app/board.c
 create mode 100644 board/efi/efi-arm_app/efi-arm_app.env
 create mode 100644 configs/efi-arm_app64_defconfig
 create mode 100644 drivers/video/vesa_helper.c
 rename {arch/x86/cpu => lib}/efi/sdram.c (94%)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/32 Convert build-efi script to Python

Before this gets any longer, convert it to Python so it is easier to maintain.

---

 MAINTAINERS                        |   2 +-
 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
 scripts/build-efi.sh               | 207 -----------------------
 4 files changed, 261 insertions(+), 210 deletions(-)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh
MAINTAINERS +1 -1
index 9ba0c98cef2..a8e81577090 100644
@@ -1072,7 +1072,7 @@ F:	doc/develop/uefi/u-boot_on_efi.rst
 F:	drivers/block/efi-media-uclass.c
 F:	drivers/block/sb_efi_media.c
 F:	lib/efi/efi_app.c
-F:	scripts/build-efi.sh
+F:	scripts/build-efi.py
 F:	test/dm/efi_media.c
 
 EFI LOGGING
doc/develop/uefi/u-boot_on_efi.rst +2 -2
index 245b4af1fa3..9d441cdc2c5 100644
@@ -96,7 +96,7 @@ that EFI does not support booting a 64-bit application from a 32-bit
 EFI (or vice versa). Also it will often fail to print an error message if
 you get this wrong.
 
-You may find the script `scripts/build-efi.sh` helpful for building and testing
+You may find the script `scripts/build-efi.py` helpful for building and testing
 U-Boot on UEFI on QEMU. It also includes links to UEFI binaries dating from
 2021.
 
@@ -201,7 +201,7 @@ Example run
 
 This shows running with serial enabled (see `include/configs/efi-x86_app.h`)::
 
-   $ scripts/build-efi.sh -wsPr
+   $ scripts/build-efi.py -wsPr
    Packaging efi-x86_app32
    Running qemu-system-i386
 
scripts/build-efi.py new file +258 -0

258 lines not on this page · raw message

scripts/build-efi.sh deleted +0 -207

207 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

Quoted 6 lines · Simon Glass

Before this gets any longer, convert it to Python so it is easier to maintain.

---

Quoted 7 lines
 MAINTAINERS                        |   2 +-
 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
 scripts/build-efi.sh               | 207 -----------------------
 4 files changed, 261 insertions(+), 210 deletions(-)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh

This should just go live in the u-boot-extras repository as another sample script. And as a bonus, there you can just push the script right now.

Signature · 1 line
Tom
#3 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 6 lines · Simon Glass

Before this gets any longer, convert it to Python so it is easier to maintain.

---

Quoted 7 lines
 MAINTAINERS                        |   2 +-
 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
 scripts/build-efi.sh               | 207 -----------------------
 4 files changed, 261 insertions(+), 210 deletions(-)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh
Quoted 3 lines

This should just go live in the u-boot-extras repository as another sample script. And as a bonus, there you can just push the script right now.

But I can't be sure it will stay that way. In any case I see these scripts as first-class citizens, in the docs, tested in CI, used by people to report bugs, updated as new features appear, etc.

Regards,
Simon

#4 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

Quoted 20 lines · Simon Glass

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 13 lines · Simon Glass

Before this gets any longer, convert it to Python so it is easier to maintain.

---

 MAINTAINERS                        |   2 +-
 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
 scripts/build-efi.sh               | 207 -----------------------
 4 files changed, 261 insertions(+), 210 deletions(-)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh
Quoted 7 lines
Quoted 3 lines

This should just go live in the u-boot-extras repository as another sample script. And as a bonus, there you can just push the script right now.

But I can't be sure it will stay that way. In any case I see these scripts as first-class citizens, in the docs, tested in CI, used by people to report bugs, updated as new features appear, etc.

Yup, I still think that's the wrong way of looking at it. It's a sample script on how to use this for QEMU which means it's useful as a debug and development aid. It's bad for CI since if we want to deal with "CI is slow" we need to pre-create test disk images, not do that on the fly. And you've got sudo and various external blobs being used. No, it does not belong in the main repository and I'm sorry I missed it the first time.

And converting this to python is even worse as we have yet another tool that should have a proper requirements.txt file and keeping that up to date. And then oh, the inevitable "here's a security issue in U-Boot!" (by which they mean an issue in a support script and not what's deployed and used).

So please, lets just move this to the extras repository, and point to *that* in our docs enough that it's clear that we have tooling that can be useful in some cases there.

Signature · 1 line
Tom
#5 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

Hi Tom,

Quoted 38 lines · Tom Rini
Quoted 20 lines · Simon Glass

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 13 lines · Simon Glass

Before this gets any longer, convert it to Python so it is easier to maintain.

---

 MAINTAINERS                        |   2 +-
 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
 scripts/build-efi.sh               | 207 -----------------------
 4 files changed, 261 insertions(+), 210 deletions(-)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh
Quoted 7 lines
Quoted 3 lines

This should just go live in the u-boot-extras repository as another sample script. And as a bonus, there you can just push the script right now.

But I can't be sure it will stay that way. In any case I see these scripts as first-class citizens, in the docs, tested in CI, used by people to report bugs, updated as new features appear, etc.

Yup, I still think that's the wrong way of looking at it. It's a sample script on how to use this for QEMU which means it's useful as a debug and development aid. It's bad for CI since if we want to deal with "CI is slow" we need to pre-create test disk images, not do that on the fly. And you've got sudo and various external blobs being used. No, it does not belong in the main repository and I'm sorry I missed it the first time.

Quoted 5 lines

And converting this to python is even worse as we have yet another tool that should have a proper requirements.txt file and keeping that up to date. And then oh, the inevitable "here's a security issue in U-Boot!" (by which they mean an issue in a support script and not what's deployed and used).

IMO development aids are quite important for efficient development. We have things like scripts/gen_compile_commands.py and checkpatch.pl which I use quite a bit. Cloning another repo just to be able to develop on U-Boot efficiently seems daft to me.

We don't pre-create any test-disk images at present(?) I'm not even sure that is a good idea, since it means that updating a test becomes a lot harder. It would save a little time, but the thing which creates the image only takes a few seconds on tui (although this happens on each runner on the test.py stage):

2.6s test_ut_dm_init_bootstd

Python is easier to maintain than shell when it gets beyond 100 lines or so. We could use the same requirements.txt we have for test/py and I'm not sure how to deal with the security side. It sounds like calling it a contrib/ directory might be enough.

Quoted 4 lines

So please, lets just move this to the extras repository, and point to *that* in our docs enough that it's clear that we have tooling that can be useful in some cases there.

So long as I can point to it in docs and never lose access to the repo in the future, I think I can live with this. At least I can try it.

I think I could add it as a repo in the contriib/ subdir of the U-Boot directory (with a .gitignore in U-Boot), so perhaps I can mostly forget that it is separate.

Regards,
Simon

#6 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

Quoted 47 lines · Simon Glass

Hi Tom,

Quoted 38 lines · Tom Rini
Quoted 20 lines · Simon Glass

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 13 lines · Simon Glass

Before this gets any longer, convert it to Python so it is easier to maintain.

---

 MAINTAINERS                        |   2 +-
 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
 scripts/build-efi.sh               | 207 -----------------------
 4 files changed, 261 insertions(+), 210 deletions(-)
 create mode 100755 scripts/build-efi.py
 delete mode 100755 scripts/build-efi.sh
Quoted 7 lines
Quoted 3 lines

This should just go live in the u-boot-extras repository as another sample script. And as a bonus, there you can just push the script right now.

But I can't be sure it will stay that way. In any case I see these scripts as first-class citizens, in the docs, tested in CI, used by people to report bugs, updated as new features appear, etc.

Yup, I still think that's the wrong way of looking at it. It's a sample script on how to use this for QEMU which means it's useful as a debug and development aid. It's bad for CI since if we want to deal with "CI is slow" we need to pre-create test disk images, not do that on the fly. And you've got sudo and various external blobs being used. No, it does not belong in the main repository and I'm sorry I missed it the first time.

Quoted 5 lines

And converting this to python is even worse as we have yet another tool that should have a proper requirements.txt file and keeping that up to date. And then oh, the inevitable "here's a security issue in U-Boot!" (by which they mean an issue in a support script and not what's deployed and used).

Quoted 4 lines

IMO development aids are quite important for efficient development. We have things like scripts/gen_compile_commands.py and checkpatch.pl which I use quite a bit. Cloning another repo just to be able to develop on U-Boot efficiently seems daft to me.

There's pluses and minuses and fine lines to be drawn, yes.

Quoted 18 lines

We don't pre-create any test-disk images at present(?) I'm not even sure that is a good idea, since it means that updating a test becomes a lot harder. It would save a little time, but the thing which creates the image only takes a few seconds on tui (although this happens on each runner on the test.py stage):

2.6s test_ut_dm_init_bootstd

Python is easier to maintain than shell when it gets beyond 100 lines or so. We could use the same requirements.txt we have for test/py and I'm not sure how to deal with the security side. It sounds like calling it a contrib/ directory might be enough.

Quoted 4 lines

So please, lets just move this to the extras repository, and point to *that* in our docs enough that it's clear that we have tooling that can be useful in some cases there.

Quoted 6 lines

So long as I can point to it in docs and never lose access to the repo in the future, I think I can live with this. At least I can try it.

I think I could add it as a repo in the contriib/ subdir of the U-Boot directory (with a .gitignore in U-Boot), so perhaps I can mostly forget that it is separate.

You've had write access to the u-boot-extras repository since it was created, sorry if I wasn't clear about that. And another good thing about having "contrib" things outside of the main repository is that it's much easier to grant write access to others.

Signature · 1 line
Tom
#7 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

In reply to Simon Glass

Am 3. Februar 2025 18:41:54 MEZ schrieb Simon Glass <[email protected]>:

Quoted 58 lines

Before this gets any longer, convert it to Python so it is easier to maintain.

---

MAINTAINERS                        |   2 +-
doc/develop/uefi/u-boot_on_efi.rst |   4 +-
scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
scripts/build-efi.sh               | 207 -----------------------
4 files changed, 261 insertions(+), 210 deletions(-)

create mode 100755 scripts/build-efi.py
delete mode 100755 scripts/build-efi.sh

MAINTAINERS +0 -0
index 9ba0c98cef2..a8e81577090 100644
@@ -1072,7 +1072,7 @@ F:	doc/develop/uefi/u-boot_on_efi.rst

F: drivers/block/efi-media-uclass.c
F: drivers/block/sb_efi_media.c
F: lib/efi/efi_app.c

MAINTAINERS +1 -1
-F:	scripts/build-efi.sh
+F:	scripts/build-efi.py

F: test/dm/efi_media.c

EFI LOGGING

doc/develop/uefi/u-boot_on_efi.rst +0 -0
index 245b4af1fa3..9d441cdc2c5 100644
@@ -96,7 +96,7 @@ that EFI does not support booting a 64-bit application from a 32-bit

EFI (or vice versa). Also it will often fail to print an error message if you get this wrong.

doc/develop/uefi/u-boot_on_efi.rst +1 -1
-You may find the script `scripts/build-efi.sh` helpful for building and testing
+You may find the script `scripts/build-efi.py` helpful for building and testing

U-Boot on UEFI on QEMU. It also includes links to UEFI binaries dating from 2021.

doc/develop/uefi/u-boot_on_efi.rst +0 -0
@@ -201,7 +201,7 @@ Example run
 

This shows running with serial enabled (see include/configs/efi-x86_app.h)::

doc/develop/uefi/u-boot_on_efi.rst +1 -1
-   $ scripts/build-efi.sh -wsPr
+   $ scripts/build-efi.py -wsPr
   Packaging efi-x86_app32
   Running qemu-system-i386
scripts/build-efi.py new file +3 -0
new file mode 100755
index 00000000000..495817bc064
@@ -0,0 +1,258 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: GPL-2.0+
+"""

scripts/build-efi.py line 13

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+Script to build an EFI thing suitable for booting with QEMU, possibly running
+it also.
+
+UEFI binaries for QEMU used for testing this script:
+
+OVMF-pure-efi.i386.fd at
+https://drive.google.com/file/d/1jWzOAZfQqMmS2_dAK2G518GhIgj9r2RY/view?usp=sharing
+
+OVMF-pure-efi.x64.fd at
+https://drive.google.com/file/d/1c39YI9QtpByGQ4V0UNNQtGqttEzS-eFV/view?usp=sharing

Who would dare to download binaries of unknown origin and execute these?

The filenames do not match what is created by upstream EDK II.

These references should be removed.

Instead you could provide the EDK II version that you used for testing and the file name created by EDK II.

Quoted 74 lines
scripts/build-efi.py new file +74 -0
+
+Use ~/.build-efi to configure the various paths used by this script.
+"""
+
+from argparse import ArgumentParser
+import configparser
+import glob
+import os
+import re
+import shutil
+import sys
+import time
+
+
+OUR_PATH = os.path.dirname(os.path.realpath(__file__))
+OUR1_PATH = os.path.dirname(OUR_PATH)
+
+# Bring in the patman and dtoc libraries (but don't override the first path
+# in PYTHONPATH)
+sys.path.insert(2, os.path.join(OUR1_PATH, 'tools'))
+
+
+# pylint: disable=C0413
+from u_boot_pylib import command
+from u_boot_pylib import tools
+
+
+def parse_args():
+    """Parse the program arguments
+
+    Return:
+        Namespace object
+    """
+    parser = ArgumentParser(
+        epilog='Script for running U-Boot as an EFI app/payload')
+    parser.add_argument('-a', '--app', action='store_true',
+                        help='Package up the app')
+    parser.add_argument('-k', '--kernel', action='store_true',
+                        help='Add a kernel')
+    parser.add_argument('-o', '--old', action='store_true',
+                        help='Use old EFI app build (before 32/64 split)')
+    parser.add_argument('-p', '--payload', action='store_true',
+                        help='Package up the payload')
+    parser.add_argument('-P', '--partition', action='store_true',
+                        help='Create a partition table')
+    parser.add_argument('-r', '--run', action='store_true',
+                        help='Run QEMU with the image')
+    parser.add_argument('-s', '--serial', action='store_true',
+                        help='Run QEMU with serial only (no display)')
+    parser.add_argument('-w', '--word', action='store_true',
+                        help='Use word version (32-bit) rather than 64-bit')
+
+    args = parser.parse_args()
+
+    if args.app and args.payload:
+        raise ValueError('Please choose either app or payload, not both')
+    return args
+
+
+def get_settings():
+    """Get settings from the settings file
+
+    Return:
+        ConfigParser containing settings
+    """
+    settings = configparser.ConfigParser()
+    fname = f'{os.getenv("HOME")}/.build-efi'
+    if not os.path.exists(fname):
+        print('No config file found ~/.build-efi\nCreating one...\n')
+        tools.write_file(fname, '''[build-efi]
+# Mount path for the temporary image
+mount_point = /mnt/test-efi
+
+# Image-output filename

scripts/build-efi.py line 97

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+image_file = try.img
+
+# Set ubdir to the build directory where you build U-Boot out-of-tree
+# We avoid in-tree build because it gets confusing trying different builds
+build_dir = /tmp/b
+
+# Build the kernel with: make O=/tmp/kernel
+bzimage = /tmp/kernel/arch/x86/boot/bzImage
+
+# Place where OVMF-pure-efi.i386.fd etc. are kept

Is this i386 only? What would you use for arm64 and amd64?

Quoted 27 lines
scripts/build-efi.py new file +27 -0
+efi_dir = .
+''', binary=False)
+    settings.read(fname)
+    return settings
+
+
+class BuildEfi:
+    """Class to collect together the various bits of state while running"""
+    def __init__(self, settings, args):
+        self.settings = settings
+        self.img = self.get_setting('image_file', 'try.img')
+        self.build_dir = self.get_setting("build_dir", '/tmp')
+        self.mnt = self.get_setting("mount_point", '/mnt/test-efi')
+        self.tmp = None
+        self.args = args
+
+    def get_setting(self, name, fallback=None):
+        """Get a setting by name
+
+        Args:
+            name (str): Name of setting to retrieve
+            fallback (str or None): Value to return if the setting is missing
+        """
+        return self.settings.get('build-efi', name, fallback=fallback)
+
+    def run_qemu(self, bitness, serial_only):
+        """Run QEMU

scripts/build-efi.py line 134

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+
+        Args:
+            bitness (int): Bitness to use, 32 or 64
+            serial_only (bool): True to run without a display
+        """
+        extra = []
+        efi_dir = self.get_setting("efi_dir")
+        if bitness == 64:
+            qemu = 'qemu-system-x86_64'
+            bios = 'OVMF-pure-efi.x64.fd'

This is not a file name used by EDK II.

And what about arm64?

scripts/build-efi.py line 147

Quoted 13 lines
scripts/build-efi.py new file +13 -0
+        else:
+            qemu = 'qemu-system-i386'
+            bios = 'OVMF-pure-efi.i386.fd'
+        if serial_only:
+            extra = ['-display', 'none', '-serial', 'mon:stdio']
+            serial_msg = ' (Ctrl-a x to quit)'
+        else:
+            extra = ['-serial', 'mon:stdio']
+            serial_msg = ''
+        print(f'Running {qemu}{serial_msg}')
+
+        # Use 512MB since U-Boot EFI likes to have 256MB to play with
+        cmd = [qemu, '-bios', os.path.join(efi_dir), bios)]

For EDK II you should use pflash.

scripts/build-efi.py line 151

Quoted 4 lines
scripts/build-efi.py new file +4 -0
+        cmd += '-m', '512'
+        cmd += '-drive', f'id=disk,file={self.img},if=none,format=raw'
+        cmd += '-device', 'ahci,id=ahci'
+        cmd += '-device', 'ide-hd,drive=disk,bus=ahci.0'

How outdated is this? Use virtio.

scripts/build-efi.py line 152

Quoted 1 line
scripts/build-efi.py new file +1 -0
+        cmd += '-nic', 'none'

Why none? Use virtio.

Quoted 14 lines
scripts/build-efi.py new file +14 -0
+        cmd += extra
+        command.run(*cmd)
+
+    def setup_files(self, build, build_type):
+        """Set up files in the staging area
+
+        Args:
+            build (str): Name of build being packaged, e.g. 'efi-x86_app32'
+            build_type (str): Build type ('app' or 'payload')
+        """
+        print(f'Packaging {build}')
+        if not os.path.exists(self.tmp):
+            os.mkdir(self.tmp)
+        fname = f'u-boot-{build_type}.efi'

scripts/build-efi.py line 176

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+        tools.write_file(f'{self.tmp}/startup.nsh', f'fs0:{fname}',
+                         binary=False)
+        shutil.copy(f'{self.build_dir}/{build}/{fname}', self.tmp)
+
+    def copy_files(self):
+        """Copy files into the filesystem"""
+        command.run('sudo', 'cp', *glob.glob(f'{self.tmp}/*'), self.mnt)
+        if self.args.kernel:
+            bzimage = self.get_setting('bzimage_file', 'bzImage')
+            command.run('sudo', 'cp', bzimage, f'{self.mnt}/vmlinuz')

Please, do not use sudo.

You can create partitioned disks with files without falling back to sudo.

Best regards

Heinrich

Quoted 295 lines
scripts/build-efi.py new file +82 -0
+
+    def setup_raw(self):
+        """Create a filesystem on a raw device and copy in the files"""
+        command.output('mkfs.vfat', self.img)
+        command.run('sudo', 'mount', '-o', 'loop', self.img, self.mnt)
+        self.copy_files()
+        command.run('sudo', 'umount', self.mnt)
+
+    def setup_part(self):
+        """Set up a partition table
+
+        Create a partition table and put the filesystem in the first partition
+        then copy in the files
+        """
+
+        # Create a gpt partition table with one partition
+        command.run('parted', self.img, 'mklabel', 'gpt', capture_stderr=True)
+
+        # This doesn't work correctly. It creates:
+        # Number  Start   End     Size    File system  Name  Flags
+        #  1      1049kB  24.1MB  23.1MB               boot  msftdata
+        # Odd if the same is entered interactively it does set the FS type
+        command.run('parted', '-s', '-a', 'optimal', '--',
+                    self.img, 'mkpart', 'boot', 'fat32', '1MiB', '23MiB')
+
+        # Map this partition to a loop device. Output is something like:
+        # add map loop48p1 (252:3): 0 45056 linear 7:48 2048
+        out = command.output('sudo', 'kpartx', '-av', self.img)
+        m = re.search(r'(loop.*p.)', out)
+        if not m:
+            raise ValueError(f'Invalid output from kpartx: {out}')
+
+        boot_dev = m.group(1)
+        dev = f'/dev/mapper/{boot_dev}'
+
+        command.output('mkfs.vfat', dev)
+
+        command.run('sudo', 'mount', '-o', 'loop', dev, self.mnt)
+
+        try:
+            self.copy_files()
+        finally:
+            # Sync here since this makes kpartx more likely to work the first time
+            command.run('sync')
+            command.run('sudo', 'umount', self.mnt)
+
+            # For some reason this needs a sleep or it sometimes fails, if it was
+            # run recently (in the last few seconds)
+            try:
+                cmd = 'sudo', 'kpartx', '-d', self.img
+                command.output(*cmd)
+            except command.CommandExc:
+                time.sleep(0.5)
+                command.output(*cmd)
+
+    def start(self):
+        """This does all the work"""
+        args = self.args
+        bitness = 32 if args.word else 64
+        build_type = 'payload' if args.payload else 'app'
+        self.tmp = f'{self.build_dir}/efi{bitness}{build_type}'
+        build = f'efi-x86_{build_type}{bitness}'
+
+        if args.old and bitness == 32:
+            build = f'efi-x86_{build_type}'
+
+        self.setup_files(build, build_type)
+
+        command.output('qemu-img', 'create', self.img, '24M')
+
+        if args.partition:
+            self.setup_part()
+        else:
+            self.setup_raw()
+
+        if args.run:
+            self.run_qemu(bitness, args.serial)
+
+
+if __name__ == "__main__":
+    efi = BuildEfi(get_settings(), parse_args())
+    efi.start()
scripts/build-efi.sh deleted +0 -207
deleted file mode 100755
index 6b7df2e9bfe..00000000000
@@ -1,207 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Script to build an EFI thing suitable for booting with QEMU, possibly running
-# it also.
-
-# This just an example. It assumes that
-
-# - you build U-Boot in ${ubdir}/<name> where <name> is the U-Boot board config
-# - /mnt/x is a directory used for mounting
-# - you have access to the 'pure UEFI' builds for QEMU
-#
-# UEFI binaries for QEMU used for testing this script:
-#
-# OVMF-pure-efi.i386.fd at
-# https://drive.google.com/file/d/1jWzOAZfQqMmS2_dAK2G518GhIgj9r2RY/view?usp=sharing
-
-# OVMF-pure-efi.x64.fd at
-# https://drive.google.com/file/d/1c39YI9QtpByGQ4V0UNNQtGqttEzS-eFV/view?usp=sharing
-
-bzimage_fname=/tmp/kernel/arch/x86/boot/bzImage
-
-set -e
-
-usage() {
-	echo "Usage: $0 [-a | -p] [other opts]" 1>&2
-	echo 1>&2
-	echo "   -a   - Package up the app" 1>&2
-	echo "   -k   - Add a kernel" 1>&2
-	echo "   -o   - Use old EFI app build (before 32/64 split)" 1>&2
-	echo "   -p   - Package up the payload" 1>&2
-	echo "   -P   - Create a partition table" 1>&2
-	echo "   -r   - Run QEMU with the image" 1>&2
-	echo "   -s   - Run QEMU with serial only (no display)" 1>&2
-	echo "   -w   - Use word version (32-bit)" 1>&2
-	exit 1
-}
-
-# 32- or 64-bit EFI
-bitness=64
-
-# app or payload ?
-type=app
-
-# create a partition table and put the filesystem in that (otherwise put the
-# filesystem in the raw device)
-part=
-
-# run the image with QEMU
-run=
-
-# run QEMU without a display (U-Boot must be set to stdout=serial)
-serial=
-
-# before the 32/64 split of the app
-old=
-
-# package up a kernel as well
-kernel=
-
-# Set ubdir to the build directory where you build U-Boot out-of-tree
-# We avoid in-tree build because it gets confusing trying different builds
-ubdir=/tmp/b/
-
-while getopts "akopPrsw" opt; do
-	case "${opt}" in
-	a)
-		type=app
-		;;
-	p)
-		type=payload
-		;;
-	k)
-		kernel=1
-		;;
-	r)
-		run=1
-		;;
-	s)
-		serial=1
-		;;
-	w)
-		bitness=32
-		;;
-	o)
-		old=1
-		;;
-	P)
-		part=1
-		;;
-	*)
-		usage
-		;;
-	esac
-done
-
-run_qemu() {
-	extra=
-	if [[ "${bitness}" = "64" ]]; then
-		qemu=qemu-system-x86_64
-		bios=OVMF-pure-efi.x64.fd
-	else
-		qemu=qemu-system-i386
-		bios=OVMF-pure-efi.i386.fd
-	fi
-	if [[ -n "${serial}" ]]; then
-		extra="-display none -serial mon:stdio"
-	else
-		extra="-serial mon:stdio"
-	fi
-	echo "Running ${qemu}"
-	# Use 512MB since U-Boot EFI likes to have 256MB to play with
-	"${qemu}" -bios "${bios}" \
-		-m 512 \
-		-drive id=disk,file="${IMG}",if=none,format=raw \
-		-nic none -device ahci,id=ahci \
-		-device ide-hd,drive=disk,bus=ahci.0 ${extra}
-}
-
-setup_files() {
-	echo "Packaging ${BUILD}"
-	mkdir -p $TMP
-	cat >$TMP/startup.nsh <<EOF
-fs0:u-boot-${type}.efi
-EOF
-	sudo cp ${ubdir}/${BUILD}/u-boot-${type}.efi $TMP
-
-	# Can copy in other files here:
-	#sudo cp ${ubdir}/$BUILD/image.bin $TMP/chromeos.rom
-	#sudo cp /boot/vmlinuz-5.4.0-77-generic $TMP/vmlinuz
-}
-
-# Copy files into the filesystem
-copy_files() {
-	sudo cp $TMP/* $MNT
-	if [[ -n "${kernel}" ]]; then
-		sudo cp ${bzimage_fname} $MNT/vmlinuz
-	fi
-}
-
-# Create a filesystem on a raw device and copy in the files
-setup_raw() {
-	mkfs.vfat "${IMG}" >/dev/null
-	sudo mount -o loop "${IMG}" $MNT
-	copy_files
-	sudo umount $MNT
-}
-
-# Create a partition table and put the filesystem in the first partition
-# then copy in the files
-setup_part() {
-	# Create a gpt partition table with one partition
-	parted "${IMG}" mklabel gpt 2>/dev/null
-
-	# This doesn't work correctly. It creates:
-	# Number  Start   End     Size    File system  Name  Flags
-	#  1      1049kB  24.1MB  23.1MB               boot  msftdata
-	# Odd if the same is entered interactively it does set the FS type
-	parted -s -a optimal -- "${IMG}" mkpart boot fat32 1MiB 23MiB
-
-	# Map this partition to a loop device
-	kp="$(sudo kpartx -av ${IMG})"
-	read boot_dev<<<$(grep -o 'loop.*p.' <<< "${kp}")
-	test "${boot_dev}"
-	dev="/dev/mapper/${boot_dev}"
-
-	mkfs.vfat "${dev}" >/dev/null
-
-	sudo mount -o loop "${dev}" $MNT
-
-	copy_files
-
-	# Sync here since this makes kpartx more likely to work the first time
-	sync
-	sudo umount $MNT
-
-	# For some reason this needs a sleep or it sometimes fails, if it was
-	# run recently (in the last few seconds)
-	if ! sudo kpartx -d "${IMG}" > /dev/null; then
-		sleep .5
-		sudo kpartx -d "${IMG}" > /dev/null || \
-			echo "Failed to remove ${boot_dev}, use: sudo kpartx -d ${IMG}"
-	fi
-}
-
-TMP="/tmp/efi${bitness}${type}"
-MNT=/mnt/x
-BUILD="efi-x86_${type}${bitness}"
-IMG=try.img
-
-if [[ -n "${old}" && "${bitness}" = "32" ]]; then
-	BUILD="efi-x86_${type}"
-fi
-
-setup_files
-
-qemu-img create "${IMG}" 24M >/dev/null
-
-if [[ -n "${part}" ]]; then
-	setup_part
-else
-	setup_raw
-fi
-
-if [[ -n "${run}" ]]; then
-	run_qemu
-fi
#8 lore raw

Re: [PATCH 01/32] Convert build-efi script to Python

Hi Heinrich,

Quoted 73 lines · Heinrich Schuchardt

Am 3. Februar 2025 18:41:54 MEZ schrieb Simon Glass <[email protected]>:

Quoted 58 lines

Before this gets any longer, convert it to Python so it is easier to maintain.

---

MAINTAINERS                        |   2 +-
doc/develop/uefi/u-boot_on_efi.rst |   4 +-
scripts/build-efi.py               | 258 +++++++++++++++++++++++++++++
scripts/build-efi.sh               | 207 -----------------------
4 files changed, 261 insertions(+), 210 deletions(-)

create mode 100755 scripts/build-efi.py
delete mode 100755 scripts/build-efi.sh

MAINTAINERS +0 -0
index 9ba0c98cef2..a8e81577090 100644
@@ -1072,7 +1072,7 @@ F:       doc/develop/uefi/u-boot_on_efi.rst
F:    drivers/block/efi-media-uclass.c
F:    drivers/block/sb_efi_media.c
F:    lib/efi/efi_app.c
MAINTAINERS +1 -1
-F:    scripts/build-efi.sh
+F:    scripts/build-efi.py

F: test/dm/efi_media.c

EFI LOGGING

doc/develop/uefi/u-boot_on_efi.rst +0 -0
index 245b4af1fa3..9d441cdc2c5 100644
@@ -96,7 +96,7 @@ that EFI does not support booting a 64-bit application from a 32-bit

EFI (or vice versa). Also it will often fail to print an error message if you get this wrong.

doc/develop/uefi/u-boot_on_efi.rst +1 -1
-You may find the script `scripts/build-efi.sh` helpful for building and testing
+You may find the script `scripts/build-efi.py` helpful for building and testing

U-Boot on UEFI on QEMU. It also includes links to UEFI binaries dating from 2021.

doc/develop/uefi/u-boot_on_efi.rst +0 -0
@@ -201,7 +201,7 @@ Example run
 

This shows running with serial enabled (see include/configs/efi-x86_app.h)::

doc/develop/uefi/u-boot_on_efi.rst +1 -1
-   $ scripts/build-efi.sh -wsPr
+   $ scripts/build-efi.py -wsPr
   Packaging efi-x86_app32
   Running qemu-system-i386
scripts/build-efi.py new file +3 -0
new file mode 100755
index 00000000000..495817bc064
@@ -0,0 +1,258 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: GPL-2.0+
+"""

scripts/build-efi.py line 13

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+Script to build an EFI thing suitable for booting with QEMU, possibly running
+it also.
+
+UEFI binaries for QEMU used for testing this script:
+
+OVMF-pure-efi.i386.fd at
+https://drive.google.com/file/d/1jWzOAZfQqMmS2_dAK2G518GhIgj9r2RY/view?usp=sharing
+
+OVMF-pure-efi.x64.fd at
+https://drive.google.com/file/d/1c39YI9QtpByGQ4V0UNNQtGqttEzS-eFV/view?usp=sharing

Who would dare to download binaries of unknown origin and execute these?

Quoted 5 lines

The filenames do not match what is created by upstream EDK II.

These references should be removed.

Instead you could provide the EDK II version that you used for testing and the file name created by EDK II.

The idea is not to execute them natively, but under QEMU. What filenames should be used? How can people get these files, if not through a download link?

Quoted 81 lines
Quoted 81 lines
scripts/build-efi.py new file +78 -0
+
+Use ~/.build-efi to configure the various paths used by this script.
+"""
+
+from argparse import ArgumentParser
+import configparser
+import glob
+import os
+import re
+import shutil
+import sys
+import time
+
+
+OUR_PATH = os.path.dirname(os.path.realpath(__file__))
+OUR1_PATH = os.path.dirname(OUR_PATH)
+
+# Bring in the patman and dtoc libraries (but don't override the first path
+# in PYTHONPATH)
+sys.path.insert(2, os.path.join(OUR1_PATH, 'tools'))
+
+
+# pylint: disable=C0413
+from u_boot_pylib import command
+from u_boot_pylib import tools
+
+
+def parse_args():
+    """Parse the program arguments
+
+    Return:
+        Namespace object
+    """
+    parser = ArgumentParser(
+        epilog='Script for running U-Boot as an EFI app/payload')
+    parser.add_argument('-a', '--app', action='store_true',
+                        help='Package up the app')
+    parser.add_argument('-k', '--kernel', action='store_true',
+                        help='Add a kernel')
+    parser.add_argument('-o', '--old', action='store_true',
+                        help='Use old EFI app build (before 32/64 split)')
+    parser.add_argument('-p', '--payload', action='store_true',
+                        help='Package up the payload')
+    parser.add_argument('-P', '--partition', action='store_true',
+                        help='Create a partition table')
+    parser.add_argument('-r', '--run', action='store_true',
+                        help='Run QEMU with the image')
+    parser.add_argument('-s', '--serial', action='store_true',
+                        help='Run QEMU with serial only (no display)')
+    parser.add_argument('-w', '--word', action='store_true',
+                        help='Use word version (32-bit) rather than 64-bit')
+
+    args = parser.parse_args()
+
+    if args.app and args.payload:
+        raise ValueError('Please choose either app or payload, not both')
+    return args
+
+
+def get_settings():
+    """Get settings from the settings file
+
+    Return:
+        ConfigParser containing settings
+    """
+    settings = configparser.ConfigParser()
+    fname = f'{os.getenv("HOME")}/.build-efi'
+    if not os.path.exists(fname):
+        print('No config file found ~/.build-efi\nCreating one...\n')
+        tools.write_file(fname, '''[build-efi]
+# Mount path for the temporary image
+mount_point = /mnt/test-efi
+
+# Image-output filename
+image_file = try.img
+
+# Set ubdir to the build directory where you build U-Boot out-of-tree
+# We avoid in-tree build because it gets confusing trying different builds
Quoted 8 lines

scripts/build-efi.py line 97

Quoted 6 lines
scripts/build-efi.py new file +6 -0
+build_dir = /tmp/b
+
+# Build the kernel with: make O=/tmp/kernel
+bzimage = /tmp/kernel/arch/x86/boot/bzImage
+
+# Place where OVMF-pure-efi.i386.fd etc. are kept

Is this i386 only? What would you use for arm64 and amd64?

Please can you check the series before responding to one patch? It is very confusing when you add comments to one patch (the conversion to Python) which are intended for another (adding ARM support).

Quoted 41 lines
Quoted 28 lines
scripts/build-efi.py new file +27 -0
+efi_dir = .
+''', binary=False)
+    settings.read(fname)
+    return settings
+
+
+class BuildEfi:
+    """Class to collect together the various bits of state while running"""
+    def __init__(self, settings, args):
+        self.settings = settings
+        self.img = self.get_setting('image_file', 'try.img')
+        self.build_dir = self.get_setting("build_dir", '/tmp')
+        self.mnt = self.get_setting("mount_point", '/mnt/test-efi')
+        self.tmp = None
+        self.args = args
+
+    def get_setting(self, name, fallback=None):
+        """Get a setting by name
+
+        Args:
+            name (str): Name of setting to retrieve
+            fallback (str or None): Value to return if the setting is missing
+        """
+        return self.settings.get('build-efi', name, fallback=fallback)
+
+    def run_qemu(self, bitness, serial_only):
+        """Run QEMU

scripts/build-efi.py line 134

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+
+        Args:
+            bitness (int): Bitness to use, 32 or 64
+            serial_only (bool): True to run without a display
+        """
+        extra = []
+        efi_dir = self.get_setting("efi_dir")
+        if bitness == 64:
+            qemu = 'qemu-system-x86_64'
+            bios = 'OVMF-pure-efi.x64.fd'

This is not a file name used by EDK II.

Quoted 1 line

And what about arm64?

It would help if you could indicate the name you want.

arm64 is in the next patch. This one just converts to Python.

Quoted 55 lines
Quoted 4 lines
scripts/build-efi.py new file +3 -0
+        else:
+            qemu = 'qemu-system-i386'
+            bios = 'OVMF-pure-efi.i386.fd'

scripts/build-efi.py line 147

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+        if serial_only:
+            extra = ['-display', 'none', '-serial', 'mon:stdio']
+            serial_msg = ' (Ctrl-a x to quit)'
+        else:
+            extra = ['-serial', 'mon:stdio']
+            serial_msg = ''
+        print(f'Running {qemu}{serial_msg}')
+
+        # Use 512MB since U-Boot EFI likes to have 256MB to play with
+        cmd = [qemu, '-bios', os.path.join(efi_dir), bios)]

For EDK II you should use pflash.

scripts/build-efi.py line 151

Quoted 4 lines
scripts/build-efi.py new file +4 -0
+        cmd += '-m', '512'
+        cmd += '-drive', f'id=disk,file={self.img},if=none,format=raw'
+        cmd += '-device', 'ahci,id=ahci'
+        cmd += '-device', 'ide-hd,drive=disk,bus=ahci.0'

How outdated is this? Use virtio.

scripts/build-efi.py line 152

Quoted 1 line
scripts/build-efi.py new file +1 -0
+        cmd += '-nic', 'none'

Why none? Use virtio.

Quoted 14 lines
scripts/build-efi.py new file +14 -0
+        cmd += extra
+        command.run(*cmd)
+
+    def setup_files(self, build, build_type):
+        """Set up files in the staging area
+
+        Args:
+            build (str): Name of build being packaged, e.g. 'efi-x86_app32'
+            build_type (str): Build type ('app' or 'payload')
+        """
+        print(f'Packaging {build}')
+        if not os.path.exists(self.tmp):
+            os.mkdir(self.tmp)
+        fname = f'u-boot-{build_type}.efi'

scripts/build-efi.py line 176

Quoted 10 lines
scripts/build-efi.py new file +10 -0
+        tools.write_file(f'{self.tmp}/startup.nsh', f'fs0:{fname}',
+                         binary=False)
+        shutil.copy(f'{self.build_dir}/{build}/{fname}', self.tmp)
+
+    def copy_files(self):
+        """Copy files into the filesystem"""
+        command.run('sudo', 'cp', *glob.glob(f'{self.tmp}/*'), self.mnt)
+        if self.args.kernel:
+            bzimage = self.get_setting('bzimage_file', 'bzImage')
+            command.run('sudo', 'cp', bzimage, f'{self.mnt}/vmlinuz')

Please, do not use sudo.

Quoted 1 line

You can create partitioned disks with files without falling back to sudo.

How do you do that? Do you mean like we do in test/py/ ?

[..]

Regards,
Simon

#9 lore raw

PATCH 2/32 Makefile: Avoid using TEXT_BASE if not present

In reply to Simon Glass

This value is only available if CONFIG_HAVE_TEXT_BASE is enabled. Add conditions to avoid introducing errors in link scripts when it is not.

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 2f7614191a1..3958ea45b9a 100644
@@ -1050,8 +1050,10 @@ LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs)
 LDFLAGS_u-boot += --build-id=none
 
 ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),)
+ifdef CONFIG_HAVE_TEXT_BASE
 LDFLAGS_u-boot += -Ttext $(CONFIG_TEXT_BASE)
 endif
+endif
 
 # make the checker run with the right architecture
 CHECKFLAGS += --arch=$(ARCH)
@@ -1741,7 +1743,7 @@ quiet_cmd_u-boot-elf ?= LD      $@
 	cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \
 	$(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \
 	-T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_TEXT_BASE) \
-	-Ttext=$(CONFIG_TEXT_BASE)
+	$(if $(CONFIG_HAVE_TEXT_BASE),-Ttext=$(CONFIG_TEXT_BASE))
 u-boot.elf: u-boot.bin u-boot-elf.lds
 	$(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o
 	$(call if_changed,u-boot-elf)
Signature · 1 line
2.43.0
#10 lore raw

Re: [PATCH 02/32] Makefile: Avoid using TEXT_BASE if not present

Quoted 14 lines · Simon Glass

This value is only available if CONFIG_HAVE_TEXT_BASE is enabled. Add conditions to avoid introducing errors in link scripts when it is not.

---

 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +0 -0
index 2f7614191a1..3958ea45b9a 100644

Makefile LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs) · line 1056

Quoted 7 lines
Makefile +2 -0
@@ -1050,8 +1050,10 @@ LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs)
 LDFLAGS_u-boot += --build-id=none
 
 ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),)
+ifdef CONFIG_HAVE_TEXT_BASE
 LDFLAGS_u-boot += -Ttext $(CONFIG_TEXT_BASE)
 endif
+endif

This is for linking of the "u-boot" target, and we can just add EFI_APP here. Looking at the cases above (arc and x86 at least), it's arguable that they're abusing CONFIG_TEXT_BASE when they really want some slightly different symbol to be used, but we can just set that can of worms aside now instead.

Makefile quiet_cmd_u-boot-elf ?= LD $@ · line 1749

Quoted 11 lines
Makefile +1 -1
 # make the checker run with the right architecture
 CHECKFLAGS += --arch=$(ARCH)
@@ -1741,7 +1743,7 @@ quiet_cmd_u-boot-elf ?= LD      $@
 	cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \
 	$(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \
 	-T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_TEXT_BASE) \
-	-Ttext=$(CONFIG_TEXT_BASE)
+	$(if $(CONFIG_HAVE_TEXT_BASE),-Ttext=$(CONFIG_TEXT_BASE))
 u-boot.elf: u-boot.bin u-boot-elf.lds
 	$(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o
 	$(call if_changed,u-boot-elf)

This is for u-boot-elf and I think not defining CONFIG_PLATFORM_ELFENTRY to CONFIG_TEXT_BASE will be a functional error.

Signature · 1 line
Tom
#11 lore raw

PATCH 3/32 video: Move vesa_setup_video_priv() into its own file

In reply to Simon Glass

This helper is used by the EFI driver and we would like to use that on ARM. Move the helper function into its own file, separate from PCI ROMs, which are an x86 thing.

Add a forward declaration for struct udevice so that the header can be included directly.

---

 drivers/pci/pci_rom.c       | 32 -----------------------------
 drivers/video/Makefile      |  2 ++
 drivers/video/vesa_helper.c | 41 +++++++++++++++++++++++++++++++++++++
 include/vesa.h              |  2 ++
 4 files changed, 45 insertions(+), 32 deletions(-)
 create mode 100644 drivers/video/vesa_helper.c
drivers/pci/pci_rom.c +0 -32
index 2753df275ca..35654ca89ac 100644
@@ -334,38 +334,6 @@ err:
 	return ret;
 }
 
-int vesa_setup_video_priv(struct vesa_mode_info *vesa, u64 fb,
-			  struct video_priv *uc_priv,
-			  struct video_uc_plat *plat)
-{
-	if (!vesa->x_resolution)
-		return log_msg_ret("No x resolution", -ENXIO);
-	uc_priv->xsize = vesa->x_resolution;
-	uc_priv->ysize = vesa->y_resolution;
-	uc_priv->line_length = vesa->bytes_per_scanline;
-	switch (vesa->bits_per_pixel) {
-	case 32:
-	case 24:
-		uc_priv->bpix = VIDEO_BPP32;
-		break;
-	case 16:
-		uc_priv->bpix = VIDEO_BPP16;
-		break;
-	default:
-		return -EPROTONOSUPPORT;
-	}
-
-	/* Use double buffering if enabled */
-	if (IS_ENABLED(CONFIG_VIDEO_COPY) && plat->base)
-		plat->copy_base = fb;
-	else
-		plat->base = fb;
-	log_debug("base = %lx, copy_base = %lx\n", plat->base, plat->copy_base);
-	plat->size = vesa->bytes_per_scanline * vesa->y_resolution;
-
-	return 0;
-}
-
 int vesa_setup_video(struct udevice *dev, int (*int15_handler)(void))
 {
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
drivers/video/Makefile +2 -0
index 5a00438ce06..416a929d36b 100644
@@ -27,6 +27,8 @@ obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o
 obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
 obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
 
+obj-y += vesa_helper.o
+
 endif
 
 obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_backlight.o
drivers/video/vesa_helper.c new file +41 -0

41 lines not on this page · raw message

include/vesa.h +2 -0
index 9285bfa921a..abfc624e7cc 100644
@@ -10,6 +10,8 @@
 #ifndef _VESA_H
 #define _VESA_H
 
+struct udevice;
+
 /* these structs are for input from and output to OF */
 struct __packed vesa_screen_info {
 	u8 display_type;	/* 0=NONE, 1= analog, 2=digital */
Signature · 1 line
2.43.0
#12 lore raw

Re: [PATCH 03/32] video: Move vesa_setup_video_priv() into its own file

Quoted 8 lines · Simon Glass

This helper is used by the EFI driver and we would like to use that on ARM. Move the helper function into its own file, separate from PCI ROMs, which are an x86 thing.

Add a forward declaration for struct udevice so that the header can be included directly.

[snip]

drivers/video/vesa_helper.c line 5

Quoted 11 lines
drivers/video/vesa_helper.c new file +5 -0
new file mode 100644
index 00000000000..dde8797e765
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025, Simon Glass <[email protected]>
+ */
+

If we have to add copyright and not just license information here, you need to copy what's in drivers/pci/pci_rom.c where yes, you added that function in 2016, and it's based on coreboot at the time.

Signature · 1 line
Tom
#13 lore raw

PATCH 4/32 video: Use a local mode_info struct in the EFI driver

In reply to Simon Glass

There is no need to use the global struct provided by PCI. Declare a local structure instead, so this can be used on ARM without including support for PCI ROMs.

---

 drivers/video/efi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/video/efi.c +1 -0
index a7b6d47f9a1..94d4c93dac3 100644
@@ -183,6 +183,7 @@ static int efi_video_probe(struct udevice *dev)
 {
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
 	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct vesa_state mode_info;
 	struct vesa_mode_info *vesa = &mode_info.vesa;
 	u64 fb;
 	int ret;
Signature · 1 line
2.43.0
#14 lore raw

PATCH 5/32 lib: Provide fdtdec_get_pci_bar32() only with PCI enabled

In reply to Simon Glass

This function calls dm_pci_read_bar32() which is only available if PCI is enabled. Add this condition here too, so that the EFI app can build without needing --gc-sections

---

 lib/fdtdec.c | 2 ++
 1 file changed, 2 insertions(+)
lib/fdtdec.c +2 -0
index 3b4247be25a..0244e8a3a72 100644
@@ -248,6 +248,7 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)
 	return -ENOENT;
 }
 
+#ifdef CONFIG_PCI
 int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
 			 u32 *bar)
 {
@@ -264,6 +265,7 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
 
 	return 0;
 }
+#endif
 
 int fdtdec_get_pci_bus_range(const void *blob, int node,
 			     struct fdt_resource *res)
Signature · 1 line
2.43.0
Reviewed-by on v1 5/32
#15 lore raw

Re: [PATCH 05/32] lib: Provide fdtdec_get_pci_bar32() only with PCI enabled

Quoted 5 lines · Simon Glass

This function calls dm_pci_read_bar32() which is only available if PCI is enabled. Add this condition here too, so that the EFI app can build without needing --gc-sections

Signature · 1 line
Tom
Reviewed-by on v1 5/32
#16 lore raw

Re: [PATCH 05/32] lib: Provide fdtdec_get_pci_bar32() only with PCI enabled

In reply to Simon Glass
Quoted 5 lines · Simon Glass

This function calls dm_pci_read_bar32() which is only available if PCI is enabled. Add this condition here too, so that the EFI app can build without needing --gc-sections

Quoted 25 lines

---

  lib/fdtdec.c | 2 ++
  1 file changed, 2 insertions(+)
lib/fdtdec.c +2 -0
index 3b4247be25a..0244e8a3a72 100644
@@ -248,6 +248,7 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)
  	return -ENOENT;
  }
 
+#ifdef CONFIG_PCI
  int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
  			 u32 *bar)
  {
@@ -264,6 +265,7 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
 
  	return 0;
  }
+#endif
 
  int fdtdec_get_pci_bus_range(const void *blob, int node,
  			     struct fdt_resource *res)
#17 lore raw

PATCH 6/32 scripts: Update build-efi to support building U-Boot

In reply to Simon Glass

Build U-Boot by default, so we can select the correct board and make the process of trying different boards less error-prone.

---

 scripts/build-efi.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/build-efi.py +14 -0
index 495817bc064..3a1bf180ade 100755
@@ -48,6 +48,8 @@ def parse_args():
         epilog='Script for running U-Boot as an EFI app/payload')
     parser.add_argument('-a', '--app', action='store_true',
                         help='Package up the app')
+    parser.add_argument('-B', '--no-build', action='store_true',
+                        help="Don't build (an existing build must be present")
     parser.add_argument('-k', '--kernel', action='store_true',
                         help='Add a kernel')
     parser.add_argument('-o', '--old', action='store_true',
@@ -229,6 +231,15 @@ class BuildEfi:
                 time.sleep(0.5)
                 command.output(*cmd)
 
+    def do_build(self, build):
+        """Build U-Boot for the selected board"""
+        res = command.run_one('buildman', '-w', '-o',
+                              f'{self.build_dir}/{build}', '--board', build,
+                              '-I', raise_on_error=False)
+        if res.return_code and res.return_code != 101:  # Allow warnings
+            raise ValueError(
+                f'buildman exited with {res.return_code}: {res.combined}')
+
     def start(self):
         """This does all the work"""
         args = self.args
@@ -237,6 +248,9 @@ class BuildEfi:
         self.tmp = f'{self.build_dir}/efi{bitness}{build_type}'
         build = f'efi-x86_{build_type}{bitness}'
 
+        if not args.no_build:
+            self.do_build(build)
+
         if args.old and bitness == 32:
             build = f'efi-x86_{build_type}'
 
Signature · 1 line
2.43.0
#18 lore raw

PATCH 7/32 scripts: Update build-efi to support arm64

In reply to Simon Glass

Provide a -A flag to select ARM instead of x86. For now, only the app is supported and only for 64-bit ARM.

---

 scripts/build-efi.py | 49 +++++++++++++++++++++++++++++++-------------
 1 file changed, 35 insertions(+), 14 deletions(-)
scripts/build-efi.py +35 -14
index 3a1bf180ade..1ba37e86e88 100755
@@ -48,6 +48,8 @@ def parse_args():
         epilog='Script for running U-Boot as an EFI app/payload')
     parser.add_argument('-a', '--app', action='store_true',
                         help='Package up the app')
+    parser.add_argument('-A', '--arm', action='store_true',
+                        help='Run on ARM architecture')
     parser.add_argument('-B', '--no-build', action='store_true',
                         help="Don't build (an existing build must be present")
     parser.add_argument('-k', '--kernel', action='store_true',
@@ -131,26 +133,43 @@ class BuildEfi:
         """
         extra = []
         efi_dir = self.get_setting("efi_dir")
-        if bitness == 64:
-            qemu = 'qemu-system-x86_64'
-            bios = 'OVMF-pure-efi.x64.fd'
-        else:
-            qemu = 'qemu-system-i386'
-            bios = 'OVMF-pure-efi.i386.fd'
+        if self.args.arm:
+            qemu_arch = 'aarch64'
+            extra += ['--machine', 'virt', '-cpu', 'max']
+            bios = os.path.join(efi_dir, 'OVMF-pure-efi.aarch64.fd.64m')
+            var_store = os.path.join(efi_dir, 'varstore.img')
+            extra += [
+                '-drive', f'if=pflash,format=raw,file={bios},readonly=on',
+                '-drive', f'if=pflash,format=raw,file={var_store}'
+                ]
+            extra += ['-drive',
+                      f'id=hd0,file={self.img},if=none,format=raw',
+                      '-device', 'virtio-blk-device,drive=hd0']
+        else:  # x86
+            if bitness == 64:
+                qemu_arch = 'x86_64'
+                bios = 'OVMF-pure-efi.x64.fd'
+            else:
+                qemu_arch = 'i386'
+                bios = 'OVMF-pure-efi.i386.fd'
+            extra += ['-bios', os.path.join(efi_dir, bios)]
+            extra += ['-drive', f'id=disk,file={self.img},if=none,format=raw']
+            extra += ['-device', 'ahci,id=ahci']
+            extra += ['-device', 'ide-hd,drive=disk,bus=ahci.0']
+        qemu = f'qemu-system-{qemu_arch}'
         if serial_only:
-            extra = ['-display', 'none', '-serial', 'mon:stdio']
+            extra += ['-display', 'none', '-serial', 'mon:stdio']
             serial_msg = ' (Ctrl-a x to quit)'
         else:
-            extra = ['-serial', 'mon:stdio']
+            if self.args.arm:
+                extra += ['-device', 'virtio-gpu-pci']
+            extra += ['-serial', 'mon:stdio']
             serial_msg = ''
         print(f'Running {qemu}{serial_msg}')
 
         # Use 512MB since U-Boot EFI likes to have 256MB to play with
-        cmd = [qemu, '-bios', os.path.join(efi_dir), bios)]
+        cmd = [qemu]
         cmd += '-m', '512'
-        cmd += '-drive', f'id=disk,file={self.img},if=none,format=raw'
-        cmd += '-device', 'ahci,id=ahci'
-        cmd += '-device', 'ide-hd,drive=disk,bus=ahci.0'
         cmd += '-nic', 'none'
         cmd += extra
         command.run(*cmd)
@@ -229,6 +248,7 @@ class BuildEfi:
                 command.output(*cmd)
             except command.CommandExc:
                 time.sleep(0.5)
+                cmd = 'sudo', 'kpartx', '-d', self.img
                 command.output(*cmd)
 
     def do_build(self, build):
@@ -244,15 +264,16 @@ class BuildEfi:
         """This does all the work"""
         args = self.args
         bitness = 32 if args.word else 64
+        arch = 'arm' if args.arm else 'x86'
         build_type = 'payload' if args.payload else 'app'
         self.tmp = f'{self.build_dir}/efi{bitness}{build_type}'
-        build = f'efi-x86_{build_type}{bitness}'
+        build = f'efi-{arch}_{build_type}{bitness}'
 
         if not args.no_build:
             self.do_build(build)
 
         if args.old and bitness == 32:
-            build = f'efi-x86_{build_type}'
+            build = f'efi-{arch}_{build_type}'
 
         self.setup_files(build, build_type)
 
Signature · 1 line
2.43.0
#19 lore raw

Re: [PATCH 07/32] scripts: Update build-efi to support arm64

Am 3. Februar 2025 18:42:00 MEZ schrieb Simon Glass <[email protected]>:

Quoted 14 lines

Provide a -A flag to select ARM instead of x86. For now, only the app is supported and only for 64-bit ARM.

---

scripts/build-efi.py | 49 +++++++++++++++++++++++++++++++-------------

1 file changed, 35 insertions(+), 14 deletions(-)
scripts/build-efi.py +0 -0
index 3a1bf180ade..1ba37e86e88 100755

scripts/build-efi.py def parse_args(): · line 51

Quoted 4 lines
scripts/build-efi.py +1 -0
@@ -48,6 +48,8 @@ def parse_args():
        epilog='Script for running U-Boot as an EFI app/payload')
    parser.add_argument('-a', '--app', action='store_true',
                        help='Package up the app')
+    parser.add_argument('-A', '--arm', action='store_true',

Why have a flag per EFI architecture?

Please add a parameterized flag instead.

--arch i386
--arch x64
--arch arm
--arch aarch64
--arch riscv64

and get rid of the bitness parameter.

Quoted 20 lines
scripts/build-efi.py +7 -6
+                        help='Run on ARM architecture')
    parser.add_argument('-B', '--no-build', action='store_true',
                        help="Don't build (an existing build must be present")
    parser.add_argument('-k', '--kernel', action='store_true',
@@ -131,26 +133,43 @@ class BuildEfi:
        """
        extra = []
        efi_dir = self.get_setting("efi_dir")
-        if bitness == 64:
-            qemu = 'qemu-system-x86_64'
-            bios = 'OVMF-pure-efi.x64.fd'
-        else:
-            qemu = 'qemu-system-i386'
-            bios = 'OVMF-pure-efi.i386.fd'
+        if self.args.arm:
+            qemu_arch = 'aarch64'
+            extra += ['--machine', 'virt', '-cpu', 'max']
+            bios = os.path.join(efi_dir, 'OVMF-pure-efi.aarch64.fd.64m')
+            var_store = os.path.join(efi_dir, 'varstore.img')
+            extra += [

scripts/build-efi.py class BuildEfi: · line 151

Quoted 10 lines
scripts/build-efi.py +10 -0
+                '-drive', f'if=pflash,format=raw,file={bios},readonly=on',
+                '-drive', f'if=pflash,format=raw,file={var_store}'
+                ]
+            extra += ['-drive',
+                      f'id=hd0,file={self.img},if=none,format=raw',
+                      '-device', 'virtio-blk-device,drive=hd0']
+        else:  # x86
+            if bitness == 64:
+                qemu_arch = 'x86_64'
+                bios = 'OVMF-pure-efi.x64.fd'

Not a filename used by EDK II or by QEMU.

Best regards

Heinrich

Quoted 57 lines
scripts/build-efi.py +17 -8
+            else:
+                qemu_arch = 'i386'
+                bios = 'OVMF-pure-efi.i386.fd'
+            extra += ['-bios', os.path.join(efi_dir, bios)]
+            extra += ['-drive', f'id=disk,file={self.img},if=none,format=raw']
+            extra += ['-device', 'ahci,id=ahci']
+            extra += ['-device', 'ide-hd,drive=disk,bus=ahci.0']
+        qemu = f'qemu-system-{qemu_arch}'
        if serial_only:
-            extra = ['-display', 'none', '-serial', 'mon:stdio']
+            extra += ['-display', 'none', '-serial', 'mon:stdio']
            serial_msg = ' (Ctrl-a x to quit)'
        else:
-            extra = ['-serial', 'mon:stdio']
+            if self.args.arm:
+                extra += ['-device', 'virtio-gpu-pci']
+            extra += ['-serial', 'mon:stdio']
            serial_msg = ''
        print(f'Running {qemu}{serial_msg}')
 
        # Use 512MB since U-Boot EFI likes to have 256MB to play with
-        cmd = [qemu, '-bios', os.path.join(efi_dir), bios)]
+        cmd = [qemu]
        cmd += '-m', '512'
-        cmd += '-drive', f'id=disk,file={self.img},if=none,format=raw'
-        cmd += '-device', 'ahci,id=ahci'
-        cmd += '-device', 'ide-hd,drive=disk,bus=ahci.0'
        cmd += '-nic', 'none'
        cmd += extra
        command.run(*cmd)
@@ -229,6 +248,7 @@ class BuildEfi:
                command.output(*cmd)
            except command.CommandExc:
                time.sleep(0.5)
+                cmd = 'sudo', 'kpartx', '-d', self.img
                command.output(*cmd)
 
    def do_build(self, build):
@@ -244,15 +264,16 @@ class BuildEfi:
        """This does all the work"""
        args = self.args
        bitness = 32 if args.word else 64
+        arch = 'arm' if args.arm else 'x86'
        build_type = 'payload' if args.payload else 'app'
        self.tmp = f'{self.build_dir}/efi{bitness}{build_type}'
-        build = f'efi-x86_{build_type}{bitness}'
+        build = f'efi-{arch}_{build_type}{bitness}'
 
        if not args.no_build:
            self.do_build(build)
 
        if args.old and bitness == 32:
-            build = f'efi-x86_{build_type}'
+            build = f'efi-{arch}_{build_type}'
 
        self.setup_files(build, build_type)
 
#20 lore raw

Re: [PATCH 07/32] scripts: Update build-efi to support arm64

Hi Heinrich,

Quoted 25 lines · Heinrich Schuchardt

Am 3. Februar 2025 18:42:00 MEZ schrieb Simon Glass <[email protected]>:

Quoted 14 lines

Provide a -A flag to select ARM instead of x86. For now, only the app is supported and only for 64-bit ARM.

---

scripts/build-efi.py | 49 +++++++++++++++++++++++++++++++-------------

1 file changed, 35 insertions(+), 14 deletions(-)
scripts/build-efi.py +0 -0
index 3a1bf180ade..1ba37e86e88 100755

scripts/build-efi.py def parse_args(): · line 51

Quoted 4 lines
scripts/build-efi.py +1 -0
@@ -48,6 +48,8 @@ def parse_args():
        epilog='Script for running U-Boot as an EFI app/payload')
    parser.add_argument('-a', '--app', action='store_true',
                        help='Package up the app')
+    parser.add_argument('-A', '--arm', action='store_true',

Why have a flag per EFI architecture?

Please add a parameterized flag instead.

Quoted 7 lines

--arch i386
--arch x64
--arch arm
--arch aarch64
--arch riscv64

and get rid of the bitness parameter.

Tom has rejected this for the tree. I'll apply it to my tree and then deal with this comments with another patch. But I'm thinking a contrib/ directory would be better.

Quoted 25 lines
Quoted 25 lines
scripts/build-efi.py +11 -6
+                        help='Run on ARM architecture')
    parser.add_argument('-B', '--no-build', action='store_true',
                        help="Don't build (an existing build must be present")
    parser.add_argument('-k', '--kernel', action='store_true',
@@ -131,26 +133,43 @@ class BuildEfi:
        """
        extra = []
        efi_dir = self.get_setting("efi_dir")
-        if bitness == 64:
-            qemu = 'qemu-system-x86_64'
-            bios = 'OVMF-pure-efi.x64.fd'
-        else:
-            qemu = 'qemu-system-i386'
-            bios = 'OVMF-pure-efi.i386.fd'
+        if self.args.arm:
+            qemu_arch = 'aarch64'
+            extra += ['--machine', 'virt', '-cpu', 'max']
+            bios = os.path.join(efi_dir, 'OVMF-pure-efi.aarch64.fd.64m')
+            var_store = os.path.join(efi_dir, 'varstore.img')
+            extra += [
+                '-drive', f'if=pflash,format=raw,file={bios},readonly=on',
+                '-drive', f'if=pflash,format=raw,file={var_store}'
+                ]
+            extra += ['-drive',
Quoted 8 lines

scripts/build-efi.py class BuildEfi: · line 151

Quoted 6 lines
scripts/build-efi.py +6 -0
+                      f'id=hd0,file={self.img},if=none,format=raw',
+                      '-device', 'virtio-blk-device,drive=hd0']
+        else:  # x86
+            if bitness == 64:
+                qemu_arch = 'x86_64'
+                bios = 'OVMF-pure-efi.x64.fd'

Not a filename used by EDK II or by QEMU.

How best to handle this? The edk2.git-ovmf-x64 package has

/usr/share/edk2.git/ovmf-x64/OVMF-pure-efi.fd

but I cannot find similar packages for arm64. For ARM, the file has to be extended to the correct size.

[..]

Regards,
Simon

#21 lore raw

Re: [PATCH 07/32] scripts: Update build-efi to support arm64

Quoted 34 lines · Simon Glass

Hi Heinrich,

Quoted 31 lines · Heinrich Schuchardt

Am 3. Februar 2025 18:42:00 MEZ schrieb Simon Glass <[email protected]>:

Quoted 14 lines

Provide a -A flag to select ARM instead of x86. For now, only the app is supported and only for 64-bit ARM.

---

scripts/build-efi.py | 49 +++++++++++++++++++++++++++++++-------------

1 file changed, 35 insertions(+), 14 deletions(-)
scripts/build-efi.py +0 -0
index 3a1bf180ade..1ba37e86e88 100755

scripts/build-efi.py def parse_args(): · line 51

Quoted 4 lines
scripts/build-efi.py +1 -0
@@ -48,6 +48,8 @@ def parse_args():
        epilog='Script for running U-Boot as an EFI app/payload')
    parser.add_argument('-a', '--app', action='store_true',
                        help='Package up the app')
+    parser.add_argument('-A', '--arm', action='store_true',

Why have a flag per EFI architecture?

Please add a parameterized flag instead.

--arch i386
--arch x64
--arch arm
--arch aarch64
--arch riscv64

Quoted 5 lines
Quoted 1 line

and get rid of the bitness parameter.

Tom has rejected this for the tree. I'll apply it to my tree and then deal with this comments with another patch. But I'm thinking a contrib/ directory would be better.

Please stop posting things that are only ever for your downstream fork.

Signature · 1 line
Tom
#22 lore raw

Re: [PATCH 07/32] scripts: Update build-efi to support arm64

In reply to Simon Glass

Hi Heinrich,

Quoted 35 lines · Simon Glass

Hi Heinrich,

Quoted 31 lines · Heinrich Schuchardt

Am 3. Februar 2025 18:42:00 MEZ schrieb Simon Glass <[email protected]>:

Quoted 14 lines

Provide a -A flag to select ARM instead of x86. For now, only the app is supported and only for 64-bit ARM.

---

scripts/build-efi.py | 49 +++++++++++++++++++++++++++++++-------------

1 file changed, 35 insertions(+), 14 deletions(-)
scripts/build-efi.py +0 -0
index 3a1bf180ade..1ba37e86e88 100755

scripts/build-efi.py def parse_args(): · line 51

Quoted 4 lines
scripts/build-efi.py +1 -0
@@ -48,6 +48,8 @@ def parse_args():
        epilog='Script for running U-Boot as an EFI app/payload')
    parser.add_argument('-a', '--app', action='store_true',
                        help='Package up the app')
+    parser.add_argument('-A', '--arm', action='store_true',

Why have a flag per EFI architecture?

Please add a parameterized flag instead.

--arch i386
--arch x64
--arch arm
--arch aarch64
--arch riscv64

Quoted 5 lines
Quoted 1 line

and get rid of the bitness parameter.

Tom has rejected this for the tree. I'll apply it to my tree and then deal with this comments with another patch. But I'm thinking a contrib/ directory would be better.

I've updated this here:

https://source.denx.de/u-boot/u-boot-extras/-/tree/master/contrib/sjg?ref_type=heads

Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
scripts/build-efi.py +11 -6
+                        help='Run on ARM architecture')
    parser.add_argument('-B', '--no-build', action='store_true',
                        help="Don't build (an existing build must be present")
    parser.add_argument('-k', '--kernel', action='store_true',
@@ -131,26 +133,43 @@ class BuildEfi:
        """
        extra = []
        efi_dir = self.get_setting("efi_dir")
-        if bitness == 64:
-            qemu = 'qemu-system-x86_64'
-            bios = 'OVMF-pure-efi.x64.fd'
-        else:
-            qemu = 'qemu-system-i386'
-            bios = 'OVMF-pure-efi.i386.fd'
+        if self.args.arm:
+            qemu_arch = 'aarch64'
+            extra += ['--machine', 'virt', '-cpu', 'max']
+            bios = os.path.join(efi_dir, 'OVMF-pure-efi.aarch64.fd.64m')
+            var_store = os.path.join(efi_dir, 'varstore.img')
+            extra += [
+                '-drive', f'if=pflash,format=raw,file={bios},readonly=on',
+                '-drive', f'if=pflash,format=raw,file={var_store}'
+                ]
+            extra += ['-drive',
Quoted 8 lines

scripts/build-efi.py class BuildEfi: · line 151

Quoted 6 lines
scripts/build-efi.py +6 -0
+                      f'id=hd0,file={self.img},if=none,format=raw',
+                      '-device', 'virtio-blk-device,drive=hd0']
+        else:  # x86
+            if bitness == 64:
+                qemu_arch = 'x86_64'
+                bios = 'OVMF-pure-efi.x64.fd'

Not a filename used by EDK II or by QEMU.

Quoted 6 lines

How best to handle this? The edk2.git-ovmf-x64 package has

/usr/share/edk2.git/ovmf-x64/OVMF-pure-efi.fd

but I cannot find similar packages for arm64. For ARM, the file has to be extended to the correct size.

I'm still wondering about this.

Regards,
SImon

Quoted 5 lines

[..]

Regards,
Simon

#23 lore raw

PATCH 8/32 efi: Rename app and payload to include x86

In reply to Simon Glass

Since we plan to support the EFI app and payload on ARM too, rename the x86 target.

Adjust the Kconfig rules to allow non-x86 builds to be added.

---

 board/efi/Kconfig                   | 12 ++++++++----
 board/efi/efi-x86_payload/Kconfig   |  2 +-
 configs/efi-x86_app32_defconfig     |  2 +-
 configs/efi-x86_app64_defconfig     |  2 +-
 configs/efi-x86_payload32_defconfig |  2 +-
 configs/efi-x86_payload64_defconfig |  2 +-
 6 files changed, 13 insertions(+), 9 deletions(-)
board/efi/Kconfig +8 -4
index 3df6e31c8ba..9027ca8482c 100644
@@ -4,7 +4,7 @@ choice
 	prompt "Mainboard model"
 	optional
 
-config TARGET_EFI_APP32
+config TARGET_EFI_X86_APP32
 	bool "32-bit efi application"
 	select EFI_APP
 	help
@@ -13,17 +13,17 @@ config TARGET_EFI_APP32
 	  takes over once the RAM, video and CPU are fully running.
 	  U-Boot is loaded as an application from EFI.
 
-config TARGET_EFI_APP64
+config TARGET_EFI_X86_APP64
 	bool "64-bit efi application"
 	select EFI_APP
-	select X86_64
+	select X86_64 if X86
 	help
 	  This target is used for running U-Boot on top of EFI in 64-bit mode.
 	  In this case EFI does the early initialisation, and U-Boot
 	  takes over once the RAM, video and CPU are fully running.
 	  U-Boot is loaded as an application from EFI.
 
-config TARGET_EFI_PAYLOAD
+config TARGET_EFI_X86_PAYLOAD
 	bool "efi payload"
 	help
 	  This target is used for running U-Boot on top of EFI. In
@@ -33,7 +33,11 @@ config TARGET_EFI_PAYLOAD
 
 endchoice
 
+if X86
+
 source "board/efi/efi-x86_app/Kconfig"
 source "board/efi/efi-x86_payload/Kconfig"
 
 endif
+
+endif
board/efi/efi-x86_payload/Kconfig +1 -1
index c500ca02ebf..d181bf6de09 100644
@@ -1,4 +1,4 @@
-if TARGET_EFI_PAYLOAD
+if TARGET_EFI_X86_PAYLOAD
 
 config SYS_BOARD
 	default "efi-x86_payload"
configs/efi-x86_app32_defconfig +1 -1
index b20c85f1cff..bfcef9afa88 100644
@@ -5,7 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app"
 CONFIG_DEBUG_UART_BASE=0x0
 CONFIG_DEBUG_UART_CLOCK=0
 CONFIG_VENDOR_EFI=y
-CONFIG_TARGET_EFI_APP32=y
+CONFIG_TARGET_EFI_X86_APP32=y
 CONFIG_DEBUG_UART=y
 CONFIG_EFI=y
 CONFIG_FIT=y
configs/efi-x86_app64_defconfig +1 -1
index 0988ad45205..8f1319c0b4c 100644
@@ -6,7 +6,7 @@ CONFIG_DEBUG_UART_BASE=0x0
 CONFIG_DEBUG_UART_CLOCK=0
 CONFIG_X86_RUN_64BIT=y
 CONFIG_VENDOR_EFI=y
-CONFIG_TARGET_EFI_APP64=y
+CONFIG_TARGET_EFI_X86_APP64=y
 CONFIG_DEBUG_UART=y
 CONFIG_EFI=y
 CONFIG_EFI_APP_64BIT=y
configs/efi-x86_payload32_defconfig +1 -1
index 957fd83e432..48e757f629d 100644
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload"
 CONFIG_PRE_CON_BUF_ADDR=0x100000
 CONFIG_VENDOR_EFI=y
-CONFIG_TARGET_EFI_PAYLOAD=y
+CONFIG_TARGET_EFI_X86_PAYLOAD=y
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
 CONFIG_FIT=y
configs/efi-x86_payload64_defconfig +1 -1
index 71612d7fb19..2606ac261c1 100644
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload"
 CONFIG_PRE_CON_BUF_ADDR=0x100000
 CONFIG_VENDOR_EFI=y
-CONFIG_TARGET_EFI_PAYLOAD=y
+CONFIG_TARGET_EFI_X86_PAYLOAD=y
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
 CONFIG_EFI_STUB_64BIT=y
Signature · 1 line
2.43.0
Reviewed-by on v1 8/32
#24 lore raw

Re: [PATCH 08/32] efi: Rename app and payload to include x86

Quoted 6 lines · Simon Glass

Since we plan to support the EFI app and payload on ARM too, rename the x86 target.

Adjust the Kconfig rules to allow non-x86 builds to be added.

Signature · 1 line
Tom
#25 lore raw

PATCH 9/32 efi: Allow board/efi Kconfig to be used outside x86

In reply to Simon Glass

So far only x86 supports the EFI app. Sadly ARM is going the same way, so allow these options to be enabled for ARM too.

---

 arch/Kconfig      | 2 ++
 arch/x86/Kconfig  | 1 -
 board/efi/Kconfig | 4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)
arch/Kconfig +2 -0
index 6258788f53f..493c827d74d 100644
@@ -544,6 +544,8 @@ source "arch/Kconfig.nxp"
 
 endif
 
+source "board/efi/Kconfig"
+
 source "board/keymile/Kconfig"
 
 choice
arch/x86/Kconfig +0 -1
index 23a1e21b29e..80396a3a2d5 100644
@@ -100,7 +100,6 @@ source "board/advantech/Kconfig"
 source "board/congatec/Kconfig"
 source "board/coreboot/Kconfig"
 source "board/dfi/Kconfig"
-source "board/efi/Kconfig"
 source "board/emulation/Kconfig"
 source "board/google/Kconfig"
 source "board/intel/Kconfig"
board/efi/Kconfig +2 -2
index 9027ca8482c..7545f808585 100644
@@ -1,5 +1,7 @@
 if VENDOR_EFI
 
+if X86
+
 choice
 	prompt "Mainboard model"
 	optional
@@ -33,8 +35,6 @@ config TARGET_EFI_X86_PAYLOAD
 
 endchoice
 
-if X86
-
 source "board/efi/efi-x86_app/Kconfig"
 source "board/efi/efi-x86_payload/Kconfig"
 
Signature · 1 line
2.43.0
Reviewed-by on v1 9/32
#26 lore raw

Re: [PATCH 09/32] efi: Allow board/efi Kconfig to be used outside x86

Quoted 2 lines · Simon Glass

So far only x86 supports the EFI app. Sadly ARM is going the same way, so allow these options to be enabled for ARM too.

Please omit "Sadly", that's tone wording we don't need here.

Quoted 1 line
Signature · 1 line
Tom
#27 lore raw

PATCH 10/32 efi: x86: Move EFI SDRAM-handling into a common file

In reply to Simon Glass

This code is not actually x86-specific, so move it into the lib/efi dir where other archs can use it.

Drop inclusion of the unnecessary x86-specific header.

---

 arch/x86/cpu/efi/Makefile         | 1 -
 lib/efi/Makefile                  | 1 +
 {arch/x86/cpu => lib}/efi/sdram.c | 1 -
 3 files changed, 1 insertion(+), 2 deletions(-)
 rename {arch/x86/cpu => lib}/efi/sdram.c (94%)
arch/x86/cpu/efi/Makefile +0 -1
index 9716a4ebe08..9be1d5e5401 100644
@@ -4,7 +4,6 @@
 
 ifdef CONFIG_EFI_APP
 obj-y += app.o
-obj-y += sdram.o
 endif
 
 ifdef CONFIG_EFI_STUB
lib/efi/Makefile +1 -0
index 315625c0e8c..5081d71a19f 100644
@@ -3,6 +3,7 @@
 # (C) Copyright 2015 Google, Inc
 
 obj-$(CONFIG_EFI_APP) += efi_app.o efi.o efi_app_init.o efi_vars.o efi_dtb.o
+obj-$(CONFIG_EFI_APP) += sdram.o
 obj-$(CONFIG_EFI_STUB) += efi_info.o
 
 ifeq ($(CONFIG_ARM64),y)
lib/efi/sdram.c renamed from arch/x86/cpu/efi/sdram.c +0 -1
similarity index 94%
rename from arch/x86/cpu/efi/sdram.c
rename to lib/efi/sdram.c
index 6fe40071140..bd59dfade0f 100644
@@ -6,7 +6,6 @@
 #include <efi.h>
 #include <init.h>
 #include <asm/global_data.h>
-#include <asm/u-boot-x86.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 10/32
#28 lore raw

Re: [PATCH 10/32] efi: x86: Move EFI SDRAM-handling into a common file

Quoted 6 lines · Simon Glass

This code is not actually x86-specific, so move it into the lib/efi dir where other archs can use it.

Drop inclusion of the unnecessary x86-specific header.

Signature · 1 line
Tom
#29 lore raw

PATCH 11/32 efi: x86: Rework VENDOR_EFI option to permit other archs

In reply to Simon Glass

At present only x86 supports the EFI app and (apart from Qualcomm) the payload. In preparation for supporting ARM more generally, rename the existing VENDOR_EFI option to VENDOR_EFI_X86, using that to define a generic VENDOR_EFI which will be enabled for all architectures.

---

 arch/arm/Kconfig                    | 4 ++++
 arch/x86/Kconfig                    | 3 ++-
 board/efi/Kconfig                   | 9 +++++++--
 configs/efi-x86_app32_defconfig     | 2 +-
 configs/efi-x86_app64_defconfig     | 2 +-
 configs/efi-x86_payload32_defconfig | 2 +-
 configs/efi-x86_payload64_defconfig | 2 +-
 7 files changed, 17 insertions(+), 7 deletions(-)
arch/arm/Kconfig +4 -0
index 01cb27aa1d7..b032aac4caa 100644
@@ -2157,6 +2157,10 @@ config ARCH_GXP
 	select OF_CONTROL
 	imply CMD_DM
 
+config VENDOR_EFI_ARM
+	bool "efi"
+	select VENDOR_EFI
+
 endchoice
 
 config SUPPORT_PASSING_ATAGS
arch/x86/Kconfig +2 -1
index 80396a3a2d5..69e624ae26c 100644
@@ -65,8 +65,9 @@ config VENDOR_COREBOOT
 config VENDOR_DFI
 	bool "dfi"
 
-config VENDOR_EFI
+config VENDOR_EFI_X86
 	bool "efi"
+	select VENDOR_EFI
 
 config VENDOR_EMULATION
 	bool "emulation"
board/efi/Kconfig +7 -2
index 7545f808585..33bc364861a 100644
@@ -1,3 +1,8 @@
+config VENDOR_EFI
+	bool
+	select OF_CONTROL
+	select DM_SERIAL
+
 if VENDOR_EFI
 
 if X86
@@ -38,6 +43,6 @@ endchoice
 source "board/efi/efi-x86_app/Kconfig"
 source "board/efi/efi-x86_payload/Kconfig"
 
-endif
+endif  # X86
 
-endif
+endif  # VENDOR_EFI
configs/efi-x86_app32_defconfig +1 -1
index bfcef9afa88..633b1b6c532 100644
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app"
 CONFIG_DEBUG_UART_BASE=0x0
 CONFIG_DEBUG_UART_CLOCK=0
-CONFIG_VENDOR_EFI=y
+CONFIG_VENDOR_EFI_X86=y
 CONFIG_TARGET_EFI_X86_APP32=y
 CONFIG_DEBUG_UART=y
 CONFIG_EFI=y
configs/efi-x86_app64_defconfig +1 -1
index 8f1319c0b4c..b3d1df42777 100644
@@ -5,7 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app"
 CONFIG_DEBUG_UART_BASE=0x0
 CONFIG_DEBUG_UART_CLOCK=0
 CONFIG_X86_RUN_64BIT=y
-CONFIG_VENDOR_EFI=y
+CONFIG_VENDOR_EFI_X86=y
 CONFIG_TARGET_EFI_X86_APP64=y
 CONFIG_DEBUG_UART=y
 CONFIG_EFI=y
configs/efi-x86_payload32_defconfig +1 -1
index 48e757f629d..00f27109860 100644
@@ -3,7 +3,7 @@ CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload"
 CONFIG_PRE_CON_BUF_ADDR=0x100000
-CONFIG_VENDOR_EFI=y
+CONFIG_VENDOR_EFI_X86=y
 CONFIG_TARGET_EFI_X86_PAYLOAD=y
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
configs/efi-x86_payload64_defconfig +1 -1
index 2606ac261c1..a22d180a591 100644
@@ -3,7 +3,7 @@ CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload"
 CONFIG_PRE_CON_BUF_ADDR=0x100000
-CONFIG_VENDOR_EFI=y
+CONFIG_VENDOR_EFI_X86=y
 CONFIG_TARGET_EFI_X86_PAYLOAD=y
 CONFIG_EFI=y
 CONFIG_EFI_STUB=y
Signature · 1 line
2.43.0
#30 lore raw

Re: [PATCH 11/32] efi: x86: Rework VENDOR_EFI option to permit other archs

Quoted 6 lines · Simon Glass

At present only x86 supports the EFI app and (apart from Qualcomm) the payload. In preparation for supporting ARM more generally, rename the existing VENDOR_EFI option to VENDOR_EFI_X86, using that to define a generic VENDOR_EFI which will be enabled for all architectures.

This looks like things that should just live under BOARD_SPECIFIC_OPTIONS in board/efi/Kconfig instead.

Signature · 1 line
Tom
#31 lore raw

Re: [PATCH 11/32] efi: x86: Rework VENDOR_EFI option to permit other archs

Hi Tom,

Quoted 8 lines · Tom Rini
Quoted 5 lines · Simon Glass

At present only x86 supports the EFI app and (apart from Qualcomm) the payload. In preparation for supporting ARM more generally, rename the existing VENDOR_EFI option to VENDOR_EFI_X86, using that to define a generic VENDOR_EFI which will be enabled for all architectures.

Quoted 4 lines
Quoted 1 line

This looks like things that should just live under BOARD_SPECIFIC_OPTIONS in board/efi/Kconfig instead.

I don't really understand what you are getting at there.

That directory is for boards, but it seems that EFI is going to grow from just being a set of boards, e.g. with board/qualcomm also having an EFI-payload build.

Regards,
SImon

#32 lore raw

Re: [PATCH 11/32] efi: x86: Rework VENDOR_EFI option to permit other archs

Quoted 13 lines · Simon Glass

Hi Tom,

Quoted 10 lines · Tom Rini
Quoted 6 lines · Simon Glass

At present only x86 supports the EFI app and (apart from Qualcomm) the payload. In preparation for supporting ARM more generally, rename the existing VENDOR_EFI option to VENDOR_EFI_X86, using that to define a generic VENDOR_EFI which will be enabled for all architectures.

Quoted 8 lines
Quoted 2 lines

This looks like things that should just live under BOARD_SPECIFIC_OPTIONS in board/efi/Kconfig instead.

I don't really understand what you are getting at there.

That directory is for boards, but it seems that EFI is going to grow from just being a set of boards, e.g. with board/qualcomm also having an EFI-payload build.

We shouldn't need VENDOR_EFI_FOO, we should likely (a) drop VENDOR_ as that's an x86'ism and then place more things as needed under lib/efi/Kconfig. Especially if we're going to have (really?) end up with per-SoC efi app builds for arm64, rather than something generic.

Signature · 1 line
Tom
#33 lore raw

PATCH 12/32 efi: x86: Allow setting the global_data pointer with EFI

In reply to Simon Glass

Provide a function which sets this pointer, for use in the EFI app.

---

 arch/x86/include/asm/global_data.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/include/asm/global_data.h +7 -0
index 06bd80ccc13..1bd1fa92078 100644
@@ -142,6 +142,13 @@ struct arch_global_data {
 /* TODO([email protected]): Consider using a fixed register for gd on x86_64 */
 #define gd global_data_ptr
 
+static inline void set_gd(volatile gd_t *gd_ptr)
+{
+	extern struct global_data *global_data_ptr;
+
+	global_data_ptr = (void *)gd_ptr;
+}
+
 #define DECLARE_GLOBAL_DATA_PTR   extern struct global_data *global_data_ptr
 # else
 static inline notrace gd_t *get_fs_gd_ptr(void)
Signature · 1 line
2.43.0
#34 lore raw

PATCH 13/32 efi: Tidy up setup of global_data

In reply to Simon Glass

Use the available functions for setting and getting the global_data pointer so that EFI-startup can operate on ARM as well as x86.

---

 lib/efi/efi_app.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
lib/efi/efi_app.c +8 -5
index ff8b62a1e1a..1aa43b511b3 100644
@@ -77,6 +77,7 @@ int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
 static efi_status_t setup_memory(struct efi_priv *priv)
 {
 	struct efi_boot_services *boot = priv->boot;
+	struct global_data *ptr;
 	efi_physical_addr_t addr;
 	efi_status_t ret;
 	int pages;
@@ -86,10 +87,12 @@ static efi_status_t setup_memory(struct efi_priv *priv)
 	 * are very few assignments to global_data in U-Boot and this makes
 	 * it easier to find them.
 	 */
-	global_data_ptr = efi_malloc(priv, sizeof(struct global_data), &ret);
-	if (!global_data_ptr)
+	ptr = efi_malloc(priv, sizeof(*ptr), &ret);
+	if (!ptr)
 		return ret;
-	memset(gd, '\0', sizeof(*gd));
+	memset(ptr, '\0', sizeof(*ptr));
+
+	set_gd(ptr);
 
 	gd->malloc_base = (ulong)efi_malloc(priv, CONFIG_VAL(SYS_MALLOC_F_LEN),
 					    &ret);
@@ -138,8 +141,8 @@ static void free_memory(struct efi_priv *priv)
 		boot->free_pages(priv->ram_base, gd->ram_size >> 12);
 
 	efi_free(priv, (void *)gd->malloc_base);
-	efi_free(priv, gd);
-	global_data_ptr = NULL;
+	efi_free(priv, (void *)gd);
+	set_gd((void *)NULL);
 }
 
 static void scan_tables(struct efi_system_table *sys_table)
Signature · 1 line
2.43.0
#35 lore raw

PATCH 14/32 efi: Rename ImageBase to image_base

In reply to Simon Glass

It is confusing to have a camel-case indentifier in the link scripts. Rename it to fit with U-Boot's snake-case style.

---

 arch/arm/lib/crt0_aarch64_efi.S | 26 +++++++++++++-------------
 arch/riscv/lib/crt0_riscv_efi.S | 28 ++++++++++++++--------------
 include/asm-generic/sections.h  |  2 ++
 3 files changed, 29 insertions(+), 27 deletions(-)
arch/arm/lib/crt0_aarch64_efi.S +13 -13
index fe6eca576ec..a1888cbb1e4 100644
@@ -15,12 +15,12 @@
 	/*
 	 * Magic "MZ" signature for PE/COFF
 	 */
-	.globl	ImageBase
-ImageBase:
+	.globl	image_base
+image_base:
 	.short	IMAGE_DOS_SIGNATURE		/* 'MZ' */
 	.skip	54				/* 'MZ' + pad + offset == 64 */
 	.long   LINUX_ARM64_MAGIC		/* For GRUB's linux command */
-	.long	pe_header - ImageBase		/* Offset to the PE header */
+	.long	pe_header - image_base		/* Offset to the PE header */
 pe_header:
 	.long	IMAGE_NT_SIGNATURE		/* 'PE' */
 coff_header:
@@ -43,11 +43,11 @@ optional_header:
 	.long	_etext - _start			/* SizeOfCode */
 	.long	0				/* SizeOfInitializedData */
 	.long	0				/* SizeOfUninitializedData */
-	.long	_start - ImageBase		/* AddressOfEntryPoint */
-	.long	_start - ImageBase		/* BaseOfCode */
+	.long	_start - image_base		/* AddressOfEntryPoint */
+	.long	_start - image_base		/* BaseOfCode */
 
 extra_header_fields:
-	.quad	0				/* ImageBase */
+	.quad	0				/* image_base */
 	.long	0x1000				/* SectionAlignment */
 	.long	0x200				/* FileAlignment */
 	.short	0				/* MajorOperatingSystemVersion */
@@ -58,12 +58,12 @@ extra_header_fields:
 	.short	0				/* MinorSubsystemVersion */
 	.long	0				/* Win32VersionValue */
 
-	.long	_edata - ImageBase		/* SizeOfImage */
+	.long	_edata - image_base		/* SizeOfImage */
 
 	/*
 	 * Everything before the kernel image is considered part of the header
 	 */
-	.long	_start - ImageBase		/* SizeOfHeaders */
+	.long	_start - image_base		/* SizeOfHeaders */
 	.long	0				/* CheckSum */
 	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
 #if CONFIG_VENDOR_EFI
@@ -114,9 +114,9 @@ section_table:
 	.byte	0
 	.byte	0			/* end of 0 padding of section name */
 	.long	_etext - _start		/* VirtualSize */
-	.long	_start - ImageBase	/* VirtualAddress */
+	.long	_start - image_base	/* VirtualAddress */
 	.long	_etext - _start		/* SizeOfRawData */
-	.long	_start - ImageBase	/* PointerToRawData */
+	.long	_start - image_base	/* PointerToRawData */
 	.long	0			/* PointerToRelocations */
 	.long	0			/* PointerToLineNumbers */
 	.short	0			/* NumberOfRelocations */
@@ -131,9 +131,9 @@ section_table:
 	.byte	0
 	.byte	0			/* end of 0 padding of section name */
 	.long	_data_size		/* VirtualSize */
-	.long	_data - ImageBase	/* VirtualAddress */
+	.long	_data - image_base	/* VirtualAddress */
 	.long	_data_size		/* SizeOfRawData */
-	.long	_data - ImageBase	/* PointerToRawData */
+	.long	_data - image_base	/* PointerToRawData */
 	.long	0			/* PointerToRelocations */
 	.long	0			/* PointerToLineNumbers */
 	.short	0			/* NumberOfRelocations */
@@ -149,7 +149,7 @@ _start:
 	mov		x29, sp
 
 	stp		x0, x1, [sp, #16]
-	adr		x0, ImageBase
+	adr		x0, image_base
 	adrp		x1, _DYNAMIC
 	add		x1, x1, #:lo12:_DYNAMIC
 	bl		_relocate
arch/riscv/lib/crt0_riscv_efi.S +14 -14
index c7a4559eac8..5fb17f10fd8 100644
@@ -41,14 +41,14 @@
 	/*
 	 * Magic "MZ" signature for PE/COFF
 	 */
-	.globl	ImageBase
-ImageBase:
+	.globl	image_base
+image_base:
 	.short	IMAGE_DOS_SIGNATURE		/* 'MZ' */
 	.skip	46				/* 'MZ' + pad + offset == 64 */
 	.long	0x43534952			/* Linux magic "RISCV */
 	.long	0x00000056
 	.long	0x05435352			/* Linux magic2 "RSC\x05*/
-	.long	pe_header - ImageBase		/* Offset to the PE header */
+	.long	pe_header - image_base		/* Offset to the PE header */
 pe_header:
 	.long	IMAGE_NT_SIGNATURE		/* 'PE' */
 coff_header:
@@ -66,17 +66,17 @@ optional_header:
 	.long	_edata - _start			/* SizeOfCode */
 	.long	0				/* SizeOfInitializedData */
 	.long	0				/* SizeOfUninitializedData */
-	.long	_start - ImageBase		/* AddressOfEntryPoint */
-	.long	_start - ImageBase		/* BaseOfCode */
+	.long	_start - image_base		/* AddressOfEntryPoint */
+	.long	_start - image_base		/* BaseOfCode */
 #if __riscv_xlen == 32
 	.long	0				/* BaseOfData */
 #endif
 
 extra_header_fields:
 #if __riscv_xlen == 32
-	.long	0				/* ImageBase */
+	.long	0				/* image_base */
 #else
-	.quad	0				/* ImageBase */
+	.quad	0				/* image_base */
 #endif
 	.long	0x200				/* SectionAlignment */
 	.long	0x200				/* FileAlignment */
@@ -88,12 +88,12 @@ extra_header_fields:
 	.short	0				/* MinorSubsystemVersion */
 	.long	0				/* Win32VersionValue */
 
-	.long	_edata - ImageBase		/* SizeOfImage */
+	.long	_edata - image_base		/* SizeOfImage */
 
 	/*
 	 * Everything before the kernel image is considered part of the header
 	 */
-	.long	_start - ImageBase		/* SizeOfHeaders */
+	.long	_start - image_base		/* SizeOfHeaders */
 	.long	0				/* CheckSum */
 	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
 #if CONFIG_VENDOR_EFI
@@ -149,9 +149,9 @@ section_table:
 	.byte	0
 	.byte	0			/* end of 0 padding of section name */
 	.long	_etext - _start		/* VirtualSize */
-	.long	_start - ImageBase	/* VirtualAddress */
+	.long	_start - image_base	/* VirtualAddress */
 	.long	_etext - _start		/* SizeOfRawData */
-	.long	_start - ImageBase	/* PointerToRawData */
+	.long	_start - image_base	/* PointerToRawData */
 	.long	0			/* PointerToRelocations (0 for executables) */
 	.long	0			/* PointerToLineNumbers (0 for executables) */
 	.short	0			/* NumberOfRelocations  (0 for executables) */
@@ -166,9 +166,9 @@ section_table:
 	.byte	0
 	.byte	0			/* end of 0 padding of section name */
 	.long	_edata - _data		/* VirtualSize */
-	.long	_data - ImageBase	/* VirtualAddress */
+	.long	_data - image_base	/* VirtualAddress */
 	.long	_edata - _data		/* SizeOfRawData */
-	.long	_data - ImageBase	/* PointerToRawData */
+	.long	_data - image_base	/* PointerToRawData */
 	.long	0			/* PointerToRelocations */
 	.long	0			/* PointerToLineNumbers */
 	.short	0			/* NumberOfRelocations */
@@ -185,7 +185,7 @@ _start:
 	SAVE_LONG(a1, 1)
 	SAVE_LONG(ra, 2)
 
-	lla		a0, ImageBase
+	lla		a0, image_base
 	lla		a1, _DYNAMIC
 	call		_relocate
 	bne		a0, zero, 0f
include/asm-generic/sections.h +2 -0
index 5b040d0acd0..606fce65adc 100644
@@ -72,6 +72,8 @@ extern char __rel_dyn_start[], __rel_dyn_end[];
 extern char _image_binary_end[];
 extern char __dtb[];
 
+extern char image_base[];
+
 /*
  * This is the U-Boot entry point - prior to relocation it should be same
  * as __text_start
Signature · 1 line
2.43.0
#36 lore raw

Re: [PATCH 14/32] efi: Rename ImageBase to image_base

Quoted 4 lines · Simon Glass

It is confusing to have a camel-case indentifier in the link scripts. Rename it to fit with U-Boot's snake-case style.

This isn't the linker script, it's the crt0 file. Given that this is intended to match up with
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format (which I
got from looking at the commit message on commit 216459d2cf36
("efi_loader: correct SizeOfCode, SizeOfInitializedData") and
include/pe.h I don't think this is a good change. Heinrich?

Signature · 1 line
Tom
#37 lore raw

Re: [PATCH 14/32] efi: Rename ImageBase to image_base

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 4 lines · Simon Glass

It is confusing to have a camel-case indentifier in the link scripts. Rename it to fit with U-Boot's snake-case style.

This isn't the linker script, it's the crt0 file.

Yes, it's referred to in the x86 linker scripts. Probably we should rationalise some of these names.

Quoted 5 lines

Given that this is intended to match up with
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format (which I got from looking at the commit message on commit 216459d2cf36 ("efi_loader: correct SizeOfCode, SizeOfInitializedData") and include/pe.h I don't think this is a good change. Heinrich?

Well, pe.h is a file format so I don't believe we need to use the same code style. We had that discussion when the EFI code was coming in, and decided that it wasn't a good idea (as I recall).

Regards,
Simon

#38 lore raw

Re: [PATCH 14/32] efi: Rename ImageBase to image_base

Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 4 lines · Simon Glass

It is confusing to have a camel-case indentifier in the link scripts. Rename it to fit with U-Boot's snake-case style.

This isn't the linker script, it's the crt0 file.

Yes, it's referred to in the x86 linker scripts. Probably we should rationalise some of these names.

Quoted 5 lines

Given that this is intended to match up with
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format (which I got from looking at the commit message on commit 216459d2cf36 ("efi_loader: correct SizeOfCode, SizeOfInitializedData") and include/pe.h I don't think this is a good change. Heinrich?

Quoted 3 lines

Well, pe.h is a file format so I don't believe we need to use the same code style. We had that discussion when the EFI code was coming in, and decided that it wasn't a good idea (as I recall).

I really don't think our linker script for making a specific output type should deviate from how the output type talks about things. Deviation is confusing.

Signature · 1 line
Tom
#39 lore raw

Re: [PATCH 14/32] efi: Rename ImageBase to image_base

Hi Tom,

Quoted 24 lines · Tom Rini
Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 4 lines · Simon Glass

It is confusing to have a camel-case indentifier in the link scripts. Rename it to fit with U-Boot's snake-case style.

This isn't the linker script, it's the crt0 file.

Yes, it's referred to in the x86 linker scripts. Probably we should rationalise some of these names.

Quoted 5 lines

Given that this is intended to match up with
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format (which I got from looking at the commit message on commit 216459d2cf36 ("efi_loader: correct SizeOfCode, SizeOfInitializedData") and include/pe.h I don't think this is a good change. Heinrich?

Quoted 7 lines
Quoted 3 lines

Well, pe.h is a file format so I don't believe we need to use the same code style. We had that discussion when the EFI code was coming in, and decided that it wasn't a good idea (as I recall).

I really don't think our linker script for making a specific output type should deviate from how the output type talks about things. Deviation is confusing.

Well in that case, it is pe.h that needs to change. The original file I brought in was there because I was planning to add ARM support at the time. As it turns out, the file isn't needed for arm64, so this series removes most of it. For 32-bit ARM, the file is not used at all (although Heinrich might correct me if sandbox on 32-bit ARM uses it?). See:

arch/sandbox/lib/crt0_sandbox_efi.S

Regards,
Simon

#40 lore raw

Re: [PATCH 14/32] efi: Rename ImageBase to image_base

Quoted 35 lines · Simon Glass

Hi Tom,

Quoted 24 lines · Tom Rini
Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 4 lines · Simon Glass

It is confusing to have a camel-case indentifier in the link scripts. Rename it to fit with U-Boot's snake-case style.

This isn't the linker script, it's the crt0 file.

Yes, it's referred to in the x86 linker scripts. Probably we should rationalise some of these names.

Quoted 5 lines

Given that this is intended to match up with
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format (which I got from looking at the commit message on commit 216459d2cf36 ("efi_loader: correct SizeOfCode, SizeOfInitializedData") and include/pe.h I don't think this is a good change. Heinrich?

Quoted 7 lines
Quoted 3 lines

Well, pe.h is a file format so I don't believe we need to use the same code style. We had that discussion when the EFI code was coming in, and decided that it wasn't a good idea (as I recall).

I really don't think our linker script for making a specific output type should deviate from how the output type talks about things. Deviation is confusing.

Quoted 8 lines

Well in that case, it is pe.h that needs to change. The original file I brought in was there because I was planning to add ARM support at the time. As it turns out, the file isn't needed for arm64, so this series removes most of it. For 32-bit ARM, the file is not used at all (although Heinrich might correct me if sandbox on 32-bit ARM uses it?). See:

arch/sandbox/lib/crt0_sandbox_efi.S

We likely shouldn't be so broadly including <pe.h> within EFI and I'll defer to Heinrich on if changing include/pe.h to non-CamelCase will make the users more or less clear.

Signature · 1 line
Tom
#41 lore raw

PATCH 15/32 efi: lmb: Avoid access to _start

In reply to Simon Glass

The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control. Disable this reservation for the EFI app.

---

 lib/lmb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +2 -1
index 588787d2a90..420eae4d0b8 100644
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)
 		lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1,
 				  LMB_NOOVERWRITE);
 
-		if (gd->flags & GD_FLG_SKIP_RELOC)
+		if (!IS_ENABLED(CONFIG_EFI_APP) &&
+		    (gd->flags & GD_FLG_SKIP_RELOC))
 			lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
 					  gd->mon_len, LMB_NOOVERWRITE);
 
Signature · 1 line
2.43.0
#42 lore raw

Re: [PATCH 15/32] efi: lmb: Avoid access to _start

Quoted 15 lines · Simon Glass

The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control. Disable this reservation for the EFI app.

---

 lib/lmb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +0 -0
index 588787d2a90..420eae4d0b8 100644

lib/lmb.c static void lmb_reserve_uboot_region(void) · line 566

Quoted 8 lines
lib/lmb.c +2 -1
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)
 		lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1,
 				  LMB_NOOVERWRITE);
 
-		if (gd->flags & GD_FLG_SKIP_RELOC)
+		if (!IS_ENABLED(CONFIG_EFI_APP) &&
+		    (gd->flags & GD_FLG_SKIP_RELOC))
 			lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
 					  gd->mon_len, LMB_NOOVERWRITE);

What prevents U-Boot from overwriting itself, with U-Boot commands? Also how is this linking today? I see lmb_reserve_uboot_region in efi-x86_app64 for example.

Signature · 1 line
Tom
#43 lore raw

Re: [PATCH 15/32] efi: lmb: Avoid access to _start

Hi Tom,

Quoted 21 lines · Tom Rini
Quoted 18 lines · Simon Glass

The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control. Disable this reservation for the EFI app.

---

 lib/lmb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +0 -0
index 588787d2a90..420eae4d0b8 100644
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)
              lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1,
                                LMB_NOOVERWRITE);
 
Quoted 9 lines

lib/lmb.c static void lmb_reserve_uboot_region(void) · line 566

Quoted 5 lines
lib/lmb.c +2 -1
-             if (gd->flags & GD_FLG_SKIP_RELOC)
+             if (!IS_ENABLED(CONFIG_EFI_APP) &&
+                 (gd->flags & GD_FLG_SKIP_RELOC))
                      lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
                                        gd->mon_len, LMB_NOOVERWRITE);

What prevents U-Boot from overwriting itself, with U-Boot commands? Also how is this linking today? I see lmb_reserve_uboot_region in efi-x86_app64 for example.

The only memory U-Boot can use when running as an EFI app is that which it has allocated using EFI calls. The actual U-Boot code is certainly in memory somewhere, but does not lie between gd->ram_start and (gd->ram_start + gd->ram_size)

Regards,
Simon

#44 lore raw

Re: [PATCH 15/32] efi: lmb: Avoid access to _start

Quoted 34 lines · Simon Glass

Hi Tom,

Quoted 21 lines · Tom Rini
Quoted 18 lines · Simon Glass

The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control. Disable this reservation for the EFI app.

---

 lib/lmb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +0 -0
index 588787d2a90..420eae4d0b8 100644
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)
              lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1,
                                LMB_NOOVERWRITE);
 
Quoted 9 lines

lib/lmb.c static void lmb_reserve_uboot_region(void) · line 566

Quoted 5 lines
lib/lmb.c +2 -1
-             if (gd->flags & GD_FLG_SKIP_RELOC)
+             if (!IS_ENABLED(CONFIG_EFI_APP) &&
+                 (gd->flags & GD_FLG_SKIP_RELOC))
                      lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
                                        gd->mon_len, LMB_NOOVERWRITE);

What prevents U-Boot from overwriting itself, with U-Boot commands? Also how is this linking today? I see lmb_reserve_uboot_region in efi-x86_app64 for example.

Quoted 4 lines

The only memory U-Boot can use when running as an EFI app is that which it has allocated using EFI calls. The actual U-Boot code is certainly in memory somewhere, but does not lie between gd->ram_start and (gd->ram_start + gd->ram_size)

That's not what the commit message means to me. But the next question is, is EFI_APP setting SKIP_RELOC?

Signature · 1 line
Tom
#45 lore raw

Re: [PATCH 15/32] efi: lmb: Avoid access to _start

Hi Tom,

Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass

Hi Tom,

Quoted 30 lines · Tom Rini
Quoted 15 lines · Simon Glass

The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control. Disable this reservation for the EFI app.

---

 lib/lmb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +0 -0
index 588787d2a90..420eae4d0b8 100644

lib/lmb.c static void lmb_reserve_uboot_region(void) · line 566

Quoted 8 lines
lib/lmb.c +2 -1
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)
              lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1,
                                LMB_NOOVERWRITE);
 
-             if (gd->flags & GD_FLG_SKIP_RELOC)
+             if (!IS_ENABLED(CONFIG_EFI_APP) &&
+                 (gd->flags & GD_FLG_SKIP_RELOC))
                      lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
                                        gd->mon_len, LMB_NOOVERWRITE);

What prevents U-Boot from overwriting itself, with U-Boot commands? Also how is this linking today? I see lmb_reserve_uboot_region in efi-x86_app64 for example.

Quoted 7 lines
Quoted 4 lines

The only memory U-Boot can use when running as an EFI app is that which it has allocated using EFI calls. The actual U-Boot code is certainly in memory somewhere, but does not lie between gd->ram_start and (gd->ram_start + gd->ram_size)

That's not what the commit message means to me. But the next question is, is EFI_APP setting SKIP_RELOC?

Yes, there is no sense in relocating from one alloced region to another. U-Boot is not able to relocate to the top of memory, nor decide what other parts of memory are used for. This is in the nature of EFI, after all. We have an API, but not policy.

Regards,
Simon

Reviewed-by
#46 lore raw

Re: [PATCH 15/32] efi: lmb: Avoid access to _start

Quoted 44 lines · Simon Glass

Hi Tom,

Quoted 41 lines · Tom Rini
Quoted 38 lines · Simon Glass

Hi Tom,

Quoted 21 lines · Tom Rini
Quoted 18 lines · Simon Glass

The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control. Disable this reservation for the EFI app.

---

 lib/lmb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +0 -0
index 588787d2a90..420eae4d0b8 100644
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)
              lmb_reserve_flags(rsv_start, bank_end - rsv_start + 1,
                                LMB_NOOVERWRITE);
 
Quoted 9 lines

lib/lmb.c static void lmb_reserve_uboot_region(void) · line 566

Quoted 5 lines
lib/lmb.c +2 -1
-             if (gd->flags & GD_FLG_SKIP_RELOC)
+             if (!IS_ENABLED(CONFIG_EFI_APP) &&
+                 (gd->flags & GD_FLG_SKIP_RELOC))
                      lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
                                        gd->mon_len, LMB_NOOVERWRITE);

What prevents U-Boot from overwriting itself, with U-Boot commands? Also how is this linking today? I see lmb_reserve_uboot_region in efi-x86_app64 for example.

The only memory U-Boot can use when running as an EFI app is that which it has allocated using EFI calls. The actual U-Boot code is certainly in memory somewhere, but does not lie between gd->ram_start and (gd->ram_start + gd->ram_size)

Quoted 7 lines
Quoted 2 lines

That's not what the commit message means to me. But the next question is, is EFI_APP setting SKIP_RELOC?

Yes, there is no sense in relocating from one alloced region to another. U-Boot is not able to relocate to the top of memory, nor decide what other parts of memory are used for. This is in the nature of EFI, after all. We have an API, but not policy.

With a commit message that explains that EFI_APP skips relocation and so isn't at the address pointed to by the _start symbol:

Signature · 1 line
Tom
#47 lore raw

PATCH 16/32 efi: arm: Don't do the EL2 switch when running under EFI

In reply to Simon Glass

The previous bootloader has likely done this already, so avoid trying to do it again. This fixes a crash in QEMU when booting from EDK2

---

 arch/arm/lib/bootm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/lib/bootm.c +5 -2
index 974cbfe8400..688c2f3f29b 100644
@@ -16,6 +16,7 @@
 #include <command.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <init.h>
 #include <log.h>
 #include <asm/global_data.h>
 #include <dm/root.h>
@@ -186,8 +187,10 @@ __weak void setup_board_tags(struct tag **in_params) {}
 #ifdef CONFIG_ARM64
 static void do_nonsec_virt_switch(void)
 {
-	smp_kick_all_cpus();
-	dcache_disable();	/* flush cache before swtiching to EL2 */
+	if (ll_boot_init()) {
+		smp_kick_all_cpus();
+		dcache_disable();	/* flush cache before swtiching to EL2 */
+	}
 }
 #endif
 
Signature · 1 line
2.43.0
#48 lore raw

Re: [PATCH 16/32] efi: arm: Don't do the EL2 switch when running under EFI

Quoted 23 lines · Simon Glass

The previous bootloader has likely done this already, so avoid trying to do it again. This fixes a crash in QEMU when booting from EDK2

---

 arch/arm/lib/bootm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/lib/bootm.c +1 -0
index 974cbfe8400..688c2f3f29b 100644
@@ -16,6 +16,7 @@
 #include <command.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <init.h>
 #include <log.h>
 #include <asm/global_data.h>
 #include <dm/root.h>
@@ -186,8 +187,10 @@ __weak void setup_board_tags(struct tag **in_params) {}
 #ifdef CONFIG_ARM64

arch/arm/lib/bootm.c __weak void setup_board_tags(struct tag **in_params) {} · line 195

Quoted 10 lines
arch/arm/lib/bootm.c +4 -2
 static void do_nonsec_virt_switch(void)
 {
-	smp_kick_all_cpus();
-	dcache_disable();	/* flush cache before swtiching to EL2 */
+	if (ll_boot_init()) {
+		smp_kick_all_cpus();
+		dcache_disable();	/* flush cache before swtiching to EL2 */
+	}
 }
 #endif

Since Marek just did a bunch of work around "use U-Boot for all ELs" I wonder if there's something cleaner / different we should be doing here?

Signature · 1 line
Tom
#49 lore raw

Re: [PATCH 16/32] efi: arm: Don't do the EL2 switch when running under EFI

Hi Tom,

Quoted 31 lines · Tom Rini
Quoted 28 lines · Simon Glass

The previous bootloader has likely done this already, so avoid trying to do it again. This fixes a crash in QEMU when booting from EDK2

---

 arch/arm/lib/bootm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/lib/bootm.c +2 -2
index 974cbfe8400..688c2f3f29b 100644
@@ -16,6 +16,7 @@
 #include <command.h>
 #include <cpu_func.h>
 #include <dm.h>
+#include <init.h>
 #include <log.h>
 #include <asm/global_data.h>
 #include <dm/root.h>
@@ -186,8 +187,10 @@ __weak void setup_board_tags(struct tag **in_params) {}
 #ifdef CONFIG_ARM64
 static void do_nonsec_virt_switch(void)
 {
-     smp_kick_all_cpus();
-     dcache_disable();       /* flush cache before swtiching to EL2 */
+     if (ll_boot_init()) {
Quoted 8 lines

arch/arm/lib/bootm.c __weak void setup_board_tags(struct tag **in_params) {} · line 195

Quoted 5 lines
arch/arm/lib/bootm.c +3 -0
+             smp_kick_all_cpus();
+             dcache_disable();       /* flush cache before swtiching to EL2 */
+     }
 }
 #endif

Since Marek just did a bunch of work around "use U-Boot for all ELs" I wonder if there's something cleaner / different we should be doing here?

It's certainly possible, but I'm not sure what that would look like.

Regards,
Simon

#50 lore raw

PATCH 17/32 efi: arm: Avoid allocating page tables when running under EFI

In reply to Simon Glass

The previous bootloader has already set up the page tables, so don't try to do it again.

This fixes a crash in QEMU when booting from EDK2

---

 arch/arm/lib/cache.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/lib/cache.c +3 -0
index 516754caeaf..bdd0f202bf9 100644
@@ -6,6 +6,7 @@
 
 #include <config.h>
 #include <cpu_func.h>
+#include <init.h>
 #include <log.h>
 #include <malloc.h>
 #include <asm/cache.h>
@@ -138,6 +139,8 @@ int arch_reserve_mmu(void)
 
 __weak int arm_reserve_mmu(void)
 {
+	if (!ll_boot_init())
+		return 0;
 #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
 	/* reserve TLB table */
 	gd->arch.tlb_size = PGTABLE_SIZE;
Signature · 1 line
2.43.0
#51 lore raw

PATCH 18/32 efi: arm: Avoid enabling caches when running under EFI

In reply to Simon Glass

The previous bootloader has already set up the cache, so don't try to do it again.

This fixes a crash in QEMU when booting from EDK2

---

 common/board_r.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
common/board_r.c +3 -2
index caac092c8e7..c4545e9b483 100644
@@ -110,8 +110,9 @@ static int initr_reloc(void)
  */
 static int initr_caches(void)
 {
-	/* Enable caches */
-	enable_caches();
+	if (ll_boot_init())
+		enable_caches();
+
 	return 0;
 }
 #endif
Signature · 1 line
2.43.0
#52 lore raw

PATCH 19/32 efi: arm: Implement access to global_data for EFI

In reply to Simon Glass

The EFI app likes to use a simple variable for global data. Implement this for ARM.

---

 arch/arm/include/asm/global_data.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arm/include/asm/global_data.h +12 -2
index 6e4471662a3..8d51111f095 100644
@@ -115,7 +115,13 @@ struct arch_global_data {
 
 #include <asm-generic/global_data.h>
 
-#if defined(__clang__) || defined(LTO_ENABLE)
+#ifdef CONFIG_EFI_APP
+
+#define DECLARE_GLOBAL_DATA_PTR   extern struct global_data *global_data_ptr
+
+#define gd global_data_ptr
+
+#elif defined(__clang__) || defined(LTO_ENABLE)
 
 #define DECLARE_GLOBAL_DATA_PTR
 #define gd	get_gd()
@@ -144,7 +150,11 @@ static inline gd_t *get_gd(void)
 
 static inline void set_gd(volatile gd_t *gd_ptr)
 {
-#ifdef CONFIG_ARM64
+#ifdef CONFIG_EFI_APP
+	extern struct global_data *global_data_ptr;
+
+	global_data_ptr = (void *)gd_ptr;
+#elif defined CONFIG_ARM64
 	__asm__ volatile("ldr x18, %0\n" : : "m"(gd_ptr));
 #elif __ARM_ARCH >= 7
 	__asm__ volatile("ldr r9, %0\n" : : "m"(gd_ptr));
Signature · 1 line
2.43.0
#53 lore raw

PATCH 20/32 efi: arm: Omit the ARM start-up code in the EFI app

In reply to Simon Glass

This code is not used with the EFI app, since it enters through a call to efi_main(). Remove start.S and crt files from the build.

---

 arch/arm/Makefile     | 2 ++
 arch/arm/lib/Makefile | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/Makefile +2 -0
index cb87a684754..2e569b330d0 100644
@@ -104,7 +104,9 @@ PLATFORM_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 
 libs-y += $(machdirs)
 
+ifndef CONFIG_EFI_APP
 head-y := arch/arm/cpu/$(CPU)/start.o
+endif
 
 ifeq ($(CONFIG_XPL_BUILD),y)
 ifeq ($(CONFIG_SYS_SOC)$(CONFIG_SPL_FRAMEWORK),"mxs")
arch/arm/lib/Makefile +4 -2
index 14e3990925a..9500ba6fddc 100644
@@ -7,19 +7,21 @@ lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o \
 				    lib1funcs.o uldivmod.o div0.o \
 				    div64.o muldi3.o
 
+ifndef CONFIG_EFI_APP
 ifdef CONFIG_CPU_V7M
 obj-y	+= vectors_m.o crt0.o
 else ifdef CONFIG_ARM64
 obj-y	+= crt0_64.o
 else
 obj-y	+= vectors.o crt0.o
-endif
+endif  #  CPU type
 
 ifdef CONFIG_ARM64
 obj-y   += setjmp_aarch64.o
 else
 obj-y   += setjmp.o
-endif
+endif  # ARM64
+endif  # CONFIG_EFI_APP
 
 ifndef CONFIG_XPL_BUILD
 ifdef CONFIG_ARM64
Signature · 1 line
2.43.0
Reviewed-by on v1 20/32
#54 lore raw

Re: [PATCH 20/32] efi: arm: Omit the ARM start-up code in the EFI app

Quoted 4 lines · Simon Glass

This code is not used with the EFI app, since it enters through a call to efi_main(). Remove start.S and crt files from the build.

Signature · 1 line
Tom
#55 lore raw

PATCH 21/32 efi: arm: Drop exception code when running as an EFI app

In reply to Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/Makefile +1 -1
index 2e71ff2dc97..7bd6cf21b19 100644
@@ -13,7 +13,7 @@ ifndef CONFIG_$(XPL_)SYS_DCACHE_OFF
 obj-y	+= cache_v8.o
 obj-y	+= cache.o
 endif
-ifdef CONFIG_XPL_BUILD
+ifneq ($(CONFIG_XPL_BUILD)$(CONFIG_EFI_APP),)
 obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o
 else
 obj-y	+= exceptions.o
Signature · 1 line
2.43.0
#56 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Quoted 8 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

Signature · 1 line
Tom
#57 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Hi Tom,

Quoted 6 lines · Tom Rini
Quoted 3 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

Quoted 7 lines
Quoted 5 lines

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

Regards,
Simon

#58 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Quoted 12 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Signature · 1 line
Tom
#59 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 15 lines · Simon Glass

Hi Tom,

Quoted 12 lines · Tom Rini
Quoted 8 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Not using SPL, but using the same code as SPL happens to use.

Regards,
Simon

#60 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 19 lines · Tom Rini
Quoted 17 lines · Simon Glass

Hi Tom,

Quoted 13 lines · Tom Rini
Quoted 8 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Not using SPL, but using the same code as SPL happens to use.

But is CONFIG_SPL enabled, or not? It shouldn't be if I follow you.

Signature · 1 line
Tom
#61 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Hi Tom,

Quoted 28 lines · Tom Rini
Quoted 26 lines · Simon Glass

Hi Tom,

Quoted 23 lines · Tom Rini
Quoted 20 lines · Simon Glass

Hi Tom,

Quoted 6 lines · Tom Rini
Quoted 3 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

Quoted 7 lines
Quoted 5 lines

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Not using SPL, but using the same code as SPL happens to use.

But is CONFIG_SPL enabled, or not? It shouldn't be if I follow you.

No, it isn't enabled. But we do want that exceptions.o both for the EFI app and for whatever boards use SPL.

Regards,
Simon

#62 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Quoted 34 lines · Simon Glass

Hi Tom,

Quoted 31 lines · Tom Rini
Quoted 29 lines · Simon Glass

Hi Tom,

Quoted 25 lines · Tom Rini
Quoted 12 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Not using SPL, but using the same code as SPL happens to use.

But is CONFIG_SPL enabled, or not? It shouldn't be if I follow you.

No, it isn't enabled. But we do want that exceptions.o both for the EFI app and for whatever boards use SPL.

Um. Isn't that the opposite of what your commit message says? And the Makefile snippet today is:
ifdef CONFIG_XPL_BUILD obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o else
obj-y += exceptions.o
obj-y += exception_level.o
endif

Signature · 1 line
Tom
#63 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Hi Tom,

Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass

Hi Tom,

Quoted 31 lines · Tom Rini
Quoted 29 lines · Simon Glass

Hi Tom,

Quoted 25 lines · Tom Rini
Quoted 12 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Not using SPL, but using the same code as SPL happens to use.

But is CONFIG_SPL enabled, or not? It shouldn't be if I follow you.

No, it isn't enabled. But we do want that exceptions.o both for the EFI app and for whatever boards use SPL.

Um. Isn't that the opposite of what your commit message says?

Would it be clearer if I said 'exception-level code'?

Quoted 4 lines

And the
Makefile snippet today is:
ifdef CONFIG_XPL_BUILD obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o

^^^ this is the line that I want enabled for the EFI app

Quoted 5 lines

else
obj-y += exceptions.o
obj-y += exception_level.o
endif

Regards,
Simon

#64 lore raw

Re: [PATCH 21/32] efi: arm: Drop exception code when running as an EFI app

Quoted 41 lines · Simon Glass

Hi Tom,

Quoted 38 lines · Tom Rini
Quoted 36 lines · Simon Glass

Hi Tom,

Quoted 33 lines · Tom Rini
Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 15 lines · Simon Glass

Hi Tom,

Quoted 12 lines · Tom Rini
Quoted 8 lines · Simon Glass

This code cannot be used since EFI is in charge of managing exceptions. Drop it.

---

 arch/arm/cpu/armv8/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Why is SPL on in this case?

SPL is enabled by a specific Kconfig option, which seems to have exceptions but not exception levels. That seemed to match what the EFI app wants, for now.

OK, so why aren't you turning off SPL? You're not using SPL at all, right?

Not using SPL, but using the same code as SPL happens to use.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

But is CONFIG_SPL enabled, or not? It shouldn't be if I follow you.

No, it isn't enabled. But we do want that exceptions.o both for the EFI app and for whatever boards use SPL.

Um. Isn't that the opposite of what your commit message says?

Would it be clearer if I said 'exception-level code'?

Since we have exception_level.o and exception.o yes, you should be clear about the code you're talking about.

Quoted 12 lines
Quoted 5 lines

And the
Makefile snippet today is:
ifdef CONFIG_XPL_BUILD obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o

^^^ this is the line that I want enabled for the EFI app

Quoted 4 lines

else
obj-y += exceptions.o
obj-y += exception_level.o
endif

Then you should be working in the non-XPL stanza and not enabling an SPL symbol for your not SPL build. I gather you're trying to not include exception_level.o because since you can't use --gc-sections you're having some undefined symbol problem. How about you file an issue for me to tidy up ARMV8_SPL_EXCEPTION_VECTORS and exception_level.o handling.

Signature · 1 line
Tom
#65 lore raw

PATCH 22/32 efi: arm: Allow use of the EFI table in the app

In reply to Simon Glass

It isn't worth the hassle of omitting this field for the app, since code is shared between the payload and the app. Adjust the condition to avoid a build error in the 'efi' command with the app on ARM.

---

 arch/arm/include/asm/global_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/global_data.h +1 -1
index 8d51111f095..6a85fb2e152 100644
@@ -108,7 +108,7 @@ struct arch_global_data {
 #ifdef CONFIG_SMBIOS
 	ulong smbios_start;		/* Start address of SMBIOS table */
 #endif
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
 	ulong table;
 #endif
 };
Signature · 1 line
2.43.0
#66 lore raw

Re: [PATCH 22/32] efi: arm: Allow use of the EFI table in the app

Quoted 15 lines · Simon Glass

It isn't worth the hassle of omitting this field for the app, since code is shared between the payload and the app. Adjust the condition to avoid a build error in the 'efi' command with the app on ARM.

---

  arch/arm/include/asm/global_data.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/global_data.h +0 -0
index 8d51111f095..6a85fb2e152 100644

arch/arm/include/asm/global_data.h struct arch_global_data { · line 112

Quoted 6 lines
arch/arm/include/asm/global_data.h +1 -1
@@ -108,7 +108,7 @@ struct arch_global_data {
  #ifdef CONFIG_SMBIOS
  	ulong smbios_start;		/* Start address of SMBIOS table */
  #endif
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
  	ulong table;

Unfortunately this field is not documented at all. Please, add a description. The description '/* Table pointer from previous loader */' given in the X86 code is quite unsatisfactory. I would not know what table the field points to.

If this field is EFI specific, shouldn't it be defined in arch/x86/include/asm/global_data.h?

Best regards

Heinrich

Quoted 2 lines
arch/arm/include/asm/global_data.h +0 -0
  #endif
  };
#67 lore raw

Re: [PATCH 22/32] efi: arm: Allow use of the EFI table in the app

Hi Heinrich,

Quoted 29 lines · Heinrich Schuchardt
Quoted 15 lines · Simon Glass

It isn't worth the hassle of omitting this field for the app, since code is shared between the payload and the app. Adjust the condition to avoid a build error in the 'efi' command with the app on ARM.

---

  arch/arm/include/asm/global_data.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/global_data.h +0 -0
index 8d51111f095..6a85fb2e152 100644

arch/arm/include/asm/global_data.h struct arch_global_data { · line 112

Quoted 6 lines
arch/arm/include/asm/global_data.h +1 -1
@@ -108,7 +108,7 @@ struct arch_global_data {
  #ifdef CONFIG_SMBIOS
      ulong smbios_start;             /* Start address of SMBIOS table */
  #endif
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
      ulong table;

Unfortunately this field is not documented at all. Please, add a description. The description '/* Table pointer from previous loader */' given in the X86 code is quite unsatisfactory. I would not know what table the field points to.

Quoted 2 lines

If this field is EFI specific, shouldn't it be defined in arch/x86/include/asm/global_data.h?

It depends on what the previous firmware was. Where it is coreboot, this stores a pointer to the coreboot tables.

On ARM it is somewhat EFI-specific, although only because we don't expect people to want to boot from coreboot to U-Boot on ARM. But I have long-since given up betting against any particular boot combination.

Regards,
SImon

#68 lore raw

Re: [PATCH 22/32] efi: arm: Allow use of the EFI table in the app

Quoted 35 lines · Simon Glass

Hi Heinrich,

Quoted 29 lines · Heinrich Schuchardt
Quoted 15 lines · Simon Glass

It isn't worth the hassle of omitting this field for the app, since code is shared between the payload and the app. Adjust the condition to avoid a build error in the 'efi' command with the app on ARM.

---

   arch/arm/include/asm/global_data.h | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/global_data.h +0 -0
index 8d51111f095..6a85fb2e152 100644

arch/arm/include/asm/global_data.h struct arch_global_data { · line 112

Quoted 6 lines
arch/arm/include/asm/global_data.h +1 -1
@@ -108,7 +108,7 @@ struct arch_global_data {
   #ifdef CONFIG_SMBIOS
       ulong smbios_start;             /* Start address of SMBIOS table */
   #endif
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
       ulong table;

Unfortunately this field is not documented at all. Please, add a description. The description '/* Table pointer from previous loader */' given in the X86 code is quite unsatisfactory. I would not know what table the field points to.

Quoted 2 lines

If this field is EFI specific, shouldn't it be defined in arch/x86/include/asm/global_data.h?

Quoted 7 lines

It depends on what the previous firmware was. Where it is coreboot, this stores a pointer to the coreboot tables.

On ARM it is somewhat EFI-specific, although only because we don't expect people to want to boot from coreboot to U-Boot on ARM. But I have long-since given up betting against any particular boot combination.

This does not quite answer the question if we should move this field to asm-generic.

As the usage of the field is non-trivial it should be documented.

Best regards

Heinrich

#69 lore raw

Re: [PATCH 22/32] efi: arm: Allow use of the EFI table in the app

Hi Heinrich,

Quoted 40 lines · Heinrich Schuchardt
Quoted 38 lines · Simon Glass

Hi Heinrich,

Quoted 29 lines · Heinrich Schuchardt
Quoted 15 lines · Simon Glass

It isn't worth the hassle of omitting this field for the app, since code is shared between the payload and the app. Adjust the condition to avoid a build error in the 'efi' command with the app on ARM.

---

   arch/arm/include/asm/global_data.h | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/global_data.h +0 -0
index 8d51111f095..6a85fb2e152 100644

arch/arm/include/asm/global_data.h struct arch_global_data { · line 112

Quoted 6 lines
arch/arm/include/asm/global_data.h +1 -1
@@ -108,7 +108,7 @@ struct arch_global_data {
   #ifdef CONFIG_SMBIOS
       ulong smbios_start;             /* Start address of SMBIOS table */
   #endif
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
       ulong table;

Unfortunately this field is not documented at all. Please, add a description. The description '/* Table pointer from previous loader */' given in the X86 code is quite unsatisfactory. I would not know what table the field points to.

Quoted 2 lines

If this field is EFI specific, shouldn't it be defined in arch/x86/include/asm/global_data.h?

It depends on what the previous firmware was. Where it is coreboot, this stores a pointer to the coreboot tables.

Quoted 7 lines
Quoted 4 lines

On ARM it is somewhat EFI-specific, although only because we don't expect people to want to boot from coreboot to U-Boot on ARM. But I have long-since given up betting against any particular boot combination.

This does not quite answer the question if we should move this field to asm-generic.

I didn't see that question in your response.

Quoted 2 lines

As the usage of the field is non-trivial it should be documented.

Yes, agreed.

Regards,
Simon

#70 lore raw

PATCH 23/32 efi: arm: Disable --gc-sections for the app

In reply to Simon Glass

This option cannot be used with a shared library, since it results in everything being removed. Disable it.

---

 arch/arm/config.mk | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/config.mk +2 -0
index e0045e22271..20f4d41f2c3 100644
@@ -14,8 +14,10 @@ CFLAGS_NON_EFI := -fno-pic $(FIXED_REG) -ffunction-sections -fdata-sections \
 CFLAGS_EFI := -fpic -fshort-wchar
 
 ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
+ifndef CONFIG_EFI_APP
 LDFLAGS_FINAL += --gc-sections
 endif
+endif
 
 ifneq ($(LTO_ENABLE),y)
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
Signature · 1 line
2.43.0
#72 lore raw

PATCH 24/32 efi: arm: Drop startup code from the app

In reply to Simon Glass

The EFI app uses different startup and relocation code and the existing code uses symbols not present in the app. Drop it.

---

 arch/arm/cpu/armv8/Makefile | 2 ++
 arch/arm/lib/Makefile       | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/Makefile +2 -0
index 7bd6cf21b19..a8f5de58cc4 100644
@@ -3,7 +3,9 @@
 # (C) Copyright 2000-2003
 # Wolfgang Denk, DENX Software Engineering, [email protected].
 
+ifndef CONFIG_EFI_APP
 extra-y	:= start.o
+endif
 
 obj-y	+= cpu.o
 ifndef CONFIG_$(PHASE_)TIMER
arch/arm/lib/Makefile +3 -1
index 9500ba6fddc..a41566c816d 100644
@@ -24,11 +24,13 @@ endif  # ARM64
 endif  # CONFIG_EFI_APP
 
 ifndef CONFIG_XPL_BUILD
+ifndef CONFIG_EFI_APP
 ifdef CONFIG_ARM64
 obj-y	+= relocate_64.o
 else
 obj-y	+= relocate.o
-endif
+endif  # ARM64
+endif  # EFI_APP
 
 obj-$(CONFIG_CPU_V7M) += cmd_boot.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
Signature · 1 line
2.43.0
#74 lore raw

PATCH 25/32 efi: arm: Adjust how the monitor length is calculated

In reply to Simon Glass

Adjust the conditions to support the EFI app when running on ARM.

---

 common/board_f.c | 4 ++--
 common/board_r.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
common/board_f.c +2 -2
index 8baaa2341a3..6426a17edc6 100644
@@ -263,6 +263,8 @@ static int setup_mon_len(void)
 {
 #if defined(CONFIG_ARCH_NEXELL)
 	gd->mon_len = (ulong)__bss_end - (ulong)__image_copy_start;
+#elif defined(CONFIG_EFI_APP)
+	gd->mon_len = (ulong)_end - (ulong)image_base;
 #elif defined(__ARM__) || defined(__MICROBLAZE__)
 	gd->mon_len = (ulong)__bss_end - (ulong)_start;
 #elif defined(CONFIG_SANDBOX) && !defined(__riscv)
@@ -270,8 +272,6 @@ static int setup_mon_len(void)
 #elif defined(CONFIG_SANDBOX)
 	/* gcc does not provide _init in crti.o on RISC-V */
 	gd->mon_len = 0;
-#elif defined(CONFIG_EFI_APP)
-	gd->mon_len = (ulong)_end - (ulong)_init;
 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
 	gd->mon_len = CONFIG_SYS_MONITOR_LEN;
 #elif defined(CONFIG_SH) || defined(CONFIG_RISCV)
common/board_r.c +3 -1
index c4545e9b483..3fa2d44402e 100644
@@ -124,7 +124,9 @@ __weak int fixup_cpu(void)
 
 static int initr_reloc_global_data(void)
 {
-#ifdef __ARM__
+#if defined(CONFIG_EFI_APP)
+	monitor_flash_len = (ulong)_end - (ulong)image_base;
+#elif defined __ARM__
 	monitor_flash_len = _end - __image_copy_start;
 #elif defined(CONFIG_RISCV)
 	monitor_flash_len = (ulong)_end - (ulong)_start;
Signature · 1 line
2.43.0
#75 lore raw

Re: [PATCH 25/32] efi: arm: Adjust how the monitor length is calculated

Quoted 14 lines · Simon Glass

Adjust the conditions to support the EFI app when running on ARM.

---

 common/board_f.c | 4 ++--
 common/board_r.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)
common/board_f.c +0 -0
index 8baaa2341a3..6426a17edc6 100644

common/board_f.c static int setup_mon_len(void) · line 270

Quoted 8 lines
common/board_f.c +2 -0
@@ -263,6 +263,8 @@ static int setup_mon_len(void)
 {
 #if defined(CONFIG_ARCH_NEXELL)
 	gd->mon_len = (ulong)__bss_end - (ulong)__image_copy_start;
+#elif defined(CONFIG_EFI_APP)
+	gd->mon_len = (ulong)_end - (ulong)image_base;
 #elif defined(__ARM__) || defined(__MICROBLAZE__)
 	gd->mon_len = (ulong)__bss_end - (ulong)_start;
 #elif defined(CONFIG_SANDBOX) && !defined(__riscv)

We should make EFI_APP the first option in this case, for clarity.

Signature · 1 line
Tom
#76 lore raw

PATCH 26/32 efi: arm: Select the EFI linker script for the app

In reply to Simon Glass

The app needs a special linker script, so select that for the app.

---

 arch/arm/cpu/armv8/config.mk | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv8/config.mk +4 -0
index 1ee31680106..d2d1a8d2bc2 100644
@@ -21,3 +21,7 @@ LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
 
 CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI)
 CPPFLAGS_crt0-efi-aarch64.o += $(CFLAGS_EFI)
+
+ifeq ($(CONFIG_EFI_APP),y)
+LDSCRIPT := $(LDSCRIPT_EFI)
+endif
Signature · 1 line
2.43.0
#77 lore raw

Re: [PATCH 26/32] efi: arm: Select the EFI linker script for the app

Quoted 13 lines · Simon Glass

The app needs a special linker script, so select that for the app.

---

 arch/arm/cpu/armv8/config.mk | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv8/config.mk +0 -0
index 1ee31680106..d2d1a8d2bc2 100644

arch/arm/cpu/armv8/config.mk LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \ · line 27

Quoted 7 lines
arch/arm/cpu/armv8/config.mk +4 -0
@@ -21,3 +21,7 @@ LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
 
 CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI)
 CPPFLAGS_crt0-efi-aarch64.o += $(CFLAGS_EFI)
+
+ifeq ($(CONFIG_EFI_APP),y)
+LDSCRIPT := $(LDSCRIPT_EFI)
+endif

This should be tidied up to use SYS_CUSTOM_LDSCRIPT / SYS_LDSCRIPT and just live in the defconfig or board/efi/Kconfig under BOARD_SPECIFIC_OPTIONS if that's objectionable.

Signature · 1 line
Tom
#78 lore raw

PATCH 27/32 efi: arm: Provide startup and relocation code

In reply to Simon Glass

Build in the EFI-app startup code as well as the code to relocate U-Boot to the loaded position, since this is under the control of the previous firmware.

---

 arch/arm/lib/Makefile | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/lib/Makefile +2 -0
index a41566c816d..a2b8ef96ff5 100644
@@ -32,6 +32,8 @@ obj-y	+= relocate.o
 endif  # ARM64
 endif  # EFI_APP
 
+obj-$(CONFIG_EFI_APP) += $(EFI_CRT0) $(EFI_RELOC)
+
 obj-$(CONFIG_CPU_V7M) += cmd_boot.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
Signature · 1 line
2.43.0
Reviewed-by on v1 27/32
#79 lore raw

Re: [PATCH 27/32] efi: arm: Provide startup and relocation code

Quoted 5 lines · Simon Glass

Build in the EFI-app startup code as well as the code to relocate U-Boot to the loaded position, since this is under the control of the previous firmware.

Signature · 1 line
Tom
#80 lore raw

PATCH 28/32 efi: Generate the app as a shared library

In reply to Simon Glass

The app should be built as a shared library, with position-independent code and the -shared flags. Update the Makefile to handle this.

---

 Makefile | 4 ++++
 1 file changed, 4 insertions(+)
Makefile +4 -0
index 3958ea45b9a..990114731b4 100644
@@ -452,9 +452,13 @@ KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 endif
 
+ifdef CONFIG_EFI_APP
+KBUILD_CFLAGS += -shared
+else
 # Don't generate position independent code
 KBUILD_CFLAGS	+= $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS	+= $(call cc-option,-fno-PIE)
+endif
 
 # Read UBOOTRELEASE from include/config/uboot.release (if it exists)
 UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
Signature · 1 line
2.43.0
#81 lore raw

Re: [PATCH 28/32] efi: Generate the app as a shared library

Quoted 17 lines · Simon Glass

The app should be built as a shared library, with position-independent code and the -shared flags. Update the Makefile to handle this.

---

 Makefile | 4 ++++
 1 file changed, 4 insertions(+)
Makefile +0 -0
index 3958ea45b9a..990114731b4 100644
@@ -452,9 +452,13 @@ KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 endif
 

Makefile KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) · line 464

Quoted 10 lines
Makefile +4 -0
+ifdef CONFIG_EFI_APP
+KBUILD_CFLAGS += -shared
+else
 # Don't generate position independent code
 KBUILD_CFLAGS	+= $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS	+= $(call cc-option,-fno-PIE)
+endif
 
 # Read UBOOTRELEASE from include/config/uboot.release (if it exists)
 UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)

You should tidy up arch/x86/config.mk while doing this, and I assume -znocombreloc ends up being common as well?

Signature · 1 line
Tom
#82 lore raw

PATCH 29/32 efi: arm: Disable STATIC_RELA for the EFI app

In reply to Simon Glass

This feature should not be used with the app, since we don't know where U-Boot will be loaded. Disable it.

---

 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
index b032aac4caa..26168670e5c 100644
@@ -142,7 +142,7 @@ config GICV3_SUPPORT_GIC600
 
 config STATIC_RELA
 	bool
-	default y if ARM64
+	default y if ARM64 && !EFI_APP
 
 config DMA_ADDR_T_64BIT
 	bool
Signature · 1 line
2.43.0
#83 lore raw

PATCH 30/32 efi: arm: Use EFI flags for all compilation with the app

In reply to Simon Glass

As opposed to the payload, which is built normally with just an EFI stub, the app is build homogenously using EFI flags. Update PLATFORM_CPPFLAGS to enable this.

---

 arch/arm/cpu/armv8/config.mk | 1 +
 1 file changed, 1 insertion(+)
arch/arm/cpu/armv8/config.mk +1 -0
index d2d1a8d2bc2..cf0b89819d5 100644
@@ -23,5 +23,6 @@ CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI)
 CPPFLAGS_crt0-efi-aarch64.o += $(CFLAGS_EFI)
 
 ifeq ($(CONFIG_EFI_APP),y)
+PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
 LDSCRIPT := $(LDSCRIPT_EFI)
 endif
Signature · 1 line
2.43.0
#84 lore raw

Re: [PATCH 30/32] efi: arm: Use EFI flags for all compilation with the app

Quoted 15 lines · Simon Glass

As opposed to the payload, which is built normally with just an EFI stub, the app is build homogenously using EFI flags. Update PLATFORM_CPPFLAGS to enable this.

---

 arch/arm/cpu/armv8/config.mk | 1 +
 1 file changed, 1 insertion(+)
arch/arm/cpu/armv8/config.mk +0 -0
index d2d1a8d2bc2..cf0b89819d5 100644

arch/arm/cpu/armv8/config.mk CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI) · line 28

Quoted 6 lines
arch/arm/cpu/armv8/config.mk +1 -0
@@ -23,5 +23,6 @@ CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI)
 CPPFLAGS_crt0-efi-aarch64.o += $(CFLAGS_EFI)
 
 ifeq ($(CONFIG_EFI_APP),y)
+PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
 LDSCRIPT := $(LDSCRIPT_EFI)
 endif

This too should be tidied up and moved somewhere common between arm and x86.

Signature · 1 line
Tom
#85 lore raw

PATCH 31/32 efi: arm: Simplify the crt0 file and update link script

In reply to Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

---

 arch/arm/config.mk               |  10 ++
 arch/arm/cpu/armv8/config.mk     |   2 +-
 arch/arm/lib/crt0_aarch64_efi.S  | 156 +++++--------------------------
 arch/arm/lib/elf_aarch64_efi.lds |  49 +++++++---
 4 files changed, 70 insertions(+), 147 deletions(-)
arch/arm/config.mk +10 -0
index 20f4d41f2c3..a786709f3b5 100644
@@ -149,6 +149,9 @@ OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
 		-j .binman_sym_table -j .text_rest
 endif
 
+OBJCOPYFLAGS_EFI += $(OBJCOPYFLAGS) -j .dynamic -j .rela -j .reloc \
+	-j .embedded_dtb
+
 # if a dtb section exists we always have to include it
 # there are only two cases where it is generated
 # 1) OF_EMBEDED is turned on
@@ -178,6 +181,13 @@ endif
 endif
 endif
 
+ifdef CONFIG_ARM64
+EFI_LDS := elf_aarch64_efi.lds
+EFI_CRT0 := crt0_aarch64_efi.o
+EFI_RELOC := reloc_aarch64_efi.o
+EFI_TARGET := --target=efi-app-aarch64
+else
 EFI_LDS := elf_arm_efi.lds
 EFI_CRT0 := crt0_arm_efi.o
 EFI_RELOC := reloc_arm_efi.o
+endif
arch/arm/cpu/armv8/config.mk +1 -1
index cf0b89819d5..25d7ea08fce 100644
@@ -13,7 +13,7 @@ EFI_RELOC := reloc_aarch64_efi.o
 
 LDSCRIPT_EFI := $(srctree)/arch/arm/lib/elf_aarch64_efi.lds
 EFISTUB := crt0_aarch64_efi.o reloc_aarch64_efi.o
-OBJCOPYFLAGS_EFI += --target=pei-aarch64-little
+OBJCOPYFLAGS_EFI += -O binary --target=efi-app-aarch64
 EFIPAYLOAD_BFDTARGET := pei-aarch64-little
 EFIPAYLOAD_BFDARCH := aarch64
 LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
arch/arm/lib/crt0_aarch64_efi.S +23 -133

166 lines not on this page · raw message

arch/arm/lib/elf_aarch64_efi.lds +36 -13

86 lines not on this page · raw message

Signature · 1 line
2.43.0
#86 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Quoted 8 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

Quoted 7 lines

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

Signature · 1 line
Tom
#87 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Hi Tom,

Quoted 10 lines · Tom Rini
Quoted 8 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

Quoted 7 lines
Quoted 7 lines

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Thanks for looking at all this stuff.

Quoted 3 lines

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

No, I mean 32-bit ARM. For reasons I don't understand, it seems the toolchain doesn't support PE on 32-bit ARM.

Regards,
Simon

#88 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Quoted 18 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 13 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Thanks for looking at all this stuff.

You're welcome.

Quoted 5 lines
Quoted 2 lines

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

No, I mean 32-bit ARM. For reasons I don't understand, it seems the toolchain doesn't support PE on 32-bit ARM.

Ah, OK. Were other parts of this series really laying the groundwork for EFI_APP with 32bit arm?

Signature · 1 line
Tom
#89 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Hi Tom,

Quoted 27 lines · Tom Rini
Quoted 18 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 13 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Thanks for looking at all this stuff.

You're welcome.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

No, I mean 32-bit ARM. For reasons I don't understand, it seems the toolchain doesn't support PE on 32-bit ARM.

Ah, OK. Were other parts of this series really laying the groundwork for EFI_APP with 32bit arm?

Not intentionally, since I was trying to get the series as small as possible and still actually get something that boots.

I'm not sure that anyone will want a 32-bit ARM EFI-app. I would much rather that we had it for completeness, but it seems that the binutils people were not that interested in it. What do you think?

Regards,
Simon

#90 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Quoted 39 lines · Simon Glass

Hi Tom,

Quoted 27 lines · Tom Rini
Quoted 18 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 13 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Thanks for looking at all this stuff.

You're welcome.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

No, I mean 32-bit ARM. For reasons I don't understand, it seems the toolchain doesn't support PE on 32-bit ARM.

Ah, OK. Were other parts of this series really laying the groundwork for EFI_APP with 32bit arm?

Quoted 6 lines

Not intentionally, since I was trying to get the series as small as possible and still actually get something that boots.

I'm not sure that anyone will want a 32-bit ARM EFI-app. I would much rather that we had it for completeness, but it seems that the binutils people were not that interested in it. What do you think?

I would ignore arm32 entirely and make things depend on ARM64 rather than ARM within the series here.

Signature · 1 line
Tom
#91 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Hi Tom,

Quoted 44 lines · Tom Rini
Quoted 42 lines · Simon Glass

Hi Tom,

Quoted 27 lines · Tom Rini
Quoted 18 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 13 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Thanks for looking at all this stuff.

You're welcome.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

No, I mean 32-bit ARM. For reasons I don't understand, it seems the toolchain doesn't support PE on 32-bit ARM.

Ah, OK. Were other parts of this series really laying the groundwork for EFI_APP with 32bit arm?

Not intentionally, since I was trying to get the series as small as possible and still actually get something that boots.

Quoted 6 lines
Quoted 3 lines

I'm not sure that anyone will want a 32-bit ARM EFI-app. I would much rather that we had it for completeness, but it seems that the binutils people were not that interested in it. What do you think?

I would ignore arm32 entirely and make things depend on ARM64 rather than ARM within the series here.

So are you saying I should remove the last part of the commit message ("Note that it does not seem to be possible to use this approach with arm,
so this is left alone"), or something else?

Regards,
SImon

#92 lore raw

Re: [PATCH 31/32] efi: arm: Simplify the crt0 file and update link script

Quoted 51 lines · Simon Glass

Hi Tom,

Quoted 48 lines · Tom Rini
Quoted 45 lines · Simon Glass

Hi Tom,

Quoted 27 lines · Tom Rini
Quoted 18 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 13 lines · Simon Glass

We don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.

Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.

Make some updates to the link-script for arm64, so this all works:

- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Note that it does not seem to be possible to use this approach with arm, so this is left alone.

Thanks for looking at all this stuff.

You're welcome.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Did you mean x86 in this last comment? I'm not sure about the rest, either way, so I'll leave it to others to comment on that.

No, I mean 32-bit ARM. For reasons I don't understand, it seems the toolchain doesn't support PE on 32-bit ARM.

Ah, OK. Were other parts of this series really laying the groundwork for EFI_APP with 32bit arm?

Not intentionally, since I was trying to get the series as small as possible and still actually get something that boots.

I'm not sure that anyone will want a 32-bit ARM EFI-app. I would much rather that we had it for completeness, but it seems that the binutils people were not that interested in it. What do you think?

Quoted 7 lines
Quoted 2 lines

I would ignore arm32 entirely and make things depend on ARM64 rather than ARM within the series here.

So are you saying I should remove the last part of the commit message ("Note that it does not seem to be possible to use this approach with arm,
so this is left alone"), or something else?

You should make sure that Kconfig entries depend on ARM64 not ARM and then commit messages should talk about arm64 or AArch64.

Signature · 1 line
Tom
#93 lore raw

PATCH 32/32 efi: arm: Add an EFI app for arm64

In reply to Simon Glass

Introduce an EFI app for arm64 and update the documentation.

Provide a value for LOAD_ADDR to avoid a link error.

---

 Kconfig                               |  1 +
 MAINTAINERS                           |  4 ++-
 arch/arm/dts/efi-arm_app.dts          | 31 ++++++++++++++++
 board/efi/Kconfig                     | 22 ++++++++++++
 board/efi/efi-arm_app/Kconfig         | 16 +++++++++
 board/efi/efi-arm_app/MAINTAINERS     | 13 +++++++
 board/efi/efi-arm_app/Makefile        |  5 +++
 board/efi/efi-arm_app/board.c         | 18 ++++++++++
 board/efi/efi-arm_app/efi-arm_app.env | 11 ++++++
 configs/efi-arm_app64_defconfig       | 51 +++++++++++++++++++++++++++
 doc/develop/uefi/u-boot_on_efi.rst    | 17 ++++-----
 lib/efi/Kconfig                       |  2 +-
 12 files changed, 181 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/dts/efi-arm_app.dts
 create mode 100644 board/efi/efi-arm_app/Kconfig
 create mode 100644 board/efi/efi-arm_app/MAINTAINERS
 create mode 100644 board/efi/efi-arm_app/Makefile
 create mode 100644 board/efi/efi-arm_app/board.c
 create mode 100644 board/efi/efi-arm_app/efi-arm_app.env
 create mode 100644 configs/efi-arm_app64_defconfig
Kconfig +1 -0
index 2e63896c477..e3c1b97c134 100644
@@ -551,6 +551,7 @@ config SYS_LOAD_ADDR
 	default 0x12000000 if ARCH_MX6 && !(MX6SL || MX6SLL  || MX6SX || MX6UL || MX6ULL)
 	default 0x80800000 if ARCH_MX7
 	default 0x90000000 if FSL_LSCH2 || FSL_LSCH3
+	default 0x02000000 if VENDOR_EFI
 	default 0x0 if ARCH_SC5XX
 	help
 	  Address in memory to use as the default safe load address.
MAINTAINERS +3 -1
index a8e81577090..04a1f50619f 100644
@@ -1066,12 +1066,14 @@ M:	Simon Glass <[email protected]>
 M:	Heinrich Schuchardt <[email protected]>
 S:	Maintained
 W:	https://docs.u-boot.org/en/latest/develop/uefi/u-boot_on_efi.html
+F:	board/efi/efi-arm_app
 F:	board/efi/efi-x86_app
+F:	configs/efi-arm_app*
 F:	configs/efi-x86_app*
 F:	doc/develop/uefi/u-boot_on_efi.rst
 F:	drivers/block/efi-media-uclass.c
 F:	drivers/block/sb_efi_media.c
-F:	lib/efi/efi_app.c
+F:	lib/efi/
 F:	scripts/build-efi.py
 F:	test/dm/efi_media.c
 
arch/arm/dts/efi-arm_app.dts new file +31 -0
new file mode 100644
index 00000000000..38cab04e510
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2015 Google, Inc
+ */
+
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
+
+/ {
+	model = "EFI ARM Application";
+	compatible = "efi,arm-app";
+
+	chosen {
+		stdout-path = &serial;
+	};
+
+	serial: serial {
+		compatible = "efi,uart";
+	};
+
+	reset {
+		compatible = "efi,reset";
+		bootph-all;
+	};
+	efi-fb {
+		compatible = "efi-fb";
+		bootph-some-ram;
+	};
+
+};
board/efi/Kconfig +22 -0
index 33bc364861a..75d272d2418 100644
@@ -45,4 +45,26 @@ source "board/efi/efi-x86_payload/Kconfig"
 
 endif  # X86
 
+if ARM
+
+choice
+	prompt "Mainboard model"
+	optional
+
+config TARGET_EFI_ARM_APP64
+	bool "64-bit efi application"
+	select EFI_APP
+	select ARM64
+	help
+	  This target is used for running U-Boot on top of EFI in 64-bit mode.
+	  In this case EFI does the early initialisation, and U-Boot
+	  takes over once the RAM, video and CPU are fully running.
+	  U-Boot is loaded as an application from EFI.
+
+endchoice
+
+source "board/efi/efi-arm_app/Kconfig"
+
+endif  # ARM
+
 endif  # VENDOR_EFI
board/efi/efi-arm_app/Kconfig new file +16 -0
new file mode 100644
index 00000000000..dc0b7df7829
@@ -0,0 +1,16 @@
+if EFI_APP
+
+config SYS_BOARD
+	default "efi-arm_app"
+
+config SYS_VENDOR
+	default "efi"
+
+config SYS_SOC
+	default "efi"
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+	def_bool y
+	imply VIDEO_EFI
+
+endif
board/efi/efi-arm_app/MAINTAINERS new file +13 -0
new file mode 100644
index 00000000000..3114db69a35
@@ -0,0 +1,13 @@
+EFI-ARM_APP32 BOARD
+M:	Simon Glass <[email protected]>
+S:	Maintained
+F:	board/efi/Kconfig
+F:	board/efi/efi-arm_app/
+F:	configs/efi-arm_app32_defconfig
+
+EFI-ARM_APP64 BOARD
+M:	Simon Glass <[email protected]>
+S:	Maintained
+F:	board/efi/Kconfig
+F:	board/efi/efi-arm_app/
+F:	configs/efi-arm_app64_defconfig
board/efi/efi-arm_app/Makefile new file +5 -0
new file mode 100644
index 00000000000..fc6ef159473
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2018, Bin Meng <[email protected]>
+
+obj-y	+= board.o
board/efi/efi-arm_app/board.c new file +18 -0
new file mode 100644
index 00000000000..239e1fbaba4
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2015 Google, Inc
+ */
+
+#include <init.h>
+
+struct mm_region *mem_map;
+
+int print_cpuinfo(void)
+{
+	return 0;
+}
+
+int board_init(void)
+{
+	return 0;
+}
board/efi/efi-arm_app/efi-arm_app.env new file +11 -0
new file mode 100644
index 00000000000..b28c15556de
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Environment file for ARM EFI app
+ *
+ * Copyright 2025, Simon Glass <[email protected]>
+ */
+
+/* common console settings */
+stdin=serial
+stdout=serial,vidconsole
+stderr=serial,vidconsole
configs/efi-arm_app64_defconfig new file +51 -0

51 lines not on this page · raw message

doc/develop/uefi/u-boot_on_efi.rst +9 -8
index 9d441cdc2c5..b1d5faa3463 100644
@@ -27,16 +27,17 @@ Running U-Boot on EFI is useful in several situations:
 
 Status
 ------
-Only x86 is supported at present. If you are using EFI on another architecture
-you may want to reconsider. However, much of the code is generic so could be
-ported.
+Only x86 and ARM64 are supported at present. If you are using EFI on another
+architecture you may want to reconsider. However, much of the code is generic so
+could be ported.
 
-U-Boot supports running as an EFI application for both 32- and 64-bit EFI.
+U-Boot supports running as an EFI application for both 32- and 64-bit EFI on
+x86, and for 64-bit on ARM.
 
-U-Boot supports building itself as a payload for either 32-bit or 64-bit EFI.
-U-Boot is packaged up and loaded in its entirety by EFI. Once started, U-Boot
-changes to 32-bit mode (currently) and takes over the machine. You can use
-devices, boot a kernel, etc.
+On x86, U-Boot supports building itself as a payload for either 32-bit or 64-bit
+EFI. U-Boot is packaged up and loaded in its entirety by EFI. Once started,
+U-Boot changes to 32-bit mode (currently) and takes over the machine. You can
+use devices, boot a kernel, etc.
 
 
 Build Instructions
lib/efi/Kconfig +1 -1
index 18f69bdcfbe..18b73965469 100644
@@ -17,7 +17,7 @@ choice
 
 config EFI_APP
 	bool "Support running as an EFI application"
-	depends on !ARM
+	depends on X86 || ARM
 	select CHARSET
 	help
 	  Build U-Boot as an application which can be started from EFI. This
Signature · 1 line
2.43.0
#94 lore raw

Re: [PATCH 32/32] efi: arm: Add an EFI app for arm64

Quoted 3 lines · Simon Glass

Introduce an EFI app for arm64 and update the documentation.

Provide a value for LOAD_ADDR to avoid a link error.

What's the link error?

[snip]

Quoted 6 lines
board/efi/Kconfig +0 -0
index 33bc364861a..75d272d2418 100644
@@ -45,4 +45,26 @@ source "board/efi/efi-x86_payload/Kconfig"
 

board/efi/Kconfig source "board/efi/efi-x86_payload/Kconfig" · line 55

Quoted 10 lines
board/efi/Kconfig +8 -0
 endif  # X86
 
+if ARM
+
+choice
+	prompt "Mainboard model"
+	optional
+
+config TARGET_EFI_ARM_APP64
+	bool "64-bit efi application"

Each of the targets should depend on the correct architecture and then we don't have duplicate choice/prompt.

Signature · 1 line
Tom
#95 lore raw
In reply to Simon Glass
Quoted 22 lines · Simon Glass

The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).

Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.

EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.

EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.

As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.

Quoted 6 lines

So this series adds an EFI app for 64-bit ARM.

Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.

Thank you Simon for going through this effort to generalize the EFI app.

The EFI app should build on all EFI architecture. Will you add RISC-V support, too?

Best regards

Heinrich

Quoted 98 lines

Simon Glass (32):
Convert build-efi script to Python
Makefile: Avoid using TEXT_BASE if not present
video: Move vesa_setup_video_priv() into its own file
video: Use a local mode_info struct in the EFI driver
lib: Provide fdtdec_get_pci_bar32() only with PCI enabled
scripts: Update build-efi to support building U-Boot
scripts: Update build-efi to support arm64
efi: Rename app and payload to include x86
efi: Allow board/efi Kconfig to be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
efi: x86: Rework VENDOR_EFI option to permit other archs
efi: x86: Allow setting the global_data pointer with EFI
efi: Tidy up setup of global_data
efi: Rename ImageBase to image_base
efi: lmb: Avoid access to _start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access to global_data for EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception code when running as an EFI app
efi: arm: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Select the EFI linker script for the app
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: Disable STATIC_RELA for the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64

  Kconfig                               |   1 +
  MAINTAINERS                           |   6 +-
  Makefile                              |   8 +-
  arch/Kconfig                          |   2 +
  arch/arm/Kconfig                      |   6 +-
  arch/arm/Makefile                     |   2 +
  arch/arm/config.mk                    |  12 ++
  arch/arm/cpu/armv8/Makefile           |   4 +-
  arch/arm/cpu/armv8/config.mk          |   7 +-
  arch/arm/dts/efi-arm_app.dts          |  31 +++
  arch/arm/include/asm/global_data.h    |  16 +-
  arch/arm/lib/Makefile                 |  12 +-
  arch/arm/lib/bootm.c                  |   7 +-
  arch/arm/lib/cache.c                  |   3 +
  arch/arm/lib/crt0_aarch64_efi.S       | 158 +++-----------
  arch/arm/lib/elf_aarch64_efi.lds      |  49 +++--
  arch/riscv/lib/crt0_riscv_efi.S       |  28 +--
  arch/x86/Kconfig                      |   4 +-
  arch/x86/cpu/efi/Makefile             |   1 -
  arch/x86/include/asm/global_data.h    |   7 +
  board/efi/Kconfig                     |  41 +++-
  board/efi/efi-arm_app/Kconfig         |  16 ++
  board/efi/efi-arm_app/MAINTAINERS     |  13 ++
  board/efi/efi-arm_app/Makefile        |   5 +
  board/efi/efi-arm_app/board.c         |  18 ++
  board/efi/efi-arm_app/efi-arm_app.env |  11 +
  board/efi/efi-x86_payload/Kconfig     |   2 +-
  common/board_f.c                      |   4 +-
  common/board_r.c                      |   9 +-
  configs/efi-arm_app64_defconfig       |  51 +++++
  configs/efi-x86_app32_defconfig       |   4 +-
  configs/efi-x86_app64_defconfig       |   4 +-
  configs/efi-x86_payload32_defconfig   |   4 +-
  configs/efi-x86_payload64_defconfig   |   4 +-
  doc/develop/uefi/u-boot_on_efi.rst    |  21 +-
  drivers/pci/pci_rom.c                 |  32 ---
  drivers/video/Makefile                |   2 +
  drivers/video/efi.c                   |   1 +
  drivers/video/vesa_helper.c           |  41 ++++
  include/asm-generic/sections.h        |   2 +
  include/vesa.h                        |   2 +
  lib/efi/Kconfig                       |   2 +-
  lib/efi/Makefile                      |   1 +
  lib/efi/efi_app.c                     |  13 +-
  {arch/x86/cpu => lib}/efi/sdram.c     |   1 -
  lib/fdtdec.c                          |   2 +
  lib/lmb.c                             |   3 +-
  scripts/build-efi.py                  | 293 ++++++++++++++++++++++++++
  scripts/build-efi.sh                  | 207 ------------------
  49 files changed, 719 insertions(+), 454 deletions(-)

create mode 100644 arch/arm/dts/efi-arm_app.dts create mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644 board/efi/efi-arm_app/board.c create mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig create mode 100644 drivers/video/vesa_helper.c rename {arch/x86/cpu => lib}/efi/sdram.c (94%) create mode 100755 scripts/build-efi.py
delete mode 100755 scripts/build-efi.sh

#96 lore raw

Hi Heinrich,

Quoted 24 lines · Heinrich Schuchardt
Quoted 22 lines · Simon Glass

The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).

Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.

EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.

EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.

As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.

Quoted 8 lines
Quoted 6 lines

So this series adds an EFI app for 64-bit ARM.

Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.

Thank you Simon for going through this effort to generalize the EFI app.

You're welcome.

Quoted 3 lines

The EFI app should build on all EFI architecture. Will you add RISC-V support, too?

Not in this series, but perhaps later.

Regards,
Simon