Skip to contentSkip to conversation

arm64 EFI stub

PATCH New Roy Franz 4 participants 8 messages Sep 26, 2014 – Oct 1, 2014

lore
Share & tools
lore

Roy Franz

author
#0 lore raw

PATCH v9 1/1 arm64 EFI stub

This patch series adds EFI boot support for arm64. A PE/COFF header is created in head.S, as there is no toolchain support for PE/COFF on arm64. This also has the advantage that the file is both an "Image" file and a PE/COFF executable - the same binary can be loaded and run either way. The EFI 'stub' code is a shim layer that serves as the loader for the XEN kernel in the EFI environment. The stub loads the dom0 kernel and initrd if required, and adds entries for them as well as for the EFI data structures into the device tree passed to XEN. Once the device tree is constructed, EFI boot services are exited, and the stub transfers control to the normal XEN entry point. The only indication XEN has that it was loaded via the stub is that the device tree contains EFI properties. This is all very similar to the arm/arm64 Linux kernel EFI stubs.

Based on staging tree a608c40d

Changes since v8:
* rebase to staging a608c40d to get already merged patches, now a single patch adding the ARM code remains.
* Add arch-private runtime.h files to arch/*/efi directories. ARM version is currently empty to allow unconditional inclusion by runtime.c, rather than #ifdef in runtime.c.
* Move x86 specific include of asm/mc146818rtc.h to x86 runtime.h
* Move x86 specific definition of efi_l4_pgtable to x86 runtime.h. This needs #ifndef COMPAT check, but I think this is cleaner long-term than an x86 #ifdef in runtime.c.
* move include of xen/bitops.h to proper alphabetized location.

Changes since v7:
* Some patches already accepted, no longer in series.
* Clean up blexit error messages (remove ERROR)
* don't process options for xsm/ramdisk modules
* Add comment explaining construction of module string, remove superfluous place_string() of empty string, only add options if present.
* remove bare extern rtc_lock declaration, use #ifdef to control x86 specific RTC include file.
* blank line addition in runtime.c

Changes since v6:
* Move pci unitialized buffer fix to first patch in series, restructured by Jan
* Move efi_l4_pgtable extern to efi.h
* Fix symlink creation in Makefile for common/efi files
* Use dt_set_cell to simplify fdt_set_reg() implementation
* move include of asm/fixmap.h back to boot.c
* formating fix in runtime.c

Changes since v5:
* FDT and ARM cache flushing patches removed, as those have been applied to master branch
* rebased to master that includes above changesets.
* Added new patch fixing bug in PCI rom scan code.
(separate patch since it is a bug fix)
* efi-boot.h files moved from global include directories to arch/*/efi directories, as that is the only place they are used.
* removed redundant newlines in blexit() calls
* removed uneccessary initializers.
* reverted string variable changes that where left over from other reverted changes.
* removed local memory map variables, no longer required.
* made symlinks from commone/efi relative
* simplify get_argv() call with NULL parameter
* rename efi_arch_memory to efi_arch_memory_setup
* fixed type of local 'i' variable in new arch functions. reviewed other local variables.
* fixed wstrlen coding style
* various formatting fixes - init ordering, remove declration reordering, blank lines, etc.
* moved x86 externs to appropriate global includes.
* fixed XXX placeholder in comments
* simplified ucode file handling, ignore anything after filename, as options not supported
* Added Acked-by lines for patches fully acked, or where minor changes were requested and made.

Changes since v4:
* Move runtime.c/compat.c/efi.h from arch/x86/efi to common/efi
* Create symbolic links at build time from common/efi to arch/xxx/efi
* Moved all non-VGA video code back to boot.c
* Cleaned up __init in forward declarations, moved declarations to common file
* Fixed type of i in efi_arch_process_memory_map()
* Added early/late arch cfg file functions - arm64 needs early, x86 wants late.
* Added #ifdefs to disable runtime services code that is not yet implemented for ARM (code moved back from arch specific file.)
Global variables are left, as this allows common code setting these in boot code to be left.
* just provide arch specific allocator for EFI memory map, not function returning the map.
* Renamed truncate_string() to split_string()
* Fixed up MBI static inilization comments in moved code.
* Added explanation of ARM config file ordering requirement to commit message and code.
* Added explanation of increase of NR_MEM_BANKS
* Variety of minor formating cleanups.
* Remove mem-reserve regions from DTB in addition to the memory banks. The EFI memory map is the only memory description that is used.

Changes since v3:
* Add symbolic link from common/efi/boot.c to arch/x86/efi/boot.c. This simplifies the build system changes and resolves the parallel build issues in v3. x86 EFI code build is unchanged, and ARM EFI code uses the normal common build structure. (This symlink seems to have confused git's moved file detection for boot.c)
* Fix XEN to be Xen throughout
* Fix spacing and missing blank lines between functions
* Add pseudo-prototype of efi_xen_start is head.S, change prototype to take pointer instead of integer to avoid cast, add comment explaining saving of x0
* Use uintptr_t in casts from uint to pointer for device tree.
* Change alignment requirements to 4k in PE/COFF header and alignment check in code.
* Rebased to latest master branch.

Changes since v2:
* Major refactor to use common EFI entry point and factor out arch specific code, rather than factoring out the common code.
* Update entire libfdt to v1.4.0 to provide fdt_create_empty_tree()

Changes since v1:
* Added common/efi directory for shared EFI code, and arch/arm/efi for arm-specfic code. Global build hacking of -fshort-wchar removed. arm32, arm64, and x86 with/without EFI enabled toolchain all build. The x86 build previously autodetected whether the EFI version should be built or not based on toolchain support. I couldn't get this working nicely with the common code, so for x86 I have the common code always build, and the EFI autodection works as normal for building the EFI version.
* Basic use of the EFI memory map instead of FDT based memory description. More work needed to resolve differences between FDT description of a small number of large memory banks with reserved regions, and EFI's potentially long list of available regions, which can be long.
* More refactoring of common EFI code to not directly exit using blexit(), as this broke the pre-linking targets. All shared code returns status, and it is up to the caller to exit and clean up.
* Reduced the number of patches. Refactoring of x86 code first, then moving all code to efi-shared.c in one patch.
* Fixed formatting/tab issues in new files, added Emacs footer.
* Fixed efi_get_memory_map to return NULL map pointer on error in addition to failed status.
* Added comments in head.S regarding PE/COFF specification, and 1:1 mapping used by EFI code.
* Updated device tree bindings to use new multiboot bindings. Since the stub is always built into XEN, we don't have to support older bindings.

Roy Franz (1):
Add ARM EFI boot support

 xen/arch/arm/Makefile               |   1 +
 xen/arch/arm/arm64/head.S           | 150 +++++++++-
 xen/arch/arm/efi/Makefile           |   4 +
 xen/arch/arm/efi/efi-boot.h         | 575 ++++++++++++++++++++++++++++++++++++
 xen/arch/arm/efi/runtime.h          |   1 +
 xen/arch/arm/xen.lds.S              |   1 +
 xen/arch/x86/efi/runtime.h          |   5 +
 xen/common/efi/boot.c               |  17 +-
 xen/common/efi/efi.h                |   2 +
 xen/common/efi/runtime.c            |  14 +-
 xen/include/asm-arm/arm64/efibind.h | 216 ++++++++++++++
 xen/include/asm-arm/efibind.h       |   2 +
 xen/include/asm-arm/setup.h         |   2 +-
 13 files changed, 981 insertions(+), 9 deletions(-)
 create mode 100644 xen/arch/arm/efi/Makefile
 create mode 100644 xen/arch/arm/efi/efi-boot.h
 create mode 100644 xen/arch/arm/efi/runtime.h
 create mode 100644 xen/arch/x86/efi/runtime.h
 create mode 100644 xen/include/asm-arm/arm64/efibind.h
 create mode 100644 xen/include/asm-arm/efibind.h
Signature · 1 line
2.1.0
author
#1 lore raw

PATCH v9 1/1 Add ARM EFI boot support

This patch adds EFI boot support for ARM based on the previous refactoring of the x86 EFI boot code. All ARM specific code is in the ARM efi-boot.h header file, with the main EFI entry point common/efi/boot.c. The PE/COFF header is open-coded in head.S, which allows us to have a single binary be both an EFI executable and a normal arm64 IMAGE file. There is currently no PE/COFF toolchain support for arm64, so it is not possible to create the PE/COFF header in the same manner as on x86. This also simplifies the build as compared to x86, as we always build the same executable, whereas x86 builds 2. An ARM version of efi-bind.h is added, which is based on the x86_64 version with the x86 specific portions removed. The Makefile in common/efi is different for x86 and ARM, as for ARM we always build in EFI support.
NR_MEM_BANKS is increased, as memory regions are now added from the UEFI memory map, rather than memory banks from a DTB. The UEFI memory map may be fragmented so a larger number of regions will be used.

---
 xen/arch/arm/Makefile               |   1 +
 xen/arch/arm/arm64/head.S           | 150 +++++++++-
 xen/arch/arm/efi/Makefile           |   4 +
 xen/arch/arm/efi/efi-boot.h         | 575 ++++++++++++++++++++++++++++++++++++
 xen/arch/arm/efi/runtime.h          |   1 +
 xen/arch/arm/xen.lds.S              |   1 +
 xen/arch/x86/efi/runtime.h          |   5 +
 xen/common/efi/boot.c               |  17 +-
 xen/common/efi/efi.h                |   2 +
 xen/common/efi/runtime.c            |  14 +-
 xen/include/asm-arm/arm64/efibind.h | 216 ++++++++++++++
 xen/include/asm-arm/efibind.h       |   2 +
 xen/include/asm-arm/setup.h         |   2 +-
 13 files changed, 981 insertions(+), 9 deletions(-)
 create mode 100644 xen/arch/arm/efi/Makefile
 create mode 100644 xen/arch/arm/efi/efi-boot.h
 create mode 100644 xen/arch/arm/efi/runtime.h
 create mode 100644 xen/arch/x86/efi/runtime.h
 create mode 100644 xen/include/asm-arm/arm64/efibind.h
 create mode 100644 xen/include/asm-arm/efibind.h
xen/arch/arm/Makefile +1 -0
index e557cac..f330302 100644
@@ -1,6 +1,7 @@
 subdir-$(arm32) += arm32
 subdir-$(arm64) += arm64
 subdir-y += platforms
+subdir-$(arm64) += efi
 
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += cpu.o
xen/arch/arm/arm64/head.S +147 -3

175 lines not on this page · raw message

xen/arch/arm/efi/Makefile new file +4 -0
new file mode 100644
index 0000000..e8a93e3
@@ -0,0 +1,4 @@
+CFLAGS += -fshort-wchar
+
+obj-y +=  boot.init.o runtime.o
+
xen/arch/arm/efi/efi-boot.h new file +575 -0

575 lines not on this page · raw message

xen/arch/arm/efi/runtime.h new file +1 -0
new file mode 100644
index 0000000..25afceb
@@ -0,0 +1 @@
+/* Placeholder for ARM-specific runtime include/declarations */
xen/arch/arm/xen.lds.S +1 -0
index 079e085..d8b0cfe 100644
@@ -135,6 +135,7 @@ SECTIONS
        *(.xsm_initcall.init)
        __xsm_initcall_end = .;
   } :text
+  __init_end_efi = .;
   . = ALIGN(STACK_SIZE);
   __init_end = .;
 
xen/arch/x86/efi/runtime.h new file +5 -0
new file mode 100644
index 0000000..0eb2fb9
@@ -0,0 +1,5 @@
+#include <asm/mc146818rtc.h>
+
+#ifndef COMPAT
+l4_pgentry_t *__read_mostly efi_l4_pgtable;
+#endif
xen/common/efi/boot.c +15 -2
index 3d3d76b..e1b243c 100644
@@ -2,6 +2,7 @@
 #include <efi/efiprot.h>
 #include <efi/efipciio.h>
 #include <public/xen.h>
+#include <xen/bitops.h>
 #include <xen/compile.h>
 #include <xen/ctype.h>
 #include <xen/dmi.h>
@@ -18,9 +19,16 @@
 #include <xen/string.h>
 #include <xen/stringify.h>
 #include <xen/vga.h>
+#ifdef CONFIG_X86
+/*
+ * Keep this arch-specific modified include in the common file, as moving
+ * it to the arch specific include file would obscure that special care is
+ * taken to include it with __ASSEMBLY__ defined.
+ */
 #define __ASSEMBLY__ /* avoid pulling in ACPI stuff (conflicts with EFI) */
 #include <asm/fixmap.h>
 #undef __ASSEMBLY__
+#endif
 
 /* Using SetVirtualAddressMap() is incompatible with kexec: */
 #undef USE_SET_VIRTUAL_ADDRESS_MAP
@@ -66,6 +74,7 @@ static bool_t read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,
                         struct file *file, char *options);
 static size_t wstrlen(const CHAR16 * s);
 static int set_color(u32 mask, int bpp, u8 *pos, u8 *sz);
+static bool_t match_guid(const EFI_GUID *guid1, const EFI_GUID *guid2);
 
 static EFI_BOOT_SERVICES *__initdata efi_bs;
 static EFI_HANDLE __initdata efi_ih;
@@ -121,7 +130,7 @@ static void __init DisplayUint(UINT64 Val, INTN Width)
     PrintStr(PrintString);
 }
 
-static size_t __init wstrlen(const CHAR16 *s)
+static size_t __init __maybe_unused wstrlen(const CHAR16 *s)
 {
     const CHAR16 *sc;
 
@@ -661,7 +670,7 @@ static void __init setup_efi_pci(void)
     efi_bs->FreePool(handles);
 }
 
-static int __init set_color(u32 mask, int bpp, u8 *pos, u8 *sz)
+static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz)
 {
    if ( bpp < 0 )
        return bpp;
@@ -986,8 +995,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 	       efi.smbios = (long)efi_ct[i].VendorTable;
     }
 
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
     if (efi.smbios != EFI_INVALID_TABLE_ADDR)
         dmi_efi_get_table((void *)(long)efi.smbios);
+#endif
 
     /* Collect PCI ROM contents. */
     setup_efi_pci();
@@ -1058,6 +1069,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     for( ; ; ); /* not reached */
 }
 
+#ifndef CONFIG_ARM /* TODO - runtime service support */
 #ifndef USE_SET_VIRTUAL_ADDRESS_MAP
 static __init void copy_mapping(unsigned long mfn, unsigned long end,
                                 bool_t (*is_valid)(unsigned long smfn,
@@ -1283,3 +1295,4 @@ void __init efi_init_memory(void)
         efi_l4_pgtable[i] = idle_pg_table[i];
 #endif
 }
+#endif
xen/common/efi/efi.h +2 -0
index a80d5f1..bee3b77 100644
@@ -28,7 +28,9 @@ extern EFI_RUNTIME_SERVICES *efi_rs;
 extern UINTN efi_memmap_size, efi_mdesc_size;
 extern void *efi_memmap;
 
+#ifdef CONFIG_X86
 extern l4_pgentry_t *efi_l4_pgtable;
+#endif
 
 extern const struct efi_pci_rom *efi_pci_roms;
 
xen/common/efi/runtime.c +11 -3
index 166852d..1c43d10 100644
@@ -1,20 +1,24 @@
 #include "efi.h"
+#include "runtime.h"
 #include <xen/cache.h>
 #include <xen/errno.h>
 #include <xen/guest_access.h>
 #include <xen/irq.h>
 #include <xen/time.h>
-#include <asm/mc146818rtc.h>
 
 DEFINE_XEN_GUEST_HANDLE(CHAR16);
 
 #ifndef COMPAT
 
+#ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
+const bool_t efi_enabled = 0;
+#else
 # include <asm/i387.h>
 # include <asm/xstate.h>
 # include <public/platform.h>
 
 const bool_t efi_enabled = 1;
+#endif
 
 unsigned int __read_mostly efi_num_ct;
 EFI_CONFIGURATION_TABLE *__read_mostly efi_ct;
@@ -24,7 +28,9 @@ unsigned int __read_mostly efi_fw_revision;
 const CHAR16 *__read_mostly efi_fw_vendor;
 
 EFI_RUNTIME_SERVICES *__read_mostly efi_rs;
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 static DEFINE_SPINLOCK(efi_rs_lock);
+#endif
 
 UINTN __read_mostly efi_memmap_size;
 UINTN __read_mostly efi_mdesc_size;
@@ -41,10 +47,9 @@ struct efi __read_mostly efi = {
 	.smbios = EFI_INVALID_TABLE_ADDR,
 };
 
-l4_pgentry_t *__read_mostly efi_l4_pgtable;
-
 const struct efi_pci_rom *__read_mostly efi_pci_roms;
 
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 unsigned long efi_rs_enter(void)
 {
     static const u16 fcw = FCW_DEFAULT;
@@ -134,8 +139,10 @@ void efi_reset_system(bool_t warm)
     printk(XENLOG_WARNING "EFI: could not reset system (%#lx)\n", status);
 }
 
+#endif /* CONFIG_ARM */
 #endif
 
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 int efi_get_info(uint32_t idx, union xenpf_efi_info *info)
 {
     unsigned int i, n;
@@ -545,3 +552,4 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op)
 
     return rc;
 }
+#endif
xen/include/asm-arm/arm64/efibind.h new file +216 -0

216 lines not on this page · raw message

xen/include/asm-arm/efibind.h new file +2 -0
new file mode 100644
index 0000000..09dca7a
@@ -0,0 +1,2 @@
+#include <xen/types.h>
+#include <asm/arm64/efibind.h>
xen/include/asm-arm/setup.h +1 -1
index 36e5704..ba5a67d 100644
@@ -3,7 +3,7 @@
 
 #include <public/version.h>
 
-#define NR_MEM_BANKS 8
+#define NR_MEM_BANKS 64
 
 #define MAX_MODULES 5 /* Current maximum useful modules */
 
Signature · 1 line
2.1.0
Acked-by on v9 1/1
#2 lore raw

Re: [PATCH for-4.5 V9] Add ARM EFI boot support

Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 27.09.14 at 00:25, <[email protected]> wrote:

This patch adds EFI boot support for ARM based on the previous refactoring of the x86 EFI boot code. All ARM specific code is in the ARM efi-boot.h header file, with the main EFI entry point common/efi/boot.c. The PE/COFF header is
open-coded in head.S, which allows us to have a single binary be both an EFI executable and a normal arm64 IMAGE file. There is currently no PE/COFF toolchain support for arm64, so it is not possible to create the PE/COFF header
in the same manner as on x86. This also simplifies the build as compared to x86, as we always build the same executable, whereas x86 builds 2. An ARM version of efi-bind.h is added, which is based on the x86_64 version with the x86 specific portions removed. The Makefile in common/efi is different for x86
and ARM, as for ARM we always build in EFI support.
NR_MEM_BANKS is increased, as memory regions are now added from the UEFI memory map,
rather than memory banks from a DTB. The UEFI memory map may be fragmented so a larger
number of regions will be used.

Quoted 1 line

For the non-ARM parts:

Two minor comments nevertheless:

Quoted 11 lines
xen/common/efi/boot.c +1 -0
@@ -2,6 +2,7 @@
 #include <efi/efiprot.h>
 #include <efi/efipciio.h>
 #include <public/xen.h>
+#include <xen/bitops.h>
 #include <xen/compile.h>
 #include <xen/ctype.h>
 #include <xen/dmi.h>

xen/common/efi/boot.c line 22

Quoted 4 lines
xen/common/efi/boot.c +1 -0
@@ -18,9 +19,16 @@
 #include <xen/string.h>
 #include <xen/stringify.h>
 #include <xen/vga.h>
+#ifdef CONFIG_X86

The context above shows xen/vga.h - this surely isn't needed in the common code anymore?

xen/include/asm-arm/arm64/efibind.h line 7

Quoted 10 lines
xen/include/asm-arm/arm64/efibind.h new file +7 -0
@@ -0,0 +1,216 @@
+/*++
+
+Copyright (c) 1998  Intel Corporation
+
+Module Name:
+
+    efefind.h

Is this so badly misspelled in the original?

Jan

Acked-by
#3 lore raw

Re: [PATCH for-4.5 V9] Add ARM EFI boot support

Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 27.09.14 at 00:25, <[email protected]> wrote:

This patch adds EFI boot support for ARM based on the previous refactoring of the x86 EFI boot code. All ARM specific code is in the ARM efi-boot.h header file, with the main EFI entry point common/efi/boot.c. The PE/COFF header is
open-coded in head.S, which allows us to have a single binary be both an EFI executable and a normal arm64 IMAGE file. There is currently no PE/COFF toolchain support for arm64, so it is not possible to create the PE/COFF header
in the same manner as on x86. This also simplifies the build as compared to x86, as we always build the same executable, whereas x86 builds 2. An ARM version of efi-bind.h is added, which is based on the x86_64 version with the x86 specific portions removed. The Makefile in common/efi is different for x86
and ARM, as for ARM we always build in EFI support.
NR_MEM_BANKS is increased, as memory regions are now added from the UEFI memory map,
rather than memory banks from a DTB. The UEFI memory map may be fragmented so a larger
number of regions will be used.

Quoted 4 lines
Quoted 1 line

For the non-ARM parts:

Konrad, we would really like to get this into 4.5. It will allow Xen to boot on EFI hardware which is already starting to appear in the field. It also unblocks other work such as the upstreaming of the Xen on ARM boot protocol work which Linaro are doing on grub.

All of the precursor refactoring is already in so the impact of this change on x86 is minimal. On the ARM side the changes to the common/non-EFI boot path are using well-worn techniques from the Linux equivalent so I think we can be reasonably confident of them, the remaining code is self contained and can't regress anything else.

Quoted 13 lines

Two minor comments nevertheless:

Quoted 10 lines
xen/common/efi/boot.c +1 -0
@@ -2,6 +2,7 @@
 #include <efi/efiprot.h>
 #include <efi/efipciio.h>
 #include <public/xen.h>
+#include <xen/bitops.h>
 #include <xen/compile.h>
 #include <xen/ctype.h>
 #include <xen/dmi.h>
Quoted 8 lines

xen/common/efi/boot.c line 22

Quoted 5 lines
xen/common/efi/boot.c +1 -0
@@ -18,9 +19,16 @@
 #include <xen/string.h>
 #include <xen/stringify.h>
 #include <xen/vga.h>
+#ifdef CONFIG_X86

The context above shows xen/vga.h - this surely isn't needed in the common code anymore?

Seems likely it isn't. Shall I fixup on commit (I always build test on commit, so if it breaks I will certainly catch it) or shall we fix in a followup?

Quoted 4 lines
Quoted 4 lines
xen/include/asm-arm/arm64/efibind.h new file +1 -0
@@ -0,0 +1,216 @@
+/*++
Quoted 8 lines

xen/include/asm-arm/arm64/efibind.h line 7

Quoted 6 lines
xen/include/asm-arm/arm64/efibind.h new file +6 -0
+
+Copyright (c) 1998  Intel Corporation
+
+Module Name:
+
+    efefind.h

Is this so badly misspelled in the original?

Apparently!

$ git grep efefind.h
xen/include/asm-x86/x86_64/efibind.h:    efefind.h

Shall I fix both cases on commit?

Ian.

#4 lore raw

Re: [PATCH for-4.5 V9] Add ARM EFI boot support

Quoted 34 lines · Ian Campbell
Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 27.09.14 at 00:25, <[email protected]> wrote:

This patch adds EFI boot support for ARM based on the previous refactoring of the x86 EFI boot code. All ARM specific code is in the ARM efi-boot.h header file, with the main EFI entry point common/efi/boot.c. The PE/COFF header is
open-coded in head.S, which allows us to have a single binary be both an EFI executable and a normal arm64 IMAGE file. There is currently no PE/COFF toolchain support for arm64, so it is not possible to create the PE/COFF header
in the same manner as on x86. This also simplifies the build as compared to x86, as we always build the same executable, whereas x86 builds 2. An ARM version of efi-bind.h is added, which is based on the x86_64 version with the x86 specific portions removed. The Makefile in common/efi is different for x86
and ARM, as for ARM we always build in EFI support.
NR_MEM_BANKS is increased, as memory regions are now added from the UEFI memory map,
rather than memory banks from a DTB. The UEFI memory map may be fragmented so a larger
number of regions will be used.

Quoted 4 lines
Quoted 1 line

For the non-ARM parts:

Konrad, we would really like to get this into 4.5. It will allow Xen to boot on EFI hardware which is already starting to appear in the field. It also unblocks other work such as the upstreaming of the Xen on ARM boot protocol work which Linaro are doing on grub.

Quoted 5 lines

All of the precursor refactoring is already in so the impact of this change on x86 is minimal. On the ARM side the changes to the common/non-EFI boot path are using well-worn techniques from the Linux equivalent so I think we can be reasonably confident of them, the remaining code is self contained and can't regress anything else.

Thank you for anticipating my questions and answering them :-)

Quoted 49 lines
Quoted 14 lines

Two minor comments nevertheless:

Quoted 10 lines
xen/common/efi/boot.c +1 -0
@@ -2,6 +2,7 @@
 #include <efi/efiprot.h>
 #include <efi/efipciio.h>
 #include <public/xen.h>
+#include <xen/bitops.h>
 #include <xen/compile.h>
 #include <xen/ctype.h>
 #include <xen/dmi.h>
Quoted 8 lines

xen/common/efi/boot.c line 22

Quoted 5 lines
xen/common/efi/boot.c +1 -0
@@ -18,9 +19,16 @@
 #include <xen/string.h>
 #include <xen/stringify.h>
 #include <xen/vga.h>
+#ifdef CONFIG_X86

The context above shows xen/vga.h - this surely isn't needed in the common code anymore?

Seems likely it isn't. Shall I fixup on commit (I always build test on commit, so if it breaks I will certainly catch it) or shall we fix in a followup?

Quoted 4 lines
Quoted 4 lines
xen/include/asm-arm/arm64/efibind.h new file +1 -0
@@ -0,0 +1,216 @@
+/*++
Quoted 8 lines

xen/include/asm-arm/arm64/efibind.h line 7

Quoted 6 lines
xen/include/asm-arm/arm64/efibind.h new file +6 -0
+
+Copyright (c) 1998  Intel Corporation
+
+Module Name:
+
+    efefind.h

Is this so badly misspelled in the original?

Apparently!

$ git grep efefind.h
xen/include/asm-x86/x86_64/efibind.h:    efefind.h

Shall I fix both cases on commit?

Ian.

author
#5 lore raw

Re: [PATCH for-4.5 V9] Add ARM EFI boot support

In reply to Ian Campbell
Quoted 62 lines · Ian Campbell
Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 27.09.14 at 00:25, <[email protected]> wrote:

This patch adds EFI boot support for ARM based on the previous refactoring of the x86 EFI boot code. All ARM specific code is in the ARM efi-boot.h header file, with the main EFI entry point common/efi/boot.c. The PE/COFF header is
open-coded in head.S, which allows us to have a single binary be both an EFI executable and a normal arm64 IMAGE file. There is currently no PE/COFF toolchain support for arm64, so it is not possible to create the PE/COFF header
in the same manner as on x86. This also simplifies the build as compared to x86, as we always build the same executable, whereas x86 builds 2. An ARM version of efi-bind.h is added, which is based on the x86_64 version with the x86 specific portions removed. The Makefile in common/efi is different for x86
and ARM, as for ARM we always build in EFI support.
NR_MEM_BANKS is increased, as memory regions are now added from the UEFI memory map,
rather than memory banks from a DTB. The UEFI memory map may be fragmented so a larger
number of regions will be used.

Quoted 4 lines
Quoted 1 line

For the non-ARM parts:

Konrad, we would really like to get this into 4.5. It will allow Xen to boot on EFI hardware which is already starting to appear in the field. It also unblocks other work such as the upstreaming of the Xen on ARM boot protocol work which Linaro are doing on grub.

All of the precursor refactoring is already in so the impact of this change on x86 is minimal. On the ARM side the changes to the common/non-EFI boot path are using well-worn techniques from the Linux equivalent so I think we can be reasonably confident of them, the remaining code is self contained and can't regress anything else.

Quoted 13 lines

Two minor comments nevertheless:

Quoted 10 lines
xen/common/efi/boot.c +1 -0
@@ -2,6 +2,7 @@
 #include <efi/efiprot.h>
 #include <efi/efipciio.h>
 #include <public/xen.h>
+#include <xen/bitops.h>
 #include <xen/compile.h>
 #include <xen/ctype.h>
 #include <xen/dmi.h>
Quoted 8 lines

xen/common/efi/boot.c line 22

Quoted 5 lines
xen/common/efi/boot.c +1 -0
@@ -18,9 +19,16 @@
 #include <xen/string.h>
 #include <xen/stringify.h>
 #include <xen/vga.h>
+#ifdef CONFIG_X86

The context above shows xen/vga.h - this surely isn't needed in the common code anymore?

Quoted 3 lines

Seems likely it isn't. Shall I fixup on commit (I always build test on commit, so if it breaks I will certainly catch it) or shall we fix in a followup?

It's not needed in boot.c, but is in x86/efi/efi-boot.h. It should have been moved along with the vga code. The following moves it from boot.c to x86/efi/efi-boot.h.

Ian - can you apply this fixup when you take the patch?

xen/arch/x86/efi/efi-boot.h +1 -0
index b44746f..82bb74a 100644
@@ -7,6 +7,7 @@
 #include <asm/edd.h>
 #include <asm/msr.h>
 #include <asm/processor.h>
+#include <xen/vga.h>
 
 static struct file __initdata ucode;
 static multiboot_info_t __initdata mbi = {
xen/common/efi/boot.c +0 -1
index e1b243c..f272171 100644
@@ -18,7 +18,6 @@
 #endif
 #include <xen/string.h>
 #include <xen/stringify.h>
-#include <xen/vga.h>
 #ifdef CONFIG_X86
 /*
  * Keep this arch-specific modified include in the common file, as moving
Quoted 23 lines
Quoted 13 lines

xen/include/asm-arm/arm64/efibind.h line 7

Quoted 11 lines
xen/include/asm-arm/arm64/efibind.h new file +7 -0
@@ -0,0 +1,216 @@
+/*++
+
+Copyright (c) 1998  Intel Corporation
+
+Module Name:
+
+    efefind.h

Is this so badly misspelled in the original?

Apparently!

$ git grep efefind.h
xen/include/asm-x86/x86_64/efibind.h:    efefind.h

Shall I fix both cases on commit?

Ian.

#6 lore raw

Re: [PATCH for-4.5 V9] Add ARM EFI boot support

xen/arch/x86/efi/efi-boot.h line 10

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 30.09.14 at 20:38, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +1 -0
@@ -7,6 +7,7 @@
 #include <asm/edd.h>
 #include <asm/msr.h>
 #include <asm/processor.h>
+#include <xen/vga.h>

Except that we commonly put xen/ includes ahead of asm/ ones.

Jan

#7 lore raw

Re: [PATCH for-4.5 V9] Add ARM EFI boot support

Quoted 10 lines · Jan Beulich

xen/arch/x86/efi/efi-boot.h line 10

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 30.09.14 at 20:38, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +1 -0
@@ -7,6 +7,7 @@
 #include <asm/edd.h>
 #include <asm/msr.h>
 #include <asm/processor.h>
+#include <xen/vga.h>

Except that we commonly put xen/ includes ahead of asm/ ones.

I made that change as I committed the patch and it passed my build tests so I pushed. Hope that's ok.

Ian.