xen: Break multiboot (v1) dependency and add multiboot2 support
v2 cover xen: Break multiboot (v1) dependency and add multiboot2 support
Hi,
This patch series breaks multiboot (v1) protocol dependency and adds multiboot2 support. It lays down the foundation for EFI + GRUB2 + Xen development. Detailed description of ideas and thoughts you will find in commit message for every patch. If something is not obvious please drop me a line.
Most of the requested things are fixed but there are still some minor outstanding issues (multiboot2 tags generation, excessive amount of casts in xen/arch/x86/boot/reloc.c, etc.; please check commit messages for more details). If something is not fixed yet it means that I do not have good idea how to do that. In case you spot something which was mentioned during previous review and still think that your comment is valid in particular case please notify me.
Below you can find reply for Konrad's questions in regards to exception request for Xen 4.5 release.
Quoted 5 lines
Couple of questions:
- Since this is mostly XBI code, is there a lot of overlap with the ARM/x86 refactoring of the EFI code? As in, will it require a lot of rebasing/fixing it up?
I did not checked that right now. However, Roy once told me that this should not be very big issue because overlap is not so big. Please check this email for more details: http://lists.xen.org/archives/html/xen-devel/2014-08/msg01173.html
Sadly, it was sent more then one month ago so maybe something has changed. Roy, any comments on that?
Anyway, I am more than happy to work on this issue with Roy.
Quoted 1 line
- What is the disadvantage of having this in Xen 4.6?
Well, it will require to rebase all this work on latest developments. It could be quite difficult because my patches touches a lot of places and as I can see there is a chance for substantial changes in some of them.
Quoted 5 lines
- What is the advantage of having this in Xen 4.5?
[My understanding is that it would allow us to thrash out a lot of
the early bootup issues _now_ and fix them up instead of having to deal in Xen 4.6 with this, EFI, and SecureBoot - which is a lot of more moving pieces]
More or less. Additionally, we will have support for multiboot2 protocol in place. There is not very big demand for that but as I know at least Intel guys were looking for that. IIRC, they needed that for TPM support.
Daniel
xen/arch/x86/Makefile | 1 + xen/arch/x86/boot/cmdline.S | 9 +- xen/arch/x86/boot/head.S | 150 ++++++++++++++++++++++++++++----- xen/arch/x86/boot/reloc.c | 248 ++++++++++++++++++++++++++++++++++++++++++++----------- xen/arch/x86/boot/x86_64.S | 10 ++- xen/arch/x86/boot_info.c | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/dmi_scan.c | 7 +- xen/arch/x86/domain_build.c | 24 +++--- xen/arch/x86/e820.c | 8 +- xen/arch/x86/efi/boot.c | 214 +++++++++++++++++++++++------------------------ xen/arch/x86/efi/efi.h | 3 - xen/arch/x86/efi/runtime.c | 52 +++++++++--- xen/arch/x86/microcode.c | 39 ++++----- xen/arch/x86/mpparse.c | 9 +- xen/arch/x86/platform_hypercall.c | 19 ++--- xen/arch/x86/setup.c | 370 +++++++++++++++++++++++++++------------------------------------------------------- xen/arch/x86/x86_64/asm-offsets.c | 5 +- xen/drivers/acpi/osl.c | 9 +- xen/drivers/video/vesa.c | 7 +- xen/drivers/video/vga.c | 18 ++-- xen/include/asm-x86/boot_info.h | 126 ++++++++++++++++++++++++++++ xen/include/asm-x86/config.h | 2 - xen/include/asm-x86/e820.h | 10 +-- xen/include/asm-x86/edd.h | 6 -- xen/include/asm-x86/mbd.h | 70 ++++++++++++++++ xen/include/asm-x86/setup.h | 10 +-- xen/include/xen/efi.h | 10 --- xen/include/xen/multiboot2.h | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/vga.h | 18 ---- xen/include/xsm/xsm.h | 14 ++-- xen/xsm/xsm_core.c | 6 +- xen/xsm/xsm_policy.c | 14 ++-- 32 files changed, 1510 insertions(+), 590 deletions(-)
Daniel Kiper (5):
xen/x86: Introduce MultiBoot Data (MBD) type xen/x86: Define e820 entries counter as unsigned int xen/x86: Migrate to boot_info structure xen/x86: Use constant as multiboot protocol identifier xen/x86: Add multiboot2 protocol support
PATCH v2 1/5 xen/x86: Introduce MultiBoot Data (MBD) type
Introduce MultiBoot Data (MBD) type. It is used to define variable which carry over data from multiboot protocol (any version) through Xen preloader stage. Later all or parts of this data is used to initialize boot_info structure. boot_info is introduced in later patches.
MBD helps to break multiboot (v1) protocol dependency. Using it we are able to save space on trampoline (we do not allocate space for unused data what happens in current preloader implementation). Additionally, we are able to easily add new members to MBD if we want support for new features or protocols.
There is not plan to share MBD among architectures. It will be nice if boot_info will be shared among architectures. Please check later patches for more details.
Code found in xen/arch/x86/boot_info.c moves MBD data to mbi struct which is referenced from main Xen code. This is temporary solution which helps to split patches into logical parts. Later it will be replaced by final version of boot_info support.
---
v2 - suggestions/fixes:
- improve inline assembly
(suggested by Andrew Cooper and Jan Beulich),
- use __used attribute
(suggested by Andrew Cooper),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).
--- xen/arch/x86/Makefile | 1 + xen/arch/x86/boot/cmdline.S | 9 +-- xen/arch/x86/boot/head.S | 31 ++++---- xen/arch/x86/boot/reloc.c | 147 +++++++++++++++++++++++++------------ xen/arch/x86/boot/x86_64.S | 10 ++- xen/arch/x86/boot_info.c | 58 +++++++++++++++ xen/arch/x86/setup.c | 41 +++++++---- xen/arch/x86/x86_64/asm-offsets.c | 5 +- xen/include/asm-x86/mbd.h | 70 ++++++++++++++++++ 9 files changed, 284 insertions(+), 88 deletions(-) create mode 100644 xen/arch/x86/boot_info.c create mode 100644 xen/include/asm-x86/mbd.h
xen/arch/x86/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-y += numa.o obj-y += pci.o obj-y += percpu.o obj-y += physdev.o +obj-y += boot_info.o obj-y += setup.o obj-y += shutdown.o obj-y += smp.o
xen/arch/x86/boot/cmdline.S +3 -6
@@ -152,17 +152,14 @@ cmdline_parse_early: pusha /* Bail if there is no command line to parse. */ - mov sym_phys(multiboot_ptr),%ebx - mov MB_flags(%ebx),%eax - test $4,%al - jz .Lcmdline_exit - mov MB_cmdline(%ebx),%eax + mov sym_phys(mbd_ptr),%ebx + mov MBD_cmdline(%ebx),%eax test %eax,%eax jz .Lcmdline_exit /* Check for 'no-real-mode' command-line option. */ pushl $sym_phys(.Lno_rm_opt) - pushl MB_cmdline(%ebx) + pushl MBD_cmdline(%ebx) call .Lfind_option test %eax,%eax setnz %al
xen/arch/x86/boot/head.S +16 -15
@@ -86,14 +86,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
@@ -105,22 +105,23 @@ __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. */ + /* Save the Multiboot data (after relocation) for later use. */ mov $sym_phys(cpu0_stack)+1024,%esp - push %ebx - call reloc - mov %eax,sym_phys(multiboot_ptr) + push %eax /* Multiboot magic */ + push %ebx /* Multiboot information address */ + call reloc /* %ecx contains trampoline address */ + mov %eax,sym_phys(mbd_ptr) /* Initialize BSS (no nasty surprises!) */ mov $sym_phys(__bss_start),%edi
xen/arch/x86/boot/reloc.c +101 -46
199 lines not on this page · raw message
xen/arch/x86/boot/x86_64.S +7 -3
@@ -29,8 +29,12 @@ test %ebx,%ebx jnz start_secondary - /* Pass off the Multiboot info structure to C land. */ - mov multiboot_ptr(%rip),%edi + /* Init boot_info. */ + mov mbd_ptr(%rip),%edi + call __init_boot_info + + /* Pass off the boot_info to C land. */ + movq %rax,%rdi call __start_xen ud2 /* Force a panic (invalid opcode). */
@@ -38,7 +42,7 @@ .data .align 8 -multiboot_ptr: +mbd_ptr: .long 0 .word 0
xen/arch/x86/boot_info.c new file +58 -0
58 lines not on this page · raw message
xen/arch/x86/setup.c +26 -15
53 lines not on this page · raw message
xen/arch/x86/x86_64/asm-offsets.c +2 -3
@@ -12,7 +12,7 @@#include <compat/xen.h> #include <asm/fixmap.h> #include <asm/hardirq.h> -#include <xen/multiboot.h> +#include <asm/mbd.h> #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
@@ -163,6 +163,5 @@ void __dummy__(void) OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);BLANK (); -OFFSET (MB_flags, multiboot_info_t, flags); -OFFSET (MB_cmdline, multiboot_info_t, cmdline); +OFFSET (MBD_cmdline, mbd_t, cmdline); }
xen/include/asm-x86/mbd.h new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 2/5 xen/x86: Define e820 entries counter as unsigned int
In reply to Daniel Kipere820 entries counter is inherently an unsigned quantity so define it as unsigned int.
---
v2 - suggestions/fixes:
- change e820 entries counter signedness
(suggested by Andrew Cooper).
--- xen/arch/x86/e820.c | 8 ++++---- xen/include/asm-x86/e820.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/x86/e820.c +4 -4
@@ -89,9 +89,9 @@ static void __init add_memory_region(unsigned long long start, } }/* add_memory_region */ -static void __init print_e820_memory_map (struct e820entry *map,int entries) +static void __init print_e820_memory_map (struct e820entry *map,unsigned int entries) { -int i; +unsigned int i;for (i =0 ; i < entries; i++) { printk(" %016Lx - %016Lx ",
@@ -512,7 +512,7 @@ static void __init reserve_dmi_region(void) }static void __init machine_specific_memory_setup ( -struct e820entry *raw,int *raw_nr) +struct e820entry *raw,unsigned int *raw_nr) {unsigned long mpt_limit, ro_mpt_limit;uint64_t top_of_ram, size;
@@ -695,7 +695,7 @@ int __init reserve_e820_ram(struct e820map *e820, uint64_t s, uint64_t e) }unsigned long __init init_e820 ( -const char *str,struct e820entry *raw,int *raw_nr) +const char *str,struct e820entry *raw,unsigned int *raw_nr) {if ( e820_verbose ) {
xen/include/asm-x86/e820.h +2 -2
@@ -30,12 +30,12 @@ extern int e820_change_range_type( uint32_t orig_type, uint32_t new_type);extern int e820_add_range (struct e820map *,uint64_t s,uint64_t e,uint32_t type); -extern unsigned long init_e820 (const char *,struct e820entry *,int *); +extern unsigned long init_e820 (const char *,struct e820entry *,unsigned int *);extern struct e820map e820;/* These symbols live in the boot trampoline. */ extern struct e820entry e820map[]; -extern int e820nr; +extern unsigned int e820nr;extern unsigned int lowmem_kb, highmem_kb;#define e820_raw bootsym(e820map)
Signature · 1 line
1.7.10.4
PATCH v2 3/5 xen/x86: Migrate to boot_info structure
In reply to Daniel KiperBreak multiboot (v1) protocol dependency. It means that most of Xen code (excluding preloader) could be bootloader agnostic and does not need almost any knowledge about boot protocol. Additionally, we are able to pass all boot data to __start_xen() in one bucket without any side channels. I do not mention that we are also able to easily identify boot data in Xen code.
Here is boot data flow for legacy BIOS platform:
BIOS -> GRUB -> multiboot[12]* -> __reloc() -> MBD ->-\
/
------<------<------<------<------<------<-----
\
\
---> __init_boot_info() -> boot_info_mb -> __start_xen() -> boot_info
/BIOS ->-/
* multiboot2 is not implemented yet. Look for it in later patches.
Here is boot data flow for EFI platform:
EFI -> efi_start() -> boot_info_efi -> __start_xen() -> boot_info
WARNING: ARM build could be broken by this patch. We need to agree boot_info integration into ARM. Personally I think that it is worth storing all data from any bootloader and preloader in boot_info on any architecture. This give a chance to share more code between architectures. However, every architecture should define its own boot_info (in relevant include/asm directory). Despite that it looks that some parts of it could be common, e.g. modules data, command line arguments, boot loader name, EFI data, etc., even if types would not be the same. So, as it was stated above a lot of code could be shared among architectures.
---
v2 - suggestions/fixes:
- rename XBI to boot_info
(suggested by Andrew Cooper),
- use more meaningful types in boot_info structure (suggested by Andrew Cooper, Jan Beulich and Stefano Stabellini),
- improve boot_info structure comment
(suggested by Andrew Cooper and Jan Beulich),
- do data shuffling after exception support initialization (suggested by Andrew Cooper),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).
--- xen/arch/x86/boot_info.c | 240 +++++++++++++++++++++++--- xen/arch/x86/dmi_scan.c | 7 +- xen/arch/x86/domain_build.c | 24 +-- xen/arch/x86/efi/boot.c | 214 +++++++++++------------ xen/arch/x86/efi/efi.h | 3 - xen/arch/x86/efi/runtime.c | 52 ++++-- xen/arch/x86/microcode.c | 39 ++--- xen/arch/x86/mpparse.c | 9 +- xen/arch/x86/platform_hypercall.c | 19 +-- xen/arch/x86/setup.c | 341 +++++++++++-------------------------- xen/drivers/acpi/osl.c | 9 +- xen/drivers/video/vesa.c | 7 +- xen/drivers/video/vga.c | 18 +- xen/include/asm-x86/boot_info.h | 126 ++++++++++++++ xen/include/asm-x86/config.h | 2 - xen/include/asm-x86/e820.h | 8 - xen/include/asm-x86/edd.h | 6 - xen/include/asm-x86/setup.h | 10 +- xen/include/xen/efi.h | 10 -- xen/include/xen/vga.h | 18 -- xen/include/xsm/xsm.h | 14 +- xen/xsm/xsm_core.c | 6 +- xen/xsm/xsm_policy.c | 14 +- 23 files changed, 680 insertions(+), 516 deletions(-) create mode 100644 xen/include/asm-x86/boot_info.h delete mode 100644 xen/include/xen/vga.h
xen/arch/x86/boot_info.c +220 -20
@@ -15,44 +15,244 @@* with this program. If not, see <http://www.gnu.org/licenses/>. */ +/* +* Some ideas are taken (out) from xen/arch/x86/boot/reloc.c, +* xen/arch/x86/efi/boot.c and xen/arch/x86/setup.c. +*/ +#include <xen/types.h> +#include <xen/cache.h> +#include <xen/efi.h> #include <xen/init.h> #include <xen/multiboot.h> +#include <asm/boot_info.h> +#include <asm/e820.h> #include <asm/mbd.h> #include <asm/page.h> -static multiboot_info_t mbi = {}; +struct boot_video_info { +u8 orig_x;/* 0x00 */ +u8 orig_y;/* 0x01 */ +u8 orig_video_mode;/* 0x02 */ +u8 orig_video_cols;/* 0x03 */ +u8 orig_video_lines;/* 0x04 */ +u8 orig_video_isVGA;/* 0x05 */ +u16 orig_video_points;/* 0x06 */ + +/* VESA graphic mode -- linear frame buffer */ +u32 capabilities;/* 0x08 */ +u16 lfb_linelength;/* 0x0c */ +u16 lfb_width;/* 0x0e */ +u16 lfb_height;/* 0x10 */ +u16 lfb_depth;/* 0x12 */ +u32 lfb_base;/* 0x14 */ +u32 lfb_size;/* 0x18 */ +u8 red_size;/* 0x1c */ +u8 red_pos;/* 0x1d */ +u8 green_size;/* 0x1e */ +u8 green_pos;/* 0x1f */ +u8 blue_size;/* 0x20 */ +u8 blue_pos;/* 0x21 */ +u8 rsvd_size;/* 0x22 */ +u8 rsvd_pos;/* 0x23 */ +u16 vesapm_seg;/* 0x24 */ +u16 vesapm_off;/* 0x26 */ +u16 vesa_attrib;/* 0x28 */ +}; + +/* These symbols live in the boot trampoline. Access via bootsym(). */ +extern struct e820entry e820map[]; +extern int e820nr; +extern unsigned int lowmem_kb, highmem_kb; + +extern struct boot_video_info boot_vid_info; + +extern unsigned short boot_edid_caps; +extern unsigned char boot_edid_info[128 ]; + +extern struct edd_info boot_edd_info[]; +extern u8 boot_edd_info_nr; + +extern struct mbr_signature boot_mbr_signature[]; +extern u8 boot_mbr_signature_nr; + +static boot_info_t __read_mostly boot_info_mb = { + .boot_loader_name ="UNKNOWN" , + .cmdline =NULL , + .mmap_type =NULL , + .mem_upper =0 , + .e820map_nr =0 , + .e820map =NULL , + .efi_mmap_size =0 , + .efi_mmap_desc_size =0 , + .efi_mmap =NULL , + .mps =EFI_INVALID_TABLE_ADDR , + .acpi =EFI_INVALID_TABLE_ADDR , + .acpi20 =EFI_INVALID_TABLE_ADDR , + .smbios =EFI_INVALID_TABLE_ADDR , + .efi_system_table =NULL , + .vga_console_info = {}, + .edid_caps =0 , + .edid_info =NULL , + .edd_info_nr =0 , + .edd_info =NULL , + .mbr_signature_nr =0 , + .mbr_signature =NULL , + .mods_nr =0 , + .mods =NULL , + .warn_msg =NULL , + .err_msg =NULL +}; + +#define e820_raw bootsym(e820map) +#define e820_raw_nr bootsym(e820nr)extern void enable_exception_support (void ); -unsigned long __init __init_boot_info (u32 mbd_ptr) +static void __init init_mmap (boot_info_t *boot_info,mbd_t *mbd) { -mbd_t *mbd =__va (mbd_ptr); +int bytes =0 ; +memory_map_t *map; -enable_exception_support (); +if ( e820_raw_nr ) + boot_info->mmap_type ="Xen-e820" ; +else if ( mbd->mmap_size ) + { + boot_info->mmap_type ="Multiboot-e820" ; + +while ( (bytes < mbd->mmap_size) && (e820_raw_nr <E820MAX ) ) + { +/* +* This is a gross workaround for a BIOS bug. Some bootloaders do +* not write e820 map entries into pre-zeroed memory. This is +* okay if the BIOS fills in all fields of the map entry, but +* some broken BIOSes do not bother to write the high word of +* the length field if the length is smaller than 4GB. We +* detect and fix this by flagging sections below 4GB that +* appear to be larger than 4GB in size. +*/ + map =__va (mbd->mmap + bytes); + +if ( !map->base_addr_high && map->length_high ) + { + map->length_high =0 ; + boot_info->warn_msg ="WARNING: Buggy e820 map detected and fixed " +"(truncated length fields).\n" ; + } -if ( mbd->boot_loader_name ) { - mbi.flags =MBI_LOADERNAME ; - mbi.boot_loader_name = mbd->boot_loader_name; + e820_raw[e820_raw_nr].addr = + ((u64 )map->base_addr_high <<32 ) | (u64 )map->base_addr_low; + e820_raw[e820_raw_nr].size = + ((u64 )map->length_high <<32 ) | (u64 )map->length_low; + e820_raw[e820_raw_nr].type = map->type; + e820_raw_nr++; + + bytes += map->size +4 ; + } + } +else if (bootsym (lowmem_kb) ) + { + boot_info->mmap_type ="Xen-e801" ; + + e820_raw[0 ].addr =0 ; + e820_raw[0 ].size =bootsym (lowmem_kb) <<10 ; + e820_raw[0 ].type =E820_RAM ; + e820_raw[1 ].addr =0x100000 ; + e820_raw[1 ].size =bootsym (highmem_kb) <<10 ; + e820_raw[1 ].type =E820_RAM ; + e820_raw_nr =2 ; } +else if ( mbd->mem_lower || mbd->mem_upper ) + { + boot_info->mmap_type ="Multiboot-e801" ; -if ( mbd->cmdline ) { - mbi.flags |=MBI_CMDLINE ; - mbi.cmdline = mbd->cmdline; + e820_raw[0 ].addr =0 ; + e820_raw[0 ].size = mbd->mem_lower <<10 ; + e820_raw[0 ].type =E820_RAM ; + e820_raw[1 ].addr =0x100000 ; + e820_raw[1 ].size = mbd->mem_upper <<10 ; + e820_raw[1 ].type =E820_RAM ; + e820_raw_nr =2 ; } +else + { + boot_info->err_msg ="Bootloader provided no memory information.\n" ; +return ; + } + + boot_info->mem_upper = mbd->mem_upper; + + boot_info->e820map_nr = e820_raw_nr; + boot_info->e820map = e820_raw; +} + +static void __init init_video_info (boot_info_t *boot_info) +{ +struct boot_video_info *bvi = &bootsym (boot_vid_info); + +if ( (bvi->orig_video_isVGA ==1 ) && (bvi->orig_video_mode ==3 ) ) + { + boot_info->vga_console_info.video_type =XEN_VGATYPE_TEXT_MODE_3 ; + boot_info->vga_console_info.u.text_mode_3.font_height = bvi->orig_video_points; + boot_info->vga_console_info.u.text_mode_3.cursor_x = bvi->orig_x; + boot_info->vga_console_info.u.text_mode_3.cursor_y = bvi->orig_y; + boot_info->vga_console_info.u.text_mode_3.rows = bvi->orig_video_lines; + boot_info->vga_console_info.u.text_mode_3.columns = bvi->orig_video_cols; + } +else if ( bvi->orig_video_isVGA ==0x23 ) + { + boot_info->vga_console_info.video_type =XEN_VGATYPE_VESA_LFB ; + boot_info->vga_console_info.u.vesa_lfb.width = bvi->lfb_width; + boot_info->vga_console_info.u.vesa_lfb.height = bvi->lfb_height; + boot_info->vga_console_info.u.vesa_lfb.bytes_per_line = bvi->lfb_linelength; + boot_info->vga_console_info.u.vesa_lfb.bits_per_pixel = bvi->lfb_depth; + boot_info->vga_console_info.u.vesa_lfb.lfb_base = bvi->lfb_base; + boot_info->vga_console_info.u.vesa_lfb.lfb_size = bvi->lfb_size; + boot_info->vga_console_info.u.vesa_lfb.red_pos = bvi->red_pos; + boot_info->vga_console_info.u.vesa_lfb.red_size = bvi->red_size; + boot_info->vga_console_info.u.vesa_lfb.green_pos = bvi->green_pos; + boot_info->vga_console_info.u.vesa_lfb.green_size = bvi->green_size; + boot_info->vga_console_info.u.vesa_lfb.blue_pos = bvi->blue_pos; + boot_info->vga_console_info.u.vesa_lfb.blue_size = bvi->blue_size; + boot_info->vga_console_info.u.vesa_lfb.rsvd_pos = bvi->rsvd_pos; + boot_info->vga_console_info.u.vesa_lfb.rsvd_size = bvi->rsvd_size; + boot_info->vga_console_info.u.vesa_lfb.gbl_caps = bvi->capabilities; + boot_info->vga_console_info.u.vesa_lfb.mode_attrs = bvi->vesa_attrib; + } + + boot_info->edid_caps =bootsym (boot_edid_caps); + boot_info->edid_info =bootsym (boot_edid_info); +} + +boot_info_t __init *__init_boot_info (u32 mbd_ptr) +{ +mbd_t *mbd =__va (mbd_ptr); + +enable_exception_support (); + +if ( mbd->boot_loader_name ) + boot_info_mb.boot_loader_name =__va (mbd->boot_loader_name); + +if ( mbd->cmdline ) + boot_info_mb.cmdline =__va (mbd->cmdline); + +init_mmap (&boot_info_mb, mbd); + +if ( boot_info_mb.err_msg ) + goto err; + +init_video_info (&boot_info_mb); - mbi.flags |=MBI_MEMLIMITS ; - mbi.mem_lower = mbd->mem_lower; - mbi.mem_upper = mbd->mem_upper; + boot_info_mb.edd_info_nr =bootsym (boot_edd_info_nr); + boot_info_mb.edd_info =bootsym (boot_edd_info); - mbi.flags |=MBI_MEMMAP ; - mbi.mmap_length = mbd->mmap_size; - mbi.mmap_addr = mbd->mmap; + boot_info_mb.mbr_signature_nr =bootsym (boot_mbr_signature_nr); + boot_info_mb.mbr_signature =bootsym (boot_mbr_signature); - mbi.flags |=MBI_MODULES ; - mbi.mods_count = mbd->mods_nr; - mbi.mods_addr = mbd->mods; + boot_info_mb.mods_nr = mbd->mods_nr; + boot_info_mb.mods =__va (mbd->mods); -return __pa (&mbi); +err: +return &boot_info_mb; }
xen/arch/x86/dmi_scan.c +4 -3
@@ -12,6 +12,7 @@#include <xen/efi.h> #include <xen/pci.h> #include <xen/pci_regs.h> +#include <asm/boot_info.h> #define bt_ioremap (b,l) ((void *)__acpi_map_table(b,l))#define bt_iounmap (b,l) ((void)0)
@@ -215,10 +216,10 @@ static int __init dmi_efi_iterate(void (*decode)(struct dmi_header *))const struct smbios_eps __iomem *p;int ret =-1 ; -if (efi.smbios ==EFI_INVALID_TABLE_ADDR ) +if (boot_info->smbios ==EFI_INVALID_TABLE_ADDR )return -1 ; - p =bt_ioremap (efi.smbios,sizeof (eps)); + p =bt_ioremap (boot_info->smbios,sizeof (eps));if (!p)return -1 ;memcpy_fromio (&eps, p,sizeof (eps));
@@ -227,7 +228,7 @@ static int __init dmi_efi_iterate(void (*decode)(struct dmi_header *))if (memcmp (eps.anchor,"_SM_" ,4 ))return -1 ; - p =bt_ioremap (efi.smbios, eps.length); + p =bt_ioremap (boot_info->smbios, eps.length);if (!p)return -1 ; if (dmi_checksum(p, eps.length) &&
xen/arch/x86/domain_build.c +12 -12
@@ -751,9 +751,9 @@ static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn,int __init construct_dom0 (struct domain *d, -const module_t *image,unsigned long image_headroom, -module_t *initrd, -void *(*bootstrap_map)(const module_t *), +const boot_module_t *image,unsigned long image_headroom, +boot_module_t *initrd, +void *(*bootstrap_map)(const boot_module_t *),char *cmdline) {int i, cpu, rc, compatible, compat32, order, machine;
@@ -770,9 +770,9 @@ int __init construct_dom0(struct vcpu *v = d->vcpu[0 ];unsigned long long value;char *image_base =bootstrap_map (image); -unsigned long image_len = image->mod_end; +unsigned long image_len = image->end;char *image_start = image_base + image_headroom; -unsigned long initrd_len = initrd ? initrd->mod_end :0 ; +unsigned long initrd_len = initrd ? initrd->end :0 ;l4_pgentry_t *l4tab =NULL , *l4start =NULL ;l3_pgentry_t *l3tab =NULL , *l3start =NULL ;l2_pgentry_t *l2tab =NULL , *l2start =NULL ;
@@ -987,7 +987,7 @@ int __init construct_dom0( initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >>PAGE_SHIFT : d->tot_pages; - initrd_mfn = mfn = initrd->mod_start; + initrd_mfn = mfn = initrd->start; count =PFN_UP (initrd_len);if ( d->arch.physaddr_bitsize && ((mfn + count -1 ) >> (d->arch.physaddr_bitsize -PAGE_SHIFT )) )
@@ -1002,12 +1002,12 @@ int __init construct_dom0(free_domheap_pages (page, order); page +=1UL << order; } -memcpy (page_to_virt (page),mfn_to_virt (initrd->mod_start), +memcpy (page_to_virt (page),mfn_to_virt (initrd->start), initrd_len); - mpt_alloc = (paddr_t )initrd->mod_start <<PAGE_SHIFT ; + mpt_alloc = (paddr_t )initrd->start <<PAGE_SHIFT ;init_domheap_pages (mpt_alloc, mpt_alloc +PAGE_ALIGN (initrd_len)); - initrd->mod_start = initrd_mfn =page_to_mfn (page); + initrd->start = initrd_mfn =page_to_mfn (page); }else {
@@ -1015,7 +1015,7 @@ int __init construct_dom0(if (assign_pages (d,mfn_to_page (mfn++),0 ,0 ) )BUG (); } - initrd->mod_end =0 ; + initrd->end =0 ; } printk("PHYSICAL MEMORY ARRANGEMENT:\n"
@@ -1026,7 +1026,7 @@ int __init construct_dom0( nr_pages - d->tot_pages);if ( initrd ) { - mpt_alloc = (paddr_t )initrd->mod_start <<PAGE_SHIFT ; + mpt_alloc = (paddr_t )initrd->start <<PAGE_SHIFT ;printk ("\n Init. ramdisk: %" PRIpaddr"->%" PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); }
@@ -1281,7 +1281,7 @@ int __init construct_dom0(if ( pfn >= initrd_pfn ) {if ( pfn < initrd_pfn +PFN_UP (initrd_len) ) - mfn = initrd->mod_start + (pfn - initrd_pfn); + mfn = initrd->start + (pfn - initrd_pfn);else mfn -=PFN_UP (initrd_len); }
xen/arch/x86/efi/boot.c +108 -106
450 lines not on this page · raw message
xen/arch/x86/efi/efi.h +0 -3
@@ -25,9 +25,6 @@ extern const CHAR16 *efi_fw_vendor;extern EFI_RUNTIME_SERVICES *efi_rs; -extern UINTN efi_memmap_size, efi_mdesc_size; -extern void *efi_memmap; -extern l4_pgentry_t *efi_l4_pgtable;extern const struct efi_pci_rom *efi_pci_roms;
xen/arch/x86/efi/runtime.c +39 -13
79 lines not on this page · raw message
xen/arch/x86/microcode.c +18 -21
@@ -40,8 +40,8 @@#include <asm/setup.h> #include <asm/microcode.h> -static module_t __initdata ucode_mod; -static void *(*__initdata ucode_mod_map)(const module_t *); +static boot_module_t __initdata ucode_mod; +static void *(*__initdata ucode_mod_map)(const boot_module_t *);static signed int __initdata ucode_mod_idx;static bool_t __initdata ucode_mod_forced;static cpumask_t __initdata init_mask;
@@ -94,10 +94,9 @@ custom_param("ucode", parse_ucode);void __init microcode_scan_module (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*bootmap)(const module_t *)) +const boot_info_t *boot_info, +void *(*bootmap)(const boot_module_t *)) { -module_t *mod = (module_t *)__va (mbi->mods_addr);uint64_t *_blob_start;unsigned long _blob_size;struct cpio_data cd;
@@ -119,13 +118,13 @@ void __init microcode_scan_module(/* * Try all modules and see whichever could be the microcode blob. */ -for ( i =1 /* Ignore dom0 kernel */ ; i < mbi->mods_count; i++ ) +for ( i =1 /* Ignore dom0 kernel */ ; i < boot_info->mods_nr; i++ ) {if ( !test_bit (i, module_map) )continue ; - _blob_start =bootmap (&mod[i]); - _blob_size = mod[i].mod_end; + _blob_start =bootmap (&boot_info->mods[i]); + _blob_size = boot_info->mods[i].end;if ( !_blob_start ) { printk("Could not map multiboot module #%d (size: %ld)\n",
@@ -165,21 +164,19 @@ err: }void __init microcode_grab_module (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*map)(const module_t *)) +const boot_info_t *boot_info, +void *(*map)(const boot_module_t *)) { -module_t *mod = (module_t *)__va (mbi->mods_addr); -if ( ucode_mod_idx <0 ) - ucode_mod_idx += mbi->mods_count; -if ( ucode_mod_idx <=0 || ucode_mod_idx >= mbi->mods_count || + ucode_mod_idx += boot_info->mods_nr; +if ( ucode_mod_idx <=0 || ucode_mod_idx >= boot_info->mods_nr || !__test_and_clear_bit (ucode_mod_idx, module_map) ) goto scan; - ucode_mod = mod[ucode_mod_idx]; + ucode_mod = boot_info->mods[ucode_mod_idx]; ucode_mod_map = map; scan:if ( ucode_scan ) -microcode_scan_module (module_map, mbi, map); +microcode_scan_module (module_map, boot_info, map); }const struct microcode_ops *microcode_ops;
@@ -345,7 +342,7 @@ int microcode_update(XEN_GUEST_HANDLE_PARAM(const_void) buf, unsigned long len)static void __init _do_microcode_update (unsigned long data) {void *_data = (void *)data; -size_t len = ucode_blob.size ? ucode_blob.size : ucode_mod.mod_end; +size_t len = ucode_blob.size ? ucode_blob.size : ucode_mod.end;microcode_update_cpu (_data, len);cpumask_set_cpu (smp_processor_id (), &init_mask);
@@ -360,7 +357,7 @@ static int __init microcode_init(void)if ( !microcode_ops )return 0 ; -if ( !ucode_mod.mod_end && !ucode_blob.size ) +if ( !ucode_mod.end && !ucode_blob.size )return 0 ; data = ucode_blob.size ? ucode_blob.data :ucode_mod_map (&ucode_mod);
@@ -414,7 +411,7 @@ static int __init microcode_presmp_init(void) {if ( microcode_ops ) { -if ( ucode_mod.mod_end || ucode_blob.size ) +if ( ucode_mod.end || ucode_blob.size ) {void *data;size_t len;
@@ -427,7 +424,7 @@ static int __init microcode_presmp_init(void) }else { - len = ucode_mod.mod_end; + len = ucode_mod.end; data =ucode_mod_map (&ucode_mod); }if ( data )
@@ -447,7 +444,7 @@ static int __init microcode_presmp_init(void) ucode_blob.data =NULL ; }else - ucode_mod.mod_end =0 ; + ucode_mod.end =0 ; } }
xen/arch/x86/mpparse.c +5 -4
@@ -29,6 +29,7 @@#include <asm/mpspec.h> #include <asm/io_apic.h> #include <asm/setup.h> +#include <asm/boot_info.h> #include <mach_apic.h> #include <mach_mpparse.h>
@@ -676,18 +677,18 @@ static void __init efi_check_config(void) {struct intel_mp_floating *mpf; -if (efi.mps ==EFI_INVALID_TABLE_ADDR ) +if (boot_info->mps ==EFI_INVALID_TABLE_ADDR )return ; -__set_fixmap (FIX_EFI_MPF ,PFN_DOWN (efi.mps), __PAGE_HYPERVISOR); - mpf = (void *)fix_to_virt (FIX_EFI_MPF ) + ((long )efi.mps & (PAGE_SIZE -1 )); +__set_fixmap (FIX_EFI_MPF ,PFN_DOWN (boot_info->mps), __PAGE_HYPERVISOR); + mpf = (void *)fix_to_virt (FIX_EFI_MPF ) + ((long )boot_info->mps & (PAGE_SIZE -1 ));if (memcmp (mpf->mpf_signature,"_MP_" ,4 ) ==0 && mpf->mpf_length ==1 &&mpf_checksum ((void *)mpf,16 ) && (mpf->mpf_specification ==1 || mpf->mpf_specification ==4 )) { smp_found_config =1 ; -printk (KERN_INFO "SMP MP-table at %08lx\n" , efi.mps); +printk (KERN_INFO "SMP MP-table at %08lx\n" , boot_info->mps); mpf_found = mpf; }else
xen/arch/x86/platform_hypercall.c +9 -10
@@ -30,6 +30,7 @@#include <asm/mtrr.h> #include <asm/io_apic.h> #include <asm/setup.h> +#include <asm/boot_info.h> #include "cpu/mtrr/mtrr.h" #include <xsm/xsm.h>
@@ -208,10 +209,10 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)u16 length; ret = -ESRCH ; -if ( op->u.firmware_info.index >=bootsym (boot_edd_info_nr) ) +if ( op->u.firmware_info.index >= boot_info->edd_info_nr )break ; - info =bootsym (boot_edd_info) + op->u.firmware_info.index; + info = boot_info->edd_info + op->u.firmware_info.index;/* Transfer the EDD info block. */ ret = -EFAULT ;
@@ -247,10 +248,10 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)const struct mbr_signature *sig; ret = -ESRCH ; -if ( op->u.firmware_info.index >=bootsym (boot_mbr_signature_nr) ) +if ( op->u.firmware_info.index >= boot_info->mbr_signature_nr )break ; - sig =bootsym (boot_mbr_signature) + op->u.firmware_info.index; + sig = boot_info->mbr_signature + op->u.firmware_info.index; op->u.firmware_info.u.disk_mbr_signature.device = sig->device; op->u.firmware_info.u.disk_mbr_signature.mbr_signature =
@@ -265,13 +266,11 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op) ret = -ESRCH ;if ( op->u.firmware_info.index !=0 )break ; -if ( *(u32 *)bootsym (boot_edid_info) ==0x13131313 ) +if ( *(u32 *)boot_info->edid_info ==0x13131313 )break ; - op->u.firmware_info.u.vbeddc_info.capabilities = -bootsym (boot_edid_caps); - op->u.firmware_info.u.vbeddc_info.edid_transfer_time = -bootsym (boot_edid_caps) >>8 ; + op->u.firmware_info.u.vbeddc_info.capabilities = boot_info->edid_caps; + op->u.firmware_info.u.vbeddc_info.edid_transfer_time = boot_info->edid_caps >>8 ; ret =0 ; if ( __copy_field_to_guest(u_xenpf_op, op, u.firmware_info.
@@ -279,7 +278,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)__copy_field_to_guest (u_xenpf_op, op, u.firmware_info. u.vbeddc_info.edid_transfer_time) ||copy_to_compat (op->u.firmware_info.u.vbeddc_info.edid, - bootsym(boot_edid_info), 128) ) + boot_info->edid_info, 128) ) ret = -EFAULT;break ;case XEN_FW_EFI_INFO :
xen/arch/x86/setup.c +102 -239
614 lines not on this page · raw message
xen/drivers/acpi/osl.c +5 -4
@@ -39,6 +39,7 @@#include <xen/domain_page.h> #include <xen/efi.h> #include <xen/vmap.h> +#include <asm/boot_info.h> #define _COMPONENT ACPI_OS_SERVICESACPI_MODULE_NAME ("osl" )
@@ -67,10 +68,10 @@ void __init acpi_os_vprintf(const char *fmt, va_list args)acpi_physical_address __init acpi_os_get_root_pointer (void ) {if (efi_enabled) { -if (efi.acpi20 !=EFI_INVALID_TABLE_ADDR ) -return efi.acpi20; -else if (efi.acpi !=EFI_INVALID_TABLE_ADDR ) -return efi.acpi; +if (boot_info->acpi20 !=EFI_INVALID_TABLE_ADDR ) +return boot_info->acpi20; +else if (boot_info->acpi !=EFI_INVALID_TABLE_ADDR ) +return boot_info->acpi;else { printk(KERN_ERR PREFIX "System description tables not found\n");
xen/drivers/video/vesa.c +4 -3
@@ -9,13 +9,14 @@#include <xen/lib.h> #include <xen/xmalloc.h> #include <xen/kernel.h> -#include <xen/vga.h> +#include <xen/video.h> #include <asm/io.h> #include <asm/page.h> +#include <asm/boot_info.h> #include "font.h" #include "lfb.h" -#define vlfb_info vga_console_info.u.vesa_lfb +#define vlfb_info (boot_info->vga_console_info.u.vesa_lfb)static void lfb_flush (void );
@@ -43,7 +44,7 @@ void __init vesa_early_init(void) {unsigned int vram_vmode; - vga_compat = !(vga_console_info.u.vesa_lfb.gbl_caps &2 ); + vga_compat = !(boot_info->vga_console_info.u.vesa_lfb.gbl_caps &2 );if ( (vlfb_info.bits_per_pixel <8 ) || (vlfb_info.bits_per_pixel >32 ) )return ;
xen/drivers/video/vga.c +8 -10
@@ -8,12 +8,10 @@#include <xen/init.h> #include <xen/lib.h> #include <xen/mm.h> -#include <xen/vga.h> +#include <xen/video.h> #include <xen/pci.h> #include <asm/io.h> - -/* Filled in by arch boot code. */ -struct xen_vga_console_info vga_console_info; +#include <asm/boot_info.h> static int vgacon_keep;static unsigned int xpos, ypos;
@@ -75,15 +73,15 @@ void __init video_init(void) vgacon_keep =1 ; } -switch ( vga_console_info.video_type ) +switch ( boot_info->vga_console_info.video_type ) {case XEN_VGATYPE_TEXT_MODE_3 :if (page_is_ram_type (paddr_to_pfn (0xB8000 ),RAM_TYPE_CONVENTIONAL ) || ((video =ioremap (0xB8000 ,0x8000 )) ==NULL ) )return ;outw (0x200a ,0x3d4 );/* disable cursor */ - columns = vga_console_info.u.text_mode_3.columns; - lines = vga_console_info.u.text_mode_3.rows; + columns = boot_info->vga_console_info.u.text_mode_3.columns; + lines = boot_info->vga_console_info.u.text_mode_3.rows;memset (video,0 , columns * lines *2 ); video_puts = vga_text_puts;break ;
@@ -92,7 +90,7 @@ void __init video_init(void)vesa_early_init ();break ;default : -memset (&vga_console_info,0 ,sizeof (vga_console_info)); +memset (&boot_info->vga_console_info,0 ,sizeof (boot_info->vga_console_info));break ; } }
@@ -163,7 +161,7 @@ void __init video_endboot(void) } } -switch ( vga_console_info.video_type ) +switch ( boot_info->vga_console_info.video_type ) {case XEN_VGATYPE_TEXT_MODE_3 :if ( !vgacon_keep )
@@ -206,6 +204,6 @@ static void vga_text_puts(const char *s)int __init fill_console_start_info (struct dom0_vga_console_info *ci) { -memcpy (ci, &vga_console_info,sizeof (*ci)); +memcpy (ci, &boot_info->vga_console_info,sizeof (*ci));return 1 ; }
xen/include/asm-x86/boot_info.h new file +126 -0
126 lines not on this page · raw message
xen/include/asm-x86/config.h +0 -2
@@ -119,8 +119,6 @@ extern unsigned int trampoline_xen_phys_start;extern unsigned char trampoline_cpu_started;extern char wakeup_start[];extern unsigned int video_mode, video_flags; -extern unsigned short boot_edid_caps; -extern unsigned char boot_edid_info[128 ];#endif #define asmlinkage
xen/include/asm-x86/e820.h +0 -8
@@ -33,12 +33,4 @@ extern int e820_add_range(extern unsigned long init_e820 (const char *,struct e820entry *,unsigned int *);extern struct e820map e820; -/* These symbols live in the boot trampoline. */ -extern struct e820entry e820map[]; -extern unsigned int e820nr; -extern unsigned int lowmem_kb, highmem_kb; - -#define e820_raw bootsym(e820map) -#define e820_raw_nr bootsym(e820nr) -#endif /*__E820_HEADER*/
xen/include/asm-x86/edd.h +0 -6
@@ -143,12 +143,6 @@ struct __packed mbr_signature { u32 signature; }; -/* These all reside in the boot trampoline. Access via bootsym(). */ -extern struct mbr_signature boot_mbr_signature[]; -extern u8 boot_mbr_signature_nr; -extern struct edd_info boot_edd_info[]; -extern u8 boot_edd_info_nr; -#endif /* __ASSEMBLY__ */ /* Maximum number of EDD information structures at boot_edd_info. */
xen/include/asm-x86/setup.h +5 -5
@@ -1,7 +1,7 @@#ifndef __X86_SETUP_H_#define __X86_SETUP_H_ -#include <xen/multiboot.h> +#include <asm/boot_info.h> extern unsigned long xenheap_initial_phys_start;
@@ -27,9 +27,9 @@ void vesa_mtrr_init(void);int construct_dom0 (struct domain *d, -const module_t *kernel,unsigned long kernel_headroom, -module_t *initrd, -void *(*bootstrap_map)(const module_t *), +const boot_module_t *kernel,unsigned long kernel_headroom, +boot_module_t *initrd, +void *(*bootstrap_map)(const boot_module_t *),char *cmdline);unsigned long initial_images_nrpages (void );
@@ -38,7 +38,7 @@ void discard_initial_images(void);int xen_in_range (unsigned long mfn);void microcode_grab_module ( -unsigned long *,const multiboot_info_t *,void *(*)(const module_t *)); +unsigned long *,const boot_info_t *,void *(*)(const boot_module_t *));extern uint8_t kbd_shift_flags;
xen/include/xen/efi.h +0 -10
@@ -9,16 +9,6 @@ extern const bool_t efi_enabled;#define EFI_INVALID_TABLE_ADDR (~0UL) -/* Add fields here only if they need to be referenced from non-EFI code. */ -struct efi { -unsigned long mps;/* MPS table */ -unsigned long acpi;/* ACPI table (IA64 ext 0.71) */ -unsigned long acpi20;/* ACPI table (ACPI 2.0) */ -unsigned long smbios;/* SM BIOS table */ -}; - -extern struct efi efi; -#ifndef __ASSEMBLY__union xenpf_efi_info ;
xen/include/xen/vga.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* -* vga.h -* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file COPYING in the main directory of this archive -* for more details. -*/ - -#ifndef _XEN_VGA_H -#define _XEN_VGA_H - -#include <xen/video.h> - -#ifdef CONFIG_VGA -extern struct xen_vga_console_info vga_console_info; -#endif - -#endif /* _XEN_VGA_H */
xen/include/xsm/xsm.h +7 -7
@@ -16,7 +16,7 @@#define __XSM_H__#include <xen/sched.h> -#include <xen/multiboot.h> +#include <asm/boot_info.h> typedef void xsm_op_t ;DEFINE_XEN_GUEST_HANDLE (xsm_op_t);
@@ -666,11 +666,11 @@ static inline int xsm_ioport_mapping (xsm_default_t def, struct domain *d, uint3#ifdef CONFIG_MULTIBOOT extern int xsm_multiboot_init (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*bootstrap_map)(const module_t *)); +const boot_info_t *boot_info, +void *(*bootstrap_map)(const boot_module_t *));extern int xsm_multiboot_policy_init (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*bootstrap_map)(const module_t *)); +const boot_info_t *boot_info, +void *(*bootstrap_map)(const boot_module_t *));#endif #ifdef HAS_DEVICE_TREE
@@ -690,8 +690,8 @@ extern void xsm_fixup_ops(struct xsm_operations *ops);#ifdef CONFIG_MULTIBOOT static inline int xsm_multiboot_init (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*bootstrap_map)(const module_t *)) +const boot_info_t *boot_info, +void *(*bootstrap_map)(const boot_module_t *)) {return 0 ; }
xen/xsm/xsm_core.c +3 -3
@@ -60,8 +60,8 @@ static int __init xsm_core_init(void)#ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_init (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*bootstrap_map)(const module_t *)) +const boot_info_t *boot_info, +void *(*bootstrap_map)(const boot_module_t *)) {int ret =0 ;
@@ -69,7 +69,7 @@ int __init xsm_multiboot_init(unsigned long *module_map,if (XSM_MAGIC ) { - ret =xsm_multiboot_policy_init (module_map, mbi, bootstrap_map); + ret =xsm_multiboot_policy_init (module_map, boot_info, bootstrap_map);if ( ret ) {bootstrap_map (NULL );
xen/xsm/xsm_policy.c +5 -9
@@ -19,9 +19,6 @@*/ #include <xsm/xsm.h> -#ifdef CONFIG_MULTIBOOT -#include <xen/multiboot.h> -#endif #include <xen/bitops.h> #ifdef HAS_DEVICE_TREE # include <asm/setup.h>
@@ -33,11 +30,10 @@ u32 __initdata policy_size = 0;#ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_policy_init (unsigned long *module_map, -const multiboot_info_t *mbi, -void *(*bootstrap_map)(const module_t *)) +const boot_info_t *boot_info, +void *(*bootstrap_map)(const boot_module_t *)) {int i; -module_t *mod = (module_t *)__va (mbi->mods_addr);int rc =0 ;u32 *_policy_start;unsigned long _policy_len;
@@ -46,13 +42,13 @@ int __init xsm_multiboot_policy_init(unsigned long *module_map,* Try all modules and see whichever could be the binary policy. * Adjust module_map for the module that is the binary policy. */ -for ( i = mbi->mods_count-1 ; i >=1 ; i-- ) +for ( i = boot_info->mods_nr -1 ; i >=1 ; i-- ) {if ( !test_bit (i, module_map) )continue ; - _policy_start =bootstrap_map (mod + i); - _policy_len = mod[i].mod_end; + _policy_start =bootstrap_map (boot_info->mods + i); + _policy_len = boot_info->mods[i].end;if ( (xsm_magic_t)(*_policy_start) ==XSM_MAGIC ) {
Signature · 1 line
1.7.10.4
PATCH v2 4/5 xen/x86: Use constant as multiboot protocol identifier
In reply to Daniel KiperUse constant as multiboot protocol identifier instead of plain number.
---
v2 - suggestions/fixes:
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).
--- xen/arch/x86/boot/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/boot/head.S +1 -1
@@ -82,7 +82,7 @@ __start: mov %ecx,%ss /* Check for Multiboot bootloader */ - cmp $0x2BADB002,%eax + cmp $MULTIBOOT_BOOTLOADER_MAGIC,%eax jne not_multiboot /* Set up trampoline segment 64k below EBDA */
Signature · 1 line
1.7.10.4
PATCH v2 5/5 xen/x86: Add multiboot2 protocol support
In reply to Daniel KiperAdd multiboot2 protocol support. This way we are laying the foundation for EFI + GRUB2 + Xen development.
---
v2 - suggestions/fixes:
- use "for" instead of "while" for loops (suggested by Jan Beulich),
- properly parenthesize macro arguments (suggested by Jan Beulich),
- change some local variables types (suggested by Jan Beulich),
- use meaningful labels
(suggested by Andrew Cooper and Jan Beulich),
- use local labels
(suggested by Jan Beulich),
- fix coding style
(suggested by Jan Beulich),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).
--- xen/arch/x86/boot/head.S | 117 +++++++++++++- xen/arch/x86/boot/reloc.c | 103 +++++++++++- xen/include/xen/multiboot2.h | 354 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 567 insertions(+), 7 deletions(-) create mode 100644 xen/include/xen/multiboot2.h
xen/arch/x86/boot/head.S +111 -6
@@ -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>
@@ -33,6 +34,68 @@ ENTRY(start) /* Checksum: must be the negated sum of the first two fields. */ .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) +/*** 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 tags... */ +.Lmultiboot2_info_req: + /* Multiboot2 information request tag. */ + .short MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST + .short MULTIBOOT2_HEADER_TAG_REQUIRED + .long .Lmultiboot2_info_req_end - .Lmultiboot2_info_req + .long MULTIBOOT2_TAG_TYPE_MMAP +.Lmultiboot2_info_req_end: + + /* + * Align Xen image and modules at page boundry. + * + * .balignl MULTIBOOT2_TAG_ALIGN, MULTIBOOT2_TAG_TYPE_END is a hack + * to avoid bug related to Multiboot2 information request tag in earlier + * versions of GRUB2. + * + * DO NOT MOVE THIS TAG! ANY CHANGE HERE MAY BREAK COMPATIBILITY + * WITH EARLIER GRUB2 VERSIONS! + */ + .balignl MULTIBOOT2_TAG_ALIGN, MULTIBOOT2_TAG_TYPE_END + .short MULTIBOOT2_HEADER_TAG_MODULE_ALIGN + .short MULTIBOOT2_HEADER_TAG_REQUIRED + .long 8 /* Tag size. */ + + /* Console flags tag. */ + .align MULTIBOOT2_TAG_ALIGN + .short MULTIBOOT2_HEADER_TAG_CONSOLE_FLAGS + .short MULTIBOOT2_HEADER_TAG_OPTIONAL + .long 12 /* Tag size. */ + .long MULTIBOOT2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED + + /* Framebuffer tag. */ + .align MULTIBOOT2_TAG_ALIGN + .short MULTIBOOT2_HEADER_TAG_FRAMEBUFFER + .short MULTIBOOT2_HEADER_TAG_OPTIONAL + .long 20 /* Tag size. */ + .long 0 /* Number of the columns - no preference. */ + .long 0 /* Number of the lines - no preference. */ + .long 0 /* Number of bits per pixel - no preference. */ + + /* Multiboot2 header end tag. */ + .align MULTIBOOT2_TAG_ALIGN + .short MULTIBOOT2_HEADER_TAG_END + .short 0 + .long 8 /* Tag size. */ +.Lmultiboot2_header_end: + .section .init.rodata, "a", @progbits .align 4
@@ -81,10 +144,56 @@ __start: mov %ecx,%es mov %ecx,%ss + /* Assume multiboot[12].mem_lower is 0 if not set by bootloader */ + xor %edx,%edx + /* Check for Multiboot bootloader */ cmp $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne not_multiboot + je multiboot_proto + + /* Check for Multiboot2 bootloader */ + cmp $MULTIBOOT2_BOOTLOADER_MAGIC,%eax + je multiboot2_proto + + jmp not_multiboot + +multiboot_proto: + /* Get mem_lower from Multiboot information */ + testb $MBI_MEMLIMITS,(%ebx) + jz trampoline_setup /* not available? BDA value will be fine */ + + mov 4(%ebx),%edx + shl $10-4,%edx + jmp trampoline_setup +multiboot2_proto: + /* Get Multiboot2 information address */ + mov %ebx,%ecx + + /* Skip Multiboot2 information fixed part */ + add $8,%ecx + +0: + /* Get mem_lower from Multiboot2 information */ + cmpl $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx) + jne 1f + + mov 8(%ecx),%edx + shl $10-4,%edx + jmp trampoline_setup + +1: + /* Is it the end of Multiboot2 information? */ + cmpl $MULTIBOOT2_TAG_TYPE_END,(%ecx) + je trampoline_setup + + /* Go to next Multiboot2 information tag */ + add 4(%ecx),%ecx + add $(MULTIBOOT2_TAG_ALIGN-1),%ecx + and $~(MULTIBOOT2_TAG_ALIGN-1),%ecx + jmp 0b + +trampoline_setup: /* Set up trampoline segment 64k below EBDA */ movzwl 0x40e,%ecx /* EBDA segment */ cmp $0xa000,%ecx /* sanity check (high) */
@@ -99,12 +208,8 @@ __start: * Compare the value in the BDA with the information from the * multiboot structure (if available) and use the smallest. */ - testb $MBI_MEMLIMITS,(%ebx) - jz 2f /* not available? BDA value will be fine */ - mov 4(%ebx),%edx - cmp $0x100,%edx /* is the multiboot value too small? */ + cmp $0x4000,%edx /* is the multiboot value too small? */ jb 2f /* if so, do not use it */ - shl $10-4,%edx cmp %ecx,%edx /* compare with BDA value */ cmovb %edx,%ecx /* and use the smaller */
xen/arch/x86/boot/reloc.c +102 -1
122 lines not on this page · raw message
xen/include/xen/multiboot2.h new file +354 -0
354 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 25 lines · Daniel Kiper
Hi,
This patch series breaks multiboot (v1) protocol dependency and adds multiboot2 support. It lays down the foundation for EFI + GRUB2 + Xen development. Detailed description of ideas and thoughts you will find in commit message for every patch. If something is not obvious please drop me a line.
Most of the requested things are fixed but there are still some minor outstanding issues (multiboot2 tags generation, excessive amount of casts in
xen/arch/x86/boot/reloc.c, etc.; please check commit messages for more details). If something is not fixed yet it means that I do not have good idea how to do that. In case you spot something which was mentioned during previous review and still think that your comment is valid in particular case please notify me.Below you can find reply for Konrad's questions in regards to exception request for Xen 4.5 release.
Quoted 5 lines
Couple of questions:
- Since this is mostly XBI code, is there a lot of overlap with the ARM/x86 refactoring of the EFI code? As in, will it require a lot of rebasing/fixing it up?
Quoted 6 lines
I did not checked that right now. However, Roy once told me that this should not be very big issue because overlap is not so big. Please check this email for more details: http://lists.xen.org/archives/html/xen-devel/2014-08/msg01173.html
Sadly, it was sent more then one month ago so maybe something has changed. Roy, any comments on that?
There aren't fundamental conceptual conflicts, but there will be quite a bit of refactoring/rebasing to do. Most of my patchset is re-organizingx86/efi/boot.c, so rebasing it on this patchset would be a significant
amount of work. My guess is that the first 10 of the 13 patches
in my series would need be be completely redone, as the code they are rearranging has been changed by your series.
I think that it would be much less work for you to re-base your series on mine, than the other way. The x86/efi/boot.c changes are a relatively small part of your series, but are the bulk of mine.
I should have another version of my patchset out today.
Quoted 62 lines
Anyway, I am more than happy to work on this issue with Roy.
Quoted 1 line
- What is the disadvantage of having this in Xen 4.6?
Well, it will require to rebase all this work on latest developments. It could be quite difficult because my patches touches a lot of places and as I can see there is a chance for substantial changes in some of them.
Quoted 5 lines
- What is the advantage of having this in Xen 4.5?
[My understanding is that it would allow us to thrash out a lot of
the early bootup issues _now_ and fix them up instead of having to deal in Xen 4.6 with this, EFI, and SecureBoot - which is a lot of more moving pieces]More or less. Additionally, we will have support for multiboot2 protocol in place. There is not very big demand for that but as I know at least Intel guys were looking for that. IIRC, they needed that for TPM support.
Daniel
xen/arch/x86/Makefile | 1 + xen/arch/x86/boot/cmdline.S | 9 +- xen/arch/x86/boot/head.S | 150 ++++++++++++++++++++++++++++----- xen/arch/x86/boot/reloc.c | 248 ++++++++++++++++++++++++++++++++++++++++++++----------- xen/arch/x86/boot/x86_64.S | 10 ++- xen/arch/x86/boot_info.c | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/dmi_scan.c | 7 +- xen/arch/x86/domain_build.c | 24 +++--- xen/arch/x86/e820.c | 8 +- xen/arch/x86/efi/boot.c | 214 +++++++++++++++++++++++------------------------ xen/arch/x86/efi/efi.h | 3 - xen/arch/x86/efi/runtime.c | 52 +++++++++--- xen/arch/x86/microcode.c | 39 ++++----- xen/arch/x86/mpparse.c | 9 +- xen/arch/x86/platform_hypercall.c | 19 ++--- xen/arch/x86/setup.c | 370 +++++++++++++++++++++++++++------------------------------------------------------- xen/arch/x86/x86_64/asm-offsets.c | 5 +- xen/drivers/acpi/osl.c | 9 +- xen/drivers/video/vesa.c | 7 +- xen/drivers/video/vga.c | 18 ++-- xen/include/asm-x86/boot_info.h | 126 ++++++++++++++++++++++++++++ xen/include/asm-x86/config.h | 2 - xen/include/asm-x86/e820.h | 10 +-- xen/include/asm-x86/edd.h | 6 -- xen/include/asm-x86/mbd.h | 70 ++++++++++++++++ xen/include/asm-x86/setup.h | 10 +-- xen/include/xen/efi.h | 10 --- xen/include/xen/multiboot2.h | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/vga.h | 18 ---- xen/include/xsm/xsm.h | 14 ++-- xen/xsm/xsm_core.c | 6 +- xen/xsm/xsm_policy.c | 14 ++-- 32 files changed, 1510 insertions(+), 590 deletions(-)Daniel Kiper (5):
xen/x86: Introduce MultiBoot Data (MBD) type xen/x86: Define e820 entries counter as unsigned int xen/x86: Migrate toboot_infostructure xen/x86: Use constant as multiboot protocol identifier xen/x86: Add multiboot2 protocol support
Re: [PATCH v2 2/5] xen/x86: Define e820 entries counter as unsigned int
In reply to Daniel KiperQuoted 4 lines · Daniel Kiper
e820 entries counter is inherently an unsigned quantity so define it as unsigned int.
Signed-off-by Daniel Kiper <[email protected]>
Although as a cleanup patch, this should be ahead of function changes in your series.
Quoted 62 lines
---
v2 - suggestions/fixes:
- change e820 entries counter signedness
(suggested by Andrew Cooper).--- xen/arch/x86/e820.c | 8 ++++---- xen/include/asm-x86/e820.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)xen/arch/x86/e820.c +4
-4@@ -89,9 +89,9 @@ static void __init add_memory_region(unsigned long long start, } }/* add_memory_region */ -static void __init print_e820_memory_map (struct e820entry *map,int entries) +static void __init print_e820_memory_map (struct e820entry *map,unsigned int entries) { -int i; +unsigned int i;for (i =0 ; i < entries; i++) { printk(" %016Lx - %016Lx ",@@ -512,7 +512,7 @@ static void __init reserve_dmi_region(void) }static void __init machine_specific_memory_setup ( -struct e820entry *raw,int *raw_nr) +struct e820entry *raw,unsigned int *raw_nr) {unsigned long mpt_limit, ro_mpt_limit;uint64_t top_of_ram, size;@@ -695,7 +695,7 @@ int __init reserve_e820_ram(struct e820map *e820, uint64_t s, uint64_t e) }unsigned long __init init_e820 ( -const char *str,struct e820entry *raw,int *raw_nr) +const char *str,struct e820entry *raw,unsigned int *raw_nr) {if ( e820_verbose ) {xen/include/asm-x86/e820.h +2
-2@@ -30,12 +30,12 @@ extern int e820_change_range_type( uint32_t orig_type, uint32_t new_type);extern int e820_add_range (struct e820map *,uint64_t s,uint64_t e,uint32_t type); -extern unsigned long init_e820 (const char *,struct e820entry *,int *); +extern unsigned long init_e820 (const char *,struct e820entry *,unsigned int *);extern struct e820map e820;/* These symbols live in the boot trampoline. */ extern struct e820entry e820map[]; -extern int e820nr; +extern unsigned int e820nr;extern unsigned int lowmem_kb, highmem_kb;#define e820_raw bootsym(e820map)
Re: [PATCH v2 4/5] xen/x86: Use constant as multiboot protocol identifier
In reply to Daniel KiperQuoted 3 lines · Daniel Kiper
Use constant as multiboot protocol identifier instead of plain number.
Signed-off-by Daniel Kiper <[email protected]>
Again - should be ahead of functional changes in your series.
Quoted 21 lines
---
v2 - suggestions/fixes:
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).--- xen/arch/x86/boot/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/boot/head.S +1
-1@@ -82,7 +82,7 @@ __start: mov %ecx,%ss /* Check for Multiboot bootloader */ - cmp $0x2BADB002,%eax + cmp $MULTIBOOT_BOOTLOADER_MAGIC,%eax jne not_multiboot /* Set up trampoline segment 64k below EBDA */
Re: [PATCH v2 1/5] xen/x86: Introduce MultiBoot Data (MBD) type
In reply to Daniel KiperQuoted 16 lines · Daniel Kiper
Introduce MultiBoot Data (MBD) type. It is used to define variable which carry over data from multiboot protocol (any version) through Xen preloader stage. Later all or parts of this data is used to initialize
boot_infostructure.boot_infois introduced in later patches.MBD helps to break multiboot (v1) protocol dependency. Using it we are able to save space on trampoline (we do not allocate space for unused data what happens in current preloader implementation). Additionally, we are able to easily add new members to MBD if we want support for new features or protocols.
There is not plan to share MBD among architectures. It will be nice if
boot_infowill be shared among architectures. Please check later patches for more details.
Quoted 6 lines
Code found in
xen/arch/x86/boot_info.cmoves MBD data to mbi struct which is referenced from main Xen code. This is temporary solution which helps to split patches into logical parts. Later it will be replaced by final version ofboot_infosupport.Signed-off-by Daniel Kiper <[email protected]>
Reviewing changes to ASM code is *very* hard, and this patch is still very complicated.
Can I suggest patches split along the following lines.
* Shuffling of registers in head.S to end up with %eax and %ecx as indended for reloc.c, and %ebx currently unclobbered, and adjusting reloc.c for %ecx. Review for this is a simple case of verifying that the changes are just a strict shuffling of registers.
* Whitespace and misc non-MBD cleanup to reloc.c
* Altering existing helper functions in preparation for MBD support
* Actually introduce mbd_t and use it.
In addition, I have some specific comments about the changes themselves.
Quoted 39 lines
---
v2 - suggestions/fixes:
- improve inline assembly
(suggested by Andrew Cooper and Jan Beulich),
- use__usedattribute
(suggested by Andrew Cooper),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).--- xen/arch/x86/Makefile | 1 + xen/arch/x86/boot/cmdline.S | 9 +-- xen/arch/x86/boot/head.S | 31 ++++---- xen/arch/x86/boot/reloc.c | 147 +++++++++++++++++++++++++------------ xen/arch/x86/boot/x86_64.S | 10 ++- xen/arch/x86/boot_info.c | 58 +++++++++++++++ xen/arch/x86/setup.c | 41 +++++++---- xen/arch/x86/x86_64/asm-offsets.c | 5 +- xen/include/asm-x86/mbd.h | 70 ++++++++++++++++++ 9 files changed, 284 insertions(+), 88 deletions(-) create mode 100644 xen/arch/x86/boot_info.c create mode 100644 xen/include/asm-x86/mbd.hxen/arch/x86/Makefile +1
-0@@ -42,6 +42,7 @@ obj-y += numa.o obj-y += pci.o obj-y += percpu.o obj-y += physdev.o +obj-y += boot_info.o obj-y += setup.o obj-y += shutdown.o obj-y += smp.oxen/arch/x86/boot/cmdline.S +0
-0
xen/arch/x86/boot/cmdline.S cmdline_parse_early: · line 155
Quoted 9 lines
xen/arch/x86/boot/cmdline.S +1
-5@@ -152,17 +152,14 @@ cmdline_parse_early: pusha /* Bail if there is no command line to parse. */ - mov sym_phys(multiboot_ptr),%ebx - mov MB_flags(%ebx),%eax - test $4,%al - jz .Lcmdline_exit - mov MB_cmdline(%ebx),%eax + mov sym_phys(mbd_ptr),%ebx
As you are already changing the name of this symbol, please call it mbd_pa or something to indicate that it genuinely is a physical address, not a pointer in the C sense of the term.
Quoted 92 lines
xen/arch/x86/boot/cmdline.S +2
-1+ mov MBD_cmdline(%ebx),%eax test %eax,%eax jz .Lcmdline_exit /* Check for 'no-real-mode' command-line option. */ pushl $sym_phys(.Lno_rm_opt) - pushl MB_cmdline(%ebx) + pushl MBD_cmdline(%ebx) call .Lfind_option test %eax,%eax setnz %alxen/arch/x86/boot/head.S +16
-15@@ -86,14 +86,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@@ -105,22 +105,23 @@ __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. */ + /* Save the Multiboot data (after relocation) for later use. */ mov $sym_phys(cpu0_stack)+1024,%esp - push %ebx - call reloc - mov %eax,sym_phys(multiboot_ptr) + push %eax /* Multiboot magic */ + push %ebx /* Multiboot information address */ + call reloc /* %ecx contains trampoline address */ + mov %eax,sym_phys(mbd_ptr) /* Initialize BSS (no nasty surprises!) */ mov $sym_phys(__bss_start),%edixen/arch/x86/boot/reloc.c +6
-4@@ -1,40 +1,58 @@ -/****************************************************************************** +/* * reloc.c -* +* * 32-bit flat memory-map routines for relocating Multiboot structures * and modules. This is most easily done early with paging disabled. -* +* * Copyright (c) 2009, Citrix Systems, Inc. -* +* Copyright (c) 2013, 2014 Oracle Co., Daniel Kiper +* * Authors: * Keir Fraser <[email protected]> +* Daniel Kiper */
xen/arch/x86/boot/reloc.c line 23
Quoted 10 lines
xen/arch/x86/boot/reloc.c +9
-1-/* entered with %eax = BOOT_TRAMPOLINE */ +typedef unsigned char u8 ; +typedef unsigned short u16 ; +typedef unsigned long u32 ; +typedef unsigned long long u64 ; + +#include "../../../include/xen/compiler.h" +#include "../../../include/xen/multiboot.h" + +#include "../../../include/asm/mbd.h"
How about playing with -I for this file in the Makefile to allow #include <xen/compiler.h> and so ?
xen/arch/x86/boot/reloc.c line 26
Quoted 3 lines
xen/arch/x86/boot/reloc.c +3
-0+ +/* +* __HERE__ IS ENTRY POINT!!!
I am still of the firm opinion that anyone capable of editing this file ought to know understand the _start symbol, making this comment useless.
Quoted 218 lines
xen/arch/x86/boot/reloc.c +83
-41+* +* It is entered from xen/arch/x86/boot/head.S with: +* - %eax = MULTIBOOT_MAGIC, +* - %ebx = MULTIBOOT_INFORMATION_ADDRESS, +* - %ecx = BOOT_TRAMPOLINE. +*/ asm (" .text \n" " .globl _start \n" "_start: \n" " call 1f \n" "1: pop %ebx \n" -" mov %eax,alloc-1b(%ebx) \n" -" jmp reloc \n" +" mov %ecx,alloc-1b(%ebx) \n" +" jmp __reloc \n" ); -/* This is our data. Because the code must be relocatable, no BSS is -* allowed. All data is accessed PC-relative with inline assembly. +/* +* This is our data. Because the code must be relocatable, no BSS is +* allowed. All data is accessed PC-relative with inline assembly. */ asm ("alloc: \n" " .long 0 \n" ); -typedef unsigned int u32 ; -#include "../../../include/xen/multiboot.h" - -static void *reloc_mbi_struct (void *old,unsigned int bytes) +static u32 alloc_struct (u32 bytes) { -void *new; +u32 s; + asm(" call 1f \n" "1: pop %%edx \n"@@ -42,58 +60,95 @@ 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" + : "=&r" (s) : "r" (bytes) : "edx"); + + return s; +} + +static void zero_struct (u32 s,u32 bytes) +{ + asmvolatile ( +" rep stosb \n" + :"+D" (s),"+c" (bytes) :"a" (0 )); +} + +static u32 copy_struct (u32 src,u32 bytes) +{ +u32 dst, dst_asm; + + dst =alloc_struct (bytes); + dst_asm = dst; + + asmvolatile (" rep movsb \n" - : "=&r" (new), "+c" (bytes), "+S" (old) - : : "edx", "edi"); - return new; + :"+S" (src),"+D" (dst_asm),"+c" (bytes)); + +return dst; } -static char *reloc_mbi_string (char *old) +static u32 copy_string (u32 src) {char *p; -for ( p = old; *p !='\0' ; p++ ) + +if ( src ==0 ) +return 0 ; + +for ( p = (char *)src; *p !='\0' ; p++ )continue ; -return reloc_mbi_struct (old, p - old +1 ); + +return copy_struct (src, p - (char *)src +1 ); } -multiboot_info_t *reloc (multiboot_info_t *mbi_old) +static mbd_t *mb_mbd (mbd_t *mbd,multiboot_info_t *mbi) { -multiboot_info_t *mbi =reloc_mbi_struct (mbi_old,sizeof (*mbi)); -int i; +boot_module_t *mbd_mods; +module_t *mbi_mods; +u32 i; + +if ( mbi->flags &MBI_LOADERNAME ) + mbd->boot_loader_name =copy_string (mbi->boot_loader_name);if ( mbi->flags &MBI_CMDLINE ) - mbi->cmdline = (u32 )reloc_mbi_string ((char *)mbi->cmdline); + mbd->cmdline =copy_string (mbi->cmdline); + +if ( mbi->flags &MBI_MEMLIMITS ) + { + mbd->mem_lower = mbi->mem_lower; + mbd->mem_upper = mbi->mem_upper; + } + +if ( mbi->flags &MBI_MEMMAP ) + { + mbd->mmap_size = mbi->mmap_length; + mbd->mmap =copy_struct (mbi->mmap_addr, mbi->mmap_length); + }if ( mbi->flags &MBI_MODULES ) { -module_t *mods =reloc_mbi_struct ( - (module_t *)mbi->mods_addr, mbi->mods_count *sizeof (module_t)); + mbd->mods_nr = mbi->mods_count; + mbd->mods =alloc_struct (mbi->mods_count *sizeof (boot_module_t)); - mbi->mods_addr = (u32 )mods; + mbi_mods = (module_t *)mbi->mods_addr; + mbd_mods = (boot_module_t *)mbd->mods;for ( i =0 ; i < mbi->mods_count; i++ ) { -if ( mods[i].string ) - mods[i].string = (u32 )reloc_mbi_string ((char *)mods[i].string); + mbd_mods[i].start = mbi_mods[i].mod_start; + mbd_mods[i].end = mbi_mods[i].mod_end; + mbd_mods[i].cmdline =copy_string (mbi_mods[i].string); + mbd_mods[i].relocated =0 ; } } -if ( mbi->flags &MBI_MEMMAP ) - mbi->mmap_addr = (u32 )reloc_mbi_struct ( - (memory_map_t *)mbi->mmap_addr, mbi->mmap_length); +return mbd; +} -if ( mbi->flags &MBI_LOADERNAME ) - mbi->boot_loader_name = (u32 )reloc_mbi_string ( - (char *)mbi->boot_loader_name); - -/* Mask features we don't understand or don't relocate. */ - mbi->flags &= (MBI_MEMLIMITS | -MBI_BOOTDEV | -MBI_CMDLINE | -MBI_MODULES | -MBI_MEMMAP | -MBI_LOADERNAME ); - -return mbi; +static mbd_t __used *__reloc (void *mbi,u32 mb_magic) +{ +mbd_t *mbd; + + mbd = (mbd_t *)alloc_struct (sizeof (mbd_t)); +zero_struct ((u32 )mbd,sizeof (mbd_t)); + +return mb_mbd (mbd, mbi); }xen/arch/x86/boot/x86_64.S +7
-3@@ -29,8 +29,12 @@ test %ebx,%ebx jnz start_secondary - /* Pass off the Multiboot info structure to C land. */ - mov multiboot_ptr(%rip),%edi + /* Init boot_info. */ + mov mbd_ptr(%rip),%edi + call __init_boot_info + + /* Pass off the boot_info to C land. */ + movq %rax,%rdi call __start_xen ud2 /* Force a panic (invalid opcode). */@@ -38,7 +42,7 @@ .data .align 8 -multiboot_ptr: +mbd_ptr: .long 0 .word 0xen/arch/x86/boot_info.c new file +15
-0@@ -0,0 +1,58 @@ +/* +* Copyright (c) 2013, 2014 Oracle Co., Daniel Kiper +* +* This program 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 2 of the License, or +* (at your option) any later version. +* +* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
xen/arch/x86/boot_info.c line 25
Quoted 10 lines
xen/arch/x86/boot_info.c new file +10
-0+*/ + +#include <xen/types.h> +#include <xen/init.h> +#include <xen/multiboot.h> + +#include <asm/mbd.h> +#include <asm/page.h> + +static multiboot_info_t mbi = {};
"= {}" is redundant for a static declaration.
Quoted 79 lines
xen/arch/x86/boot_info.c new file +33
-0+ +extern void enable_exception_support (void ); + +unsigned long __init __init_boot_info (u32 mbd_ptr) +{ +mbd_t *mbd =__va (mbd_ptr); + +enable_exception_support (); + +if ( mbd->boot_loader_name ) { + mbi.flags =MBI_LOADERNAME ; + mbi.boot_loader_name = mbd->boot_loader_name; + } + +if ( mbd->cmdline ) { + mbi.flags |=MBI_CMDLINE ; + mbi.cmdline = mbd->cmdline; + } + + mbi.flags |=MBI_MEMLIMITS ; + mbi.mem_lower = mbd->mem_lower; + mbi.mem_upper = mbd->mem_upper; + + mbi.flags |=MBI_MEMMAP ; + mbi.mmap_length = mbd->mmap_size; + mbi.mmap_addr = mbd->mmap; + + mbi.flags |=MBI_MODULES ; + mbi.mods_count = mbd->mods_nr; + mbi.mods_addr = mbd->mods; + +return __pa (&mbi); +}xen/arch/x86/setup.c +19
-12@@ -539,6 +539,25 @@ static char * __init cmdline_cook(char *p, char *loader_name)return p; } +void __init enable_exception_support (void ) +{ +/* Critical region without IDT or TSS. Any fault is deadly! */ + +set_processor_id (0 ); +set_current ((struct vcpu *)0xfffff000 );/* debug sanity. */ + idle_vcpu[0 ] = current; + +percpu_init_areas (); + +init_idt_traps (); +load_system_tables (); + +smp_prepare_boot_cpu (); +sort_exception_tables (); + +/* Full exception support from here on in. */ +} +void __init noreturn__start_xen (unsigned long mbi_p) {char *memmap_type =NULL ;@@ -556,21 +575,13 @@ void __init noreturn __start_xen(unsigned long mbi_p) .stop_bits = 1 }; -/* Critical region without IDT or TSS. Any fault is deadly! */ - -set_processor_id (0 ); -set_current ((struct vcpu *)0xfffff000 );/* debug sanity. */ - idle_vcpu[0 ] = current; - -percpu_init_areas (); - -init_idt_traps (); -load_system_tables (); - -smp_prepare_boot_cpu ();
xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 584
Quoted 10 lines
xen/arch/x86/setup.c +7
-3-sort_exception_tables (); - -/* Full exception support from here on in. */ +if ( !efi_enabled ) { +/* Exception support was enabled before __start_xen() call. */ + } +else + { +enable_exception_support (); + }
For this, absolutely not.
Pass mbi_pa into __start_xen() and have __start_xen() call __init_boot_info() after it has set up exception support. None of the contents of MBD are needed beforehand.
Quoted 39 lines
xen/arch/x86/setup.c +0
-0loader = (mbi->flags &MBI_LOADERNAME ) ? (char *)__va (mbi->boot_loader_name) :"unknown" ;xen/arch/x86/x86_64/asm-offsets.c +2
-3@@ -12,7 +12,7 @@#include <compat/xen.h> #include <asm/fixmap.h> #include <asm/hardirq.h> -#include <xen/multiboot.h> +#include <asm/mbd.h> #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \@@ -163,6 +163,5 @@ void __dummy__(void) OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);BLANK (); -OFFSET (MB_flags, multiboot_info_t, flags); -OFFSET (MB_cmdline, multiboot_info_t, cmdline); +OFFSET (MBD_cmdline, mbd_t, cmdline); }xen/include/asm-x86/mbd.h new file +9
-0@@ -0,0 +1,70 @@ +/* +* Copyright (c) 2013, 2014 Oracle Co., Daniel Kiper +* +* This program 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 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful,
xen/include/asm-x86/mbd.h line 19
Quoted 10 lines
xen/include/asm-x86/mbd.h new file +10
-0+* 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 this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MBD_H__ +#define __MBD_H__
#include <xen/types.h>
Do not rely on the translation using including this file to make u32 available for you.
Quoted 15 lines
xen/include/asm-x86/mbd.h new file +15
-0+ +/* Module type. */ +typedef struct { +u32 start; +u32 end; + +/* Pointer to a module command line. */ +u32 cmdline; + +/* If relocated != 0 then a given module was relocated. */ +u32 relocated; +}boot_module_t ; + +/* +* MultiBoot Data (MBD) type. It is used to define variable which
xen/include/asm-x86/mbd.h line 44
Quoted 10 lines
xen/include/asm-x86/mbd.h new file +10
-0+* carry over data from multiboot protocol (any version) through +* Xen preloader stage. Later all or parts of this data is used +* to initialize boot_info structure. +*/ +typedef struct { + /* Pointer to boot loader name. */ + u32 boot_loader_name; + + /* Pointer to Xen command line. */ + u32 cmdline;
These need to be very clear about being physical addresses rather than pointers.
~Andrew
Quoted 26 lines
xen/include/asm-x86/mbd.h new file +26
-0+ +/* +* Amount of lower memory (in KiB) accordingly to The Multiboot +* Specification version 0.6.96. +*/ +u32 mem_lower; + +/* +* Amount of upper memory (in KiB) accordingly to The Multiboot +* Specification version 0.6.96. +*/ +u32 mem_upper; + +/* Size (in bytes) of memory map provided by bootloader. */ +u32 mmap_size; + +/* Pointer to memory map provided by bootloader. */ +u32 mmap; + +/* Number of modules. */ +u32 mods_nr; + +/* Pointer to modules description (boot_module_t *). */ + u32 mods; +} mbd_t; +#endif /* __MBD_H__ */
Re: [PATCH v2 3/5] xen/x86: Migrate to boot_info structure
In reply to Daniel KiperQuoted 33 lines · Daniel Kiper
Break multiboot (v1) protocol dependency. It means that most of Xen code (excluding preloader) could be bootloader agnostic and does not need almost any knowledge about boot protocol. Additionally, we are able to pass all boot data to
__start_xen()in one bucket without any side channels. I do not mention that we are also able to easily identify boot data in Xen code.Here is boot data flow for legacy BIOS platform:
BIOS -> GRUB -> multiboot[12]* -> __reloc() -> MBD ->-\ / ------<------<------<------<------<------<----- \ \ ---> __init_boot_info() -> boot_info_mb -> __start_xen() -> boot_info /BIOS ->-/
* multiboot2 is not implemented yet. Look for it in later patches.
Here is boot data flow for EFI platform:
EFI ->
efi_start()->boot_info_efi->__start_xen()->boot_infoWARNING: ARM build could be broken by this patch. We need to agree
boot_infointegration into ARM. Personally I think that it is worth storing all data from any bootloader and preloader inboot_infoon any architecture. This give a chance to share more code between architectures. However, every architecture should define its ownboot_info(in relevantinclude/asmdirectory). Despite that it looks that some parts of it could be common, e.g. modules data, command line arguments, boot loader name, EFI data, etc., even if types would not be the same. So, as it was stated above a lot of code could be shared among architectures.
Quoted 1 line
Signed-off-by Daniel Kiper <[email protected]>
This patch is basically unreviewable. Please split it up more, starting with misc cleanup such as video.h vs vga.h
e.g. start with
typedef struct {
/* Boot loader name. */
char *boot_loader_name;
} boot_info_t;And make some stub declarations which set and retrieve the loader name alone.
Then over the course of the following patches, move small bits one at a time into this new structure, such as the command line then memory map, acpi tables, smbios tables etc. This should probably be at least 8 patches.
~Andrew
Re: [PATCH v2 5/5] xen/x86: Add multiboot2 protocol support
In reply to Daniel KiperQuoted 4 lines · Daniel Kiper
Add multiboot2 protocol support. This way we are laying the foundation for EFI + GRUB2 + Xen development.
Signed-off-by Daniel Kiper <[email protected]>
Much clearer than before.
Can I suggest retroactively renaming the old multiboot bits to multiboot1 to make a more marked difference between between "multiboot1_proto" and "multiboot2_proto" ?
It would also be better to split the changing of multiboot1 and shuffling of memory calculations away from the introduction of multiboot2.
Quoted 106 lines
---
v2 - suggestions/fixes:
- use "for" instead of "while" for loops
(suggested by Jan Beulich),
- properly parenthesize macro argumentschar
*boot_loader_name;
(suggested by Jan Beulich),
- change some local variables types (suggested by Jan Beulich),
- use meaningful labels
(suggested by Andrew Cooper and Jan Beulich),
- use local labels
(suggested by Jan Beulich),
- fix coding style
(suggested by Jan Beulich),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).--- xen/arch/x86/boot/head.S | 117 +++++++++++++- xen/arch/x86/boot/reloc.c | 103 +++++++++++- xen/include/xen/multiboot2.h | 354 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 567 insertions(+), 7 deletions(-) create mode 100644 xen/include/xen/multiboot2.hxen/arch/x86/boot/head.S +63
-0@@ -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>@@ -33,6 +34,68 @@ ENTRY(start) /* Checksum: must be the negated sum of the first two fields. */ .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) +/*** 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 tags... */ +.Lmultiboot2_info_req: + /* Multiboot2 information request tag. */ + .short MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST + .short MULTIBOOT2_HEADER_TAG_REQUIRED + .long .Lmultiboot2_info_req_end - .Lmultiboot2_info_req + .long MULTIBOOT2_TAG_TYPE_MMAP +.Lmultiboot2_info_req_end: + + /* + * Align Xen image and modules at page boundry. + * + * .balignl MULTIBOOT2_TAG_ALIGN, MULTIBOOT2_TAG_TYPE_END is a hack + * to avoid bug related to Multiboot2 information request tag in earlier + * versions of GRUB2. + * + * DO NOT MOVE THIS TAG! ANY CHANGE HERE MAY BREAK COMPATIBILITY + * WITH EARLIER GRUB2 VERSIONS! + */ + .balignl MULTIBOOT2_TAG_ALIGN, MULTIBOOT2_TAG_TYPE_END + .short MULTIBOOT2_HEADER_TAG_MODULE_ALIGN + .short MULTIBOOT2_HEADER_TAG_REQUIRED + .long 8 /* Tag size. */ + + /* Console flags tag. */ + .align MULTIBOOT2_TAG_ALIGN + .short MULTIBOOT2_HEADER_TAG_CONSOLE_FLAGS + .short MULTIBOOT2_HEADER_TAG_OPTIONAL + .long 12 /* Tag size. */ + .long MULTIBOOT2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED + + /* Framebuffer tag. */ + .align MULTIBOOT2_TAG_ALIGN + .short MULTIBOOT2_HEADER_TAG_FRAMEBUFFER + .short MULTIBOOT2_HEADER_TAG_OPTIONAL + .long 20 /* Tag size. */ + .long 0 /* Number of the columns - no preference. */ + .long 0 /* Number of the lines - no preference. */ + .long 0 /* Number of bits per pixel - no preference. */ + + /* Multiboot2 header end tag. */ + .align MULTIBOOT2_TAG_ALIGN + .short MULTIBOOT2_HEADER_TAG_END + .short 0 + .long 8 /* Tag size. */ +.Lmultiboot2_header_end: + .section .init.rodata, "a", @progbits .align 4
xen/arch/x86/boot/head.S __start: · line 149
Quoted 6 lines
xen/arch/x86/boot/head.S +3
-0@@ -81,10 +144,56 @@ __start: mov %ecx,%es mov %ecx,%ss + /* Assume multiboot[12].mem_lower is 0 if not set by bootloader */ + xor %edx,%edx +
This change does not match its comment, and seems to have appeared from nowhere.
Quoted 52 lines
xen/arch/x86/boot/head.S +44
-1/* Check for Multiboot bootloader */ cmp $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne not_multiboot + je multiboot_proto + + /* Check for Multiboot2 bootloader */ + cmp $MULTIBOOT2_BOOTLOADER_MAGIC,%eax + je multiboot2_proto + + jmp not_multiboot + +multiboot_proto: + /* Get mem_lower from Multiboot information */ + testb $MBI_MEMLIMITS,(%ebx) + jz trampoline_setup /* not available? BDA value will be fine */ + + mov 4(%ebx),%edx + shl $10-4,%edx + jmp trampoline_setup +multiboot2_proto: + /* Get Multiboot2 information address */ + mov %ebx,%ecx + + /* Skip Multiboot2 information fixed part */ + add $8,%ecx + +0: + /* Get mem_lower from Multiboot2 information */ + cmpl $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx) + jne 1f + + mov 8(%ecx),%edx + shl $10-4,%edx + jmp trampoline_setup + +1: + /* Is it the end of Multiboot2 information? */ + cmpl $MULTIBOOT2_TAG_TYPE_END,(%ecx) + je trampoline_setup + + /* Go to next Multiboot2 information tag */ + add 4(%ecx),%ecx + add $(MULTIBOOT2_TAG_ALIGN-1),%ecx + and $~(MULTIBOOT2_TAG_ALIGN-1),%ecx + jmp 0b + +trampoline_setup: /* Set up trampoline segment 64k below EBDA */ movzwl 0x40e,%ecx /* EBDA segment */ cmp $0xa000,%ecx /* sanity check (high) */
xen/arch/x86/boot/head.S __start: · line 211
Quoted 8 lines
xen/arch/x86/boot/head.S +1
-4@@ -99,12 +208,8 @@ __start: * Compare the value in the BDA with the information from the * multiboot structure (if available) and use the smallest. */ - testb $MBI_MEMLIMITS,(%ebx) - jz 2f /* not available? BDA value will be fine */ - mov 4(%ebx),%edx - cmp $0x100,%edx /* is the multiboot value too small? */ + cmp $0x4000,%edx /* is the multiboot value too small? */
You are going to need some justification for changing this lower bound of memory.
xen/include/xen/multiboot2.h
Quoted 135 lines
xen/arch/x86/boot/head.S +0
-1jb 2f /* if so, do not use it */ - shl $10-4,%edx cmp %ecx,%edx /* compare with BDA value */ cmovb %edx,%ecx /* and use the smaller */xen/arch/x86/boot/reloc.c +102
-1@@ -19,9 +19,13 @@ typedef unsigned long long u64;#include "../../../include/xen/compiler.h" #include "../../../include/xen/multiboot.h" +#include "../../../include/xen/multiboot2.h" #include "../../../include/asm/mbd.h" +#define ALIGN_UP (addr, align) \ + (((addr) + (typeof(addr))(align) - 1) & ~((typeof(addr))(align) - 1)) +/* * __HERE__ IS ENTRY POINT!!! * @@ -143,6 +147,100 @@ static mbd_t *mb_mbd(mbd_t *mbd, multiboot_info_t *mbi)return mbd; } +static mbd_t *mb2_mbd (mbd_t *mbd,void *mbi) +{ +boot_module_t *mbd_mods; +memory_map_t *mmap_dst; +multiboot2_memory_map_t *mmap_src; +multiboot2_tag_t *tag; +u32 ptr; +unsigned int i, mod_idx =0 ; + +/* Skip Multiboot2 information fixed part. */ + tag = mbi +sizeof (u32) *2 ; + +for ( ; ; ) + { +if ( tag->type ==MULTIBOOT2_TAG_TYPE_MODULE ) + ++mbd->mods_nr; +else if ( tag->type ==MULTIBOOT2_TAG_TYPE_END ) + { + mbd->mods =alloc_struct (mbd->mods_nr *sizeof (boot_module_t)); + mbd_mods = (boot_module_t *)mbd->mods; +break ; + } + +/* Go to next Multiboot2 information tag. */ + tag = (multiboot2_tag_t *)(ALIGN_UP ((u32 )tag + tag->size,MULTIBOOT2_TAG_ALIGN )); + } + +/* Skip Multiboot2 information fixed part. */ + tag = mbi +sizeof (u32) *2 ; + +for ( ; ; ) + { +switch ( tag->type ) + { +case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME : + ptr = (u32)((multiboot2_tag_string_t *)tag)->string; + mbd->boot_loader_name =copy_string (ptr); +break ; + +case MULTIBOOT2_TAG_TYPE_CMDLINE : + ptr = (u32)((multiboot2_tag_string_t *)tag)->string; + mbd->cmdline =copy_string (ptr); +break ; + +case MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO : + mbd->mem_lower = ((multiboot2_tag_basic_meminfo_t *)tag)->mem_lower; + mbd->mem_upper = ((multiboot2_tag_basic_meminfo_t *)tag)->mem_upper; +break ; + +case MULTIBOOT2_TAG_TYPE_MMAP : + mbd->mmap_size = ((multiboot2_tag_mmap_t *)tag)->size; + mbd->mmap_size -=sizeof (multiboot2_tag_mmap_t); + mbd->mmap_size +=sizeof (((multiboot2_tag_mmap_t ){0 }).entries); + mbd->mmap_size /= ((multiboot2_tag_mmap_t *)tag)->entry_size; + mbd->mmap_size *=sizeof (memory_map_t); + + mbd->mmap =alloc_struct (mbd->mmap_size); + + mmap_src = ((multiboot2_tag_mmap_t *)tag)->entries; + mmap_dst = (memory_map_t *)mbd->mmap; + +for ( i =0 ; i < mbd->mmap_size /sizeof (memory_map_t); ++i ) + { + mmap_dst[i].size =sizeof (memory_map_t); + mmap_dst[i].size -=sizeof (((memory_map_t ){0 }).size); + mmap_dst[i].base_addr_low = (u32 )mmap_src[i].addr; + mmap_dst[i].base_addr_high = (u32)(mmap_src[i].addr >>32 ); + mmap_dst[i].length_low = (u32 )mmap_src[i].len; + mmap_dst[i].length_high = (u32)(mmap_src[i].len >>32 ); + mmap_dst[i].type = mmap_src[i].type; + } +break ; + +case MULTIBOOT2_TAG_TYPE_MODULE : + mbd_mods[mod_idx].start = (u32)((multiboot2_tag_module_t *)tag)->mod_start; + mbd_mods[mod_idx].end = (u32)((multiboot2_tag_module_t *)tag)->mod_end; + ptr = (u32)((multiboot2_tag_module_t *)tag)->cmdline; + mbd_mods[mod_idx].cmdline =copy_string (ptr); + mbd_mods[mod_idx].relocated =0 ; + ++mod_idx; +break ; + +case MULTIBOOT2_TAG_TYPE_END : +return mbd; + +default : +break ; + } + +/* Go to next Multiboot2 information tag. */ + tag = (multiboot2_tag_t *)(ALIGN_UP ((u32 )tag + tag->size,MULTIBOOT2_TAG_ALIGN )); + } +} +static mbd_t __used *__reloc (void *mbi,u32 mb_magic) {mbd_t *mbd;@@ -150,5 +248,8 @@ static mbd_t __used *__reloc(void *mbi, u32 mb_magic) mbd = (mbd_t *)alloc_struct (sizeof (mbd_t));zero_struct ((u32 )mbd,sizeof (mbd_t)); -return mb_mbd (mbd, mbi); +if ( mb_magic ==MULTIBOOT_BOOTLOADER_MAGIC ) +return mb_mbd (mbd, mbi); +else +return mb2_mbd (mbd, mbi); }xen/include/xen/multiboot2.h +0
-0
This multiboot2.h is huge - can we get away with only including struct definitions for tags we currently use/support?
~Andrew
Quoted 359 lines
new file mode 100644
index 0000000..47ca08exen/include/xen/multiboot2.h new file +354
-0@@ -0,0 +1,354 @@ +/* +* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. +* +* multiboot2.h - Multiboot 2 header file. +* +* Based on grub-2.00/include/multiboot2.h file. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY +* DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __MULTIBOOT2_H__ +#define __MULTIBOOT2_H__ + +/* The magic field should contain this. */ +#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 + +/* This should be in %eax on x86 architecture. */ +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 + +/* How many bytes from the start of the file we search for the header. */ +#define MULTIBOOT2_SEARCH 32768 + +/* Multiboot 2 header alignment. */ +#define MULTIBOOT2_HEADER_ALIGN 8 + +/* Alignment of multiboot 2 modules. */ +#define MULTIBOOT2_MOD_ALIGN 0x00001000 + +/* Alignment of the multiboot 2 info structure. */ +#define MULTIBOOT2_INFO_ALIGN 0x00000008 + +/* Multiboot 2 architectures. */ +#define MULTIBOOT2_ARCHITECTURE_I386 0 +#define MULTIBOOT2_ARCHITECTURE_MIPS32 4 + +/* Header tag types. */ +#define MULTIBOOT2_HEADER_TAG_END 0 +#define MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST 1 +#define MULTIBOOT2_HEADER_TAG_ADDRESS 2 +#define MULTIBOOT2_HEADER_TAG_ENTRY_ADDRESS 3 +#define MULTIBOOT2_HEADER_TAG_CONSOLE_FLAGS 4 +#define MULTIBOOT2_HEADER_TAG_FRAMEBUFFER 5 +#define MULTIBOOT2_HEADER_TAG_MODULE_ALIGN 6 +#define MULTIBOOT2_HEADER_TAG_EFI_BS 7 + +/* Header tag flags. */ +#define MULTIBOOT2_HEADER_TAG_REQUIRED 0 +#define MULTIBOOT2_HEADER_TAG_OPTIONAL 1 + +/* Header console tag console_flags. */ +#define MULTIBOOT2_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 +#define MULTIBOOT2_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 + +/* Flags set in the 'flags' member of the multiboot header. */ +#define MULTIBOOT2_TAG_TYPE_END 0 +#define MULTIBOOT2_TAG_TYPE_CMDLINE 1 +#define MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME 2 +#define MULTIBOOT2_TAG_TYPE_MODULE 3 +#define MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO 4 +#define MULTIBOOT2_TAG_TYPE_BOOTDEV 5 +#define MULTIBOOT2_TAG_TYPE_MMAP 6 +#define MULTIBOOT2_TAG_TYPE_VBE 7 +#define MULTIBOOT2_TAG_TYPE_FRAMEBUFFER 8 +#define MULTIBOOT2_TAG_TYPE_ELF_SECTIONS 9 +#define MULTIBOOT2_TAG_TYPE_APM 10 +#define MULTIBOOT2_TAG_TYPE_EFI32 11 +#define MULTIBOOT2_TAG_TYPE_EFI64 12 +#define MULTIBOOT2_TAG_TYPE_SMBIOS 13 +#define MULTIBOOT2_TAG_TYPE_ACPI_OLD 14 +#define MULTIBOOT2_TAG_TYPE_ACPI_NEW 15 +#define MULTIBOOT2_TAG_TYPE_NETWORK 16 +#define MULTIBOOT2_TAG_TYPE_EFI_MMAP 17 +#define MULTIBOOT2_TAG_TYPE_EFI_BS 18 + +/* Multiboot 2 tag alignment. */ +#define MULTIBOOT2_TAG_ALIGN 8 + +/* Memory types. */ +#define MULTIBOOT2_MEMORY_AVAILABLE 1 +#define MULTIBOOT2_MEMORY_RESERVED 2 +#define MULTIBOOT2_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT2_MEMORY_NVS 4 +#define MULTIBOOT2_MEMORY_BADRAM 5 + +/* Framebuffer types. */ +#define MULTIBOOT2_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT2_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT2_FRAMEBUFFER_TYPE_EGA_TEXT 2 + +#ifndef __ASSEMBLY__ +typedef struct { +/* Must be MULTIBOOT2_MAGIC - see above. */ +u32 magic; + +/* ISA */ +u32 architecture; + +/* Total header length. */ +u32 header_length; + +/* The above fields plus this one must equal 0 mod 2^32. */ +u32 checksum; +}multiboot2_header_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +}multiboot2_header_tag_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +u32 requests[0 ]; +}multiboot2_header_tag_information_request_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +u32 header_addr; +u32 load_addr; +u32 load_end_addr; +u32 bss_end_addr; +}multiboot2_header_tag_address_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +u32 entry_addr; +}multiboot2_header_tag_entry_address_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +u32 console_flags; +}multiboot2_header_tag_console_flags_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +u32 width; +u32 height; +u32 depth; +}multiboot2_header_tag_framebuffer_t ; + +typedef struct { +u16 type; +u16 flags; +u32 size; +u32 width; +u32 height; +u32 depth; +}multiboot2_header_tag_module_align_t ; + +typedef struct { +u8 red; +u8 green; +u8 blue; +}multiboot2_color_t ; + +typedef struct __packed { +u64 addr; +u64 len; +u32 type; +u32 zero; +}multiboot2_memory_map_t ; + +typedef struct { +u32 type; +u32 size; +}multiboot2_tag_t ; + +typedef struct { +u32 type; +u32 size; +char string[0 ]; +}multiboot2_tag_string_t ; + +typedef struct { +u32 type; +u32 size; +u32 mod_start; +u32 mod_end; +char cmdline[0 ]; +}multiboot2_tag_module_t ; + +typedef struct { +u32 type; +u32 size; +u32 mem_lower; +u32 mem_upper; +}multiboot2_tag_basic_meminfo_t ; + +typedef struct { +u32 type; +u32 size; +u32 biosdev; +u32 slice; +u32 part; +}multiboot2_tag_bootdev_t ; + +typedef struct { +u32 type; +u32 size; +u32 entry_size; +u32 entry_version; +multiboot2_memory_map_t entries[0 ]; +}multiboot2_tag_mmap_t ; + +typedef struct { +u8 external_specification[512 ]; +}multiboot2_vbe_info_block_t ; + +typedef struct { +u8 external_specification[256 ]; +}multiboot2_vbe_mode_info_block_t ; + +typedef struct { +u32 type; +u32 size; + +u16 vbe_mode; +u16 vbe_interface_seg; +u16 vbe_interface_off; +u16 vbe_interface_len; + +multiboot2_vbe_info_block_t vbe_control_info; +multiboot2_vbe_mode_info_block_t vbe_mode_info; +}multiboot2_tag_vbe_t ; + +typedef struct { +u32 type; +u32 size; + +u64 framebuffer_addr; +u32 framebuffer_pitch; +u32 framebuffer_width; +u32 framebuffer_height; +u8 framebuffer_bpp; +u8 framebuffer_type; +u16 reserved; +}multiboot2_tag_framebuffer_common_t ; + +typedef struct { +multiboot2_tag_framebuffer_common_t common; + +union { +struct { +u16 framebuffer_palette_num_colors; +multiboot2_color_t framebuffer_palette[0 ]; + }; +struct { +u8 framebuffer_red_field_position; +u8 framebuffer_red_mask_size; +u8 framebuffer_green_field_position; +u8 framebuffer_green_mask_size; +u8 framebuffer_blue_field_position; +u8 framebuffer_blue_mask_size; + }; + }; +}multiboot2_tag_framebuffer_t ; + +typedef struct { +u32 type; +u32 size; +u32 num; +u32 entsize; +u32 shndx; +char sections[0 ]; +}multiboot2_tag_elf_sections_t ; + +typedef struct { +u32 type; +u32 size; +u16 version; +u16 cseg; +u32 offset; +u16 cseg_16; +u16 dseg; +u16 flags; +u16 cseg_len; +u16 cseg_16_len; +u16 dseg_len; +}multiboot2_tag_apm_t ; + +typedef struct { +u32 type; +u32 size; +u32 pointer; +}multiboot2_tag_efi32_t ; + +typedef struct { +u32 type; +u32 size; +u64 pointer; +}multiboot2_tag_efi64_t ; + +typedef struct { +u32 type; +u32 size; +u8 major; +u8 minor; +u8 reserved[6 ]; +u8 tables[0 ]; +}multiboot2_tag_smbios_t ; + +typedef struct { +u32 type; +u32 size; +u8 rsdp[0 ]; +}multiboot2_tag_old_acpi_t ; + +typedef struct { +u32 type; +u32 size; +u8 rsdp[0 ]; +}multiboot2_tag_new_acpi_t ; + +typedef struct { +u32 type; +u32 size; +u8 dhcpack[0 ]; +}multiboot2_tag_network_t ; + +typedef struct { +u32 type; +u32 size; +u32 descr_size; +u32 descr_vers; +u8 efi_mmap[0 ]; +}multiboot2_tag_efi_mmap_t ; +#endif /* __ASSEMBLY__ */ + +#endif /* __MULTIBOOT2_H__ */
Quoted 45 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 19:48, <[email protected]> wrote:
Quoted 21 lines · Daniel Kiper
Hi,
This patch series breaks multiboot (v1) protocol dependency and adds multiboot2 support. It lays down the foundation for EFI + GRUB2 + Xen development. Detailed description of ideas and thoughts you will find in commit message for every patch. If something is not obvious please drop me a line.
Most of the requested things are fixed but there are still some minor outstanding issues (multiboot2 tags generation, excessive amount of casts in
xen/arch/x86/boot/reloc.c, etc.; please check commit messages for more details). If something is not fixed yet it means that I do not have good idea how to do that. In case you spot something which was mentioned during previous review and still think that your comment is valid in particular case please notify me.Below you can find reply for Konrad's questions in regards to exception request for Xen 4.5 release.
Quoted 2 lines
Couple of questions:
Quoted 7 lines
Quoted 3 lines
- Since this is mostly XBI code, is there a lot of overlap with the ARM/x86 refactoring of the EFI code? As in, will it require a lot of rebasing/fixing it up?
I did not checked that right now. However, Roy once told me that this should not be very big issue because overlap is not so big. Please check this email for more details:
http://lists.xen.org/archives/html/xen-devel/2014-08/msg01173.html
Quoted 3 lines
Sadly, it was sent more then one month ago so maybe something has changed. Roy, any comments on that?
There aren't fundamental conceptual conflicts, but there will be quite a bit of refactoring/rebasing to do. Most of my patchset is re-organizing
x86/efi/boot.c, so rebasing it on this patchset would be a significant
amount of work. My guess is that the first 10 of the 13 patches
in my series would need be be completely redone, as the code they are rearranging has been changed by your series.
I think that it would be much less work for you to re-base your series on mine, than the other way. Thex86/efi/boot.cchanges are a relatively small part of your series, but are the bulk of mine.
Quoted 1 line
I should have another version of my patchset out today.
And when looking at both series later today in detail, I'm certainly going to give priority to Roy's as I expect that one to be largely ready to go in now (or at least a sufficiently large initial part of it).
Jan
Re: [PATCH v2 1/5] xen/x86: Introduce MultiBoot Data (MBD) type
In reply to Andrew CooperQuoted 35 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 20:40, <[email protected]> wrote:
Quoted 16 lines · Daniel Kiper
Introduce MultiBoot Data (MBD) type. It is used to define variable which carry over data from multiboot protocol (any version) through Xen preloader stage. Later all or parts of this data is used to initialize
boot_infostructure.boot_infois introduced in later patches.MBD helps to break multiboot (v1) protocol dependency. Using it we are able to save space on trampoline (we do not allocate space for unused data what happens in current preloader implementation). Additionally, we are able to easily add new members to MBD if we want support for new features or protocols.
There is not plan to share MBD among architectures. It will be nice if
boot_infowill be shared among architectures. Please check later patches for more details.Quoted 6 lines
Code found in
xen/arch/x86/boot_info.cmoves MBD data to mbi struct which is referenced from main Xen code. This is temporary solution which helps to split patches into logical parts. Later it will be replaced by final version ofboot_infosupport.Signed-off-by Daniel Kiper <[email protected]>Reviewing changes to ASM code is *very* hard, and this patch is still very complicated.
Can I suggest patches split along the following lines.
* Shuffling of registers in
head.Sto end up with %eax and %ecx as indended forreloc.c, and %ebx currently unclobbered, and adjustingreloc.cfor %ecx. Review for this is a simple case of verifying that the changes are just a strict shuffling of registers.
Quoted 5 lines
* Whitespace and misc non-MBD cleanup to
reloc.c* Altering existing helper functions in preparation for MBD support
* Actually introduce
mbd_tand use it.
+1
Quoted 21 lines
Quoted 21 lines
xen/arch/x86/boot/reloc.c +6
-4@@ -1,40 +1,58 @@ -/****************************************************************************** +/* * reloc.c -* +* * 32-bit flat memory-map routines for relocating Multiboot structures * and modules. This is most easily done early with paging disabled. -* +* * Copyright (c) 2009, Citrix Systems, Inc. -* +* Copyright (c) 2013, 2014 Oracle Co., Daniel Kiper +* * Authors: * Keir Fraser <[email protected]> +* Daniel Kiper */
Quoted 13 lines
xen/arch/x86/boot/reloc.c line 23
Quoted 10 lines
xen/arch/x86/boot/reloc.c +9
-1-/* entered with %eax = BOOT_TRAMPOLINE */ +typedef unsigned char u8 ; +typedef unsigned short u16 ; +typedef unsigned long u32 ; +typedef unsigned long long u64 ; + +#include "../../../include/xen/compiler.h" +#include "../../../include/xen/multiboot.h" + +#include "../../../include/asm/mbd.h" How about playing with -I for this file in the
Makefileto allow #include <xen/compiler.h> and so ?
Including these here is bogus anyway, even if for the ones above it's perhaps acceptable. But expressing it to be bogus via the ../../../ prefix is quite desirable imo.
Quoted 6 lines
xen/arch/x86/boot/reloc.c line 26
Quoted 3 lines
xen/arch/x86/boot/reloc.c +3
-0+ +/* +* __HERE__ IS ENTRY POINT!!! I am still of the firm opinion that anyone capable of editing this file ought to know understand the
_startsymbol, making this comment useless.
Indeed.
Quoted 7 lines
Quoted 7 lines
xen/arch/x86/boot/reloc.c +7
-0+/* +* MultiBoot Data (MBD) type. It is used to define variable which +* carry over data from multiboot protocol (any version) through +* Xen preloader stage. Later all or parts of this data is used +* to initialize boot_info structure. +*/ +typedef struct {
Quoted 8 lines
xen/arch/x86/boot/reloc.c line 38
Quoted 5 lines
xen/arch/x86/boot/reloc.c +5
-0+/* Pointer to boot loader name. */ +u32 boot_loader_name; + +/* Pointer to Xen command line. */ +u32 cmdline;These need to be very clear about being physical addresses rather than pointers.
Isn't their type being u32 and their placement in this structure sufficient indication thereof?
Jan
Re: [PATCH v2 3/5] xen/x86: Migrate to boot_info structure
In reply to Daniel KiperQuoted 17 lines · Daniel Kiper
Break multiboot (v1) protocol dependency. It means that most of Xen code (excluding preloader) could be bootloader agnostic and does not need almost any knowledge about boot protocol. Additionally, we are able to pass all boot data to
__start_xen()in one bucket without any side channels. I do not mention that we are also able to easily identify boot data in Xen code.Here is boot data flow for legacy BIOS platform:
BIOS -> GRUB -> multiboot[12]* -> __reloc() -> MBD ->-\ / ------<------<------<------<------<------<----- \ \ ---> __init_boot_info() -> boot_info_mb -> __start_xen() -> boot_info /BIOS ->-/
Quoted 7 lines
* multiboot2 is not implemented yet. Look for it in later patches.
Here is boot data flow for EFI platform:
EFI ->
efi_start()->boot_info_efi->__start_xen()->boot_infoWARNING: ARM build could be broken by this patch.
The hypervisor is easy to cross compile, so please confirm and if so fix it.
I use the cross compilers from
https://launchpad.net/linaro-toolchain-binaries
See
http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions#Cross_Compiling for more info.
Quoted 9 lines
We need to agree
boot_info
integration into ARM. Personally I think that it is worth storing all data from any bootloader and preloader inboot_infoon any architecture. This give a chance to share more code between architectures. However, every architecture should define its ownboot_info(in relevantinclude/asmdirectory). Despite that it looks that some parts of it could be common, e.g. modules data, command line arguments, boot loader name, EFI data, etc., even if types would not be the same. So, as it was stated above a lot of code could be shared among architectures.
As I think I've said before I'm happy to consider this in the future but not for 4.5 at this stage. Please ensure that ARM at least still compiles after this change.
Ian.
Quoted 5 lines · Jan Beulich
Quoted 1 line
I should have another version of my patchset out today.
And when looking at both series later today in detail, I'm certainly going to give priority to Roy's as I expect that one to be largely ready to go in now (or at least a sufficiently large initial part of it).
Per http://lists.xen.org/archives/html/xen-devel/2014-09/msg03874.html
which I just sent I'm not in favour of trying to move ARM over to this new scheme for 4.5 anyway.
Ian.
Re: [PATCH v2 3/5] xen/x86: Migrate to boot_info structure
In reply to Ian CampbellQuoted 26 lines · Ian Campbell
Quoted 17 lines · Daniel Kiper
Break multiboot (v1) protocol dependency. It means that most of Xen code (excluding preloader) could be bootloader agnostic and does not need almost any knowledge about boot protocol. Additionally, we are able to pass all boot data to
__start_xen()in one bucket without any side channels. I do not mention that we are also able to easily identify boot data in Xen code.Here is boot data flow for legacy BIOS platform:
BIOS -> GRUB -> multiboot[12]* -> __reloc() -> MBD ->-\ / ------<------<------<------<------<------<----- \ \ ---> __init_boot_info() -> boot_info_mb -> __start_xen() -> boot_info /BIOS ->-/
Quoted 7 lines
* multiboot2 is not implemented yet. Look for it in later patches.
Here is boot data flow for EFI platform:
EFI ->
efi_start()->boot_info_efi->__start_xen()->boot_infoWARNING: ARM build could be broken by this patch.
Quoted 8 lines
The hypervisor is easy to cross compile, so please confirm and if so fix it.
I use the cross compilers from
https://launchpad.net/linaro-toolchain-binariesSee
http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions#Cross_Compiling for more info.
Thanks, wilco.
Quoted 11 lines
Quoted 9 lines
We need to agree
boot_info
integration into ARM. Personally I think that it is worth storing all data from any bootloader and preloader inboot_infoon any architecture. This give a chance to share more code between architectures. However, every architecture should define its ownboot_info(in relevantinclude/asmdirectory). Despite that it looks that some parts of it could be common, e.g. modules data, command line arguments, boot loader name, EFI data, etc., even if types would not be the same. So, as it was stated above a lot of code could be shared among architectures.As I think I've said before I'm happy to consider this in the future but
Great!
Quoted 1 line
not for 4.5 at this stage. Please ensure that ARM at least still
Roger.
Quoted 1 line
compiles after this change.
Ditto.
Daniel
Re: [PATCH v2 1/5] xen/x86: Introduce MultiBoot Data (MBD) type
In reply to Jan BeulichQuoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 20:40, <[email protected]> wrote:
On 24/09/14 18:19, Daniel Kiper wrote:
[...]
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
xen/arch/x86/boot/reloc.c +4
-0+typedef unsigned char u8 ; +typedef unsigned short u16 ; +typedef unsigned long u32 ; +typedef unsigned long long u64 ;Quoted 8 lines
xen/arch/x86/boot/reloc.c line 23
Quoted 5 lines
xen/arch/x86/boot/reloc.c +5
-0+ +#include "../../../include/xen/compiler.h" +#include "../../../include/xen/multiboot.h" + +#include "../../../include/asm/mbd.h" How about playing with -I for this file in the
Makefileto allow #include <xen/compiler.h> and so ?
Quoted 1 line
Including these here is bogus anyway, even if for the ones above it's
Hmmm... Why it is bogus?
Quoted 2 lines
perhaps acceptable. But expressing it to be bogus via the ../../../ prefix is quite desirable imo.
I have been thinking about that since I saw this first time. Why we could not use -I gcc option here? Could you enlighten me?
Quoted 8 lines
Quoted 6 lines
xen/arch/x86/boot/reloc.c line 26
Quoted 3 lines
xen/arch/x86/boot/reloc.c +3
-0+ +/* +* __HERE__ IS ENTRY POINT!!! I am still of the firm opinion that anyone capable of editing this file ought to know understand the
_startsymbol, making this comment useless.Indeed.
We know this right now. However, I spent some time to discover this at the beginning of this work. This file is full of magic so I think that this comment helps a bit to understand what is going on. So, please do me a favor and let's leave it here. If you wish I can use lowercase and remove underscore. Additionally, I removed similar comment for __reloc() (as you requested) which does not make sense if it is prefixed with static.
Daniel
Quoted 45 lines · Jan Beulich
Quoted 45 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 19:48, <[email protected]> wrote:
Quoted 21 lines · Daniel Kiper
Hi,
This patch series breaks multiboot (v1) protocol dependency and adds multiboot2 support. It lays down the foundation for EFI + GRUB2 + Xen development. Detailed description of ideas and thoughts you will find in commit message for every patch. If something is not obvious please drop me a line.
Most of the requested things are fixed but there are still some minor outstanding issues (multiboot2 tags generation, excessive amount of casts in
xen/arch/x86/boot/reloc.c, etc.; please check commit messages for more details). If something is not fixed yet it means that I do not have good idea how to do that. In case you spot something which was mentioned during previous review and still think that your comment is valid in particular case please notify me.Below you can find reply for Konrad's questions in regards to exception request for Xen 4.5 release.
Quoted 2 lines
Couple of questions:
Quoted 7 lines
Quoted 3 lines
- Since this is mostly XBI code, is there a lot of overlap with the ARM/x86 refactoring of the EFI code? As in, will it require a lot of rebasing/fixing it up?
I did not checked that right now. However, Roy once told me that this should not be very big issue because overlap is not so big. Please check this email for more details:
http://lists.xen.org/archives/html/xen-devel/2014-08/msg01173.html
Quoted 3 lines
Sadly, it was sent more then one month ago so maybe something has changed. Roy, any comments on that?
There aren't fundamental conceptual conflicts, but there will be quite a bit of refactoring/rebasing to do. Most of my patchset is re-organizing
x86/efi/boot.c, so rebasing it on this patchset would be a significant
amount of work. My guess is that the first 10 of the 13 patches
in my series would need be be completely redone, as the code they are rearranging has been changed by your series.
I think that it would be much less work for you to re-base your series on mine, than the other way. Thex86/efi/boot.cchanges are a relatively small part of your series, but are the bulk of mine.
Quoted 5 lines
Quoted 1 line
I should have another version of my patchset out today.
And when looking at both series later today in detail, I'm certainly going to give priority to Roy's as I expect that one to be largely ready to go in now (or at least a sufficiently large initial part of it).
OK. Roy, do you expect any bigger changes in your code right now? May I rebase safely my work on latest release of your patches? Should I care about anything in special way?
Daniel
Re: [PATCH v2 1/5] xen/x86: Introduce MultiBoot Data (MBD) type
In reply to Daniel KiperQuoted 17 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 14:56, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 20:40, <[email protected]> wrote:
xen/arch/x86/boot/reloc.c line 23
Quoted 9 lines · Daniel Kiper
xen/arch/x86/boot/reloc.c +9
-0+typedef unsigned char u8 ; +typedef unsigned short u16 ; +typedef unsigned long u32 ; +typedef unsigned long long u64 ; + +#include "../../../include/xen/compiler.h" +#include "../../../include/xen/multiboot.h" + +#include "../../../include/asm/mbd.h" How about playing with -I for this file in the
Makefileto allow #include <xen/compiler.h> and so ?
Quoted 3 lines
Quoted 1 line
Including these here is bogus anyway, even if for the ones above it's
Hmmm... Why it is bogus?
Because the headers aren't intended for the environment this code runs in.
Quoted 5 lines
Quoted 2 lines
perhaps acceptable. But expressing it to be bogus via the ../../../ prefix is quite desirable imo.
I have been thinking about that since I saw this first time. Why we could not use -I gcc option here? Could you enlighten me?
For aforementioned reason: Once we make it easy and seamless to include further headers, the risk of depending on something this code shouldn't depend on grows.
Apart from that you also need to deal with dependency tracking if you include new headers here - please see the Makefile for how this needs to be done (and which really should have got dropped by 46fce9fd2b3 ["x86: get rid of BOOT_TRAMPOLINE"]). And yes, the existing inclusion of multiboot.h is lacking dependency tracking too (but as usual this is no excuse to continue with this bad practice).
Which points at another issue making it (right now at least) desirable to don't make it a nobrainer to include further ones: Non-leaf ones would likely cause missed dependencies as long as they need to be tracked manually.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
xen/arch/x86/boot/reloc.c line 26
Quoted 3 lines
xen/arch/x86/boot/reloc.c +3
-0+ +/* +* __HERE__ IS ENTRY POINT!!! I am still of the firm opinion that anyone capable of editing this file ought to know understand the
_startsymbol, making this comment useless.
Quoted 7 lines
Quoted 1 line
Indeed.
We know this right now. However, I spent some time to discover this at the beginning of this work. This file is full of magic so I think that this comment helps a bit to understand what is going on. So, please do me a favor and let's leave it here. If you wish I can use lowercase and remove underscore.
And remove the three exclamation marks and fix the grammar. All in all - much preferred - just drop the comment.
Quoted 3 lines
Additionally, I removed similar comment for
__reloc()(as you requested) which does not make sense if it is prefixed with static.
Making a function referenced from inline assembly only static is likely wrong anyway. No idea though why removing a similar comment there would be an issue.
Jan
Quoted 52 lines · Daniel Kiper
Quoted 45 lines · Jan Beulich
Quoted 45 lines
Quoted 1 line
Quoted 1 line · On 24.09.14 at 19:48, <[email protected]> wrote:
Quoted 21 lines · Daniel Kiper
Hi,
This patch series breaks multiboot (v1) protocol dependency and adds multiboot2 support. It lays down the foundation for EFI + GRUB2 + Xen development. Detailed description of ideas and thoughts you will find in commit message for every patch. If something is not obvious please drop me a line.
Most of the requested things are fixed but there are still some minor outstanding issues (multiboot2 tags generation, excessive amount of casts in
xen/arch/x86/boot/reloc.c, etc.; please check commit messages for more details). If something is not fixed yet it means that I do not have good idea how to do that. In case you spot something which was mentioned during previous review and still think that your comment is valid in particular case please notify me.Below you can find reply for Konrad's questions in regards to exception request for Xen 4.5 release.
Quoted 2 lines
Couple of questions:
Quoted 7 lines
Quoted 3 lines
- Since this is mostly XBI code, is there a lot of overlap with the ARM/x86 refactoring of the EFI code? As in, will it require a lot of rebasing/fixing it up?
I did not checked that right now. However, Roy once told me that this should not be very big issue because overlap is not so big. Please check this email for more details:
http://lists.xen.org/archives/html/xen-devel/2014-08/msg01173.html
Quoted 3 lines
Sadly, it was sent more then one month ago so maybe something has changed. Roy, any comments on that?
There aren't fundamental conceptual conflicts, but there will be quite a bit of refactoring/rebasing to do. Most of my patchset is re-organizing
x86/efi/boot.c, so rebasing it on this patchset would be a significant
amount of work. My guess is that the first 10 of the 13 patches
in my series would need be be completely redone, as the code they are rearranging has been changed by your series.
I think that it would be much less work for you to re-base your series on mine, than the other way. Thex86/efi/boot.cchanges are a relatively small part of your series, but are the bulk of mine.Quoted 5 lines
Quoted 1 line
I should have another version of my patchset out today.
And when looking at both series later today in detail, I'm certainly going to give priority to Roy's as I expect that one to be largely ready to go in now (or at least a sufficiently large initial part of it).
Quoted 5 lines
OK. Roy, do you expect any bigger changes in your code right now? May I rebase safely my work on latest release of your patches? Should I care about anything in special way?
Daniel
I don't think there should be any more major changes, but I'm still working through a few
last issues which may result in some code movement. A lot of my patches are re-organizingboot.c, so even small changes can be a pain for patches based on that. I'm hoping to be able
to resolve the last few issues in the next few days to get the patches merged for 4.5, so if you
hold of for a few days you can hopefully take my changes from the master branch.
Roy
Re: [PATCH v2 5/5] xen/x86: Add multiboot2 protocol support
In reply to Andrew CooperQuoted 9 lines · Andrew Cooper
Quoted 4 lines · Daniel Kiper
Add multiboot2 protocol support. This way we are laying the foundation for EFI + GRUB2 + Xen development.
Signed-off-by Daniel Kiper <[email protected]>Much clearer than before.
Can I suggest retroactively renaming the old multiboot bits to
Do you mean before or after this (rewritten) patch?
Quoted 2 lines
multiboot1 to make a more marked difference between between "
multiboot1_proto" and "multiboot2_proto" ?
Do you think about labels in this file only or about all stuff related to multiboot(1) protocol?
Quoted 32 lines
It would also be better to split the changing of multiboot1 and shuffling of memory calculations away from the introduction of multiboot2.
Quoted 29 lines
---
v2 - suggestions/fixes:
- use "for" instead of "while" for loops
(suggested by Jan Beulich),
- properly parenthesize macro argumentschar
*boot_loader_name;
(suggested by Jan Beulich),
- change some local variables types (suggested by Jan Beulich),
- use meaningful labels
(suggested by Andrew Cooper and Jan Beulich),
- use local labels
(suggested by Jan Beulich),
- fix coding style
(suggested by Jan Beulich),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).--- xen/arch/x86/boot/head.S | 117 +++++++++++++- xen/arch/x86/boot/reloc.c | 103 +++++++++++- xen/include/xen/multiboot2.h | 354 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 567 insertions(+), 7 deletions(-) create mode 100644 xen/include/xen/multiboot2.hxen/arch/x86/boot/head.S +0
-0
[...]
Quoted 10 lines
xen/arch/x86/boot/head.S __start: · line 149
Quoted 7 lines
xen/arch/x86/boot/head.S +3
-0@@ -81,10 +144,56 @@ __start: mov %ecx,%es mov %ecx,%ss + /* Assume multiboot[12].mem_lower is 0 if not set by bootloader */ + xor %edx,%edx +This change does not match its comment, and seems to have appeared from nowhere.
I still do not understand what is wrong with that. We need to set %edx to known value here (0 in this case). If MBI_MEMLIMITS or MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO is not set by bootloader and we do not initialize %edx then we will use uninitialized value later.
Quoted 55 lines
Quoted 55 lines
xen/arch/x86/boot/head.S +44
-1/* Check for Multiboot bootloader */ cmp $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne not_multiboot + je multiboot_proto + + /* Check for Multiboot2 bootloader */ + cmp $MULTIBOOT2_BOOTLOADER_MAGIC,%eax + je multiboot2_proto + + jmp not_multiboot + +multiboot_proto: + /* Get mem_lower from Multiboot information */ + testb $MBI_MEMLIMITS,(%ebx) + jz trampoline_setup /* not available? BDA value will be fine */ + + mov 4(%ebx),%edx + shl $10-4,%edx + jmp trampoline_setup +multiboot2_proto: + /* Get Multiboot2 information address */ + mov %ebx,%ecx + + /* Skip Multiboot2 information fixed part */ + add $8,%ecx + +0: + /* Get mem_lower from Multiboot2 information */ + cmpl $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx) + jne 1f + + mov 8(%ecx),%edx + shl $10-4,%edx + jmp trampoline_setup + +1: + /* Is it the end of Multiboot2 information? */ + cmpl $MULTIBOOT2_TAG_TYPE_END,(%ecx) + je trampoline_setup + + /* Go to next Multiboot2 information tag */ + add 4(%ecx),%ecx + add $(MULTIBOOT2_TAG_ALIGN-1),%ecx + and $~(MULTIBOOT2_TAG_ALIGN-1),%ecx + jmp 0b + +trampoline_setup: /* Set up trampoline segment 64k below EBDA */ movzwl 0x40e,%ecx /* EBDA segment */ cmp $0xa000,%ecx /* sanity check (high) */@@ -99,12 +208,8 @@ __start: * Compare the value in the BDA with the information from the * multiboot structure (if available) and use the smallest. */
Quoted 8 lines
xen/arch/x86/boot/head.S __start: · line 211
Quoted 5 lines
xen/arch/x86/boot/head.S +1
-4- testb $MBI_MEMLIMITS,(%ebx) - jz 2f /* not available? BDA value will be fine */ - mov 4(%ebx),%edx - cmp $0x100,%edx /* is the multiboot value too small? */ + cmp $0x4000,%edx /* is the multiboot value too small? */You are going to need some justification for changing this lower bound of memory.
It is not changed. I did "shl $10-4,%edx" above so I must change relevant value here too. However, it looks that it left from my earlier work and I am able to remove that change safely.
[...]
Quoted 4 lines
xen/include/xen/multiboot2.h
Quoted 1 line
xen/include/xen/multiboot2.h +0
-0This
multiboot2.his huge - can we get away with only including struct definitions for tags we currently use/support?
I did that because multiboot.h contains all multiboot(1) related stuff. I think that it is nice to have all defs for multiboot2 protocol too, however, I do not insist on that.
Daniel
Re: [PATCH v2 5/5] xen/x86: Add multiboot2 protocol support
Quoted 10 lines · Daniel Kiper
Quoted 8 lines · Andrew Cooper
Quoted 4 lines · Daniel Kiper
Add multiboot2 protocol support. This way we are laying the foundation for EFI + GRUB2 + Xen development.
Signed-off-by Daniel Kiper <[email protected]>Much clearer than before.
Can I suggest retroactively renaming the old multiboot bits to
Do you mean before or after this (rewritten) patch?
I would suggest a separate patch, if others concur that it is a sensible idea.
Quoted 5 lines
Quoted 3 lines
multiboot1 to make a more marked difference between between "
multiboot1_proto" and "multiboot2_proto" ?Do you think about labels in this file only or about all stuff related to multiboot(1) protocol?
Frankly, even changing the constant names to be MULTIBOOT1_$FOO would aid in clarity of the code.
Quoted 112 lines
Quoted 33 lines
It would also be better to split the changing of multiboot1 and shuffling of memory calculations away from the introduction of multiboot2.
Quoted 29 lines
---
v2 - suggestions/fixes:
- use "for" instead of "while" for loops
(suggested by Jan Beulich),
- properly parenthesize macro argumentschar
*boot_loader_name;
(suggested by Jan Beulich),
- change some local variables types (suggested by Jan Beulich),
- use meaningful labels
(suggested by Andrew Cooper and Jan Beulich),
- use local labels
(suggested by Jan Beulich),
- fix coding style
(suggested by Jan Beulich),
- patch split rearrangement
(suggested by Andrew Cooper and Jan Beulich).--- xen/arch/x86/boot/head.S | 117 +++++++++++++- xen/arch/x86/boot/reloc.c | 103 +++++++++++- xen/include/xen/multiboot2.h | 354 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 567 insertions(+), 7 deletions(-) create mode 100644 xen/include/xen/multiboot2.hxen/arch/x86/boot/head.S +0
-0[...]
Quoted 9 lines
xen/arch/x86/boot/head.S __start: · line 149
Quoted 7 lines
xen/arch/x86/boot/head.S +3
-0@@ -81,10 +144,56 @@ __start: mov %ecx,%es mov %ecx,%ss + /* Assume multiboot[12].mem_lower is 0 if not set by bootloader */ + xor %edx,%edx +This change does not match its comment, and seems to have appeared from nowhere.
I still do not understand what is wrong with that. We need to set %edx to known value here (0 in this case). If
MBI_MEMLIMITSorMULTIBOOT2_TAG_TYPE_BASIC_MEMINFOis not set by bootloader and we do not initialize %edx then we will use uninitialized value later.Quoted 54 lines
Quoted 54 lines
xen/arch/x86/boot/head.S +44
-1/* Check for Multiboot bootloader */ cmp $MULTIBOOT_BOOTLOADER_MAGIC,%eax - jne not_multiboot + je multiboot_proto + + /* Check for Multiboot2 bootloader */ + cmp $MULTIBOOT2_BOOTLOADER_MAGIC,%eax + je multiboot2_proto + + jmp not_multiboot + +multiboot_proto: + /* Get mem_lower from Multiboot information */ + testb $MBI_MEMLIMITS,(%ebx) + jz trampoline_setup /* not available? BDA value will be fine */ + + mov 4(%ebx),%edx + shl $10-4,%edx + jmp trampoline_setup +multiboot2_proto: + /* Get Multiboot2 information address */ + mov %ebx,%ecx + + /* Skip Multiboot2 information fixed part */ + add $8,%ecx + +0: + /* Get mem_lower from Multiboot2 information */ + cmpl $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx) + jne 1f + + mov 8(%ecx),%edx + shl $10-4,%edx + jmp trampoline_setup + +1: + /* Is it the end of Multiboot2 information? */ + cmpl $MULTIBOOT2_TAG_TYPE_END,(%ecx) + je trampoline_setup + + /* Go to next Multiboot2 information tag */ + add 4(%ecx),%ecx + add $(MULTIBOOT2_TAG_ALIGN-1),%ecx + and $~(MULTIBOOT2_TAG_ALIGN-1),%ecx + jmp 0b + +trampoline_setup: /* Set up trampoline segment 64k below EBDA */ movzwl 0x40e,%ecx /* EBDA segment */ cmp $0xa000,%ecx /* sanity check (high) */@@ -99,12 +208,8 @@ __start: * Compare the value in the BDA with the information from the * multiboot structure (if available) and use the smallest.Quoted 8 lines
xen/arch/x86/boot/head.S __start: · line 211
Quoted 6 lines
xen/arch/x86/boot/head.S +1
-4*/ - testb $MBI_MEMLIMITS,(%ebx) - jz 2f /* not available? BDA value will be fine */ - mov 4(%ebx),%edx - cmp $0x100,%edx /* is the multiboot value too small? */ + cmp $0x4000,%edx /* is the multiboot value too small? */You are going to need some justification for changing this lower bound of memory.
Quoted 2 lines
It is not changed. I did "shl $10-4,%edx" above so I must change relevant value here too.
And I saw that, given close inspection of the patch. It is however not obvious at a glance, and makes review harder.
A comment or paragraph in the commit message is perfectly fine (e.g. "Alter min memory limit handling as we now may not find it from either multiboot1 or multiboot2"). This makes it obvious to anyone reading the patch that there is a real need for the memory limit handling to change, which also covers setting a sane default of 0.
Quoted 11 lines
However, it looks that it left from my
earlier work and I am able to remove that change safely.[...]
Quoted 3 lines
xen/include/xen/multiboot2.h
Quoted 1 line
xen/include/xen/multiboot2.h +0
-0This
multiboot2.his huge - can we get away with only including struct definitions for tags we currently use/support?I did that because
multiboot.hcontains all multiboot(1) related stuff. I think that it is nice to have all defs for multiboot2 protocol too, however, I do not insist on that.
I suppose it doesn't matter either way for a header file like this.
~Andrew
Re: [PATCH v2 1/5] xen/x86: Introduce MultiBoot Data (MBD) type
In reply to Andrew CooperQuoted 1 line · Andrew Cooper
On 24/09/14 18:19, Daniel Kiper wrote:
[...]
Quoted 29 lines
Quoted 16 lines
xen/arch/x86/setup.c +0
-12@@ -556,21 +575,13 @@ void __init noreturn __start_xen(unsigned long mbi_p) .stop_bits = 1 }; -/* Critical region without IDT or TSS. Any fault is deadly! */ - -set_processor_id (0 ); -set_current ((struct vcpu *)0xfffff000 );/* debug sanity. */ - idle_vcpu[0 ] = current; - -percpu_init_areas (); - -init_idt_traps (); -load_system_tables (); - -smp_prepare_boot_cpu ();xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 584
Quoted 10 lines
xen/arch/x86/setup.c +7
-3-sort_exception_tables (); - -/* Full exception support from here on in. */ +if ( !efi_enabled ) { +/* Exception support was enabled before __start_xen() call. */ + } +else + { +enable_exception_support (); + }For this, absolutely not.
Quoted 3 lines
Pass
mbi_painto__start_xen()and have__start_xen()call__init_boot_info()after it has set up exception support. None of the contents of MBD are needed beforehand.
Ehhh... I do not like this solution too. However, I want to avoid passing mbd to __start_xen(). If we do that as you suggest then EFI case will look bad because we would not be able to pass boot_info directly to __start_xen(). boot_info is build directly in EFI case. We do not need mbd. It means that __init_boot_info() is not used on EFI platforms too. Additionally, I think that __start_xen() is firm border between preloader and Xen main code and this as is should not see any variables belonging to preloader (mbd is preloader stuff). Hence, I think that __start_xen() should take boot_info as an argument. However, I agree that we should work out better solution for exception initialization.
Quoted 51 lines
Quoted 38 lines
xen/arch/x86/setup.c +0
-0loader = (mbi->flags &MBI_LOADERNAME ) ? (char *)__va (mbi->boot_loader_name) :"unknown" ;xen/arch/x86/x86_64/asm-offsets.c +2
-3@@ -12,7 +12,7 @@#include <compat/xen.h> #include <asm/fixmap.h> #include <asm/hardirq.h> -#include <xen/multiboot.h> +#include <asm/mbd.h> #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \@@ -163,6 +163,5 @@ void __dummy__(void) OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);BLANK (); -OFFSET (MB_flags, multiboot_info_t, flags); -OFFSET (MB_cmdline, multiboot_info_t, cmdline); +OFFSET (MBD_cmdline, mbd_t, cmdline); }xen/include/asm-x86/mbd.h new file +9
-0@@ -0,0 +1,70 @@ +/* +* Copyright (c) 2013, 2014 Oracle Co., Daniel Kiper +* +* This program 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 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, xen/include/asm-x86/mbd.h line 19
Quoted 10 lines
xen/include/asm-x86/mbd.h new file +10
-0+* 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 this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MBD_H__ +#define __MBD_H__#include <
xen/types.h>
Quoted 2 lines
Do not rely on the translation using including this file to make u32 available for you.
I did not include this header deliberately. Sadly mbd.h is used in reloc.c and if we do that then build will be broken. However, if you wish I could add ifndef __FOOBAR__ and then define __FOOBAR__ in reloc.c. Or maybe you have better idea?
Daniel
On Thu, Sep 25, 2014 at 08:56:39AM -0700, Roy Franz wrote:
[...]
Quoted 9 lines
I don't think there should be any more major changes, but I'm still working through a few
last issues which may result in some code movement. A lot of my patches are re-organizingboot.c, so even small changes can be a pain for patches based on that. I'm hoping to be able
to resolve the last few issues in the next few days to get the patches merged for 4.5, so if you
hold of for a few days you can hopefully take my changes from the master branch.
Thanks. I will start work on MBD which does not touch EFI stuff. I hope that in the meantime your patches will be merged into master branch.
Daniel
Re: [PATCH v2 1/5] xen/x86: Introduce MultiBoot Data (MBD) type
In reply to Daniel KiperQuoted 36 lines
Quoted 1 line
Quoted 1 line · On 25.09.14 at 21:24, <[email protected]> wrote:
Quoted 30 lines · Andrew Cooper
Quoted 16 lines · Daniel Kiper
xen/arch/x86/setup.c +0
-12@@ -556,21 +575,13 @@ void __init noreturn __start_xen(unsigned long mbi_p) .stop_bits = 1 }; -/* Critical region without IDT or TSS. Any fault is deadly! */ - -set_processor_id (0 ); -set_current ((struct vcpu *)0xfffff000 );/* debug sanity. */ - idle_vcpu[0 ] = current; - -percpu_init_areas (); - -init_idt_traps (); -load_system_tables (); - -smp_prepare_boot_cpu ();xen/arch/x86/setup.c void __init noreturn __start_xen(unsigned long mbi_p) · line 584
Quoted 10 lines
xen/arch/x86/setup.c +7
-3-sort_exception_tables (); - -/* Full exception support from here on in. */ +if ( !efi_enabled ) { +/* Exception support was enabled before __start_xen() call. */ + } +else + { +enable_exception_support (); + }For this, absolutely not.
Quoted 3 lines
Pass
mbi_painto__start_xen()and have__start_xen()call__init_boot_info()after it has set up exception support. None of the contents of MBD are needed beforehand.
Quoted 11 lines
Ehhh... I do not like this solution too. However, I want to avoid passing mbd to
__start_xen(). If we do that as you suggest then EFI case will look bad because we would not be able to passboot_infodirectly to__start_xen().boot_infois build directly in EFI case. We do not need mbd. It means that__init_boot_info()is not used on EFI platforms too. Additionally, I think that__start_xen()is firm border between preloader and Xen main code and this as is should not see any variables belonging to preloader (mbd is preloader stuff). Hence, I think that__start_xen()should takeboot_infoas an argument. However, I agree that we should work out better solution for exception initialization.
There's no hard boundary between what the pre-__start_xen() code in the EFI case (or the equivalent code in the non-EFI one) can access, and I don't think there needs to be.
Quoted 25 lines
Quoted 25 lines
Quoted 12 lines
xen/include/asm-x86/mbd.h new file +9
-0@@ -0,0 +1,70 @@ +/* +* Copyright (c) 2013, 2014 Oracle Co., Daniel Kiper +* +* This program 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 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, xen/include/asm-x86/mbd.h line 19
Quoted 10 lines
xen/include/asm-x86/mbd.h new file +10
-0+* 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 this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MBD_H__ +#define __MBD_H__#include <
xen/types.h>
Quoted 7 lines
Quoted 2 lines
Do not rely on the translation using including this file to make u32 available for you.
I did not include this header deliberately. Sadly
mbd.his used inreloc.cand if we do that then build will be broken. However, if you wish I could add ifndef__FOOBAR__and then define__FOOBAR__inreloc.c. Or maybe you have better idea?
Add a comment explaining why the header is deliberately not being included? Or only use standard C types (perhaps with suitable BUILD_BUG_ON()s put elsewhere)?
Jan