arm64 EFI stub
v7 cover 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.
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 (14):
x86/EFI: fix freeing of uninitialized pointer
move x86 EFI boot/runtime code to common/efi
Move x86 specific funtions/variables to arch header
create arch functions to allocate memory for and process EFI memory
map.
Add architecture functions for pre/post ExitBootServices Add efi_arch_cfg_file_early/late() to handle arch specific cfg file
fields
Add efi_arch_handle_cmdline() for processing commandline Move x86 specific disk probing code
Create arch functions for console and video init
Add efi_arch_memory() for arch specific memory setup
Add arch specific module handling to read_file()
Add several misc. arch functions for EFI boot code.
Add efi_arch_use_config_file() function to control use of config file Add ARM EFI boot support
.gitignore | 8 +
xen/Makefile | 3 +
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/xen.lds.S | 1 +
xen/arch/x86/efi/efi-boot.h | 632 +++++++++++++++++++++++++
xen/{arch/x86 => common}/efi/boot.c | 819 ++++++++-------------------------
xen/{arch/x86 => common}/efi/compat.c | 0
xen/{arch/x86 => common}/efi/efi.h | 2 +
xen/{arch/x86 => common}/efi/runtime.c | 16 +-
xen/include/asm-arm/arm64/efibind.h | 216 +++++++++
xen/include/asm-arm/efibind.h | 2 +
xen/include/asm-arm/setup.h | 2 +-
xen/include/asm-x86/processor.h | 1 +
xen/include/xen/kernel.h | 2 +-
17 files changed, 1804 insertions(+), 630 deletions(-)
create mode 100644 xen/arch/arm/efi/Makefile
create mode 100644 xen/arch/arm/efi/efi-boot.h
create mode 100644 xen/arch/x86/efi/efi-boot.h
rename xen/{arch/x86 => common}/efi/boot.c (58%)
rename xen/{arch/x86 => common}/efi/compat.c (100%)
rename xen/{arch/x86 => common}/efi/efi.h (97%)
rename xen/{arch/x86 => common}/efi/runtime.c (98%)
create mode 100644 xen/include/asm-arm/arm64/efibind.h
create mode 100644 xen/include/asm-arm/efibind.hSignature · 1 line
2.1.0
PATCH v7 1/14 x86/EFI: fix freeing of uninitialized pointer
The only valid response from the LocateHandle() call is EFI_BUFFER_TOO_SMALL, so exit if we get anything else. We pass a 0 size/NULL pointer buffer, so the only other returns we will get is an error. Return right away as there is nothing to do. Also return if there is an error allocating the buffer, as the previous code path also allowed for an undefined pointer to be freed.
Re-structure the change.
--- xen/arch/x86/efi/boot.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
xen/arch/x86/efi/boot.c +6 -5
@@ -595,11 +595,12 @@ static void __init setup_efi_pci(void)struct efi_pci_rom *last =NULL ; status = efi_bs->LocateHandle (ByProtocol, &pci_guid,NULL , &size,NULL ); -if ( status ==EFI_BUFFER_TOO_SMALL ) - status = efi_bs->AllocatePool (EfiLoaderData, size, (void **)&handles); -if ( !EFI_ERROR (status) ) - status = efi_bs->LocateHandle (ByProtocol, &pci_guid,NULL , &size, - handles); +if ( status !=EFI_BUFFER_TOO_SMALL ) +return ; + status = efi_bs->AllocatePool (EfiLoaderData, size, (void **)&handles); +if (EFI_ERROR (status) ) +return ; + status = efi_bs->LocateHandle (ByProtocol, &pci_guid,NULL , &size, handles);if (EFI_ERROR (status) ) size =0 ;
Signature · 1 line
2.1.0
PATCH v7 2/14 move x86 EFI boot/runtime code to common/efi
In reply to Roy FranzThis moves the EFI boot and runtime services code to the common/efi directory. This code is symbolicly linked back into the arch/x86/efi directory where it is built if a build-time check for PE/COFF support in the toolchain passes. In the PE/COFF supporting case, both the EFI executable and the normal Xen image (with stubbed EFI functions) are built. We can't use the normal common build infrastructure since we are building two versions at the same time, with different EFI related code in each. No code changes, just file movement and make updates. The files are symbolicly linked at build time back toe the original arch/x86/efi directory. This is in preparation for adding ARM EFI support where much of these files can be shared.
---
.gitignore | 4 ++++
xen/Makefile | 3 +++
xen/{arch/x86 => common}/efi/boot.c | 0
xen/{arch/x86 => common}/efi/compat.c | 0
xen/{arch/x86 => common}/efi/efi.h | 0
xen/{arch/x86 => common}/efi/runtime.c | 0
6 files changed, 7 insertions(+)
rename xen/{arch/x86 => common}/efi/boot.c (100%)
rename xen/{arch/x86 => common}/efi/compat.c (100%)
rename xen/{arch/x86 => common}/efi/efi.h (100%)
rename xen/{arch/x86 => common}/efi/runtime.c (100%).gitignore +4 -0
@@ -254,6 +254,10 @@ xen/arch/x86/efi.lds xen/arch/x86/efi/check.efi xen/arch/x86/efi/disabled xen/arch/x86/efi/mkreloc +xen/arch/x86/efi/boot.c +xen/arch/x86/efi/runtime.c +xen/arch/x86/efi/compat.c +xen/arch/x86/efi/efi.h xen/ddb/* xen/include/headers.chk xen/include/asm
xen/Makefile +3 -0
@@ -100,6 +100,9 @@ $(TARGET): delete-unfresh-files $(MAKE) -C tools $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm + [ -e arch/$(TARGET_ARCH)/efi ] && for f in boot.c runtime.c compat.c efi.h;\ + do ln -nsf ../../../common/efi/$$f arch/$(TARGET_ARCH)/efi/; done;\ + /bin/true $(MAKE) -f $(BASEDIR)/Rules.mk -C include $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s $(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h
xen/common/efi/boot.c renamed from xen/arch/x86/efi/boot.c +0 -0
xen/common/efi/compat.c renamed from xen/arch/x86/efi/compat.c +0 -0
xen/common/efi/efi.h renamed from xen/arch/x86/efi/efi.h +0 -0
xen/common/efi/runtime.c renamed from xen/arch/x86/efi/runtime.c +0 -0
Signature · 1 line
2.1.0
PATCH v7 3/14 Move x86 specific funtions/variables to arch header
In reply to Roy FranzMove the global variables and functions that can be moved as-is from the common boot.c file to the x86 implementation header file.
--- xen/arch/x86/efi/efi-boot.h | 129 +++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 145 +++++----------------------------------- xen/include/asm-x86/processor.h | 1 + xen/include/xen/kernel.h | 2 +- 4 files changed, 146 insertions(+), 131 deletions(-) create mode 100644 xen/arch/x86/efi/efi-boot.h
xen/arch/x86/efi/efi-boot.h new file +129 -0
@@ -0,0 +1,129 @@ +/* +* Architecture specific implementation for EFI boot code. This file +* is intended to be included by common/efi/boot.c _only_, and +* therefore can define arch specific global variables. +*/ +#include <asm/e820.h> +#include <asm/edd.h> +#include <asm/msr.h> +#include <asm/processor.h> + +static struct file __initdata ucode; +static multiboot_info_t __initdata mbi = { + .flags =MBI_MODULES |MBI_LOADERNAME +}; +static module_t __initdata mb_modules[3 ]; + +static void __init edd_put_string (u8 *dst,size_t n,const char *src) +{ +while ( n-- && *src ) + *dst++ = *src++; +if ( *src ) +PrintErrMesg (L"Internal error populating EDD info" , +EFI_BUFFER_TOO_SMALL ); +while ( n-- ) + *dst++ =' ' ; +} +#define edd_put_string (d, s) edd_put_string(d, ARRAY_SIZE(d), s) + +extern const intpte_t __page_tables_start[], __page_tables_end[]; +#define in_page_tables (v) ((intpte_t *)(v) >= __page_tables_start && \ + (intpte_t *)(v) < __page_tables_end) + +#define PE_BASE_RELOC_ABS 0 +#define PE_BASE_RELOC_HIGHLOW 3 +#define PE_BASE_RELOC_DIR64 10 + +extern const struct pe_base_relocs { +u32 rva; +u32 size; +u16 entries[]; +} __base_relocs_start[], __base_relocs_end[]; + +static void __init efi_arch_relocate_image (unsigned long delta) +{ +const struct pe_base_relocs *base_relocs; + +for ( base_relocs = __base_relocs_start; base_relocs < __base_relocs_end; ) + { +unsigned int i, n; + + n = (base_relocs->size -sizeof (*base_relocs)) / +sizeof (*base_relocs->entries); +for ( i =0 ; i < n; ++i ) + { +unsigned long addr = xen_phys_start + base_relocs->rva + + (base_relocs->entries[i] &0xfff ); + +switch ( base_relocs->entries[i] >>12 ) + { +case PE_BASE_RELOC_ABS : +break ; +case PE_BASE_RELOC_HIGHLOW : +if ( delta ) + { + *(u32 *)addr += delta; +if (in_page_tables (addr) ) + *(u32 *)addr += xen_phys_start; + } +break ; +case PE_BASE_RELOC_DIR64 : +if ( delta ) + { + *(u64 *)addr += delta; +if (in_page_tables (addr) ) + *(intpte_t *)addr += xen_phys_start; + } +break ; +default : +blexit (L"Unsupported relocation type" ); + } + } + base_relocs = (const void *)(base_relocs->entries + i + (i &1 )); + } +} + +extern const s32 __trampoline_rel_start[], __trampoline_rel_stop[]; +extern const s32 __trampoline_seg_start[], __trampoline_seg_stop[]; + +static void __init relocate_trampoline (unsigned long phys) +{ +const s32 *trampoline_ptr; + + trampoline_phys = phys; +/* Apply relocations to trampoline. */ +for ( trampoline_ptr = __trampoline_rel_start; + trampoline_ptr < __trampoline_rel_stop; + ++trampoline_ptr ) + *(u32 *)(*trampoline_ptr + (long )trampoline_ptr) += phys; +for ( trampoline_ptr = __trampoline_seg_start; + trampoline_ptr < __trampoline_seg_stop; + ++trampoline_ptr ) + *(u16 *)(*trampoline_ptr + (long )trampoline_ptr) = phys >>4 ; +} + +static void __init place_string (u32 *addr,const char *s) +{ +static char *__initdata alloc = start; + +if ( s && *s ) + { +size_t len1 =strlen (s) +1 ; +const char *old = (char *)(long )*addr; +size_t len2 = *addr ?strlen (old) +1 :0 ; + + alloc -= len1 + len2; +/* +* Insert new string before already existing one. This is needed +* for options passed on the command line to override options from +* the configuration file. +*/ +memcpy (alloc, s, len1); +if ( *addr ) + { + alloc[len1 -1 ] =' ' ; +memcpy (alloc + len1, old, len2); + } + } + *addr = (long )alloc; +}
xen/common/efi/boot.c +15 -130
208 lines not on this page · raw message
xen/include/asm-x86/processor.h +1 -0
@@ -199,6 +199,7 @@ extern void set_cpuid_faulting(bool_t enable);extern u64 host_pat;extern bool_t opt_cpu_info; +extern u32 cpuid_ext_features;/* Maximum width of physical addresses supported by the hardware */ extern unsigned int paddr_bits;
xen/include/xen/kernel.h +1 -1
@@ -65,7 +65,7 @@1 ; \ }) -extern char _start[], _end[]; +extern char _start[], _end[], start[];#define is_kernel (p) ({ \ char *__p = (char *)(unsigned long)(p); \ (__p >= _start) && (__p < _end); \
Signature · 1 line
2.1.0
PATCH v7 4/14 create arch functions to allocate memory for and process EFI memory map.
In reply to Roy FranzThe memory used to store the EFI memory map is allocated in an architecture specific way, and the processing of the memory map itself uses x86 specific data structures. This patch adds architecture specific funtions so each architecture can provide its own implementation.
--- xen/arch/x86/efi/efi-boot.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 62 ++++----------------------------------- 2 files changed, 77 insertions(+), 56 deletions(-)
xen/arch/x86/efi/efi-boot.h +71 -0
@@ -127,3 +127,74 @@ static void __init place_string(u32 *addr, const char *s) } *addr = (long )alloc; } + +static void __init efi_arch_process_memory_map (EFI_SYSTEM_TABLE *SystemTable, +void *map, +UINTN map_size, +UINTN desc_size, +UINT32 desc_ver) +{ +struct e820entry *e; +unsigned int i; + +/* Populate E820 table and check trampoline area availability. */ + e = e820map -1 ; +for ( i =0 ; i < map_size; i += desc_size ) + { +EFI_MEMORY_DESCRIPTOR *desc = map + i; +u64 len = desc->NumberOfPages <<EFI_PAGE_SHIFT ; +u32 type; + +switch ( desc->Type ) + { +default : + type =E820_RESERVED ; +break ; +case EfiConventionalMemory: +case EfiBootServicesCode: +case EfiBootServicesData: +if ( !trampoline_phys && desc->PhysicalStart + len <=0x100000 && + len >= cfg.size && desc->PhysicalStart + len > cfg.addr ) + cfg.addr = (desc->PhysicalStart + len - cfg.size) &PAGE_MASK ; +/* fall through */ +case EfiLoaderCode: +case EfiLoaderData: +if ( desc->Attribute &EFI_MEMORY_WB ) + type =E820_RAM ; +else +case EfiUnusableMemory: + type =E820_UNUSABLE ; +break ; +case EfiACPIReclaimMemory: + type =E820_ACPI ; +break ; +case EfiACPIMemoryNVS: + type =E820_NVS ; +break ; + } +if ( e820nr && type == e->type && + desc->PhysicalStart == e->addr + e->size ) + e->size += len; +else if ( !len || e820nr >=E820MAX ) +continue ; +else + { + ++e; + e->addr = desc->PhysicalStart; + e->size = len; + e->type = type; + ++e820nr; + } + } + +} + +static void *__init efi_arch_allocate_mmap_buffer (UINTN map_size) +{ +place_string (&mbi.mem_upper,NULL ); + mbi.mem_upper -= map_size; + mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR ); +if ( mbi.mem_upper < xen_phys_start ) +return NULL ; +return (void *)(long )mbi.mem_upper; +}
xen/common/efi/boot.c +6 -56
86 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v7 5/14 Add architecture functions for pre/post ExitBootServices
In reply to Roy FranzThe UEFI ExitBootServices function is invoked to transition the system to the 'runtime' mode of operation, and is done right before transitioning from the EFI loader code into Xen proper. x86 does some arch specific memory management (trampoline) before exit boot services, and the code that transitions from the EFI application state to Xen is architecture specific. This patch adds two functions, one pre and one post ExitBootServices to allow each architecture to to handle these cases in a customized manner.
--- xen/arch/x86/efi/efi-boot.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 42 ++----------------------------------- 2 files changed, 52 insertions(+), 40 deletions(-)
xen/arch/x86/efi/efi-boot.h +50 -0
@@ -198,3 +198,53 @@ static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size)return NULL ;return (void *)(long )mbi.mem_upper; } + +static void __init efi_arch_pre_exit_boot (void ) +{ +if ( !trampoline_phys ) + { +if ( !cfg.addr ) +blexit (L"No memory for trampoline" ); +relocate_trampoline (cfg.addr); + } +} + +static void __init noreturnefi_arch_post_exit_boot (void ) +{ +u64 efer; + +efi_arch_relocate_image (__XEN_VIRT_START - xen_phys_start); +memcpy ((void *)trampoline_phys, trampoline_start, cfg.size); + +/* Set system registers and transfer control. */ + asmvolatile ("pushq $0\n\tpopfq" ); +rdmsrl (MSR_EFER , efer); + efer |=EFER_SCE ; +if ( cpuid_ext_features & (1 << (X86_FEATURE_NX &0x1f )) ) + efer |=EFER_NX ; +wrmsrl (MSR_EFER , efer); +write_cr0 (X86_CR0_PE |X86_CR0_MP |X86_CR0_ET |X86_CR0_NE |X86_CR0_WP | +X86_CR0_AM |X86_CR0_PG ); + asmvolatile ("mov %[cr4], %%cr4\n\t" +"mov %[cr3], %%cr3\n\t" +"movabs $__start_xen, %[rip]\n\t" +"lgdt gdt_descr(%%rip)\n\t" +"mov stack_start(%%rip), %%rsp\n\t" +"mov %[ds], %%ss\n\t" +"mov %[ds], %%ds\n\t" +"mov %[ds], %%es\n\t" +"mov %[ds], %%fs\n\t" +"mov %[ds], %%gs\n\t" +"movl %[cs], 8(%%rsp)\n\t" +"mov %[rip], (%%rsp)\n\t" +"lretq %[stkoff]-16" + : [rip]"=&r" (efer/* any dead 64-bit variable */ ) + : [cr3]"r" (idle_pg_table), + [cr4]"r" (mmu_cr4_features), + [cs]"ir" (__HYPERVISOR_CS), + [ds]"r" (__HYPERVISOR_DS), + [stkoff]"i" (STACK_SIZE -sizeof (struct cpu_info )), +"D" (&mbi) + :"memory" ); +for ( ; ; );/* not reached */ +}
xen/common/efi/boot.c +2 -40
60 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v7 6/14 Add efi_arch_cfg_file_early/late() to handle arch specific cfg file fields
In reply to Roy FranzDifferent architectures have some different configuration file fields that need to be handled. In particular, x86 has ucode and ARM has device tree files to be loaded. These arch specific functions is used to allow each architecture to implement these features in arch specific code. Early/late versions are provided, as ARM needs to process the DTB entry first, and x86 wants to process the ucode entry last as it is the smallest allocation.
--- xen/arch/x86/efi/efi-boot.h | 20 ++++++++++++++++++++ xen/common/efi/boot.c | 21 ++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-)
xen/arch/x86/efi/efi-boot.h +20 -0
@@ -248,3 +248,23 @@ static void __init noreturn efi_arch_post_exit_boot(void) : "memory" );for ( ; ; );/* not reached */ } + +static void __init efi_arch_cfg_file_early (EFI_FILE_HANDLE dir_handle,char *section) +{ +} + +static void __init efi_arch_cfg_file_late (EFI_FILE_HANDLE dir_handle,char *section) +{ +union string name; + + name.s =get_value (&cfg, section,"ucode" ); +if ( !name.s ) + name.s =get_value (&cfg,"global" ,"ucode" ); +if ( name.s ) + { +microcode_set_module (mbi.mods_count); +split_value (name.s); +read_file (dir_handle,s2w (&name), &ucode); + efi_bs->FreePool (name.w); + } +}
xen/common/efi/boot.c +10 -11
@@ -57,6 +57,12 @@ static void DisplayUint(UINT64 Val, INTN Width);static CHAR16 *wstrcpy (CHAR16 *d,const CHAR16 *s);static void noreturnblexit (const CHAR16 *str);static void PrintErrMesg (const CHAR16 *mesg,EFI_STATUS ErrCode); +static char *get_value (const struct file *cfg,const char *section, +const char *item); +static void split_value (char *s); +static CHAR16 *s2w (union string *str); +static bool_t read_file (EFI_FILE_HANDLE dir_handle,CHAR16 *name, +struct file *file);static EFI_BOOT_SERVICES *__initdata efi_bs;static EFI_HANDLE __initdata efi_ih;
@@ -846,6 +852,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) }if ( !name.s )blexit (L"No Dom0 kernel image specified." ); + +efi_arch_cfg_file_early (dir_handle, section.s); +split_value (name.s);read_file (dir_handle,s2w (&name), &kernel); efi_bs->FreePool (name.w);
@@ -863,17 +872,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_bs->FreePool (name.w); } - name.s =get_value (&cfg, section.s,"ucode" ); -if ( !name.s ) - name.s =get_value (&cfg,"global" ,"ucode" ); -if ( name.s ) - { -microcode_set_module (mbi.mods_count); -split_value (name.s); -read_file (dir_handle,s2w (&name), &ucode); - efi_bs->FreePool (name.w); - } - name.s =get_value (&cfg, section.s,"xsm" );if ( name.s ) {
@@ -912,6 +910,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) cols = rows = depth =0 ; } } +efi_arch_cfg_file_late (dir_handle, section.s); efi_bs->FreePages (cfg.addr,PFN_UP (cfg.size)); cfg.addr =0 ;
Signature · 1 line
2.1.0
PATCH v7 7/14 Add efi_arch_handle_cmdline() for processing commandline
In reply to Roy FranzAdd arch function for processing the Xen commandline and updating internal structures.
--- xen/arch/x86/efi/efi-boot.h | 34 ++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 37 +++++++++---------------------------- 2 files changed, 43 insertions(+), 28 deletions(-)
xen/arch/x86/efi/efi-boot.h +34 -0
@@ -268,3 +268,37 @@ static void __init efi_arch_cfg_file_late(EFI_FILE_HANDLE dir_handle, char *sect efi_bs->FreePool (name.w); } } + +static void __init efi_arch_handle_cmdline (CHAR16 *image_name, +CHAR16 *cmdline_options, +char *cfgfile_options) +{ +union string name; + +if ( cmdline_options ) + { + name.w = cmdline_options; +w2s (&name); +place_string (&mbi.cmdline, name.s); + } +if ( cfgfile_options ) +place_string (&mbi.cmdline, cfgfile_options); +/* Insert image name last, as it gets prefixed to the other options. */ +if ( image_name ) + { + name.w = image_name; +w2s (&name); + } +else + name.s ="xen" ; +place_string (&mbi.cmdline, name.s); + +if ( mbi.cmdline ) + mbi.flags |=MBI_CMDLINE ; +/* +* These must not be initialized statically, since the value must +* not get relocated when processing base relocations later. +*/ + mbi.boot_loader_name = (long )"EFI" ; + mbi.mods_addr = (long )mb_modules; +}
xen/common/efi/boot.c +9 -28
@@ -61,6 +61,7 @@ static char *get_value(const struct file *cfg, const char *section, const char *item);static void split_value (char *s);static CHAR16 *s2w (union string *str); +static char *w2s (const union string *str);static bool_t read_file (EFI_FILE_HANDLE dir_handle,CHAR16 *name,struct file *file);
@@ -261,7 +262,8 @@ static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode) }static unsigned int __init get_argv (unsigned int argc,CHAR16 **argv, -CHAR16 *cmdline,UINTN cmdsize) +CHAR16 *cmdline,UINTN cmdsize, +CHAR16 **options) {CHAR16 *ptr = (CHAR16 *)(argv + argc +1 ), *prev =NULL ;bool_t prev_sep = TRUE;
@@ -287,10 +289,8 @@ static unsigned int __init get_argv(unsigned int argc, CHAR16 **argv, ++argc; else if ( prev && wstrcmp(prev, L"--") == 0 ) { -union string rest = { .w = cmdline }; - - --argv; -place_string (&mbi.cmdline,w2s (&rest)); +if ( options ) + *options = cmdline;break ; } else
@@ -666,7 +666,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)EFI_LOADED_IMAGE *loaded_image;EFI_STATUS status;unsigned int i, argc; -CHAR16 **argv, *file_name, *cfg_file_name =NULL ; +CHAR16 **argv, *file_name, *cfg_file_name =NULL , *options =NULL ;UINTN cols, rows, depth, size, map_key, info_size, gop_mode = ~0 ;EFI_HANDLE *handles =NULL ;EFI_SHIM_LOCK_PROTOCOL *shim_lock;
@@ -704,14 +704,14 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) dir_handle =get_parent_handle (loaded_image, &file_name); argc =get_argv (0 ,NULL , loaded_image->LoadOptions, - loaded_image->LoadOptionsSize); + loaded_image->LoadOptionsSize,NULL );if ( argc >0 && efi_bs->AllocatePool (EfiLoaderData, (argc +1 ) *sizeof (*argv) + loaded_image->LoadOptionsSize, (void **)&argv) ==EFI_SUCCESS )get_argv (argc, argv, loaded_image->LoadOptions, - loaded_image->LoadOptionsSize); + loaded_image->LoadOptionsSize, &options);else argc =0 ;for ( i =1 ; i < argc; ++i )
@@ -881,17 +881,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } name.s =get_value (&cfg, section.s,"options" ); -if ( name.s ) -place_string (&mbi.cmdline, name.s); -/* Insert image name last, as it gets prefixed to the other options. */ -if ( argc ) - { - name.w = *argv; -w2s (&name); - } -else - name.s ="xen" ; -place_string (&mbi.cmdline, name.s); +efi_arch_handle_cmdline (argc ? *argv :NULL , options, name.s); cols = rows = depth =0 ;if ( !base_video )
@@ -958,15 +948,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } } -if ( mbi.cmdline ) - mbi.flags |=MBI_CMDLINE ; -/* -* These must not be initialized statically, since the value must -* not get relocated when processing base relocations below. -*/ - mbi.boot_loader_name = (long )"EFI" ; - mbi.mods_addr = (long )mb_modules; -/* Collect EDD info. */ BUILD_BUG_ON (offsetof(struct edd_info , edd_device_params) !=EDDEXTSIZE );BUILD_BUG_ON (sizeof (struct edd_device_params ) !=EDDPARMSIZE );
Signature · 1 line
2.1.0
PATCH v7 8/14 Move x86 specific disk probing code
In reply to Roy FranzMove x86 specific disk (EDD) probing to arch specific file. This code is x86 only and relates to legacy BIOS handling of disk drives.
--- xen/arch/x86/efi/efi-boot.h | 152 ++++++++++++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 144 +---------------------------------------- 2 files changed, 153 insertions(+), 143 deletions(-)
xen/arch/x86/efi/efi-boot.h +152 -0
@@ -302,3 +302,155 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name, mbi.boot_loader_name = (long )"EFI" ; mbi.mods_addr = (long )mb_modules; } + +static void __init efi_arch_edd (void ) +{ +static EFI_GUID __initdata bio_guid =BLOCK_IO_PROTOCOL ; +static EFI_GUID __initdata devp_guid =DEVICE_PATH_PROTOCOL ; +EFI_HANDLE *handles =NULL ; +unsigned int i; +UINTN size; +EFI_STATUS status; + +/* Collect EDD info. */ +BUILD_BUG_ON (offsetof(struct edd_info , edd_device_params) !=EDDEXTSIZE ); +BUILD_BUG_ON (sizeof (struct edd_device_params ) !=EDDPARMSIZE ); + size =0 ; + status = efi_bs->LocateHandle (ByProtocol, &bio_guid,NULL , &size,NULL ); +if ( status ==EFI_BUFFER_TOO_SMALL ) + status = efi_bs->AllocatePool (EfiLoaderData, size, (void **)&handles); +if ( !EFI_ERROR (status) ) + status = efi_bs->LocateHandle (ByProtocol, &bio_guid,NULL , &size, + handles); +if (EFI_ERROR (status) ) + size =0 ; +for ( i =0 ; i < size /sizeof (*handles); ++i ) + { +EFI_BLOCK_IO *bio; +EFI_DEV_PATH_PTR devp; +struct edd_info *info = boot_edd_info + boot_edd_info_nr; +struct edd_device_params *params = &info->edd_device_params; +enum { root, acpi, pci, ctrlr } state = root; + + status = efi_bs->HandleProtocol (handles[i], &bio_guid, (void **)&bio); +if (EFI_ERROR (status) || + bio->Media->RemovableMedia || + bio->Media->LogicalPartition ) +continue ; +if ( boot_edd_info_nr <EDD_INFO_MAX ) + { + info->device =0x80 + boot_edd_info_nr;/* fake */ + info->version =0x11 ; + params->length = offsetof(struct edd_device_params , dpte_ptr); + params->number_of_sectors = bio->Media->LastBlock +1 ; + params->bytes_per_sector = bio->Media->BlockSize; + params->dpte_ptr = ~0 ; + } + ++boot_edd_info_nr; + status = efi_bs->HandleProtocol (handles[i], &devp_guid, + (void **)&devp); +if (EFI_ERROR (status) ) +continue ; +for ( ; !IsDevicePathEnd (devp.DevPath); + devp.DevPath =NextDevicePathNode (devp.DevPath) ) + { +switch (DevicePathType (devp.DevPath) ) + { +const u8 *p; + +case ACPI_DEVICE_PATH : +if ( state != root || boot_edd_info_nr >EDD_INFO_MAX ) +break ; +switch (DevicePathSubType (devp.DevPath) ) + { +case ACPI_DP : +if ( devp.Acpi->HID !=EISA_PNP_ID (0xA03 ) && + devp.Acpi->HID !=EISA_PNP_ID (0xA08 ) ) +break ; + params->interface_path.pci.bus = devp.Acpi->UID; + state = acpi; +break ; +case EXPANDED_ACPI_DP : +/* XXX */ +break ; + } +break ; +case HARDWARE_DEVICE_PATH : +if ( state != acpi || +DevicePathSubType (devp.DevPath) !=HW_PCI_DP || + boot_edd_info_nr >EDD_INFO_MAX ) +break ; + state = pci; +edd_put_string (params->host_bus_type,"PCI" ); + params->interface_path.pci.slot = devp.Pci->Device; + params->interface_path.pci.function = devp.Pci->Function; +break ; +case MESSAGING_DEVICE_PATH : +if ( state != pci || boot_edd_info_nr >EDD_INFO_MAX ) +break ; + state = ctrlr; +switch (DevicePathSubType (devp.DevPath) ) + { +case MSG_ATAPI_DP : +edd_put_string (params->interface_type,"ATAPI" ); + params->interface_path.pci.channel = + devp.Atapi->PrimarySecondary; + params->device_path.atapi.device = devp.Atapi->SlaveMaster; + params->device_path.atapi.lun = devp.Atapi->Lun; +break ; +case MSG_SCSI_DP : +edd_put_string (params->interface_type,"SCSI" ); + params->device_path.scsi.id = devp.Scsi->Pun; + params->device_path.scsi.lun = devp.Scsi->Lun; +break ; +case MSG_FIBRECHANNEL_DP : +edd_put_string (params->interface_type,"FIBRE" ); + params->device_path.fibre.wwid = devp.FibreChannel->WWN; + params->device_path.fibre.lun = devp.FibreChannel->Lun; +break ; +case MSG_1394_DP : +edd_put_string (params->interface_type,"1394" ); + params->device_path.i1394.eui = devp.F1394->Guid; +break ; +case MSG_USB_DP : +case MSG_USB_CLASS_DP : +edd_put_string (params->interface_type,"USB" ); +break ; +case MSG_I2O_DP : +edd_put_string (params->interface_type,"I2O" ); + params->device_path.i2o.identity_tag = devp.I2O->Tid; +break ; +default : +continue ; + } + info->version =0x30 ; + params->length =sizeof (struct edd_device_params ); + params->key =0xbedd ; + params->device_path_info_length = +sizeof (struct edd_device_params ) - + offsetof(struct edd_device_params , key); +for ( p = (const u8 *)¶ms->key; p < ¶ms->checksum; ++p ) + params->checksum -= *p; +break ; +case MEDIA_DEVICE_PATH : +if (DevicePathSubType (devp.DevPath) ==MEDIA_HARDDRIVE_DP && + devp.HardDrive->MBRType ==MBR_TYPE_PCAT && + boot_mbr_signature_nr <EDD_MBR_SIG_MAX ) + { +struct mbr_signature *sig = boot_mbr_signature + + boot_mbr_signature_nr; + + sig->device =0x80 + boot_edd_info_nr;/* fake */ +memcpy (&sig->signature, devp.HardDrive->Signature, +sizeof (sig->signature)); + ++boot_mbr_signature_nr; + } +break ; + } + } + } +if ( handles ) + efi_bs->FreePool (handles); +if ( boot_edd_info_nr >EDD_INFO_MAX ) + boot_edd_info_nr =EDD_INFO_MAX ; +}
xen/common/efi/boot.c +1 -143
156 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v7 9/14 Create arch functions for console and video init
In reply to Roy FranzAdd arch functions for text console and graphics initialization, and move VGA specific code to x86 architecture file.
--- xen/arch/x86/efi/efi-boot.h | 75 +++++++++++++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 69 ++--------------------------------------- 2 files changed, 78 insertions(+), 66 deletions(-)
xen/arch/x86/efi/efi-boot.h +75 -0
@@ -454,3 +454,78 @@ static void __init efi_arch_edd(void)if ( boot_edd_info_nr >EDD_INFO_MAX ) boot_edd_info_nr =EDD_INFO_MAX ; } + +static void __init efi_arch_console_init (UINTN cols,UINTN rows) +{ + vga_console_info.video_type =XEN_VGATYPE_TEXT_MODE_3 ; + vga_console_info.u.text_mode_3.columns = cols; + vga_console_info.u.text_mode_3.rows = rows; + vga_console_info.u.text_mode_3.font_height =16 ; +} + +static void __init efi_arch_video_init (EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, +UINTN info_size, +EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info) +{ +int bpp =0 ; + +switch ( mode_info->PixelFormat ) + { +case PixelRedGreenBlueReserved8BitPerColor: + vga_console_info.u.vesa_lfb.red_pos =0 ; + vga_console_info.u.vesa_lfb.red_size =8 ; + vga_console_info.u.vesa_lfb.green_pos =8 ; + vga_console_info.u.vesa_lfb.green_size =8 ; + vga_console_info.u.vesa_lfb.blue_pos =16 ; + vga_console_info.u.vesa_lfb.blue_size =8 ; + vga_console_info.u.vesa_lfb.rsvd_pos =24 ; + vga_console_info.u.vesa_lfb.rsvd_size =8 ; + bpp =32 ; +break ; +case PixelBlueGreenRedReserved8BitPerColor: + vga_console_info.u.vesa_lfb.red_pos =16 ; + vga_console_info.u.vesa_lfb.red_size =8 ; + vga_console_info.u.vesa_lfb.green_pos =8 ; + vga_console_info.u.vesa_lfb.green_size =8 ; + vga_console_info.u.vesa_lfb.blue_pos =0 ; + vga_console_info.u.vesa_lfb.blue_size =8 ; + vga_console_info.u.vesa_lfb.rsvd_pos =24 ; + vga_console_info.u.vesa_lfb.rsvd_size =8 ; + bpp =32 ; +break ; +case PixelBitMask: + bpp =set_color (mode_info->PixelInformation.RedMask, bpp, + &vga_console_info.u.vesa_lfb.red_pos, + &vga_console_info.u.vesa_lfb.red_size); + bpp =set_color (mode_info->PixelInformation.GreenMask, bpp, + &vga_console_info.u.vesa_lfb.green_pos, + &vga_console_info.u.vesa_lfb.green_size); + bpp =set_color (mode_info->PixelInformation.BlueMask, bpp, + &vga_console_info.u.vesa_lfb.blue_pos, + &vga_console_info.u.vesa_lfb.blue_size); + bpp =set_color (mode_info->PixelInformation.ReservedMask, bpp, + &vga_console_info.u.vesa_lfb.rsvd_pos, + &vga_console_info.u.vesa_lfb.rsvd_size); +if ( bpp >0 ) +break ; +/* fall through */ +default : +PrintErr (L"Current graphics mode is unsupported!\r\n" ); + bpp =0 ; +break ; + } +if ( bpp >0 ) + { + vga_console_info.video_type =XEN_VGATYPE_EFI_LFB ; + vga_console_info.u.vesa_lfb.gbl_caps =2 ;/* possibly non-VGA */ + vga_console_info.u.vesa_lfb.width = + mode_info->HorizontalResolution; + vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution; + vga_console_info.u.vesa_lfb.bits_per_pixel = bpp; + vga_console_info.u.vesa_lfb.bytes_per_line = + (mode_info->PixelsPerScanLine * bpp +7 ) >>3 ; + vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase; + vga_console_info.u.vesa_lfb.lfb_size = + (gop->Mode->FrameBufferSize +0xffff ) >>16 ; + } +}
xen/common/efi/boot.c +3 -66
93 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v7 10/14 Add efi_arch_memory() for arch specific memory setup
In reply to Roy FranzThis patch adds efi_arch_memory() to allow each architecture a hook to use for do memory setup. x86 uses this for trampoline memory setup and some pagetable setup.
--- xen/arch/x86/efi/efi-boot.h | 35 +++++++++++++++++++++++++++++++++++ xen/common/efi/boot.c | 29 +---------------------------- 2 files changed, 36 insertions(+), 28 deletions(-)
xen/arch/x86/efi/efi-boot.h +35 -0
@@ -529,3 +529,38 @@ static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, (gop->Mode->FrameBufferSize +0xffff ) >>16 ; } } + +static void __init efi_arch_memory_setup (void ) +{ +unsigned int i; +EFI_STATUS status; + +/* Allocate space for trampoline (in first Mb). */ + cfg.addr =0x100000 ; + cfg.size = trampoline_end - trampoline_start; + status = efi_bs->AllocatePages (AllocateMaxAddress, EfiLoaderData, +PFN_UP (cfg.size), &cfg.addr); +if ( status ==EFI_SUCCESS ) +relocate_trampoline (cfg.addr); +else + { + cfg.addr =0 ; +PrintStr (L"Trampoline space cannot be allocated; will try fallback.\r\n" ); + } + +/* Initialise L2 identity-map and boot-map page table entries (16MB). */ +for ( i =0 ; i <8 ; ++i ) + { +unsigned int slot = (xen_phys_start >>L2_PAGETABLE_SHIFT ) + i; +paddr_t addr = slot <<L2_PAGETABLE_SHIFT ; + + l2_identmap[slot] =l2e_from_paddr (addr,PAGE_HYPERVISOR |_PAGE_PSE); + slot &=L2_PAGETABLE_ENTRIES -1 ; + l2_bootmap[slot] =l2e_from_paddr (addr, __PAGE_HYPERVISOR|_PAGE_PSE); + } +/* Initialise L3 boot-map page directory entries. */ + l3_bootmap[l3_table_offset (xen_phys_start)] = +l3e_from_paddr ((UINTN )l2_bootmap, __PAGE_HYPERVISOR); + l3_bootmap[l3_table_offset (xen_phys_start + (8 <<L2_PAGETABLE_SHIFT ) -1 )] = +l3e_from_paddr ((UINTN )l2_bootmap, __PAGE_HYPERVISOR); +}
xen/common/efi/boot.c +1 -28
@@ -995,34 +995,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)PrintStr (newline); } -/* Allocate space for trampoline (in first Mb). */ - cfg.addr =0x100000 ; - cfg.size = trampoline_end - trampoline_start; - status = efi_bs->AllocatePages (AllocateMaxAddress, EfiLoaderData, -PFN_UP (cfg.size), &cfg.addr); -if ( status ==EFI_SUCCESS ) -relocate_trampoline (cfg.addr); -else - { - cfg.addr =0 ; -PrintStr (L"Trampoline space cannot be allocated; will try fallback.\r\n" ); - } - -/* Initialise L2 identity-map and boot-map page table entries (16MB). */ -for ( i =0 ; i <8 ; ++i ) - { -unsigned int slot = (xen_phys_start >>L2_PAGETABLE_SHIFT ) + i; -paddr_t addr = slot <<L2_PAGETABLE_SHIFT ; - - l2_identmap[slot] =l2e_from_paddr (addr,PAGE_HYPERVISOR |_PAGE_PSE); - slot &=L2_PAGETABLE_ENTRIES -1 ; - l2_bootmap[slot] =l2e_from_paddr (addr, __PAGE_HYPERVISOR|_PAGE_PSE); - } -/* Initialise L3 boot-map page directory entries. */ - l3_bootmap[l3_table_offset (xen_phys_start)] = -l3e_from_paddr ((UINTN )l2_bootmap, __PAGE_HYPERVISOR); - l3_bootmap[l3_table_offset (xen_phys_start + (8 <<L2_PAGETABLE_SHIFT ) -1 )] = -l3e_from_paddr ((UINTN )l2_bootmap, __PAGE_HYPERVISOR); +efi_arch_memory_setup ();if ( gop ) {
Signature · 1 line
2.1.0
PATCH v7 11/14 Add arch specific module handling to read_file()
In reply to Roy FranzEach architecture tracks modules differently internally, so add efi_arch_handle_module() routine to enable the common code to invoke the proper handling of modules as the are loaded. ucode module handling is changed to not process remainder of string after filename as options, since ucode module does not take options.
--- xen/arch/x86/efi/efi-boot.h | 31 ++++++++++++++++-- xen/common/efi/boot.c | 77 ++++++++++++++++++++++++++++----------------- 2 files changed, 78 insertions(+), 30 deletions(-)
xen/arch/x86/efi/efi-boot.h +29 -2
@@ -263,8 +263,8 @@ static void __init efi_arch_cfg_file_late(EFI_FILE_HANDLE dir_handle, char *sectif ( name.s ) {microcode_set_module (mbi.mods_count); -split_value (name.s); -read_file (dir_handle,s2w (&name), &ucode); +split_string (name.s); +read_file (dir_handle,s2w (&name), &ucode,NULL ); efi_bs->FreePool (name.w); } }
@@ -564,3 +564,30 @@ static void __init efi_arch_memory_setup(void) l3_bootmap[l3_table_offset (xen_phys_start + (8 <<L2_PAGETABLE_SHIFT ) -1 )] =l3e_from_paddr ((UINTN )l2_bootmap, __PAGE_HYPERVISOR); } + +static void __init efi_arch_handle_module (struct file *file,const CHAR16 *name, +char *options) +{ +union string local_name; +void *ptr; + +/* +* Make a copy, as conversion is destructive, and caller still wants +* wide string available after this call returns. +*/ +if ( efi_bs->AllocatePool (EfiLoaderData, (wstrlen (name) +1 ) *sizeof (*name), + &ptr) !=EFI_SUCCESS ) +blexit (L"ERROR Unable to allocate string buffer" ); + + local_name.w = ptr; +wstrcpy (local_name.w, name); +w2s (&local_name); + +place_string (&mb_modules[mbi.mods_count].string, options); +place_string (&mb_modules[mbi.mods_count].string,"" ); +place_string (&mb_modules[mbi.mods_count].string, local_name.s); + mb_modules[mbi.mods_count].mod_start = file->addr >>PAGE_SHIFT ; + mb_modules[mbi.mods_count].mod_end = file->size; + ++mbi.mods_count; + efi_bs->FreePool (ptr); +}
xen/common/efi/boot.c +49 -28
167 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [PATCH for-4.5 V7 11/14] Add arch specific module handling to read_file()
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 580
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +7
-0+/* +* Make a copy, as conversion is destructive, and caller still wants +* wide string available after this call returns. +*/ +if ( efi_bs->AllocatePool (EfiLoaderData, (wstrlen (name) +1 ) *sizeof (*name), + &ptr) !=EFI_SUCCESS ) +blexit (L"ERROR Unable to allocate string buffer" );
Kind of disappointing: You said you'd drop these ERROR prefixes, but this is the second one I come across. I'm ditching them in preparation for committing.
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 587
Quoted 7 lines
xen/arch/x86/efi/efi-boot.h +7
-0+ + local_name.w = ptr; +wstrcpy (local_name.w, name); +w2s (&local_name); + +place_string (&mb_modules[mbi.mods_count].string, options); +place_string (&mb_modules[mbi.mods_count].string,"" );
Hmm, this one's still here, and I don't recall having seen an explanation for it. I guess I need to cut off committing at this patch then...
xen/common/efi/boot.c efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) · line 886
Quoted 8 lines
xen/common/efi/boot.c +2
-2@@ -861,16 +882,16 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) name.s =get_value (&cfg, section.s,"ramdisk" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &ramdisk); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &ramdisk, option_str);
As said before, this should be NULL as not having and never going to have a consumer. Whether you keep the XSM one below is - as also said before - up to you.
Jan
Quoted 13 lines
xen/common/efi/boot.c +2
-2efi_bs->FreePool (name.w); } name.s =get_value (&cfg, section.s,"xsm" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &xsm); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &xsm, option_str); efi_bs->FreePool (name.w); }
Re: [PATCH for-4.5 V7 11/14] Add arch specific module handling to read_file()
Quoted 13 lines · Jan Beulich
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 580
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +7
-0+/* +* Make a copy, as conversion is destructive, and caller still wants +* wide string available after this call returns. +*/ +if ( efi_bs->AllocatePool (EfiLoaderData, (wstrlen (name) +1 ) *sizeof (*name), + &ptr) !=EFI_SUCCESS ) +blexit (L"ERROR Unable to allocate string buffer" );Kind of disappointing: You said you'd drop these ERROR prefixes, but this is the second one I come across. I'm ditching them in preparation for committing.
Quoted 12 lines
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 587
Quoted 7 lines
xen/arch/x86/efi/efi-boot.h +7
-0+ + local_name.w = ptr; +wstrcpy (local_name.w, name); +w2s (&local_name); + +place_string (&mb_modules[mbi.mods_count].string, options); +place_string (&mb_modules[mbi.mods_count].string,"" );Hmm, this one's still here, and I don't recall having seen an explanation for it. I guess I need to cut off committing at this patch then...
I apologize - I missed adding the above to items to my checklist, and was likely too focused
on getting an updated set out yesterday so these items got missed.
Quoted 13 lines
xen/common/efi/boot.c efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) · line 886
Quoted 8 lines
xen/common/efi/boot.c +2
-2@@ -861,16 +882,16 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) name.s =get_value (&cfg, section.s,"ramdisk" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &ramdisk); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &ramdisk, option_str);As said before, this should be NULL as not having and never going to have a consumer. Whether you keep the XSM one below is - as also said before - up to you.
Quoted 1 line
Jan
I'll drop the options for ramdisk and xsm. I addresses the options on the ucode module,
which is what you had previously commented on.
I will rebase on staging ( or master if they get pushed there today) to get the patches you have already committed.
Roy
Quoted 16 lines
Quoted 14 lines
xen/common/efi/boot.c +2
-2efi_bs->FreePool (name.w); } name.s =get_value (&cfg, section.s,"xsm" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &xsm); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &xsm, option_str); efi_bs->FreePool (name.w); }
Re: [PATCH for-4.5 V7 11/14] Add arch specific module handling to read_file()
Quoted 14 lines · Roy Franz
Quoted 13 lines · Jan Beulich
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 580
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +7
-0+/* +* Make a copy, as conversion is destructive, and caller still wants +* wide string available after this call returns. +*/ +if ( efi_bs->AllocatePool (EfiLoaderData, (wstrlen (name) +1 ) *sizeof (*name), + &ptr) !=EFI_SUCCESS ) +blexit (L"ERROR Unable to allocate string buffer" );Kind of disappointing: You said you'd drop these ERROR prefixes, but this is the second one I come across. I'm ditching them in preparation for committing.
Quoted 12 lines
Quoted 12 lines
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 587
Quoted 7 lines
xen/arch/x86/efi/efi-boot.h +7
-0+ + local_name.w = ptr; +wstrcpy (local_name.w, name); +w2s (&local_name); + +place_string (&mb_modules[mbi.mods_count].string, options); +place_string (&mb_modules[mbi.mods_count].string,"" );Hmm, this one's still here, and I don't recall having seen an explanation for it. I guess I need to cut off committing at this patch then...
The original code put the entire line from the config file into the mb_modules[i].string field,
which consists of the filename and module options, space separated. This was done at the
same time the filename was extracted to pass to read_file().
My refactored version of read_file() takes a filename and option string as separate arguments,
and then after the file is loaded and address known, the module info is updated. The efi_arch_handle_module() gets the filename and options separately, and the above place_string()
commands reconstruct the the single string of filename followed by options that is placed
in the mb_modules[i].string field.
I will add a comment to this effect, and also only add the options if present, since for
several module types options will be NULL.
Quoted 45 lines
I apologize - I missed adding the above to items to my checklist, and was likely too focused
on getting an updated set out yesterday so these items got missed.Quoted 13 lines
xen/common/efi/boot.c efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) · line 886
Quoted 8 lines
xen/common/efi/boot.c +2
-2@@ -861,16 +882,16 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) name.s =get_value (&cfg, section.s,"ramdisk" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &ramdisk); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &ramdisk, option_str);As said before, this should be NULL as not having and never going to have a consumer. Whether you keep the XSM one below is - as also said before - up to you.
Quoted 1 line
Jan
I'll drop the options for ramdisk and xsm. I addresses the options on the ucode module,
which is what you had previously commented on.I will rebase on staging ( or master if they get pushed there today) to get the patches you have already committed.
Roy
Quoted 16 lines
Quoted 14 lines
xen/common/efi/boot.c +2
-2efi_bs->FreePool (name.w); } name.s =get_value (&cfg, section.s,"xsm" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &xsm); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &xsm, option_str); efi_bs->FreePool (name.w); }
Re: [PATCH for-4.5 V7 11/14] Add arch specific module handling to read_file()
Quoted 43 lines · Roy Franz
Quoted 14 lines · Roy Franz
Quoted 13 lines · Jan Beulich
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 580
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +7
-0+/* +* Make a copy, as conversion is destructive, and caller still wants +* wide string available after this call returns. +*/ +if ( efi_bs->AllocatePool (EfiLoaderData, (wstrlen (name) +1 ) *sizeof (*name), + &ptr) !=EFI_SUCCESS ) +blexit (L"ERROR Unable to allocate string buffer" );Kind of disappointing: You said you'd drop these ERROR prefixes, but this is the second one I come across. I'm ditching them in preparation for committing.
Quoted 12 lines
Quoted 12 lines
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 587
Quoted 7 lines
xen/arch/x86/efi/efi-boot.h +7
-0+ + local_name.w = ptr; +wstrcpy (local_name.w, name); +w2s (&local_name); + +place_string (&mb_modules[mbi.mods_count].string, options); +place_string (&mb_modules[mbi.mods_count].string,"" );Hmm, this one's still here, and I don't recall having seen an explanation for it. I guess I need to cut off committing at this patch then...
The original code put the entire line from the config file into the mb_modules[i].string field,
which consists of the filename and module options, space separated. This was done at the
same time the filename was extracted to pass toread_file().My refactored version of
read_file()takes a filename and option string as separate arguments,
and then after the file is loaded and address known, the module info is updated. Theefi_arch_handle_module()gets the filename and options separately, and the aboveplace_string()
commands reconstruct the the single string of filename followed by options that is placed
in the mb_modules[i].string field.
Quoted 4 lines
I will add a comment to this effect, and also only add the options if present, since for
several module types options will be NULL.
Reviewing this in more detail, the line:
place_string(&mb_modules[mbi.mods_count].string, "");
is not needed and has been removed. I have verified the same kernel commandline in dom0 (/proc/cmdline) before and after the change.
Quoted 46 lines
Quoted 46 lines
I apologize - I missed adding the above to items to my checklist, and was likely too focused
on getting an updated set out yesterday so these items got missed.Quoted 13 lines
xen/common/efi/boot.c efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) · line 886
Quoted 8 lines
xen/common/efi/boot.c +2
-2@@ -861,16 +882,16 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) name.s =get_value (&cfg, section.s,"ramdisk" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &ramdisk); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &ramdisk, option_str);As said before, this should be NULL as not having and never going to have a consumer. Whether you keep the XSM one below is - as also said before - up to you.
Quoted 1 line
Jan
I'll drop the options for ramdisk and xsm. I addresses the options on the ucode module,
which is what you had previously commented on.I will rebase on staging ( or master if they get pushed there today) to get the patches you have already committed.
Roy
Quoted 16 lines
Quoted 14 lines
xen/common/efi/boot.c +2
-2efi_bs->FreePool (name.w); } name.s =get_value (&cfg, section.s,"xsm" );if ( name.s ) { -split_value (name.s); -read_file (dir_handle,s2w (&name), &xsm); + option_str =split_string (name.s); +read_file (dir_handle,s2w (&name), &xsm, option_str); efi_bs->FreePool (name.w); }
Re: [PATCH for-4.5 V7 11/14] Add arch specific module handling to read_file()
Quoted 34 lines
Quoted 1 line
Quoted 1 line · On 26.09.14 at 02:25, <[email protected]> wrote:
Quoted 17 lines · Roy Franz
Quoted 9 lines · Roy Franz
Quoted 8 lines · Jan Beulich
xen/arch/x86/efi/efi-boot.h static void __init efi_arch_memory_setup(void) · line 587
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/arch/x86/efi/efi-boot.h +2
-0+place_string (&mb_modules[mbi.mods_count].string, options); +place_string (&mb_modules[mbi.mods_count].string,"" );Hmm, this one's still here, and I don't recall having seen an explanation for it. I guess I need to cut off committing at this patch then...
The original code put the entire line from the config file into the mb_modules[i].string field,
which consists of the filename and module options, space separated. This was done at the
same time the filename was extracted to pass toread_file().Quoted 3 lines
My refactored version of
read_file()takes a filename and option string as separate arguments,
and then after the file is loaded and address known, the module info isupdated.
Quoted 10 lines
The
efi_arch_handle_module()gets the filename and options separately, and the aboveplace_string()
commands reconstruct the the single string of filename followed by options that is placed
in the mb_modules[i].string field.I will add a comment to this effect, and also only add the options if present, since for
several module types options will be NULL.
Quoted 7 lines
Reviewing this in more detail, the line:
place_string(&mb_modules[mbi.mods_count].string, "");is not needed and has been removed. I have verified the same kernel commandline
in dom0 (/proc/cmdline) before and after the change.
Indeed, since
if ( s && *s )
in place_string() made this a no-op.
Jan
PATCH v7 12/14 Add several misc. arch functions for EFI boot code.
In reply to Roy FranzAdd efi_arch_blexit() for arch specific cleanup on error exit, efi_arch_load_addr_check() to do the arch specific verifications of where the UEFI firmware loaded Xen, and efi_arch_cpu() for probing CPU features.
--- xen/arch/x86/efi/efi-boot.h | 25 +++++++++++++++++++++++++ xen/common/efi/boot.c | 18 ++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-)
xen/arch/x86/efi/efi-boot.h +25 -0
@@ -591,3 +591,28 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name, ++mbi.mods_count; efi_bs->FreePool (ptr); } + +static void __init efi_arch_cpu (void ) +{ +if (cpuid_eax (0x80000000 ) >0x80000000 ) + { + cpuid_ext_features =cpuid_edx (0x80000001 ); + boot_cpu_data.x86_capability[1 ] = cpuid_ext_features; + } +} + +static void __init efi_arch_blexit (void ) +{ +if ( ucode.addr ) + efi_bs->FreePages (ucode.addr,PFN_UP (ucode.size)); +} + +static void __init efi_arch_load_addr_check (EFI_LOADED_IMAGE *loaded_image) +{ + xen_phys_start = (UINTN )loaded_image->ImageBase; +if ( (xen_phys_start + loaded_image->ImageSize -1 ) >>32 ) +blexit (L"Xen must be loaded below 4Gb." ); +if ( xen_phys_start & ((1 <<L2_PAGETABLE_SHIFT ) -1 ) ) +blexit (L"Xen must be loaded at a 2Mb boundary." ); + trampoline_xen_phys_start = xen_phys_start; +}
xen/common/efi/boot.c +4 -14
@@ -212,11 +212,11 @@ static void __init noreturn blexit(const CHAR16 *str) efi_bs->FreePages (kernel.addr,PFN_UP (kernel.size));if ( ramdisk.addr ) efi_bs->FreePages (ramdisk.addr,PFN_UP (ramdisk.size)); -if ( ucode.addr ) - efi_bs->FreePages (ucode.addr,PFN_UP (ucode.size));if ( xsm.addr ) efi_bs->FreePages (xsm.addr,PFN_UP (xsm.size)); +efi_arch_blexit (); + efi_bs->Exit (efi_ih,EFI_SUCCESS ,0 ,NULL );unreachable ();/* not reached */ }
@@ -713,12 +713,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)if ( status !=EFI_SUCCESS )PrintErrMesg (L"No Loaded Image Protocol" , status); - xen_phys_start = (UINTN )loaded_image->ImageBase; -if ( (xen_phys_start + loaded_image->ImageSize -1 ) >>32 ) -blexit (L"Xen must be loaded below 4Gb." ); -if ( xen_phys_start & ((1 <<L2_PAGETABLE_SHIFT ) -1 ) ) -blexit (L"Xen must be loaded at a 2Mb boundary." ); - trampoline_xen_phys_start = xen_phys_start; +efi_arch_load_addr_check (loaded_image);/* Get the file system interface. */ dir_handle =get_parent_handle (loaded_image, &file_name);
@@ -966,12 +961,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)efi_arch_edd ();/* XXX Collect EDID info. */ - -if (cpuid_eax (0x80000000 ) >0x80000000 ) - { - cpuid_ext_features =cpuid_edx (0x80000001 ); - boot_cpu_data.x86_capability[1 ] = cpuid_ext_features; - } +efi_arch_cpu ();/* Obtain basic table pointers. */ for ( i =0 ; i < efi_num_ct; ++i )
Signature · 1 line
2.1.0
PATCH v7 13/14 Add efi_arch_use_config_file() function to control use of config file
In reply to Roy FranzThe x86 EFI build of Xen always uses a configuration file to load modules, but the ARM version can either use a config file to specify the modules, or be loaded by GRUB in which case GRUB loads the modules and adds them to the DTB that is passed to Xen. Add the efi_arch_use_config_file() to indicate if a configuration file is required. For x86, this will always be true. ARM will examine the DTB passed via EFI configuration table (if any), and if it contains module information will use that that not use the configuration file at all. Add Emacs footer to efi-boot.h and boot.c
--- xen/arch/x86/efi/efi-boot.h | 14 ++++ xen/common/efi/boot.c | 179 +++++++++++++++++++++++--------------------- 2 files changed, 107 insertions(+), 86 deletions(-)
xen/arch/x86/efi/efi-boot.h +14 -0
@@ -616,3 +616,17 @@ static void __init efi_arch_load_addr_check(EFI_LOADED_IMAGE *loaded_image)blexit (L"Xen must be loaded at a 2Mb boundary." ); trampoline_xen_phys_start = xen_phys_start; } + +static bool_t __init efi_arch_use_config_file (EFI_SYSTEM_TABLE *SystemTable) +{ +return 1 ;/* x86 always uses a config file */ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/common/efi/boot.c +93 -86
218 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v7 14/14 Add ARM EFI boot support
In reply to Roy FranzThis 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.
--- .gitignore | 4 + 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/xen.lds.S | 1 + xen/common/efi/boot.c | 17 +- xen/common/efi/efi.h | 2 + xen/common/efi/runtime.c | 16 +- xen/include/asm-arm/arm64/efibind.h | 216 ++++++++++++++ xen/include/asm-arm/efibind.h | 2 + xen/include/asm-arm/setup.h | 2 +- 12 files changed, 980 insertions(+), 10 deletions(-) create mode 100644 xen/arch/arm/efi/Makefile create mode 100644 xen/arch/arm/efi/efi-boot.h create mode 100644 xen/include/asm-arm/arm64/efibind.h create mode 100644 xen/include/asm-arm/efibind.h
.gitignore +4 -0
@@ -258,6 +258,10 @@ xen/arch/x86/efi/boot.c xen/arch/x86/efi/runtime.c xen/arch/x86/efi/compat.c xen/arch/x86/efi/efi.h +xen/arch/arm/efi/boot.c +xen/arch/arm/efi/runtime.c +xen/arch/arm/efi/compat.c +xen/arch/arm/efi/efi.h xen/ddb/* xen/include/headers.chk xen/include/asm
xen/arch/arm/Makefile +1 -0
@@ -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
@@ -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/xen.lds.S +1 -0
@@ -135,6 +135,7 @@ SECTIONS *(.xsm_initcall.init) __xsm_initcall_end = .; } :text + __init_end_efi = .; . = ALIGN(STACK_SIZE); __init_end = .;
xen/common/efi/boot.c +15 -2
@@ -18,9 +18,17 @@#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 +#include <xen/bitops.h> /* 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;
@@ -988,8 +997,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 ();
@@ -1060,6 +1071,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,
@@ -1285,3 +1297,4 @@ void __init efi_init_memory(void) efi_l4_pgtable[i] = idle_pg_table[i]; #endif } +#endif
xen/common/efi/efi.h +2 -0
@@ -28,7 +28,9 @@ extern EFI_RUNTIME_SERVICES *efi_rs;extern UINTN efi_memmap_size, efi_mdesc_size;extern void *efi_memmap; +#ifndef CONFIG_ARM extern l4_pgentry_t *efi_l4_pgtable; +#endif extern const struct efi_pci_rom *efi_pci_roms;
xen/common/efi/runtime.c +12 -4
@@ -4,17 +4,22 @@#include <xen/guest_access.h> #include <xen/irq.h> #include <xen/time.h> -#include <asm/mc146818rtc.h> + +extern spinlock_t rtc_lock;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 +29,6 @@ unsigned int __read_mostly efi_fw_revision;const CHAR16 *__read_mostly efi_fw_vendor;EFI_RUNTIME_SERVICES *__read_mostly efi_rs; -static DEFINE_SPINLOCK (efi_rs_lock);UINTN __read_mostly efi_memmap_size;UINTN __read_mostly efi_mdesc_size;
@@ -41,10 +45,11 @@ 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 */ +static DEFINE_SPINLOCK (efi_rs_lock); +l4_pgentry_t *__read_mostly efi_l4_pgtable;unsigned long efi_rs_enter (void ) {static const u16 fcw =FCW_DEFAULT ;
@@ -135,7 +140,9 @@ void efi_reset_system(bool_t warm) }#endif +#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
@@ -0,0 +1,2 @@ +#include <xen/types.h> +#include <asm/arm64/efibind.h>
xen/include/asm-arm/setup.h +1 -1
@@ -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
Re: [PATCH for-4.5 V7 14/14] Add ARM EFI boot support
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/common/efi/boot.c +1
-0@@ -1060,6 +1071,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,
xen/common/efi/boot.c void __init efi_init_memory(void) · line 1300
Quoted 4 lines
xen/common/efi/boot.c +1
-0@@ -1285,3 +1297,4 @@ void __init efi_init_memory(void) efi_l4_pgtable[i] = idle_pg_table[i]; #endif } +#endif
So you want from moving this code block out in its entirety back to leaving it in its entirety, despite there being clearly x86-specific pieces. That's a little sad...
xen/common/efi/efi.h extern EFI_RUNTIME_SERVICES *efi_rs; · line 33
Quoted 9 lines
xen/common/efi/efi.h +2
-0@@ -28,7 +28,9 @@ extern EFI_RUNTIME_SERVICES *efi_rs;extern UINTN efi_memmap_size, efi_mdesc_size;extern void *efi_memmap; +#ifndef CONFIG_ARM extern l4_pgentry_t *efi_l4_pgtable; +#endif
#ifdef CONFIG_X86 please.
xen/common/efi/runtime.c line 8
Quoted 9 lines
xen/common/efi/runtime.c +2
-1@@ -4,17 +4,22 @@#include <xen/guest_access.h> #include <xen/irq.h> #include <xen/time.h> -#include <asm/mc146818rtc.h> + +extern spinlock_t rtc_lock;
No extern declarations in .c files for things being defined in other .c files please.
Quoted 10 lines
xen/common/efi/runtime.c +0
-1@@ -24,7 +29,6 @@ unsigned int __read_mostly efi_fw_revision;const CHAR16 *__read_mostly efi_fw_vendor;EFI_RUNTIME_SERVICES *__read_mostly efi_rs; -static DEFINE_SPINLOCK (efi_rs_lock);UINTN __read_mostly efi_memmap_size;UINTN __read_mostly efi_mdesc_size;@@ -41,10 +45,11 @@ struct efi __read_mostly efi = { .smbios = EFI_INVALID_TABLE_ADDR,
xen/common/efi/runtime.c struct efi __read_mostly efi = { · line 53
Quoted 10 lines
xen/common/efi/runtime.c +3
-2}; -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 */ +static DEFINE_SPINLOCK (efi_rs_lock); +l4_pgentry_t *__read_mostly efi_l4_pgtable;unsigned long efi_rs_enter (void )
Blank lines missing.
xen/common/efi/runtime.c void efi_reset_system(bool_t warm) · line 143
Quoted 5 lines
xen/common/efi/runtime.c +1
-0@@ -135,7 +140,9 @@ void efi_reset_system(bool_t warm) }#endif +#endif
Please attach a /* CONFIG_ARM */ comment to the right one of those two (at once making clear without having to consult the actual file that the #ifndef below can't be folded with this one).
Jan
Quoted 4 lines
xen/common/efi/runtime.c +1
-0+#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;
Re: [PATCH for-4.5 V7 14/14] Add ARM EFI boot support
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/common/efi/boot.c +0
-0@@ -1060,6 +1071,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)for ( ; ; );/* not reached */ }
Quoted 14 lines
xen/common/efi/boot.c void __init efi_init_memory(void) · line 1300
Quoted 9 lines
xen/common/efi/boot.c +2
-0+#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,@@ -1285,3 +1297,4 @@ void __init efi_init_memory(void) efi_l4_pgtable[i] = idle_pg_table[i]; #endif } +#endif So you want from moving this code block out in its entirety back to leaving it in its entirety, despite there being clearly x86-specific pieces. That's a little sad...
This code is all EFI runtime service related, and not used by ARM at all. I have deliberately left
refactoring of the runtime services code until the refactoring can actually be _used_ by ARM, as I view
changing this code as out of scope for this patchset, and the refactoring would likely need to be tweaked
when there is a second user.
Quoted 11 lines
xen/common/efi/efi.h extern EFI_RUNTIME_SERVICES *efi_rs; · line 33
Quoted 9 lines
xen/common/efi/efi.h +2
-0@@ -28,7 +28,9 @@ extern EFI_RUNTIME_SERVICES *efi_rs;extern UINTN efi_memmap_size, efi_mdesc_size;extern void *efi_memmap; +#ifndef CONFIG_ARM extern l4_pgentry_t *efi_l4_pgtable; +#endif #ifdef
CONFIG_X86please.
sure
Quoted 13 lines
xen/common/efi/runtime.c line 8
Quoted 10 lines
xen/common/efi/runtime.c +2
-1@@ -4,17 +4,22 @@#include <xen/guest_access.h> #include <xen/irq.h> #include <xen/time.h> -#include <asm/mc146818rtc.h> + +extern spinlock_t rtc_lock;No extern declarations in .c files for things being defined in other .c files please.
OK, I'll have to look at making asm/mc146818rtc.h a common file, or moving the extern declaration from that x86 specific include file to a common one.
(or #ifdef CONFIG_X86 this and the spinlock, but that's not nice either.)
Quoted 27 lines
Quoted 11 lines
xen/common/efi/runtime.c +0
-1@@ -24,7 +29,6 @@ unsigned int __read_mostly efi_fw_revision;const CHAR16 *__read_mostly efi_fw_vendor;EFI_RUNTIME_SERVICES *__read_mostly efi_rs; -static DEFINE_SPINLOCK (efi_rs_lock);UINTN __read_mostly efi_memmap_size;UINTN __read_mostly efi_mdesc_size;@@ -41,10 +45,11 @@ struct efi __read_mostly efi = { .smbios = EFI_INVALID_TABLE_ADDR,xen/common/efi/runtime.c struct efi __read_mostly efi = { · line 53
Quoted 10 lines
xen/common/efi/runtime.c +3
-2}; -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 */ +static DEFINE_SPINLOCK (efi_rs_lock); +l4_pgentry_t *__read_mostly efi_l4_pgtable;unsigned long efi_rs_enter (void )Blank lines missing.
Quoted 3 lines
xen/common/efi/runtime.c +0
-0@@ -135,7 +140,9 @@ void efi_reset_system(bool_t warm) }
Quoted 8 lines
xen/common/efi/runtime.c void efi_reset_system(bool_t warm) · line 143
Quoted 2 lines
xen/common/efi/runtime.c +1
-0#endif +#endif Please attach a /*
CONFIG_ARM*/ comment to the right one of those two (at once making clear without having to consult the actual file that the #ifndef below can't be folded with this one).Jan
OK, I didn't see any other #endifs commented, so I wasn't sure that the policy on that
was. I agree this makes things clearer.
Quoted 7 lines
Quoted 5 lines
xen/common/efi/runtime.c +1
-0+#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;
Re: [PATCH for-4.5 V7 14/14] Add ARM EFI boot support
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 19:05, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
xen/common/efi/runtime.c line 8
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 03:42, <[email protected]> wrote:
xen/common/efi/runtime.c +2
-1@@ -4,17 +4,22 @@#include <xen/guest_access.h> #include <xen/irq.h> #include <xen/time.h> -#include <asm/mc146818rtc.h> + +extern spinlock_t rtc_lock;No extern declarations in .c files for things being defined in other .c files please.
Quoted 4 lines
OK, I'll have to look at making
asm/mc146818rtc.ha common file, or moving the extern declaration from that x86 specific include file to a common one.
(or #ifdefCONFIG_X86this and the spinlock, but that's not nice either.)
Just like you introduced efi-boot.h (which really should have been just boot.h, but I noticed this only when already having been through most of the part that I committed yesterday), we'll need runtime.h anyway sooner or later, and that's where the #include should get moved imo (even if for now this may end up being the only content of that file).
Jan