All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
@ 2014-10-08 17:52 Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit Daniel Kiper
                   ` (17 more replies)
  0 siblings, 18 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

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.

Patch #13 reveals a bug which probably was introduced between commit
3e2331d271cc0882e4013c8f20398c46c35f90a1 (VT-d: suppress UR signaling for
further desktop chipsets) and 61fdda7acf3de11f3d50d50e5b4f4ecfac7e0d04
(x86/HVM: properly bound x2APIC MSR range). Xen crashes at video_endboot()
because earlier scrub process wipes vga_console_info data (sic!). So,
it means that at least page containing this structure was freed mistakenly
somewhere. Interestingly this issue appears on legacy BIOS machines only.
EFI platforms work as usual. It is possible to workaround this bug by
passing no-bootscrub to xen.gz.

I was not able to spot anything obvious just looking briefly at commit history.
I am going to narrow down and fix this issue in next release.

ARM build has not been tested yet.

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 reviews and still think that your comment is valid
in particular case please notify me.

Daniel

 xen/arch/x86/Makefile             |    1 +
 xen/arch/x86/boot/cmdline.S       |    9 +--
 xen/arch/x86/boot/head.S          |  143 +++++++++++++++++++++++++++-----
 xen/arch/x86/boot/reloc.c         |  244 ++++++++++++++++++++++++++++++++++++++++++++-----------
 xen/arch/x86/boot/x86_64.S        |   10 ++-
 xen/arch/x86/boot_info.c          |  257 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/dmi_scan.c           |   11 ++-
 xen/arch/x86/domain_build.c       |   24 +++---
 xen/arch/x86/efi/efi-boot.h       |  173 +++++++++++++++++++--------------------
 xen/arch/x86/microcode.c          |   39 +++++----
 xen/arch/x86/mpparse.c            |   13 ++-
 xen/arch/x86/platform_hypercall.c |   17 ++--
 xen/arch/x86/setup.c              |  364 +++++++++++++++++++++++++++-------------------------------------------------------
 xen/arch/x86/x86_64/asm-offsets.c |    5 +-
 xen/common/efi/boot.c             |    1 -
 xen/common/efi/efi.h              |   11 +++
 xen/common/efi/runtime.c          |   55 +++++++++++--
 xen/drivers/acpi/osl.c            |   13 ++-
 xen/drivers/video/vesa.c          |    7 +-
 xen/drivers/video/vga.c           |   18 ++---
 xen/include/asm-x86/boot_info.h   |  123 ++++++++++++++++++++++++++++
 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/mbd.h         |   79 ++++++++++++++++++
 xen/include/asm-x86/setup.h       |   10 +--
 xen/include/xen/efi.h             |    7 ++
 xen/include/xen/multiboot2.h      |  148 +++++++++++++++++++++++++++++++++
 xen/include/xen/vga.h             |   18 -----
 xen/include/xsm/xsm.h             |   14 ++--
 xen/xsm/xsm_core.c                |    6 +-
 xen/xsm/xsm_policy.c              |   10 +--
 32 files changed, 1310 insertions(+), 536 deletions(-)

Daniel Kiper (16):
      x86/boot/reloc: Remove redundant blank characters and reformat comments a bit
      x86/boot/reloc: Move typedef and include to beginning of file
      x86/boot/reloc: Create generic alloc and copy functions
      x86: Introduce MultiBoot Data (MBD) type
      x86/efi: Add place_string_u32() function
      x86: Introduce boot_info structure
      x86: Move boot_loader_name from mbi to boot_info
      x86: Move cmdline from mbi to boot_info
      x86: Move legacy BIOS memory map stuff to boot_info
      x86: Move modules data from mbi to boot_info and remove mbi
      x86: Move EFI memory map stuff to boot_info
      x86: Move MPS, ACPI and SMBIOS data to boot_info
      x86: Move video data to boot_info
      x86: Move HDD data to boot_info
      x86/boot: Use %ecx instead of %eax
      xen/x86: Add multiboot2 protocol support

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09  9:26   ` Andrew Cooper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file Daniel Kiper
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/reloc.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index fa0fb6b..4609e55 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -1,11 +1,11 @@
-/******************************************************************************
+/*
  * 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.
- * 
+ *
  * Authors:
  *    Keir Fraser <keir@xen.org>
  */
@@ -21,8 +21,9 @@ asm (
     "    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"
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09  9:40   ` Andrew Cooper
  2014-10-10  8:50   ` Jan Beulich
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions Daniel Kiper
                   ` (15 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/reloc.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index 4609e55..0c03291 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -10,6 +10,10 @@
  *    Keir Fraser <keir@xen.org>
  */
 
+typedef unsigned int u32;
+
+#include "../../../include/xen/multiboot.h"
+
 /* entered with %eax = BOOT_TRAMPOLINE */
 asm (
     "    .text                         \n"
@@ -30,9 +34,6 @@ asm (
     "    .long 0                       \n"
     );
 
-typedef unsigned int u32;
-#include "../../../include/xen/multiboot.h"
-
 static void *reloc_mbi_struct(void *old, unsigned int bytes)
 {
     void *new;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09  9:45   ` Andrew Cooper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type Daniel Kiper
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Create generic alloc and copy functions. We need them to
introduce MBD struct and multiboot2 protocol. Please
check later patches for more details.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/reloc.c |   52 +++++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index 0c03291..b678f67 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -34,9 +34,10 @@ asm (
     "    .long 0                       \n"
     );
 
-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"
@@ -44,50 +45,65 @@ 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 u32 copy_struct(u32 src, u32 bytes)
+{
+    u32 dst, dst_asm;
+
+    dst = alloc_struct(bytes);
+    dst_asm = dst;
+
+    asm volatile(
     "    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)
 {
-    multiboot_info_t *mbi = reloc_mbi_struct(mbi_old, sizeof(*mbi));
+    multiboot_info_t *mbi = (multiboot_info_t *)copy_struct((u32)mbi_old, sizeof(*mbi));
     int i;
 
     if ( mbi->flags & MBI_CMDLINE )
-        mbi->cmdline = (u32)reloc_mbi_string((char *)mbi->cmdline);
+        mbi->cmdline = copy_string(mbi->cmdline);
 
     if ( mbi->flags & MBI_MODULES )
     {
-        module_t *mods = reloc_mbi_struct(
-            (module_t *)mbi->mods_addr, mbi->mods_count * sizeof(module_t));
+        module_t *mods = (module_t *)copy_struct(
+            mbi->mods_addr, mbi->mods_count * sizeof(module_t));
 
         mbi->mods_addr = (u32)mods;
 
         for ( i = 0; i < mbi->mods_count; i++ )
         {
             if ( mods[i].string )
-                mods[i].string = (u32)reloc_mbi_string((char *)mods[i].string);
+                mods[i].string = copy_string(mods[i].string);
         }
     }
 
     if ( mbi->flags & MBI_MEMMAP )
-        mbi->mmap_addr = (u32)reloc_mbi_struct(
-            (memory_map_t *)mbi->mmap_addr, mbi->mmap_length);
+        mbi->mmap_addr = copy_struct(mbi->mmap_addr, mbi->mmap_length);
 
     if ( mbi->flags & MBI_LOADERNAME )
-        mbi->boot_loader_name = (u32)reloc_mbi_string(
-            (char *)mbi->boot_loader_name);
+        mbi->boot_loader_name = copy_string(mbi->boot_loader_name);
 
     /* Mask features we don't understand or don't relocate. */
     mbi->flags &= (MBI_MEMLIMITS |
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (2 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09 10:28   ` Andrew Cooper
  2014-10-14 15:27   ` Jan Beulich
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 05/16] x86/efi: Add place_string_u32() function Daniel Kiper
                   ` (13 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

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.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
v3 - suggestions/fixes:
   - rename some variables
     (suggested by Andrew Cooper),
   - remove unneeded initialization
     (suggested by Andrew Cooper),
   - improve comments
     (suggested by Andrew Cooper),
   - further patch split rearrangement
     (suggested by Andrew Cooper and Jan Beulich).

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          |    2 +-
 xen/arch/x86/boot/reloc.c         |   69 +++++++++++++++++++++-----------
 xen/arch/x86/boot/x86_64.S        |   10 +++--
 xen/arch/x86/boot_info.c          |   59 +++++++++++++++++++++++++++
 xen/arch/x86/setup.c              |   41 ++++++++++++-------
 xen/arch/x86/x86_64/asm-offsets.c |    5 +--
 xen/include/asm-x86/mbd.h         |   79 +++++++++++++++++++++++++++++++++++++
 9 files changed, 225 insertions(+), 50 deletions(-)
 create mode 100644 xen/arch/x86/boot_info.c
 create mode 100644 xen/include/asm-x86/mbd.h

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 86ca5f8..8425e65 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -43,6 +43,7 @@ obj-y += pci.o
 obj-y += percpu.o
 obj-y += physdev.o
 obj-y += psr.o
+obj-y += boot_info.o
 obj-y += setup.o
 obj-y += shutdown.o
 obj-y += smp.o
diff --git a/xen/arch/x86/boot/cmdline.S b/xen/arch/x86/boot/cmdline.S
index 00687eb..dd1a027 100644
--- a/xen/arch/x86/boot/cmdline.S
+++ b/xen/arch/x86/boot/cmdline.S
@@ -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_pa),%ebx
+        mov     MBD_cmdline_pa(%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_pa(%ebx)
         call    .Lfind_option
         test    %eax,%eax
         setnz   %al
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index cd43952..f1b872a 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -120,7 +120,7 @@ __start:
         mov     $sym_phys(cpu0_stack)+1024,%esp
         push    %ebx
         call    reloc
-        mov     %eax,sym_phys(multiboot_ptr)
+        mov     %eax,sym_phys(mbd_pa)
 
         /* Initialize BSS (no nasty surprises!) */
         mov     $sym_phys(__bss_start),%edi
diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index b678f67..59edb4d 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -12,8 +12,11 @@
 
 typedef unsigned int u32;
 
+#include "../../../include/xen/compiler.h"
 #include "../../../include/xen/multiboot.h"
 
+#include "../../../include/asm/mbd.h"
+
 /* entered with %eax = BOOT_TRAMPOLINE */
 asm (
     "    .text                         \n"
@@ -22,7 +25,7 @@ asm (
     "    call 1f                       \n"
     "1:  pop  %ebx                     \n"
     "    mov  %eax,alloc-1b(%ebx)      \n"
-    "    jmp  reloc                    \n"
+    "    jmp  __reloc                  \n"
     );
 
 /*
@@ -50,6 +53,13 @@ static u32 alloc_struct(u32 bytes)
     return s;
 }
 
+static void zero_struct(u32 s, u32 bytes)
+{
+    asm volatile(
+    "    rep  stosb                   \n"
+       : "+D" (s), "+c" (bytes) : "a" (0));
+}
+
 static u32 copy_struct(u32 src, u32 bytes)
 {
     u32 dst, dst_asm;
@@ -77,41 +87,56 @@ static u32 copy_string(u32 src)
     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 = (multiboot_info_t *)copy_struct((u32)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 = copy_string(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 = (module_t *)copy_struct(
-            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 = copy_string(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 = copy_struct(mbi->mmap_addr, mbi->mmap_length);
+    return mbd;
+}
 
-    if ( mbi->flags & MBI_LOADERNAME )
-        mbi->boot_loader_name = copy_string(mbi->boot_loader_name);
+static mbd_t __used *__reloc(void *mbi)
+{
+    mbd_t *mbd;
 
-    /* Mask features we don't understand or don't relocate. */
-    mbi->flags &= (MBI_MEMLIMITS |
-                   MBI_BOOTDEV |
-                   MBI_CMDLINE |
-                   MBI_MODULES |
-                   MBI_MEMMAP |
-                   MBI_LOADERNAME);
+    mbd = (mbd_t *)alloc_struct(sizeof(mbd_t));
+    zero_struct((u32)mbd, sizeof(mbd_t));
 
-    return mbi;
+    return mb_mbd(mbd, mbi);
 }
diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index bfbafd2..ef8c735 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -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 mbi. */
+        mov     mbd_pa(%rip),%edi
+        call    __init_mbi
+
+        /* Pass off the mbi 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_pa:
         .long   0
 
         .word   0
diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
new file mode 100644
index 0000000..a2799aa
--- /dev/null
+++ b/xen/arch/x86/boot_info.c
@@ -0,0 +1,59 @@
+/*
+ * 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/>.
+ */
+
+#include <xen/types.h>
+#include <xen/cache.h>
+#include <xen/init.h>
+#include <xen/multiboot.h>
+
+#include <asm/mbd.h>
+#include <asm/page.h>
+
+static multiboot_info_t __read_mostly mbi;
+
+extern void enable_exception_support(void);
+
+unsigned long __init __init_mbi(u32 mbd_pa)
+{
+    mbd_t *mbd = __va(mbd_pa);
+
+    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);
+}
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 8c8b91f..24e1be3 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -529,6 +529,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;
@@ -546,21 +565,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();
-    sort_exception_tables();
-
-    /* Full exception support from here on in. */
+    if ( efi_enabled ) {
+        enable_exception_support();
+    }
+    else
+    {
+        /* Exception support was enabled before __start_xen() call. */
+    }
 
     loader = (mbi->flags & MBI_LOADERNAME)
         ? (char *)__va(mbi->boot_loader_name) : "unknown";
diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index 3994f4d..dab0ae1 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -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_pa, mbd_t, cmdline);
 }
diff --git a/xen/include/asm-x86/mbd.h b/xen/include/asm-x86/mbd.h
new file mode 100644
index 0000000..45e7285
--- /dev/null
+++ b/xen/include/asm-x86/mbd.h
@@ -0,0 +1,79 @@
+/*
+ * 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/>.
+ */
+
+#ifndef __MBD_H__
+#define __MBD_H__
+
+/*
+ * Do not include any headers here!
+ *
+ * This file is used by xen/arch/x86/boot/reloc.c
+ * and any include statement here will break its build.
+ * It means that every basic type used below must be defined
+ * before any usage of this header.
+ */
+
+/* Module type. */
+typedef struct {
+    u32 start;
+    u32 end;
+
+    /* A module command line address. */
+    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
+ * 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 {
+    /* Boot loader name physical address. */
+    u32 boot_loader_name;
+
+    /* Xen command line physical address. */
+    u32 cmdline;
+
+    /*
+     * 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;
+
+    /* Physical address of memory map provided by bootloader. */
+    u32 mmap;
+
+    /* Number of modules. */
+    u32 mods_nr;
+
+    /* Physical address of modules description (boot_module_t *). */
+    u32 mods;
+} mbd_t;
+#endif /* __MBD_H__ */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 05/16] x86/efi: Add place_string_u32() function
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (3 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09 10:30   ` Andrew Cooper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure Daniel Kiper
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Add place_string_u32() function and rename place_string()
to place_string_char().

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/efi/efi-boot.h |   29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 4348cfe..71030b0 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -103,14 +103,14 @@ static void __init relocate_trampoline(unsigned long phys)
         *(u16 *)(*trampoline_ptr + (long)trampoline_ptr) = phys >> 4;
 }
 
-static void __init place_string(u32 *addr, const char *s)
+static void __init place_string_char(char **addr, const char *s)
 {
     static char *__initdata alloc = start;
 
     if ( s && *s )
     {
         size_t len1 = strlen(s) + 1;
-        const char *old = (char *)(long)*addr;
+        const char *old = *addr;
         size_t len2 = *addr ? strlen(old) + 1 : 0;
 
         alloc -= len1 + len2;
@@ -126,7 +126,16 @@ static void __init place_string(u32 *addr, const char *s)
             memcpy(alloc + len1, old, len2);
         }
     }
-    *addr = (long)alloc;
+    *addr = alloc;
+}
+
+static void __init place_string_u32(u32 *addr, const char *s)
+{
+    char *s_new = (char *)(long)*addr;
+
+    place_string_char(&s_new, s);
+
+    *addr = (long)s_new;
 }
 
 static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
@@ -192,7 +201,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
 
 static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size)
 {
-    place_string(&mbi.mem_upper, NULL);
+    place_string_u32(&mbi.mem_upper, NULL);
     mbi.mem_upper -= map_size;
     mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR);
     if ( mbi.mem_upper < xen_phys_start )
@@ -280,10 +289,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     {
         name.w = cmdline_options;
         w2s(&name);
-        place_string(&mbi.cmdline, name.s);
+        place_string_u32(&mbi.cmdline, name.s);
     }
     if ( cfgfile_options )
-        place_string(&mbi.cmdline, cfgfile_options);
+        place_string_u32(&mbi.cmdline, cfgfile_options);
     /* Insert image name last, as it gets prefixed to the other options. */
     if ( image_name )
     {
@@ -292,7 +301,7 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     }
     else
         name.s = "xen";
-    place_string(&mbi.cmdline, name.s);
+    place_string_u32(&mbi.cmdline, name.s);
 
     if ( mbi.cmdline )
         mbi.flags |= MBI_CMDLINE;
@@ -587,12 +596,12 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name,
     /*
      * If options are provided, put them in
      * mb_modules[mbi.mods_count].string after the filename, with a space
-     * separating them.  place_string() prepends strings and adds separating
+     * separating them.  place_string_u32() prepends strings and adds separating
      * spaces, so the call order is reversed.
      */
     if ( options )
-        place_string(&mb_modules[mbi.mods_count].string, options);
-    place_string(&mb_modules[mbi.mods_count].string, local_name.s);
+        place_string_u32(&mb_modules[mbi.mods_count].string, options);
+    place_string_u32(&mb_modules[mbi.mods_count].string, local_name.s);
     mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT;
     mb_modules[mbi.mods_count].mod_end = file->size;
     ++mbi.mods_count;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (4 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 05/16] x86/efi: Add place_string_u32() function Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09 10:48   ` Andrew Cooper
  2014-10-10 13:55   ` Stefano Stabellini
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 07/16] x86: Move boot_loader_name from mbi to boot_info Daniel Kiper
                   ` (11 subsequent siblings)
  17 siblings, 2 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

This patch introduces boot_info structure. Subsequent patches will move
step by step all boot related data to above mentioned struct. At the end
of this process multiboot (v1) protocol dependency will be broken. It means
that most of Xen code (excluding preloader) could be bootloader agnostic
and does not need almost any knowledge about boot protocol. Additionally,
it will be possible 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 has not been tested yet.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
v3 - suggestions/fixes:
   - further patch split rearrangement
     (suggested by Andrew Cooper).

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/x86_64.S      |   10 +++++++--
 xen/arch/x86/boot_info.c        |   11 ++++++++++
 xen/arch/x86/efi/efi-boot.h     |    3 ++-
 xen/arch/x86/setup.c            |   13 ++++++++++-
 xen/common/efi/efi.h            |    7 ++++++
 xen/common/efi/runtime.c        |   10 +++++++++
 xen/include/asm-x86/boot_info.h |   46 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 96 insertions(+), 4 deletions(-)
 create mode 100644 xen/include/asm-x86/boot_info.h

diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index ef8c735..647c33b 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -32,9 +32,15 @@
         /* Init mbi. */
         mov     mbd_pa(%rip),%edi
         call    __init_mbi
+        pushq   %rax
+
+        /* Init boot_info. */
+        mov     mbd_pa(%rip),%edi
+        call    __init_boot_info
 
-        /* Pass off the mbi to C land. */
-        movq    %rax,%rdi
+        /* Pass off the mbi and boot_info to C land. */
+        popq    %rdi
+        movq    %rax,%rsi
         call    __start_xen
         ud2     /* Force a panic (invalid opcode). */
 
diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index a2799aa..83bd255 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -20,11 +20,17 @@
 #include <xen/init.h>
 #include <xen/multiboot.h>
 
+#include <asm/boot_info.h>
 #include <asm/mbd.h>
 #include <asm/page.h>
 
 static multiboot_info_t __read_mostly mbi;
 
+static boot_info_t __read_mostly boot_info_mb = {
+    .warn_msg = NULL,
+    .err_msg = NULL
+};
+
 extern void enable_exception_support(void);
 
 unsigned long __init __init_mbi(u32 mbd_pa)
@@ -57,3 +63,8 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
     return __pa(&mbi);
 }
+
+paddr_t __init __init_boot_info(u32 mbd_pa)
+{
+    return __pa(&boot_info_mb);
+}
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 71030b0..6d7c222 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -254,7 +254,8 @@ static void __init noreturn efi_arch_post_exit_boot(void)
                      [cs] "ir" (__HYPERVISOR_CS),
                      [ds] "r" (__HYPERVISOR_DS),
                      [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)),
-                     "D" (&mbi)
+                     "D" (&mbi),
+                     "S" (&boot_info_efi)
                    : "memory" );
     for( ; ; ); /* not reached */
 }
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 24e1be3..d2a1450 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -49,6 +49,7 @@
 #include <xen/cpu.h>
 #include <asm/nmi.h>
 #include <asm/alternative.h>
+#include <asm/boot_info.h>
 
 /* opt_nosmp: If true, secondary processors are ignored. */
 static bool_t __initdata opt_nosmp;
@@ -92,6 +93,8 @@ unsigned long __initdata highmem_start;
 size_param("highmem-start", highmem_start);
 #endif
 
+boot_info_t *boot_info;
+
 cpumask_t __read_mostly cpu_present_map;
 
 unsigned long __read_mostly xen_phys_start;
@@ -548,7 +551,7 @@ void __init enable_exception_support(void)
     /* Full exception support from here on in. */
 }
 
-void __init noreturn __start_xen(unsigned long mbi_p)
+void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
 {
     char *memmap_type = NULL;
     char *cmdline, *kextra, *loader;
@@ -565,6 +568,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         .stop_bits = 1
     };
 
+    boot_info = __va(boot_info_pa);
+
     if ( efi_enabled ) {
         enable_exception_support();
     }
@@ -613,6 +618,12 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     ehci_dbgp_init();
     console_init_preirq();
 
+    if ( boot_info->err_msg )
+        panic(boot_info->err_msg);
+
+    if ( boot_info->warn_msg )
+        printk(boot_info->warn_msg);
+
     printk("Bootloader: %s\n", loader);
 
     printk("Command line: %s\n", cmdline);
diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
index bee3b77..526f57c 100644
--- a/xen/common/efi/efi.h
+++ b/xen/common/efi/efi.h
@@ -8,6 +8,9 @@
 #include <xen/efi.h>
 #include <xen/spinlock.h>
 #include <asm/page.h>
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+#include <asm/boot_info.h>
+#endif
 
 struct efi_pci_rom {
     const struct efi_pci_rom *next;
@@ -25,6 +28,10 @@ extern const CHAR16 *efi_fw_vendor;
 
 extern EFI_RUNTIME_SERVICES *efi_rs;
 
+#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
+extern boot_info_t boot_info_efi;
+#endif
+
 extern UINTN efi_memmap_size, efi_mdesc_size;
 extern void *efi_memmap;
 
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 1c43d10..eb0acae 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -5,6 +5,9 @@
 #include <xen/guest_access.h>
 #include <xen/irq.h>
 #include <xen/time.h>
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+#include <asm/boot_info.h>
+#endif
 
 DEFINE_XEN_GUEST_HANDLE(CHAR16);
 
@@ -50,6 +53,13 @@ struct efi __read_mostly efi = {
 const struct efi_pci_rom *__read_mostly efi_pci_roms;
 
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+boot_info_t __read_mostly boot_info_efi = {
+    .warn_msg = NULL,
+    .err_msg = NULL
+};
+#endif
+
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 unsigned long efi_rs_enter(void)
 {
     static const u16 fcw = FCW_DEFAULT;
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
new file mode 100644
index 0000000..9ff3c0f
--- /dev/null
+++ b/xen/include/asm-x86/boot_info.h
@@ -0,0 +1,46 @@
+/*
+ * 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/>.
+ */
+
+#ifndef __BOOT_INFO_H__
+#define __BOOT_INFO_H__
+
+/*
+ * Define boot_info type. It will be used to define variable which in turn
+ * will store data collected by bootloader and preloader. This way it will
+ * be possible to make most of Xen code bootloader agnostic.
+ *
+ * Some members should have relevant EFI/ACPI types. However, due to type
+ * conflicts among ACPI and EFI headers it is not possible to use required
+ * EFI/ACPI types here. Instead of them there are simple types in use which
+ * are compatible as much as possible with relevant EFI/ACPI types.
+ */
+typedef struct {
+    /*
+     * Info about warning occurred during boot_info initialization.
+     * NULL if everything went OK.
+     */
+    char *warn_msg;
+
+    /*
+     * Info about error occurred during boot_info initialization. NULL if everything
+     * went OK. Otherwise boot_info is not fully/properly initialized.
+     */
+    char *err_msg;
+} boot_info_t;
+
+extern boot_info_t *boot_info;
+#endif /* __BOOT_INFO_H__ */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 07/16] x86: Move boot_loader_name from mbi to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (5 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09 10:53   ` Andrew Cooper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 08/16] x86: Move cmdline " Daniel Kiper
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c        |   11 ++++++-----
 xen/arch/x86/efi/efi-boot.h     |    3 +--
 xen/arch/x86/setup.c            |   13 +++++--------
 xen/common/efi/runtime.c        |    1 +
 xen/include/asm-x86/boot_info.h |    3 +++
 5 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 83bd255..5851123 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -27,6 +27,7 @@
 static multiboot_info_t __read_mostly mbi;
 
 static boot_info_t __read_mostly boot_info_mb = {
+    .boot_loader_name = "UNKNOWN",
     .warn_msg = NULL,
     .err_msg = NULL
 };
@@ -39,11 +40,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
     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;
@@ -66,5 +62,10 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
 paddr_t __init __init_boot_info(u32 mbd_pa)
 {
+    mbd_t *mbd = __va(mbd_pa);
+
+    if ( mbd->boot_loader_name )
+        boot_info_mb.boot_loader_name = __va(mbd->boot_loader_name);
+
     return __pa(&boot_info_mb);
 }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 6d7c222..29504e9 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -11,7 +11,7 @@
 
 static struct file __initdata ucode;
 static multiboot_info_t __initdata mbi = {
-    .flags = MBI_MODULES | MBI_LOADERNAME
+    .flags = MBI_MODULES
 };
 static module_t __initdata mb_modules[3];
 
@@ -310,7 +310,6 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
      * These must not be initialized statically, since the value must
      * not get relocated when processing base relocations later.
      */
-    mbi.boot_loader_name = (long)"EFI";
     mbi.mods_addr = (long)mb_modules;
 }
 
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index d2a1450..c4642f3 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -554,7 +554,7 @@ void __init enable_exception_support(void)
 void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
 {
     char *memmap_type = NULL;
-    char *cmdline, *kextra, *loader;
+    char *cmdline, *kextra;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
     multiboot_info_t *mbi = __va(mbi_p);
     module_t *mod = (module_t *)__va(mbi->mods_addr);
@@ -578,13 +578,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         /* Exception support was enabled before __start_xen() call. */
     }
 
-    loader = (mbi->flags & MBI_LOADERNAME)
-        ? (char *)__va(mbi->boot_loader_name) : "unknown";
-
     /* Parse the command-line options. */
     cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ?
                            __va(mbi->cmdline) : NULL,
-                           loader);
+                           boot_info->boot_loader_name);
     if ( (kextra = strstr(cmdline, " -- ")) != NULL )
     {
         /*
@@ -624,7 +621,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
     if ( boot_info->warn_msg )
         printk(boot_info->warn_msg);
 
-    printk("Bootloader: %s\n", loader);
+    printk("Bootloader: %s\n", boot_info->boot_loader_name);
 
     printk("Command line: %s\n", cmdline);
 
@@ -698,7 +695,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         l3_bootmap[l3_table_offset(BOOTSTRAP_MAP_BASE)] =
             l3e_from_paddr(__pa(l2_bootmap), __PAGE_HYPERVISOR);
 
-        memmap_type = loader;
+        memmap_type = boot_info->boot_loader_name;
     }
     else if ( e820_raw_nr != 0 )
     {
@@ -1380,7 +1377,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
     {
         static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE];
 
-        cmdline = cmdline_cook(cmdline, loader);
+        cmdline = cmdline_cook(cmdline, boot_info->boot_loader_name);
         safe_strcpy(dom0_cmdline, cmdline);
 
         if ( kextra != NULL )
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index eb0acae..7846b2b 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -54,6 +54,7 @@ const struct efi_pci_rom *__read_mostly efi_pci_roms;
 
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 boot_info_t __read_mostly boot_info_efi = {
+    .boot_loader_name = "EFI",
     .warn_msg = NULL,
     .err_msg = NULL
 };
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index 9ff3c0f..58a4cb6 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -29,6 +29,9 @@
  * are compatible as much as possible with relevant EFI/ACPI types.
  */
 typedef struct {
+    /* Boot loader name. */
+    char *boot_loader_name;
+
     /*
      * Info about warning occurred during boot_info initialization.
      * NULL if everything went OK.
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 08/16] x86: Move cmdline from mbi to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (6 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 07/16] x86: Move boot_loader_name from mbi to boot_info Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff " Daniel Kiper
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c        |    9 ++++-----
 xen/arch/x86/efi/efi-boot.h     |    8 +++-----
 xen/arch/x86/setup.c            |    4 +---
 xen/common/efi/runtime.c        |    1 +
 xen/include/asm-x86/boot_info.h |    3 +++
 5 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 5851123..7101f6c 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -28,6 +28,7 @@ static multiboot_info_t __read_mostly mbi;
 
 static boot_info_t __read_mostly boot_info_mb = {
     .boot_loader_name = "UNKNOWN",
+    .cmdline = NULL,
     .warn_msg = NULL,
     .err_msg = NULL
 };
@@ -40,11 +41,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
     enable_exception_support();
 
-    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;
@@ -67,5 +63,8 @@ paddr_t __init __init_boot_info(u32 mbd_pa)
     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);
+
     return __pa(&boot_info_mb);
 }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 29504e9..3b5628a 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -290,10 +290,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     {
         name.w = cmdline_options;
         w2s(&name);
-        place_string_u32(&mbi.cmdline, name.s);
+        place_string_char(&boot_info_efi.cmdline, name.s);
     }
     if ( cfgfile_options )
-        place_string_u32(&mbi.cmdline, cfgfile_options);
+        place_string_char(&boot_info_efi.cmdline, cfgfile_options);
     /* Insert image name last, as it gets prefixed to the other options. */
     if ( image_name )
     {
@@ -302,10 +302,8 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     }
     else
         name.s = "xen";
-    place_string_u32(&mbi.cmdline, name.s);
+    place_string_char(&boot_info_efi.cmdline, name.s);
 
-    if ( mbi.cmdline )
-        mbi.flags |= MBI_CMDLINE;
     /*
      * These must not be initialized statically, since the value must
      * not get relocated when processing base relocations later.
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index c4642f3..d7416d3 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -579,9 +579,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
     }
 
     /* Parse the command-line options. */
-    cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ?
-                           __va(mbi->cmdline) : NULL,
-                           boot_info->boot_loader_name);
+    cmdline = cmdline_cook(boot_info->cmdline, boot_info->boot_loader_name);
     if ( (kextra = strstr(cmdline, " -- ")) != NULL )
     {
         /*
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 7846b2b..ee2ee2d 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -55,6 +55,7 @@ const struct efi_pci_rom *__read_mostly efi_pci_roms;
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 boot_info_t __read_mostly boot_info_efi = {
     .boot_loader_name = "EFI",
+    .cmdline = NULL,
     .warn_msg = NULL,
     .err_msg = NULL
 };
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index 58a4cb6..d74ed67 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -32,6 +32,9 @@ typedef struct {
     /* Boot loader name. */
     char *boot_loader_name;
 
+    /* Xen command line. */
+    char *cmdline;
+
     /*
      * Info about warning occurred during boot_info initialization.
      * NULL if everything went OK.
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (7 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 08/16] x86: Move cmdline " Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-10 14:02   ` Stefano Stabellini
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 10/16] x86: Move modules data from mbi to boot_info and remove mbi Daniel Kiper
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c        |  105 ++++++++++++++++++++++++++++++++++++---
 xen/arch/x86/efi/efi-boot.h     |   18 +++----
 xen/arch/x86/setup.c            |   73 ++-------------------------
 xen/common/efi/runtime.c        |    7 +++
 xen/include/asm-x86/boot_info.h |   22 ++++++++
 xen/include/asm-x86/e820.h      |    8 ---
 6 files changed, 138 insertions(+), 95 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 7101f6c..53e890b 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -15,40 +15,127 @@
  * 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/init.h>
 #include <xen/multiboot.h>
 
 #include <asm/boot_info.h>
+#include <asm/e820.h>
 #include <asm/mbd.h>
 #include <asm/page.h>
 
+/* These symbols live in the boot trampoline. Access via bootsym(). */
+extern struct e820entry e820map[];
+extern unsigned int e820nr;
+extern unsigned int lowmem_kb, highmem_kb;
+
 static multiboot_info_t __read_mostly mbi;
 
 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,
     .warn_msg = NULL,
     .err_msg = NULL
 };
 
+#define e820_raw bootsym(e820map)
+#define e820_raw_nr bootsym(e820nr)
+
 extern void enable_exception_support(void);
 
+static void __init init_mmap(boot_info_t *boot_info, mbd_t *mbd)
+{
+    int bytes = 0;
+    memory_map_t *map;
+
+    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";
+            }
+
+            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";
+
+        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;
+}
+
 unsigned long __init __init_mbi(u32 mbd_pa)
 {
     mbd_t *mbd = __va(mbd_pa);
 
     enable_exception_support();
 
-    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;
@@ -66,5 +153,7 @@ paddr_t __init __init_boot_info(u32 mbd_pa)
     if ( mbd->cmdline )
         boot_info_mb.cmdline = __va(mbd->cmdline);
 
+    init_mmap(&boot_info_mb, mbd);
+
     return __pa(&boot_info_mb);
 }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 3b5628a..8e57ac2 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -148,7 +148,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
     unsigned int i;
 
     /* Populate E820 table and check trampoline area availability. */
-    e = e820map - 1;
+    e = boot_info_efi.e820map - 1;
     for ( i = 0; i < map_size; i += desc_size )
     {
         EFI_MEMORY_DESCRIPTOR *desc = map + i;
@@ -182,10 +182,10 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
             type = E820_NVS;
             break;
         }
-        if ( e820nr && type == e->type &&
+        if ( boot_info_efi.e820map_nr && type == e->type &&
              desc->PhysicalStart == e->addr + e->size )
             e->size += len;
-        else if ( !len || e820nr >= E820MAX )
+        else if ( !len || boot_info_efi.e820map_nr >= E820MAX )
             continue;
         else
         {
@@ -193,7 +193,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
             e->addr = desc->PhysicalStart;
             e->size = len;
             e->type = type;
-            ++e820nr;
+            ++boot_info_efi.e820map_nr;
         }
     }
 
@@ -201,12 +201,12 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
 
 static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size)
 {
-    place_string_u32(&mbi.mem_upper, NULL);
-    mbi.mem_upper -= map_size;
-    mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR);
-    if ( mbi.mem_upper < xen_phys_start )
+    place_string_u32(&boot_info_efi.mem_upper, NULL);
+    boot_info_efi.mem_upper -= map_size;
+    boot_info_efi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR);
+    if ( boot_info_efi.mem_upper < xen_phys_start )
         return NULL;
-    return (void *)(long)mbi.mem_upper;
+    return (void *)(long)boot_info_efi.mem_upper;
 }
 
 static void __init efi_arch_pre_exit_boot(void)
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index d7416d3..de29d9e 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -553,13 +553,12 @@ void __init enable_exception_support(void)
 
 void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
 {
-    char *memmap_type = NULL;
     char *cmdline, *kextra;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
     multiboot_info_t *mbi = __va(mbi_p);
     module_t *mod = (module_t *)__va(mbi->mods_addr);
     unsigned long nr_pages, raw_max_page, modules_headroom, *module_map;
-    int i, j, e820_warn = 0, bytes = 0;
+    int i, j;
     bool_t acpi_boot_table_init_done = 0;
     struct domain *dom0;
     struct ns16550_defaults ns16550 = {
@@ -692,77 +691,11 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         /* Make boot page tables match non-EFI boot. */
         l3_bootmap[l3_table_offset(BOOTSTRAP_MAP_BASE)] =
             l3e_from_paddr(__pa(l2_bootmap), __PAGE_HYPERVISOR);
-
-        memmap_type = boot_info->boot_loader_name;
-    }
-    else if ( e820_raw_nr != 0 )
-    {
-        memmap_type = "Xen-e820";
     }
-    else if ( mbi->flags & MBI_MEMMAP )
-    {
-        memmap_type = "Multiboot-e820";
-        while ( (bytes < mbi->mmap_length) && (e820_raw_nr < E820MAX) )
-        {
-            memory_map_t *map = __va(mbi->mmap_addr + bytes);
-
-            /*
-             * 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.
-             */
-            if ( (map->base_addr_high == 0) && (map->length_high != 0) )
-            {
-                if ( !e820_warn )
-                {
-                    printk("WARNING: Buggy e820 map detected and fixed "
-                           "(truncated length fields).\n");
-                    e820_warn = 1;
-                }
-                map->length_high = 0;
-            }
-
-            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) )
-    {
-        memmap_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 ( mbi->flags & MBI_MEMLIMITS )
-    {
-        memmap_type = "Multiboot-e801";
-        e820_raw[0].addr = 0;
-        e820_raw[0].size = mbi->mem_lower << 10;
-        e820_raw[0].type = E820_RAM;
-        e820_raw[1].addr = 0x100000;
-        e820_raw[1].size = mbi->mem_upper << 10;
-        e820_raw[1].type = E820_RAM;
-        e820_raw_nr = 2;
-    }
-    else
-        panic("Bootloader provided no memory information.");
 
     /* Sanitise the raw E820 map to produce a final clean version. */
-    max_page = raw_max_page = init_e820(memmap_type, e820_raw, &e820_raw_nr);
+    max_page = raw_max_page = init_e820(boot_info->mmap_type, boot_info->e820map,
+                                        &boot_info->e820map_nr);
 
     /* Create a temporary copy of the E820 map. */
     memcpy(&boot_e820, &e820, sizeof(e820));
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index ee2ee2d..865d0bc 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -7,6 +7,7 @@
 #include <xen/time.h>
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 #include <asm/boot_info.h>
+#include <asm/e820.h>
 #endif
 
 DEFINE_XEN_GUEST_HANDLE(CHAR16);
@@ -53,9 +54,15 @@ struct efi __read_mostly efi = {
 const struct efi_pci_rom *__read_mostly efi_pci_roms;
 
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+extern struct e820entry e820map[];
+
 boot_info_t __read_mostly boot_info_efi = {
     .boot_loader_name = "EFI",
     .cmdline = NULL,
+    .mmap_type = "EFI",
+    .mem_upper = 0,
+    .e820map_nr = 0,
+    .e820map = e820map,
     .warn_msg = NULL,
     .err_msg = NULL
 };
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index d74ed67..640a420 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -18,6 +18,10 @@
 #ifndef __BOOT_INFO_H__
 #define __BOOT_INFO_H__
 
+#include <xen/types.h>
+
+#include <asm/e820.h>
+
 /*
  * Define boot_info type. It will be used to define variable which in turn
  * will store data collected by bootloader and preloader. This way it will
@@ -35,6 +39,24 @@ typedef struct {
     /* Xen command line. */
     char *cmdline;
 
+    /* Memory map type (source of memory map). */
+    char *mmap_type;
+
+    /*
+     * Amount of upper memory (in KiB) accordingly to The Multiboot
+     * Specification version 0.6.96.
+     */
+    u32 mem_upper;
+
+    /* Number of memory map entries provided by Xen preloader. */
+    unsigned int e820map_nr;
+
+    /*
+     * Memory map provided by Xen preloader. It should always point
+     * to an area able to accommodate at least E820MAX entries.
+     */
+    struct e820entry *e820map;
+
     /*
      * Info about warning occurred during boot_info initialization.
      * NULL if everything went OK.
diff --git a/xen/include/asm-x86/e820.h b/xen/include/asm-x86/e820.h
index d9ff4eb..8727afb 100644
--- a/xen/include/asm-x86/e820.h
+++ b/xen/include/asm-x86/e820.h
@@ -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*/
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 10/16] x86: Move modules data from mbi to boot_info and remove mbi
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (8 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff " Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 11/16] x86: Move EFI memory map stuff to boot_info Daniel Kiper
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/x86_64.S      |   10 +--
 xen/arch/x86/boot_info.c        |   24 +++----
 xen/arch/x86/domain_build.c     |   24 +++----
 xen/arch/x86/efi/efi-boot.h     |   30 +++------
 xen/arch/x86/microcode.c        |   39 +++++------
 xen/arch/x86/setup.c            |  140 +++++++++++++++++++--------------------
 xen/common/efi/boot.c           |    1 -
 xen/common/efi/runtime.c        |    4 ++
 xen/include/asm-x86/boot_info.h |    7 ++
 xen/include/asm-x86/setup.h     |   10 +--
 xen/include/xsm/xsm.h           |   14 ++--
 xen/xsm/xsm_core.c              |    6 +-
 xen/xsm/xsm_policy.c            |   10 +--
 13 files changed, 151 insertions(+), 168 deletions(-)

diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index 647c33b..6a0efd6 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -29,18 +29,12 @@
         test    %ebx,%ebx
         jnz     start_secondary
 
-        /* Init mbi. */
-        mov     mbd_pa(%rip),%edi
-        call    __init_mbi
-        pushq   %rax
-
         /* Init boot_info. */
         mov     mbd_pa(%rip),%edi
         call    __init_boot_info
 
-        /* Pass off the mbi and boot_info to C land. */
-        popq    %rdi
-        movq    %rax,%rsi
+        /* Pass off the boot_info to C land. */
+        movq    %rax,%rdi
         call    __start_xen
         ud2     /* Force a panic (invalid opcode). */
 
diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 53e890b..9f7c4a5 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -35,8 +35,6 @@ extern struct e820entry e820map[];
 extern unsigned int e820nr;
 extern unsigned int lowmem_kb, highmem_kb;
 
-static multiboot_info_t __read_mostly mbi;
-
 static boot_info_t __read_mostly boot_info_mb = {
     .boot_loader_name = "UNKNOWN",
     .cmdline = NULL,
@@ -44,6 +42,8 @@ static boot_info_t __read_mostly boot_info_mb = {
     .mem_upper = 0,
     .e820map_nr = 0,
     .e820map = NULL,
+    .mods_nr = 0,
+    .mods = NULL,
     .warn_msg = NULL,
     .err_msg = NULL
 };
@@ -130,23 +130,12 @@ static void __init init_mmap(boot_info_t *boot_info, mbd_t *mbd)
     boot_info->e820map = e820_raw;
 }
 
-unsigned long __init __init_mbi(u32 mbd_pa)
+paddr_t __init __init_boot_info(u32 mbd_pa)
 {
     mbd_t *mbd = __va(mbd_pa);
 
     enable_exception_support();
 
-    mbi.flags |= MBI_MODULES;
-    mbi.mods_count = mbd->mods_nr;
-    mbi.mods_addr = mbd->mods;
-
-    return __pa(&mbi);
-}
-
-paddr_t __init __init_boot_info(u32 mbd_pa)
-{
-    mbd_t *mbd = __va(mbd_pa);
-
     if ( mbd->boot_loader_name )
         boot_info_mb.boot_loader_name = __va(mbd->boot_loader_name);
 
@@ -155,5 +144,12 @@ paddr_t __init __init_boot_info(u32 mbd_pa)
 
     init_mmap(&boot_info_mb, mbd);
 
+    if ( boot_info_mb.err_msg )
+        goto err;
+
+    boot_info_mb.mods_nr = mbd->mods_nr;
+    boot_info_mb.mods = __va(mbd->mods);
+
+err:
     return __pa(&boot_info_mb);
 }
diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
index 7a6afea..2737b06 100644
--- a/xen/arch/x86/domain_build.c
+++ b/xen/arch/x86/domain_build.c
@@ -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);
         }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 8e57ac2..3a6e7ec 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -10,10 +10,6 @@
 #include <asm/processor.h>
 
 static struct file __initdata ucode;
-static multiboot_info_t __initdata mbi = {
-    .flags = MBI_MODULES
-};
-static module_t __initdata mb_modules[3];
 
 static void __init edd_put_string(u8 *dst, size_t n, const char *src)
 {
@@ -254,8 +250,7 @@ static void __init noreturn efi_arch_post_exit_boot(void)
                      [cs] "ir" (__HYPERVISOR_CS),
                      [ds] "r" (__HYPERVISOR_DS),
                      [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)),
-                     "D" (&mbi),
-                     "S" (&boot_info_efi)
+                     "D" (&boot_info_efi)
                    : "memory" );
     for( ; ; ); /* not reached */
 }
@@ -273,7 +268,7 @@ static void __init efi_arch_cfg_file_late(EFI_FILE_HANDLE dir_handle, char *sect
         name.s = get_value(&cfg, "global", "ucode");
     if ( name.s )
     {
-        microcode_set_module(mbi.mods_count);
+        microcode_set_module(boot_info_efi.mods_nr);
         split_string(name.s);
         read_file(dir_handle, s2w(&name), &ucode, NULL);
         efi_bs->FreePool(name.w);
@@ -303,12 +298,6 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     else
         name.s = "xen";
     place_string_char(&boot_info_efi.cmdline, name.s);
-
-    /*
-     * These must not be initialized statically, since the value must
-     * not get relocated when processing base relocations later.
-     */
-    mbi.mods_addr = (long)mb_modules;
 }
 
 static void __init efi_arch_edd(void)
@@ -593,16 +582,17 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name,
 
     /*
      * If options are provided, put them in
-     * mb_modules[mbi.mods_count].string after the filename, with a space
-     * separating them.  place_string_u32() prepends strings and adds separating
+     * boot_info_efi.mods[boot_info_efi.mods_nr].cmdline
+     * after the filename, with a space separating them.
+     * place_string_u32() prepends strings and adds separating
      * spaces, so the call order is reversed.
      */
     if ( options )
-        place_string_u32(&mb_modules[mbi.mods_count].string, options);
-    place_string_u32(&mb_modules[mbi.mods_count].string, local_name.s);
-    mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT;
-    mb_modules[mbi.mods_count].mod_end = file->size;
-    ++mbi.mods_count;
+        place_string_u32(&boot_info_efi.mods[boot_info_efi.mods_nr].cmdline, options);
+    place_string_u32(&boot_info_efi.mods[boot_info_efi.mods_nr].cmdline, local_name.s);
+    boot_info_efi.mods[boot_info_efi.mods_nr].start = file->addr >> PAGE_SHIFT;
+    boot_info_efi.mods[boot_info_efi.mods_nr].end = file->size;
+    ++boot_info_efi.mods_nr;
     efi_bs->FreePool(ptr);
 }
 
diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode.c
index 091d5d1..0293eba 100644
--- a/xen/arch/x86/microcode.c
+++ b/xen/arch/x86/microcode.c
@@ -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;
             }
         }
 
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index de29d9e..0e48726 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -12,7 +12,6 @@
 #include <xen/console.h>
 #include <xen/serial.h>
 #include <xen/trace.h>
-#include <xen/multiboot.h>
 #include <xen/domain_page.h>
 #include <xen/version.h>
 #include <xen/gdbstub.h>
@@ -140,7 +139,7 @@ static void __init parse_acpi_param(char *s)
     }
 }
 
-static const module_t *__initdata initial_images;
+static const boot_module_t *__initdata initial_images;
 static unsigned int __initdata nr_initial_images;
 
 unsigned long __init initial_images_nrpages(void)
@@ -149,7 +148,7 @@ unsigned long __init initial_images_nrpages(void)
     unsigned int i;
 
     for ( nr = i = 0; i < nr_initial_images; ++i )
-        nr += PFN_UP(initial_images[i].mod_end);
+        nr += PFN_UP(initial_images[i].end);
 
     return nr;
 }
@@ -160,10 +159,10 @@ void __init discard_initial_images(void)
 
     for ( i = 0; i < nr_initial_images; ++i )
     {
-        uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT;
+        uint64_t start = (uint64_t)initial_images[i].start << PAGE_SHIFT;
 
         init_domheap_pages(start,
-                           start + PAGE_ALIGN(initial_images[i].mod_end));
+                           start + PAGE_ALIGN(initial_images[i].end));
     }
 
     nr_initial_images = 0;
@@ -264,14 +263,14 @@ static void __init normalise_cpu_order(void)
  * Ensure a given physical memory range is present in the bootstrap mappings.
  * Use superpage mappings to ensure that pagetable memory needn't be allocated.
  */
-static void *__init bootstrap_map(const module_t *mod)
+static void *__init bootstrap_map(const boot_module_t *mod)
 {
     static unsigned long __initdata map_cur = BOOTSTRAP_MAP_BASE;
     uint64_t start, end, mask = (1L << L2_PAGETABLE_SHIFT) - 1;
     void *ret;
 
     if ( system_state != SYS_STATE_early_boot )
-        return mod ? mfn_to_virt(mod->mod_start) : NULL;
+        return mod ? mfn_to_virt(mod->start) : NULL;
 
     if ( !mod )
     {
@@ -280,8 +279,8 @@ static void *__init bootstrap_map(const module_t *mod)
         return NULL;
     }
 
-    start = (uint64_t)mod->mod_start << PAGE_SHIFT;
-    end = start + mod->mod_end;
+    start = (uint64_t)mod->start << PAGE_SHIFT;
+    end = start + mod->end;
     if ( start >= end )
         return NULL;
 
@@ -311,25 +310,25 @@ static void *__init move_memory(
 
     while ( size )
     {
-        module_t mod;
+        boot_module_t mod;
         unsigned int soffs = src & mask;
         unsigned int doffs = dst & mask;
         unsigned int sz;
         void *d, *s;
 
-        mod.mod_start = (src - soffs) >> PAGE_SHIFT;
-        mod.mod_end = soffs + size;
-        if ( mod.mod_end > blksz )
-            mod.mod_end = blksz;
-        sz = mod.mod_end - soffs;
+        mod.start = (src - soffs) >> PAGE_SHIFT;
+        mod.end = soffs + size;
+        if ( mod.end > blksz )
+            mod.end = blksz;
+        sz = mod.end - soffs;
         s = bootstrap_map(&mod);
 
-        mod.mod_start = (dst - doffs) >> PAGE_SHIFT;
-        mod.mod_end = doffs + size;
-        if ( mod.mod_end > blksz )
-            mod.mod_end = blksz;
-        if ( sz > mod.mod_end - doffs )
-            sz = mod.mod_end - doffs;
+        mod.start = (dst - doffs) >> PAGE_SHIFT;
+        mod.end = doffs + size;
+        if ( mod.end > blksz )
+            mod.end = blksz;
+        if ( sz > mod.end - doffs )
+            sz = mod.end - doffs;
         d = bootstrap_map(&mod);
 
         memmove(d + doffs, s + soffs, sz);
@@ -348,7 +347,7 @@ static void *__init move_memory(
 }
 
 static uint64_t __init consider_modules(
-    uint64_t s, uint64_t e, uint32_t size, const module_t *mod,
+    uint64_t s, uint64_t e, uint32_t size, const boot_module_t *mod,
     unsigned int nr_mods, unsigned int this_mod)
 {
     unsigned int i;
@@ -358,8 +357,8 @@ static uint64_t __init consider_modules(
 
     for ( i = 0; i < nr_mods ; ++i )
     {
-        uint64_t start = (uint64_t)mod[i].mod_start << PAGE_SHIFT;
-        uint64_t end = start + PAGE_ALIGN(mod[i].mod_end);
+        uint64_t start = (uint64_t)mod[i].start << PAGE_SHIFT;
+        uint64_t end = start + PAGE_ALIGN(mod[i].end);
 
         if ( i == this_mod )
             continue;
@@ -551,12 +550,10 @@ void __init enable_exception_support(void)
     /* Full exception support from here on in. */
 }
 
-void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
+void __init noreturn __start_xen(paddr_t boot_info_pa)
 {
     char *cmdline, *kextra;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
-    multiboot_info_t *mbi = __va(mbi_p);
-    module_t *mod = (module_t *)__va(mbi->mods_addr);
     unsigned long nr_pages, raw_max_page, modules_headroom, *module_map;
     int i, j;
     bool_t acpi_boot_table_init_done = 0;
@@ -673,7 +670,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
            bootsym(boot_edd_info_nr));
 
     /* Check that we have at least one Multiboot module. */
-    if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) )
+    if ( !boot_info->mods_nr )
         panic("dom0 kernel not specified. Check bootloader configuration.");
 
     if ( ((unsigned long)cpu0_stack & (STACK_SIZE-1)) != 0 )
@@ -708,8 +705,8 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
     set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT);
     kexec_reserve_area(&boot_e820);
 
-    initial_images = mod;
-    nr_initial_images = mbi->mods_count;
+    nr_initial_images = boot_info->mods_nr;
+    initial_images = boot_info->mods;
 
     /*
      * Iterate backwards over all superpage-aligned RAM regions.
@@ -724,16 +721,15 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
      * we can relocate the dom0 kernel and other multiboot modules. Also, on
      * x86/64, we relocate Xen to higher memory.
      */
-    for ( i = 0; !efi_enabled && i < mbi->mods_count; i++ )
+    for ( i = 0; !efi_enabled && i < boot_info->mods_nr; i++ )
     {
-        if ( mod[i].mod_start & (PAGE_SIZE - 1) )
+        if ( boot_info->mods[i].start & (PAGE_SIZE - 1) )
             panic("Bootloader didn't honor module alignment request.");
-        mod[i].mod_end -= mod[i].mod_start;
-        mod[i].mod_start >>= PAGE_SHIFT;
-        mod[i].reserved = 0;
+        boot_info->mods[i].end -= boot_info->mods[i].start;
+        boot_info->mods[i].start >>= PAGE_SHIFT;
     }
 
-    modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end);
+    modules_headroom = bzimage_headroom(bootstrap_map(boot_info->mods), boot_info->mods->end);
     bootstrap_map(NULL);
 
 #ifndef highmem_start
@@ -774,7 +770,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         {
             /* Don't overlap with modules. */
             end = consider_modules(s, e, reloc_size + mask,
-                                   mod, mbi->mods_count, -1);
+                                   boot_info->mods, boot_info->mods_nr, -1);
             end &= ~mask;
         }
         else
@@ -862,36 +858,36 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         }
 
         /* Is the region suitable for relocating the multiboot modules? */
-        for ( j = mbi->mods_count - 1; j >= 0; j-- )
+        for ( j = boot_info->mods_nr - 1; j >= 0; j-- )
         {
             unsigned long headroom = j ? 0 : modules_headroom;
-            unsigned long size = PAGE_ALIGN(headroom + mod[j].mod_end);
+            unsigned long size = PAGE_ALIGN(headroom + boot_info->mods[j].end);
 
-            if ( mod[j].reserved )
+            if ( boot_info->mods[j].relocated )
                 continue;
 
             /* Don't overlap with other modules. */
-            end = consider_modules(s, e, size, mod, mbi->mods_count, j);
+            end = consider_modules(s, e, size, boot_info->mods, boot_info->mods_nr, j);
 
             if ( highmem_start && end > highmem_start )
                 continue;
 
             if ( s < end &&
                  (headroom ||
-                  ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) )
+                  ((end - size) >> PAGE_SHIFT) > boot_info->mods[j].start) )
             {
                 move_memory(end - size + headroom,
-                            (uint64_t)mod[j].mod_start << PAGE_SHIFT,
-                            mod[j].mod_end, 0);
-                mod[j].mod_start = (end - size) >> PAGE_SHIFT;
-                mod[j].mod_end += headroom;
-                mod[j].reserved = 1;
+                            (uint64_t)boot_info->mods[j].start << PAGE_SHIFT,
+                            boot_info->mods[j].end, 0);
+                boot_info->mods[j].start = (end - size) >> PAGE_SHIFT;
+                boot_info->mods[j].end += headroom;
+                boot_info->mods[j].relocated = 1;
             }
         }
 
         /* Don't overlap with modules. */
         e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size),
-                             mod, mbi->mods_count, -1);
+                             boot_info->mods, boot_info->mods_nr, -1);
         if ( !kexec_crash_area.start && (s < e) )
         {
             e = (e - kexec_crash_area.size) & PAGE_MASK;
@@ -899,18 +895,18 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         }
     }
 
-    if ( modules_headroom && !mod->reserved )
+    if ( modules_headroom && !boot_info->mods->relocated )
         panic("Not enough memory to relocate the dom0 kernel image.");
-    for ( i = 0; i < mbi->mods_count; ++i )
+    for ( i = 0; i < boot_info->mods_nr; ++i )
     {
-        uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT;
+        uint64_t s = (uint64_t)boot_info->mods[i].start << PAGE_SHIFT;
 
-        reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(mod[i].mod_end));
+        reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(boot_info->mods[i].end));
     }
 
     if ( !xen_phys_start )
         panic("Not enough memory to relocate Xen.");
-    reserve_e820_ram(&boot_e820, efi_enabled ? mbi->mem_upper : __pa(&_start),
+    reserve_e820_ram(&boot_e820, efi_enabled ? boot_info->mem_upper : __pa(&_start),
                      __pa(&_end));
 
     /* Late kexec reservation (dynamic start address). */
@@ -956,10 +952,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
                     ASSERT(j);
                 }
                 map_e = boot_e820.map[j].addr + boot_e820.map[j].size;
-                for ( j = 0; j < mbi->mods_count; ++j )
+                for ( j = 0; j < boot_info->mods_nr; ++j )
                 {
-                    uint64_t end = pfn_to_paddr(mod[j].mod_start) +
-                                   mod[j].mod_end;
+                    uint64_t end = pfn_to_paddr(boot_info->mods[j].start) +
+                                   boot_info->mods[j].end;
 
                     if ( map_e < end )
                         map_e = end;
@@ -1032,13 +1028,13 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
         }
     }
 
-    for ( i = 0; i < mbi->mods_count; ++i )
+    for ( i = 0; i < boot_info->mods_nr; ++i )
     {
-        set_pdx_range(mod[i].mod_start,
-                      mod[i].mod_start + PFN_UP(mod[i].mod_end));
-        map_pages_to_xen((unsigned long)mfn_to_virt(mod[i].mod_start),
-                         mod[i].mod_start,
-                         PFN_UP(mod[i].mod_end), PAGE_HYPERVISOR);
+        set_pdx_range(boot_info->mods[i].start,
+                      boot_info->mods[i].start + PFN_UP(boot_info->mods[i].end));
+        map_pages_to_xen((unsigned long)mfn_to_virt(boot_info->mods[i].start),
+                         boot_info->mods[i].start,
+                         PFN_UP(boot_info->mods[i].end), PAGE_HYPERVISOR);
     }
 
     if ( kexec_crash_area.size )
@@ -1192,13 +1188,13 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
 
     init_IRQ();
 
-    module_map = xmalloc_array(unsigned long, BITS_TO_LONGS(mbi->mods_count));
-    bitmap_fill(module_map, mbi->mods_count);
+    module_map = xmalloc_array(unsigned long, BITS_TO_LONGS(boot_info->mods_nr));
+    bitmap_fill(module_map, boot_info->mods_nr);
     __clear_bit(0, module_map); /* Dom0 kernel is always first */
 
-    xsm_multiboot_init(module_map, mbi, bootstrap_map);
+    xsm_multiboot_init(module_map, boot_info, bootstrap_map);
 
-    microcode_grab_module(module_map, mbi, bootstrap_map);
+    microcode_grab_module(module_map, boot_info, bootstrap_map);
 
     timer_init();
 
@@ -1303,7 +1299,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
     dom0->target = NULL;
 
     /* Grab the DOM0 command line. */
-    cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
+    cmdline = (char *)(boot_info->mods[0].cmdline ? __va(boot_info->mods[0].cmdline) : NULL);
     if ( (cmdline != NULL) || (kextra != NULL) )
     {
         static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE];
@@ -1335,8 +1331,8 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
     if ( xen_cpuidle )
         xen_processor_pmbits |= XEN_PROCESSOR_PM_CX;
 
-    initrdidx = find_first_bit(module_map, mbi->mods_count);
-    if ( bitmap_weight(module_map, mbi->mods_count) > 1 )
+    initrdidx = find_first_bit(module_map, boot_info->mods_nr);
+    if ( bitmap_weight(module_map, boot_info->mods_nr) > 1 )
         printk(XENLOG_WARNING
                "Multiple initrd candidates, picking module #%u\n",
                initrdidx);
@@ -1353,9 +1349,9 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
      * We're going to setup domain0 using the module(s) that we stashed safely
      * above our heap. The second module, if present, is an initrd ramdisk.
      */
-    if ( construct_dom0(dom0, mod, modules_headroom,
-                        (initrdidx > 0) && (initrdidx < mbi->mods_count)
-                        ? mod + initrdidx : NULL,
+    if ( construct_dom0(dom0, boot_info->mods, modules_headroom,
+                        (initrdidx > 0) && (initrdidx < boot_info->mods_nr)
+                        ? boot_info->mods + initrdidx : NULL,
                         bootstrap_map, cmdline) != 0)
         panic("Could not set up DOM0 guest OS");
 
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index f272171..43f2939 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -10,7 +10,6 @@
 #include <xen/keyhandler.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
-#include <xen/multiboot.h>
 #include <xen/pci_regs.h>
 #include <xen/pfn.h>
 #if EFI_PAGE_SIZE != PAGE_SIZE
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 865d0bc..b5ee6e0 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -56,6 +56,8 @@ const struct efi_pci_rom *__read_mostly efi_pci_roms;
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 extern struct e820entry e820map[];
 
+static boot_module_t __read_mostly boot_info_mods[3] = {};
+
 boot_info_t __read_mostly boot_info_efi = {
     .boot_loader_name = "EFI",
     .cmdline = NULL,
@@ -63,6 +65,8 @@ boot_info_t __read_mostly boot_info_efi = {
     .mem_upper = 0,
     .e820map_nr = 0,
     .e820map = e820map,
+    .mods_nr = 0,
+    .mods = boot_info_mods,
     .warn_msg = NULL,
     .err_msg = NULL
 };
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index 640a420..342ee7a 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -21,6 +21,7 @@
 #include <xen/types.h>
 
 #include <asm/e820.h>
+#include <asm/mbd.h>
 
 /*
  * Define boot_info type. It will be used to define variable which in turn
@@ -57,6 +58,12 @@ typedef struct {
      */
     struct e820entry *e820map;
 
+    /* Number of modules. */
+    unsigned int mods_nr;
+
+    /* Pointer to modules description. */
+    boot_module_t *mods;
+
     /*
      * Info about warning occurred during boot_info initialization.
      * NULL if everything went OK.
diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h
index 8f8c6f3..75b5c5a 100644
--- a/xen/include/asm-x86/setup.h
+++ b/xen/include/asm-x86/setup.h
@@ -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;
 
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 4ce089f..b6369ba 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -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);
@@ -671,11 +671,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
@@ -695,8 +695,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;
 }
diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
index 0ac6d03..39b7ff6 100644
--- a/xen/xsm/xsm_core.c
+++ b/xen/xsm/xsm_core.c
@@ -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);
diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c
index 6e0bb78..aa30c21 100644
--- a/xen/xsm/xsm_policy.c
+++ b/xen/xsm/xsm_policy.c
@@ -33,11 +33,11 @@ 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);
+    boot_module_t *mod = (boot_module_t *)__va(boot_info->mods);
     int rc = 0;
     u32 *_policy_start;
     unsigned long _policy_len;
@@ -46,13 +46,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_len   = mod[i].end;
 
         if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC )
         {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 11/16] x86: Move EFI memory map stuff to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (9 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 10/16] x86: Move modules data from mbi to boot_info and remove mbi Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 12/16] x86: Move MPS, ACPI and SMBIOS data " Daniel Kiper
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c        |    3 +++
 xen/common/efi/efi.h            |    6 +++++-
 xen/common/efi/runtime.c        |   11 +++++++----
 xen/include/asm-x86/boot_info.h |    9 +++++++++
 4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 9f7c4a5..ce6f266 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -42,6 +42,9 @@ static boot_info_t __read_mostly boot_info_mb = {
     .mem_upper = 0,
     .e820map_nr = 0,
     .e820map = NULL,
+    .efi_mmap_size = 0,
+    .efi_mmap_desc_size = 0,
+    .efi_mmap = NULL,
     .mods_nr = 0,
     .mods = NULL,
     .warn_msg = NULL,
diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
index 526f57c..214651b 100644
--- a/xen/common/efi/efi.h
+++ b/xen/common/efi/efi.h
@@ -30,10 +30,14 @@ extern EFI_RUNTIME_SERVICES *efi_rs;
 
 #ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
 extern boot_info_t boot_info_efi;
-#endif
 
+#define efi_memmap_size		boot_info_efi.efi_mmap_size
+#define efi_mdesc_size		boot_info_efi.efi_mmap_desc_size
+#define efi_memmap		boot_info_efi.efi_mmap
+#else
 extern UINTN efi_memmap_size, efi_mdesc_size;
 extern void *efi_memmap;
+#endif
 
 #ifdef CONFIG_X86
 extern l4_pgentry_t *efi_l4_pgtable;
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index b5ee6e0..98991f9 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -36,10 +36,6 @@ EFI_RUNTIME_SERVICES *__read_mostly efi_rs;
 static DEFINE_SPINLOCK(efi_rs_lock);
 #endif
 
-UINTN __read_mostly efi_memmap_size;
-UINTN __read_mostly efi_mdesc_size;
-void *__read_mostly efi_memmap;
-
 UINT64 __read_mostly efi_boot_max_var_store_size;
 UINT64 __read_mostly efi_boot_remain_var_store_size;
 UINT64 __read_mostly efi_boot_max_var_size;
@@ -65,11 +61,18 @@ boot_info_t __read_mostly boot_info_efi = {
     .mem_upper = 0,
     .e820map_nr = 0,
     .e820map = e820map,
+    .efi_mmap_size = 0,
+    .efi_mmap_desc_size = 0,
+    .efi_mmap = NULL,
     .mods_nr = 0,
     .mods = boot_info_mods,
     .warn_msg = NULL,
     .err_msg = NULL
 };
+#else
+UINTN __read_mostly efi_memmap_size;
+UINTN __read_mostly efi_mdesc_size;
+void *__read_mostly efi_memmap;
 #endif
 
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index 342ee7a..59586ef 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -58,6 +58,15 @@ typedef struct {
      */
     struct e820entry *e820map;
 
+    /* Size (in bytes) of EFI memory map provided by Xen preloader. */
+    size_t efi_mmap_size;
+
+    /* Size (in bytes) of EFI memory map descriptor provided by Xen preloader. */
+    size_t efi_mmap_desc_size;
+
+    /* Pointer to EFI memory map provided by preloader. */
+    void *efi_mmap;
+
     /* Number of modules. */
     unsigned int mods_nr;
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 12/16] x86: Move MPS, ACPI and SMBIOS data to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (10 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 11/16] x86: Move EFI memory map stuff to boot_info Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 13/16] x86: Move video " Daniel Kiper
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c        |    5 +++++
 xen/arch/x86/dmi_scan.c         |   11 ++++++++---
 xen/arch/x86/mpparse.c          |   13 +++++++++----
 xen/common/efi/runtime.c        |   18 +++++++++++-------
 xen/drivers/acpi/osl.c          |   13 +++++++++----
 xen/include/asm-x86/boot_info.h |   12 ++++++++++++
 xen/include/xen/efi.h           |    7 +++++++
 7 files changed, 61 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index ce6f266..8b49036 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -22,6 +22,7 @@
 
 #include <xen/types.h>
 #include <xen/cache.h>
+#include <xen/efi.h>
 #include <xen/init.h>
 #include <xen/multiboot.h>
 
@@ -45,6 +46,10 @@ static boot_info_t __read_mostly boot_info_mb = {
     .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,
     .mods_nr = 0,
     .mods = NULL,
     .warn_msg = NULL,
diff --git a/xen/arch/x86/dmi_scan.c b/xen/arch/x86/dmi_scan.c
index 500133a..94f81f3 100644
--- a/xen/arch/x86/dmi_scan.c
+++ b/xen/arch/x86/dmi_scan.c
@@ -12,6 +12,11 @@
 #include <xen/efi.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
+#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
+#include <asm/boot_info.h>
+#else
+#define boot_info	(&efi)
+#endif
 
 #define bt_ioremap(b,l)  ((void *)__acpi_map_table(b,l))
 #define bt_iounmap(b,l)  ((void)0)
@@ -215,10 +220,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 +232,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) &&
diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c
index a38e016..8de39aa 100644
--- a/xen/arch/x86/mpparse.c
+++ b/xen/arch/x86/mpparse.c
@@ -29,6 +29,11 @@
 #include <asm/mpspec.h>
 #include <asm/io_apic.h>
 #include <asm/setup.h>
+#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
+#include <asm/boot_info.h>
+#else
+#define boot_info	(&efi)
+#endif
 
 #include <mach_apic.h>
 #include <mach_mpparse.h>
@@ -676,18 +681,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
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 98991f9..8c37b28 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -40,13 +40,6 @@ UINT64 __read_mostly efi_boot_max_var_store_size;
 UINT64 __read_mostly efi_boot_remain_var_store_size;
 UINT64 __read_mostly efi_boot_max_var_size;
 
-struct efi __read_mostly efi = {
-	.acpi   = EFI_INVALID_TABLE_ADDR,
-	.acpi20 = EFI_INVALID_TABLE_ADDR,
-	.mps    = EFI_INVALID_TABLE_ADDR,
-	.smbios = EFI_INVALID_TABLE_ADDR,
-};
-
 const struct efi_pci_rom *__read_mostly efi_pci_roms;
 
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
@@ -64,6 +57,10 @@ boot_info_t __read_mostly boot_info_efi = {
     .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,
     .mods_nr = 0,
     .mods = boot_info_mods,
     .warn_msg = NULL,
@@ -73,6 +70,13 @@ boot_info_t __read_mostly boot_info_efi = {
 UINTN __read_mostly efi_memmap_size;
 UINTN __read_mostly efi_mdesc_size;
 void *__read_mostly efi_memmap;
+
+struct efi __read_mostly efi = {
+	.acpi   = EFI_INVALID_TABLE_ADDR,
+	.acpi20 = EFI_INVALID_TABLE_ADDR,
+	.mps    = EFI_INVALID_TABLE_ADDR,
+	.smbios = EFI_INVALID_TABLE_ADDR,
+};
 #endif
 
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 93c983c..ab48aad 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -39,6 +39,11 @@
 #include <xen/domain_page.h>
 #include <xen/efi.h>
 #include <xen/vmap.h>
+#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
+#include <asm/boot_info.h>
+#else
+#define boot_info	(&efi)
+#endif
 
 #define _COMPONENT		ACPI_OS_SERVICES
 ACPI_MODULE_NAME("osl")
@@ -67,10 +72,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");
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index 59586ef..7444876 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -67,6 +67,18 @@ typedef struct {
     /* Pointer to EFI memory map provided by preloader. */
     void *efi_mmap;
 
+    /* MPS physical address. */
+    paddr_t mps;
+
+    /* ACPI RSDP physical address. */
+    paddr_t acpi;
+
+    /* ACPI 2.0 RSDP physical address. */
+    paddr_t acpi20;
+
+    /* SMBIOS physical address. */
+    paddr_t smbios;
+
     /* Number of modules. */
     unsigned int mods_nr;
 
diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
index 8a2b788..75b14db 100644
--- a/xen/include/xen/efi.h
+++ b/xen/include/xen/efi.h
@@ -3,12 +3,18 @@
 
 #ifndef __ASSEMBLY__
 #include <xen/types.h>
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+#include <asm/boot_info.h>
+#endif
 #endif
 
 extern const bool_t efi_enabled;
 
 #define EFI_INVALID_TABLE_ADDR (~0UL)
 
+#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
+#define efi	boot_info_efi
+#else
 /* Add fields here only if they need to be referenced from non-EFI code. */
 struct efi {
     unsigned long mps;          /* MPS table */
@@ -18,6 +24,7 @@ struct efi {
 };
 
 extern struct efi efi;
+#endif
 
 #ifndef __ASSEMBLY__
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 13/16] x86: Move video data to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (11 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 12/16] x86: Move MPS, ACPI and SMBIOS data " Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 14/16] x86: Move HDD " Daniel Kiper
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Move video data to boot_info.

This commit reveals a bug which probably was introduced between commit
3e2331d271cc0882e4013c8f20398c46c35f90a1 (VT-d: suppress UR signaling for
further desktop chipsets) and 61fdda7acf3de11f3d50d50e5b4f4ecfac7e0d04
(x86/HVM: properly bound x2APIC MSR range). Xen crashes at video_endboot()
because earlier scrub process wipes vga_console_info data (sic!). So,
it means that at least page containing this structure was freed mistakenly
somewhere. Interestingly this issue appears on legacy BIOS machines only.
EFI platforms work as usual. It is possible to workaround this bug by
passing no-bootscrub to xen.gz.

I was not able to spot anything obvious just looking briefly at commit history.
I am going to narrow down and fix this issue in next release.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c          |   78 ++++++++++++++++++++++++++++++
 xen/arch/x86/efi/efi-boot.h       |   74 ++++++++++++++---------------
 xen/arch/x86/platform_hypercall.c |    9 ++--
 xen/arch/x86/setup.c              |   94 +++++--------------------------------
 xen/common/efi/runtime.c          |    6 +++
 xen/drivers/video/vesa.c          |    7 +--
 xen/drivers/video/vga.c           |   18 ++++---
 xen/include/asm-x86/boot_info.h   |    8 ++++
 xen/include/asm-x86/config.h      |    2 -
 xen/include/xen/vga.h             |   18 -------
 10 files changed, 157 insertions(+), 157 deletions(-)
 delete mode 100644 xen/include/xen/vga.h

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 8b49036..48d5274 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -31,11 +31,46 @@
 #include <asm/mbd.h>
 #include <asm/page.h>
 
+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 unsigned 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];
+
 static boot_info_t __read_mostly boot_info_mb = {
     .boot_loader_name = "UNKNOWN",
     .cmdline = NULL,
@@ -50,6 +85,9 @@ static boot_info_t __read_mostly boot_info_mb = {
     .acpi = EFI_INVALID_TABLE_ADDR,
     .acpi20 = EFI_INVALID_TABLE_ADDR,
     .smbios = EFI_INVALID_TABLE_ADDR,
+    .vga_console_info = {},
+    .edid_caps = 0,
+    .edid_info = NULL,
     .mods_nr = 0,
     .mods = NULL,
     .warn_msg = NULL,
@@ -138,6 +176,44 @@ static void __init init_mmap(boot_info_t *boot_info, mbd_t *mbd)
     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);
+}
+
 paddr_t __init __init_boot_info(u32 mbd_pa)
 {
     mbd_t *mbd = __va(mbd_pa);
@@ -155,6 +231,8 @@ paddr_t __init __init_boot_info(u32 mbd_pa)
     if ( boot_info_mb.err_msg )
         goto err;
 
+    init_video_info(&boot_info_mb);
+
     boot_info_mb.mods_nr = mbd->mods_nr;
     boot_info_mb.mods = __va(mbd->mods);
 
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 3a6e7ec..ee5b54b 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -3,7 +3,7 @@
  * is intended to be included by common/efi/boot.c _only_, and
  * therefore can define arch specific global variables.
  */
-#include <xen/vga.h>
+#include <xen/video.h>
 #include <asm/e820.h>
 #include <asm/edd.h>
 #include <asm/msr.h>
@@ -454,10 +454,10 @@ static void __init efi_arch_edd(void)
 
 static void __init efi_arch_console_init(UINTN cols, UINTN rows)
 {
-    vga_console_info.video_type = XEN_VGATYPE_TEXT_MODE_3;
-    vga_console_info.u.text_mode_3.columns = cols;
-    vga_console_info.u.text_mode_3.rows = rows;
-    vga_console_info.u.text_mode_3.font_height = 16;
+    boot_info_efi.vga_console_info.video_type = XEN_VGATYPE_TEXT_MODE_3;
+    boot_info_efi.vga_console_info.u.text_mode_3.columns = cols;
+    boot_info_efi.vga_console_info.u.text_mode_3.rows = rows;
+    boot_info_efi.vga_console_info.u.text_mode_3.font_height = 16;
 }
 
 static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
@@ -469,40 +469,40 @@ static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
     switch ( mode_info->PixelFormat )
     {
     case PixelRedGreenBlueReserved8BitPerColor:
-        vga_console_info.u.vesa_lfb.red_pos = 0;
-        vga_console_info.u.vesa_lfb.red_size = 8;
-        vga_console_info.u.vesa_lfb.green_pos = 8;
-        vga_console_info.u.vesa_lfb.green_size = 8;
-        vga_console_info.u.vesa_lfb.blue_pos = 16;
-        vga_console_info.u.vesa_lfb.blue_size = 8;
-        vga_console_info.u.vesa_lfb.rsvd_pos = 24;
-        vga_console_info.u.vesa_lfb.rsvd_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.red_pos = 0;
+        boot_info_efi.vga_console_info.u.vesa_lfb.red_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.green_pos = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.green_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.blue_pos = 16;
+        boot_info_efi.vga_console_info.u.vesa_lfb.blue_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.rsvd_pos = 24;
+        boot_info_efi.vga_console_info.u.vesa_lfb.rsvd_size = 8;
         bpp = 32;
         break;
     case PixelBlueGreenRedReserved8BitPerColor:
-        vga_console_info.u.vesa_lfb.red_pos = 16;
-        vga_console_info.u.vesa_lfb.red_size = 8;
-        vga_console_info.u.vesa_lfb.green_pos = 8;
-        vga_console_info.u.vesa_lfb.green_size = 8;
-        vga_console_info.u.vesa_lfb.blue_pos = 0;
-        vga_console_info.u.vesa_lfb.blue_size = 8;
-        vga_console_info.u.vesa_lfb.rsvd_pos = 24;
-        vga_console_info.u.vesa_lfb.rsvd_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.red_pos = 16;
+        boot_info_efi.vga_console_info.u.vesa_lfb.red_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.green_pos = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.green_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.blue_pos = 0;
+        boot_info_efi.vga_console_info.u.vesa_lfb.blue_size = 8;
+        boot_info_efi.vga_console_info.u.vesa_lfb.rsvd_pos = 24;
+        boot_info_efi.vga_console_info.u.vesa_lfb.rsvd_size = 8;
         bpp = 32;
         break;
     case PixelBitMask:
         bpp = set_color(mode_info->PixelInformation.RedMask, bpp,
-                        &vga_console_info.u.vesa_lfb.red_pos,
-                        &vga_console_info.u.vesa_lfb.red_size);
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.red_pos,
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.red_size);
         bpp = set_color(mode_info->PixelInformation.GreenMask, bpp,
-                        &vga_console_info.u.vesa_lfb.green_pos,
-                        &vga_console_info.u.vesa_lfb.green_size);
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.green_pos,
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.green_size);
         bpp = set_color(mode_info->PixelInformation.BlueMask, bpp,
-                        &vga_console_info.u.vesa_lfb.blue_pos,
-                        &vga_console_info.u.vesa_lfb.blue_size);
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.blue_pos,
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.blue_size);
         bpp = set_color(mode_info->PixelInformation.ReservedMask, bpp,
-                        &vga_console_info.u.vesa_lfb.rsvd_pos,
-                        &vga_console_info.u.vesa_lfb.rsvd_size);
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.rsvd_pos,
+                        &boot_info_efi.vga_console_info.u.vesa_lfb.rsvd_size);
         if ( bpp > 0 )
             break;
         /* fall through */
@@ -513,16 +513,16 @@ static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
     }
     if ( bpp > 0 )
     {
-        vga_console_info.video_type = XEN_VGATYPE_EFI_LFB;
-        vga_console_info.u.vesa_lfb.gbl_caps = 2; /* possibly non-VGA */
-        vga_console_info.u.vesa_lfb.width =
+        boot_info_efi.vga_console_info.video_type = XEN_VGATYPE_EFI_LFB;
+        boot_info_efi.vga_console_info.u.vesa_lfb.gbl_caps = 2; /* possibly non-VGA */
+        boot_info_efi.vga_console_info.u.vesa_lfb.width =
             mode_info->HorizontalResolution;
-        vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution;
-        vga_console_info.u.vesa_lfb.bits_per_pixel = bpp;
-        vga_console_info.u.vesa_lfb.bytes_per_line =
+        boot_info_efi.vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution;
+        boot_info_efi.vga_console_info.u.vesa_lfb.bits_per_pixel = bpp;
+        boot_info_efi.vga_console_info.u.vesa_lfb.bytes_per_line =
             (mode_info->PixelsPerScanLine * bpp + 7) >> 3;
-        vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase;
-        vga_console_info.u.vesa_lfb.lfb_size =
+        boot_info_efi.vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase;
+        boot_info_efi.vga_console_info.u.vesa_lfb.lfb_size =
             (gop->Mode->FrameBufferSize + 0xffff) >> 16;
     }
 }
diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index 32f39b2..7687dd1 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -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>
 
@@ -357,13 +358,13 @@ 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);
+                boot_info->edid_caps;
             op->u.firmware_info.u.vbeddc_info.edid_transfer_time =
-                bootsym(boot_edid_caps) >> 8;
+                boot_info->edid_caps >> 8;
 
             ret = 0;
             if ( __copy_field_to_guest(u_xenpf_op, op, u.firmware_info.
@@ -371,7 +372,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:
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 0e48726..9b41172 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -20,7 +20,7 @@
 #include <xen/keyhandler.h>
 #include <xen/numa.h>
 #include <xen/rcupdate.h>
-#include <xen/vga.h>
+#include <xen/video.h>
 #include <xen/dmi.h>
 #include <xen/pfn.h>
 #include <xen/nodemask.h>
@@ -397,76 +397,6 @@ static void __init setup_max_pdx(unsigned long top_page)
 /* A temporary copy of the e820 map that we can mess with during bootstrap. */
 static struct e820map __initdata boot_e820;
 
-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 */
-};
-extern struct boot_video_info boot_vid_info;
-
-static void __init parse_video_info(void)
-{
-    struct boot_video_info *bvi = &bootsym(boot_vid_info);
-
-    /* The EFI loader fills vga_console_info directly. */
-    if ( efi_enabled )
-        return;
-
-    if ( (bvi->orig_video_isVGA == 1) && (bvi->orig_video_mode == 3) )
-    {
-        vga_console_info.video_type = XEN_VGATYPE_TEXT_MODE_3;
-        vga_console_info.u.text_mode_3.font_height = bvi->orig_video_points;
-        vga_console_info.u.text_mode_3.cursor_x = bvi->orig_x;
-        vga_console_info.u.text_mode_3.cursor_y = bvi->orig_y;
-        vga_console_info.u.text_mode_3.rows = bvi->orig_video_lines;
-        vga_console_info.u.text_mode_3.columns = bvi->orig_video_cols;
-    }
-    else if ( bvi->orig_video_isVGA == 0x23 )
-    {
-        vga_console_info.video_type = XEN_VGATYPE_VESA_LFB;
-        vga_console_info.u.vesa_lfb.width = bvi->lfb_width;
-        vga_console_info.u.vesa_lfb.height = bvi->lfb_height;
-        vga_console_info.u.vesa_lfb.bytes_per_line = bvi->lfb_linelength;
-        vga_console_info.u.vesa_lfb.bits_per_pixel = bvi->lfb_depth;
-        vga_console_info.u.vesa_lfb.lfb_base = bvi->lfb_base;
-        vga_console_info.u.vesa_lfb.lfb_size = bvi->lfb_size;
-        vga_console_info.u.vesa_lfb.red_pos = bvi->red_pos;
-        vga_console_info.u.vesa_lfb.red_size = bvi->red_size;
-        vga_console_info.u.vesa_lfb.green_pos = bvi->green_pos;
-        vga_console_info.u.vesa_lfb.green_size = bvi->green_size;
-        vga_console_info.u.vesa_lfb.blue_pos = bvi->blue_pos;
-        vga_console_info.u.vesa_lfb.blue_size = bvi->blue_size;
-        vga_console_info.u.vesa_lfb.rsvd_pos = bvi->rsvd_pos;
-        vga_console_info.u.vesa_lfb.rsvd_size = bvi->rsvd_size;
-        vga_console_info.u.vesa_lfb.gbl_caps = bvi->capabilities;
-        vga_console_info.u.vesa_lfb.mode_attrs = bvi->vesa_attrib;
-    }
-}
-
 static void __init kexec_reserve_area(struct e820map *e820)
 {
     unsigned long kdump_start = kexec_crash_area.start;
@@ -593,8 +523,6 @@ void __init noreturn __start_xen(paddr_t boot_info_pa)
      * allocing any xenheap structures wanted in lower memory. */
     kexec_early_calculations();
 
-    parse_video_info();
-
     if ( cpu_has_efer )
         rdmsrl(MSR_EFER, this_cpu(efer));
     asm volatile ( "mov %%cr4,%0" : "=r" (this_cpu(cr4)) );
@@ -622,20 +550,20 @@ void __init noreturn __start_xen(paddr_t boot_info_pa)
     printk("Video information:\n");
 
     /* Print VGA display mode information. */
-    switch ( vga_console_info.video_type )
+    switch ( boot_info->vga_console_info.video_type )
     {
     case XEN_VGATYPE_TEXT_MODE_3:
         printk(" VGA is text mode %dx%d, font 8x%d\n",
-               vga_console_info.u.text_mode_3.columns,
-               vga_console_info.u.text_mode_3.rows,
-               vga_console_info.u.text_mode_3.font_height);
+               boot_info->vga_console_info.u.text_mode_3.columns,
+               boot_info->vga_console_info.u.text_mode_3.rows,
+               boot_info->vga_console_info.u.text_mode_3.font_height);
         break;
     case XEN_VGATYPE_VESA_LFB:
     case XEN_VGATYPE_EFI_LFB:
         printk(" VGA is graphics mode %dx%d, %d bpp\n",
-               vga_console_info.u.vesa_lfb.width,
-               vga_console_info.u.vesa_lfb.height,
-               vga_console_info.u.vesa_lfb.bits_per_pixel);
+               boot_info->vga_console_info.u.vesa_lfb.width,
+               boot_info->vga_console_info.u.vesa_lfb.height,
+               boot_info->vga_console_info.u.vesa_lfb.bits_per_pixel);
         break;
     default:
         printk(" No VGA detected\n");
@@ -643,15 +571,15 @@ void __init noreturn __start_xen(paddr_t boot_info_pa)
     }
 
     /* Print VBE/DDC EDID information. */
-    if ( bootsym(boot_edid_caps) != 0x1313 )
+    if ( boot_info->edid_caps != 0x1313 )
     {
-        u16 caps = bootsym(boot_edid_caps);
+        u16 caps = boot_info->edid_caps;
         printk(" VBE/DDC methods:%s%s%s; ",
                (caps & 1) ? " V1" : "",
                (caps & 2) ? " V2" : "",
                !(caps & 3) ? " none" : "");
         printk("EDID transfer time: %d seconds\n", caps >> 8);
-        if ( *(u32 *)bootsym(boot_edid_info) == 0x13131313 )
+        if ( *(u32 *)boot_info->edid_info == 0x13131313 )
         {
             printk(" EDID info not retrieved because ");
             if ( !(caps & 3) )
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 8c37b28..988464f 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -5,6 +5,7 @@
 #include <xen/guest_access.h>
 #include <xen/irq.h>
 #include <xen/time.h>
+#include <xen/video.h>
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 #include <asm/boot_info.h>
 #include <asm/e820.h>
@@ -45,6 +46,8 @@ const struct efi_pci_rom *__read_mostly efi_pci_roms;
 #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
 extern struct e820entry e820map[];
 
+extern unsigned char boot_edid_info[128];
+
 static boot_module_t __read_mostly boot_info_mods[3] = {};
 
 boot_info_t __read_mostly boot_info_efi = {
@@ -61,6 +64,9 @@ boot_info_t __read_mostly boot_info_efi = {
     .acpi = EFI_INVALID_TABLE_ADDR,
     .acpi20 = EFI_INVALID_TABLE_ADDR,
     .smbios = EFI_INVALID_TABLE_ADDR,
+    .vga_console_info = {},
+    .edid_caps = 0,
+    .edid_info = boot_edid_info,
     .mods_nr = 0,
     .mods = boot_info_mods,
     .warn_msg = NULL,
diff --git a/xen/drivers/video/vesa.c b/xen/drivers/video/vesa.c
index 575db62..942a356 100644
--- a/xen/drivers/video/vesa.c
+++ b/xen/drivers/video/vesa.c
@@ -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;
diff --git a/xen/drivers/video/vga.c b/xen/drivers/video/vga.c
index 40e5963..608d92b 100644
--- a/xen/drivers/video/vga.c
+++ b/xen/drivers/video/vga.c
@@ -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;
 }
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index 7444876..df31627 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -19,6 +19,7 @@
 #define __BOOT_INFO_H__
 
 #include <xen/types.h>
+#include <xen/video.h>
 
 #include <asm/e820.h>
 #include <asm/mbd.h>
@@ -79,6 +80,13 @@ typedef struct {
     /* SMBIOS physical address. */
     paddr_t smbios;
 
+    /* VGA console info. */
+    struct xen_vga_console_info vga_console_info;
+
+    /* EDID info. */
+    unsigned short edid_caps;
+    unsigned char *edid_info;
+
     /* Number of modules. */
     unsigned int mods_nr;
 
diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h
index 210ff57..ae68322 100644
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -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
diff --git a/xen/include/xen/vga.h b/xen/include/xen/vga.h
deleted file mode 100644
index f72b63d..0000000
--- a/xen/include/xen/vga.h
+++ /dev/null
@@ -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 */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 14/16] x86: Move HDD data to boot_info
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (12 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 13/16] x86: Move video " Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 15/16] x86/boot: Use %ecx instead of %eax Daniel Kiper
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot_info.c          |   16 ++++++++++++++++
 xen/arch/x86/efi/efi-boot.h       |   28 ++++++++++++++--------------
 xen/arch/x86/platform_hypercall.c |    8 ++++----
 xen/arch/x86/setup.c              |    4 ++--
 xen/common/efi/runtime.c          |    7 +++++++
 xen/include/asm-x86/boot_info.h   |   13 +++++++++++++
 xen/include/asm-x86/edd.h         |    6 ------
 7 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 48d5274..4f38edf 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -71,6 +71,12 @@ 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,
@@ -88,6 +94,10 @@ static boot_info_t __read_mostly boot_info_mb = {
     .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,
@@ -233,6 +243,12 @@ paddr_t __init __init_boot_info(u32 mbd_pa)
 
     init_video_info(&boot_info_mb);
 
+    boot_info_mb.edd_info_nr = bootsym(boot_edd_info_nr);
+    boot_info_mb.edd_info = bootsym(boot_edd_info);
+
+    boot_info_mb.mbr_signature_nr = bootsym(boot_mbr_signature_nr);
+    boot_info_mb.mbr_signature = bootsym(boot_mbr_signature);
+
     boot_info_mb.mods_nr = mbd->mods_nr;
     boot_info_mb.mods = __va(mbd->mods);
 
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index ee5b54b..b5ff624 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -325,7 +325,7 @@ static void __init efi_arch_edd(void)
     {
         EFI_BLOCK_IO *bio;
         EFI_DEV_PATH_PTR devp;
-        struct edd_info *info = boot_edd_info + boot_edd_info_nr;
+        struct edd_info *info = boot_info_efi.edd_info + boot_info_efi.edd_info_nr;
         struct edd_device_params *params = &info->edd_device_params;
         enum { root, acpi, pci, ctrlr } state = root;
 
@@ -334,16 +334,16 @@ static void __init efi_arch_edd(void)
              bio->Media->RemovableMedia ||
              bio->Media->LogicalPartition )
             continue;
-        if ( boot_edd_info_nr < EDD_INFO_MAX )
+        if ( boot_info_efi.edd_info_nr < EDD_INFO_MAX )
         {
-            info->device = 0x80 + boot_edd_info_nr; /* fake */
+            info->device = 0x80 + boot_info_efi.edd_info_nr; /* fake */
             info->version = 0x11;
             params->length = offsetof(struct edd_device_params, dpte_ptr);
             params->number_of_sectors = bio->Media->LastBlock + 1;
             params->bytes_per_sector = bio->Media->BlockSize;
             params->dpte_ptr = ~0;
         }
-        ++boot_edd_info_nr;
+        ++boot_info_efi.edd_info_nr;
         status = efi_bs->HandleProtocol(handles[i], &devp_guid,
                                         (void **)&devp);
         if ( EFI_ERROR(status) )
@@ -356,7 +356,7 @@ static void __init efi_arch_edd(void)
                 const u8 *p;
 
             case ACPI_DEVICE_PATH:
-                if ( state != root || boot_edd_info_nr > EDD_INFO_MAX )
+                if ( state != root || boot_info_efi.edd_info_nr > EDD_INFO_MAX )
                     break;
                 switch ( DevicePathSubType(devp.DevPath) )
                 {
@@ -375,7 +375,7 @@ static void __init efi_arch_edd(void)
             case HARDWARE_DEVICE_PATH:
                 if ( state != acpi ||
                      DevicePathSubType(devp.DevPath) != HW_PCI_DP ||
-                     boot_edd_info_nr > EDD_INFO_MAX )
+                     boot_info_efi.edd_info_nr > EDD_INFO_MAX )
                     break;
                 state = pci;
                 edd_put_string(params->host_bus_type, "PCI");
@@ -383,7 +383,7 @@ static void __init efi_arch_edd(void)
                 params->interface_path.pci.function = devp.Pci->Function;
                 break;
             case MESSAGING_DEVICE_PATH:
-                if ( state != pci || boot_edd_info_nr > EDD_INFO_MAX )
+                if ( state != pci || boot_info_efi.edd_info_nr > EDD_INFO_MAX )
                     break;
                 state = ctrlr;
                 switch ( DevicePathSubType(devp.DevPath) )
@@ -432,15 +432,15 @@ static void __init efi_arch_edd(void)
             case MEDIA_DEVICE_PATH:
                 if ( DevicePathSubType(devp.DevPath) == MEDIA_HARDDRIVE_DP &&
                      devp.HardDrive->MBRType == MBR_TYPE_PCAT &&
-                     boot_mbr_signature_nr < EDD_MBR_SIG_MAX )
+                     boot_info_efi.mbr_signature_nr < EDD_MBR_SIG_MAX )
                 {
-                    struct mbr_signature *sig = boot_mbr_signature +
-                                                boot_mbr_signature_nr;
+                    struct mbr_signature *sig = boot_info_efi.mbr_signature +
+                                                boot_info_efi.mbr_signature_nr;
 
-                    sig->device = 0x80 + boot_edd_info_nr; /* fake */
+                    sig->device = 0x80 + boot_info_efi.edd_info_nr; /* fake */
                     memcpy(&sig->signature, devp.HardDrive->Signature,
                            sizeof(sig->signature));
-                    ++boot_mbr_signature_nr;
+                    ++boot_info_efi.mbr_signature_nr;
                 }
                 break;
             }
@@ -448,8 +448,8 @@ static void __init efi_arch_edd(void)
     }
     if ( handles )
         efi_bs->FreePool(handles);
-    if ( boot_edd_info_nr > EDD_INFO_MAX )
-        boot_edd_info_nr = EDD_INFO_MAX;
+    if ( boot_info_efi.edd_info_nr > EDD_INFO_MAX )
+        boot_info_efi.edd_info_nr = EDD_INFO_MAX;
 }
 
 static void __init efi_arch_console_init(UINTN cols, UINTN rows)
diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index 7687dd1..2bcee57 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -301,10 +301,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;
@@ -340,10 +340,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 =
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 9b41172..a257fe9 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -593,9 +593,9 @@ void __init noreturn __start_xen(paddr_t boot_info_pa)
 
     printk("Disc information:\n");
     printk(" Found %d MBR signatures\n",
-           bootsym(boot_mbr_signature_nr));
+           boot_info->mbr_signature_nr);
     printk(" Found %d EDD information structures\n",
-           bootsym(boot_edd_info_nr));
+           boot_info->edd_info_nr);
 
     /* Check that we have at least one Multiboot module. */
     if ( !boot_info->mods_nr )
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index 988464f..3416fd3 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -48,6 +48,9 @@ extern struct e820entry e820map[];
 
 extern unsigned char boot_edid_info[128];
 
+extern struct edd_info boot_edd_info[];
+extern struct mbr_signature boot_mbr_signature[];
+
 static boot_module_t __read_mostly boot_info_mods[3] = {};
 
 boot_info_t __read_mostly boot_info_efi = {
@@ -67,6 +70,10 @@ boot_info_t __read_mostly boot_info_efi = {
     .vga_console_info = {},
     .edid_caps = 0,
     .edid_info = boot_edid_info,
+    .edd_info_nr = 0,
+    .edd_info = boot_edd_info,
+    .mbr_signature_nr = 0,
+    .mbr_signature = boot_mbr_signature,
     .mods_nr = 0,
     .mods = boot_info_mods,
     .warn_msg = NULL,
diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
index df31627..ff3a310 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -22,6 +22,7 @@
 #include <xen/video.h>
 
 #include <asm/e820.h>
+#include <asm/edd.h>
 #include <asm/mbd.h>
 
 /*
@@ -87,6 +88,18 @@ typedef struct {
     unsigned short edid_caps;
     unsigned char *edid_info;
 
+    /* Number of EDD entries provided by Xen preloader. */
+    u8 edd_info_nr;
+
+    /* Pointer to EDD info. */
+    struct edd_info *edd_info;
+
+    /* Number of MBR entries provided by Xen preloader. */
+    u8 mbr_signature_nr;
+
+    /* Pointer to MBR info. */
+    struct mbr_signature *mbr_signature;
+
     /* Number of modules. */
     unsigned int mods_nr;
 
diff --git a/xen/include/asm-x86/edd.h b/xen/include/asm-x86/edd.h
index afaa237..e8361a5 100644
--- a/xen/include/asm-x86/edd.h
+++ b/xen/include/asm-x86/edd.h
@@ -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. */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 15/16] x86/boot: Use %ecx instead of %eax
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (13 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 14/16] x86: Move HDD " Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09 11:02   ` Andrew Cooper
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support Daniel Kiper
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Use %ecx instead of %eax and do not wipe multiboot protocol identifier.
We need that info in __reloc() to differentiate between multiboot(1)
and multiboot2 protocol.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/head.S |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index f1b872a..18df0b7 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -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,19 +105,20 @@ __start:
         cmp     $0x100,%edx         /* is the multiboot value too small? */
         jb      2f                  /* if so, do not use it */
         shl     $10-4,%edx
-        cmp     %eax,%edx           /* compare with BDA value */
-        cmovb   %edx,%eax           /* and use the smaller */
+        cmp     %ecx,%edx           /* compare with BDA value */
+        cmovb   %edx,%ecx           /* and use the smaller */
 
 2:      /* Reserve 64kb for the trampoline */
-        sub     $0x1000,%eax
+        sub     $0x1000,%ecx
 
         /* From arch/x86/smpboot.c: start_eip had better be page-aligned! */
-        xor     %al, %al
-        shl     $4, %eax
-        mov     %eax,sym_phys(trampoline_phys)
+        xor     %cl, %cl
+        shl     $4, %ecx
+        mov     %ecx,sym_phys(trampoline_phys)
 
         /* Save the Multiboot info struct (after relocation) for later use. */
         mov     $sym_phys(cpu0_stack)+1024,%esp
+        mov     %ecx,%eax
         push    %ebx
         call    reloc
         mov     %eax,sym_phys(mbd_pa)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (14 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 15/16] x86/boot: Use %ecx instead of %eax Daniel Kiper
@ 2014-10-08 17:52 ` Daniel Kiper
  2014-10-09 11:20   ` Andrew Cooper
  2014-10-10  8:23 ` [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
  2014-10-16  8:13 ` Jan Beulich
  17 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-08 17:52 UTC (permalink / raw)
  To: xen-devel
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

Add multiboot2 protocol support. Alter min memory limit handling as we
now may not find it from either multiboot (v1) or multiboot2.

This way we are laying the foundation for EFI + GRUB2 + Xen development.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
v3 - suggestions/fixes:
   - rearrange assembly a bit
     (suggested by Andrew Cooper),
   - define only used structs in multiboot2.h
     (suggested by Andrew Cooper),
   - improve commit comment
     (suggested by Andrew Cooper),
   - further patch split rearrangement
     (suggested by Andrew Cooper).

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     |  120 +++++++++++++++++++++++++++++++---
 xen/arch/x86/boot/reloc.c    |  117 +++++++++++++++++++++++++++++++--
 xen/include/xen/multiboot2.h |  148 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 373 insertions(+), 12 deletions(-)
 create mode 100644 xen/include/xen/multiboot2.h

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 18df0b7..ef0c7de 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <xen/multiboot.h>
+#include <xen/multiboot2.h>
 #include <public/xen.h>
 #include <asm/asm_defns.h>
 #include <asm/desc.h>
@@ -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,54 @@ __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
+        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
+        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,9 +206,6 @@ __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? */
         jb      2f                  /* if so, do not use it */
         shl     $10-4,%edx
@@ -116,11 +220,11 @@ __start:
         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
-        mov     %ecx,%eax
-        push    %ebx
-        call    reloc
+        push    %eax                /* Multiboot magic */
+        push    %ebx                /* Multiboot information address */
+        call    reloc               /* %ecx contains trampoline address */
         mov     %eax,sym_phys(mbd_pa)
 
         /* Initialize BSS (no nasty surprises!) */
diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index 59edb4d..4df8b6d 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -5,26 +5,38 @@
  * 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 <keir@xen.org>
+ *    Daniel Kiper
  */
 
 typedef unsigned int u32;
+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"
 
-/* entered with %eax = BOOT_TRAMPOLINE */
+#define ALIGN_UP(addr, align) \
+                (((addr) + (typeof(addr))(align) - 1) & ~((typeof(addr))(align) - 1))
+
+/*
+ * This entry point 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"
+    "    mov  %ecx,alloc-1b(%ebx)      \n"
     "    jmp  __reloc                  \n"
     );
 
@@ -131,12 +143,109 @@ static mbd_t *mb_mbd(mbd_t *mbd, multiboot_info_t *mbi)
     return mbd;
 }
 
-static mbd_t __used *__reloc(void *mbi)
+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;
 
     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);
 }
diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h
new file mode 100644
index 0000000..309c180
--- /dev/null
+++ b/xen/include/xen/multiboot2.h
@@ -0,0 +1,148 @@
+/*
+ *  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 {
+    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 mem_lower;
+    u32 mem_upper;
+} multiboot2_tag_basic_meminfo_t;
+
+typedef struct __packed {
+    u64 addr;
+    u64 len;
+    u32 type;
+    u32 zero;
+} multiboot2_memory_map_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 {
+    u32 type;
+    u32 size;
+    u32 mod_start;
+    u32 mod_end;
+    char cmdline[0];
+} multiboot2_tag_module_t;
+#endif /* __ASSEMBLY__ */
+
+#endif /* __MULTIBOOT2_H__ */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit Daniel Kiper
@ 2014-10-09  9:26   ` Andrew Cooper
  0 siblings, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09  9:26 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

> ---
>  xen/arch/x86/boot/reloc.c |   13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> index fa0fb6b..4609e55 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -1,11 +1,11 @@
> -/******************************************************************************
> +/*
>   * 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.
> - * 
> + *
>   * Authors:
>   *    Keir Fraser <keir@xen.org>
>   */
> @@ -21,8 +21,9 @@ asm (
>      "    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"

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file Daniel Kiper
@ 2014-10-09  9:40   ` Andrew Cooper
  2014-10-10  8:50   ` Jan Beulich
  1 sibling, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09  9:40 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, roy.franz,
	ning.sun, jbeulich, ross.philipson, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

(FWIW, this would be find IMO folded into the previous patch as part of
a "misc cleanup to reloc.c" patch)

> ---
>  xen/arch/x86/boot/reloc.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> index 4609e55..0c03291 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -10,6 +10,10 @@
>   *    Keir Fraser <keir@xen.org>
>   */
>  
> +typedef unsigned int u32;
> +
> +#include "../../../include/xen/multiboot.h"
> +
>  /* entered with %eax = BOOT_TRAMPOLINE */
>  asm (
>      "    .text                         \n"
> @@ -30,9 +34,6 @@ asm (
>      "    .long 0                       \n"
>      );
>  
> -typedef unsigned int u32;
> -#include "../../../include/xen/multiboot.h"
> -
>  static void *reloc_mbi_struct(void *old, unsigned int bytes)
>  {
>      void *new;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions Daniel Kiper
@ 2014-10-09  9:45   ` Andrew Cooper
  2014-10-13 15:00     ` Daniel Kiper
  0 siblings, 1 reply; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09  9:45 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Create generic alloc and copy functions. We need them to
> introduce MBD struct and multiboot2 protocol. Please
> check later patches for more details.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

copy_string() is fine, as all its uses are in terms of u32s, but why do
the other two change from pointers to u32s now?

You could drop almost all of the casts with the reintroduction of the
void pointers.  This code, after all, is only ever going to be 32bit.

~Andrew

> ---
>  xen/arch/x86/boot/reloc.c |   52 +++++++++++++++++++++++++++++----------------
>  1 file changed, 34 insertions(+), 18 deletions(-)
>
> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> index 0c03291..b678f67 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -34,9 +34,10 @@ asm (
>      "    .long 0                       \n"
>      );
>  
> -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"
> @@ -44,50 +45,65 @@ 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 u32 copy_struct(u32 src, u32 bytes)
> +{
> +    u32 dst, dst_asm;
> +
> +    dst = alloc_struct(bytes);
> +    dst_asm = dst;
> +
> +    asm volatile(
>      "    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)
>  {
> -    multiboot_info_t *mbi = reloc_mbi_struct(mbi_old, sizeof(*mbi));
> +    multiboot_info_t *mbi = (multiboot_info_t *)copy_struct((u32)mbi_old, sizeof(*mbi));
>      int i;
>  
>      if ( mbi->flags & MBI_CMDLINE )
> -        mbi->cmdline = (u32)reloc_mbi_string((char *)mbi->cmdline);
> +        mbi->cmdline = copy_string(mbi->cmdline);
>  
>      if ( mbi->flags & MBI_MODULES )
>      {
> -        module_t *mods = reloc_mbi_struct(
> -            (module_t *)mbi->mods_addr, mbi->mods_count * sizeof(module_t));
> +        module_t *mods = (module_t *)copy_struct(
> +            mbi->mods_addr, mbi->mods_count * sizeof(module_t));
>  
>          mbi->mods_addr = (u32)mods;
>  
>          for ( i = 0; i < mbi->mods_count; i++ )
>          {
>              if ( mods[i].string )
> -                mods[i].string = (u32)reloc_mbi_string((char *)mods[i].string);
> +                mods[i].string = copy_string(mods[i].string);
>          }
>      }
>  
>      if ( mbi->flags & MBI_MEMMAP )
> -        mbi->mmap_addr = (u32)reloc_mbi_struct(
> -            (memory_map_t *)mbi->mmap_addr, mbi->mmap_length);
> +        mbi->mmap_addr = copy_struct(mbi->mmap_addr, mbi->mmap_length);
>  
>      if ( mbi->flags & MBI_LOADERNAME )
> -        mbi->boot_loader_name = (u32)reloc_mbi_string(
> -            (char *)mbi->boot_loader_name);
> +        mbi->boot_loader_name = copy_string(mbi->boot_loader_name);
>  
>      /* Mask features we don't understand or don't relocate. */
>      mbi->flags &= (MBI_MEMLIMITS |

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type Daniel Kiper
@ 2014-10-09 10:28   ` Andrew Cooper
  2014-10-10 11:47     ` Daniel Kiper
  2014-10-14 15:27   ` Jan Beulich
  1 sibling, 1 reply; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09 10:28 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> 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.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v3 - suggestions/fixes:
>    - rename some variables
>      (suggested by Andrew Cooper),
>    - remove unneeded initialization
>      (suggested by Andrew Cooper),
>    - improve comments
>      (suggested by Andrew Cooper),
>    - further patch split rearrangement
>      (suggested by Andrew Cooper and Jan Beulich).
>
> 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          |    2 +-
>  xen/arch/x86/boot/reloc.c         |   69 +++++++++++++++++++++-----------
>  xen/arch/x86/boot/x86_64.S        |   10 +++--
>  xen/arch/x86/boot_info.c          |   59 +++++++++++++++++++++++++++
>  xen/arch/x86/setup.c              |   41 ++++++++++++-------
>  xen/arch/x86/x86_64/asm-offsets.c |    5 +--
>  xen/include/asm-x86/mbd.h         |   79 +++++++++++++++++++++++++++++++++++++
>  9 files changed, 225 insertions(+), 50 deletions(-)
>  create mode 100644 xen/arch/x86/boot_info.c
>  create mode 100644 xen/include/asm-x86/mbd.h
>
> diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> index 86ca5f8..8425e65 100644
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -43,6 +43,7 @@ obj-y += pci.o
>  obj-y += percpu.o
>  obj-y += physdev.o
>  obj-y += psr.o
> +obj-y += boot_info.o
>  obj-y += setup.o
>  obj-y += shutdown.o
>  obj-y += smp.o
> diff --git a/xen/arch/x86/boot/cmdline.S b/xen/arch/x86/boot/cmdline.S
> index 00687eb..dd1a027 100644
> --- a/xen/arch/x86/boot/cmdline.S
> +++ b/xen/arch/x86/boot/cmdline.S
> @@ -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_pa),%ebx
> +        mov     MBD_cmdline_pa(%ebx),%eax

What sets the value of MBD_cmdline_pa?  You are blindly consuming it
here without checks the flags for its presence, but I can't spot
anything in this patch which ever sets it.

>          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_pa(%ebx)
>          call    .Lfind_option
>          test    %eax,%eax
>          setnz   %al
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index cd43952..f1b872a 100644
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -120,7 +120,7 @@ __start:
>          mov     $sym_phys(cpu0_stack)+1024,%esp
>          push    %ebx
>          call    reloc
> -        mov     %eax,sym_phys(multiboot_ptr)
> +        mov     %eax,sym_phys(mbd_pa)
>  
>          /* Initialize BSS (no nasty surprises!) */
>          mov     $sym_phys(__bss_start),%edi
> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> index b678f67..59edb4d 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -12,8 +12,11 @@
>  
>  typedef unsigned int u32;
>  
> +#include "../../../include/xen/compiler.h"
>  #include "../../../include/xen/multiboot.h"
>  
> +#include "../../../include/asm/mbd.h"
> +
>  /* entered with %eax = BOOT_TRAMPOLINE */
>  asm (
>      "    .text                         \n"
> @@ -22,7 +25,7 @@ asm (
>      "    call 1f                       \n"
>      "1:  pop  %ebx                     \n"
>      "    mov  %eax,alloc-1b(%ebx)      \n"
> -    "    jmp  reloc                    \n"
> +    "    jmp  __reloc                  \n"

Why do you need to change the name of the reloc() function?  reloc()
seems like a fine name.

>      );
>  
>  /*
> @@ -50,6 +53,13 @@ static u32 alloc_struct(u32 bytes)
>      return s;
>  }
>  
> +static void zero_struct(u32 s, u32 bytes)

"static void memclear(void *ptr, size_t bytes)" would seem to be more
appropriate, and avoid you needing to cast the pointers you actually
pass into it.

> +{
> +    asm volatile(
> +    "    rep  stosb                   \n"

For a single instruction instruction asm statement, just use 'asm
volatile ("rep stosb" ...'  No need for these multi-line hoops to create
a readable .S

> +       : "+D" (s), "+c" (bytes) : "a" (0));
> +}
> +
>  static u32 copy_struct(u32 src, u32 bytes)
>  {
>      u32 dst, dst_asm;
> @@ -77,41 +87,56 @@ static u32 copy_string(u32 src)
>      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 = (multiboot_info_t *)copy_struct((u32)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 = copy_string(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;
> +    }

Now I am completely confused.  here you set mbd from mbi, but lower in
init_mbi, you set mbi from mbd.  What is the intended dataflow?

> +
> +    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 = (module_t *)copy_struct(
> -            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 = copy_string(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 = copy_struct(mbi->mmap_addr, mbi->mmap_length);
> +    return mbd;
> +}
>  
> -    if ( mbi->flags & MBI_LOADERNAME )
> -        mbi->boot_loader_name = copy_string(mbi->boot_loader_name);
> +static mbd_t __used *__reloc(void *mbi)
> +{
> +    mbd_t *mbd;
>  
> -    /* Mask features we don't understand or don't relocate. */
> -    mbi->flags &= (MBI_MEMLIMITS |
> -                   MBI_BOOTDEV |
> -                   MBI_CMDLINE |
> -                   MBI_MODULES |
> -                   MBI_MEMMAP |
> -                   MBI_LOADERNAME);
> +    mbd = (mbd_t *)alloc_struct(sizeof(mbd_t));
> +    zero_struct((u32)mbd, sizeof(mbd_t));
>  
> -    return mbi;
> +    return mb_mbd(mbd, mbi);
>  }
> diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
> index bfbafd2..ef8c735 100644
> --- a/xen/arch/x86/boot/x86_64.S
> +++ b/xen/arch/x86/boot/x86_64.S
> @@ -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 mbi. */

This is wholly useless as a comment.  "Initialise Multiboot Info" would
be better, but still identifiable from the name of the function.

> +        mov     mbd_pa(%rip),%edi
> +        call    __init_mbi
> +
> +        /* Pass off the mbi to C land. */

Again, for the commit it would be useful to expand mbi.

> +        movq    %rax,%rdi
>          call    __start_xen
>          ud2     /* Force a panic (invalid opcode). */
>  
> @@ -38,7 +42,7 @@
>  
>          .data
>          .align 8
> -multiboot_ptr:
> +mbd_pa:
>          .long   0
>  
>          .word   0
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> new file mode 100644
> index 0000000..a2799aa
> --- /dev/null
> +++ b/xen/arch/x86/boot_info.c
> @@ -0,0 +1,59 @@
> +/*
> + * 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/>.
> + */
> +
> +#include <xen/types.h>
> +#include <xen/cache.h>
> +#include <xen/init.h>
> +#include <xen/multiboot.h>
> +
> +#include <asm/mbd.h>
> +#include <asm/page.h>
> +
> +static multiboot_info_t __read_mostly mbi;
> +
> +extern void enable_exception_support(void);

No externs in .c files.  This should be in a header file.

(I am still not particularly happy about splitting exception support
like this, but I can't currently suggest a better alternative)

> +
> +unsigned long __init __init_mbi(u32 mbd_pa)
> +{
> +    mbd_t *mbd = __va(mbd_pa);
> +
> +    enable_exception_support();
> +
> +    if ( mbd->boot_loader_name ) {

Xen style

> +        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);
> +}
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 8c8b91f..24e1be3 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -529,6 +529,25 @@ static char * __init cmdline_cook(char *p, char *loader_name)
>      return p;
>  }
>  
> +void __init enable_exception_support(void)

This should have bsp somewhere in the name, as it is specifically
different to the ap method of gaining exception support.

> +{
> +    /* 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. */

This comment serves no purpose now that it is in a function named
"enable_exception_support()"

> +}
> +
>  void __init noreturn __start_xen(unsigned long mbi_p)
>  {
>      char *memmap_type = NULL;
> @@ -546,21 +565,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();
> -    sort_exception_tables();
> -
> -    /* Full exception support from here on in. */
> +    if ( efi_enabled ) {

Xen style.

> +        enable_exception_support();
> +    }
> +    else
> +    {
> +        /* Exception support was enabled before __start_xen() call. */
> +    }
>  
>      loader = (mbi->flags & MBI_LOADERNAME)
>          ? (char *)__va(mbi->boot_loader_name) : "unknown";
> diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
> index 3994f4d..dab0ae1 100644
> --- a/xen/arch/x86/x86_64/asm-offsets.c
> +++ b/xen/arch/x86/x86_64/asm-offsets.c
> @@ -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_pa, mbd_t, cmdline);
>  }
> diff --git a/xen/include/asm-x86/mbd.h b/xen/include/asm-x86/mbd.h
> new file mode 100644
> index 0000000..45e7285
> --- /dev/null
> +++ b/xen/include/asm-x86/mbd.h
> @@ -0,0 +1,79 @@
> +/*
> + * 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/>.
> + */
> +
> +#ifndef __MBD_H__
> +#define __MBD_H__
> +
> +/*
> + * Do not include any headers here!
> + *
> + * This file is used by xen/arch/x86/boot/reloc.c
> + * and any include statement here will break its build.
> + * It means that every basic type used below must be defined
> + * before any usage of this header.
> + */
> +
> +/* Module type. */
> +typedef struct {
> +    u32 start;
> +    u32 end;
> +
> +    /* A module command line address. */
> +    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
> + * 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 {
> +    /* Boot loader name physical address. */
> +    u32 boot_loader_name;
> +
> +    /* Xen command line physical address. */
> +    u32 cmdline;
> +
> +    /*
> +     * 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;
> +
> +    /* Physical address of memory map provided by bootloader. */
> +    u32 mmap;
> +
> +    /* Number of modules. */
> +    u32 mods_nr;
> +
> +    /* Physical address of modules description (boot_module_t *). */

This is surely the list of modules, so the pa of a list of module
descriptions?

~Andrew

> +    u32 mods;
> +} mbd_t;
> +#endif /* __MBD_H__ */

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 05/16] x86/efi: Add place_string_u32() function
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 05/16] x86/efi: Add place_string_u32() function Daniel Kiper
@ 2014-10-09 10:30   ` Andrew Cooper
  0 siblings, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09 10:30 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, roy.franz,
	ning.sun, jbeulich, ross.philipson, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Add place_string_u32() function and rename place_string()
> to place_string_char().

Why?  You need some description of their intended purpose.

~Andrew

>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  xen/arch/x86/efi/efi-boot.h |   29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 4348cfe..71030b0 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -103,14 +103,14 @@ static void __init relocate_trampoline(unsigned long phys)
>          *(u16 *)(*trampoline_ptr + (long)trampoline_ptr) = phys >> 4;
>  }
>  
> -static void __init place_string(u32 *addr, const char *s)
> +static void __init place_string_char(char **addr, const char *s)
>  {
>      static char *__initdata alloc = start;
>  
>      if ( s && *s )
>      {
>          size_t len1 = strlen(s) + 1;
> -        const char *old = (char *)(long)*addr;
> +        const char *old = *addr;
>          size_t len2 = *addr ? strlen(old) + 1 : 0;
>  
>          alloc -= len1 + len2;
> @@ -126,7 +126,16 @@ static void __init place_string(u32 *addr, const char *s)
>              memcpy(alloc + len1, old, len2);
>          }
>      }
> -    *addr = (long)alloc;
> +    *addr = alloc;
> +}
> +
> +static void __init place_string_u32(u32 *addr, const char *s)
> +{
> +    char *s_new = (char *)(long)*addr;
> +
> +    place_string_char(&s_new, s);
> +
> +    *addr = (long)s_new;
>  }
>  
>  static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
> @@ -192,7 +201,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
>  
>  static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size)
>  {
> -    place_string(&mbi.mem_upper, NULL);
> +    place_string_u32(&mbi.mem_upper, NULL);
>      mbi.mem_upper -= map_size;
>      mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR);
>      if ( mbi.mem_upper < xen_phys_start )
> @@ -280,10 +289,10 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
>      {
>          name.w = cmdline_options;
>          w2s(&name);
> -        place_string(&mbi.cmdline, name.s);
> +        place_string_u32(&mbi.cmdline, name.s);
>      }
>      if ( cfgfile_options )
> -        place_string(&mbi.cmdline, cfgfile_options);
> +        place_string_u32(&mbi.cmdline, cfgfile_options);
>      /* Insert image name last, as it gets prefixed to the other options. */
>      if ( image_name )
>      {
> @@ -292,7 +301,7 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
>      }
>      else
>          name.s = "xen";
> -    place_string(&mbi.cmdline, name.s);
> +    place_string_u32(&mbi.cmdline, name.s);
>  
>      if ( mbi.cmdline )
>          mbi.flags |= MBI_CMDLINE;
> @@ -587,12 +596,12 @@ static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name,
>      /*
>       * If options are provided, put them in
>       * mb_modules[mbi.mods_count].string after the filename, with a space
> -     * separating them.  place_string() prepends strings and adds separating
> +     * separating them.  place_string_u32() prepends strings and adds separating
>       * spaces, so the call order is reversed.
>       */
>      if ( options )
> -        place_string(&mb_modules[mbi.mods_count].string, options);
> -    place_string(&mb_modules[mbi.mods_count].string, local_name.s);
> +        place_string_u32(&mb_modules[mbi.mods_count].string, options);
> +    place_string_u32(&mb_modules[mbi.mods_count].string, local_name.s);
>      mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT;
>      mb_modules[mbi.mods_count].mod_end = file->size;
>      ++mbi.mods_count;

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure Daniel Kiper
@ 2014-10-09 10:48   ` Andrew Cooper
  2014-10-10 13:55   ` Stefano Stabellini
  1 sibling, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09 10:48 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, roy.franz,
	ning.sun, jbeulich, ross.philipson, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> This patch introduces boot_info structure. Subsequent patches will move
> step by step all boot related data to above mentioned struct. At the end
> of this process multiboot (v1) protocol dependency will be broken. It means
> that most of Xen code (excluding preloader) could be bootloader agnostic
> and does not need almost any knowledge about boot protocol. Additionally,
> it will be possible 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 has not been tested yet.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v3 - suggestions/fixes:
>    - further patch split rearrangement
>      (suggested by Andrew Cooper).
>
> 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/x86_64.S      |   10 +++++++--
>  xen/arch/x86/boot_info.c        |   11 ++++++++++
>  xen/arch/x86/efi/efi-boot.h     |    3 ++-
>  xen/arch/x86/setup.c            |   13 ++++++++++-
>  xen/common/efi/efi.h            |    7 ++++++
>  xen/common/efi/runtime.c        |   10 +++++++++
>  xen/include/asm-x86/boot_info.h |   46 +++++++++++++++++++++++++++++++++++++++
>  7 files changed, 96 insertions(+), 4 deletions(-)
>  create mode 100644 xen/include/asm-x86/boot_info.h
>
> diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
> index ef8c735..647c33b 100644
> --- a/xen/arch/x86/boot/x86_64.S
> +++ b/xen/arch/x86/boot/x86_64.S
> @@ -32,9 +32,15 @@
>          /* Init mbi. */
>          mov     mbd_pa(%rip),%edi
>          call    __init_mbi
> +        pushq   %rax
> +
> +        /* Init boot_info. */
> +        mov     mbd_pa(%rip),%edi
> +        call    __init_boot_info
>  
> -        /* Pass off the mbi to C land. */
> -        movq    %rax,%rdi
> +        /* Pass off the mbi and boot_info to C land. */
> +        popq    %rdi
> +        movq    %rax,%rsi
>          call    __start_xen
>          ud2     /* Force a panic (invalid opcode). */
>  
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index a2799aa..83bd255 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -20,11 +20,17 @@
>  #include <xen/init.h>
>  #include <xen/multiboot.h>
>  
> +#include <asm/boot_info.h>
>  #include <asm/mbd.h>
>  #include <asm/page.h>
>  
>  static multiboot_info_t __read_mostly mbi;
>  
> +static boot_info_t __read_mostly boot_info_mb = {
> +    .warn_msg = NULL,
> +    .err_msg = NULL
> +};

You don't need to explicitly 0 things like this with structure
initialisation.

> +
>  extern void enable_exception_support(void);
>  
>  unsigned long __init __init_mbi(u32 mbd_pa)
> @@ -57,3 +63,8 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>  
>      return __pa(&mbi);
>  }
> +
> +paddr_t __init __init_boot_info(u32 mbd_pa)
> +{
> +    return __pa(&boot_info_mb);
> +}
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 71030b0..6d7c222 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -254,7 +254,8 @@ static void __init noreturn efi_arch_post_exit_boot(void)
>                       [cs] "ir" (__HYPERVISOR_CS),
>                       [ds] "r" (__HYPERVISOR_DS),
>                       [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)),
> -                     "D" (&mbi)
> +                     "D" (&mbi),
> +                     "S" (&boot_info_efi)
>                     : "memory" );
>      for( ; ; ); /* not reached */
>  }
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 24e1be3..d2a1450 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -49,6 +49,7 @@
>  #include <xen/cpu.h>
>  #include <asm/nmi.h>
>  #include <asm/alternative.h>
> +#include <asm/boot_info.h>
>  
>  /* opt_nosmp: If true, secondary processors are ignored. */
>  static bool_t __initdata opt_nosmp;
> @@ -92,6 +93,8 @@ unsigned long __initdata highmem_start;
>  size_param("highmem-start", highmem_start);
>  #endif
>  
> +boot_info_t *boot_info;
> +
>  cpumask_t __read_mostly cpu_present_map;
>  
>  unsigned long __read_mostly xen_phys_start;
> @@ -548,7 +551,7 @@ void __init enable_exception_support(void)
>      /* Full exception support from here on in. */
>  }
>  
> -void __init noreturn __start_xen(unsigned long mbi_p)
> +void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>  {
>      char *memmap_type = NULL;
>      char *cmdline, *kextra, *loader;
> @@ -565,6 +568,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>          .stop_bits = 1
>      };
>  
> +    boot_info = __va(boot_info_pa);
> +
>      if ( efi_enabled ) {
>          enable_exception_support();
>      }
> @@ -613,6 +618,12 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>      ehci_dbgp_init();
>      console_init_preirq();
>  
> +    if ( boot_info->err_msg )
> +        panic(boot_info->err_msg);
> +
> +    if ( boot_info->warn_msg )
> +        printk(boot_info->warn_msg);
> +
>      printk("Bootloader: %s\n", loader);
>  
>      printk("Command line: %s\n", cmdline);
> diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
> index bee3b77..526f57c 100644
> --- a/xen/common/efi/efi.h
> +++ b/xen/common/efi/efi.h
> @@ -8,6 +8,9 @@
>  #include <xen/efi.h>
>  #include <xen/spinlock.h>
>  #include <asm/page.h>
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +#include <asm/boot_info.h>
> +#endif
>  
>  struct efi_pci_rom {
>      const struct efi_pci_rom *next;
> @@ -25,6 +28,10 @@ extern const CHAR16 *efi_fw_vendor;
>  
>  extern EFI_RUNTIME_SERVICES *efi_rs;
>  
> +#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
> +extern boot_info_t boot_info_efi;
> +#endif
> +
>  extern UINTN efi_memmap_size, efi_mdesc_size;
>  extern void *efi_memmap;
>  
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index 1c43d10..eb0acae 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -5,6 +5,9 @@
>  #include <xen/guest_access.h>
>  #include <xen/irq.h>
>  #include <xen/time.h>
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +#include <asm/boot_info.h>
> +#endif
>  
>  DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  
> @@ -50,6 +53,13 @@ struct efi __read_mostly efi = {
>  const struct efi_pci_rom *__read_mostly efi_pci_roms;
>  
>  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +boot_info_t __read_mostly boot_info_efi = {
> +    .warn_msg = NULL,
> +    .err_msg = NULL
> +};
> +#endif
> +
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
>  unsigned long efi_rs_enter(void)
>  {
>      static const u16 fcw = FCW_DEFAULT;
> diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
> new file mode 100644
> index 0000000..9ff3c0f
> --- /dev/null
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -0,0 +1,46 @@
> +/*
> + * 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/>.
> + */
> +
> +#ifndef __BOOT_INFO_H__
> +#define __BOOT_INFO_H__
> +
> +/*
> + * Define boot_info type. It will be used to define variable which in turn
> + * will store data collected by bootloader and preloader. This way it will
> + * be possible to make most of Xen code bootloader agnostic.
> + *
> + * Some members should have relevant EFI/ACPI types. However, due to type
> + * conflicts among ACPI and EFI headers it is not possible to use required
> + * EFI/ACPI types here. Instead of them there are simple types in use which
> + * are compatible as much as possible with relevant EFI/ACPI types.
> + */
> +typedef struct {
> +    /*
> +     * Info about warning occurred during boot_info initialization.
> +     * NULL if everything went OK.
> +     */
> +    char *warn_msg;

const char *

~Andrew

> +
> +    /*
> +     * Info about error occurred during boot_info initialization. NULL if everything
> +     * went OK. Otherwise boot_info is not fully/properly initialized.
> +     */
> +    char *err_msg;
> +} boot_info_t;
> +
> +extern boot_info_t *boot_info;
> +#endif /* __BOOT_INFO_H__ */

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 07/16] x86: Move boot_loader_name from mbi to boot_info
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 07/16] x86: Move boot_loader_name from mbi to boot_info Daniel Kiper
@ 2014-10-09 10:53   ` Andrew Cooper
  0 siblings, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09 10:53 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  xen/arch/x86/boot_info.c        |   11 ++++++-----
>  xen/arch/x86/efi/efi-boot.h     |    3 +--
>  xen/arch/x86/setup.c            |   13 +++++--------
>  xen/common/efi/runtime.c        |    1 +
>  xen/include/asm-x86/boot_info.h |    3 +++
>  5 files changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index 83bd255..5851123 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -27,6 +27,7 @@
>  static multiboot_info_t __read_mostly mbi;
>  
>  static boot_info_t __read_mostly boot_info_mb = {
> +    .boot_loader_name = "UNKNOWN",
>      .warn_msg = NULL,
>      .err_msg = NULL
>  };
> @@ -39,11 +40,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>  
>      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;
> @@ -66,5 +62,10 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>  
>  paddr_t __init __init_boot_info(u32 mbd_pa)
>  {
> +    mbd_t *mbd = __va(mbd_pa);
> +
> +    if ( mbd->boot_loader_name )
> +        boot_info_mb.boot_loader_name = __va(mbd->boot_loader_name);
> +
>      return __pa(&boot_info_mb);
>  }
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 6d7c222..29504e9 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -11,7 +11,7 @@
>  
>  static struct file __initdata ucode;
>  static multiboot_info_t __initdata mbi = {
> -    .flags = MBI_MODULES | MBI_LOADERNAME
> +    .flags = MBI_MODULES
>  };
>  static module_t __initdata mb_modules[3];
>  
> @@ -310,7 +310,6 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
>       * These must not be initialized statically, since the value must
>       * not get relocated when processing base relocations later.
>       */
> -    mbi.boot_loader_name = (long)"EFI";
>      mbi.mods_addr = (long)mb_modules;
>  }
>  
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index d2a1450..c4642f3 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -554,7 +554,7 @@ void __init enable_exception_support(void)
>  void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>  {
>      char *memmap_type = NULL;
> -    char *cmdline, *kextra, *loader;
> +    char *cmdline, *kextra;
>      unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
>      multiboot_info_t *mbi = __va(mbi_p);
>      module_t *mod = (module_t *)__va(mbi->mods_addr);
> @@ -578,13 +578,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>          /* Exception support was enabled before __start_xen() call. */
>      }
>  
> -    loader = (mbi->flags & MBI_LOADERNAME)
> -        ? (char *)__va(mbi->boot_loader_name) : "unknown";
> -
>      /* Parse the command-line options. */
>      cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ?
>                             __va(mbi->cmdline) : NULL,
> -                           loader);
> +                           boot_info->boot_loader_name);
>      if ( (kextra = strstr(cmdline, " -- ")) != NULL )
>      {
>          /*
> @@ -624,7 +621,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>      if ( boot_info->warn_msg )
>          printk(boot_info->warn_msg);
>  
> -    printk("Bootloader: %s\n", loader);
> +    printk("Bootloader: %s\n", boot_info->boot_loader_name);
>  
>      printk("Command line: %s\n", cmdline);
>  
> @@ -698,7 +695,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>          l3_bootmap[l3_table_offset(BOOTSTRAP_MAP_BASE)] =
>              l3e_from_paddr(__pa(l2_bootmap), __PAGE_HYPERVISOR);
>  
> -        memmap_type = loader;
> +        memmap_type = boot_info->boot_loader_name;
>      }
>      else if ( e820_raw_nr != 0 )
>      {
> @@ -1380,7 +1377,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>      {
>          static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE];
>  
> -        cmdline = cmdline_cook(cmdline, loader);
> +        cmdline = cmdline_cook(cmdline, boot_info->boot_loader_name);
>          safe_strcpy(dom0_cmdline, cmdline);
>  
>          if ( kextra != NULL )
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index eb0acae..7846b2b 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -54,6 +54,7 @@ const struct efi_pci_rom *__read_mostly efi_pci_roms;
>  
>  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
>  boot_info_t __read_mostly boot_info_efi = {
> +    .boot_loader_name = "EFI",
>      .warn_msg = NULL,
>      .err_msg = NULL
>  };
> diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
> index 9ff3c0f..58a4cb6 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -29,6 +29,9 @@
>   * are compatible as much as possible with relevant EFI/ACPI types.
>   */
>  typedef struct {
> +    /* Boot loader name. */
> +    char *boot_loader_name;
> +

const char *loader_name;  No need to have boot twice.

~Andrew

>      /*
>       * Info about warning occurred during boot_info initialization.
>       * NULL if everything went OK.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 15/16] x86/boot: Use %ecx instead of %eax
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 15/16] x86/boot: Use %ecx instead of %eax Daniel Kiper
@ 2014-10-09 11:02   ` Andrew Cooper
  0 siblings, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09 11:02 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Use %ecx instead of %eax and do not wipe multiboot protocol identifier.
> We need that info in __reloc() to differentiate between multiboot(1)
> and multiboot2 protocol.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

Much easier to review!

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> given 1 tiny
comment...

> ---
>  xen/arch/x86/boot/head.S |   23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index f1b872a..18df0b7 100644
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -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,19 +105,20 @@ __start:
>          cmp     $0x100,%edx         /* is the multiboot value too small? */
>          jb      2f                  /* if so, do not use it */
>          shl     $10-4,%edx
> -        cmp     %eax,%edx           /* compare with BDA value */
> -        cmovb   %edx,%eax           /* and use the smaller */
> +        cmp     %ecx,%edx           /* compare with BDA value */
> +        cmovb   %edx,%ecx           /* and use the smaller */
>  
>  2:      /* Reserve 64kb for the trampoline */
> -        sub     $0x1000,%eax
> +        sub     $0x1000,%ecx
>  
>          /* From arch/x86/smpboot.c: start_eip had better be page-aligned! */
> -        xor     %al, %al
> -        shl     $4, %eax
> -        mov     %eax,sym_phys(trampoline_phys)
> +        xor     %cl, %cl
> +        shl     $4, %ecx
> +        mov     %ecx,sym_phys(trampoline_phys)
>  
>          /* Save the Multiboot info struct (after relocation) for later use. */
>          mov     $sym_phys(cpu0_stack)+1024,%esp
> +        mov     %ecx,%eax

Probably useful to identify which parameters are in which registers when
calling into reloc

~Andrew

>          push    %ebx
>          call    reloc
>          mov     %eax,sym_phys(mbd_pa)

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support Daniel Kiper
@ 2014-10-09 11:20   ` Andrew Cooper
  2014-10-10  8:21     ` Jan Beulich
  0 siblings, 1 reply; 52+ messages in thread
From: Andrew Cooper @ 2014-10-09 11:20 UTC (permalink / raw)
  To: Daniel Kiper, xen-devel
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On 08/10/14 18:52, Daniel Kiper wrote:
> Add multiboot2 protocol support. Alter min memory limit handling as we
> now may not find it from either multiboot (v1) or multiboot2.
>
> This way we are laying the foundation for EFI + GRUB2 + Xen development.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v3 - suggestions/fixes:
>    - rearrange assembly a bit
>      (suggested by Andrew Cooper),
>    - define only used structs in multiboot2.h
>      (suggested by Andrew Cooper),
>    - improve commit comment
>      (suggested by Andrew Cooper),
>    - further patch split rearrangement
>      (suggested by Andrew Cooper).
>
> 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     |  120 +++++++++++++++++++++++++++++++---
>  xen/arch/x86/boot/reloc.c    |  117 +++++++++++++++++++++++++++++++--
>  xen/include/xen/multiboot2.h |  148 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 373 insertions(+), 12 deletions(-)
>  create mode 100644 xen/include/xen/multiboot2.h
>
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index 18df0b7..ef0c7de 100644
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -1,5 +1,6 @@
>  #include <xen/config.h>
>  #include <xen/multiboot.h>
> +#include <xen/multiboot2.h>
>  #include <public/xen.h>
>  #include <asm/asm_defns.h>
>  #include <asm/desc.h>
> @@ -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,54 @@ __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

Can this 4 be a named constant?

> +        jmp     trampoline_setup
> +
> +multiboot2_proto:
> +        /* Get Multiboot2 information address */
> +        mov     %ebx,%ecx
> +
> +        /* Skip Multiboot2 information fixed part */
> +        add     $8,%ecx

And these 8s as well?

> +
> +0:
> +        /* Get mem_lower from Multiboot2 information */
> +        cmpl    $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx)
> +        jne     1f
> +
> +        mov     8(%ecx),%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,9 +206,6 @@ __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? */
>          jb      2f                  /* if so, do not use it */
>          shl     $10-4,%edx
> @@ -116,11 +220,11 @@ __start:
>          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
> -        mov     %ecx,%eax
> -        push    %ebx
> -        call    reloc
> +        push    %eax                /* Multiboot magic */
> +        push    %ebx                /* Multiboot information address */
> +        call    reloc               /* %ecx contains trampoline address */
>          mov     %eax,sym_phys(mbd_pa)
>  
>          /* Initialize BSS (no nasty surprises!) */
> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> index 59edb4d..4df8b6d 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -5,26 +5,38 @@
>   * 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 <keir@xen.org>
> + *    Daniel Kiper
>   */
>  
>  typedef unsigned int u32;
> +typedef unsigned long long u64;

Might just be better to use <inttypes.h> and be done with it.

>  
>  #include "../../../include/xen/compiler.h"
>  #include "../../../include/xen/multiboot.h"
> +#include "../../../include/xen/multiboot2.h"
>  
>  #include "../../../include/asm/mbd.h"
>  
> -/* entered with %eax = BOOT_TRAMPOLINE */
> +#define ALIGN_UP(addr, align) \
> +                (((addr) + (typeof(addr))(align) - 1) & ~((typeof(addr))(align) - 1))
> +
> +/*
> + * This entry point 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"
> +    "    mov  %ecx,alloc-1b(%ebx)      \n"
>      "    jmp  __reloc                  \n"
>      );
>  
> @@ -131,12 +143,109 @@ static mbd_t *mb_mbd(mbd_t *mbd, multiboot_info_t *mbi)
>      return mbd;
>  }
>  
> -static mbd_t __used *__reloc(void *mbi)
> +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);

Erm?  what is wrong with sizeof(multiboot2_tag_mmap_t.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;
>  
>      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

I know it has been checked before entering, but you should recheck the
magic for multiboot2 here for consistency.

If you need a default to fall back to, falling back to multiboot1 seems
safer.

~Andrew

> +        return mb2_mbd(mbd, mbi);
>  }
> diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h
> new file mode 100644
> index 0000000..309c180
> --- /dev/null
> +++ b/xen/include/xen/multiboot2.h
> @@ -0,0 +1,148 @@
> +/*
> + *  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 {
> +    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 mem_lower;
> +    u32 mem_upper;
> +} multiboot2_tag_basic_meminfo_t;
> +
> +typedef struct __packed {
> +    u64 addr;
> +    u64 len;
> +    u32 type;
> +    u32 zero;
> +} multiboot2_memory_map_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 {
> +    u32 type;
> +    u32 size;
> +    u32 mod_start;
> +    u32 mod_end;
> +    char cmdline[0];
> +} multiboot2_tag_module_t;
> +#endif /* __ASSEMBLY__ */
> +
> +#endif /* __MULTIBOOT2_H__ */

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support
  2014-10-09 11:20   ` Andrew Cooper
@ 2014-10-10  8:21     ` Jan Beulich
  0 siblings, 0 replies; 52+ messages in thread
From: Jan Beulich @ 2014-10-10  8:21 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	Daniel Kiper, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 09.10.14 at 13:20, <andrew.cooper3@citrix.com> wrote:
> On 08/10/14 18:52, Daniel Kiper wrote:
>> +        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);
> 
> Erm?  what is wrong with sizeof(multiboot2_tag_mmap_t.entries) ?

The fact that this isn't a valid expression? You need an object on the
left side of ., not a type.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (15 preceding siblings ...)
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support Daniel Kiper
@ 2014-10-10  8:23 ` Jan Beulich
  2014-10-10 11:07   ` Daniel Kiper
  2014-10-16  8:13 ` Jan Beulich
  17 siblings, 1 reply; 52+ messages in thread
From: Jan Beulich @ 2014-10-10  8:23 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> Patch #13 reveals a bug which probably was introduced between commit
> 3e2331d271cc0882e4013c8f20398c46c35f90a1 (VT-d: suppress UR signaling for
> further desktop chipsets) and 61fdda7acf3de11f3d50d50e5b4f4ecfac7e0d04
> (x86/HVM: properly bound x2APIC MSR range). Xen crashes at video_endboot()
> because earlier scrub process wipes vga_console_info data (sic!). So,
> it means that at least page containing this structure was freed mistakenly
> somewhere. Interestingly this issue appears on legacy BIOS machines only.
> EFI platforms work as usual. It is possible to workaround this bug by
> passing no-bootscrub to xen.gz.

Giving a little more detail on how exactly things crash would be rather
useful to make suggestions. Or if you intend to figure this out all by
yourself, then I think you would have better done so before posting
this series.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file Daniel Kiper
  2014-10-09  9:40   ` Andrew Cooper
@ 2014-10-10  8:50   ` Jan Beulich
  2014-10-10 13:17     ` Daniel Kiper
  1 sibling, 1 reply; 52+ messages in thread
From: Jan Beulich @ 2014-10-10  8:50 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -10,6 +10,10 @@
>   *    Keir Fraser <keir@xen.org>
>   */
>  
> +typedef unsigned int u32;
> +
> +#include "../../../include/xen/multiboot.h"
> +
>  /* entered with %eax = BOOT_TRAMPOLINE */
>  asm (
>      "    .text                         \n"
> @@ -30,9 +34,6 @@ asm (
>      "    .long 0                       \n"
>      );
>  
> -typedef unsigned int u32;
> -#include "../../../include/xen/multiboot.h"
> -
>  static void *reloc_mbi_struct(void *old, unsigned int bytes)
>  {
>      void *new;

In an earlier version you added some shouting warning comments to
point out where the entry point here is. Without your adjustment it
was right at the top of the file, making it rather obvious. I don't see
what the adjustment you do here is good for, and you also don't
say so (description is missing altogether).

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-10  8:23 ` [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
@ 2014-10-10 11:07   ` Daniel Kiper
  2014-10-10 12:25     ` Jan Beulich
  0 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-10 11:07 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

On Fri, Oct 10, 2014 at 09:23:55AM +0100, Jan Beulich wrote:
> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> > Patch #13 reveals a bug which probably was introduced between commit
> > 3e2331d271cc0882e4013c8f20398c46c35f90a1 (VT-d: suppress UR signaling for
> > further desktop chipsets) and 61fdda7acf3de11f3d50d50e5b4f4ecfac7e0d04
> > (x86/HVM: properly bound x2APIC MSR range). Xen crashes at video_endboot()
> > because earlier scrub process wipes vga_console_info data (sic!). So,
> > it means that at least page containing this structure was freed mistakenly
> > somewhere. Interestingly this issue appears on legacy BIOS machines only.
> > EFI platforms work as usual. It is possible to workaround this bug by
> > passing no-bootscrub to xen.gz.
>
> Giving a little more detail on how exactly things crash would be rather
> useful to make suggestions. Or if you intend to figure this out all by
> yourself, then I think you would have better done so before posting
> this series.

I am attaching console log. Xen crashes at xen/drivers/video/vga.c:video_endboot():175.

    switch ( boot_info->vga_console_info.video_type )
    {
    case XEN_VGATYPE_TEXT_MODE_3:
        if ( !vgacon_keep )
            memset(video, 0, columns * lines * 2);
        break;
    case XEN_VGATYPE_VESA_LFB:
    case XEN_VGATYPE_EFI_LFB:
        vesa_endboot(vgacon_keep);
        break;
    default:
        BUG();
        ^^^^^^ <------------- HERE
    }

If you suggest something then it will be nice.
I am going to work on this bug soon.

Daniel

[-- Attachment #2: xl-demsg.txt --]
[-- Type: text/plain, Size: 13969 bytes --]

(XEN) Xen version 4.5-unstable (root@local.net-space.pl) (gcc (Debian 4.7.2-5) 4.7.2) debug=y Wed Oct  8 19:19:55 CEST 2014
(XEN) Latest ChangeSet: Wed Oct 8 15:02:59 2014 +0200 git:309f109
(XEN) Console output is synchronous.
(XEN) Bootloader: GRUB 2.02~beta2
(XEN) Command line: apic_verbosity=debug com1=115200,8n1 conring_size=256k crashkernel=256m@64m dom0_mem=1g,max:1g guest_loglvl=all loglvl=all sync_console console=com1,vga noreboot
(XEN) Video information:
(XEN)  VGA is text mode 80x25, font 8x16
(XEN) Disc information:
(XEN)  Found 1 MBR signatures
(XEN)  Found 1 EDD information structures
(XEN) Xen-e820 RAM map:
(XEN)  0000000000000000 - 000000000009f400 (usable)
(XEN)  000000000009f400 - 00000000000a0000 (reserved)
(XEN)  00000000000f0000 - 0000000000100000 (reserved)
(XEN)  0000000000100000 - 000000007fffe000 (usable)
(XEN)  000000007fffe000 - 0000000080000000 (reserved)
(XEN)  00000000feffc000 - 00000000ff000000 (reserved)
(XEN)  00000000fffc0000 - 0000000100000000 (reserved)
(XEN) Kdump: 256MB (262144kB) at 0x4000000
(XEN) System RAM: 2047MB (2096756kB)
(XEN) ACPI: RSDP 000FD8E0, 0014 (r0 BOCHS )
(XEN) ACPI: RSDT 7FFFE470, 0038 (r1 BOCHS  BXPCRSDT        1 BXPC        1)
(XEN) ACPI: FACP 7FFFFF80, 0074 (r1 BOCHS  BXPCFACP        1 BXPC        1)
(XEN) ACPI: DSDT 7FFFE4B0, 1121 (r1   BXPC   BXDSDT        1 INTL 20100528)
(XEN) ACPI: FACS 7FFFFF40, 0040
(XEN) ACPI: SSDT 7FFFFD70, 01C1 (r1 BOCHS  BXPCSSDT        1 BXPC        1)
(XEN) ACPI: APIC 7FFFFC70, 0090 (r1 BOCHS  BXPCAPIC        1 BXPC        1)
(XEN) ACPI: HPET 7FFFFC30, 0038 (r1 BOCHS  BXPCHPET        1 BXPC        1)
(XEN) ACPI: SSDT 7FFFF5E0, 0644 (r1   BXPC BXSSDTPC        1 INTL 20100528)
(XEN) No NUMA configuration found
(XEN) Faking a node at 0000000000000000-000000007fffe000
(XEN) Domain heap initialised
(XEN) found SMP MP-table at 000fdac0
(XEN) DMI 2.4 present.
(XEN) APIC boot state is 'xapic'
(XEN) Using APIC driver default
(XEN) ACPI: PM-Timer IO Port: 0xb008
(XEN) ACPI: SLEEP INFO: pm1x_cnt[1:b004,1:0], pm1x_evt[1:b000,1:0]
(XEN) ACPI:             wakeup_vec[7fffff4c], vec_size[20]
(XEN) ACPI: Local APIC address 0xfee00000
(XEN) ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
(XEN) Processor #0 6:2 APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
(XEN) Processor #1 6:2 APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x02] lapic_id[0x02] enabled)
(XEN) Processor #2 6:2 APIC version 20
(XEN) ACPI: LAPIC (acpi_id[0x03] lapic_id[0x03] enabled)
(XEN) Processor #3 6:2 APIC version 20
(XEN) ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
(XEN) ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0])
(XEN) IOAPIC[0]: apic_id 4, version 17, address 0xfec00000, GSI 0-23
(XEN) ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
(XEN) ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
(XEN) ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
(XEN) ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
(XEN) ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
(XEN) ACPI: IRQ0 used by override.
(XEN) ACPI: IRQ2 used by override.
(XEN) ACPI: IRQ5 used by override.
(XEN) ACPI: IRQ9 used by override.
(XEN) ACPI: IRQ10 used by override.
(XEN) ACPI: IRQ11 used by override.
(XEN) Enabling APIC mode:  Flat.  Using 1 I/O APICs
(XEN) ACPI: HPET id: 0x8086a201 base: 0xfed00000
(XEN) ERST table was not found
(XEN) Using ACPI (MADT) for SMP configuration information
(XEN) SMP: Allowing 4 CPUs (0 hotplug CPUs)
(XEN) mapped APIC to ffff82cfffdfb000 (fee00000)
(XEN) mapped IOAPIC to ffff82cfffdfa000 (fec00000)
(XEN) IRQ limits: 24 GSI, 760 MSI/MSI-X
(XEN) Using scheduler: SMP Credit Scheduler (credit)
(XEN) Detected 2194.901 MHz processor.
(XEN) Initing memory sharing.
(XEN) traps.c:3151: GPF (0000): ffff82d0801ac1ae -> ffff82d080235e52
(XEN) mce_intel.c:719: MCA Capability: BCAST 0 SER 1 CMCI 0 firstbank 1 extended MCE MSR 0
(XEN) Intel machine check reporting enabled
(XEN) alt table ffff82d0802dbab0 -> ffff82d0802dcad0
(XEN) I/O virtualisation disabled
(XEN) Getting VERSION: 50014
(XEN) Getting VERSION: 50014
(XEN) Getting ID: 0
(XEN) Getting LVT0: 8700
(XEN) Getting LVT1: 8400
(XEN) enabled ExtINT on CPU#0
(XEN) ENABLING IO-APIC IRQs
(XEN)  -> Using new ACK method
(XEN) init IO_APIC IRQs
(XEN)  IO-APIC (apicid-pin) 4-0, 4-16, 4-17, 4-18, 4-19, 4-20, 4-21, 4-22, 4-23 not connected.
(XEN) ..TIMER: vector=0xF0 apic1=0 pin1=2 apic2=-1 pin2=-1
(XEN) number of MP IRQ sources: 15.
(XEN) number of IO-APIC #4 registers: 24.
(XEN) testing the IO APIC.......................
(XEN) IO APIC #4......
(XEN) .... register #00: 00000000
(XEN) .......    : physical APIC id: 00
(XEN) .......    : Delivery Type: 0
(XEN) .......    : LTS          : 0
(XEN) .... register #01: 00170011
(XEN) .......     : max redirection entries: 0017
(XEN) .......     : PRQ implemented: 0
(XEN) .......     : IO APIC version: 0011
(XEN) .... register #02: 00000000
(XEN) .......     : arbitration: 00
(XEN) .... IRQ redirection table:
(XEN)  NR Log Phy Mask Trig IRR Pol Stat Dest Deli Vect:
(XEN)  00 000 00  1    0    0   0   0    0    0    00
(XEN)  01 001 01  0    0    0   0   0    1    1    28
(XEN)  02 001 01  0    0    0   0   0    1    1    F0
(XEN)  03 001 01  0    0    0   0   0    1    1    30
(XEN)  04 001 01  0    0    0   0   0    1    1    F1
(XEN)  05 001 01  1    1    0   0   0    1    1    38
(XEN)  06 001 01  0    0    0   0   0    1    1    40
(XEN)  07 001 01  0    0    0   0   0    1    1    48
(XEN)  08 001 01  0    0    0   0   0    1    1    50
(XEN)  09 001 01  1    1    0   0   0    1    1    58
(XEN)  0a 001 01  1    1    0   0   0    1    1    60
(XEN)  0b 001 01  1    1    0   0   0    1    1    68
(XEN)  0c 001 01  0    0    0   0   0    1    1    70
(XEN)  0d 001 01  0    0    0   0   0    1    1    78
(XEN)  0e 001 01  0    0    0   0   0    1    1    88
(XEN)  0f 001 01  0    0    0   0   0    1    1    90
(XEN)  10 000 00  1    0    0   0   0    0    0    00
(XEN)  11 000 00  1    0    0   0   0    0    0    00
(XEN)  12 000 00  1    0    0   0   0    0    0    00
(XEN)  13 000 00  1    0    0   0   0    0    0    00
(XEN)  14 000 00  1    0    0   0   0    0    0    00
(XEN)  15 000 00  1    0    0   0   0    0    0    00
(XEN)  16 000 00  1    0    0   0   0    0    0    00
(XEN)  17 000 00  1    0    0   0   0    0    0    00
(XEN) Using vector-based indexing
(XEN) IRQ to pin mappings:
(XEN) IRQ240 -> 0:2
(XEN) IRQ40 -> 0:1
(XEN) IRQ48 -> 0:3
(XEN) IRQ241 -> 0:4
(XEN) IRQ56 -> 0:5
(XEN) IRQ64 -> 0:6
(XEN) IRQ72 -> 0:7
(XEN) IRQ80 -> 0:8
(XEN) IRQ88 -> 0:9
(XEN) IRQ96 -> 0:10
(XEN) IRQ104 -> 0:11
(XEN) IRQ112 -> 0:12
(XEN) IRQ120 -> 0:13
(XEN) IRQ136 -> 0:14
(XEN) IRQ144 -> 0:15
(XEN) .................................... done.
(XEN) Using local APIC timer interrupts.
(XEN) calibrating APIC timer ...
(XEN) ..... CPU clock speed is 2194.8175 MHz.
(XEN) ..... host bus clock speed is 1000.0244 MHz.
(XEN) ..... bus_scale = 0x40106
(XEN) Platform timer is 100.000MHz HPET
(XEN) Allocated console ring of 256 KiB.
(XEN) VMX: CPU0 has insufficient CPU-Based Exec Control (b299868c; requires 2299968c)
(XEN) VMX: CPU0 has insufficient VMExit Control (00000200; requires 00008200)
(XEN) VMX: failed to initialise.
(XEN) masked ExtINT on CPU#1
(XEN) masked ExtINT on CPU#2
(XEN) masked ExtINT on CPU#3
(XEN) Brought up 4 CPUs
(XEN) HPET: 0 timers usable for broadcast (3 total)
(XEN) ACPI sleep modes: S3
(XEN) mcheck_poll: Machine check polling timer started.
(XEN) mtrr: your CPUs had inconsistent variable MTRR settings
(XEN) mtrr: your CPUs had inconsistent MTRRdefType settings
(XEN) mtrr: probably your BIOS does not setup all CPUs.
(XEN) mtrr: corrected configuration.
(XEN) MTRR default type: write-back
(XEN) MTRR fixed ranges enabled:
(XEN)   00000-9ffff write-back
(XEN)   a0000-bffff uncachable
(XEN)   c0000-fffff write-protect
(XEN) MTRR variable ranges enabled:
(XEN)   0 base 00e0000000 mask ffe0000000 uncachable
(XEN)   1 disabled
(XEN)   2 disabled
(XEN)   3 disabled
(XEN)   4 disabled
(XEN)   5 disabled
(XEN)   6 disabled
(XEN)   7 disabled
(XEN)   8 disabled
(XEN)   9 disabled
(XEN) xenoprof: Initialization failed. Intel processor family 6 model 2is not supported
(XEN) *** LOADING DOMAIN 0 ***
(XEN) elf_parse_binary: phdr: paddr=0x1000000 memsz=0x57d000
(XEN) elf_parse_binary: phdr: paddr=0x1600000 memsz=0x76000
(XEN) elf_parse_binary: phdr: paddr=0x1676000 memsz=0x13600
(XEN) elf_parse_binary: phdr: paddr=0x168a000 memsz=0x596000
(XEN) elf_parse_binary: memory: 0x1000000 -> 0x1c20000
(XEN) elf_xen_parse_note: GUEST_OS = "linux"
(XEN) elf_xen_parse_note: GUEST_VERSION = "2.6"
(XEN) elf_xen_parse_note: XEN_VERSION = "xen-3.0"
(XEN) elf_xen_parse_note: VIRT_BASE = 0xffffffff80000000
(XEN) elf_xen_parse_note: ENTRY = 0xffffffff8168a1f0
(XEN) elf_xen_parse_note: HYPERCALL_PAGE = 0xffffffff81001000
(XEN) elf_xen_parse_note: FEATURES = "!writable_page_tables|pae_pgdir_above_4gb"
(XEN) elf_xen_parse_note: SUPPORTED_FEATURES = 0x801
(XEN) elf_xen_parse_note: PAE_MODE = "yes"
(XEN) elf_xen_parse_note: LOADER = "generic"
(XEN) elf_xen_parse_note: unknown xen elf note (0xd)
(XEN) elf_xen_parse_note: SUSPEND_CANCEL = 0x1
(XEN) elf_xen_parse_note: HV_START_LOW = 0xffff800000000000
(XEN) elf_xen_parse_note: PADDR_OFFSET = 0x0
(XEN) elf_xen_addr_calc_check: addresses:
(XEN)     virt_base        = 0xffffffff80000000
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0xffffffff80000000
(XEN)     virt_kstart      = 0xffffffff81000000
(XEN)     virt_kend        = 0xffffffff81c20000
(XEN)     virt_entry       = 0xffffffff8168a1f0
(XEN)     p2m_base         = 0xffffffffffffffff
(XEN)  Xen  kernel: 64-bit, lsb, compat32
(XEN)  Dom0 kernel: 64-bit, PAE, lsb, paddr 0x1000000 -> 0x1c20000
(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN)  Dom0 alloc.:   000000007a000000->000000007c000000 (253952 pages to be allocated)
(XEN) VIRTUAL MEMORY ARRANGEMENT:
(XEN)  Loaded kernel: ffffffff81000000->ffffffff81c20000
(XEN)  Init. ramdisk: ffffffff81c20000->ffffffff81c20000
(XEN)  Phys-Mach map: ffffffff81c20000->ffffffff81e20000
(XEN)  Start info:    ffffffff81e20000->ffffffff81e204b4
(XEN)  Page tables:   ffffffff81e21000->ffffffff81e34000
(XEN)  Boot stack:    ffffffff81e34000->ffffffff81e35000
(XEN)  TOTAL:         ffffffff80000000->ffffffff82000000
(XEN)  ENTRY ADDRESS: ffffffff8168a1f0
(XEN) Dom0 has maximum 4 VCPUs
(XEN) elf_load_binary: phdr 0 at 0xffffffff81000000 -> 0xffffffff8157d000
(XEN) elf_load_binary: phdr 1 at 0xffffffff81600000 -> 0xffffffff81676000
(XEN) elf_load_binary: phdr 2 at 0xffffffff81676000 -> 0xffffffff81689600
(XEN) elf_load_binary: phdr 3 at 0xffffffff8168a000 -> 0xffffffff8174b000
(XEN) Scrubbing Free RAM on 1 nodes using 4 CPUs
(XEN) ....done.
(XEN) Initial low memory virq threshold set at 0x4000 pages.
(XEN) Std. Loglevel: All
(XEN) Guest Loglevel: All
(XEN) **********************************************
(XEN) ******* WARNING: CONSOLE OUTPUT IS SYNCHRONOUS
(XEN) ******* This option is intended to aid debugging of Xen by ensuring
(XEN) ******* that all output is synchronously delivered on the serial line.
(XEN) ******* However it can introduce SIGNIFICANT latencies and affect
(XEN) ******* timekeeping. It is NOT recommended for production use!
(XEN) **********************************************
(XEN) 3... 2... 1...
(XEN) Xen is relinquishing VGA console.
(XEN) ----[ Xen-4.5-unstable  x86_64  debug=y  Tainted:    C ]----
(XEN) CPU:    0
(XEN) RIP:    e008:[<ffff82d0802b0a07>] video_endboot+0x22d/0x23e
(XEN) RFLAGS: 0000000000010292   CONTEXT: hypervisor
(XEN) rax: 00000000000000c2   rbx: 0000000000000000   rcx: 0000000000000000
(XEN) rdx: ffff82d0802e0000   rsi: 000000000000000a   rdi: ffff82d0802956c0
(XEN) rbp: ffff82d0802e7e28   rsp: ffff82d0802e7de8   r8:  ffff83007fd40000
(XEN) r9:  0000000000000000   r10: 000000021076383c   r11: 000000079464a225
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: ffff82d08025e4d9
(XEN) r15: 0000000000000000   cr0: 000000008005003b   cr4: 00000000000026f0
(XEN) cr3: 000000007fc93000   cr2: 0000000000000000
(XEN) ds: 0000   es: 0000   fs: 0000   gs: 0000   ss: 0000   cs: e008
(XEN) Xen stack trace from rsp=ffff82d0802e7de8:
(XEN)    ffff82d0802e7e38 ffff82d0802e7df8 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 ffff82d08025e4d9 0000000000000000
(XEN)    ffff82d0802e7e58 ffff82d0802a6074 ffff82d0802d8280 ffff83007fff3fe0
(XEN)    ffff83007fd39000 0000000000000040 ffff82d0802e7f08 ffff82d0802bc3be
(XEN)    ffff82d0802b2cec 0000000000000000 0000000000100000 ffff82d080310bf4
(XEN)    0000000000b55000 000000000007fffe ffffff0000e59b10 000000000000000d
(XEN)    0000000000000000 ffff82d000000003 0000000800000000 000000010000006e
(XEN)    0000000000000003 00000000000002f8 ffff82d0802e7f08 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 ffff82d0801000cb 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    ffff83007fd2c000 0000000000000000 0000000000000000
(XEN) Xen call trace:
(XEN)    [<ffff82d0802b0a07>] video_endboot+0x22d/0x23e
(XEN)    [<ffff82d0802a6074>] console_endboot+0x18b/0x1c6
(XEN)    [<ffff82d0802bc3be>] __start_xen+0x1977/0x19be
(XEN)    [<ffff82d0801000cb>] __high_start+0x5b/0x60
(XEN)
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) FATAL TRAP: vector = 6 (invalid opcode)
(XEN) ****************************************
(XEN)
(XEN) Manual reset required ('noreboot' specified)

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-09 10:28   ` Andrew Cooper
@ 2014-10-10 11:47     ` Daniel Kiper
  2014-10-10 12:48       ` Jan Beulich
  2014-10-13 10:21       ` Andrew Cooper
  0 siblings, 2 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-10 11:47 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Thu, Oct 09, 2014 at 11:28:04AM +0100, Andrew Cooper wrote:
> On 08/10/14 18:52, Daniel Kiper wrote:
> > 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.
> >
> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> > ---
> > v3 - suggestions/fixes:
> >    - rename some variables
> >      (suggested by Andrew Cooper),
> >    - remove unneeded initialization
> >      (suggested by Andrew Cooper),
> >    - improve comments
> >      (suggested by Andrew Cooper),
> >    - further patch split rearrangement
> >      (suggested by Andrew Cooper and Jan Beulich).
> >
> > 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          |    2 +-
> >  xen/arch/x86/boot/reloc.c         |   69 +++++++++++++++++++++-----------
> >  xen/arch/x86/boot/x86_64.S        |   10 +++--
> >  xen/arch/x86/boot_info.c          |   59 +++++++++++++++++++++++++++
> >  xen/arch/x86/setup.c              |   41 ++++++++++++-------
> >  xen/arch/x86/x86_64/asm-offsets.c |    5 +--
> >  xen/include/asm-x86/mbd.h         |   79 +++++++++++++++++++++++++++++++++++++
> >  9 files changed, 225 insertions(+), 50 deletions(-)
> >  create mode 100644 xen/arch/x86/boot_info.c
> >  create mode 100644 xen/include/asm-x86/mbd.h
> >
> > diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
> > index 86ca5f8..8425e65 100644
> > --- a/xen/arch/x86/Makefile
> > +++ b/xen/arch/x86/Makefile
> > @@ -43,6 +43,7 @@ obj-y += pci.o
> >  obj-y += percpu.o
> >  obj-y += physdev.o
> >  obj-y += psr.o
> > +obj-y += boot_info.o
> >  obj-y += setup.o
> >  obj-y += shutdown.o
> >  obj-y += smp.o
> > diff --git a/xen/arch/x86/boot/cmdline.S b/xen/arch/x86/boot/cmdline.S
> > index 00687eb..dd1a027 100644
> > --- a/xen/arch/x86/boot/cmdline.S
> > +++ b/xen/arch/x86/boot/cmdline.S
> > @@ -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_pa),%ebx
> > +        mov     MBD_cmdline_pa(%ebx),%eax
>
> What sets the value of MBD_cmdline_pa?  You are blindly consuming it
> here without checks the flags for its presence, but I can't spot
> anything in this patch which ever sets it.

This translates to mbd->cmdline. If mbd->cmdline == 0 then there is not
cmdline passed to xen.gz. It translates to test %eax,%eax one line below.
Please check also xen/arch/x86/boot/reloc.c:__reloc() and
xen/arch/x86/boot/reloc.c:mb_mbd() for more details.

Hmmm... Now I am thinking that MBD_cmdline_pa() should be MBD_cmdline()
as it was earlier. This will make less confusion.

> >          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_pa(%ebx)
> >          call    .Lfind_option
> >          test    %eax,%eax
> >          setnz   %al
> > diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> > index cd43952..f1b872a 100644
> > --- a/xen/arch/x86/boot/head.S
> > +++ b/xen/arch/x86/boot/head.S
> > @@ -120,7 +120,7 @@ __start:
> >          mov     $sym_phys(cpu0_stack)+1024,%esp
> >          push    %ebx
> >          call    reloc
> > -        mov     %eax,sym_phys(multiboot_ptr)
> > +        mov     %eax,sym_phys(mbd_pa)
> >
> >          /* Initialize BSS (no nasty surprises!) */
> >          mov     $sym_phys(__bss_start),%edi
> > diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> > index b678f67..59edb4d 100644
> > --- a/xen/arch/x86/boot/reloc.c
> > +++ b/xen/arch/x86/boot/reloc.c
> > @@ -12,8 +12,11 @@
> >
> >  typedef unsigned int u32;
> >
> > +#include "../../../include/xen/compiler.h"
> >  #include "../../../include/xen/multiboot.h"
> >
> > +#include "../../../include/asm/mbd.h"
> > +
> >  /* entered with %eax = BOOT_TRAMPOLINE */
> >  asm (
> >      "    .text                         \n"
> > @@ -22,7 +25,7 @@ asm (
> >      "    call 1f                       \n"
> >      "1:  pop  %ebx                     \n"
> >      "    mov  %eax,alloc-1b(%ebx)      \n"
> > -    "    jmp  reloc                    \n"
> > +    "    jmp  __reloc                  \n"
>
> Why do you need to change the name of the reloc() function?  reloc()
> seems like a fine name.

I will leave it as is.

> >      );
> >
> >  /*
> > @@ -50,6 +53,13 @@ static u32 alloc_struct(u32 bytes)
> >      return s;
> >  }
> >
> > +static void zero_struct(u32 s, u32 bytes)
>
> "static void memclear(void *ptr, size_t bytes)" would seem to be more
> appropriate, and avoid you needing to cast the pointers you actually
> pass into it.

OK.

> > +{
> > +    asm volatile(
> > +    "    rep  stosb                   \n"
>
> For a single instruction instruction asm statement, just use 'asm
> volatile ("rep stosb" ...'  No need for these multi-line hoops to create
> a readable .S

OK.

> > +       : "+D" (s), "+c" (bytes) : "a" (0));
> > +}
> > +
> >  static u32 copy_struct(u32 src, u32 bytes)
> >  {
> >      u32 dst, dst_asm;
> > @@ -77,41 +87,56 @@ static u32 copy_string(u32 src)
> >      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 = (multiboot_info_t *)copy_struct((u32)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 = copy_string(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;
> > +    }
>
> Now I am completely confused.  here you set mbd from mbi, but lower in
> init_mbi, you set mbi from mbd.  What is the intended dataflow?

We need mbi together with boot_info to make smooth transition from mbi
to boot_info possible. Patch #10 completely removes mbi from Xen main code.
I mentioned about that in commit message.

> > +
> > +    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 = (module_t *)copy_struct(
> > -            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 = copy_string(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 = copy_struct(mbi->mmap_addr, mbi->mmap_length);
> > +    return mbd;
> > +}
> >
> > -    if ( mbi->flags & MBI_LOADERNAME )
> > -        mbi->boot_loader_name = copy_string(mbi->boot_loader_name);
> > +static mbd_t __used *__reloc(void *mbi)
> > +{
> > +    mbd_t *mbd;
> >
> > -    /* Mask features we don't understand or don't relocate. */
> > -    mbi->flags &= (MBI_MEMLIMITS |
> > -                   MBI_BOOTDEV |
> > -                   MBI_CMDLINE |
> > -                   MBI_MODULES |
> > -                   MBI_MEMMAP |
> > -                   MBI_LOADERNAME);
> > +    mbd = (mbd_t *)alloc_struct(sizeof(mbd_t));
> > +    zero_struct((u32)mbd, sizeof(mbd_t));
> >
> > -    return mbi;
> > +    return mb_mbd(mbd, mbi);
> >  }
> > diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
> > index bfbafd2..ef8c735 100644
> > --- a/xen/arch/x86/boot/x86_64.S
> > +++ b/xen/arch/x86/boot/x86_64.S
> > @@ -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 mbi. */
>
> This is wholly useless as a comment.  "Initialise Multiboot Info" would
> be better, but still identifiable from the name of the function.

OK.

> > +        mov     mbd_pa(%rip),%edi
> > +        call    __init_mbi
> > +
> > +        /* Pass off the mbi to C land. */
>
> Again, for the commit it would be useful to expand mbi.

OK.

> > +        movq    %rax,%rdi
> >          call    __start_xen
> >          ud2     /* Force a panic (invalid opcode). */
> >
> > @@ -38,7 +42,7 @@
> >
> >          .data
> >          .align 8
> > -multiboot_ptr:
> > +mbd_pa:
> >          .long   0
> >
> >          .word   0
> > diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> > new file mode 100644
> > index 0000000..a2799aa
> > --- /dev/null
> > +++ b/xen/arch/x86/boot_info.c
> > @@ -0,0 +1,59 @@
> > +/*
> > + * 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/>.
> > + */
> > +
> > +#include <xen/types.h>
> > +#include <xen/cache.h>
> > +#include <xen/init.h>
> > +#include <xen/multiboot.h>
> > +
> > +#include <asm/mbd.h>
> > +#include <asm/page.h>
> > +
> > +static multiboot_info_t __read_mostly mbi;
> > +
> > +extern void enable_exception_support(void);
>
> No externs in .c files.  This should be in a header file.

I am still do not understand what is wrong with that. We need
that function only here. So, why we should put it in a header?

> (I am still not particularly happy about splitting exception support
> like this, but I can't currently suggest a better alternative)

I am too.

> > +
> > +unsigned long __init __init_mbi(u32 mbd_pa)
> > +{
> > +    mbd_t *mbd = __va(mbd_pa);
> > +
> > +    enable_exception_support();
> > +
> > +    if ( mbd->boot_loader_name ) {
>
> Xen style

OK.

> > +        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);
> > +}
> > diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> > index 8c8b91f..24e1be3 100644
> > --- a/xen/arch/x86/setup.c
> > +++ b/xen/arch/x86/setup.c
> > @@ -529,6 +529,25 @@ static char * __init cmdline_cook(char *p, char *loader_name)
> >      return p;
> >  }
> >
> > +void __init enable_exception_support(void)
>
> This should have bsp somewhere in the name, as it is specifically
> different to the ap method of gaining exception support.

I think that enable_bsp_exception_support(void) will be fine.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-10 11:07   ` Daniel Kiper
@ 2014-10-10 12:25     ` Jan Beulich
  2014-10-10 13:03       ` Daniel Kiper
  0 siblings, 1 reply; 52+ messages in thread
From: Jan Beulich @ 2014-10-10 12:25 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 10.10.14 at 13:07, <daniel.kiper@oracle.com> wrote:
> On Fri, Oct 10, 2014 at 09:23:55AM +0100, Jan Beulich wrote:
>> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
>> > Patch #13 reveals a bug which probably was introduced between commit
>> > 3e2331d271cc0882e4013c8f20398c46c35f90a1 (VT-d: suppress UR signaling for
>> > further desktop chipsets) and 61fdda7acf3de11f3d50d50e5b4f4ecfac7e0d04
>> > (x86/HVM: properly bound x2APIC MSR range). Xen crashes at video_endboot()
>> > because earlier scrub process wipes vga_console_info data (sic!). So,
>> > it means that at least page containing this structure was freed mistakenly
>> > somewhere. Interestingly this issue appears on legacy BIOS machines only.
>> > EFI platforms work as usual. It is possible to workaround this bug by
>> > passing no-bootscrub to xen.gz.
>>
>> Giving a little more detail on how exactly things crash would be rather
>> useful to make suggestions. Or if you intend to figure this out all by
>> yourself, then I think you would have better done so before posting
>> this series.
> 
> I am attaching console log. Xen crashes at 
> xen/drivers/video/vga.c:video_endboot():175.
> 
>     switch ( boot_info->vga_console_info.video_type )

Without your changes this line is

    switch ( vga_console_info.video_type )

with the variable being a global, non-_initdata one. That way it just
can't go away unless we have some sort of memory corruption.
Therefore I would rather think that the problem is inside your series.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-10 11:47     ` Daniel Kiper
@ 2014-10-10 12:48       ` Jan Beulich
  2014-10-13 10:21       ` Andrew Cooper
  1 sibling, 0 replies; 52+ messages in thread
From: Jan Beulich @ 2014-10-10 12:48 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	Andrew Cooper, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 10.10.14 at 13:47, <daniel.kiper@oracle.com> wrote:
> On Thu, Oct 09, 2014 at 11:28:04AM +0100, Andrew Cooper wrote:
>> On 08/10/14 18:52, Daniel Kiper wrote:
>> > --- /dev/null
>> > +++ b/xen/arch/x86/boot_info.c
>> > @@ -0,0 +1,59 @@
>> > +/*
>> > + * 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/>.
>> > + */
>> > +
>> > +#include <xen/types.h>
>> > +#include <xen/cache.h>
>> > +#include <xen/init.h>
>> > +#include <xen/multiboot.h>
>> > +
>> > +#include <asm/mbd.h>
>> > +#include <asm/page.h>
>> > +
>> > +static multiboot_info_t __read_mostly mbi;
>> > +
>> > +extern void enable_exception_support(void);
>>
>> No externs in .c files.  This should be in a header file.
> 
> I am still do not understand what is wrong with that. We need
> that function only here. So, why we should put it in a header?

Because any declaration should be seen not only by all consumers,
but also by the producer (unless that is an assembly file of course),
to make sure declaration and definition agree with one another.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-10 12:25     ` Jan Beulich
@ 2014-10-10 13:03       ` Daniel Kiper
  0 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-10 13:03 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Fri, Oct 10, 2014 at 01:25:20PM +0100, Jan Beulich wrote:
> >>> On 10.10.14 at 13:07, <daniel.kiper@oracle.com> wrote:
> > On Fri, Oct 10, 2014 at 09:23:55AM +0100, Jan Beulich wrote:
> >> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> >> > Patch #13 reveals a bug which probably was introduced between commit
> >> > 3e2331d271cc0882e4013c8f20398c46c35f90a1 (VT-d: suppress UR signaling for
> >> > further desktop chipsets) and 61fdda7acf3de11f3d50d50e5b4f4ecfac7e0d04
> >> > (x86/HVM: properly bound x2APIC MSR range). Xen crashes at video_endboot()
> >> > because earlier scrub process wipes vga_console_info data (sic!). So,
> >> > it means that at least page containing this structure was freed mistakenly
> >> > somewhere. Interestingly this issue appears on legacy BIOS machines only.
> >> > EFI platforms work as usual. It is possible to workaround this bug by
> >> > passing no-bootscrub to xen.gz.
> >>
> >> Giving a little more detail on how exactly things crash would be rather
> >> useful to make suggestions. Or if you intend to figure this out all by
> >> yourself, then I think you would have better done so before posting
> >> this series.
> >
> > I am attaching console log. Xen crashes at
> > xen/drivers/video/vga.c:video_endboot():175.
> >
> >     switch ( boot_info->vga_console_info.video_type )
>
> Without your changes this line is
>
>     switch ( vga_console_info.video_type )
>
> with the variable being a global, non-_initdata one. That way it just
> can't go away unless we have some sort of memory corruption.
> Therefore I would rather think that the problem is inside your series.

I do not rule it out but... v2 which I sent previously works correctly. v3 is
just better split of v2 (with minor changes). Additonally, boot_info
points to boot_info_mb on legacy BIOS which is defined in
xen/arch/x86/boot_info.c as static boot_info_t __read_mostly boot_info_mb.

readelf -Wa xen/xen-syms shows:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        ffff82d080100000 001000 13637e 00 WAX  0   0 4096
  [ 2] .rodata           PROGBITS        ffff82d080236380 137380 0471f0 00   A  0   0 32
  [ 3] .data.read_mostly PROGBITS        ffff82d08027d580 17e580 00ab38 00  WA  0   0 128
  [ 4] .data             PROGBITS        ffff82d080289000 18a000 00e3c8 00  WA  0   0 4096
  [ 5] .discard          PROGBITS        ffff82d0802973c8 1983c8 00014e 00  WA  0   0  1
  [ 6] .init.text        PROGBITS        ffff82d080298000 199000 032ae9 00  AX  0   0 16
  [ 7] .init.data        PROGBITS        ffff82d0802cab00 1cbb00 011fb0 00  WA  0   0 32
  [ 8] .init.setup       PROGBITS        ffff82d0802dcac0 1ddac0 001220 00  WA  0   0 32
  [ 9] .initcall.init    PROGBITS        ffff82d0802ddce0 1dece0 000218 00  WA  0   0  8
  [10] .bss              NOBITS          ffff82d0802e0000 1deef8 049e00 00  WA  0   0 128

I thoutgh that .data.read_mostly is adjacent to .init.* section, which
would be an explanation, but it is not the case. So, what is wrong?

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file
  2014-10-10  8:50   ` Jan Beulich
@ 2014-10-10 13:17     ` Daniel Kiper
  2014-10-10 13:33       ` Jan Beulich
  0 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-10 13:17 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Fri, Oct 10, 2014 at 09:50:12AM +0100, Jan Beulich wrote:
> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> > --- a/xen/arch/x86/boot/reloc.c
> > +++ b/xen/arch/x86/boot/reloc.c
> > @@ -10,6 +10,10 @@
> >   *    Keir Fraser <keir@xen.org>
> >   */
> >
> > +typedef unsigned int u32;
> > +
> > +#include "../../../include/xen/multiboot.h"
> > +
> >  /* entered with %eax = BOOT_TRAMPOLINE */
> >  asm (
> >      "    .text                         \n"
> > @@ -30,9 +34,6 @@ asm (
> >      "    .long 0                       \n"
> >      );
> >
> > -typedef unsigned int u32;
> > -#include "../../../include/xen/multiboot.h"
> > -
> >  static void *reloc_mbi_struct(void *old, unsigned int bytes)
> >  {
> >      void *new;
>
> In an earlier version you added some shouting warning comments to
> point out where the entry point here is. Without your adjustment it
> was right at the top of the file, making it rather obvious. I don't see
> what the adjustment you do here is good for, and you also don't
> say so (description is missing altogether).

Personally I think that all includes and definitions/declarations should be
at the beginning of file (if it is possible) and separated from the "real code".
This makes files more readable. So, that is why I am doing this here.
Additionally, I have improved comment seen above in patch #16 but it is much
softer (no shouting) as we agreed earlier.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file
  2014-10-10 13:17     ` Daniel Kiper
@ 2014-10-10 13:33       ` Jan Beulich
  0 siblings, 0 replies; 52+ messages in thread
From: Jan Beulich @ 2014-10-10 13:33 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 10.10.14 at 15:17, <daniel.kiper@oracle.com> wrote:
> On Fri, Oct 10, 2014 at 09:50:12AM +0100, Jan Beulich wrote:
>> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
>> > --- a/xen/arch/x86/boot/reloc.c
>> > +++ b/xen/arch/x86/boot/reloc.c
>> > @@ -10,6 +10,10 @@
>> >   *    Keir Fraser <keir@xen.org>
>> >   */
>> >
>> > +typedef unsigned int u32;
>> > +
>> > +#include "../../../include/xen/multiboot.h"
>> > +
>> >  /* entered with %eax = BOOT_TRAMPOLINE */
>> >  asm (
>> >      "    .text                         \n"
>> > @@ -30,9 +34,6 @@ asm (
>> >      "    .long 0                       \n"
>> >      );
>> >
>> > -typedef unsigned int u32;
>> > -#include "../../../include/xen/multiboot.h"
>> > -
>> >  static void *reloc_mbi_struct(void *old, unsigned int bytes)
>> >  {
>> >      void *new;
>>
>> In an earlier version you added some shouting warning comments to
>> point out where the entry point here is. Without your adjustment it
>> was right at the top of the file, making it rather obvious. I don't see
>> what the adjustment you do here is good for, and you also don't
>> say so (description is missing altogether).
> 
> Personally I think that all includes and definitions/declarations should be
> at the beginning of file (if it is possible) and separated from the "real 
> code".
> This makes files more readable. So, that is why I am doing this here.

While generally I agree, I think there are always reasons for exceptions.
And this is one of them.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure Daniel Kiper
  2014-10-09 10:48   ` Andrew Cooper
@ 2014-10-10 13:55   ` Stefano Stabellini
  2014-10-10 20:44     ` Daniel Kiper
  1 sibling, 1 reply; 52+ messages in thread
From: Stefano Stabellini @ 2014-10-10 13:55 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Wed, 8 Oct 2014, Daniel Kiper wrote:
> This patch introduces boot_info structure. Subsequent patches will move
> step by step all boot related data to above mentioned struct. At the end
> of this process multiboot (v1) protocol dependency will be broken. It means
> that most of Xen code (excluding preloader) could be bootloader agnostic
> and does not need almost any knowledge about boot protocol. Additionally,
> it will be possible 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 has not been tested yet.

I am not completely against this patch series for 4.5 but I am really
wary of allowing this amount of changes to EFI (which is now working on
ARM) at this stage of the release cycle without even being built tested
on ARM.

We need to make sure it doesn't introduce any regressions on x86 but
also on ARM, so even if the ARM bits are not implemented, I think it
should be required that the series is not only compiled but also
properly tested on ARM too.


> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v3 - suggestions/fixes:
>    - further patch split rearrangement
>      (suggested by Andrew Cooper).
> 
> 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/x86_64.S      |   10 +++++++--
>  xen/arch/x86/boot_info.c        |   11 ++++++++++
>  xen/arch/x86/efi/efi-boot.h     |    3 ++-
>  xen/arch/x86/setup.c            |   13 ++++++++++-
>  xen/common/efi/efi.h            |    7 ++++++
>  xen/common/efi/runtime.c        |   10 +++++++++
>  xen/include/asm-x86/boot_info.h |   46 +++++++++++++++++++++++++++++++++++++++
>  7 files changed, 96 insertions(+), 4 deletions(-)
>  create mode 100644 xen/include/asm-x86/boot_info.h
> 
> diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
> index ef8c735..647c33b 100644
> --- a/xen/arch/x86/boot/x86_64.S
> +++ b/xen/arch/x86/boot/x86_64.S
> @@ -32,9 +32,15 @@
>          /* Init mbi. */
>          mov     mbd_pa(%rip),%edi
>          call    __init_mbi
> +        pushq   %rax
> +
> +        /* Init boot_info. */
> +        mov     mbd_pa(%rip),%edi
> +        call    __init_boot_info
>  
> -        /* Pass off the mbi to C land. */
> -        movq    %rax,%rdi
> +        /* Pass off the mbi and boot_info to C land. */
> +        popq    %rdi
> +        movq    %rax,%rsi
>          call    __start_xen
>          ud2     /* Force a panic (invalid opcode). */
>  
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index a2799aa..83bd255 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -20,11 +20,17 @@
>  #include <xen/init.h>
>  #include <xen/multiboot.h>
>  
> +#include <asm/boot_info.h>
>  #include <asm/mbd.h>
>  #include <asm/page.h>
>  
>  static multiboot_info_t __read_mostly mbi;
>  
> +static boot_info_t __read_mostly boot_info_mb = {
> +    .warn_msg = NULL,
> +    .err_msg = NULL
> +};
> +
>  extern void enable_exception_support(void);
>  
>  unsigned long __init __init_mbi(u32 mbd_pa)
> @@ -57,3 +63,8 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>  
>      return __pa(&mbi);
>  }
> +
> +paddr_t __init __init_boot_info(u32 mbd_pa)
> +{
> +    return __pa(&boot_info_mb);
> +}
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 71030b0..6d7c222 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -254,7 +254,8 @@ static void __init noreturn efi_arch_post_exit_boot(void)
>                       [cs] "ir" (__HYPERVISOR_CS),
>                       [ds] "r" (__HYPERVISOR_DS),
>                       [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)),
> -                     "D" (&mbi)
> +                     "D" (&mbi),
> +                     "S" (&boot_info_efi)
>                     : "memory" );
>      for( ; ; ); /* not reached */
>  }
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 24e1be3..d2a1450 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -49,6 +49,7 @@
>  #include <xen/cpu.h>
>  #include <asm/nmi.h>
>  #include <asm/alternative.h>
> +#include <asm/boot_info.h>
>  
>  /* opt_nosmp: If true, secondary processors are ignored. */
>  static bool_t __initdata opt_nosmp;
> @@ -92,6 +93,8 @@ unsigned long __initdata highmem_start;
>  size_param("highmem-start", highmem_start);
>  #endif
>  
> +boot_info_t *boot_info;
> +
>  cpumask_t __read_mostly cpu_present_map;
>  
>  unsigned long __read_mostly xen_phys_start;
> @@ -548,7 +551,7 @@ void __init enable_exception_support(void)
>      /* Full exception support from here on in. */
>  }
>  
> -void __init noreturn __start_xen(unsigned long mbi_p)
> +void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>  {
>      char *memmap_type = NULL;
>      char *cmdline, *kextra, *loader;
> @@ -565,6 +568,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>          .stop_bits = 1
>      };
>  
> +    boot_info = __va(boot_info_pa);
> +
>      if ( efi_enabled ) {
>          enable_exception_support();
>      }
> @@ -613,6 +618,12 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>      ehci_dbgp_init();
>      console_init_preirq();
>  
> +    if ( boot_info->err_msg )
> +        panic(boot_info->err_msg);
> +
> +    if ( boot_info->warn_msg )
> +        printk(boot_info->warn_msg);
> +
>      printk("Bootloader: %s\n", loader);
>  
>      printk("Command line: %s\n", cmdline);
> diff --git a/xen/common/efi/efi.h b/xen/common/efi/efi.h
> index bee3b77..526f57c 100644
> --- a/xen/common/efi/efi.h
> +++ b/xen/common/efi/efi.h
> @@ -8,6 +8,9 @@
>  #include <xen/efi.h>
>  #include <xen/spinlock.h>
>  #include <asm/page.h>
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +#include <asm/boot_info.h>
> +#endif
>  
>  struct efi_pci_rom {
>      const struct efi_pci_rom *next;
> @@ -25,6 +28,10 @@ extern const CHAR16 *efi_fw_vendor;
>  
>  extern EFI_RUNTIME_SERVICES *efi_rs;
>  
> +#ifndef CONFIG_ARM /* TODO - boot_info is not implemented on ARM yet */
> +extern boot_info_t boot_info_efi;
> +#endif
> +
>  extern UINTN efi_memmap_size, efi_mdesc_size;
>  extern void *efi_memmap;
>  
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index 1c43d10..eb0acae 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -5,6 +5,9 @@
>  #include <xen/guest_access.h>
>  #include <xen/irq.h>
>  #include <xen/time.h>
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +#include <asm/boot_info.h>
> +#endif
>  
>  DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  
> @@ -50,6 +53,13 @@ struct efi __read_mostly efi = {
>  const struct efi_pci_rom *__read_mostly efi_pci_roms;
>  
>  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +boot_info_t __read_mostly boot_info_efi = {
> +    .warn_msg = NULL,
> +    .err_msg = NULL
> +};
> +#endif
> +
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
>  unsigned long efi_rs_enter(void)
>  {
>      static const u16 fcw = FCW_DEFAULT;
> diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
> new file mode 100644
> index 0000000..9ff3c0f
> --- /dev/null
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -0,0 +1,46 @@
> +/*
> + * 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/>.
> + */
> +
> +#ifndef __BOOT_INFO_H__
> +#define __BOOT_INFO_H__
> +
> +/*
> + * Define boot_info type. It will be used to define variable which in turn
> + * will store data collected by bootloader and preloader. This way it will
> + * be possible to make most of Xen code bootloader agnostic.
> + *
> + * Some members should have relevant EFI/ACPI types. However, due to type
> + * conflicts among ACPI and EFI headers it is not possible to use required
> + * EFI/ACPI types here. Instead of them there are simple types in use which
> + * are compatible as much as possible with relevant EFI/ACPI types.
> + */
> +typedef struct {
> +    /*
> +     * Info about warning occurred during boot_info initialization.
> +     * NULL if everything went OK.
> +     */
> +    char *warn_msg;
> +
> +    /*
> +     * Info about error occurred during boot_info initialization. NULL if everything
> +     * went OK. Otherwise boot_info is not fully/properly initialized.
> +     */
> +    char *err_msg;
> +} boot_info_t;
> +
> +extern boot_info_t *boot_info;
> +#endif /* __BOOT_INFO_H__ */
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff to boot_info
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff " Daniel Kiper
@ 2014-10-10 14:02   ` Stefano Stabellini
  2014-10-10 20:26     ` Daniel Kiper
  0 siblings, 1 reply; 52+ messages in thread
From: Stefano Stabellini @ 2014-10-10 14:02 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, keir, ian.campbell, andrew.cooper3, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, jbeulich, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Wed, 8 Oct 2014, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  xen/arch/x86/boot_info.c        |  105 ++++++++++++++++++++++++++++++++++++---
>  xen/arch/x86/efi/efi-boot.h     |   18 +++----
>  xen/arch/x86/setup.c            |   73 ++-------------------------
>  xen/common/efi/runtime.c        |    7 +++
>  xen/include/asm-x86/boot_info.h |   22 ++++++++
>  xen/include/asm-x86/e820.h      |    8 ---
>  6 files changed, 138 insertions(+), 95 deletions(-)
> 
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index 7101f6c..53e890b 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -15,40 +15,127 @@
>   * 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/init.h>
>  #include <xen/multiboot.h>
>  
>  #include <asm/boot_info.h>
> +#include <asm/e820.h>
>  #include <asm/mbd.h>
>  #include <asm/page.h>
>  
> +/* These symbols live in the boot trampoline. Access via bootsym(). */
> +extern struct e820entry e820map[];
> +extern unsigned int e820nr;
> +extern unsigned int lowmem_kb, highmem_kb;
> +
>  static multiboot_info_t __read_mostly mbi;
>  
>  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,
>      .warn_msg = NULL,
>      .err_msg = NULL
>  };
>  
> +#define e820_raw bootsym(e820map)
> +#define e820_raw_nr bootsym(e820nr)
> +
>  extern void enable_exception_support(void);
>  
> +static void __init init_mmap(boot_info_t *boot_info, mbd_t *mbd)
> +{
> +    int bytes = 0;
> +    memory_map_t *map;
> +
> +    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";
> +            }
> +
> +            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";
> +
> +        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;
> +}
> +
>  unsigned long __init __init_mbi(u32 mbd_pa)
>  {
>      mbd_t *mbd = __va(mbd_pa);
>  
>      enable_exception_support();
>  
> -    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;
> @@ -66,5 +153,7 @@ paddr_t __init __init_boot_info(u32 mbd_pa)
>      if ( mbd->cmdline )
>          boot_info_mb.cmdline = __va(mbd->cmdline);
>  
> +    init_mmap(&boot_info_mb, mbd);
> +
>      return __pa(&boot_info_mb);
>  }
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 3b5628a..8e57ac2 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -148,7 +148,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
>      unsigned int i;
>  
>      /* Populate E820 table and check trampoline area availability. */
> -    e = e820map - 1;
> +    e = boot_info_efi.e820map - 1;
>      for ( i = 0; i < map_size; i += desc_size )
>      {
>          EFI_MEMORY_DESCRIPTOR *desc = map + i;
> @@ -182,10 +182,10 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
>              type = E820_NVS;
>              break;
>          }
> -        if ( e820nr && type == e->type &&
> +        if ( boot_info_efi.e820map_nr && type == e->type &&
>               desc->PhysicalStart == e->addr + e->size )
>              e->size += len;
> -        else if ( !len || e820nr >= E820MAX )
> +        else if ( !len || boot_info_efi.e820map_nr >= E820MAX )
>              continue;
>          else
>          {
> @@ -193,7 +193,7 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
>              e->addr = desc->PhysicalStart;
>              e->size = len;
>              e->type = type;
> -            ++e820nr;
> +            ++boot_info_efi.e820map_nr;
>          }
>      }
>  
> @@ -201,12 +201,12 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable,
>  
>  static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size)
>  {
> -    place_string_u32(&mbi.mem_upper, NULL);
> -    mbi.mem_upper -= map_size;
> -    mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR);
> -    if ( mbi.mem_upper < xen_phys_start )
> +    place_string_u32(&boot_info_efi.mem_upper, NULL);
> +    boot_info_efi.mem_upper -= map_size;
> +    boot_info_efi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR);
> +    if ( boot_info_efi.mem_upper < xen_phys_start )
>          return NULL;
> -    return (void *)(long)mbi.mem_upper;
> +    return (void *)(long)boot_info_efi.mem_upper;
>  }
>  
>  static void __init efi_arch_pre_exit_boot(void)
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index d7416d3..de29d9e 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -553,13 +553,12 @@ void __init enable_exception_support(void)
>  
>  void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>  {
> -    char *memmap_type = NULL;
>      char *cmdline, *kextra;
>      unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
>      multiboot_info_t *mbi = __va(mbi_p);
>      module_t *mod = (module_t *)__va(mbi->mods_addr);
>      unsigned long nr_pages, raw_max_page, modules_headroom, *module_map;
> -    int i, j, e820_warn = 0, bytes = 0;
> +    int i, j;
>      bool_t acpi_boot_table_init_done = 0;
>      struct domain *dom0;
>      struct ns16550_defaults ns16550 = {
> @@ -692,77 +691,11 @@ void __init noreturn __start_xen(unsigned long mbi_p, paddr_t boot_info_pa)
>          /* Make boot page tables match non-EFI boot. */
>          l3_bootmap[l3_table_offset(BOOTSTRAP_MAP_BASE)] =
>              l3e_from_paddr(__pa(l2_bootmap), __PAGE_HYPERVISOR);
> -
> -        memmap_type = boot_info->boot_loader_name;
> -    }
> -    else if ( e820_raw_nr != 0 )
> -    {
> -        memmap_type = "Xen-e820";
>      }
> -    else if ( mbi->flags & MBI_MEMMAP )
> -    {
> -        memmap_type = "Multiboot-e820";
> -        while ( (bytes < mbi->mmap_length) && (e820_raw_nr < E820MAX) )
> -        {
> -            memory_map_t *map = __va(mbi->mmap_addr + bytes);
> -
> -            /*
> -             * 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.
> -             */
> -            if ( (map->base_addr_high == 0) && (map->length_high != 0) )
> -            {
> -                if ( !e820_warn )
> -                {
> -                    printk("WARNING: Buggy e820 map detected and fixed "
> -                           "(truncated length fields).\n");
> -                    e820_warn = 1;
> -                }
> -                map->length_high = 0;
> -            }
> -
> -            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) )
> -    {
> -        memmap_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 ( mbi->flags & MBI_MEMLIMITS )
> -    {
> -        memmap_type = "Multiboot-e801";
> -        e820_raw[0].addr = 0;
> -        e820_raw[0].size = mbi->mem_lower << 10;
> -        e820_raw[0].type = E820_RAM;
> -        e820_raw[1].addr = 0x100000;
> -        e820_raw[1].size = mbi->mem_upper << 10;
> -        e820_raw[1].type = E820_RAM;
> -        e820_raw_nr = 2;
> -    }
> -    else
> -        panic("Bootloader provided no memory information.");
>  
>      /* Sanitise the raw E820 map to produce a final clean version. */
> -    max_page = raw_max_page = init_e820(memmap_type, e820_raw, &e820_raw_nr);
> +    max_page = raw_max_page = init_e820(boot_info->mmap_type, boot_info->e820map,
> +                                        &boot_info->e820map_nr);
>  
>      /* Create a temporary copy of the E820 map. */
>      memcpy(&boot_e820, &e820, sizeof(e820));
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index ee2ee2d..865d0bc 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -7,6 +7,7 @@
>  #include <xen/time.h>
>  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
>  #include <asm/boot_info.h>
> +#include <asm/e820.h>
>  #endif
>  
>  DEFINE_XEN_GUEST_HANDLE(CHAR16);
> @@ -53,9 +54,15 @@ struct efi __read_mostly efi = {
>  const struct efi_pci_rom *__read_mostly efi_pci_roms;
>  
>  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +extern struct e820entry e820map[];
> +
>  boot_info_t __read_mostly boot_info_efi = {
>      .boot_loader_name = "EFI",
>      .cmdline = NULL,
> +    .mmap_type = "EFI",
> +    .mem_upper = 0,
> +    .e820map_nr = 0,
> +    .e820map = e820map,
>      .warn_msg = NULL,
>      .err_msg = NULL
>  };

This is not going in the right direction of getting rid of arch-specific
concepts from xen/common/efi/runtime.c.


> diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
> index d74ed67..640a420 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -18,6 +18,10 @@
>  #ifndef __BOOT_INFO_H__
>  #define __BOOT_INFO_H__
>  
> +#include <xen/types.h>
> +
> +#include <asm/e820.h>
> +
>  /*
>   * Define boot_info type. It will be used to define variable which in turn
>   * will store data collected by bootloader and preloader. This way it will
> @@ -35,6 +39,24 @@ typedef struct {
>      /* Xen command line. */
>      char *cmdline;
>  
> +    /* Memory map type (source of memory map). */
> +    char *mmap_type;

I realize that you inherited mmap_type from existing code, but shouldn't
this be an enum?


> +    /*
> +     * Amount of upper memory (in KiB) accordingly to The Multiboot
> +     * Specification version 0.6.96.
> +     */
> +    u32 mem_upper;
> +
> +    /* Number of memory map entries provided by Xen preloader. */
> +    unsigned int e820map_nr;
> +
> +    /*
> +     * Memory map provided by Xen preloader. It should always point
> +     * to an area able to accommodate at least E820MAX entries.
> +     */
> +    struct e820entry *e820map;
> +
>      /*
>       * Info about warning occurred during boot_info initialization.
>       * NULL if everything went OK.
> diff --git a/xen/include/asm-x86/e820.h b/xen/include/asm-x86/e820.h
> index d9ff4eb..8727afb 100644
> --- a/xen/include/asm-x86/e820.h
> +++ b/xen/include/asm-x86/e820.h
> @@ -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*/
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff to boot_info
  2014-10-10 14:02   ` Stefano Stabellini
@ 2014-10-10 20:26     ` Daniel Kiper
  0 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-10 20:26 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: jgross, keir, ian.campbell, andrew.cooper3, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Fri, Oct 10, 2014 at 03:02:43PM +0100, Stefano Stabellini wrote:
> On Wed, 8 Oct 2014, Daniel Kiper wrote:
> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

[...]

> > diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> > index ee2ee2d..865d0bc 100644
> > --- a/xen/common/efi/runtime.c
> > +++ b/xen/common/efi/runtime.c
> > @@ -7,6 +7,7 @@
> >  #include <xen/time.h>
> >  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> >  #include <asm/boot_info.h>
> > +#include <asm/e820.h>
> >  #endif
> >
> >  DEFINE_XEN_GUEST_HANDLE(CHAR16);
> > @@ -53,9 +54,15 @@ struct efi __read_mostly efi = {
> >  const struct efi_pci_rom *__read_mostly efi_pci_roms;
> >
> >  #ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> > +extern struct e820entry e820map[];
> > +
> >  boot_info_t __read_mostly boot_info_efi = {
> >      .boot_loader_name = "EFI",
> >      .cmdline = NULL,
> > +    .mmap_type = "EFI",
> > +    .mem_upper = 0,
> > +    .e820map_nr = 0,
> > +    .e820map = e820map,
> >      .warn_msg = NULL,
> >      .err_msg = NULL
> >  };
>
> This is not going in the right direction of getting rid of arch-specific
> concepts from xen/common/efi/runtime.c.

I thought about that a bit and decided to do this in that way right now.
However, I agree that finally (after introducing boot_info into ARM) there
should be an arch_boot_info_init() function which will initialize all
architecture specific stuff here.

> > diff --git a/xen/include/asm-x86/boot_info.h b/xen/include/asm-x86/boot_info.h
> > index d74ed67..640a420 100644
> > --- a/xen/include/asm-x86/boot_info.h
> > +++ b/xen/include/asm-x86/boot_info.h
> > @@ -18,6 +18,10 @@
> >  #ifndef __BOOT_INFO_H__
> >  #define __BOOT_INFO_H__
> >
> > +#include <xen/types.h>
> > +
> > +#include <asm/e820.h>
> > +
> >  /*
> >   * Define boot_info type. It will be used to define variable which in turn
> >   * will store data collected by bootloader and preloader. This way it will
> > @@ -35,6 +39,24 @@ typedef struct {
> >      /* Xen command line. */
> >      char *cmdline;
> >
> > +    /* Memory map type (source of memory map). */
> > +    char *mmap_type;
>
> I realize that you inherited mmap_type from existing code, but shouldn't
> this be an enum?

This is a boot loader name. I will improve the comment here.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure
  2014-10-10 13:55   ` Stefano Stabellini
@ 2014-10-10 20:44     ` Daniel Kiper
  0 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-10 20:44 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: jgross, keir, ian.campbell, andrew.cooper3, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Fri, Oct 10, 2014 at 02:55:51PM +0100, Stefano Stabellini wrote:
> On Wed, 8 Oct 2014, Daniel Kiper wrote:
> > This patch introduces boot_info structure. Subsequent patches will move
> > step by step all boot related data to above mentioned struct. At the end
> > of this process multiboot (v1) protocol dependency will be broken. It means
> > that most of Xen code (excluding preloader) could be bootloader agnostic
> > and does not need almost any knowledge about boot protocol. Additionally,
> > it will be possible 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 has not been tested yet.
>
> I am not completely against this patch series for 4.5 but I am really
> wary of allowing this amount of changes to EFI (which is now working on
> ARM) at this stage of the release cycle without even being built tested
> on ARM.
>
> We need to make sure it doesn't introduce any regressions on x86 but
> also on ARM, so even if the ARM bits are not implemented, I think it
> should be required that the series is not only compiled but also
> properly tested on ARM too.

I concur. Fortunately this patch series do not introduce major functional
changes in EFI code (there is only one function change). Hence, I hope
there should not be any regressions here. Anyway, I will do ARM test build
before next release (I hope that it will happen next week). However,
I do not have ARM hardware here so I am not able to do more tests. So,
I will be more than happy if somebody could do relevant tests for me.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-10 11:47     ` Daniel Kiper
  2014-10-10 12:48       ` Jan Beulich
@ 2014-10-13 10:21       ` Andrew Cooper
  2014-10-13 15:14         ` Daniel Kiper
  1 sibling, 1 reply; 52+ messages in thread
From: Andrew Cooper @ 2014-10-13 10:21 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On 10/10/14 12:47, Daniel Kiper wrote:
>
>>> +       : "+D" (s), "+c" (bytes) : "a" (0));
>>> +}
>>> +
>>>  static u32 copy_struct(u32 src, u32 bytes)
>>>  {
>>>      u32 dst, dst_asm;
>>> @@ -77,41 +87,56 @@ static u32 copy_string(u32 src)
>>>      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 = (multiboot_info_t *)copy_struct((u32)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 = copy_string(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;
>>> +    }
>> Now I am completely confused.  here you set mbd from mbi, but lower in
>> init_mbi, you set mbi from mbd.  What is the intended dataflow?
> We need mbi together with boot_info to make smooth transition from mbi
> to boot_info possible. Patch #10 completely removes mbi from Xen main code.
> I mentioned about that in commit message.

That is perhaps all well and fine, but my initial point still stands.

In this patch alone, you set mbd here from mbi, but later in
__init_mbi(), initialise mbi from mbd.

I can't spot anywhere else which initialises either of the structures
with values, so I can only assume they are both 0's (or even
uninitialised) all the way through the boot process.

~Andrew

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions
  2014-10-09  9:45   ` Andrew Cooper
@ 2014-10-13 15:00     ` Daniel Kiper
  2014-10-13 15:02       ` Andrew Cooper
  0 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-13 15:00 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Thu, Oct 09, 2014 at 10:45:08AM +0100, Andrew Cooper wrote:
> On 08/10/14 18:52, Daniel Kiper wrote:
> > Create generic alloc and copy functions. We need them to
> > introduce MBD struct and multiboot2 protocol. Please
> > check later patches for more details.
> >
> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>
> copy_string() is fine, as all its uses are in terms of u32s, but why do
> the other two change from pointers to u32s now?
>
> You could drop almost all of the casts with the reintroduction of the
> void pointers.  This code, after all, is only ever going to be 32bit.

We need some casts in this patch but after moving to MBD there are not any casts.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions
  2014-10-13 15:00     ` Daniel Kiper
@ 2014-10-13 15:02       ` Andrew Cooper
  0 siblings, 0 replies; 52+ messages in thread
From: Andrew Cooper @ 2014-10-13 15:02 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On 13/10/14 16:00, Daniel Kiper wrote:
> On Thu, Oct 09, 2014 at 10:45:08AM +0100, Andrew Cooper wrote:
>> On 08/10/14 18:52, Daniel Kiper wrote:
>>> Create generic alloc and copy functions. We need them to
>>> introduce MBD struct and multiboot2 protocol. Please
>>> check later patches for more details.
>>>
>>> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>> copy_string() is fine, as all its uses are in terms of u32s, but why do
>> the other two change from pointers to u32s now?
>>
>> You could drop almost all of the casts with the reintroduction of the
>> void pointers.  This code, after all, is only ever going to be 32bit.
> We need some casts in this patch but after moving to MBD there are not any casts.
>
> Daniel

Ok - that is a good reason.

~Andrew

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-13 10:21       ` Andrew Cooper
@ 2014-10-13 15:14         ` Daniel Kiper
  0 siblings, 0 replies; 52+ messages in thread
From: Daniel Kiper @ 2014-10-13 15:14 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: jgross, keir, ian.campbell, stefano.stabellini, ross.philipson,
	roy.franz, ning.sun, jbeulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Mon, Oct 13, 2014 at 11:21:46AM +0100, Andrew Cooper wrote:
> On 10/10/14 12:47, Daniel Kiper wrote:
> >
> >>> +       : "+D" (s), "+c" (bytes) : "a" (0));
> >>> +}
> >>> +
> >>>  static u32 copy_struct(u32 src, u32 bytes)
> >>>  {
> >>>      u32 dst, dst_asm;
> >>> @@ -77,41 +87,56 @@ static u32 copy_string(u32 src)
> >>>      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 = (multiboot_info_t *)copy_struct((u32)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 = copy_string(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;
> >>> +    }
> >> Now I am completely confused.  here you set mbd from mbi, but lower in
> >> init_mbi, you set mbi from mbd.  What is the intended dataflow?
> > We need mbi together with boot_info to make smooth transition from mbi
> > to boot_info possible. Patch #10 completely removes mbi from Xen main code.
> > I mentioned about that in commit message.
>
> That is perhaps all well and fine, but my initial point still stands.
>
> In this patch alone, you set mbd here from mbi, but later in
> __init_mbi(), initialise mbi from mbd.
>
> I can't spot anywhere else which initialises either of the structures
> with values, so I can only assume they are both 0's (or even
> uninitialised) all the way through the boot process.

__reloc() takes mbi from bootloader and initializes mbd to zero.
Later mbd is filled with needed data from mbi passed by bootloader.
xen/arch/x86/boot_info.c:static multiboot_info_t __read_mostly mbi
is initialized by GCC to 0 (I removed explicit initialization as you
requested). Later xen/arch/x86/boot_info.c:mbi is filled with data
from mbd and then passed to __start_xen().

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type Daniel Kiper
  2014-10-09 10:28   ` Andrew Cooper
@ 2014-10-14 15:27   ` Jan Beulich
  2014-10-14 16:03     ` Daniel Kiper
  1 sibling, 1 reply; 52+ messages in thread
From: Jan Beulich @ 2014-10-14 15:27 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> +static mbd_t __used *__reloc(void *mbi)
> +{
> +    mbd_t *mbd;
>  
> -    /* Mask features we don't understand or don't relocate. */
> -    mbi->flags &= (MBI_MEMLIMITS |
> -                   MBI_BOOTDEV |
> -                   MBI_CMDLINE |
> -                   MBI_MODULES |
> -                   MBI_MEMMAP |
> -                   MBI_LOADERNAME);
> +    mbd = (mbd_t *)alloc_struct(sizeof(mbd_t));
> +    zero_struct((u32)mbd, sizeof(mbd_t));

Here and elsewhere - please prefer sizeof(<expression>) over
sizeof(<type>) where possible. Also I continue to be questioning
the myriad of casts you're adding - why can't you use void *,
following what the old code did?

> +static multiboot_info_t __read_mostly mbi;

Is this really used post-init?

> +unsigned long __init __init_mbi(u32 mbd_pa)
> +{
> +    mbd_t *mbd = __va(mbd_pa);
> +
> +    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);
> +}

You shouldn't be blindly setting these flags - the incoming structure
has them, but you discard them in reloc.c instead of propagating
them here.

> @@ -546,21 +565,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();
> -    sort_exception_tables();
> -
> -    /* Full exception support from here on in. */
> +    if ( efi_enabled ) {
> +        enable_exception_support();
> +    }
> +    else
> +    {
> +        /* Exception support was enabled before __start_xen() call. */
> +    }

Apart from the coding style issue (not just here) - what's the reason
this can't also be done in the EFI case?

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-14 15:27   ` Jan Beulich
@ 2014-10-14 16:03     ` Daniel Kiper
  2014-10-14 16:26       ` Jan Beulich
  0 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-14 16:03 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Tue, Oct 14, 2014 at 04:27:13PM +0100, Jan Beulich wrote:
> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> > +static mbd_t __used *__reloc(void *mbi)
> > +{
> > +    mbd_t *mbd;
> >
> > -    /* Mask features we don't understand or don't relocate. */
> > -    mbi->flags &= (MBI_MEMLIMITS |
> > -                   MBI_BOOTDEV |
> > -                   MBI_CMDLINE |
> > -                   MBI_MODULES |
> > -                   MBI_MEMMAP |
> > -                   MBI_LOADERNAME);
> > +    mbd = (mbd_t *)alloc_struct(sizeof(mbd_t));
> > +    zero_struct((u32)mbd, sizeof(mbd_t));
>
> Here and elsewhere - please prefer sizeof(<expression>) over
> sizeof(<type>) where possible. Also I continue to be questioning

You mean alloc_struct(sizeof(*mbd)) in this case?

> the myriad of casts you're adding - why can't you use void *,
> following what the old code did?

Most of mbi, mbi2 and mbd members are u32. So, that is why
all basic functions use u32 arguments and returns u32. There
are only two needed casts related to this functions and you can
see them above.

> > +static multiboot_info_t __read_mostly mbi;
>
> Is this really used post-init?

Yep.

> > +unsigned long __init __init_mbi(u32 mbd_pa)
> > +{
> > +    mbd_t *mbd = __va(mbd_pa);
> > +
> > +    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);
> > +}
>
> You shouldn't be blindly setting these flags - the incoming structure
> has them, but you discard them in reloc.c instead of propagating
> them here.

Good point. I think that this should work:

if ( mbd->mem_lower || mbd->mem_upper )
{
    mbi.flags |= MBI_MEMLIMITS;
    mbi.mem_lower = mbd->mem_lower;
    mbi.mem_upper = mbd->mem_upper;
}

...

> > @@ -546,21 +565,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();
> > -    sort_exception_tables();
> > -
> > -    /* Full exception support from here on in. */
> > +    if ( efi_enabled ) {
> > +        enable_exception_support();
> > +    }
> > +    else
> > +    {
> > +        /* Exception support was enabled before __start_xen() call. */
> > +    }
>
> Apart from the coding style issue (not just here) - what's the reason
> this can't also be done in the EFI case?

I will try to call it from EFI boot code.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type
  2014-10-14 16:03     ` Daniel Kiper
@ 2014-10-14 16:26       ` Jan Beulich
  0 siblings, 0 replies; 52+ messages in thread
From: Jan Beulich @ 2014-10-14 16:26 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 14.10.14 at 18:03, <daniel.kiper@oracle.com> wrote:
> On Tue, Oct 14, 2014 at 04:27:13PM +0100, Jan Beulich wrote:
>> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
>> > +static mbd_t __used *__reloc(void *mbi)
>> > +{
>> > +    mbd_t *mbd;
>> >
>> > -    /* Mask features we don't understand or don't relocate. */
>> > -    mbi->flags &= (MBI_MEMLIMITS |
>> > -                   MBI_BOOTDEV |
>> > -                   MBI_CMDLINE |
>> > -                   MBI_MODULES |
>> > -                   MBI_MEMMAP |
>> > -                   MBI_LOADERNAME);
>> > +    mbd = (mbd_t *)alloc_struct(sizeof(mbd_t));
>> > +    zero_struct((u32)mbd, sizeof(mbd_t));
>>
>> Here and elsewhere - please prefer sizeof(<expression>) over
>> sizeof(<type>) where possible. Also I continue to be questioning
> 
> You mean alloc_struct(sizeof(*mbd)) in this case?

Yes.

>> the myriad of casts you're adding - why can't you use void *,
>> following what the old code did?
> 
> Most of mbi, mbi2 and mbd members are u32. So, that is why
> all basic functions use u32 arguments and returns u32. There
> are only two needed casts related to this functions and you can
> see them above.

Patch 3 had quite a few more of them.

>> > +unsigned long __init __init_mbi(u32 mbd_pa)
>> > +{
>> > +    mbd_t *mbd = __va(mbd_pa);
>> > +
>> > +    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);
>> > +}
>>
>> You shouldn't be blindly setting these flags - the incoming structure
>> has them, but you discard them in reloc.c instead of propagating
>> them here.
> 
> Good point. I think that this should work:
> 
> if ( mbd->mem_lower || mbd->mem_upper )
> {
>     mbi.flags |= MBI_MEMLIMITS;
>     mbi.mem_lower = mbd->mem_lower;
>     mbi.mem_upper = mbd->mem_upper;
> }

If it is guaranteed that whatever non-zero field(s) if and only if
original flag set - fine by me. But I guess it would be better if
you forwarded the flags values.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (16 preceding siblings ...)
  2014-10-10  8:23 ` [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
@ 2014-10-16  8:13 ` Jan Beulich
  2014-10-16 12:58   ` Daniel Kiper
  17 siblings, 1 reply; 52+ messages in thread
From: Jan Beulich @ 2014-10-16  8:13 UTC (permalink / raw)
  To: Daniel Kiper, konrad.wilk
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:

Just for the record - I do not see this as warranting a release exception.
The effort to get this in place was started way too late, and shouldn't
be rushed close to or already beyond the feature freeze point.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-16  8:13 ` Jan Beulich
@ 2014-10-16 12:58   ` Daniel Kiper
  2014-10-16 13:41     ` Jan Beulich
  0 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-16 12:58 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Thu, Oct 16, 2014 at 09:13:35AM +0100, Jan Beulich wrote:
> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
>
> Just for the record - I do not see this as warranting a release exception.
> The effort to get this in place was started way too late, and shouldn't
> be rushed close to or already beyond the feature freeze point.

It will be nice to have it in 4.5 but I am not going to insist on it
so strong. Anyway, I am working on next release. I hope that I will
be able to send it tomorrow. If you state that it is not in good shape
still then I will send next version (then with multiboot2 stuff for EFI)
when 4.6 merge window will be open.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-16 12:58   ` Daniel Kiper
@ 2014-10-16 13:41     ` Jan Beulich
  2014-10-16 15:33       ` Daniel Kiper
  0 siblings, 1 reply; 52+ messages in thread
From: Jan Beulich @ 2014-10-16 13:41 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 16.10.14 at 14:58, <daniel.kiper@oracle.com> wrote:
> On Thu, Oct 16, 2014 at 09:13:35AM +0100, Jan Beulich wrote:
>> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
>>
>> Just for the record - I do not see this as warranting a release exception.
>> The effort to get this in place was started way too late, and shouldn't
>> be rushed close to or already beyond the feature freeze point.
> 
> It will be nice to have it in 4.5 but I am not going to insist on it
> so strong. Anyway, I am working on next release. I hope that I will
> be able to send it tomorrow.

Which means I can ditch the to-be-reviewed v3 patches 5...16 from
my queue?

And then I'm still not really convinced that all this goes in the right
direction. In particular I'm worried about you doing pretty invasive
to early boot code when it's not really clear that all this need to be
touched (and largely re-written). I'd really favor you initially working
towards supporting MB2 without at the same time trying to abstract
things to fit all of MB1, EFI, MB2, and eventually even ARM. This is
to a good part that it's currently rather hard to see whether what
you abstract and how are really the right items and mechanisms.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-16 13:41     ` Jan Beulich
@ 2014-10-16 15:33       ` Daniel Kiper
  2014-10-16 15:42         ` Jan Beulich
  0 siblings, 1 reply; 52+ messages in thread
From: Daniel Kiper @ 2014-10-16 15:33 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Thu, Oct 16, 2014 at 02:41:45PM +0100, Jan Beulich wrote:
> >>> On 16.10.14 at 14:58, <daniel.kiper@oracle.com> wrote:
> > On Thu, Oct 16, 2014 at 09:13:35AM +0100, Jan Beulich wrote:
> >> >>> On 08.10.14 at 19:52, <daniel.kiper@oracle.com> wrote:
> >>
> >> Just for the record - I do not see this as warranting a release exception.
> >> The effort to get this in place was started way too late, and shouldn't
> >> be rushed close to or already beyond the feature freeze point.
> >
> > It will be nice to have it in 4.5 but I am not going to insist on it
> > so strong. Anyway, I am working on next release. I hope that I will
> > be able to send it tomorrow.
>
> Which means I can ditch the to-be-reviewed v3 patches 5...16 from
> my queue?

Yep.

> And then I'm still not really convinced that all this goes in the right
> direction. In particular I'm worried about you doing pretty invasive
> to early boot code when it's not really clear that all this need to be
> touched (and largely re-written). I'd really favor you initially working
> towards supporting MB2 without at the same time trying to abstract

I have a feeling that if we go in that direction that this strong
dependency on MB1 never would be broken.

> things to fit all of MB1, EFI, MB2, and eventually even ARM. This is
> to a good part that it's currently rather hard to see whether what
> you abstract and how are really the right items and mechanisms.

As said earlier, I think that we should break MB1 dependency first
and use this work for further MB2 development. It pays. Please, look
at patch which introduce MB2. It is very easy to do after my changes
(introducing MBD and boot_info). Just one very simple patch. We do not
even touch Xen main code! I am sure that it could be more difficult
if we try to do that on currently exiting MB1 code. I do not mention
that if we need to pass something which is not specified in MB1 then
we will be forced to pass it using side channel. Additionally, as
I showed on MB2 case it will be much easier to introduce other boot
protocols in the future if we need it. Just change preloder. There
is a small chance that we should change anything in Xen main code
(after __start_xen()).

However, I am aware of difficulties related to MB2 and EFI. Currently
I have at least two ideas how to solve that problem. More or less
we can put MB2 header and relevant code into currently generated PE
file or pack currently generated ELF file into PE header. So, this
is thing which I should dig deeper. I am going to do it soon.

Daniel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-16 15:33       ` Daniel Kiper
@ 2014-10-16 15:42         ` Jan Beulich
  0 siblings, 0 replies; 52+ messages in thread
From: Jan Beulich @ 2014-10-16 15:42 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, roy.franz, ning.sun, ross.philipson, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 16.10.14 at 17:33, <daniel.kiper@oracle.com> wrote:
> On Thu, Oct 16, 2014 at 02:41:45PM +0100, Jan Beulich wrote:
>> And then I'm still not really convinced that all this goes in the right
>> direction. In particular I'm worried about you doing pretty invasive
>> to early boot code when it's not really clear that all this need to be
>> touched (and largely re-written). I'd really favor you initially working
>> towards supporting MB2 without at the same time trying to abstract
> 
> I have a feeling that if we go in that direction that this strong
> dependency on MB1 never would be broken.
> 
>> things to fit all of MB1, EFI, MB2, and eventually even ARM. This is
>> to a good part that it's currently rather hard to see whether what
>> you abstract and how are really the right items and mechanisms.
> 
> As said earlier, I think that we should break MB1 dependency first
> and use this work for further MB2 development. It pays. Please, look
> at patch which introduce MB2. It is very easy to do after my changes
> (introducing MBD and boot_info). Just one very simple patch. We do not
> even touch Xen main code! I am sure that it could be more difficult
> if we try to do that on currently exiting MB1 code.

Pretty strange way of looking at this: Of course everything can become
a 1-liner if dozens of intrusive preparatory patches set the stage right.

Jan

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2014-10-16 15:42 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-08 17:52 [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 01/16] x86/boot/reloc: Remove redundant blank characters and reformat comments a bit Daniel Kiper
2014-10-09  9:26   ` Andrew Cooper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 02/16] x86/boot/reloc: Move typedef and include to beginning of file Daniel Kiper
2014-10-09  9:40   ` Andrew Cooper
2014-10-10  8:50   ` Jan Beulich
2014-10-10 13:17     ` Daniel Kiper
2014-10-10 13:33       ` Jan Beulich
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 03/16] x86/boot/reloc: Create generic alloc and copy functions Daniel Kiper
2014-10-09  9:45   ` Andrew Cooper
2014-10-13 15:00     ` Daniel Kiper
2014-10-13 15:02       ` Andrew Cooper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 04/16] x86: Introduce MultiBoot Data (MBD) type Daniel Kiper
2014-10-09 10:28   ` Andrew Cooper
2014-10-10 11:47     ` Daniel Kiper
2014-10-10 12:48       ` Jan Beulich
2014-10-13 10:21       ` Andrew Cooper
2014-10-13 15:14         ` Daniel Kiper
2014-10-14 15:27   ` Jan Beulich
2014-10-14 16:03     ` Daniel Kiper
2014-10-14 16:26       ` Jan Beulich
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 05/16] x86/efi: Add place_string_u32() function Daniel Kiper
2014-10-09 10:30   ` Andrew Cooper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 06/16] x86: Introduce boot_info structure Daniel Kiper
2014-10-09 10:48   ` Andrew Cooper
2014-10-10 13:55   ` Stefano Stabellini
2014-10-10 20:44     ` Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 07/16] x86: Move boot_loader_name from mbi to boot_info Daniel Kiper
2014-10-09 10:53   ` Andrew Cooper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 08/16] x86: Move cmdline " Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 09/16] x86: Move legacy BIOS memory map stuff " Daniel Kiper
2014-10-10 14:02   ` Stefano Stabellini
2014-10-10 20:26     ` Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 10/16] x86: Move modules data from mbi to boot_info and remove mbi Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 11/16] x86: Move EFI memory map stuff to boot_info Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 12/16] x86: Move MPS, ACPI and SMBIOS data " Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 13/16] x86: Move video " Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 14/16] x86: Move HDD " Daniel Kiper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 15/16] x86/boot: Use %ecx instead of %eax Daniel Kiper
2014-10-09 11:02   ` Andrew Cooper
2014-10-08 17:52 ` [PATCH for-xen-4.5 v3 16/16] xen/x86: Add multiboot2 protocol support Daniel Kiper
2014-10-09 11:20   ` Andrew Cooper
2014-10-10  8:21     ` Jan Beulich
2014-10-10  8:23 ` [PATCH for-xen-4.5 v3 00/16] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
2014-10-10 11:07   ` Daniel Kiper
2014-10-10 12:25     ` Jan Beulich
2014-10-10 13:03       ` Daniel Kiper
2014-10-16  8:13 ` Jan Beulich
2014-10-16 12:58   ` Daniel Kiper
2014-10-16 13:41     ` Jan Beulich
2014-10-16 15:33       ` Daniel Kiper
2014-10-16 15:42         ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.