[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH V4 15/15] Add ARM EFI boot support



Please use plain text in emails, no html.

On Thu, 11 Sep 2014, Roy Franz wrote:
> On Thu, Sep 11, 2014 at 5:49 PM, Stefano Stabellini 
> <stefano.stabellini@xxxxxxxxxxxxx> wrote:
>       On Tue, 9 Sep 2014, Roy Franz 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.
>       >
>       > Signed-off-by: Roy Franz <roy.franz@xxxxxxxxxx>
>       > ---
>       > config/arm64.mk          Â| Â1 +
>       >Â xen/arch/arm/arm64/head.SÂ Â Â Â Â Â| 150 ++++++++-
>       >Â xen/arch/arm/xen.lds.SÂ Â Â Â Â Â Â |Â Â1 +
>       > xen/common/Makefile        Â| Â1 +
>       > xen/common/efi/Makefile      Â| Â3 +
>       >Â xen/include/asm-arm/arm64/efibind.h | 216 +++++++++++++
>       > xen/include/asm-arm/efi-boot.h   | 630 
> ++++++++++++++++++++++++++++++++++++
>       > xen/include/asm-arm/efi.h     Â| 29 ++
>       > xen/include/asm-arm/efibind.h   Â| Â2 +
>       > xen/include/asm-arm/setup.h    Â| Â2 +-
>       >Â 10 files changed, 1031 insertions(+), 4 deletions(-)
>       >Â create mode 100644 xen/common/efi/Makefile
>       >Â create mode 100644 xen/include/asm-arm/arm64/efibind.h
>       >Â create mode 100644 xen/include/asm-arm/efi-boot.h
>       >Â create mode 100644 xen/include/asm-arm/efi.h
>       >Â create mode 100644 xen/include/asm-arm/efibind.h
>       >
>       > diff --git a/config/arm64.mk b/config/arm64.mk
>       > index 15b57a4..e6aab0e 100644
>       > --- a/config/arm64.mk
>       > +++ b/config/arm64.mk
>       > @@ -1,6 +1,7 @@
>       >Â CONFIG_ARM := y
>       >Â CONFIG_ARM_64 := y
>       >Â CONFIG_ARM_$(XEN_OS) := y
>       > +CONFIG_EFI := y
>       >
>       >Â CONFIG_XEN_INSTALL_SUFFIX :=
>       >
>       > diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
>       > index 43b5e72..158c102 100644
>       > --- a/xen/arch/arm/arm64/head.S
>       > +++ b/xen/arch/arm/arm64/head.S
>       > @@ -24,6 +24,8 @@
>       >Â #include <asm/page.h>
>       >Â #include <asm/asm_defns.h>
>       >Â #include <asm/early_printk.h>
>       > +#include <efi/efierr.h>
>       > +#include <asm/arm64/efibind.h>
>       >
>       >Â #define PT_PTÂ Â Â0xf7f /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=1 
> P=1 */
>       >Â #define PT_MEMÂ Â 0xf7d /* nG=1 AF=1 SH=11 AP=01 NS=1 ATTR=111 T=0 
> P=1 */
>       > @@ -104,8 +106,14 @@ GLOBAL(start)
>       >Â Â Â Â Â /*
>       >Â Â Â Â Â Â* DO NOT MODIFY. Image header expected by Linux 
> boot-loaders.
>       >Â Â Â Â Â Â*/
>       > -    b   Âreal_start     Â/* branch to kernel start, 
> magic */
>       > -    .long Â0          /* reserved */
>       > +efi_head:
>       > +Â Â Â Â /*
>       > +Â Â Â Â Â* This add instruction has no meaningful effect except that
>       > +Â Â Â Â Â* its opcode forms the magic "MZ" signature of a PE/COFF 
> file
>       > +Â Â Â Â Â* that is required for UEFI applications.
>       > +Â Â Â Â Â*/
>       > +    add  Âx13, x18, #0x16
>       > +    b   Âreal_start     Â/* branch to kernel start */
>       >     .quad Â0          /* Image load offset from start 
> of RAM */
>       >     .quad Â0          /* reserved */
>       >     .quad Â0          /* reserved */
>       > @@ -116,8 +124,113 @@ GLOBAL(start)
>       >     .byte Â0x52
>       >     .byte Â0x4d
>       >     .byte Â0x64
>       > -    .word Â0          /* reserved */
>       > +    .long Âpe_header - efi_head    /* Offset to the PE 
> header. */
>       > +
>       > +Â Â Â Â /*
>       > +    Â* Add the PE/COFF header to the file. The address of this 
> header
>       > +Â Â Â Â Â* is at offset 0x3c in the file, and is part of Linux 
> "Image"
>       > +    Â* header. The arm64 Linux Image format is designed to 
> support
>       > +Â Â Â Â Â* being both an 'Image' format binary and a PE/COFF binary.
>       > +Â Â Â Â Â* The PE/COFF format is defined by Microsoft, and is 
> available
>       > +Â Â Â Â Â* from: http://msdn.microsoft.com/en-us/gg463119.aspx
>       > +Â Â Â Â Â* Version 8.3 adds support for arm64 and UEFI usage.
>       > +Â Â Â Â Â*/
>       > +
>       > +    .align 3
>       > +pe_header:
>       > +    .ascii "PE"
>       > +    .short 0
>       > +coff_header:
>       > +    .short 0xaa64             /* AArch64 */
>       > +    .short 2               Â/* nr_sections */
>       > +    .long Â0               Â/* TimeDateStamp */
>       > +    .long Â0               Â/* 
> PointerToSymbolTable */
>       > +    .long Â1               Â/* NumberOfSymbols */
>       > +    .short section_table - optional_header /* 
> SizeOfOptionalHeader */
>       > +    .short 0x206             Â/* Characteristics. 
> */
>       > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* 
> IMAGE_FILE_DEBUG_STRIPPED | */
>       > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* 
> IMAGE_FILE_EXECUTABLE_IMAGE | */
>       > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* 
> IMAGE_FILE_LINE_NUMS_STRIPPED */
>       > +optional_header:
>       > +    .short 0x20b             Â/* PE32+ format */
>       > +    .byte Â0x02              /* 
> MajorLinkerVersion */
>       > +    .byte Â0x14              /* 
> MinorLinkerVersion */
>       > +    .long Â_end - real_start       Â/* SizeOfCode */
>       > +    .long Â0               Â/* 
> SizeOfInitializedData */
>       > +    .long Â0               Â/* 
> SizeOfUninitializedData */
>       > +    .long Âefi_start - efi_head      /* 
> AddressOfEntryPoint */
>       > +    .long Âreal_start - efi_head     Â/* BaseOfCode */
>       > +
>       > +extra_header_fields:
>       > +    .quad Â0               Â/* ImageBase */
>       > +    .long Â0x1000             /* SectionAlignment 
> (4 KByte) */
>       > +    .long Â0x8              Â/* FileAlignment */
>       > +    .short 0               Â/* 
> MajorOperatingSystemVersion */
>       > +    .short 0               Â/* 
> MinorOperatingSystemVersion */
>       > +    .short 0               Â/* MajorImageVersion 
> */
>       > +    .short 0               Â/* MinorImageVersion 
> */
>       > +    .short 0               Â/* 
> MajorSubsystemVersion */
>       > +    .short 0               Â/* 
> MinorSubsystemVersion */
>       > +    .long Â0               Â/* Win32VersionValue 
> */
>       > +
>       > +    .long Â_end - efi_head        Â/* SizeOfImage */
>       > +
>       > +Â Â Â Â /* Everything before the kernel image is considered part of 
> the header */
>       > +    .long Âreal_start - efi_head     Â/* SizeOfHeaders */
>       > +    .long Â0               Â/* CheckSum */
>       > +    .short 0xa              Â/* Subsystem (EFI 
> application) */
>       > +    .short 0               Â/* 
> DllCharacteristics */
>       > +    .quad Â0               Â/* 
> SizeOfStackReserve */
>       > +    .quad Â0               Â/* SizeOfStackCommit 
> */
>       > +    .quad Â0               Â/* SizeOfHeapReserve 
> */
>       > +    .quad Â0               Â/* SizeOfHeapCommit 
> */
>       > +    .long Â0               Â/* LoaderFlags */
>       > +    .long Â0x6              Â/* 
> NumberOfRvaAndSizes */
>       > +
>       > +    .quad Â0               Â/* ExportTable */
>       > +    .quad Â0               Â/* ImportTable */
>       > +    .quad Â0               Â/* ResourceTable */
>       > +    .quad Â0               Â/* ExceptionTable */
>       > +    .quad Â0               Â/* 
> CertificationTable */
>       > +    .quad Â0               Â/* 
> BaseRelocationTable */
>       > +
>       > +Â Â Â Â /* Section table */
>       > +section_table:
>       >
>       > +Â Â Â Â /*
>       > +Â Â Â Â Â* The EFI application loader requires a relocation section
>       > +    Â* because EFI applications must be relocatable. This is a
>       > +Â Â Â Â Â* dummy section as far as we are concerned.
>       > +Â Â Â Â Â*/
>       > +    .ascii ".reloc"
>       > +    .byte Â0
>       > +    .byte Â0               Â/* end of 0 padding 
> of section name */
>       > +    .long Â0
>       > +    .long Â0
>       > +    .long Â0               Â/* SizeOfRawData */
>       > +    .long Â0               Â/* PointerToRawData 
> */
>       > +    .long Â0               Â/* 
> PointerToRelocations */
>       > +    .long Â0               Â/* 
> PointerToLineNumbers */
>       > +    .short 0               Â/* 
> NumberOfRelocations */
>       > +    .short 0               Â/* 
> NumberOfLineNumbers */
>       > +    .long Â0x42100040           /* Characteristics 
> (section flags) */
>       > +
>       > +
>       > +    .ascii ".text"
>       > +    .byte Â0
>       > +    .byte Â0
>       > +    .byte Â0               Â/* end of 0 padding 
> of section name */
>       > +    .long Â_end - real_start       Â/* VirtualSize */
>       > +    .long Âreal_start - efi_head     Â/* VirtualAddress */
>       > +    .long Â__init_end_efi - real_start  Â/* SizeOfRawData */
>       > +    .long Âreal_start - efi_head     Â/* PointerToRawData 
> */
>       > +
>       > +    .long Â0        /* PointerToRelocations (0 for 
> executables) */
>       > +    .long Â0        /* PointerToLineNumbers (0 for 
> executables) */
>       > +    .short 0        /* NumberOfRelocations (0 for 
> executables) */
>       > +    .short 0        /* NumberOfLineNumbers (0 for 
> executables) */
>       > +    .long Â0xe0500020   Â/* Characteristics (section flags) 
> */
>       > +    .align 5
>       >Â real_start:
>       >     msr ÂDAIFSet, 0xf     Â/* Disable all interrupts */
>       >
>       > @@ -617,6 +730,37 @@ putn:Â Âret
>       >Â ENTRY(lookup_processor_type)
>       >     mov x0, #0
>       >Â Â Â Â Â ret
>       > +/*
>       > + *Â Function to transition from EFI loader in C, to Xen entry point.
>       > + *Â void noreturn efi_xen_start(void *fdt_ptr);
>       > + */
>       > +ENTRY(efi_xen_start)
>       > +Â Â Â Â /*
>       > +Â Â Â Â Â* Turn off cache and MMU as Xen expects. EFI enables them, 
> but also
>       > +Â Â Â Â Â* mandates a 1:1 (unity) VA->PA mapping, so we can turn off 
> the
>       > +Â Â Â Â Â* MMU while executing EFI code before entering Xen.
>       > +Â Â Â Â Â* The EFI loader calls this to start Xen.
>       > +Â Â Â Â Â* Preserve x0 (fdf pointer) across call to 
> __flush_dcache_all,
>       > +Â Â Â Â Â* restore for entry into Xen.
>       > +Â Â Â Â Â*/
>       > +    mov Âx20, x0
>       > +    bl  __flush_dcache_all
>       > +    ic  ialluis
>       > +
>       > +Â Â Â Â /* Turn off Dcache and MMU */
>       > +    mrs Âx0, sctlr_el2
>       > +    bic Âx0, x0, #1 << 0    /* clear SCTLR.M */
>       > +    bic Âx0, x0, #1 << 2    /* clear SCTLR.C */
> 
> dsb?
> 
> The dsb is done at the end of Â__flush_dcache_all
 
I think this would be to make sure __flush_dcache_all reads the correct
arguments. We do the same when enabling dcache.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.