Re: [PATCH 1/2] Add powerpc little-endian (ppc64le) flags
On 2015-07-16 16:30, Andrei Borzenkov wrote: В Thu, 16 Jul 2015 21:05:07 +0200 Vladimir 'φ-coder/phcoder' Serbinenko phco...@gmail.com пишет: On 16.07.2015 20:55, Andrei Borzenkov wrote: В Wed, 15 Jul 2015 19:42:39 +0200 Vladimir 'φ-coder/phcoder' Serbinenko phco...@gmail.com пишет: It is possible to compile using --target=powerpc -Wl,-EB - this works on all three ppc, ppc64 and ppc64le, but this means hardcoding GNU ld dependency. Thanks for this info. See attached patch Test has to come before asm tests (so that we are sure to compile for the right target). But real problem is that -Wl,-EB has to be added to TARGET_LDFLAGS only Yes, discovered it already and updated the patch Yes, this version builds OK both in native PPC environment as well as cross-compiling. ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel Here works too. Both native and cross-compiled. -- Paulo Flabiano Smorigo IBM Linux Technology Center ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Wimboot fails to get initrd data (probably regression)
Hello, I built yesterdays git of grub2. I observed that booting via wimboot 2.2.4 or 2.4.1 is in this combination not longer possible. The last lines of the failing boot on screen: ... Using boot.wim via 0xfca5254 len 0x13fc7f7f ...found WIM file boot.wim Bad CPIO magic FATAL: could not extract initrd files Press a key to reboot The used entry in grub.cfg: menuentry * Win81PEx64 2014-06-14 MistyPE_81_x64 wimboot (usb/pxe) { set isoroot=/boot/windows/win81/2014-06-14_MistyPE_x64/ISO.ROOT linux16 /boot/bootloader/wimboot/wimboot-2.4.1/wimboot initrd16 \ newc:bootmgr:${isoroot}/bootmgr \ newc:bcd:${isoroot}/boot/bcd \ newc:wgl4_boot.ttf:${isoroot}/boot/fonts/wgl4_boot.ttf \ newc:boot.sdi:${isoroot}/boot/boot.sdi \ newc:boot.wim:${isoroot}/sources/boot.wim } A git bisect pointed to following commit: a8c473288d3f0a5e17a903a5121dea1a695dda3b is the first bad commit commit a8c473288d3f0a5e17a903a5121dea1a695dda3b Author: Andrei Borzenkov arvidj...@gmail.com Date: Thu May 7 20:24:24 2015 +0300 loader/linux: do not pad initrd with zeroes at the end Syslinux memdisk is using initrd image and needs to know uncompressed size in advance. For gzip uncompressed size is at the end of compressed stream. Grub padded each input file to 4 bytes at the end, which means syslinux got wrong size. Linux initramfs loader apparently does not care about trailing alignment. So change code to align beginning of each file instead which atomatically gives us the correct size for single file. Reported-By: David Shaw ds...@jabberwocky.com :04 04 f999167e8f6744c6be8abb2df5490617d2d6a5aa c7631f7f7683e9aaa31736f095f8234935727483 M grub-core ([1] and [2] for the discussions about this change.) I tried to have a look at the data wimboot is complaining and found that the five files were extracted successfully but the trailing element (TRAILER!!!) was not recognized, because the data pointer is set one byte too far. Therefore the magic does not match. Wimboot expects the next file to start at a aligned address, even if last file size was not even. This is probably because my boot.wim has not a even size. When cpio_len is not aligned, like in following patch to wimboot, then the boot can continue successful. diff --git a/src/cpio.c b/src/cpio.c index affb1d8..a0a1e87 100644 --- a/src/cpio.c +++ b/src/cpio.c @@ -112,8 +112,6 @@ int cpio_extract ( void *data, size_t len, file_name_len ) ); file_len = cpio_value ( cpio-c_filesize ); cpio_len = ( file_data + file_len - data ); - if ( cpio_len len ) - cpio_len = cpio_align ( cpio_len ); if ( cpio_len len ) { DBG ( Truncated CPIO file\n ); return -1; --- I am not certain if this is a regression with grub or if it revealed a bug within wimboot. Therefore I tried to reorder the initrd files and switched boot.sdi and boot.wim and then it booted also successfully with unmodified wimboot. Then this would just be a problem with the trailer entry and a regression in grub? I tried therefore to put the trailer again to an aligned address. This makes the boot succeed again (Also attached as patch to current grub git): @@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[], if (newc) { + initrd_ctx-size = ALIGN_UP (initrd_ctx-size, 4); initrd_ctx-size += ALIGN_UP (sizeof (struct newc_head) + sizeof (TRAILER!!!) - 1, 4); free_dir (root); @@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, ptr += cursize; } if (newc) -ptr = make_header (ptr, TRAILER!!!, sizeof (TRAILER!!!) - 1, 0, 0); +{ + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); + ptr = make_header (ptr, TRAILER!!!, sizeof (TRAILER!!!) - 1, 0, 0); +} free_dir (root); root = 0; return GRUB_ERR_NONE; -- If the documentation in [3] is still valid, it looks to me like the cpio_trailer really has to be aligned: cpio_trailer := ALGN(4) + cpio_header + TRAILER!!!\0 + ALGN(4) What do you think? Kind regards, Bernhard [1] http://www.syslinux.org/archives/2015-April/thread.html#23396 [2] http://lists.gnu.org/archive/html/grub-devel/2015-04/threads.html#00095 [3] https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt From
[PATCH v2 00/23] x86: multiboot2 protocol support
Hi, I am sending, long awaited, second version of multiboot2 protocol support for legacy BIOS and EFI platforms. It fixes all major issues discovered until now. There are still some minor problems which should be fixed in one way or another. I will address them in next releases. This series, in general, is not targeted to Xen 4.6. However, there are some fixes at the beginning of it which are worth considering, I think. The final goal is xen.efi binary file which could be loaded by EFI loader, multiboot (v1) protocol (only on legacy BIOS platforms) and multiboot2 protocol. This way we will have: - smaller Xen code base, - one code base for xen.gz and xen.efi, - one build method for xen.gz and xen.efi; xen.efi will be extracted from xen file using objcopy; PE header will be contained in ELF file and will precede Xen code, - xen.efi build will not so strongly depend on a given GCC and binutils version. ARM guys should check at least patches #9 - #18 and #20. In general earlier mentioned patches touches common EFI code but they are not change functionality significantly. GRUB2 patch series will follow this patch series. GRUB2 guys should check patches #20 and #23 but I am sending to you all Xen related patches just in case. If you are not interested in this patch series at all please drop me a line and I will remove you from distribution list. Daniel .gitignore|5 +- xen/arch/x86/Makefile | 21 ++-- xen/arch/x86/Rules.mk |4 + xen/arch/x86/boot/Makefile| 10 +- xen/arch/x86/boot/build32.mk |4 +- xen/arch/x86/boot/cmdline.S | 367 --- xen/arch/x86/boot/cmdline.c | 396 xen/arch/x86/boot/edd.S |3 - xen/arch/x86/boot/head.S | 474 -- xen/arch/x86/boot/reloc.c | 242 +++--- xen/arch/x86/boot/trampoline.S| 25 - xen/arch/x86/boot/video.S |6 -- xen/arch/x86/boot/wakeup.S|6 +- xen/arch/x86/boot/x86_64.S| 34 +++--- xen/arch/x86/dmi_scan.c |4 +- xen/arch/x86/domain_page.c|2 +- xen/arch/x86/efi/Makefile | 16 +-- xen/arch/x86/efi/efi-boot.h | 68 ++-- xen/arch/x86/efi/stub.c | 16 ++- xen/arch/x86/mm.c |3 +- xen/arch/x86/mpparse.c|4 +- xen/arch/x86/setup.c | 50 - xen/arch/x86/shutdown.c |2 +- xen/arch/x86/time.c |2 +- xen/arch/x86/x86_64/asm-offsets.c | 10 ++ xen/arch/x86/x86_64/mm.c |2 +- xen/arch/x86/xen.lds.S|6 +- xen/common/efi/boot.c | 461 ++- xen/common/efi/runtime.c | 23 ++-- xen/drivers/acpi/osl.c|2 +- xen/include/asm-x86/config.h |3 + xen/include/asm-x86/page.h|2 +- xen/include/xen/efi.h | 17 ++- xen/include/xen/multiboot2.h | 182 34 files changed, 1709 insertions(+), 763 deletions(-) Daniel Kiper (23): x86/boot: remove unneeded instruction x86/boot: copy only text section from *.lnk file to *.bin file x86: zero BSS using stosl instead of stosb x86/boot: call reloc() using cdecl calling convention x86/boot/reloc: create generic alloc and copy functions x86/boot: use %ecx instead of %eax x86/boot/reloc: Rename some variables and rearrange code a bit x86: add multiboot2 protocol support efi: create efi_enabled() efi: build xen.gz with EFI code efi: split out efi_init() efi: split out efi_console_set_mode() efi: split out efi_get_gop() efi: split out efi_find_gop_mode() efi: split out efi_tables() efi: split out efi_variables() efi: split out efi_set_gop_mode() efi: split out efi_exit_boot() x86/efi: create new early memory allocator x86: add multiboot2 protocol support for EFI platforms x86/boot: implement early command line parser in C x86: make Xen early boot code relocatable x86: add multiboot2 protocol support for relocatable images ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 01/23] x86/boot: remove unneeded instruction
Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/boot/head.S |1 - 1 file changed, 1 deletion(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index cfd59dc..f63b349 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -169,7 +169,6 @@ __start: /* Apply relocations to bootstrap trampoline. */ mov sym_phys(trampoline_phys),%edx mov $sym_phys(__trampoline_rel_start),%edi -mov %edx,sym_phys(trampoline_phys) 1: mov (%edi),%eax add %edx,(%edi,%eax) -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 04/23] x86/boot: call reloc() using cdecl calling convention
Suggested-by: Jan Beulich jbeul...@suse.com Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/boot/head.S |4 +++- xen/arch/x86/boot/reloc.c | 20 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index ed42782..3cbb2e6 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -119,8 +119,10 @@ __start: /* Save the Multiboot info struct (after relocation) for later use. */ mov $sym_phys(cpu0_stack)+1024,%esp -push%ebx +push%ebx/* Multiboot information address. */ +push%eax/* Boot trampoline address. */ callreloc +add $8,%esp /* Remove reloc() args from stack. */ mov %eax,sym_phys(multiboot_ptr) /* Initialize BSS (no nasty surprises!). */ diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 63045c0..708898f 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -10,15 +10,27 @@ *Keir Fraser k...@xen.org */ -/* entered with %eax = BOOT_TRAMPOLINE */ +/* + * This entry point is entered from xen/arch/x86/boot/head.S with: + * - 0x4(%esp) = BOOT_TRAMPOLINE_ADDRESS, + * - 0x8(%esp) = MULTIBOOT_INFORMATION_ADDRESS. + */ asm ( .text \n .globl _start \n _start: \n +push %ebp \n +mov %esp,%ebp\n call 1f \n -1: pop %ebx \n -mov %eax,alloc-1b(%ebx) \n -jmp reloc\n +1: pop %ecx \n +mov 0x8(%ebp),%eax \n +mov %eax,alloc-1b(%ecx) \n +mov 0xc(%ebp),%eax \n +push %eax \n +call reloc\n +add $4,%esp \n +pop %ebp \n +ret \n ); /* -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 03/23] x86: zero BSS using stosl instead of stosb
Additionally, align relevant comment to coding style. Suggested-by: Andrew Cooper andrew.coop...@citrix.com Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/boot/head.S |5 +++-- xen/arch/x86/xen.lds.S |2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index f63b349..ed42782 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -123,12 +123,13 @@ __start: callreloc mov %eax,sym_phys(multiboot_ptr) -/* Initialize BSS (no nasty surprises!) */ +/* Initialize BSS (no nasty surprises!). */ mov $sym_phys(__bss_start),%edi mov $sym_phys(__bss_end),%ecx sub %edi,%ecx +shr $2,%ecx xor %eax,%eax -rep stosb +rep stosl /* Interrogate CPU extended features via CPUID. */ mov $0x8000,%eax diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 6553cff..3e1f2af 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -162,6 +162,7 @@ SECTIONS . = ALIGN(STACK_SIZE); __init_end = .; + . = ALIGN(4); .bss : { /* BSS */ __bss_start = .; *(.bss.stack_aligned) @@ -175,6 +176,7 @@ SECTIONS *(.bss.percpu.read_mostly) . = ALIGN(SMP_CACHE_BYTES); __per_cpu_data_end = .; + . = ALIGN(4); __bss_end = .; } :text _end = . ; -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 05/23] x86/boot/reloc: create generic alloc and copy functions
Create generic alloc and copy functions. We need separate tools for memory allocation and copy to provide multiboot2 protocol support. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com --- v2 - suggestions/fixes: - generalize new functions names (suggested by Jan Beulich), - reduce number of casts (suggested by Jan Beulich). --- xen/arch/x86/boot/reloc.c | 59 - 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 708898f..09fd540 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -45,9 +45,10 @@ asm ( typedef unsigned int u32; #include ../../../include/xen/multiboot.h -static void *reloc_mbi_struct(void *old, unsigned int bytes) +static u32 alloc_mem(u32 bytes) { -void *new; +u32 s; + asm( call 1f \n 1: pop %%edx \n @@ -55,50 +56,64 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes) sub %1,%0 \n and $~15,%0 \n mov %0,alloc-1b(%%edx) \n -mov %0,%%edi\n -rep movsb \n - : =r (new), +c (bytes), +S (old) - : : edx, edi, memory); -return new; + : =r (s) : r (bytes) : edx, memory); + +return s; } -static char *reloc_mbi_string(char *old) +static u32 copy_mem(u32 src, u32 bytes) { -char *p; -for ( p = old; *p != '\0'; p++ ) +u32 dst, dst_asm; + +dst = alloc_mem(bytes); +dst_asm = dst; + +asm volatile(rep movsb : +S (src), +D (dst_asm), +c (bytes) : : memory); + +return dst; +} + +static u32 copy_string(u32 src) +{ +u32 p; + +if ( src == 0 ) +return 0; + +for ( p = src; *(char *)p != '\0'; p++ ) continue; -return reloc_mbi_struct(old, p - old + 1); + +return copy_mem(src, p - src + 1); } -multiboot_info_t *reloc(multiboot_info_t *mbi_old) +multiboot_info_t *reloc(u32 mbi_old) { -multiboot_info_t *mbi = reloc_mbi_struct(mbi_old, sizeof(*mbi)); +multiboot_info_t *mbi = (multiboot_info_t *)copy_mem(mbi_old, sizeof(*mbi)); int i; if ( mbi-flags MBI_CMDLINE ) -mbi-cmdline = (u32)reloc_mbi_string((char *)mbi-cmdline); +mbi-cmdline = copy_string(mbi-cmdline); if ( mbi-flags MBI_MODULES ) { -module_t *mods = reloc_mbi_struct( -(module_t *)mbi-mods_addr, mbi-mods_count * sizeof(module_t)); +module_t *mods; -mbi-mods_addr = (u32)mods; +mbi-mods_addr = copy_mem(mbi-mods_addr, mbi-mods_count * sizeof(module_t)); + +mods = (module_t *)mbi-mods_addr; for ( i = 0; i mbi-mods_count; i++ ) { if ( mods[i].string ) -mods[i].string = (u32)reloc_mbi_string((char *)mods[i].string); +mods[i].string = copy_string(mods[i].string); } } if ( mbi-flags MBI_MEMMAP ) -mbi-mmap_addr = (u32)reloc_mbi_struct( -(memory_map_t *)mbi-mmap_addr, mbi-mmap_length); +mbi-mmap_addr = copy_mem(mbi-mmap_addr, mbi-mmap_length); if ( mbi-flags MBI_LOADERNAME ) -mbi-boot_loader_name = (u32)reloc_mbi_string( -(char *)mbi-boot_loader_name); +mbi-boot_loader_name = copy_string(mbi-boot_loader_name); /* Mask features we don't understand or don't relocate. */ mbi-flags = (MBI_MEMLIMITS | -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 06/23] x86/boot: use %ecx instead of %eax
Use %ecx instead of %eax to store low memory upper limit from EBDA. This way we do not wipe multiboot protocol identifier. It is needed in reloc() to differentiate between multiboot (v1) and multiboot2 protocol. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com --- xen/arch/x86/boot/head.S | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 3cbb2e6..77e7da9 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -87,14 +87,14 @@ __start: jne not_multiboot /* Set up trampoline segment 64k below EBDA */ -movzwl 0x40e,%eax /* EBDA segment */ -cmp $0xa000,%eax/* sanity check (high) */ +movzwl 0x40e,%ecx /* EBDA segment */ +cmp $0xa000,%ecx/* sanity check (high) */ jae 0f -cmp $0x4000,%eax/* sanity check (low) */ +cmp $0x4000,%ecx/* sanity check (low) */ jae 1f 0: -movzwl 0x413,%eax /* use base memory size on failure */ -shl $10-4,%eax +movzwl 0x413,%ecx /* use base memory size on failure */ +shl $10-4,%ecx 1: /* * Compare the value in the BDA with the information from the @@ -106,21 +106,21 @@ __start: cmp $0x100,%edx /* is the multiboot value too small? */ jb 2f /* if so, do not use it */ shl $10-4,%edx -cmp %eax,%edx /* compare with BDA value */ -cmovb %edx,%eax /* and use the smaller */ +cmp %ecx,%edx /* compare with BDA value */ +cmovb %edx,%ecx /* and use the smaller */ 2: /* Reserve 64kb for the trampoline */ -sub $0x1000,%eax +sub $0x1000,%ecx /* From arch/x86/smpboot.c: start_eip had better be page-aligned! */ -xor %al, %al -shl $4, %eax -mov %eax,sym_phys(trampoline_phys) +xor %cl, %cl +shl $4, %ecx +mov %ecx,sym_phys(trampoline_phys) /* Save the Multiboot info struct (after relocation) for later use. */ mov $sym_phys(cpu0_stack)+1024,%esp push%ebx/* Multiboot information address. */ -push%eax/* Boot trampoline address. */ +push%ecx/* Boot trampoline address. */ callreloc add $8,%esp /* Remove reloc() args from stack. */ mov %eax,sym_phys(multiboot_ptr) -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 02/23] x86/boot: copy only text section from *.lnk file to *.bin file
Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/boot/build32.mk |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/boot/build32.mk b/xen/arch/x86/boot/build32.mk index c208249..c83effe 100644 --- a/xen/arch/x86/boot/build32.mk +++ b/xen/arch/x86/boot/build32.mk @@ -13,7 +13,7 @@ CFLAGS := $(filter-out -flto,$(CFLAGS)) sed 's/ /,0x/g' | sed 's/,0x$$//' | sed 's/^[0-9]*,/ .long /') $@ %.bin: %.lnk - $(OBJCOPY) -O binary $ $@ + $(OBJCOPY) -O binary -j .text $ $@ %.lnk: %.o $(LD) $(LDFLAGS_DIRECT) -N -Ttext 0 -o $@ $ -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 13/23] efi: split out efi_get_gop()
..which gets pointer to GOP device. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 59 ++--- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 4614146..6fad230 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -630,6 +630,41 @@ static void __init efi_console_set_mode(void) StdOut-SetMode(StdOut, best); } +static EFI_GRAPHICS_OUTPUT_PROTOCOL __init *efi_get_gop(void) +{ +EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; +EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; +EFI_HANDLE *handles; +EFI_STATUS status; +UINTN info_size, size = 0; +static EFI_GUID __initdata gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; +unsigned int i; + +status = efi_bs-LocateHandle(ByProtocol, gop_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, gop_guid, NULL, size, + handles); +if ( EFI_ERROR(status) ) +size = 0; +for ( i = 0; i size / sizeof(*handles); ++i ) +{ +status = efi_bs-HandleProtocol(handles[i], gop_guid, (void **)gop); +if ( EFI_ERROR(status) ) +continue; +status = gop-QueryMode(gop, gop-Mode-Mode, info_size, mode_info); +if ( !EFI_ERROR(status) ) +break; +} +if ( handles ) +efi_bs-FreePool(handles); +if ( EFI_ERROR(status) ) +gop = NULL; + +return gop; +} + static void __init setup_efi_pci(void) { EFI_STATUS status; @@ -736,14 +771,12 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { static EFI_GUID __initdata loaded_image_guid = LOADED_IMAGE_PROTOCOL; -static EFI_GUID __initdata gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID; EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; unsigned int i, argc; CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL; UINTN map_key, info_size, gop_mode = ~0; -EFI_HANDLE *handles = NULL; EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; @@ -837,27 +870,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) cols, rows) == EFI_SUCCESS ) efi_arch_console_init(cols, rows); -status = efi_bs-LocateHandle(ByProtocol, gop_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, gop_guid, NULL, size, - handles); -if ( EFI_ERROR(status) ) -size = 0; -for ( i = 0; i size / sizeof(*handles); ++i ) -{ -status = efi_bs-HandleProtocol(handles[i], gop_guid, (void **)gop); -if ( EFI_ERROR(status) ) -continue; -status = gop-QueryMode(gop, gop-Mode-Mode, info_size, mode_info); -if ( !EFI_ERROR(status) ) -break; -} -if ( handles ) -efi_bs-FreePool(handles); -if ( EFI_ERROR(status) ) -gop = NULL; +gop = efi_get_gop(); /* Get the file system interface. */ dir_handle = get_parent_handle(loaded_image, file_name); -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 18/23] efi: split out efi_exit_boot()
..which gets memory map and calls ExitBootServices(). We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 92 +++-- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 04b9c7e..bf2f198 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -879,6 +879,53 @@ static void __init efi_set_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop efi_arch_video_init(gop, info_size, mode_info); } +static void __init efi_exit_boot(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) +{ +EFI_STATUS status; +UINTN info_size = 0, map_key; +bool_t retry; + +efi_bs-GetMemoryMap(info_size, NULL, map_key, + efi_mdesc_size, mdesc_ver); +info_size += 8 * efi_mdesc_size; +efi_memmap = efi_arch_allocate_mmap_buffer(info_size); +if ( !efi_memmap ) +blexit(LUnable to allocate memory for EFI memory map); + +for ( retry = 0; ; retry = 1 ) +{ +efi_memmap_size = info_size; +status = SystemTable-BootServices-GetMemoryMap(efi_memmap_size, + efi_memmap, map_key, + efi_mdesc_size, + mdesc_ver); +if ( EFI_ERROR(status) ) +PrintErrMesg(LCannot obtain memory map, status); + +efi_arch_process_memory_map(SystemTable, efi_memmap, efi_memmap_size, +efi_mdesc_size, mdesc_ver); + +efi_arch_pre_exit_boot(); + +status = SystemTable-BootServices-ExitBootServices(ImageHandle, + map_key); +efi_bs = NULL; +if ( status != EFI_INVALID_PARAMETER || retry ) +break; +} + +if ( EFI_ERROR(status) ) +PrintErrMesg(LCannot exit boot services, status); + +/* Adjust pointers into EFI. */ +efi_ct = (void *)efi_ct + DIRECTMAP_VIRT_START; +#ifdef USE_SET_VIRTUAL_ADDRESS_MAP +efi_rs = (void *)efi_rs + DIRECTMAP_VIRT_START; +#endif +efi_memmap = (void *)efi_memmap + DIRECTMAP_VIRT_START; +efi_fw_vendor = (void *)efi_fw_vendor + DIRECTMAP_VIRT_START; +} + static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz) { if ( bpp 0 ) @@ -903,11 +950,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) EFI_STATUS status; unsigned int i, argc; CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL; -UINTN map_key, info_size, gop_mode = ~0; +UINTN gop_mode = ~0; EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; union string section = { NULL }, name; -bool_t base_video = 0, retry; +bool_t base_video = 0; char *option_str; bool_t use_cfg_file; @@ -1125,46 +1172,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_set_gop_mode(gop, gop_mode); -info_size = 0; -efi_bs-GetMemoryMap(info_size, NULL, map_key, - efi_mdesc_size, mdesc_ver); -info_size += 8 * efi_mdesc_size; -efi_memmap = efi_arch_allocate_mmap_buffer(info_size); -if ( !efi_memmap ) -blexit(LUnable to allocate memory for EFI memory map); - -for ( retry = 0; ; retry = 1 ) -{ -efi_memmap_size = info_size; -status = SystemTable-BootServices-GetMemoryMap(efi_memmap_size, - efi_memmap, map_key, - efi_mdesc_size, - mdesc_ver); -if ( EFI_ERROR(status) ) -PrintErrMesg(LCannot obtain memory map, status); - -efi_arch_process_memory_map(SystemTable, efi_memmap, efi_memmap_size, -efi_mdesc_size, mdesc_ver); - -efi_arch_pre_exit_boot(); - -status = SystemTable-BootServices-ExitBootServices(ImageHandle, - map_key); -efi_bs = NULL; -if ( status != EFI_INVALID_PARAMETER || retry ) -break; -} - -if ( EFI_ERROR(status) ) -PrintErrMesg(LCannot exit boot services, status); - -/* Adjust pointers into EFI. */ -efi_ct = (void *)efi_ct + DIRECTMAP_VIRT_START; -#ifdef USE_SET_VIRTUAL_ADDRESS_MAP -efi_rs = (void *)efi_rs + DIRECTMAP_VIRT_START; -#endif -efi_memmap = (void *)efi_memmap + DIRECTMAP_VIRT_START; -efi_fw_vendor = (void *)efi_fw_vendor + DIRECTMAP_VIRT_START; +efi_exit_boot(ImageHandle, SystemTable); efi_arch_post_exit_boot(); for( ; ; );
[PATCH v2 12/23] efi: split out efi_console_set_mode()
..which sets console mode. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 37 - 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 6f327cd..4614146 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -611,6 +611,25 @@ static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTabl StdErr = SystemTable-StdErr ?: StdOut; } +static void __init efi_console_set_mode(void) +{ +UINTN cols, rows, size; +unsigned int best, i; + +for ( i = 0, size = 0, best = StdOut-Mode-Mode; + i StdOut-Mode-MaxMode; ++i ) +{ +if ( StdOut-QueryMode(StdOut, i, cols, rows) == EFI_SUCCESS + cols * rows size ) +{ +size = cols * rows; +best = i; +} +} +if ( best != StdOut-Mode-Mode ) +StdOut-SetMode(StdOut, best); +} + static void __init setup_efi_pci(void) { EFI_STATUS status; @@ -799,23 +818,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) } if ( !base_video ) -{ -unsigned int best; -UINTN cols, rows, size; - -for ( i = 0, size = 0, best = StdOut-Mode-Mode; - i StdOut-Mode-MaxMode; ++i ) -{ -if ( StdOut-QueryMode(StdOut, i, cols, rows) == EFI_SUCCESS - cols * rows size ) -{ -size = cols * rows; -best = i; -} -} -if ( best != StdOut-Mode-Mode ) -StdOut-SetMode(StdOut, best); -} +efi_console_set_mode(); } PrintStr(LXen __stringify(XEN_VERSION) . __stringify(XEN_SUBVERSION) -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 07/23] x86/boot/reloc: Rename some variables and rearrange code a bit
Rename mbi and mbi_old variables and rearrange code a bit to make it more readable. Additionally, this way multiboot (v1) protocol implementation and future multiboot2 protocol implementation will use the same variable naming convention. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - extract this change from main mutliboot2 protocol implementation (suggested by Jan Beulich). --- xen/arch/x86/boot/reloc.c | 39 +-- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 09fd540..feb1d72 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -86,41 +86,44 @@ static u32 copy_string(u32 src) return copy_mem(src, p - src + 1); } -multiboot_info_t *reloc(u32 mbi_old) +multiboot_info_t *reloc(u32 mbi_in) { -multiboot_info_t *mbi = (multiboot_info_t *)copy_mem(mbi_old, sizeof(*mbi)); int i; +multiboot_info_t *mbi_out; -if ( mbi-flags MBI_CMDLINE ) -mbi-cmdline = copy_string(mbi-cmdline); +mbi_out = (multiboot_info_t *)copy_mem(mbi_in, sizeof(*mbi_out)); -if ( mbi-flags MBI_MODULES ) +if ( mbi_out-flags MBI_CMDLINE ) +mbi_out-cmdline = copy_string(mbi_out-cmdline); + +if ( mbi_out-flags MBI_MODULES ) { module_t *mods; -mbi-mods_addr = copy_mem(mbi-mods_addr, mbi-mods_count * sizeof(module_t)); +mbi_out-mods_addr = copy_mem(mbi_out-mods_addr, + mbi_out-mods_count * sizeof(module_t)); -mods = (module_t *)mbi-mods_addr; +mods = (module_t *)mbi_out-mods_addr; -for ( i = 0; i mbi-mods_count; i++ ) +for ( i = 0; i mbi_out-mods_count; i++ ) { if ( mods[i].string ) mods[i].string = copy_string(mods[i].string); } } -if ( mbi-flags MBI_MEMMAP ) -mbi-mmap_addr = copy_mem(mbi-mmap_addr, mbi-mmap_length); +if ( mbi_out-flags MBI_MEMMAP ) +mbi_out-mmap_addr = copy_mem(mbi_out-mmap_addr, mbi_out-mmap_length); -if ( mbi-flags MBI_LOADERNAME ) -mbi-boot_loader_name = copy_string(mbi-boot_loader_name); +if ( mbi_out-flags MBI_LOADERNAME ) +mbi_out-boot_loader_name = copy_string(mbi_out-boot_loader_name); /* Mask features we don't understand or don't relocate. */ -mbi-flags = (MBI_MEMLIMITS | - MBI_CMDLINE | - MBI_MODULES | - MBI_MEMMAP | - MBI_LOADERNAME); +mbi_out-flags = (MBI_MEMLIMITS | + MBI_CMDLINE | + MBI_MODULES | + MBI_MEMMAP | + MBI_LOADERNAME); -return mbi; +return mbi_out; } -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 10/23] efi: build xen.gz with EFI code
Build xen.gz with EFI code. We need this to support multiboot2 protocol on EFI platforms. If we wish to load not ELF file using multiboot (v1) or multiboot2 then it must contain linear (or flat) representation of code and data. Currently, PE file contains many sections which are not linear (one after another without any holes) or even do not have representation in a file (e.g. BSS). In theory there is a chance that we could build proper PE file using current build system. However, it means that xen.efi further diverge from xen ELF file (in terms of contents and build method). ELF have all needed properties. So, it means that this is good starting point for further development. Additionally, I think that this is also good starting point for further xen.efi code and build optimizations. It looks that there is a chance that finally we can generate xen.efi directly from xen ELF using just simple objcopy. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - build EFI code only if it is supported in a given build environment (suggested by Jan Beulich). --- xen/arch/x86/Makefile | 13 + xen/arch/x86/efi/Makefile | 16 +--- xen/arch/x86/mm.c |3 ++- xen/common/efi/runtime.c |6 ++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 5f24951..0335445 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -80,7 +80,7 @@ ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in ifeq ($(lto),y) # Gather all LTO objects together -prelink_lto.o: $(ALL_OBJS) +prelink_lto.o: $(ALL_OBJS) efi/relocs-dummy.o $(LD_LTO) -r -o $@ $^ prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/compat.o @@ -90,14 +90,14 @@ prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/compat.o prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o $(LD) $(LDFLAGS) -r -o $@ $^ -prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o efi/boot.init.o +prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o $(guard) $(LD) $(LDFLAGS) -r -o $@ $^ else -prelink.o: $(ALL_OBJS) +prelink.o: $(ALL_OBJS) efi/relocs-dummy.o $(LD) $(LDFLAGS) -r -o $@ $^ -prelink-efi.o: $(ALL_OBJS) efi/boot.init.o efi/runtime.o efi/compat.o - $(guard) $(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^) +prelink-efi.o: $(ALL_OBJS) + $(guard) $(LD) $(LDFLAGS) -r -o $@ $^ endif $(BASEDIR)/common/symbols-dummy.o: @@ -146,9 +146,6 @@ $(TARGET).efi: prelink-efi.o efi.lds efi/relocs-dummy.o $(BASEDIR)/common/symbol if $(guard) false; then rm -f $@; echo 'EFI support disabled'; fi rm -f $(@D)/.$(@F).[0-9]* -efi/boot.init.o efi/runtime.o efi/compat.o: $(BASEDIR)/arch/x86/efi/built_in.o -efi/boot.init.o efi/runtime.o efi/compat.o: ; - asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(CC) $(filter-out -flto,$(CFLAGS)) -S -o $@ $ diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 1daa7ac..b1e8883 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -1,14 +1,16 @@ CFLAGS += -fshort-wchar -obj-y += stub.o - -create = test -e $(1) || touch -t 19990101 $(1) - efi := $(filter y,$(x86_64)$(shell rm -f disabled)) efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c check.c 2disabled echo y)) efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o check.efi check.o 2disabled echo y)) -efi := $(if $(efi),$(shell rm disabled)y,$(shell $(call create,boot.init.o); $(call create,runtime.o))) +efi := $(if $(efi),$(shell rm disabled)y) -extra-$(efi) += boot.init.o relocs-dummy.o runtime.o compat.o +extra-y += relocs-dummy.o -stub.o: $(extra-y) +ifeq ($(efi),y) +obj-y += boot.init.o +obj-y += compat.o +obj-y += runtime.o +else +obj-y += stub.o +endif diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 342414f..cef2eb6 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -344,7 +344,8 @@ void __init arch_init_memory(void) subarch_init_memory(); -efi_init_memory(); +if ( efi_enabled(EFI_PLATFORM) ) +efi_init_memory(); mem_sharing_init(); diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c index aa064e7..3eb21c1 100644 --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -167,6 +167,9 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) { unsigned int i, n; +if ( !efi_enabled(EFI_PLATFORM) ) +return -EOPNOTSUPP; + switch ( idx ) { case XEN_FW_EFI_VERSION: @@ -301,6 +304,9 @@ int efi_runtime_call(struct xenpf_efi_runtime_call *op) EFI_STATUS status = EFI_NOT_STARTED; int rc = 0; +if ( !efi_enabled(EFI_PLATFORM) ) +return -EOPNOTSUPP; + switch ( op-function ) { case XEN_EFI_get_time: -- 1.7.10.4
[PATCH v2 08/23] x86: add multiboot2 protocol support
Add multiboot2 protocol support. Alter min memory limit handling as we now may not find it from either multiboot (v1) or multiboot2. This way we are laying the foundation for EFI + GRUB2 + Xen development. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com --- v2 - suggestions/fixes: - generate multiboot2 header using macros (suggested by Jan Beulich), - improve comments (suggested by Jan Beulich), - simplify assembly in xen/arch/x86/boot/head.S (suggested by Jan Beulich), - do not include include/xen/compiler.h in xen/arch/x86/boot/reloc.c (suggested by Jan Beulich), - do not read data beyond the end of Multiboot2 information (suggested by Jan Beulich). v2 - not fixed yet: - dynamic dependency generation for xen/arch/x86/boot/reloc.S; this requires more work; I am not sure that it pays because potential patch requires more changes than addition of just multiboot2.h to Makefile (suggested by Jan Beulich), - isolated/stray __packed attribute usage for multiboot2_memory_map_t (suggested by Jan Beulich). --- xen/arch/x86/boot/Makefile|3 +- xen/arch/x86/boot/head.S | 105 +-- xen/arch/x86/boot/reloc.c | 146 +++- xen/arch/x86/x86_64/asm-offsets.c |7 ++ xen/include/xen/multiboot2.h | 169 + 5 files changed, 420 insertions(+), 10 deletions(-) create mode 100644 xen/include/xen/multiboot2.h diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile index 5fdb5ae..06893d8 100644 --- a/xen/arch/x86/boot/Makefile +++ b/xen/arch/x86/boot/Makefile @@ -1,6 +1,7 @@ obj-bin-y += head.o -RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h \ +$(BASEDIR)/include/xen/multiboot2.h head.o: reloc.S diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 77e7da9..57197db 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -1,5 +1,6 @@ #include xen/config.h #include xen/multiboot.h +#include xen/multiboot2.h #include public/xen.h #include asm/asm_defns.h #include asm/desc.h @@ -19,6 +20,28 @@ #define BOOT_PSEUDORM_CS 0x0020 #define BOOT_PSEUDORM_DS 0x0028 +#define MB2_HT(name) (MULTIBOOT2_HEADER_TAG_##name) +#define MB2_TT(name) (MULTIBOOT2_TAG_TYPE_##name) + +.macro mb2ht_args arg, args:vararg +.long \arg +.ifnb \args +mb2ht_args \args +.endif +.endm + +.macro mb2ht_init type, req, args:vararg +.align MULTIBOOT2_TAG_ALIGN +0: +.short \type +.short \req +.long 1f - 0b +.ifnb \args +mb2ht_args \args +.endif +1: +.endm + ENTRY(start) jmp __start @@ -34,6 +57,42 @@ multiboot1_header_start: /*** MULTIBOOT1 HEADER / .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) multiboot1_header_end: +/*** MULTIBOOT2 HEADER / +/* Some ideas are taken from grub-2.00/grub-core/tests/boot/kernel-i386.S file. */ +.align MULTIBOOT2_HEADER_ALIGN + +.Lmultiboot2_header: +/* Magic number indicating a Multiboot2 header. */ +.long MULTIBOOT2_HEADER_MAGIC +/* Architecture: i386. */ +.long MULTIBOOT2_ARCHITECTURE_I386 +/* Multiboot2 header length. */ +.long .Lmultiboot2_header_end - .Lmultiboot2_header +/* Multiboot2 header checksum. */ +.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 + \ +(.Lmultiboot2_header_end - .Lmultiboot2_header)) + +/* Multiboot2 information request tag. */ +mb2ht_init MB2_HT(INFORMATION_REQUEST), MB2_HT(REQUIRED), \ + MB2_TT(BASIC_MEMINFO), MB2_TT(MMAP) + +/* Align modules at page boundry. */ +mb2ht_init MB2_HT(MODULE_ALIGN), MB2_HT(REQUIRED) + +/* Console flags tag. */ +mb2ht_init MB2_HT(CONSOLE_FLAGS), MB2_HT(OPTIONAL), \ + MULTIBOOT2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED + +/* Framebuffer tag. */ +mb2ht_init MB2_HT(FRAMEBUFFER), MB2_HT(OPTIONAL), \ + 0, /* Number of the columns - no preference. */ \ + 0, /* Number of the lines - no preference. */ \ + 0 /* Number of bits per pixel - no preference. */ + +/* Multiboot2 header end tag. */ +mb2ht_init MB2_HT(END), MB2_HT(REQUIRED) +.Lmultiboot2_header_end: + .section .init.rodata, a, @progbits .align 4 @@ -82,10 +141,48 @@ __start: mov %ecx,%es mov %ecx,%ss -/* Check for Multiboot bootloader */ +/* Bootloaders may set multiboot{1,2}.mem_lower to a nonzero value. */ +xor %edx,%edx + +
[PATCH v2 19/23] x86/efi: create new early memory allocator
There is a problem with place_string() which is used as early memory allocator. It gets memory chunks starting from start symbol and going down. Sadly this does not work when Xen is loaded using multiboot2 protocol because start lives on 1 MiB address. So, I tried to use mem_lower address calculated by GRUB2. However, it works only on some machines. There are machines in the wild (e.g. Dell PowerEdge R820) which uses first ~640 KiB for boot services code or data... :-((( In case of multiboot2 protocol we need that place_string() only allocate memory chunk for EFI memory map. However, I think that it should be fixed instead of making another function used just in one case. I thought about two solutions. 1) We could use native EFI allocation functions (e.g. AllocatePool() or AllocatePages()) to get memory chunk. However, later (somewhere in __start_xen()) we must copy its contents to safe place or reserve this in e820 memory map and map it in Xen virtual address space. In later case we must also care about conflicts with e.g. crash kernel regions which could be quite difficult. 2) We may allocate memory area statically somewhere in Xen code which could be used as memory pool for early dynamic allocations. Looks quite simple. Additionally, it would not depend on EFI at all and could be used on legacy BIOS platforms if we need it. However, we must carefully choose size of this pool. We do not want increase Xen binary size too much and waste too much memory but also we must fit at least memory map on x86 EFI platforms. As I saw on small machine, e.g. IBM System x3550 M2 with 8 GiB RAM, memory map may contain more than 200 entries. Every entry on x86-64 platform is 40 bytes in size. So, it means that we need more than 8 KiB for EFI memory map only. Additionally, if we want to use this memory pool for Xen and modules command line storage (it would be used when xen.efi is executed as EFI application) then we should add, I think, about 1 KiB. In this case, to be on safe side, we should assume at least 64 KiB pool for early memory allocations, which is about 4 times of our earlier calculations. However, during discussion on Xen-devel Jan Beulich suggested that just in case we should use 1 MiB memory pool like it was in original place_string() implementation. So, let's use 1 MiB as it was proposed. If we think that we should not waste unallocated memory in the pool on running system then we can mark this region as __initdata and move all required data to dynamically allocated places somewhere in __start_xen(). Now solution #2 is implemented but maybe we should consider #1 one day. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/efi/efi-boot.h | 38 ++ xen/arch/x86/setup.c|3 +-- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 2dd69f6..3d25c48 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -103,9 +103,36 @@ static void __init relocate_trampoline(unsigned long phys) *(u16 *)(*trampoline_ptr + (long)trampoline_ptr) = phys 4; } +#define EBMALLOC_SIZE MB(1) + +static char __initdata ebmalloc_mem[EBMALLOC_SIZE]; +static char __initdata *ebmalloc_free = NULL; + +/* EFI boot allocator. */ +static void __init *ebmalloc(size_t size) +{ +void *ptr; + +/* + * Init ebmalloc_free on runtime. Static initialization + * will not work because it puts virtual address there. + */ +if ( ebmalloc_free == NULL ) +ebmalloc_free = ebmalloc_mem; + +ptr = ebmalloc_free; + +ebmalloc_free += size; + +if ( ebmalloc_free - ebmalloc_mem sizeof(ebmalloc_mem) ) +blexit(LOut of static memory\r\n); + +return ptr; +} + static void __init place_string(u32 *addr, const char *s) { -static char *__initdata alloc = start; +char *alloc = NULL; if ( s *s ) { @@ -113,7 +140,7 @@ static void __init place_string(u32 *addr, const char *s) const char *old = (char *)(long)*addr; size_t len2 = *addr ? strlen(old) + 1 : 0; -alloc -= len1 + len2; +alloc = ebmalloc(len1 + len2); /* * Insert new string before already existing one. This is needed * for options passed on the command line to override options from @@ -196,12 +223,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, 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; +return ebmalloc(map_size); } static void __init efi_arch_pre_exit_boot(void) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index
[PATCH v2 21/23] x86/boot: implement early command line parser in C
Current early command line parser implementation in assembler is very difficult to change to relocatable stuff using segment registers. This requires a lot of changes in very weird and fragile code. So, reimplement this functionality in C. This way code will be relocatable out of the box and much easier to maintain. Suggested-by: Andrew Cooper andrew.coop...@citrix.com Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- .gitignore |5 +- xen/arch/x86/Makefile |2 +- xen/arch/x86/boot/Makefile |7 +- xen/arch/x86/boot/build32.mk |2 + xen/arch/x86/boot/cmdline.S| 367 - xen/arch/x86/boot/cmdline.c| 396 xen/arch/x86/boot/edd.S|3 - xen/arch/x86/boot/head.S | 17 ++ xen/arch/x86/boot/trampoline.S | 14 ++ xen/arch/x86/boot/video.S |6 - 10 files changed, 439 insertions(+), 380 deletions(-) delete mode 100644 xen/arch/x86/boot/cmdline.S create mode 100644 xen/arch/x86/boot/cmdline.c diff --git a/.gitignore b/.gitignore index f6ddb00..e0618b9 100644 --- a/.gitignore +++ b/.gitignore @@ -223,9 +223,10 @@ xen/arch/arm/xen.lds xen/arch/x86/asm-offsets.s xen/arch/x86/boot/mkelf32 xen/arch/x86/xen.lds +xen/arch/x86/boot/cmdline.S xen/arch/x86/boot/reloc.S -xen/arch/x86/boot/reloc.bin -xen/arch/x86/boot/reloc.lnk +xen/arch/x86/boot/*.bin +xen/arch/x86/boot/*.lnk xen/arch/x86/efi.lds xen/arch/x86/efi/check.efi xen/arch/x86/efi/disabled diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 0335445..82c5a93 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -170,4 +170,4 @@ clean:: rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32 rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.o efi/.*.d efi/*.efi efi/disabled efi/mkreloc - rm -f boot/reloc.S boot/reloc.lnk boot/reloc.bin + rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile index 06893d8..d73cc76 100644 --- a/xen/arch/x86/boot/Makefile +++ b/xen/arch/x86/boot/Makefile @@ -1,9 +1,14 @@ obj-bin-y += head.o +CMDLINE_DEPS = video.h + RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h \ $(BASEDIR)/include/xen/multiboot2.h -head.o: reloc.S +head.o: cmdline.S reloc.S + +cmdline.S: cmdline.c $(CMDLINE_DEPS) + $(MAKE) -f build32.mk $@ CMDLINE_DEPS=$(CMDLINE_DEPS) reloc.S: reloc.c $(RELOC_DEPS) $(MAKE) -f build32.mk $@ RELOC_DEPS=$(RELOC_DEPS) diff --git a/xen/arch/x86/boot/build32.mk b/xen/arch/x86/boot/build32.mk index c83effe..d681643 100644 --- a/xen/arch/x86/boot/build32.mk +++ b/xen/arch/x86/boot/build32.mk @@ -30,6 +30,8 @@ CFLAGS := $(filter-out -flto,$(CFLAGS)) esac; \ done +cmdline.o: cmdline.c $(CMDLINE_DEPS) + reloc.o: reloc.c $(RELOC_DEPS) .PRECIOUS: %.bin %.lnk diff --git a/xen/arch/x86/boot/cmdline.S b/xen/arch/x86/boot/cmdline.S deleted file mode 100644 index 00687eb..000 --- a/xen/arch/x86/boot/cmdline.S +++ /dev/null @@ -1,367 +0,0 @@ -/** - * cmdline.S - * - * Early command-line parsing. - */ - -.code32 - -#include video.h - -# NB. String pointer on stack is modified to point past parsed digits. -.Latoi: -push%ebx -push%ecx -push%edx -push%esi -xor %ebx,%ebx /* %ebx = accumulator */ -mov $10,%ecx/* %ecx = base (default base 10) */ -mov 16+4(%esp),%esi /* %esi = pointer into ascii string. */ -lodsb -cmpb$'0',%al -jne 2f -mov $8,%ecx /* Prefix '0' = octal (base 8) */ -lodsb -cmpb$'x',%al -jne 2f -mov $16,%ecx/* Prefix '0x' = hex (base 16) */ -1: lodsb -2: sub $'0',%al -jb 4f -cmp $9,%al -jbe 3f -sub $'A'-'0'-10,%al -jb 4f -cmp $15,%al -jbe 3f -sub $'a'-'A',%al -jb 4f -3: cmp %cl,%al -jae 4f -movzbl %al,%eax -xchg%eax,%ebx -mul %ecx -xchg%eax,%ebx -add %eax,%ebx -jmp 1b -4: mov %ebx,%eax -dec %esi -mov %esi,16+4(%esp) -pop %esi -pop %edx -pop %ecx -pop %ebx -ret - -.Lstrstr: -push%ecx -push%edx -push%esi -push%edi -xor %eax,%eax -xor %ecx,%ecx -not %ecx -mov 16+4(%esp),%esi -mov 16+8(%esp),%edi -repne scasb -not %ecx -dec %ecx -mov %ecx,%edx -1:
[PATCH v2 11/23] efi: split out efi_init()
..which initializes basic EFI variables. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 28 +--- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 1f188fe..6f327cd 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -595,6 +595,22 @@ static char *__init get_value(const struct file *cfg, const char *section, return NULL; } +static void __init efi_init(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) +{ +efi_ih = ImageHandle; +efi_bs = SystemTable-BootServices; +efi_bs_revision = efi_bs-Hdr.Revision; +efi_rs = SystemTable-RuntimeServices; +efi_ct = SystemTable-ConfigurationTable; +efi_num_ct = SystemTable-NumberOfTableEntries; +efi_version = SystemTable-Hdr.Revision; +efi_fw_vendor = SystemTable-FirmwareVendor; +efi_fw_revision = SystemTable-FirmwareRevision; + +StdOut = SystemTable-ConOut; +StdErr = SystemTable-StdErr ?: StdOut; +} + static void __init setup_efi_pci(void) { EFI_STATUS status; @@ -721,18 +737,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) set_bit(EFI_PLATFORM, efi.flags); #endif -efi_ih = ImageHandle; -efi_bs = SystemTable-BootServices; -efi_bs_revision = efi_bs-Hdr.Revision; -efi_rs = SystemTable-RuntimeServices; -efi_ct = SystemTable-ConfigurationTable; -efi_num_ct = SystemTable-NumberOfTableEntries; -efi_version = SystemTable-Hdr.Revision; -efi_fw_vendor = SystemTable-FirmwareVendor; -efi_fw_revision = SystemTable-FirmwareRevision; +efi_init(ImageHandle, SystemTable); -StdOut = SystemTable-ConOut; -StdErr = SystemTable-StdErr ?: StdOut; use_cfg_file = efi_arch_use_config_file(SystemTable); status = efi_bs-HandleProtocol(ImageHandle, loaded_image_guid, -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 22/23] x86: make Xen early boot code relocatable
Every multiboot protocol (regardless of version) compatible image must specify its load address (in ELF or multiboot header). Multiboot protocol compatible loader have to load image at specified address. However, there is no guarantee that the requested memory region (in case of Xen it starts at 1 MiB and ends at 17 MiB) where image should be loaded initially is a RAM and it is free (legacy BIOS platforms are merciful for Xen but I found at least one EFI platform on which Xen load address conflicts with EFI boot services; it is Dell PowerEdge R820 with latest firmware). To cope with that problem we must make Xen early boot code relocatable. This patch does that. However, it does not add multiboot2 protocol interface which is done in next patch. This patch changes following things: - default load address is changed from 1 MiB to 2 MiB; I did that because initial page tables are using 2 MiB huge pages and this way required updates for them are quite easy; it means that e.g. we avoid spacial cases for beginning and end of required memory region if it live at address not aligned to 2 MiB, - %ebp register is used as a storage for Xen image base address; this way we can get this value very quickly if it is needed; however, %ebp register is not used directly to access a given memory region, - %fs register is filled with segment descriptor which describes memory region with Xen image (it could be relocated or not); it is used to access some of Xen data in early boot code; potentially we can use above mentioned segment descriptor to access data using %ds:%esi and/or %es:%esi (e.g. movs*); however, I think that it could unnecessarily obfuscate code (e.g. we need at least to operations to reload a given segment descriptor) and current solution looks quite optimal. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/Makefile |6 +- xen/arch/x86/Rules.mk |4 + xen/arch/x86/boot/head.S | 165 ++-- xen/arch/x86/boot/trampoline.S | 11 ++- xen/arch/x86/boot/wakeup.S |6 +- xen/arch/x86/boot/x86_64.S | 34 - xen/arch/x86/setup.c | 33 xen/arch/x86/x86_64/mm.c |2 +- xen/arch/x86/xen.lds.S |2 +- xen/include/asm-x86/config.h |3 + xen/include/asm-x86/page.h |2 +- 11 files changed, 182 insertions(+), 86 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 82c5a93..93069a8 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -72,8 +72,10 @@ efi-$(x86_64) := $(shell if [ ! -r $(BASEDIR)/include/xen/compile.h -o \ echo '$(TARGET).efi'; fi) $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 - ./boot/mkelf32 $(TARGET)-syms $(TARGET) 0x10 \ - `$(NM) -nr $(TARGET)-syms | head -n 1 | sed -e 's/^\([^ ]*\).*/0x\1/'` +# THIS IS UGLY HACK! PLEASE DO NOT COMPLAIN. I WILL FIX IT IN NEXT RELEASE. + ./boot/mkelf32 $(TARGET)-syms $(TARGET) $(XEN_IMG_PHYS_START) 0x82d08100 +# ./boot/mkelf32 $(TARGET)-syms $(TARGET) 0x10 \ +# `$(NM) -nr $(TARGET)-syms | head -n 1 | sed -e 's/^\([^ ]*\).*/0x\1/'` ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS) diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk index 4a04a8a..7ccb8a0 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -15,6 +15,10 @@ HAS_GDBSX := y HAS_PDX := y xenoprof := y +XEN_IMG_PHYS_START = 0x20 + +CFLAGS += -DXEN_IMG_PHYS_START=$(XEN_IMG_PHYS_START) + CFLAGS += -I$(BASEDIR)/include CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 3f1054d..d484f68 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -12,13 +12,15 @@ .text .code32 -#define sym_phys(sym) ((sym) - __XEN_VIRT_START) +#define sym_phys(sym) ((sym) - __XEN_VIRT_START + XEN_IMG_PHYS_START - XEN_IMG_OFFSET) +#define sym_offset(sym) ((sym) - __XEN_VIRT_START) #define BOOT_CS320x0008 #define BOOT_CS640x0010 #define BOOT_DS 0x0018 #define BOOT_PSEUDORM_CS 0x0020 #define BOOT_PSEUDORM_DS 0x0028 +#define BOOT_FS 0x0030 #define MB2_HT(name) (MULTIBOOT2_HEADER_TAG_##name) #define MB2_TT(name) (MULTIBOOT2_TAG_TYPE_##name) @@ -105,12 +107,13 @@ multiboot1_header_end: .word 0 gdt_boot_descr: -.word 6*8-1 -.long sym_phys(trampoline_gdt) +.word 7*8-1 +gdt_boot_descr_addr: +.long sym_offset(trampoline_gdt) .long 0 /* Needed for 64-bit lgdt */ cs32_switch_addr: -.long sym_phys(cs32_switch) +.long sym_offset(cs32_switch) .word BOOT_CS32 .Lbad_cpu_msg: .asciz ERR: Not a 64-bit CPU! @@ -120,13
[PATCH v2 14/23] efi: split out efi_find_gop_mode()
..which finds suitable GOP mode. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 94 - 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 6fad230..8d16470 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -665,6 +665,58 @@ static EFI_GRAPHICS_OUTPUT_PROTOCOL __init *efi_get_gop(void) return gop; } +static UINTN __init efi_find_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, + UINTN cols, UINTN rows, UINTN depth) +{ +EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; +EFI_STATUS status; +UINTN gop_mode = ~0, info_size, size; +unsigned int i; + +if ( !gop ) +return gop_mode; + +for ( i = size = 0; i gop-Mode-MaxMode; ++i ) +{ +unsigned int bpp = 0; + +status = gop-QueryMode(gop, i, info_size, mode_info); +if ( EFI_ERROR(status) ) +continue; +switch ( mode_info-PixelFormat ) +{ +case PixelBitMask: +bpp = hweight32(mode_info-PixelInformation.RedMask | +mode_info-PixelInformation.GreenMask | +mode_info-PixelInformation.BlueMask); +break; +case PixelRedGreenBlueReserved8BitPerColor: +case PixelBlueGreenRedReserved8BitPerColor: +bpp = 24; +break; +default: +continue; +} +if ( cols == mode_info-HorizontalResolution + rows == mode_info-VerticalResolution + (!depth || bpp == depth) ) +{ +gop_mode = i; +break; +} +if ( !cols !rows + mode_info-HorizontalResolution * + mode_info-VerticalResolution size ) +{ +size = mode_info-HorizontalResolution * + mode_info-VerticalResolution; +gop_mode = i; +} +} + +return gop_mode; +} + static void __init setup_efi_pci(void) { EFI_STATUS status; @@ -978,46 +1030,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) dir_handle-Close(dir_handle); -if ( gop !base_video ) -{ -for ( i = size = 0; i gop-Mode-MaxMode; ++i ) -{ -unsigned int bpp = 0; - -status = gop-QueryMode(gop, i, info_size, mode_info); -if ( EFI_ERROR(status) ) -continue; -switch ( mode_info-PixelFormat ) -{ -case PixelBitMask: -bpp = hweight32(mode_info-PixelInformation.RedMask | -mode_info-PixelInformation.GreenMask | -mode_info-PixelInformation.BlueMask); -break; -case PixelRedGreenBlueReserved8BitPerColor: -case PixelBlueGreenRedReserved8BitPerColor: -bpp = 24; -break; -default: -continue; -} -if ( cols == mode_info-HorizontalResolution - rows == mode_info-VerticalResolution - (!depth || bpp == depth) ) -{ -gop_mode = i; -break; -} -if ( !cols !rows - mode_info-HorizontalResolution * - mode_info-VerticalResolution size ) -{ -size = mode_info-HorizontalResolution * - mode_info-VerticalResolution; -gop_mode = i; -} -} -} +if ( !base_video ) +gop_mode = efi_find_gop_mode(gop, cols, rows, depth); } efi_arch_edd(); -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 17/23] efi: split out efi_set_gop_mode()
..which sets chosen GOP mode. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 33 - 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 177697a..04b9c7e 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -860,6 +860,25 @@ static void __init efi_variables(void) } } +static void __init efi_set_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop_mode) +{ +EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; +EFI_STATUS status; +UINTN info_size; + +if ( !gop ) +return; + +/* Set graphics mode. */ +if ( gop_mode gop-Mode-MaxMode gop_mode != gop-Mode-Mode ) +gop-SetMode(gop, gop_mode); + +/* Get graphics and frame buffer info. */ +status = gop-QueryMode(gop, gop-Mode-Mode, info_size, mode_info); +if ( !EFI_ERROR(status) ) +efi_arch_video_init(gop, info_size, mode_info); +} + static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz) { if ( bpp 0 ) @@ -887,7 +906,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) UINTN map_key, info_size, gop_mode = ~0; EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; -EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; union string section = { NULL }, name; bool_t base_video = 0, retry; char *option_str; @@ -1105,18 +1123,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_arch_memory_setup(); -if ( gop ) -{ - -/* Set graphics mode. */ -if ( gop_mode gop-Mode-MaxMode gop_mode != gop-Mode-Mode ) -gop-SetMode(gop, gop_mode); - -/* Get graphics and frame buffer info. */ -status = gop-QueryMode(gop, gop-Mode-Mode, info_size, mode_info); -if ( !EFI_ERROR(status) ) -efi_arch_video_init(gop, info_size, mode_info); -} +efi_set_gop_mode(gop, gop_mode); info_size = 0; efi_bs-GetMemoryMap(info_size, NULL, map_key, -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 09/23] efi: create efi_enabled()
We need more fine grained knowledge about EFI environment and check for EFI platform and EFI loader separately to properly support multiboot2 protocol. In general Xen loaded by this protocol uses memory mappings and loaded modules in similar way to Xen loaded by multiboot (v1) protocol. Hence, create efi_enabled() which checks available features in efi.flags. This patch only defines EFI_PLATFORM feature which is equal to old efi_enabled == 1. Following patch will define EFI_LOADER feature accordingly. Suggested-by: Jan Beulich jbeul...@suse.com Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/dmi_scan.c|4 ++-- xen/arch/x86/domain_page.c |2 +- xen/arch/x86/efi/stub.c| 11 --- xen/arch/x86/mpparse.c |4 ++-- xen/arch/x86/setup.c | 10 +- xen/arch/x86/shutdown.c|2 +- xen/arch/x86/time.c|2 +- xen/arch/x86/xen.lds.S |2 -- xen/common/efi/boot.c |4 xen/common/efi/runtime.c | 17 +++-- xen/drivers/acpi/osl.c |2 +- xen/include/xen/efi.h | 16 ++-- 12 files changed, 46 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c index 269168c..95c5a77 100644 --- a/xen/arch/x86/dmi_scan.c +++ b/xen/arch/x86/dmi_scan.c @@ -229,7 +229,7 @@ const char *__init dmi_get_table(paddr_t *base, u32 *len) { static unsigned int __initdata instance; - if (efi_enabled) { + if (efi_enabled(EFI_PLATFORM)) { if (efi_smbios3_size !(instance 1)) { *base = efi_smbios3_address; *len = efi_smbios3_size; @@ -693,7 +693,7 @@ static void __init dmi_decode(struct dmi_header *dm) void __init dmi_scan_machine(void) { - if ((!efi_enabled ? dmi_iterate(dmi_decode) : + if ((!efi_enabled(EFI_PLATFORM) ? dmi_iterate(dmi_decode) : dmi_efi_iterate(dmi_decode)) == 0) dmi_check_system(dmi_blacklist); else diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index d86f8fe..fdf0d8a 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -36,7 +36,7 @@ static inline struct vcpu *mapcache_current_vcpu(void) * domain's page tables but current may point at another domain's VCPU. * Return NULL as though current is not properly set up yet. */ -if ( efi_enabled efi_rs_using_pgtables() ) +if ( efi_enabled(EFI_PLATFORM) efi_rs_using_pgtables() ) return NULL; /* diff --git a/xen/arch/x86/efi/stub.c b/xen/arch/x86/efi/stub.c index 07c2bd0..c5ae369 100644 --- a/xen/arch/x86/efi/stub.c +++ b/xen/arch/x86/efi/stub.c @@ -4,9 +4,14 @@ #include xen/lib.h #include asm/page.h -#ifndef efi_enabled -const bool_t efi_enabled = 0; -#endif +struct efi __read_mostly efi = { + .flags = 0, /* Initialized later. */ + .acpi= EFI_INVALID_TABLE_ADDR, + .acpi20 = EFI_INVALID_TABLE_ADDR, + .mps = EFI_INVALID_TABLE_ADDR, + .smbios = EFI_INVALID_TABLE_ADDR, + .smbios3 = EFI_INVALID_TABLE_ADDR +}; void __init efi_init_memory(void) { } diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c index 8609f4a..5223579 100644 --- a/xen/arch/x86/mpparse.c +++ b/xen/arch/x86/mpparse.c @@ -557,7 +557,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type) static __init void efi_unmap_mpf(void) { - if (efi_enabled) + if (efi_enabled(EFI_PLATFORM)) clear_fixmap(FIX_EFI_MPF); } @@ -715,7 +715,7 @@ void __init find_smp_config (void) { unsigned int address; - if (efi_enabled) { + if (efi_enabled(EFI_PLATFORM)) { efi_check_config(); return; } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ff34670..bce708c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -444,8 +444,8 @@ static void __init parse_video_info(void) { struct boot_video_info *bvi = bootsym(boot_vid_info); -/* The EFI loader fills vga_console_info directly. */ -if ( efi_enabled ) +/* vga_console_info is filled directly on EFI platform. */ +if ( efi_enabled(EFI_PLATFORM) ) return; if ( (bvi-orig_video_isVGA == 1) (bvi-orig_video_mode == 3) ) @@ -695,7 +695,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( !(mbi-flags MBI_MODULES) || (mbi-mods_count == 0) ) panic(dom0 kernel not specified. Check bootloader configuration.); -if ( efi_enabled ) +if ( efi_enabled(EFI_PLATFORM) ) { set_pdx_range(xen_phys_start PAGE_SHIFT, (xen_phys_start + BOOTSTRAP_MAP_BASE) PAGE_SHIFT); @@ -806,7 +806,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * we can relocate the dom0 kernel and other multiboot modules. Also, on * x86/64, we relocate Xen to higher memory. */ -for ( i =
[PATCH v2 20/23] x86: add multiboot2 protocol support for EFI platforms
Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - generate multiboot2 header using macros (suggested by Jan Beulich), - switch CPU to x86_32 mode before jumping to 32-bit code (suggested by Andrew Cooper), - reduce code changes to increase patch readability (suggested by Jan Beulich), - improve comments (suggested by Jan Beulich), - ignore MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO tag on EFI platform and find on my own multiboot2.mem_lower value, - stop execution if EFI platform is detected in legacy BIOS path. --- xen/arch/x86/boot/head.S | 157 +++-- xen/arch/x86/efi/efi-boot.h | 30 +++ xen/arch/x86/efi/stub.c |5 ++ xen/arch/x86/setup.c | 10 ++- xen/arch/x86/x86_64/asm-offsets.c |2 + xen/arch/x86/xen.lds.S|4 +- xen/common/efi/boot.c | 12 +++ xen/include/xen/efi.h |1 + 8 files changed, 210 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 57197db..056047f 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -89,6 +89,13 @@ multiboot1_header_end: 0, /* Number of the lines - no preference. */ \ 0 /* Number of bits per pixel - no preference. */ +/* Do not disable EFI boot services. */ +mb2ht_init MB2_HT(EFI_BS), MB2_HT(OPTIONAL) + +/* EFI64 entry point. */ +mb2ht_init MB2_HT(ENTRY_ADDRESS_EFI64), MB2_HT(OPTIONAL), \ + sym_phys(__efi64_start) + /* Multiboot2 header end tag. */ mb2ht_init MB2_HT(END), MB2_HT(REQUIRED) .Lmultiboot2_header_end: @@ -100,9 +107,15 @@ multiboot1_header_end: gdt_boot_descr: .word 6*8-1 .long sym_phys(trampoline_gdt) +.long 0 /* Needed for 64-bit lgdt */ + +cs32_switch_addr: +.long sym_phys(cs32_switch) +.word BOOT_CS32 .Lbad_cpu_msg: .asciz ERR: Not a 64-bit CPU! .Lbad_ldr_msg: .asciz ERR: Not a Multiboot bootloader! +.Lbad_mb2_ldr: .asciz ERR: Use latest Multiboot2 compatible bootloader! .section .init.text, ax, @progbits @@ -111,6 +124,9 @@ bad_cpu: jmp print_err not_multiboot: mov $(sym_phys(.Lbad_ldr_msg)),%esi # Error message +jmp print_err +mb2_too_old: +mov $(sym_phys(.Lbad_mb2_ldr)),%esi # Error message print_err: mov $0xB8000,%edi # VGA framebuffer 1: mov (%esi),%bl @@ -130,6 +146,119 @@ print_err: .Lhalt: hlt jmp .Lhalt +.code64 + +__efi64_start: +cld + +/* Check for Multiboot2 bootloader. */ +cmp $MULTIBOOT2_BOOTLOADER_MAGIC,%eax +je efi_multiboot2_proto + +/* Jump to not_multiboot after switching CPU to x86_32 mode. */ +lea not_multiboot(%rip),%rdi +jmp x86_32_switch + +efi_multiboot2_proto: +/* + * Multiboot2 information address is 32-bit, + * so, zero higher half of %rbx. + */ +mov %ebx,%ebx + +/* Skip Multiboot2 information fixed part. */ +lea MB2_fixed_sizeof(%rbx),%rcx + +0: +/* Get EFI SystemTable address from Multiboot2 information. */ +cmpl$MULTIBOOT2_TAG_TYPE_EFI64,MB2_tag_type(%rcx) +jne 1f + +mov MB2_efi64_st(%rcx),%rsi + +/* Do not go into real mode on EFI platform. */ +movb$1,skip_realmode(%rip) +jmp 3f + +1: +/* Get EFI ImageHandle address from Multiboot2 information. */ +cmpl$MULTIBOOT2_TAG_TYPE_EFI64_IH,MB2_tag_type(%rcx) +jne 2f + +mov MB2_efi64_ih(%rcx),%rdi +jmp 3f + +2: +/* Is it the end of Multiboot2 information? */ +cmpl$MULTIBOOT2_TAG_TYPE_END,MB2_tag_type(%rcx) +je run_bs + +3: +/* Go to next Multiboot2 information tag. */ +add MB2_tag_size(%rcx),%ecx +add $(MULTIBOOT2_TAG_ALIGN-1),%rcx +and $~(MULTIBOOT2_TAG_ALIGN-1),%rcx +jmp 0b + +run_bs: +push%rax +push%rdi + +/* Initialize BSS (no nasty surprises!). */ +lea __bss_start(%rip),%rdi +lea __bss_end(%rip),%rcx +sub %rdi,%rcx +shr $3,%rcx +xor %eax,%eax +rep stosq + +pop %rdi + +/* + * IN: %rdi - EFI ImageHandle, %rsi - EFI SystemTable. + * OUT: %rax - multiboot2.mem_lower. Do not get this value from + * MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO tag. It could be bogus on + * EFI platforms. + */ +callefi_multiboot2 + +/* Convert multiboot2.mem_lower to bytes/16. */ +mov %rax,%rcx +shr $4,%rcx + +pop %rax + +/* Jump to trampoline_setup after switching CPU to x86_32 mode.
[PATCH v2 16/23] efi: split out efi_variables()
..which collects variable store parameters. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 41 - 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index fd62125..177697a 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -837,6 +837,29 @@ static void __init setup_efi_pci(void) efi_bs-FreePool(handles); } +static void __init efi_variables(void) +{ +EFI_STATUS status; + +status = (efi_rs-Hdr.Revision 16) = 2 ? + efi_rs-QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + efi_boot_max_var_store_size, + efi_boot_remain_var_store_size, + efi_boot_max_var_size) : + EFI_INCOMPATIBLE_VERSION; +if ( EFI_ERROR(status) ) +{ +efi_boot_max_var_store_size = 0; +efi_boot_remain_var_store_size = 0; +efi_boot_max_var_size = status; +PrintStr(LWarning: Could not query variable store: ); +DisplayUint(status, 0); +PrintStr(newline); +} +} + static int __init __maybe_unused set_color(u32 mask, int bpp, u8 *pos, u8 *sz) { if ( bpp 0 ) @@ -1078,23 +1101,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) setup_efi_pci(); /* Get snapshot of variable store parameters. */ -status = (efi_rs-Hdr.Revision 16) = 2 ? - efi_rs-QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - efi_boot_max_var_store_size, - efi_boot_remain_var_store_size, - efi_boot_max_var_size) : - EFI_INCOMPATIBLE_VERSION; -if ( EFI_ERROR(status) ) -{ -efi_boot_max_var_store_size = 0; -efi_boot_remain_var_store_size = 0; -efi_boot_max_var_size = status; -PrintStr(LWarning: Could not query variable store: ); -DisplayUint(status, 0); -PrintStr(newline); -} +efi_variables(); efi_arch_memory_setup(); -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 15/23] efi: split out efi_tables()
..which collects system tables data. We want to re-use this code to support multiboot2 protocol on EFI platforms. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- v2 - suggestions/fixes: - improve commit message (suggested by Jan Beulich). --- xen/common/efi/boot.c | 61 +++-- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 8d16470..fd62125 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -717,6 +717,39 @@ static UINTN __init efi_find_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, return gop_mode; } +static void __init efi_tables(void) +{ +unsigned int i; + +/* Obtain basic table pointers. */ +for ( i = 0; i efi_num_ct; ++i ) +{ +static EFI_GUID __initdata acpi2_guid = ACPI_20_TABLE_GUID; +static EFI_GUID __initdata acpi_guid = ACPI_TABLE_GUID; +static EFI_GUID __initdata mps_guid = MPS_TABLE_GUID; +static EFI_GUID __initdata smbios_guid = SMBIOS_TABLE_GUID; +static EFI_GUID __initdata smbios3_guid = SMBIOS3_TABLE_GUID; + +if ( match_guid(acpi2_guid, efi_ct[i].VendorGuid) ) + efi.acpi20 = (long)efi_ct[i].VendorTable; +if ( match_guid(acpi_guid, efi_ct[i].VendorGuid) ) + efi.acpi = (long)efi_ct[i].VendorTable; +if ( match_guid(mps_guid, efi_ct[i].VendorGuid) ) + efi.mps = (long)efi_ct[i].VendorTable; +if ( match_guid(smbios_guid, efi_ct[i].VendorGuid) ) + efi.smbios = (long)efi_ct[i].VendorTable; +if ( match_guid(smbios3_guid, efi_ct[i].VendorGuid) ) + efi.smbios3 = (long)efi_ct[i].VendorTable; +} + +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */ +dmi_efi_get_table(efi.smbios != EFI_INVALID_TABLE_ADDR + ? (void *)(long)efi.smbios : NULL, + efi.smbios3 != EFI_INVALID_TABLE_ADDR + ? (void *)(long)efi.smbios3 : NULL); +#endif +} + static void __init setup_efi_pci(void) { EFI_STATUS status; @@ -1039,33 +1072,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) /* XXX Collect EDID info. */ efi_arch_cpu(); -/* Obtain basic table pointers. */ -for ( i = 0; i efi_num_ct; ++i ) -{ -static EFI_GUID __initdata acpi2_guid = ACPI_20_TABLE_GUID; -static EFI_GUID __initdata acpi_guid = ACPI_TABLE_GUID; -static EFI_GUID __initdata mps_guid = MPS_TABLE_GUID; -static EFI_GUID __initdata smbios_guid = SMBIOS_TABLE_GUID; -static EFI_GUID __initdata smbios3_guid = SMBIOS3_TABLE_GUID; - -if ( match_guid(acpi2_guid, efi_ct[i].VendorGuid) ) - efi.acpi20 = (long)efi_ct[i].VendorTable; -if ( match_guid(acpi_guid, efi_ct[i].VendorGuid) ) - efi.acpi = (long)efi_ct[i].VendorTable; -if ( match_guid(mps_guid, efi_ct[i].VendorGuid) ) - efi.mps = (long)efi_ct[i].VendorTable; -if ( match_guid(smbios_guid, efi_ct[i].VendorGuid) ) - efi.smbios = (long)efi_ct[i].VendorTable; -if ( match_guid(smbios3_guid, efi_ct[i].VendorGuid) ) - efi.smbios3 = (long)efi_ct[i].VendorTable; -} - -#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */ -dmi_efi_get_table(efi.smbios != EFI_INVALID_TABLE_ADDR - ? (void *)(long)efi.smbios : NULL, - efi.smbios3 != EFI_INVALID_TABLE_ADDR - ? (void *)(long)efi.smbios3 : NULL); -#endif +efi_tables(); /* Collect PCI ROM contents. */ setup_efi_pci(); -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 23/23] x86: add multiboot2 protocol support for relocatable images
Add multiboot2 protocol support for relocatable images. Only GRUB2 with relevant patches understands that feature. Older multiboot protocol (regardless of version) compatible loaders ignore it and everything works as usual. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- xen/arch/x86/boot/head.S | 46 + xen/arch/x86/x86_64/asm-offsets.c |1 + xen/include/xen/multiboot2.h | 13 +++ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index d484f68..2520e48 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -81,6 +81,13 @@ multiboot1_header_end: /* Align modules at page boundry. */ mb2ht_init MB2_HT(MODULE_ALIGN), MB2_HT(REQUIRED) +/* Load address preference. */ +mb2ht_init MB2_HT(RELOCATABLE), MB2_HT(OPTIONAL), \ + sym_phys(start), /* Min load address. */ \ + 0x, /* Max load address (4 GiB - 1). */ \ + 0x20, /* Load address alignment (2 MiB). */ \ + MULTIBOOT2_LOAD_PREFERENCE_HIGH + /* Console flags tag. */ mb2ht_init MB2_HT(CONSOLE_FLAGS), MB2_HT(OPTIONAL), \ MULTIBOOT2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED @@ -176,30 +183,39 @@ efi_multiboot2_proto: lea MB2_fixed_sizeof(%rbx),%rcx 0: +/* Get Xen image base address from Multiboot2 information. */ +cmpl$MULTIBOOT2_TAG_TYPE_BASE_ADDR,MB2_tag_type(%rcx) +jne 1f + +mov MB2_base_addr(%rcx),%ebp +sub $XEN_IMG_OFFSET,%rbp +jmp 4f + +1: /* Get EFI SystemTable address from Multiboot2 information. */ cmpl$MULTIBOOT2_TAG_TYPE_EFI64,MB2_tag_type(%rcx) -jne 1f +jne 2f mov MB2_efi64_st(%rcx),%rsi /* Do not go into real mode on EFI platform. */ movb$1,skip_realmode(%rip) -jmp 3f +jmp 4f -1: +2: /* Get EFI ImageHandle address from Multiboot2 information. */ cmpl$MULTIBOOT2_TAG_TYPE_EFI64_IH,MB2_tag_type(%rcx) -jne 2f +jne 3f mov MB2_efi64_ih(%rcx),%rdi -jmp 3f +jmp 4f -2: +3: /* Is it the end of Multiboot2 information? */ cmpl$MULTIBOOT2_TAG_TYPE_END,MB2_tag_type(%rcx) je run_bs -3: +4: /* Go to next Multiboot2 information tag. */ add MB2_tag_size(%rcx),%ecx add $(MULTIBOOT2_TAG_ALIGN-1),%rcx @@ -297,14 +313,23 @@ multiboot2_proto: lea MB2_fixed_sizeof(%ebx),%ecx 0: +/* Get Xen image base address from Multiboot2 information. */ +cmpl$MULTIBOOT2_TAG_TYPE_BASE_ADDR,MB2_tag_type(%ecx) +jne 1f + +mov MB2_base_addr(%ecx),%ebp +sub $XEN_IMG_OFFSET,%ebp +jmp 3f + +1: /* Get mem_lower from Multiboot2 information. */ cmpl$MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,MB2_tag_type(%ecx) -jne 1f +jne 2f mov MB2_mem_lower(%ecx),%edx -jmp trampoline_bios_setup +jmp 3f -1: +2: /* EFI mode is not supported via legacy BIOS path. */ cmpl$MULTIBOOT2_TAG_TYPE_EFI32,MB2_tag_type(%ecx) je mb2_too_old @@ -316,6 +341,7 @@ multiboot2_proto: cmpl$MULTIBOOT2_TAG_TYPE_END,MB2_tag_type(%ecx) je trampoline_bios_setup +3: /* Go to next Multiboot2 information tag. */ add MB2_tag_size(%ecx),%ecx add $(MULTIBOOT2_TAG_ALIGN-1),%ecx diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index b7aed49..5345a9e 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -172,6 +172,7 @@ void __dummy__(void) DEFINE(MB2_fixed_sizeof, sizeof(multiboot2_fixed_t)); OFFSET(MB2_tag_type, multiboot2_tag_t, type); OFFSET(MB2_tag_size, multiboot2_tag_t, size); +OFFSET(MB2_base_addr, multiboot2_tag_base_addr_t, base_addr); OFFSET(MB2_mem_lower, multiboot2_tag_basic_meminfo_t, mem_lower); OFFSET(MB2_efi64_st, multiboot2_tag_efi64_t, pointer); OFFSET(MB2_efi64_ih, multiboot2_tag_efi64_ih_t, pointer); diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h index 09ee64e..a63c4d6 100644 --- a/xen/include/xen/multiboot2.h +++ b/xen/include/xen/multiboot2.h @@ -59,11 +59,17 @@ #define MULTIBOOT2_HEADER_TAG_EFI_BS 7 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 #define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 +#define MULTIBOOT2_HEADER_TAG_RELOCATABLE 10 /* Header tag flags. */ #define MULTIBOOT2_HEADER_TAG_REQUIRED 0 #define MULTIBOOT2_HEADER_TAG_OPTIONAL 1 +/* Where image should be loaded (suggestion not requirement). */ +#define
[PATCH v2 5/6] multiboot2: Add support for relocatable images
Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- grub-core/loader/i386/multiboot_mbi.c |6 ++-- grub-core/loader/multiboot.c | 12 +-- grub-core/loader/multiboot_elfxx.c| 28 +++ grub-core/loader/multiboot_mbi2.c | 63 + include/grub/multiboot.h |4 ++- include/multiboot2.h | 24 + 6 files changed, 118 insertions(+), 19 deletions(-) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 956d0e3..abdb98b 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -72,7 +72,8 @@ load_kernel (grub_file_t file, const char *filename, grub_err_t err; if (grub_multiboot_quirks GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE) { - err = grub_multiboot_load_elf (file, filename, buffer); + err = grub_multiboot_load_elf (file, filename, buffer, 0, 0, 0, 0, +GRUB_RELOCATOR_PREFERENCE_NONE, NULL, 0); if (err == GRUB_ERR_UNKNOWN_OS (header-flags MULTIBOOT_AOUT_KLUDGE)) grub_errno = err = GRUB_ERR_NONE; } @@ -118,7 +119,8 @@ load_kernel (grub_file_t file, const char *filename, return GRUB_ERR_NONE; } - return grub_multiboot_load_elf (file, filename, buffer); + return grub_multiboot_load_elf (file, filename, buffer, 0, 0, 0, 0, + GRUB_RELOCATOR_PREFERENCE_NONE, NULL, 0); } static struct multiboot_header * diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index ca7154f..1b1f7a9 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -190,12 +190,18 @@ static grub_uint64_t highest_load; /* Load ELF32 or ELF64. */ grub_err_t grub_multiboot_load_elf (grub_file_t file, const char *filename, -void *buffer) +void *buffer, int relocatable, grub_uint32_t min_addr, +grub_uint32_t max_addr, grub_size_t align, grub_uint32_t preference, +grub_uint32_t *base_addr, int avoid_efi_boot_services) { if (grub_multiboot_is_elf32 (buffer)) -return grub_multiboot_load_elf32 (file, filename, buffer); +return grub_multiboot_load_elf32 (file, filename, buffer, relocatable, + min_addr, max_addr, align, preference, + base_addr, avoid_efi_boot_services); else if (grub_multiboot_is_elf64 (buffer)) -return grub_multiboot_load_elf64 (file, filename, buffer); +return grub_multiboot_load_elf64 (file, filename, buffer, relocatable, + min_addr, max_addr, align, preference, + base_addr, avoid_efi_boot_services); return grub_error (GRUB_ERR_UNKNOWN_OS, N_(invalid arch-dependent ELF magic)); } diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 6a220bd..4fce685 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -51,7 +51,10 @@ CONCAT(grub_multiboot_is_elf, XX) (void *buffer) } static grub_err_t -CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, void *buffer) +CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, +void *buffer, int relocatable, grub_uint32_t min_addr, +grub_uint32_t max_addr, grub_size_t align, grub_uint32_t preference, +grub_uint32_t *base_addr, int avoid_efi_boot_services) { Elf_Ehdr *ehdr = (Elf_Ehdr *) buffer; char *phdr_base; @@ -89,19 +92,30 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi if (phdr(i)-p_paddr + phdr(i)-p_memsz highest_load) highest_load = phdr(i)-p_paddr + phdr(i)-p_memsz; - grub_dprintf (multiboot_loader, segment %d: paddr=0x%lx, memsz=0x%lx, vaddr=0x%lx\n, - i, (long) phdr(i)-p_paddr, (long) phdr(i)-p_memsz, (long) phdr(i)-p_vaddr); + grub_dprintf (multiboot_loader, segment %d: paddr=0x%lx, memsz=0x%lx, vaddr=0x%lx, + align=0x%lx, relocatable=%d, avoid_efi_boot_services=%d\n, i, + (long) phdr(i)-p_paddr, (long) phdr(i)-p_memsz, (long) phdr(i)-p_vaddr, + (long) align, relocatable, avoid_efi_boot_services); { grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, - ch, phdr(i)-p_paddr, - phdr(i)-p_memsz); + + if (relocatable) + err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, ch, + min_addr, max_addr -
[PATCH v2 1/6] gitignore: Ignore *.orig, *.rej and *.swp files
Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- .gitignore |3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 18ab8e8..6d25d39 100644 --- a/.gitignore +++ b/.gitignore @@ -147,6 +147,7 @@ mod-*.c missing netboot_test *.o +*.orig *.a ohci_test partmap_test @@ -160,9 +161,11 @@ po/stamp-po printf_test priority_queue_unit_test pseries_test +*.rej stamp-h stamp-h1 stamp-h.in +*.swp symlist.c symlist.h trigtables.c -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 6/6] multiboot2: Do not pass memory maps to image if EFI boot services are enabled
Do not pass memory maps to image if it asked for EFI boot services. Maps are usually invalid in that case and they can confuse potential user. Image should get memory map itself just before ExitBootServices() call. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- grub-core/loader/multiboot_mbi2.c | 71 ++--- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 7ac64ec..26e955c 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -431,7 +431,7 @@ static grub_size_t grub_multiboot_get_mbi_size (void) { #ifdef GRUB_MACHINE_EFI - if (!efi_mmap_size) + if (!keep_bs !efi_mmap_size) find_efi_mmap_size (); #endif return 2 * sizeof (grub_uint32_t) + sizeof (struct multiboot_tag) @@ -805,12 +805,13 @@ grub_multiboot_make_mbi (grub_uint32_t *target) } } - { -struct multiboot_tag_mmap *tag = (struct multiboot_tag_mmap *) ptrorig; -grub_fill_multiboot_mmap (tag); -ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); - } + if (!keep_bs) +{ + struct multiboot_tag_mmap *tag = (struct multiboot_tag_mmap *) ptrorig; + grub_fill_multiboot_mmap (tag); + ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); +} { struct multiboot_tag_elf_sections *tag @@ -826,18 +827,19 @@ grub_multiboot_make_mbi (grub_uint32_t *target) / sizeof (grub_properly_aligned_t); } - { -struct multiboot_tag_basic_meminfo *tag - = (struct multiboot_tag_basic_meminfo *) ptrorig; -tag-type = MULTIBOOT_TAG_TYPE_BASIC_MEMINFO; -tag-size = sizeof (struct multiboot_tag_basic_meminfo); + if (!keep_bs) +{ + struct multiboot_tag_basic_meminfo *tag + = (struct multiboot_tag_basic_meminfo *) ptrorig; + tag-type = MULTIBOOT_TAG_TYPE_BASIC_MEMINFO; + tag-size = sizeof (struct multiboot_tag_basic_meminfo); -/* Convert from bytes to kilobytes. */ -tag-mem_lower = grub_mmap_get_lower () / 1024; -tag-mem_upper = grub_mmap_get_upper () / 1024; -ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); - } + /* Convert from bytes to kilobytes. */ + tag-mem_lower = grub_mmap_get_lower () / 1024; + tag-mem_upper = grub_mmap_get_upper () / 1024; + ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); +} { struct grub_net_network_level_interface *net; @@ -936,27 +938,24 @@ grub_multiboot_make_mbi (grub_uint32_t *target) grub_efi_uintn_t efi_desc_size; grub_efi_uint32_t efi_desc_version; -tag-type = MULTIBOOT_TAG_TYPE_EFI_MMAP; -tag-size = sizeof (*tag) + efi_mmap_size; - if (!keep_bs) - err = grub_efi_finish_boot_services (efi_mmap_size, tag-efi_mmap, NULL, - efi_desc_size, efi_desc_version); -else { - if (grub_efi_get_memory_map (efi_mmap_size, (void *) tag-efi_mmap, -NULL, -efi_desc_size, efi_desc_version) = 0) - err = grub_error (GRUB_ERR_IO, couldn't retrieve memory map); + tag-type = MULTIBOOT_TAG_TYPE_EFI_MMAP; + tag-size = sizeof (*tag) + efi_mmap_size; + + err = grub_efi_finish_boot_services (efi_mmap_size, tag-efi_mmap, NULL, +efi_desc_size, efi_desc_version); + + if (err) + return err; + + tag-descr_size = efi_desc_size; + tag-descr_vers = efi_desc_version; + tag-size = sizeof (*tag) + efi_mmap_size; + + ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); } -if (err) - return err; -tag-descr_size = efi_desc_size; -tag-descr_vers = efi_desc_version; -tag-size = sizeof (*tag) + efi_mmap_size; - -ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); } if (keep_bs) -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 3/6] i386/relocator: Add grub_relocator64_efi relocator
Add grub_relocator64_efi relocator. It will be used on EFI 64-bit platforms when multiboot2 compatible image requests MULTIBOOT_TAG_TYPE_EFI_BS. Relocator will set lower parts of %rax and %rbx accordingly to multiboot2 specification. On the other hand processor mode, just before jumping into loaded image, will be set accordingly to Unified Extensible Firmware Interface Specification, Version 2.4 Errata B, section 2.3.4, x64 Platforms, boot services. This way loaded image will be able to use EFI boot services without any issues. If idea is accepted I will prepare grub_relocator32_efi relocator too. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- grub-core/Makefile.core.def |1 + grub-core/lib/i386/relocator.c | 53 +++ grub-core/lib/i386/relocator64_efi.S | 77 ++ grub-core/loader/multiboot.c | 29 +++-- grub-core/loader/multiboot_mbi2.c| 19 +++-- include/grub/i386/multiboot.h| 11 + include/grub/i386/relocator.h| 21 ++ include/multiboot2.h |9 8 files changed, 213 insertions(+), 7 deletions(-) create mode 100644 grub-core/lib/i386/relocator64_efi.S diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a6101de..d583549 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1519,6 +1519,7 @@ module = { x86 = lib/i386/relocator_common_c.c; ieee1275 = lib/ieee1275/relocator.c; efi = lib/efi/relocator.c; + x86_64_efi = lib/i386/relocator64_efi.S; mips = lib/mips/relocator_asm.S; mips = lib/mips/relocator.c; powerpc = lib/powerpc/relocator_asm.S; diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c index 71dd4f0..459027e 100644 --- a/grub-core/lib/i386/relocator.c +++ b/grub-core/lib/i386/relocator.c @@ -69,6 +69,19 @@ extern grub_uint64_t grub_relocator64_rsi; extern grub_addr_t grub_relocator64_cr3; extern struct grub_i386_idt grub_relocator16_idt; +#ifdef GRUB_MACHINE_EFI +#ifdef __x86_64__ +extern grub_uint8_t grub_relocator64_efi_start; +extern grub_uint8_t grub_relocator64_efi_end; +extern grub_uint64_t grub_relocator64_efi_rax; +extern grub_uint64_t grub_relocator64_efi_rbx; +extern grub_uint64_t grub_relocator64_efi_rcx; +extern grub_uint64_t grub_relocator64_efi_rdx; +extern grub_uint64_t grub_relocator64_efi_rip; +extern grub_uint64_t grub_relocator64_efi_rsi; +#endif +#endif + #define RELOCATOR_SIZEOF(x)(grub_relocator##x##_end - grub_relocator##x##_start) grub_err_t @@ -214,3 +227,43 @@ grub_relocator64_boot (struct grub_relocator *rel, /* Not reached. */ return GRUB_ERR_NONE; } + +#ifdef GRUB_MACHINE_EFI +#ifdef __x86_64__ +grub_err_t +grub_relocator64_efi_boot (struct grub_relocator *rel, + struct grub_relocator64_efi_state state) +{ + grub_err_t err; + void *relst; + grub_relocator_chunk_t ch; + + err = grub_relocator_alloc_chunk_align (rel, ch, 0, + 0x4000 - RELOCATOR_SIZEOF (64_efi), + RELOCATOR_SIZEOF (64_efi), 16, + GRUB_RELOCATOR_PREFERENCE_NONE, 1); + if (err) +return err; + + grub_relocator64_efi_rax = state.rax; + grub_relocator64_efi_rbx = state.rbx; + grub_relocator64_efi_rcx = state.rcx; + grub_relocator64_efi_rdx = state.rdx; + grub_relocator64_efi_rip = state.rip; + grub_relocator64_efi_rsi = state.rsi; + + grub_memmove (get_virtual_current_address (ch), grub_relocator64_efi_start, + RELOCATOR_SIZEOF (64_efi)); + + err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch), + relst, NULL); + if (err) +return err; + + ((void (*) (void)) relst) (); + + /* Not reached. */ + return GRUB_ERR_NONE; +} +#endif +#endif diff --git a/grub-core/lib/i386/relocator64_efi.S b/grub-core/lib/i386/relocator64_efi.S new file mode 100644 index 000..fcd1964 --- /dev/null +++ b/grub-core/lib/i386/relocator64_efi.S @@ -0,0 +1,77 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009,2010 Free Software Foundation, Inc. + * Copyright (C) 2014,2015 Oracle Co. + * Author: Daniel Kiper + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see http://www.gnu.org/licenses/. + */ + +#include relocator_common.S + +
[PATCH v2 4/6] multiboot2: Add tags used to pass ImageHandle to loaded image
Add tags used to pass ImageHandle to loaded image. It is used by at least ExitBootServices() function. Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- grub-core/loader/multiboot_mbi2.c | 46 + include/multiboot2.h | 16 + 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 8d66e3f..dc9c709 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -172,6 +172,8 @@ grub_multiboot_load (grub_file_t file, const char *filename) case MULTIBOOT_TAG_TYPE_NETWORK: case MULTIBOOT_TAG_TYPE_EFI_MMAP: case MULTIBOOT_TAG_TYPE_EFI_BS: + case MULTIBOOT_TAG_TYPE_EFI32_IH: + case MULTIBOOT_TAG_TYPE_EFI64_IH: break; default: @@ -407,16 +409,18 @@ grub_multiboot_get_mbi_size (void) + grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry)), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN) +#ifdef GRUB_MACHINE_EFI + ALIGN_UP (sizeof (struct multiboot_tag_efi32), MULTIBOOT_TAG_ALIGN) + ALIGN_UP (sizeof (struct multiboot_tag_efi64), MULTIBOOT_TAG_ALIGN) ++ ALIGN_UP (sizeof (struct multiboot_tag_efi32_ih), MULTIBOOT_TAG_ALIGN) ++ ALIGN_UP (sizeof (struct multiboot_tag_efi64_ih), MULTIBOOT_TAG_ALIGN) ++ ALIGN_UP (sizeof (struct multiboot_tag_efi_mmap) + + efi_mmap_size, MULTIBOOT_TAG_ALIGN) +#endif + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) + sizeof (struct grub_acpi_rsdp_v10), MULTIBOOT_TAG_ALIGN) + acpiv2_size () + net_size () -#ifdef GRUB_MACHINE_EFI -+ ALIGN_UP (sizeof (struct multiboot_tag_efi_mmap) - + efi_mmap_size, MULTIBOOT_TAG_ALIGN) -#endif + sizeof (struct multiboot_tag_vbe) + MULTIBOOT_TAG_ALIGN - 1 + sizeof (struct multiboot_tag_apm) + MULTIBOOT_TAG_ALIGN - 1; } @@ -906,11 +910,35 @@ grub_multiboot_make_mbi (grub_uint32_t *target) if (keep_bs) { - struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig; - tag-type = MULTIBOOT_TAG_TYPE_EFI_BS; - tag-size = sizeof (struct multiboot_tag); - ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) - / sizeof (grub_properly_aligned_t); + { + struct multiboot_tag *tag = (struct multiboot_tag *) ptrorig; + tag-type = MULTIBOOT_TAG_TYPE_EFI_BS; + tag-size = sizeof (struct multiboot_tag); + ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } + +#ifdef __x86_64__ + { + struct multiboot_tag_efi64_ih *tag = (struct multiboot_tag_efi64_ih *) ptrorig; + tag-type = MULTIBOOT_TAG_TYPE_EFI64_IH; + tag-size = sizeof (*tag); + tag-pointer = (grub_addr_t) grub_efi_image_handle; + ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } +#endif + +#ifdef __i386__ + { + struct multiboot_tag_efi32_ih *tag = (struct multiboot_tag_efi32_ih *) ptrorig; + tag-type = MULTIBOOT_TAG_TYPE_EFI32_IH; + tag-size = sizeof (*tag); + tag-pointer = (grub_addr_t) grub_efi_image_handle; + ptrorig += ALIGN_UP (tag-size, MULTIBOOT_TAG_ALIGN) + / sizeof (grub_properly_aligned_t); + } +#endif } #endif diff --git a/include/multiboot2.h b/include/multiboot2.h index b3977e3..9f97ddc 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -60,6 +60,8 @@ #define MULTIBOOT_TAG_TYPE_NETWORK 16 #define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 #define MULTIBOOT_TAG_TYPE_EFI_BS18 +#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 +#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 #define MULTIBOOT_HEADER_TAG_END 0 #define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 @@ -379,6 +381,20 @@ struct multiboot_tag_efi_mmap multiboot_uint8_t efi_mmap[0]; }; +struct multiboot_tag_efi32_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint32_t pointer; +}; + +struct multiboot_tag_efi64_ih +{ + multiboot_uint32_t type; + multiboot_uint32_t size; + multiboot_uint64_t pointer; +}; + #endif /* ! ASM_FILE */ #endif /* ! MULTIBOOT_HEADER */ -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size
malloc_in_range() should not use memory region if its starta is smaller than size. Otherwise target wraps around and points to region which is usually not a RAM, e.g.: loader/multiboot.c:93: segment 0: paddr=0x80, memsz=0x3f80, vaddr=0x80 lib/relocator.c:1241: min_addr = 0x0, max_addr = 0x, target = 0x80 lib/relocator.c:434: trying to allocate in 0x80-0x aligned 0x1 size 0x3f80 lib/relocator.c:434: trying to allocate in 0x0-0x80 aligned 0x1 size 0x3f80 lib/relocator.c:434: trying to allocate in 0x0-0x aligned 0x1 size 0x3f80 lib/relocator.c:1188: allocated: 0xc07f+0x3f80 lib/relocator.c:1277: allocated 0xc07f/0x80 Signed-off-by: Daniel Kiper daniel.ki...@oracle.com --- grub-core/lib/relocator.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index f759c7f..4eee0c5 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -748,7 +748,7 @@ malloc_in_range (struct grub_relocator *rel, /* Found an usable address. */ goto found; } - if (isinsidebefore !isinsideafter !from_low_priv) + if (isinsidebefore !isinsideafter !from_low_priv starta = size) { target = starta - size; if (target end - size) -- 1.7.10.4 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: Wimboot fails to get initrd data (probably regression)
On Mon, Jul 20, 2015 at 3:38 PM, Bernhard Übelacker bernha...@vr-web.de wrote: @@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[], if (newc) { + initrd_ctx-size = ALIGN_UP (initrd_ctx-size, 4); initrd_ctx-size += ALIGN_UP (sizeof (struct newc_head) + sizeof (TRAILER!!!) - 1, 4); free_dir (root); But code already does exactly the same. initrd_ctx-size = ALIGN_UP (initrd_ctx-size, 4); ... else if (newc) { initrd_ctx-size += ALIGN_UP (sizeof (struct newc_head) + sizeof (TRAILER!!!) - 1, 4); @@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, ptr += cursize; } if (newc) -ptr = make_header (ptr, TRAILER!!!, sizeof (TRAILER!!!) - 1, 0, 0); +{ + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); + ptr = make_header (ptr, TRAILER!!!, sizeof (TRAILER!!!) - 1, 0, 0); +} free_dir (root); root = 0; return GRUB_ERR_NONE; Ditto. Could you make your failing initrd available? ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: Wimboot fails to get initrd data (probably regression)
On Mon, Jul 20, 2015 at 4:47 PM, Andrei Borzenkov arvidj...@gmail.com wrote: But code already does exactly the same. Ignore this. I see. Thank you! ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
GRUB release schedule?
Hi everyone, Is there a plan for when upcoming GNU GRUB releases will happen? As far as I can tell, the last official release on ftp://ftp.gnu.org/gnu/grub/ was 2.00 on 28-Jun-2012, and the last beta on http://alpha.gnu.org/pub/gnu/grub/ for the next version was 2.02~beta2 on 24-Dec-2013 . There are (give or take) 471 patches committed since that beta 18 months ago. In the mean time, nearly every Linux distro is shipping a package derived from the 2.02~beta2 release plus some number of patches, some from the upstream repo and some not, and it's cumbersome to rectify which ones aren't upstream vs which ones have been fixed upstream with /nearly/ the same patch, etc., with all the noise of so many patches since the release. I suspect this would be better for a lot of GRUB users if releases happened on a regular schedule, or if, relatively often (say once or twice per year), a release schedule that spans several weeks and organized some kind of alpha-beta-release progression were decided upon and followed. So, can we make a release process that happens according to some regular cadence? What needs to be done to make regular releases happen? Going for years with the patch volume GRUB sees without doing a release is really not good for anybody. -- Peter ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: Wimboot fails to get initrd data (probably regression)
В Mon, 20 Jul 2015 14:38:39 +0200 Bernhard Übelacker bernha...@vr-web.de пишет: This makes the boot succeed again (Also attached as patch to current grub git): Applied. ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
Re: GRUB release schedule?
I'll do next beta tomorrow and will assess current open bugs to see how far we're from release Le 20 juil. 2015 20:23, Peter Jones pjo...@redhat.com a écrit : Hi everyone, Is there a plan for when upcoming GNU GRUB releases will happen? As far as I can tell, the last official release on ftp://ftp.gnu.org/gnu/grub/ was 2.00 on 28-Jun-2012, and the last beta on http://alpha.gnu.org/pub/gnu/grub/ for the next version was 2.02~beta2 on 24-Dec-2013 . There are (give or take) 471 patches committed since that beta 18 months ago. In the mean time, nearly every Linux distro is shipping a package derived from the 2.02~beta2 release plus some number of patches, some from the upstream repo and some not, and it's cumbersome to rectify which ones aren't upstream vs which ones have been fixed upstream with /nearly/ the same patch, etc., with all the noise of so many patches since the release. I suspect this would be better for a lot of GRUB users if releases happened on a regular schedule, or if, relatively often (say once or twice per year), a release schedule that spans several weeks and organized some kind of alpha-beta-release progression were decided upon and followed. So, can we make a release process that happens according to some regular cadence? What needs to be done to make regular releases happen? Going for years with the patch volume GRUB sees without doing a release is really not good for anybody. -- Peter ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel