All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
@ 2014-10-17 14:11 Daniel Kiper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 01/18] xen/makefile: clean target should remove xen.efi binary Daniel Kiper
                   ` (19 more replies)
  0 siblings, 20 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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 all,

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.

I took into account all suggestions sent to me up until now.

ARM build has been tested. However, I am not able to test generated
binaries because I do not have a required hardware under my feet.
Could you do some tests guys?

This is my last attempt to have this series in 4.5. If it will be not
accepted for 4.5 I will continue multiboot2 + EFI development on the
base of this patch series. Now I am almost sure that we are going in
right direction. I hope that I will be able to post multiboot2 + EFI
patches in about 1 month.

Daniel

 xen/Makefile                      |    2 +-
 xen/arch/x86/Makefile             |    1 +
 xen/arch/x86/boot/Makefile        |    8 +-
 xen/arch/x86/boot/build32.mk      |    3 +-
 xen/arch/x86/boot/cmdline.S       |    9 +-
 xen/arch/x86/boot/head.S          |  157 ++++++++++++++++++++++++++++++-----
 xen/arch/x86/boot/reloc.c         |  223 ++++++++++++++++++++++++++++++++++++++++---------
 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              |  369 +++++++++++++++++++++++++++-------------------------------------------------------
 xen/arch/x86/x86_64/asm-offsets.c |   15 +++-
 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   |  124 ++++++++++++++++++++++++++++
 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         |   80 ++++++++++++++++++
 xen/include/asm-x86/setup.h       |   12 +--
 xen/include/xen/efi.h             |    7 ++
 xen/include/xen/multiboot2.h      |  153 ++++++++++++++++++++++++++++++++++
 xen/include/xen/vga.h             |   18 ----
 xen/include/xsm/xsm.h             |   16 ++--
 xen/xsm/xsm_core.c                |    6 +-
 xen/xsm/xsm_policy.c              |   10 +--
 35 files changed, 1344 insertions(+), 534 deletions(-)

Daniel Kiper (18):
      xen/makefile: clean target should remove xen.efi binary
      x86/boot: fix reloc.S build dependencies
      x86: define cmdline_cook() loader_name argument as a const
      x86/boot: use constant in head.S instead of hardcoded value
      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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 01/18] xen/makefile: clean target should remove xen.efi binary
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
@ 2014-10-17 14:11 ` Daniel Kiper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies Daniel Kiper
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 9d91ca7..28b4b79 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -84,7 +84,7 @@ _clean: delete-unfresh-files
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C xsm clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C crypto clean
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) clean
-	rm -f include/asm *.o $(TARGET) $(TARGET).gz $(TARGET)-syms *~ core
+	rm -f include/asm *.o $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET)-syms *~ core
 	rm -f include/asm-*/asm-offsets.h
 	rm -f .banner
 
-- 
1.7.10.4

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

* [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 01/18] xen/makefile: clean target should remove xen.efi binary Daniel Kiper
@ 2014-10-17 14:11 ` Daniel Kiper
  2014-10-17 14:51   ` Jan Beulich
  2014-10-17 14:56   ` Andrew Cooper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 03/18] x86: define cmdline_cook() loader_name argument as a const Daniel Kiper
                   ` (17 subsequent siblings)
  19 siblings, 2 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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

reloc.S is not rebuild if header included
in reloc.c is updated. Fix this issue.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/Makefile   |    6 +++++-
 xen/arch/x86/boot/build32.mk |    3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
index 13f4a66..3cab36a 100644
--- a/xen/arch/x86/boot/Makefile
+++ b/xen/arch/x86/boot/Makefile
@@ -1,8 +1,12 @@
 obj-bin-y += head.o
 
+RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
+
+export RELOC_DEPS
+
 head.o: reloc.S
 
 %.S: %.c
 	$(MAKE) -f build32.mk $@
 
-reloc.S: head.S
+reloc.S: $(RELOC_DEPS)
diff --git a/xen/arch/x86/boot/build32.mk b/xen/arch/x86/boot/build32.mk
index a36f620..809f296 100644
--- a/xen/arch/x86/boot/build32.mk
+++ b/xen/arch/x86/boot/build32.mk
@@ -30,5 +30,6 @@ CFLAGS := $(filter-out -flto,$(CFLAGS))
 			esac; \
 		done
 
-reloc.o: $(BASEDIR)/include/asm-x86/config.h
+reloc.o: $(RELOC_DEPS)
+
 .PRECIOUS: %.bin %.lnk
-- 
1.7.10.4

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

* [PATCH for-xen-4.5 v4 03/18] x86: define cmdline_cook() loader_name argument as a const
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 01/18] xen/makefile: clean target should remove xen.efi binary Daniel Kiper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies Daniel Kiper
@ 2014-10-17 14:11 ` Daniel Kiper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value Daniel Kiper
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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

cmdline_cook() loader_name argument is not changed so
define it as a const.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/setup.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 8c8b91f..bfbb310 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -508,7 +508,7 @@ static bool_t __init loader_is_grub2(const char *loader_name)
     return (p != NULL) && (p[5] != '0');
 }
 
-static char * __init cmdline_cook(char *p, char *loader_name)
+static char * __init cmdline_cook(char *p, const char *loader_name)
 {
     p = p ? : "";
 
-- 
1.7.10.4

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

* [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (2 preceding siblings ...)
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 03/18] x86: define cmdline_cook() loader_name argument as a const Daniel Kiper
@ 2014-10-17 14:11 ` Daniel Kiper
  2014-10-17 15:00   ` Andrew Cooper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions Daniel Kiper
                   ` (15 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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

..to access multiboot.mem_lower data.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 xen/arch/x86/boot/head.S          |    2 +-
 xen/arch/x86/x86_64/asm-offsets.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index cd43952..0bdbc65 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -101,7 +101,7 @@ __start:
          */
         testb   $MBI_MEMLIMITS,(%ebx)
         jz      2f                  /* not available? BDA value will be fine */
-        mov     4(%ebx),%edx
+        mov     MBI_mem_lower(%ebx),%edx
         cmp     $0x100,%edx         /* is the multiboot value too small? */
         jb      2f                  /* if so, do not use it */
         shl     $10-4,%edx
diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index 3994f4d..2de9cad 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -163,6 +163,9 @@ void __dummy__(void)
     OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);
     BLANK();
 
+    OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
+    BLANK();
+
     OFFSET(MB_flags, multiboot_info_t, flags);
     OFFSET(MB_cmdline, multiboot_info_t, cmdline);
 }
-- 
1.7.10.4

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

* [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (3 preceding siblings ...)
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value Daniel Kiper
@ 2014-10-17 14:11 ` Daniel Kiper
  2014-10-17 16:04   ` Andrew Cooper
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 06/18] x86: introduce MultiBoot Data (MBD) type Daniel Kiper
                   ` (14 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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, 33 insertions(+), 19 deletions(-)

diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index 4609e55..e1c83f4 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -33,9 +33,10 @@ asm (
 typedef unsigned int u32;
 #include "../../../include/xen/multiboot.h"
 
-static void *reloc_mbi_struct(void *old, unsigned int bytes)
+static u32 alloc_struct(u32 bytes)
 {
-    void *new;
+    u32 s;
+
     asm(
     "    call 1f                      \n"
     "1:  pop  %%edx                   \n"
@@ -43,50 +44,63 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes)
     "    sub  %1,%0                   \n"
     "    and  $~15,%0                 \n"
     "    mov  %0,alloc-1b(%%edx)      \n"
-    "    mov  %0,%%edi                \n"
-    "    rep  movsb                   \n"
-       : "=&r" (new), "+c" (bytes), "+S" (old)
-	: : "edx", "edi");
-    return new;
+       : "=&r" (s) : "r" (bytes) : "edx");
+
+    return s;
 }
 
-static char *reloc_mbi_string(char *old)
+static u32 copy_struct(u32 src, u32 bytes)
+{
+    u32 dst, dst_asm;
+
+    dst = alloc_struct(bytes);
+    dst_asm = dst;
+
+    asm volatile("rep movsb" : "+S" (src), "+D" (dst_asm), "+c" (bytes));
+
+    return dst;
+}
+
+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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 06/18] x86: introduce MultiBoot Data (MBD) type
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (4 preceding siblings ...)
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions Daniel Kiper
@ 2014-10-17 14:11 ` Daniel Kiper
  2014-10-17 17:14   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 07/18] x86/efi: add place_string_u32() function Daniel Kiper
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:11 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>
---
v4 - suggestions/fixes:
   - rename reloc() function
     (suggested by Andrew Cooper),
   - rename enable_bsp_exception_support() function
     (suggested by Andrew Cooper),
   - move enable_bsp_exception_support() function
     declaration to header file
     (suggested by Andrew Cooper and Jan Beulich),
   - change sizeof(<expression>) to sizeof(<type>) where possible
     (suggested by Jan Beulich),
   - set only mbi flag only if relevant data is valid
     (suggested by Jan Beulich),
   - improve inline assembly
     (suggested by Andrew Cooper),
   - improve comments
     (suggested by Andrew Cooper),
   - fix copyright
     (suggested by Konrad Rzeszutek Wilk),
   - fix coding style
     (suggested by Andrew Cooper, Jan Beulich and Konrad Rzeszutek Wilk).

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/Makefile        |    3 +-
 xen/arch/x86/boot/cmdline.S       |    9 ++---
 xen/arch/x86/boot/head.S          |    2 +-
 xen/arch/x86/boot/reloc.c         |   66 ++++++++++++++++++++----------
 xen/arch/x86/boot/x86_64.S        |   10 +++--
 xen/arch/x86/boot_info.c          |   70 ++++++++++++++++++++++++++++++++
 xen/arch/x86/efi/efi-boot.h       |    2 +-
 xen/arch/x86/setup.c              |   42 +++++++++++--------
 xen/arch/x86/x86_64/asm-offsets.c |    6 +--
 xen/include/asm-x86/mbd.h         |   80 +++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/setup.h       |    2 +
 12 files changed, 241 insertions(+), 52 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/Makefile b/xen/arch/x86/boot/Makefile
index 3cab36a..e6ff2b7 100644
--- a/xen/arch/x86/boot/Makefile
+++ b/xen/arch/x86/boot/Makefile
@@ -1,6 +1,7 @@
 obj-bin-y += head.o
 
-RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
+RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/compiler.h \
+	     $(BASEDIR)/include/xen/multiboot.h $(BASEDIR)/include/asm-x86/mbd.h
 
 export RELOC_DEPS
 
diff --git a/xen/arch/x86/boot/cmdline.S b/xen/arch/x86/boot/cmdline.S
index 00687eb..b622c6b 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(%ebx),%eax
         test    %eax,%eax
         jz      .Lcmdline_exit
 
         /* Check for 'no-real-mode' command-line option. */
         pushl   $sym_phys(.Lno_rm_opt)
-        pushl   MB_cmdline(%ebx)
+        pushl   MBD_cmdline(%ebx)
         call    .Lfind_option
         test    %eax,%eax
         setnz   %al
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 0bdbc65..64a0ff7 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 e1c83f4..9792fcd 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -31,8 +31,12 @@ asm (
     );
 
 typedef unsigned int u32;
+
+#include "../../../include/xen/compiler.h"
 #include "../../../include/xen/multiboot.h"
 
+#include "../../../include/asm/mbd.h"
+
 static u32 alloc_struct(u32 bytes)
 {
     u32 s;
@@ -49,6 +53,11 @@ static u32 alloc_struct(u32 bytes)
     return s;
 }
 
+static void zero_struct(u32 s, u32 bytes)
+{
+    asm volatile("rep stosb" : "+D" (s), "+c" (bytes) : "a" (0));
+}
+
 static u32 copy_struct(u32 src, u32 bytes)
 {
     u32 dst, dst_asm;
@@ -74,41 +83,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));
+    zero_struct((u32)mbd, sizeof(*mbd));
 
-    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..fc7ce74 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
+        /* Initialize the Multiboot info struct. */
+        mov     mbd_pa(%rip),%edi
+        call    __init_mbi
+
+        /* Pass off the Multiboot info struct 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..64bc4d9
--- /dev/null
+++ b/xen/arch/x86/boot_info.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013, 2014 Oracle Corp.
+ *      Author: 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>
+#include <asm/setup.h>
+
+static multiboot_info_t __read_mostly mbi;
+
+unsigned long __init __init_mbi(u32 mbd_pa)
+{
+    mbd_t *mbd = __va(mbd_pa);
+
+    enable_bsp_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;
+    }
+
+    if ( mbd->mem_lower || mbd->mem_upper )
+    {
+        mbi.flags |= MBI_MEMLIMITS;
+        mbi.mem_lower = mbd->mem_lower;
+        mbi.mem_upper = mbd->mem_upper;
+    }
+
+    if ( mbd->mmap_size )
+    {
+        mbi.flags |= MBI_MEMMAP;
+        mbi.mmap_length = mbd->mmap_size;
+        mbi.mmap_addr = mbd->mmap;
+    }
+
+    if ( mbd->mods_nr )
+    {
+        mbi.flags |= MBI_MODULES;
+        mbi.mods_count = mbd->mods_nr;
+        mbi.mods_addr = mbd->mods;
+    }
+
+    return (unsigned long)&mbi;
+}
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 4348cfe..5c85854 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -245,7 +245,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)
+                     "D" (__va(&mbi))
                    : "memory" );
     for( ; ; ); /* not reached */
 }
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index bfbb310..eacb9b2 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -529,12 +529,29 @@ static char * __init cmdline_cook(char *p, const char *loader_name)
     return p;
 }
 
+void __init enable_bsp_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();
+}
+
 void __init noreturn __start_xen(unsigned long mbi_p)
 {
     char *memmap_type = NULL;
     char *cmdline, *kextra, *loader;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
-    multiboot_info_t *mbi = __va(mbi_p);
+    multiboot_info_t *mbi = (multiboot_info_t *)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;
@@ -546,21 +563,14 @@ 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_bsp_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 2de9cad..7364dd6 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -9,10 +9,11 @@
 #include <xen/perfc.h>
 #include <xen/sched.h>
 #include <xen/bitops.h>
+#include <xen/multiboot.h>
 #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 " */<==\"" \
@@ -166,6 +167,5 @@ void __dummy__(void)
     OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
     BLANK();
 
-    OFFSET(MB_flags, multiboot_info_t, flags);
-    OFFSET(MB_cmdline, multiboot_info_t, cmdline);
+    OFFSET(MBD_cmdline, 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..11c7bcd
--- /dev/null
+++ b/xen/include/asm-x86/mbd.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013, 2014 Oracle Corp.
+ *      Author: 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 an array of module descriptions (boot_module_t *). */
+    u32 mods;
+} mbd_t;
+#endif /* __MBD_H__ */
diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h
index 8f8c6f3..d051ee6 100644
--- a/xen/include/asm-x86/setup.h
+++ b/xen/include/asm-x86/setup.h
@@ -5,6 +5,8 @@
 
 extern unsigned long xenheap_initial_phys_start;
 
+extern void enable_bsp_exception_support(void);
+
 void early_cpu_init(void);
 void early_time_init(void);
 
-- 
1.7.10.4

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

* [PATCH for-xen-4.5 v4 07/18] x86/efi: add place_string_u32() function
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (5 preceding siblings ...)
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 06/18] x86: introduce MultiBoot Data (MBD) type Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 08/18] x86: introduce boot_info structure Daniel Kiper
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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(). We need place_string_u32() to
play with u32 MBD and boot_info structures members
in later patches.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
v4 - suggestions/fixes:
   - improve commit message
     (suggested by Andrew Cooper).
---
 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 5c85854..9458e7f 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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 08/18] x86: introduce boot_info structure
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (6 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 07/18] x86/efi: add place_string_u32() function Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 20:55   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 09/18] x86: move boot_loader_name from mbi to boot_info Daniel Kiper
                   ` (11 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
---
v4 - suggestions/fixes:
   - change some variables "char *" type to "const char *" type
     (suggested by Andrew Cooper),
   - do ARM test build
     (suggested by Ian Campbell and Stefano Stabellini).

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     |    1 +
 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 |   47 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 96 insertions(+), 3 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 fc7ce74..2305b56 100644
--- a/xen/arch/x86/boot/x86_64.S
+++ b/xen/arch/x86/boot/x86_64.S
@@ -32,9 +32,15 @@
         /* Initialize the Multiboot info struct. */
         mov     mbd_pa(%rip),%edi
         call    __init_mbi
+        pushq   %rax
+
+        /* Initialize the boot_info. */
+        mov     mbd_pa(%rip),%edi
+        call    __init_boot_info
 
-        /* Pass off the Multiboot info struct to C land. */
-        movq    %rax,%rdi
+        /* Pass off the Multiboot info struct and the 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 64bc4d9..c5f2a18 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -21,12 +21,18 @@
 #include <xen/init.h>
 #include <xen/multiboot.h>
 
+#include <asm/boot_info.h>
 #include <asm/mbd.h>
 #include <asm/page.h>
 #include <asm/setup.h>
 
 static multiboot_info_t __read_mostly mbi;
 
+static boot_info_t __read_mostly boot_info_mb = {
+    .warn_msg = NULL,
+    .err_msg = NULL
+};
+
 unsigned long __init __init_mbi(u32 mbd_pa)
 {
     mbd_t *mbd = __va(mbd_pa);
@@ -68,3 +74,8 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
     return (unsigned long)&mbi;
 }
+
+boot_info_t __init *__init_boot_info(u32 mbd_pa)
+{
+    return &boot_info_mb;
+}
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 9458e7f..3da1a2a 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -255,6 +255,7 @@ static void __init noreturn efi_arch_post_exit_boot(void)
                      [ds] "r" (__HYPERVISOR_DS),
                      [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)),
                      "D" (__va(&mbi))
+                     "S" (__va(&boot_info_efi))
                    : "memory" );
     for( ; ; ); /* not reached */
 }
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index eacb9b2..18fa3e4 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;
@@ -546,7 +549,7 @@ void __init enable_bsp_exception_support(void)
     sort_exception_tables();
 }
 
-void __init noreturn __start_xen(unsigned long mbi_p)
+void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
 {
     char *memmap_type = NULL;
     char *cmdline, *kextra, *loader;
@@ -563,6 +566,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         .stop_bits = 1
     };
 
+    boot_info = boot_info_ptr;
+
     if ( efi_enabled )
     {
         enable_bsp_exception_support();
@@ -612,6 +617,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..f0a76b2
--- /dev/null
+++ b/xen/include/asm-x86/boot_info.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013, 2014 Oracle Corp.
+ *      Author: 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.
+     */
+    const char *warn_msg;
+
+    /*
+     * Info about error occurred during boot_info initialization. NULL if everything
+     * went OK. Otherwise boot_info is not fully/properly initialized.
+     */
+    const 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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 09/18] x86: move boot_loader_name from mbi to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (7 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 08/18] x86: introduce boot_info structure Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 21:05   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 10/18] x86: move cmdline " Daniel Kiper
                   ` (10 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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>
---
v4 - suggestions/fixes:
   - change boot_loader_name type to "const char *"
     (suggested by Andrew Cooper).
---
 xen/arch/x86/boot_info.c        |   12 ++++++------
 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(+), 16 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index c5f2a18..a81e98b 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -29,6 +29,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,12 +40,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
     enable_bsp_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;
@@ -77,5 +72,10 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
 boot_info_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 &boot_info_mb;
 }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 3da1a2a..19be165 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 18fa3e4..a9dbc05 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -552,7 +552,7 @@ void __init enable_bsp_exception_support(void)
 void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
 {
     char *memmap_type = NULL;
-    char *cmdline, *kextra, *loader;
+    char *cmdline, *kextra;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
     multiboot_info_t *mbi = (multiboot_info_t *)mbi_p;
     module_t *mod = (module_t *)__va(mbi->mods_addr);
@@ -577,13 +577,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         /* 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 )
     {
         /*
@@ -623,7 +620,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
     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);
 
@@ -697,7 +694,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         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 )
     {
@@ -1379,7 +1376,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
     {
         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 f0a76b2..9e68447 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -30,6 +30,9 @@
  * are compatible as much as possible with relevant EFI/ACPI types.
  */
 typedef struct {
+    /* Boot loader name. */
+    const 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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 10/18] x86: move cmdline from mbi to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (8 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 09/18] x86: move boot_loader_name from mbi to boot_info Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 21:27   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 11/18] x86: move legacy BIOS memory map stuff " Daniel Kiper
                   ` (9 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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        |   10 ++++------
 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(+), 14 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index a81e98b..7d8b0e5 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -30,6 +30,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,12 +41,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
 
     enable_bsp_exception_support();
 
-    if ( mbd->cmdline )
-    {
-        mbi.flags |= MBI_CMDLINE;
-        mbi.cmdline = mbd->cmdline;
-    }
-
     if ( mbd->mem_lower || mbd->mem_upper )
     {
         mbi.flags |= MBI_MEMLIMITS;
@@ -77,5 +72,8 @@ boot_info_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 &boot_info_mb;
 }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 19be165..f02e604 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 a9dbc05..8f83969 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -578,9 +578,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
     }
 
     /* 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 9e68447..44d1674 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -33,6 +33,9 @@ typedef struct {
     /* Boot loader name. */
     const 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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 11/18] x86: move legacy BIOS memory map stuff to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (9 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 10/18] x86: move cmdline " Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 22:08   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi Daniel Kiper
                   ` (8 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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, 135 insertions(+), 98 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 7d8b0e5..9e4af78 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -16,45 +16,126 @@
  * 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>
 #include <asm/setup.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_src = NULL,
+    .mem_upper = 0,
+    .e820map_nr = 0,
+    .e820map = NULL,
     .warn_msg = NULL,
     .err_msg = NULL
 };
 
-unsigned long __init __init_mbi(u32 mbd_pa)
+#define e820_raw bootsym(e820map)
+#define e820_raw_nr bootsym(e820nr)
+
+static void __init init_mmap(boot_info_t *boot_info, mbd_t *mbd)
 {
-    mbd_t *mbd = __va(mbd_pa);
+    int bytes = 0;
+    memory_map_t *map;
 
-    enable_bsp_exception_support();
+    if ( e820_raw_nr )
+        boot_info->mmap_src = "Xen-e820";
+    else if ( mbd->mmap_size )
+    {
+        boot_info->mmap_src = "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 ( mbd->mem_lower || mbd->mem_upper )
+            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) )
     {
-        mbi.flags |= MBI_MEMLIMITS;
-        mbi.mem_lower = mbd->mem_lower;
-        mbi.mem_upper = mbd->mem_upper;
+        boot_info->mmap_src = "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_src = "Multiboot-e801";
 
-    if ( mbd->mmap_size )
+        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
     {
-        mbi.flags |= MBI_MEMMAP;
-        mbi.mmap_length = mbd->mmap_size;
-        mbi.mmap_addr = mbd->mmap;
+        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_bsp_exception_support();
+
     if ( mbd->mods_nr )
     {
         mbi.flags |= MBI_MODULES;
@@ -75,5 +156,7 @@ boot_info_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 &boot_info_mb;
 }
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index f02e604..96e758c 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 8f83969..32d9a3a 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -551,13 +551,12 @@ void __init enable_bsp_exception_support(void)
 
 void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
 {
-    char *memmap_type = NULL;
     char *cmdline, *kextra;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
     multiboot_info_t *mbi = (multiboot_info_t *)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 = {
@@ -691,77 +690,11 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         /* 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_src, 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..03c6658 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_src = "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 44d1674..a882c0c 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -19,6 +19,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
@@ -36,6 +40,24 @@ typedef struct {
     /* Xen command line. */
     char *cmdline;
 
+    /* Memory map source name. */
+    const char *mmap_src;
+
+    /*
+     * 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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (10 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 11/18] x86: move legacy BIOS memory map stuff " Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 22:35   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 13/18] x86: move EFI memory map stuff to boot_info Daniel Kiper
                   ` (7 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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        |   27 +++-----
 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           |   16 +++--
 xen/xsm/xsm_core.c              |    6 +-
 xen/xsm/xsm_policy.c            |   10 +--
 13 files changed, 153 insertions(+), 171 deletions(-)

diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
index 2305b56..500e0d7 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
 
-        /* Initialize the Multiboot info struct. */
-        mov     mbd_pa(%rip),%edi
-        call    __init_mbi
-        pushq   %rax
-
         /* Initialize the boot_info. */
         mov     mbd_pa(%rip),%edi
         call    __init_boot_info
 
-        /* Pass off the Multiboot info struct and the 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 9e4af78..081453e 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -37,8 +37,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,
@@ -46,6 +44,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,26 +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)
+boot_info_t __init *__init_boot_info(u32 mbd_pa)
 {
     mbd_t *mbd = __va(mbd_pa);
 
     enable_bsp_exception_support();
 
-    if ( mbd->mods_nr )
-    {
-        mbi.flags |= MBI_MODULES;
-        mbi.mods_count = mbd->mods_nr;
-        mbi.mods_addr = mbd->mods;
-    }
-
-    return (unsigned long)&mbi;
-}
-
-boot_info_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);
 
@@ -158,5 +144,12 @@ boot_info_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 &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 96e758c..d8b30c1 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" (__va(&mbi))
-                     "S" (__va(&boot_info_efi))
+                     "D" (__va(&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 32d9a3a..6417419 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;
@@ -549,12 +548,10 @@ void __init enable_bsp_exception_support(void)
     sort_exception_tables();
 }
 
-void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
+void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
 {
     char *cmdline, *kextra;
     unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
-    multiboot_info_t *mbi = (multiboot_info_t *)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;
@@ -672,7 +669,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
            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 )
@@ -707,8 +704,8 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
     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.
@@ -723,16 +720,15 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
      * 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
@@ -773,7 +769,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         {
             /* 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
@@ -861,36 +857,36 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         }
 
         /* 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;
@@ -898,18 +894,18 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         }
     }
 
-    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). */
@@ -955,10 +951,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
                     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;
@@ -1031,13 +1027,13 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
         }
     }
 
-    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 )
@@ -1191,13 +1187,13 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
 
     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();
 
@@ -1302,7 +1298,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
     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];
@@ -1334,8 +1330,8 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
     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);
@@ -1352,9 +1348,9 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
      * 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 03c6658..1b786a1 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 a882c0c..c0c92b4 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -22,6 +22,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
@@ -58,6 +59,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 d051ee6..f60cf41 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;
 
@@ -29,9 +29,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);
@@ -40,7 +40,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..9723e59 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -16,7 +16,9 @@
 #define __XSM_H__
 
 #include <xen/sched.h>
-#include <xen/multiboot.h>
+#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
+#include <asm/boot_info.h>
+#endif
 
 typedef void xsm_op_t;
 DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
@@ -671,11 +673,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 +697,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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 13/18] x86: move EFI memory map stuff to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (11 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 14/18] x86: move MPS, ACPI and SMBIOS data " Daniel Kiper
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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 081453e..77e9d5a 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -44,6 +44,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 1b786a1..3a74e98 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 c0c92b4..99ff93e 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -59,6 +59,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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 14/18] x86: move MPS, ACPI and SMBIOS data to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (12 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 13/18] x86: move EFI memory map stuff to boot_info Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 22:51   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 15/18] x86: move video " Daniel Kiper
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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 77e9d5a..c1a4977 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -23,6 +23,7 @@
 
 #include <xen/types.h>
 #include <xen/cache.h>
+#include <xen/efi.h>
 #include <xen/init.h>
 #include <xen/multiboot.h>
 
@@ -47,6 +48,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 3a74e98..abaebd4 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 99ff93e..4d888ab 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -68,6 +68,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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 15/18] x86: move video data to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (13 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 14/18] x86: move MPS, ACPI and SMBIOS data " Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 22:55   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 16/18] x86: move HDD " Daniel Kiper
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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          |   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 c1a4977..5f990e1 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -33,11 +33,46 @@
 #include <asm/page.h>
 #include <asm/setup.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,
@@ -52,6 +87,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);
+}
+
 boot_info_t __init *__init_boot_info(u32 mbd_pa)
 {
     mbd_t *mbd = __va(mbd_pa);
@@ -155,6 +231,8 @@ boot_info_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 d8b30c1..8ee3e93 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 6417419..05f9e93 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;
@@ -592,8 +522,6 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
      * 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)) );
@@ -621,20 +549,20 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
     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");
@@ -642,15 +570,15 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
     }
 
     /* 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 abaebd4..6212bed 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 4d888ab..97f8a3b 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -20,6 +20,7 @@
 #define __BOOT_INFO_H__
 
 #include <xen/types.h>
+#include <xen/video.h>
 
 #include <asm/e820.h>
 #include <asm/mbd.h>
@@ -80,6 +81,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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 16/18] x86: move HDD data to boot_info
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (14 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 15/18] x86: move video " Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 22:57   ` Andrew Cooper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 17/18] x86/boot: use %ecx instead of %eax Daniel Kiper
                   ` (3 subsequent siblings)
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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              |    6 ++----
 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(+), 28 deletions(-)

diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
index 5f990e1..65f9379 100644
--- a/xen/arch/x86/boot_info.c
+++ b/xen/arch/x86/boot_info.c
@@ -73,6 +73,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,
@@ -90,6 +96,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 @@ boot_info_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 8ee3e93..3311e77 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 05f9e93..6abb61a 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -591,10 +591,8 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
     }
 
     printk("Disc information:\n");
-    printk(" Found %d MBR signatures\n",
-           bootsym(boot_mbr_signature_nr));
-    printk(" Found %d EDD information structures\n",
-           bootsym(boot_edd_info_nr));
+    printk(" Found %d MBR signatures\n", boot_info->mbr_signature_nr);
+    printk(" Found %d EDD information structures\n", 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 6212bed..b67c731 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 97f8a3b..a495522 100644
--- a/xen/include/asm-x86/boot_info.h
+++ b/xen/include/asm-x86/boot_info.h
@@ -23,6 +23,7 @@
 #include <xen/video.h>
 
 #include <asm/e820.h>
+#include <asm/edd.h>
 #include <asm/mbd.h>
 
 /*
@@ -88,6 +89,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] 61+ messages in thread

* [PATCH for-xen-4.5 v4 17/18] x86/boot: use %ecx instead of %eax
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (15 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 16/18] x86: move HDD " Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 18/18] xen/x86: add multiboot2 protocol support Daniel Kiper
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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 (v1)
and multiboot2 protocol.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
v4 - suggestions/fixes:
   - improve comments
     (suggested by Andrew Cooper).
---
 xen/arch/x86/boot/head.S |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

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

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

* [PATCH for-xen-4.5 v4 18/18] xen/x86: add multiboot2 protocol support
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (16 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 17/18] x86/boot: use %ecx instead of %eax Daniel Kiper
@ 2014-10-17 14:12 ` Daniel Kiper
  2014-10-17 23:13   ` Andrew Cooper
  2014-10-17 14:42 ` [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
  2014-10-17 18:02 ` Roy Franz
  19 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 14:12 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>
---
v4 - suggestions/fixes:
   - use macro to get multiboot2 data
     (suggested by Jan Beulich),
   - use named constant in assembly files
     (suggested by Andrew Cooper),
   - rearrange condition for multiboot protocol version
     detection; fallback to multiboot(1) if protocol
     is unknown
     (suggested by Andrew Cooper),
   - improve multiboot2 header comment in head.S
     (suggested by Jan Beulich).

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/Makefile        |    3 +-
 xen/arch/x86/boot/head.S          |  132 ++++++++++++++++++++++++++++++--
 xen/arch/x86/boot/reloc.c         |  119 ++++++++++++++++++++++++++++-
 xen/arch/x86/x86_64/asm-offsets.c |    6 ++
 xen/include/xen/multiboot2.h      |  153 +++++++++++++++++++++++++++++++++++++
 5 files changed, 401 insertions(+), 12 deletions(-)
 create mode 100644 xen/include/xen/multiboot2.h

diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
index e6ff2b7..031a758 100644
--- a/xen/arch/x86/boot/Makefile
+++ b/xen/arch/x86/boot/Makefile
@@ -1,7 +1,8 @@
 obj-bin-y += head.o
 
 RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/compiler.h \
-	     $(BASEDIR)/include/xen/multiboot.h $(BASEDIR)/include/asm-x86/mbd.h
+	     $(BASEDIR)/include/xen/multiboot.h $(BASEDIR)/include/xen/multiboot2.h \
+	     $(BASEDIR)/include/asm-x86/mbd.h
 
 export RELOC_DEPS
 
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 12e41f9..e9a5955 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,82 @@ 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!
+         *
+         * Earlier versions of GRUB2 incorrectly calculate Multiboot2 information
+         * request tag size and read past the end of it 8 bytes. It means that
+         * these 8 bytes must contain something valid in terms of request tag.
+         * Fortunately next tag has MULTIBOOT2_TAG_TYPE_MMAP meaning as a request
+         * and as is it does not change anything in our request because we asked
+         * for that thing above. However, if request tag ends at unaligned address
+         * and .align is used then compiler may put random value in void before
+         * first tag. This could not be accepted by earlier versions of GRUB2 and
+         * Xen load would fail. So, use .balignl and forcibly fill this void with
+         * something valid in terms of request tag. However, this thing should not
+         * change our request in significant way. MULTIBOOT2_TAG_TYPE_END satisfies
+         * these assumptions because GRUB2 must provide ending tag for list of
+         * arguments even if it was not explicitly requested.
+         */
+        .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 +158,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     MBI_mem_lower(%ebx),%edx
+        jmp     trampoline_setup
+
+multiboot2_proto:
+        /* Get Multiboot2 information address */
+        mov     %ebx,%ecx
+
+        /* Skip Multiboot2 information fixed part */
+        add     $MBI2_fixed_sizeof,%ecx
+
+0:
+        /* Get mem_lower from Multiboot2 information */
+        cmpl    $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx)
+        jne     1f
+
+        mov     MBI2_mem_lower(%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     MBI2_tag_size(%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 +220,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     MBI_mem_lower(%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 +234,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    %eax                /* Multiboot magic */
         push    %ebx                /* Multiboot information address */
-        call    reloc               /* %eax contains trampoline 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 9792fcd..4984b00 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -5,19 +5,26 @@
  * and modules. This is most easily done early with paging disabled.
  *
  * Copyright (c) 2009, Citrix Systems, Inc.
+ * Copyright (c) 2013, 2014 Oracle Corp.
  *
  * Authors:
  *    Keir Fraser <keir@xen.org>
+ *    Daniel Kiper
  */
 
-/* entered with %eax = BOOT_TRAMPOLINE */
+/*
+ * 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"
     );
 
@@ -31,12 +38,19 @@ asm (
     );
 
 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"
 
+#define ALIGN_UP(addr, align) \
+                (((addr) + (typeof(addr))(align) - 1) & ~((typeof(addr))(align) - 1))
+
+#define get_mb2_data(tag, type, member) (((type *)(tag))->member)
+
 static u32 alloc_struct(u32 bytes)
 {
     u32 s;
@@ -127,12 +141,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(multiboot2_fixed_t);
+
+    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(multiboot2_fixed_t);
+
+    for ( ; ; )
+    {
+        switch ( tag->type )
+        {
+        case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME:
+            ptr = (u32)get_mb2_data(tag, multiboot2_tag_string_t, string);
+            mbd->boot_loader_name = copy_string(ptr);
+            break;
+
+        case MULTIBOOT2_TAG_TYPE_CMDLINE:
+            ptr = (u32)get_mb2_data(tag, multiboot2_tag_string_t, string);
+            mbd->cmdline = copy_string(ptr);
+            break;
+
+        case MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO:
+            mbd->mem_lower = get_mb2_data(tag, multiboot2_tag_basic_meminfo_t, mem_lower);
+            mbd->mem_upper = get_mb2_data(tag, multiboot2_tag_basic_meminfo_t, mem_upper);
+            break;
+
+        case MULTIBOOT2_TAG_TYPE_MMAP:
+            mbd->mmap_size = get_mb2_data(tag, multiboot2_tag_mmap_t, size);
+            mbd->mmap_size -= sizeof(multiboot2_tag_mmap_t);
+            mbd->mmap_size += sizeof(((multiboot2_tag_mmap_t){0}).entries);
+            mbd->mmap_size /= get_mb2_data(tag, multiboot2_tag_mmap_t, entry_size);
+            mbd->mmap_size *= sizeof(memory_map_t);
+
+            mbd->mmap = alloc_struct(mbd->mmap_size);
+
+            mmap_src = get_mb2_data(tag, multiboot2_tag_mmap_t, 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 = get_mb2_data(tag, multiboot2_tag_module_t, mod_start);
+            mbd_mods[mod_idx].end = get_mb2_data(tag, multiboot2_tag_module_t, mod_end);
+            ptr = (u32)get_mb2_data(tag, multiboot2_tag_module_t, 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));
     zero_struct((u32)mbd, sizeof(*mbd));
 
-    return mb_mbd(mbd, mbi);
+    if ( mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC )
+        return mb2_mbd(mbd, mbi);
+    else
+        return mb_mbd(mbd, mbi);
 }
diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index 7364dd6..ac4ce93 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -10,6 +10,7 @@
 #include <xen/sched.h>
 #include <xen/bitops.h>
 #include <xen/multiboot.h>
+#include <xen/multiboot2.h>
 #include <compat/xen.h>
 #include <asm/fixmap.h>
 #include <asm/hardirq.h>
@@ -167,5 +168,10 @@ void __dummy__(void)
     OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
     BLANK();
 
+    DEFINE(MBI2_fixed_sizeof, sizeof(multiboot2_fixed_t));
+    OFFSET(MBI2_tag_size, multiboot2_tag_t, size);
+    OFFSET(MBI2_mem_lower, multiboot2_tag_basic_meminfo_t, mem_lower);
+    BLANK();
+
     OFFSET(MBD_cmdline, mbd_t, cmdline);
 }
diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h
new file mode 100644
index 0000000..95eaa76
--- /dev/null
+++ b/xen/include/xen/multiboot2.h
@@ -0,0 +1,153 @@
+/*
+ *  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 total_size;
+    u32 reserved;
+} multiboot2_fixed_t;
+
+typedef struct {
+    u32 type;
+    u32 size;
+} multiboot2_tag_t;
+
+typedef struct {
+    u32 type;
+    u32 size;
+    char string[0];
+} multiboot2_tag_string_t;
+
+typedef struct {
+    u32 type;
+    u32 size;
+    u32 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] 61+ messages in thread

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (17 preceding siblings ...)
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 18/18] xen/x86: add multiboot2 protocol support Daniel Kiper
@ 2014-10-17 14:42 ` Jan Beulich
  2014-10-17 15:49   ` Daniel Kiper
  2014-10-17 18:02 ` Roy Franz
  19 siblings, 1 reply; 61+ messages in thread
From: Jan Beulich @ 2014-10-17 14: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 17.10.14 at 16:11, <daniel.kiper@oracle.com> wrote:
> This is my last attempt to have this series in 4.5. If it will be not
> accepted for 4.5 I will continue multiboot2 + EFI development on the
> base of this patch series. Now I am almost sure that we are going in
> right direction. I hope that I will be able to post multiboot2 + EFI
> patches in about 1 month.

Simply looking at the diffstat:

>  xen/Makefile                      |    2 +-
>  xen/arch/x86/Makefile             |    1 +
>  xen/arch/x86/boot/Makefile        |    8 +-
>  xen/arch/x86/boot/build32.mk      |    3 +-
>  xen/arch/x86/boot/cmdline.S       |    9 +-
>  xen/arch/x86/boot/head.S          |  157 ++++++++++++++++++++++++++++++-----
>  xen/arch/x86/boot/reloc.c         |  223 
> ++++++++++++++++++++++++++++++++++++++++---------
>  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              |  369 +++++++++++++++++++++++++++-------------------------------------------------------
>  xen/arch/x86/x86_64/asm-offsets.c |   15 +++-
>  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   |  124 ++++++++++++++++++++++++++++
>  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         |   80 ++++++++++++++++++
>  xen/include/asm-x86/setup.h       |   12 +--
>  xen/include/xen/efi.h             |    7 ++
>  xen/include/xen/multiboot2.h      |  153 ++++++++++++++++++++++++++++++++++
>  xen/include/xen/vga.h             |   18 ----
>  xen/include/xsm/xsm.h             |   16 ++--
>  xen/xsm/xsm_core.c                |    6 +-
>  xen/xsm/xsm_policy.c              |   10 +--
>  35 files changed, 1344 insertions(+), 534 deletions(-)

already makes clear that is isn't the right time for this to get merged,
leaving aside my reservations against you touching all this early boot
code. Sadly I haven't seen Konrad around on IRC lately to check
whether he wants to convince me this absolutely has to go in.

Jan

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

* Re: [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies Daniel Kiper
@ 2014-10-17 14:51   ` Jan Beulich
  2014-10-17 16:10     ` Daniel Kiper
  2014-10-17 14:56   ` Andrew Cooper
  1 sibling, 1 reply; 61+ messages in thread
From: Jan Beulich @ 2014-10-17 14:51 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 17.10.14 at 16:11, <daniel.kiper@oracle.com> wrote:
> --- a/xen/arch/x86/boot/Makefile
> +++ b/xen/arch/x86/boot/Makefile
> @@ -1,8 +1,12 @@
>  obj-bin-y += head.o
>  
> +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
> +
> +export RELOC_DEPS

This can be done on one line, but I'd prefer dropping the export
altogether and communicating the setting on just the make
invocation line.

> -reloc.S: head.S
> +reloc.S: $(RELOC_DEPS)

The dropping of the head.S dependency seems fine, but needs to be
briefly explained in the commit message.

Jan

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

* Re: [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies Daniel Kiper
  2014-10-17 14:51   ` Jan Beulich
@ 2014-10-17 14:56   ` Andrew Cooper
  2014-10-17 15:10     ` Jan Beulich
  1 sibling, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 14:56 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 17/10/14 15:11, Daniel Kiper wrote:
> reloc.S is not rebuild if header included
> in reloc.c is updated. Fix this issue.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  xen/arch/x86/boot/Makefile   |    6 +++++-
>  xen/arch/x86/boot/build32.mk |    3 ++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
> index 13f4a66..3cab36a 100644
> --- a/xen/arch/x86/boot/Makefile
> +++ b/xen/arch/x86/boot/Makefile
> @@ -1,8 +1,12 @@
>  obj-bin-y += head.o
>  
> +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h

What is wrong with the normal gcc method of using "-MMD -MF" ?  It would
avoid duplicating the list of includes in the Makefile.

~Andrew

> +
> +export RELOC_DEPS
> +
>  head.o: reloc.S
>  
>  %.S: %.c
>  	$(MAKE) -f build32.mk $@
>  
> -reloc.S: head.S
> +reloc.S: $(RELOC_DEPS)
> diff --git a/xen/arch/x86/boot/build32.mk b/xen/arch/x86/boot/build32.mk
> index a36f620..809f296 100644
> --- a/xen/arch/x86/boot/build32.mk
> +++ b/xen/arch/x86/boot/build32.mk
> @@ -30,5 +30,6 @@ CFLAGS := $(filter-out -flto,$(CFLAGS))
>  			esac; \
>  		done
>  
> -reloc.o: $(BASEDIR)/include/asm-x86/config.h
> +reloc.o: $(RELOC_DEPS)
> +
>  .PRECIOUS: %.bin %.lnk

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

* Re: [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value Daniel Kiper
@ 2014-10-17 15:00   ` Andrew Cooper
  2014-10-17 15:52     ` Daniel Kiper
  0 siblings, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 15:00 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 17/10/14 15:11, Daniel Kiper wrote:
> ..to access multiboot.mem_lower data.
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

Fine, but...

> ---
>  xen/arch/x86/boot/head.S          |    2 +-
>  xen/arch/x86/x86_64/asm-offsets.c |    3 +++
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index cd43952..0bdbc65 100644
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -101,7 +101,7 @@ __start:
>           */
>          testb   $MBI_MEMLIMITS,(%ebx)
>          jz      2f                  /* not available? BDA value will be fine */
> -        mov     4(%ebx),%edx
> +        mov     MBI_mem_lower(%ebx),%edx
>          cmp     $0x100,%edx         /* is the multiboot value too small? */
>          jb      2f                  /* if so, do not use it */
>          shl     $10-4,%edx
> diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
> index 3994f4d..2de9cad 100644
> --- a/xen/arch/x86/x86_64/asm-offsets.c
> +++ b/xen/arch/x86/x86_64/asm-offsets.c
> @@ -163,6 +163,9 @@ void __dummy__(void)
>      OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);
>      BLANK();
>  
> +    OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
> +    BLANK();
> +
>      OFFSET(MB_flags, multiboot_info_t, flags);
>      OFFSET(MB_cmdline, multiboot_info_t, cmdline);

These are derived from the same struct, so should be declared together,
and have consistent naming.

~Andrew

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

* Re: [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies
  2014-10-17 14:56   ` Andrew Cooper
@ 2014-10-17 15:10     ` Jan Beulich
  0 siblings, 0 replies; 61+ messages in thread
From: Jan Beulich @ 2014-10-17 15:10 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 17.10.14 at 16:56, <andrew.cooper3@citrix.com> wrote:
> On 17/10/14 15:11, Daniel Kiper wrote:
>> reloc.S is not rebuild if header included
>> in reloc.c is updated. Fix this issue.
>>
>> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>> ---
>>  xen/arch/x86/boot/Makefile   |    6 +++++-
>>  xen/arch/x86/boot/build32.mk |    3 ++-
>>  2 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
>> index 13f4a66..3cab36a 100644
>> --- a/xen/arch/x86/boot/Makefile
>> +++ b/xen/arch/x86/boot/Makefile
>> @@ -1,8 +1,12 @@
>>  obj-bin-y += head.o
>>  
>> +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
> 
> What is wrong with the normal gcc method of using "-MMD -MF" ?  It would
> avoid duplicating the list of includes in the Makefile.

The main one being that build32.mk doesn't get invoked with the
full build machinery in place, but just via "$(MAKE) -f".

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-17 14:42 ` [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
@ 2014-10-17 15:49   ` Daniel Kiper
  2014-10-23 10:19     ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 15:49 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 17, 2014 at 03:42:38PM +0100, Jan Beulich wrote:
> >>> On 17.10.14 at 16:11, <daniel.kiper@oracle.com> wrote:
> > This is my last attempt to have this series in 4.5. If it will be not
> > accepted for 4.5 I will continue multiboot2 + EFI development on the
> > base of this patch series. Now I am almost sure that we are going in
> > right direction. I hope that I will be able to post multiboot2 + EFI
> > patches in about 1 month.
>
> Simply looking at the diffstat:
>
> >  xen/Makefile                      |    2 +-
> >  xen/arch/x86/Makefile             |    1 +
> >  xen/arch/x86/boot/Makefile        |    8 +-
> >  xen/arch/x86/boot/build32.mk      |    3 +-
> >  xen/arch/x86/boot/cmdline.S       |    9 +-
> >  xen/arch/x86/boot/head.S          |  157 ++++++++++++++++++++++++++++++-----
> >  xen/arch/x86/boot/reloc.c         |  223
> > ++++++++++++++++++++++++++++++++++++++++---------
> >  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              |  369 +++++++++++++++++++++++++++-------------------------------------------------------
> >  xen/arch/x86/x86_64/asm-offsets.c |   15 +++-
> >  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   |  124 ++++++++++++++++++++++++++++
> >  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         |   80 ++++++++++++++++++
> >  xen/include/asm-x86/setup.h       |   12 +--
> >  xen/include/xen/efi.h             |    7 ++
> >  xen/include/xen/multiboot2.h      |  153 ++++++++++++++++++++++++++++++++++
> >  xen/include/xen/vga.h             |   18 ----
> >  xen/include/xsm/xsm.h             |   16 ++--
> >  xen/xsm/xsm_core.c                |    6 +-
> >  xen/xsm/xsm_policy.c              |   10 +--
> >  35 files changed, 1344 insertions(+), 534 deletions(-)
>
> already makes clear that is isn't the right time for this to get merged,

OK.

> leaving aside my reservations against you touching all this early boot

What is your main concern here (beside that it is big patch series)?

Daniel

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

* Re: [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value
  2014-10-17 15:00   ` Andrew Cooper
@ 2014-10-17 15:52     ` Daniel Kiper
  2014-10-17 16:18       ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 15:52 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 Fri, Oct 17, 2014 at 04:00:57PM +0100, Andrew Cooper wrote:
> On 17/10/14 15:11, Daniel Kiper wrote:
> > ..to access multiboot.mem_lower data.
> >
> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>
> Fine, but...
>
> > ---
> >  xen/arch/x86/boot/head.S          |    2 +-
> >  xen/arch/x86/x86_64/asm-offsets.c |    3 +++
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> > index cd43952..0bdbc65 100644
> > --- a/xen/arch/x86/boot/head.S
> > +++ b/xen/arch/x86/boot/head.S
> > @@ -101,7 +101,7 @@ __start:
> >           */
> >          testb   $MBI_MEMLIMITS,(%ebx)
> >          jz      2f                  /* not available? BDA value will be fine */
> > -        mov     4(%ebx),%edx
> > +        mov     MBI_mem_lower(%ebx),%edx
> >          cmp     $0x100,%edx         /* is the multiboot value too small? */
> >          jb      2f                  /* if so, do not use it */
> >          shl     $10-4,%edx
> > diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
> > index 3994f4d..2de9cad 100644
> > --- a/xen/arch/x86/x86_64/asm-offsets.c
> > +++ b/xen/arch/x86/x86_64/asm-offsets.c
> > @@ -163,6 +163,9 @@ void __dummy__(void)
> >      OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);
> >      BLANK();
> >
> > +    OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
> > +    BLANK();
> > +
> >      OFFSET(MB_flags, multiboot_info_t, flags);
> >      OFFSET(MB_cmdline, multiboot_info_t, cmdline);
>
> These are derived from the same struct, so should be declared together,
> and have consistent naming.

MB_* stuff is removed by patch #6. Later we have MBD_*, MBI_* and MBI2_* only.

Daniel

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

* Re: [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions Daniel Kiper
@ 2014-10-17 16:04   ` Andrew Cooper
  2014-10-17 17:11     ` Daniel Kiper
  0 siblings, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 16:04 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 17/10/14 15:11, 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.

As I asked before, you need to make some comment about changing the
types and introducing loads of casts.  Its fine to say that the eventual
code will use u32s everywhere, but this information must be in the
commit message.

>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>  xen/arch/x86/boot/reloc.c |   52 ++++++++++++++++++++++++++++-----------------
>  1 file changed, 33 insertions(+), 19 deletions(-)
>
> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> index 4609e55..e1c83f4 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -33,9 +33,10 @@ asm (
>  typedef unsigned int u32;
>  #include "../../../include/xen/multiboot.h"
>  
> -static void *reloc_mbi_struct(void *old, unsigned int bytes)
> +static u32 alloc_struct(u32 bytes)
>  {
> -    void *new;
> +    u32 s;
> +
>      asm(
>      "    call 1f                      \n"
>      "1:  pop  %%edx                   \n"
> @@ -43,50 +44,63 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes)
>      "    sub  %1,%0                   \n"
>      "    and  $~15,%0                 \n"
>      "    mov  %0,alloc-1b(%%edx)      \n"
> -    "    mov  %0,%%edi                \n"
> -    "    rep  movsb                   \n"
> -       : "=&r" (new), "+c" (bytes), "+S" (old)
> -	: : "edx", "edi");
> -    return new;
> +       : "=&r" (s) : "r" (bytes) : "edx");
> +
> +    return s;
>  }
>  
> -static char *reloc_mbi_string(char *old)
> +static u32 copy_struct(u32 src, u32 bytes)
> +{
> +    u32 dst, dst_asm;
> +
> +    dst = alloc_struct(bytes);
> +    dst_asm = dst;
> +
> +    asm volatile("rep movsb" : "+S" (src), "+D" (dst_asm), "+c" (bytes));

All 3 registers are only used as inputs, and the modified values are not
useful.  You can drop dst_asm entirely.  See the stack resync code in
__start_xen() as an example.

~Andrew

> +
> +    return dst;
> +}
> +
> +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] 61+ messages in thread

* Re: [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies
  2014-10-17 14:51   ` Jan Beulich
@ 2014-10-17 16:10     ` Daniel Kiper
  2014-10-17 16:22       ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 16:10 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 17, 2014 at 03:51:35PM +0100, Jan Beulich wrote:
> >>> On 17.10.14 at 16:11, <daniel.kiper@oracle.com> wrote:
> > --- a/xen/arch/x86/boot/Makefile
> > +++ b/xen/arch/x86/boot/Makefile
> > @@ -1,8 +1,12 @@
> >  obj-bin-y += head.o
> >
> > +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
> > +
> > +export RELOC_DEPS
>
> This can be done on one line, but I'd prefer dropping the export
> altogether and communicating the setting on just the make
> invocation line.

I suppose that you think about that one:

%.S: %.c
         $(MAKE) -f build32.mk $@ RELOC_DEPS=$(RELOC_DEPS)

However, this is a bit strange because in general rule
we pass args for specific build. So, maybe we should
do that:

reloc.S: reloc.c $(RELOC_DEPS)
         $(MAKE) -f build32.mk $@ RELOC_DEPS=$(RELOC_DEPS)

and simply remove this generic rule from Makefile.

> > -reloc.S: head.S
> > +reloc.S: $(RELOC_DEPS)
>
> The dropping of the head.S dependency seems fine, but needs to be
> briefly explained in the commit message.

OK.

Daniel

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

* Re: [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value
  2014-10-17 15:52     ` Daniel Kiper
@ 2014-10-17 16:18       ` Jan Beulich
  2014-10-17 16:22         ` Daniel Kiper
  0 siblings, 1 reply; 61+ messages in thread
From: Jan Beulich @ 2014-10-17 16:18 UTC (permalink / raw)
  To: Andrew Cooper, Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini, roy.franz,
	ning.sun, ross.philipson, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

>>> On 17.10.14 at 17:52, <daniel.kiper@oracle.com> wrote:
> On Fri, Oct 17, 2014 at 04:00:57PM +0100, Andrew Cooper wrote:
>> On 17/10/14 15:11, Daniel Kiper wrote:
>> > ..to access multiboot.mem_lower data.
>> >
>> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>>
>> Fine, but...
>>
>> > ---
>> >  xen/arch/x86/boot/head.S          |    2 +-
>> >  xen/arch/x86/x86_64/asm-offsets.c |    3 +++
>> >  2 files changed, 4 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
>> > index cd43952..0bdbc65 100644
>> > --- a/xen/arch/x86/boot/head.S
>> > +++ b/xen/arch/x86/boot/head.S
>> > @@ -101,7 +101,7 @@ __start:
>> >           */
>> >          testb   $MBI_MEMLIMITS,(%ebx)
>> >          jz      2f                  /* not available? BDA value will be 
> fine */
>> > -        mov     4(%ebx),%edx
>> > +        mov     MBI_mem_lower(%ebx),%edx
>> >          cmp     $0x100,%edx         /* is the multiboot value too small? 
> */
>> >          jb      2f                  /* if so, do not use it */
>> >          shl     $10-4,%edx
>> > diff --git a/xen/arch/x86/x86_64/asm-offsets.c 
> b/xen/arch/x86/x86_64/asm-offsets.c
>> > index 3994f4d..2de9cad 100644
>> > --- a/xen/arch/x86/x86_64/asm-offsets.c
>> > +++ b/xen/arch/x86/x86_64/asm-offsets.c
>> > @@ -163,6 +163,9 @@ void __dummy__(void)
>> >      OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);
>> >      BLANK();
>> >
>> > +    OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
>> > +    BLANK();
>> > +
>> >      OFFSET(MB_flags, multiboot_info_t, flags);
>> >      OFFSET(MB_cmdline, multiboot_info_t, cmdline);
>>
>> These are derived from the same struct, so should be declared together,
>> and have consistent naming.
> 
> MB_* stuff is removed by patch #6. Later we have MBD_*, MBI_* and MBI2_* 
> only.

But that's no excuse to make things inconsistent here. Applying
some of these initial trivial patches might still be fine for 4.5.

Jan

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

* Re: [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies
  2014-10-17 16:10     ` Daniel Kiper
@ 2014-10-17 16:22       ` Jan Beulich
  0 siblings, 0 replies; 61+ messages in thread
From: Jan Beulich @ 2014-10-17 16:22 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 17.10.14 at 18:10, <daniel.kiper@oracle.com> wrote:
> On Fri, Oct 17, 2014 at 03:51:35PM +0100, Jan Beulich wrote:
>> >>> On 17.10.14 at 16:11, <daniel.kiper@oracle.com> wrote:
>> > --- a/xen/arch/x86/boot/Makefile
>> > +++ b/xen/arch/x86/boot/Makefile
>> > @@ -1,8 +1,12 @@
>> >  obj-bin-y += head.o
>> >
>> > +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h 
> $(BASEDIR)/include/xen/multiboot.h
>> > +
>> > +export RELOC_DEPS
>>
>> This can be done on one line, but I'd prefer dropping the export
>> altogether and communicating the setting on just the make
>> invocation line.
> 
> I suppose that you think about that one:
> 
> %.S: %.c
>          $(MAKE) -f build32.mk $@ RELOC_DEPS=$(RELOC_DEPS)
> 
> However, this is a bit strange because in general rule
> we pass args for specific build. So, maybe we should
> do that:
> 
> reloc.S: reloc.c $(RELOC_DEPS)
>          $(MAKE) -f build32.mk $@ RELOC_DEPS=$(RELOC_DEPS)
> 
> and simply remove this generic rule from Makefile.

Yes.

Jan

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

* Re: [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value
  2014-10-17 16:18       ` Jan Beulich
@ 2014-10-17 16:22         ` Daniel Kiper
  2014-10-20  8:00           ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 16:22 UTC (permalink / raw)
  To: Jan Beulich
  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 Fri, Oct 17, 2014 at 05:18:07PM +0100, Jan Beulich wrote:
> >>> On 17.10.14 at 17:52, <daniel.kiper@oracle.com> wrote:
> > On Fri, Oct 17, 2014 at 04:00:57PM +0100, Andrew Cooper wrote:
> >> On 17/10/14 15:11, Daniel Kiper wrote:
> >> > ..to access multiboot.mem_lower data.
> >> >
> >> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> >>
> >> Fine, but...
> >>
> >> > ---
> >> >  xen/arch/x86/boot/head.S          |    2 +-
> >> >  xen/arch/x86/x86_64/asm-offsets.c |    3 +++
> >> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> >> > index cd43952..0bdbc65 100644
> >> > --- a/xen/arch/x86/boot/head.S
> >> > +++ b/xen/arch/x86/boot/head.S
> >> > @@ -101,7 +101,7 @@ __start:
> >> >           */
> >> >          testb   $MBI_MEMLIMITS,(%ebx)
> >> >          jz      2f                  /* not available? BDA value will be
> > fine */
> >> > -        mov     4(%ebx),%edx
> >> > +        mov     MBI_mem_lower(%ebx),%edx
> >> >          cmp     $0x100,%edx         /* is the multiboot value too small?
> > */
> >> >          jb      2f                  /* if so, do not use it */
> >> >          shl     $10-4,%edx
> >> > diff --git a/xen/arch/x86/x86_64/asm-offsets.c
> > b/xen/arch/x86/x86_64/asm-offsets.c
> >> > index 3994f4d..2de9cad 100644
> >> > --- a/xen/arch/x86/x86_64/asm-offsets.c
> >> > +++ b/xen/arch/x86/x86_64/asm-offsets.c
> >> > @@ -163,6 +163,9 @@ void __dummy__(void)
> >> >      OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);
> >> >      BLANK();
> >> >
> >> > +    OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
> >> > +    BLANK();
> >> > +
> >> >      OFFSET(MB_flags, multiboot_info_t, flags);
> >> >      OFFSET(MB_cmdline, multiboot_info_t, cmdline);
> >>
> >> These are derived from the same struct, so should be declared together,
> >> and have consistent naming.
> >
> > MB_* stuff is removed by patch #6. Later we have MBD_*, MBI_* and MBI2_*
> > only.
>
> But that's no excuse to make things inconsistent here. Applying
> some of these initial trivial patches might still be fine for 4.5.

OK, please tell me which one from this series you want in 4.5 and
I will repost all of them with relevant fixes at the beginning
of next week.

Daniel

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

* Re: [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions
  2014-10-17 16:04   ` Andrew Cooper
@ 2014-10-17 17:11     ` Daniel Kiper
  2014-10-17 17:22       ` Andrew Cooper
  0 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-17 17:11 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 Fri, Oct 17, 2014 at 05:04:33PM +0100, Andrew Cooper wrote:
> On 17/10/14 15:11, 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.
>
> As I asked before, you need to make some comment about changing the
> types and introducing loads of casts.  Its fine to say that the eventual
> code will use u32s everywhere, but this information must be in the
> commit message.

OK.

> > Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> > ---
> >  xen/arch/x86/boot/reloc.c |   52 ++++++++++++++++++++++++++++-----------------
> >  1 file changed, 33 insertions(+), 19 deletions(-)
> >
> > diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
> > index 4609e55..e1c83f4 100644
> > --- a/xen/arch/x86/boot/reloc.c
> > +++ b/xen/arch/x86/boot/reloc.c
> > @@ -33,9 +33,10 @@ asm (
> >  typedef unsigned int u32;
> >  #include "../../../include/xen/multiboot.h"
> >
> > -static void *reloc_mbi_struct(void *old, unsigned int bytes)
> > +static u32 alloc_struct(u32 bytes)
> >  {
> > -    void *new;
> > +    u32 s;
> > +
> >      asm(
> >      "    call 1f                      \n"
> >      "1:  pop  %%edx                   \n"
> > @@ -43,50 +44,63 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes)
> >      "    sub  %1,%0                   \n"
> >      "    and  $~15,%0                 \n"
> >      "    mov  %0,alloc-1b(%%edx)      \n"
> > -    "    mov  %0,%%edi                \n"
> > -    "    rep  movsb                   \n"
> > -       : "=&r" (new), "+c" (bytes), "+S" (old)
> > -	: : "edx", "edi");
> > -    return new;
> > +       : "=&r" (s) : "r" (bytes) : "edx");
> > +
> > +    return s;
> >  }
> >
> > -static char *reloc_mbi_string(char *old)
> > +static u32 copy_struct(u32 src, u32 bytes)
> > +{
> > +    u32 dst, dst_asm;
> > +
> > +    dst = alloc_struct(bytes);
> > +    dst_asm = dst;
> > +
> > +    asm volatile("rep movsb" : "+S" (src), "+D" (dst_asm), "+c" (bytes));
>
> All 3 registers are only used as inputs, and the modified values are not
> useful.  You can drop dst_asm entirely.  See the stack resync code in
> __start_xen() as an example.

"rep movsb" clobbers S, D and c. If you put them as inputs then you are
not able to tell GCC that they are clobbered. It means that GCC will assume
that e.g. D contents, which in turn is assigned to dst variable, is the same
before and after "asm volatile" which is not true. So, I do not know how
'asm volatile("rep movsb"...' in __start_xen() works and nothing has not
blown out yet... Probably it is just fortunate coincidence. In my case it
did not work (to be precise, sometime it worked). Hence, that is why I must
put all input data as input/output and define additional variable which
is used by "asm volatile" only. Maybe we should consider fixing this stuff
in __start_xen() too... Are there other places with that bad guys?

However, now I am thinking that we should add "memory" to clobbers when
"rep movsb" and similar thing are used here.

Daniel

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

* Re: [PATCH for-xen-4.5 v4 06/18] x86: introduce MultiBoot Data (MBD) type
  2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 06/18] x86: introduce MultiBoot Data (MBD) type Daniel Kiper
@ 2014-10-17 17:14   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 17:14 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 17/10/14 15:11, 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).

"for unused data, which is what currently happens."

> 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.

I have finally worked out why I am so confused by this patch which
initialises mbi from mbd, and mbd from mbi.

You appear to be:
* Introducing the concept of MBD
* Introducing a new global by the name "mbi"

The dataflow at the end of the patch is now:
* Take multiboot1_info from bootloader
* Covert it to MBD in reloc()
* For compatibility reasons, reinitialise the new global from mbd so the
v1 code in __start_xen() continues to work.

Details like this *absolutely must* be in the message, especially when
the code looks buggy to an insufficiently-informed reviewer.

>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v4 - suggestions/fixes:
>    - rename reloc() function
>      (suggested by Andrew Cooper),
>    - rename enable_bsp_exception_support() function
>      (suggested by Andrew Cooper),
>    - move enable_bsp_exception_support() function
>      declaration to header file
>      (suggested by Andrew Cooper and Jan Beulich),
>    - change sizeof(<expression>) to sizeof(<type>) where possible
>      (suggested by Jan Beulich),
>    - set only mbi flag only if relevant data is valid
>      (suggested by Jan Beulich),
>    - improve inline assembly
>      (suggested by Andrew Cooper),
>    - improve comments
>      (suggested by Andrew Cooper),
>    - fix copyright
>      (suggested by Konrad Rzeszutek Wilk),
>    - fix coding style
>      (suggested by Andrew Cooper, Jan Beulich and Konrad Rzeszutek Wilk).
>
> 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/Makefile        |    3 +-
>  xen/arch/x86/boot/cmdline.S       |    9 ++---
>  xen/arch/x86/boot/head.S          |    2 +-
>  xen/arch/x86/boot/reloc.c         |   66 ++++++++++++++++++++----------
>  xen/arch/x86/boot/x86_64.S        |   10 +++--
>  xen/arch/x86/boot_info.c          |   70 ++++++++++++++++++++++++++++++++
>  xen/arch/x86/efi/efi-boot.h       |    2 +-
>  xen/arch/x86/setup.c              |   42 +++++++++++--------
>  xen/arch/x86/x86_64/asm-offsets.c |    6 +--
>  xen/include/asm-x86/mbd.h         |   80 +++++++++++++++++++++++++++++++++++++
>  xen/include/asm-x86/setup.h       |    2 +
>  12 files changed, 241 insertions(+), 52 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/Makefile b/xen/arch/x86/boot/Makefile
> index 3cab36a..e6ff2b7 100644
> --- a/xen/arch/x86/boot/Makefile
> +++ b/xen/arch/x86/boot/Makefile
> @@ -1,6 +1,7 @@
>  obj-bin-y += head.o
>  
> -RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/multiboot.h
> +RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/compiler.h \
> +	     $(BASEDIR)/include/xen/multiboot.h $(BASEDIR)/include/asm-x86/mbd.h
>  
>  export RELOC_DEPS
>  
> diff --git a/xen/arch/x86/boot/cmdline.S b/xen/arch/x86/boot/cmdline.S
> index 00687eb..b622c6b 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(%ebx),%eax
>          test    %eax,%eax
>          jz      .Lcmdline_exit
>  
>          /* Check for 'no-real-mode' command-line option. */
>          pushl   $sym_phys(.Lno_rm_opt)
> -        pushl   MB_cmdline(%ebx)
> +        pushl   MBD_cmdline(%ebx)
>          call    .Lfind_option
>          test    %eax,%eax
>          setnz   %al
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index 0bdbc65..64a0ff7 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 e1c83f4..9792fcd 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -31,8 +31,12 @@ asm (
>      );
>  
>  typedef unsigned int u32;
> +
> +#include "../../../include/xen/compiler.h"
>  #include "../../../include/xen/multiboot.h"
>  
> +#include "../../../include/asm/mbd.h"
> +
>  static u32 alloc_struct(u32 bytes)
>  {
>      u32 s;
> @@ -49,6 +53,11 @@ static u32 alloc_struct(u32 bytes)
>      return s;
>  }
>  
> +static void zero_struct(u32 s, u32 bytes)
> +{
> +    asm volatile("rep stosb" : "+D" (s), "+c" (bytes) : "a" (0));

As with copy_struct(), s and bytes are just inputs.

> +}
> +
>  static u32 copy_struct(u32 src, u32 bytes)
>  {
>      u32 dst, dst_asm;
> @@ -74,41 +83,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));
> +    zero_struct((u32)mbd, sizeof(*mbd));
>  
> -    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..fc7ce74 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
> +        /* Initialize the Multiboot info struct. */
> +        mov     mbd_pa(%rip),%edi
> +        call    __init_mbi
> +
> +        /* Pass off the Multiboot info struct 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..64bc4d9
> --- /dev/null
> +++ b/xen/arch/x86/boot_info.c
> @@ -0,0 +1,70 @@
> +/*
> + * Copyright (c) 2013, 2014 Oracle Corp.
> + *      Author: 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>
> +#include <asm/setup.h>
> +
> +static multiboot_info_t __read_mostly mbi;
> +
> +unsigned long __init __init_mbi(u32 mbd_pa)

This function is for compatibility while boot_info is introduced across
the series, and removed later.

This is fine, but leave a comment here in the code, to help review.

> +{
> +    mbd_t *mbd = __va(mbd_pa);
> +
> +    enable_bsp_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;
> +    }
> +
> +    if ( mbd->mem_lower || mbd->mem_upper )
> +    {
> +        mbi.flags |= MBI_MEMLIMITS;
> +        mbi.mem_lower = mbd->mem_lower;
> +        mbi.mem_upper = mbd->mem_upper;
> +    }
> +
> +    if ( mbd->mmap_size )
> +    {
> +        mbi.flags |= MBI_MEMMAP;
> +        mbi.mmap_length = mbd->mmap_size;
> +        mbi.mmap_addr = mbd->mmap;
> +    }
> +
> +    if ( mbd->mods_nr )
> +    {
> +        mbi.flags |= MBI_MODULES;
> +        mbi.mods_count = mbd->mods_nr;
> +        mbi.mods_addr = mbd->mods;
> +    }
> +
> +    return (unsigned long)&mbi;
> +}
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 4348cfe..5c85854 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -245,7 +245,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)
> +                     "D" (__va(&mbi))
>                     : "memory" );
>      for( ; ; ); /* not reached */
>  }
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index bfbb310..eacb9b2 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -529,12 +529,29 @@ static char * __init cmdline_cook(char *p, const char *loader_name)
>      return p;
>  }
>  
> +void __init enable_bsp_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();
> +}
> +
>  void __init noreturn __start_xen(unsigned long mbi_p)
>  {
>      char *memmap_type = NULL;
>      char *cmdline, *kextra, *loader;
>      unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
> -    multiboot_info_t *mbi = __va(mbi_p);
> +    multiboot_info_t *mbi = (multiboot_info_t *)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;
> @@ -546,21 +563,14 @@ 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_bsp_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 2de9cad..7364dd6 100644
> --- a/xen/arch/x86/x86_64/asm-offsets.c
> +++ b/xen/arch/x86/x86_64/asm-offsets.c
> @@ -9,10 +9,11 @@
>  #include <xen/perfc.h>
>  #include <xen/sched.h>
>  #include <xen/bitops.h>
> +#include <xen/multiboot.h>
>  #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 " */<==\"" \
> @@ -166,6 +167,5 @@ void __dummy__(void)
>      OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
>      BLANK();
>  
> -    OFFSET(MB_flags, multiboot_info_t, flags);
> -    OFFSET(MB_cmdline, multiboot_info_t, cmdline);
> +    OFFSET(MBD_cmdline, 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..11c7bcd
> --- /dev/null
> +++ b/xen/include/asm-x86/mbd.h
> @@ -0,0 +1,80 @@
> +/*
> + * Copyright (c) 2013, 2014 Oracle Corp.
> + *      Author: 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 an array of module descriptions (boot_module_t *). */
> +    u32 mods;
> +} mbd_t;
> +#endif /* __MBD_H__ */
> diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h
> index 8f8c6f3..d051ee6 100644
> --- a/xen/include/asm-x86/setup.h
> +++ b/xen/include/asm-x86/setup.h
> @@ -5,6 +5,8 @@
>  
>  extern unsigned long xenheap_initial_phys_start;
>  
> +extern void enable_bsp_exception_support(void);
> +

Altering the exception support should be in a separate patch.  It is a
logically distinct piece of work.

~Andrew

>  void early_cpu_init(void);
>  void early_time_init(void);
>  

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

* Re: [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions
  2014-10-17 17:11     ` Daniel Kiper
@ 2014-10-17 17:22       ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 17:22 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 17/10/14 18:11, Daniel Kiper wrote:
> On Fri, Oct 17, 2014 at 05:04:33PM +0100, Andrew Cooper wrote:
>> On 17/10/14 15:11, 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.
>> As I asked before, you need to make some comment about changing the
>> types and introducing loads of casts.  Its fine to say that the eventual
>> code will use u32s everywhere, but this information must be in the
>> commit message.
> OK.
>
>>> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>>> ---
>>>  xen/arch/x86/boot/reloc.c |   52 ++++++++++++++++++++++++++++-----------------
>>>  1 file changed, 33 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
>>> index 4609e55..e1c83f4 100644
>>> --- a/xen/arch/x86/boot/reloc.c
>>> +++ b/xen/arch/x86/boot/reloc.c
>>> @@ -33,9 +33,10 @@ asm (
>>>  typedef unsigned int u32;
>>>  #include "../../../include/xen/multiboot.h"
>>>
>>> -static void *reloc_mbi_struct(void *old, unsigned int bytes)
>>> +static u32 alloc_struct(u32 bytes)
>>>  {
>>> -    void *new;
>>> +    u32 s;
>>> +
>>>      asm(
>>>      "    call 1f                      \n"
>>>      "1:  pop  %%edx                   \n"
>>> @@ -43,50 +44,63 @@ static void *reloc_mbi_struct(void *old, unsigned int bytes)
>>>      "    sub  %1,%0                   \n"
>>>      "    and  $~15,%0                 \n"
>>>      "    mov  %0,alloc-1b(%%edx)      \n"
>>> -    "    mov  %0,%%edi                \n"
>>> -    "    rep  movsb                   \n"
>>> -       : "=&r" (new), "+c" (bytes), "+S" (old)
>>> -	: : "edx", "edi");
>>> -    return new;
>>> +       : "=&r" (s) : "r" (bytes) : "edx");
>>> +
>>> +    return s;
>>>  }
>>>
>>> -static char *reloc_mbi_string(char *old)
>>> +static u32 copy_struct(u32 src, u32 bytes)
>>> +{
>>> +    u32 dst, dst_asm;
>>> +
>>> +    dst = alloc_struct(bytes);
>>> +    dst_asm = dst;
>>> +
>>> +    asm volatile("rep movsb" : "+S" (src), "+D" (dst_asm), "+c" (bytes));
>> All 3 registers are only used as inputs, and the modified values are not
>> useful.  You can drop dst_asm entirely.  See the stack resync code in
>> __start_xen() as an example.
> "rep movsb" clobbers S, D and c. If you put them as inputs then you are
> not able to tell GCC that they are clobbered. It means that GCC will assume
> that e.g. D contents, which in turn is assigned to dst variable, is the same
> before and after "asm volatile" which is not true. So, I do not know how
> 'asm volatile("rep movsb"...' in __start_xen() works and nothing has not
> blown out yet... Probably it is just fortunate coincidence. In my case it
> did not work (to be precise, sometime it worked). Hence, that is why I must
> put all input data as input/output and define additional variable which
> is used by "asm volatile" only. Maybe we should consider fixing this stuff
> in __start_xen() too... Are there other places with that bad guys?

Hmm - is appears that __start_xen() is saved because it only clobbers
the registers which are also clobbered by the unconditional call to
bootstrap_unmap() following it.

I will take a look for other issues.

>
> However, now I am thinking that we should add "memory" to clobbers when
> "rep movsb" and similar thing are used here.

Yes - the memory clobber is very important.

~Andrew

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
                   ` (18 preceding siblings ...)
  2014-10-17 14:42 ` [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
@ 2014-10-17 18:02 ` Roy Franz
  2014-10-27 11:09   ` Daniel Kiper
  19 siblings, 1 reply; 61+ messages in thread
From: Roy Franz @ 2014-10-17 18:02 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: jgross, keir, Ian Campbell, andrew.cooper3, Stefano Stabellini,
	ross.philipson, ning.sun, Jan Beulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, Fu Wei

On Fri, Oct 17, 2014 at 7:11 AM, Daniel Kiper <daniel.kiper@oracle.com> wrote:
> Hi all,
>
> 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.
>
> I took into account all suggestions sent to me up until now.
>
> ARM build has been tested. However, I am not able to test generated
> binaries because I do not have a required hardware under my feet.
> Could you do some tests guys?

This boots to dom0 for me using the FVP arm64 model, and booting
using EFI. (I don't have a setup for testing non-EFI boot)

>
> This is my last attempt to have this series in 4.5. If it will be not
> accepted for 4.5 I will continue multiboot2 + EFI development on the
> base of this patch series. Now I am almost sure that we are going in
> right direction. I hope that I will be able to post multiboot2 + EFI
> patches in about 1 month.
>
> Daniel
>
>  xen/Makefile                      |    2 +-
>  xen/arch/x86/Makefile             |    1 +
>  xen/arch/x86/boot/Makefile        |    8 +-
>  xen/arch/x86/boot/build32.mk      |    3 +-
>  xen/arch/x86/boot/cmdline.S       |    9 +-
>  xen/arch/x86/boot/head.S          |  157 ++++++++++++++++++++++++++++++-----
>  xen/arch/x86/boot/reloc.c         |  223 ++++++++++++++++++++++++++++++++++++++++---------
>  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              |  369 +++++++++++++++++++++++++++-------------------------------------------------------
>  xen/arch/x86/x86_64/asm-offsets.c |   15 +++-
>  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   |  124 ++++++++++++++++++++++++++++
>  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         |   80 ++++++++++++++++++
>  xen/include/asm-x86/setup.h       |   12 +--
>  xen/include/xen/efi.h             |    7 ++
>  xen/include/xen/multiboot2.h      |  153 ++++++++++++++++++++++++++++++++++
>  xen/include/xen/vga.h             |   18 ----
>  xen/include/xsm/xsm.h             |   16 ++--
>  xen/xsm/xsm_core.c                |    6 +-
>  xen/xsm/xsm_policy.c              |   10 +--
>  35 files changed, 1344 insertions(+), 534 deletions(-)
>
> Daniel Kiper (18):
>       xen/makefile: clean target should remove xen.efi binary
>       x86/boot: fix reloc.S build dependencies
>       x86: define cmdline_cook() loader_name argument as a const
>       x86/boot: use constant in head.S instead of hardcoded value
>       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] 61+ messages in thread

* Re: [PATCH for-xen-4.5 v4 08/18] x86: introduce boot_info structure
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 08/18] x86: introduce boot_info structure Daniel Kiper
@ 2014-10-17 20:55   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 20:55 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 17/10/2014 15:12, 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
>
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v4 - suggestions/fixes:
>     - change some variables "char *" type to "const char *" type
>       (suggested by Andrew Cooper),
>     - do ARM test build
>       (suggested by Ian Campbell and Stefano Stabellini).
>
> 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     |    1 +
>   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 |   47 +++++++++++++++++++++++++++++++++++++++
>   7 files changed, 96 insertions(+), 3 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 fc7ce74..2305b56 100644
> --- a/xen/arch/x86/boot/x86_64.S
> +++ b/xen/arch/x86/boot/x86_64.S
> @@ -32,9 +32,15 @@
>           /* Initialize the Multiboot info struct. */
>           mov     mbd_pa(%rip),%edi
>           call    __init_mbi
> +        pushq   %rax
> +
> +        /* Initialize the boot_info. */
> +        mov     mbd_pa(%rip),%edi
> +        call    __init_boot_info
>   
> -        /* Pass off the Multiboot info struct to C land. */
> -        movq    %rax,%rdi
> +        /* Pass off the Multiboot info struct and the 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 64bc4d9..c5f2a18 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -21,12 +21,18 @@
>   #include <xen/init.h>
>   #include <xen/multiboot.h>
>   
> +#include <asm/boot_info.h>
>   #include <asm/mbd.h>
>   #include <asm/page.h>
>   #include <asm/setup.h>
>   
>   static multiboot_info_t __read_mostly mbi;
>   
> +static boot_info_t __read_mostly boot_info_mb = {
> +    .warn_msg = NULL,
> +    .err_msg = NULL

Almost all of these fields are 0.  It would be neater to only initialise 
the ones which need to be non-0.

> +};
> +
>   unsigned long __init __init_mbi(u32 mbd_pa)
>   {
>       mbd_t *mbd = __va(mbd_pa);
> @@ -68,3 +74,8 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>   
>       return (unsigned long)&mbi;
>   }
> +
> +boot_info_t __init *__init_boot_info(u32 mbd_pa)

No need for leading underscores on the function name.

> +{
> +    return &boot_info_mb;
> +}
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 9458e7f..3da1a2a 100644
> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -255,6 +255,7 @@ static void __init noreturn efi_arch_post_exit_boot(void)
>                        [ds] "r" (__HYPERVISOR_DS),
>                        [stkoff] "i" (STACK_SIZE - sizeof(struct cpu_info)),
>                        "D" (__va(&mbi))
> +                     "S" (__va(&boot_info_efi))
>                      : "memory" );
>       for( ; ; ); /* not reached */
>   }
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index eacb9b2..18fa3e4 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;
> @@ -546,7 +549,7 @@ void __init enable_bsp_exception_support(void)
>       sort_exception_tables();
>   }
>   
> -void __init noreturn __start_xen(unsigned long mbi_p)
> +void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
>   {
>       char *memmap_type = NULL;
>       char *cmdline, *kextra, *loader;
> @@ -563,6 +566,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>           .stop_bits = 1
>       };
>   
> +    boot_info = boot_info_ptr;
> +
>       if ( efi_enabled )
>       {
>           enable_bsp_exception_support();
> @@ -612,6 +617,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);

panic("Fatal error from early boot: %s", boot_info->err_msg);

although I suspect any fatal error from boot will prevent us from 
reaching this point.

> +
> +    if ( boot_info->warn_msg )
> +        printk(boot_info->warn_msg);

printk(XENLOG_WARNING "Warning from early boot: %s\n", boot_info->warn_msg);

~Andrew

> +
>       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..f0a76b2
> --- /dev/null
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -0,0 +1,47 @@
> +/*
> + * Copyright (c) 2013, 2014 Oracle Corp.
> + *      Author: 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.
> +     */
> +    const char *warn_msg;
> +
> +    /*
> +     * Info about error occurred during boot_info initialization. NULL if everything
> +     * went OK. Otherwise boot_info is not fully/properly initialized.
> +     */
> +    const char *err_msg;
> +} boot_info_t;
> +
> +extern boot_info_t *boot_info;
> +#endif /* __BOOT_INFO_H__ */

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

* Re: [PATCH for-xen-4.5 v4 09/18] x86: move boot_loader_name from mbi to boot_info
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 09/18] x86: move boot_loader_name from mbi to boot_info Daniel Kiper
@ 2014-10-17 21:05   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 21:05 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 17/10/2014 15:12, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
> v4 - suggestions/fixes:
>     - change boot_loader_name type to "const char *"
>       (suggested by Andrew Cooper).
> ---
>   xen/arch/x86/boot_info.c        |   12 ++++++------
>   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(+), 16 deletions(-)
>
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index c5f2a18..a81e98b 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -29,6 +29,7 @@
>   static multiboot_info_t __read_mostly mbi;
>   
>   static boot_info_t __read_mostly boot_info_mb = {
> +    .boot_loader_name = "UNKNOWN",

This should be lowercase if you wish to match the code removed lower down.

>       .warn_msg = NULL,
>       .err_msg = NULL
>   };
> @@ -39,12 +40,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>   
>       enable_bsp_exception_support();
>   
> -    if ( mbd->boot_loader_name )
> -    {
> -        mbi.flags = MBI_LOADERNAME;

I have only noticed in this patch, but the above line should strictly be 
an |=, when it is introduced in the earlier patch.

> -        mbi.boot_loader_name = mbd->boot_loader_name;
> -    }
> -
>       if ( mbd->cmdline )
>       {
>           mbi.flags |= MBI_CMDLINE;
> @@ -77,5 +72,10 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>   
>   boot_info_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 &boot_info_mb;
>   }
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 3da1a2a..19be165 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 18fa3e4..a9dbc05 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -552,7 +552,7 @@ void __init enable_bsp_exception_support(void)
>   void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
>   {
>       char *memmap_type = NULL;
> -    char *cmdline, *kextra, *loader;
> +    char *cmdline, *kextra;
>       unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
>       multiboot_info_t *mbi = (multiboot_info_t *)mbi_p;
>       module_t *mod = (module_t *)__va(mbi->mods_addr);
> @@ -577,13 +577,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           /* 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 )
>       {
>           /*
> @@ -623,7 +620,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>       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);
>   
> @@ -697,7 +694,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           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 )
>       {
> @@ -1379,7 +1376,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>       {
>           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 f0a76b2..9e68447 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -30,6 +30,9 @@
>    * are compatible as much as possible with relevant EFI/ACPI types.
>    */
>   typedef struct {
> +    /* Boot loader name. */
> +    const char *boot_loader_name;
> +

I think this can reasonably be named simply "loader".

~Andrew

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

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

* Re: [PATCH for-xen-4.5 v4 10/18] x86: move cmdline from mbi to boot_info
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 10/18] x86: move cmdline " Daniel Kiper
@ 2014-10-17 21:27   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 21:27 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 17/10/2014 15:12, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

After adjusting for relevant review given in previous patches,

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

> ---
>   xen/arch/x86/boot_info.c        |   10 ++++------
>   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(+), 14 deletions(-)
>
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index a81e98b..7d8b0e5 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -30,6 +30,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,12 +41,6 @@ unsigned long __init __init_mbi(u32 mbd_pa)
>   
>       enable_bsp_exception_support();
>   
> -    if ( mbd->cmdline )
> -    {
> -        mbi.flags |= MBI_CMDLINE;
> -        mbi.cmdline = mbd->cmdline;
> -    }
> -
>       if ( mbd->mem_lower || mbd->mem_upper )
>       {
>           mbi.flags |= MBI_MEMLIMITS;
> @@ -77,5 +72,8 @@ boot_info_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 &boot_info_mb;
>   }
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index 19be165..f02e604 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 a9dbc05..8f83969 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -578,9 +578,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>       }
>   
>       /* 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 9e68447..44d1674 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -33,6 +33,9 @@ typedef struct {
>       /* Boot loader name. */
>       const char *boot_loader_name;
>   
> +    /* Xen command line. */
> +    char *cmdline;
> +
>       /*
>        * Info about warning occurred during boot_info initialization.
>        * NULL if everything went OK.

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

* Re: [PATCH for-xen-4.5 v4 11/18] x86: move legacy BIOS memory map stuff to boot_info
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 11/18] x86: move legacy BIOS memory map stuff " Daniel Kiper
@ 2014-10-17 22:08   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 22:08 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 17/10/2014 15:12, 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, 135 insertions(+), 98 deletions(-)
>
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index 7d8b0e5..9e4af78 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -16,45 +16,126 @@
>    * 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.
> + */
> +

I don't think this comment adds any productive value.  I would just 
discard it.

>   #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>
>   #include <asm/setup.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;

Strictly speaking, these are uint32_t's rather than unsigned ints.

> +
>   static multiboot_info_t __read_mostly mbi;
>   
>   static boot_info_t __read_mostly boot_info_mb = {
>       .boot_loader_name = "UNKNOWN",
>       .cmdline = NULL,
> +    .mmap_src = NULL,
> +    .mem_upper = 0,
> +    .e820map_nr = 0,
> +    .e820map = NULL,
>       .warn_msg = NULL,
>       .err_msg = NULL
>   };
>   
> -unsigned long __init __init_mbi(u32 mbd_pa)

This is a rather peculiar way for git/diff to have split the patch. Does 
the patient algorithm yield a more intelligible patch?

> +#define e820_raw bootsym(e820map)
> +#define e820_raw_nr bootsym(e820nr)
> +
> +static void __init init_mmap(boot_info_t *boot_info, mbd_t *mbd)
>   {
> -    mbd_t *mbd = __va(mbd_pa);
> +    int bytes = 0;
> +    memory_map_t *map;
>   
> -    enable_bsp_exception_support();
> +    if ( e820_raw_nr )
> +        boot_info->mmap_src = "Xen-e820";
> +    else if ( mbd->mmap_size )
> +    {
> +        boot_info->mmap_src = "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 ( mbd->mem_lower || mbd->mem_upper )
> +            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) )
>       {
> -        mbi.flags |= MBI_MEMLIMITS;
> -        mbi.mem_lower = mbd->mem_lower;
> -        mbi.mem_upper = mbd->mem_upper;
> +        boot_info->mmap_src = "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_src = "Multiboot-e801";
>   
> -    if ( mbd->mmap_size )
> +        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
>       {
> -        mbi.flags |= MBI_MEMMAP;
> -        mbi.mmap_length = mbd->mmap_size;
> -        mbi.mmap_addr = mbd->mmap;
> +        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_bsp_exception_support();
> +
>       if ( mbd->mods_nr )
>       {
>           mbi.flags |= MBI_MODULES;
> @@ -75,5 +156,7 @@ boot_info_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 &boot_info_mb;
>   }
> diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
> index f02e604..96e758c 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;

Having a variable by the name of "e820map" of type "e820entry *" is 
confusing alongside the type "e320map", but that is a fault of the 
original code.

However, how can this code ever have worked?  the symbol e820map is a 
bootsym and not valid to be used as a regular pointer like this.

>       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 8f83969..32d9a3a 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -551,13 +551,12 @@ void __init enable_bsp_exception_support(void)
>   
>   void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
>   {
> -    char *memmap_type = NULL;
>       char *cmdline, *kextra;
>       unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
>       multiboot_info_t *mbi = (multiboot_info_t *)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 = {
> @@ -691,77 +690,11 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           /* 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_src, boot_info->e820map,
> +                                        &boot_info->e820map_nr);

A possible consideration for cleanup.  As this is the single caller of 
init_e820, and all the information is derived from boot_info, init_e820 
could drop all 3 of its parameters, and read boot_info straight.

~Andrew

>   
>       /* 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..03c6658 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_src = "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 44d1674..a882c0c 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -19,6 +19,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
> @@ -36,6 +40,24 @@ typedef struct {
>       /* Xen command line. */
>       char *cmdline;
>   
> +    /* Memory map source name. */
> +    const char *mmap_src;
> +
> +    /*
> +     * 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*/

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

* Re: [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi Daniel Kiper
@ 2014-10-17 22:35   ` Andrew Cooper
  2014-10-20  8:38     ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 22:35 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 17/10/2014 15:12, Daniel Kiper wrote:

This patch is still conflating two things (moving modules from one 
scheme to another), and clearing up the compat mbi notion.  They should 
be split apart, which would aid the clarity of the modules change.

> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
> ---
>   xen/arch/x86/boot/x86_64.S      |   10 +--
>   xen/arch/x86/boot_info.c        |   27 +++-----
>   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           |   16 +++--
>   xen/xsm/xsm_core.c              |    6 +-
>   xen/xsm/xsm_policy.c            |   10 +--
>   13 files changed, 153 insertions(+), 171 deletions(-)
>
> diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S
> index 2305b56..500e0d7 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
>   
> -        /* Initialize the Multiboot info struct. */
> -        mov     mbd_pa(%rip),%edi
> -        call    __init_mbi
> -        pushq   %rax
> -
>           /* Initialize the boot_info. */
>           mov     mbd_pa(%rip),%edi

Thinking about this, having got this far through the series.  Why cant 
__init_boot_inf() be a parameterless function?  mbd is available to it 
straight from C, which would reduce the amount of parameter-passing in 
asm code.

>           call    __init_boot_info
>   
> -        /* Pass off the Multiboot info struct and the 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 9e4af78..081453e 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -37,8 +37,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,
> @@ -46,6 +44,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,26 +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)
> +boot_info_t __init *__init_boot_info(u32 mbd_pa)
>   {
>       mbd_t *mbd = __va(mbd_pa);
>   
>       enable_bsp_exception_support();
>   
> -    if ( mbd->mods_nr )
> -    {
> -        mbi.flags |= MBI_MODULES;
> -        mbi.mods_count = mbd->mods_nr;
> -        mbi.mods_addr = mbd->mods;
> -    }
> -
> -    return (unsigned long)&mbi;
> -}
> -
> -boot_info_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);
>   
> @@ -158,5 +144,12 @@ boot_info_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 &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 96e758c..d8b30c1 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" (__va(&mbi))
> -                     "S" (__va(&boot_info_efi))
> +                     "D" (__va(&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;

end is surely start + size (give or take a fencepost) ?  How did the 
pre-existing code work?

> +    ++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 32d9a3a..6417419 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;
> @@ -549,12 +548,10 @@ void __init enable_bsp_exception_support(void)
>       sort_exception_tables();
>   }
>   
> -void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr)
> +void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
>   {
>       char *cmdline, *kextra;
>       unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity;
> -    multiboot_info_t *mbi = (multiboot_info_t *)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;
> @@ -672,7 +669,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>              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 )
> @@ -707,8 +704,8 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>       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.
> @@ -723,16 +720,15 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>        * 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);

The old code was playing a little fast-and-loose with pointers vs arrays.

Please convert to the more-appropriate mods[0] as you are transforming 
the code anyway, which helps highlight the bzimage_headroom() check 
applies to the dom0 kernel only.

>       bootstrap_map(NULL);
>   
>   #ifndef highmem_start
> @@ -773,7 +769,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           {
>               /* 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
> @@ -861,36 +857,36 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           }
>   
>           /* 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;
> @@ -898,18 +894,18 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           }
>       }
>   
> -    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). */
> @@ -955,10 +951,10 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>                       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;
> @@ -1031,13 +1027,13 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>           }
>       }
>   
> -    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 )
> @@ -1191,13 +1187,13 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>   
>       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();
>   
> @@ -1302,7 +1298,7 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>       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];
> @@ -1334,8 +1330,8 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>       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);
> @@ -1352,9 +1348,9 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>        * 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,

&boot_info->mods[0] please.

> +                        (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 03c6658..1b786a1 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] = {};

You can drop the braces, as this is static.

~Andrew

> +
>   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 a882c0c..c0c92b4 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -22,6 +22,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
> @@ -58,6 +59,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 d051ee6..f60cf41 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;
>   
> @@ -29,9 +29,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);
> @@ -40,7 +40,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..9723e59 100644
> --- a/xen/include/xsm/xsm.h
> +++ b/xen/include/xsm/xsm.h
> @@ -16,7 +16,9 @@
>   #define __XSM_H__
>   
>   #include <xen/sched.h>
> -#include <xen/multiboot.h>
> +#ifndef CONFIG_ARM /* TODO - disabled until implemented on ARM */
> +#include <asm/boot_info.h>
> +#endif
>   
>   typedef void xsm_op_t;
>   DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
> @@ -671,11 +673,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 +697,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 )
>           {

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

* Re: [PATCH for-xen-4.5 v4 14/18] x86: move MPS, ACPI and SMBIOS data to boot_info
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 14/18] x86: move MPS, ACPI and SMBIOS data " Daniel Kiper
@ 2014-10-17 22:51   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 22:51 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 17/10/2014 15:12, Daniel Kiper wrote:
> 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 77e9d5a..c1a4977 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -23,6 +23,7 @@
>   
>   #include <xen/types.h>
>   #include <xen/cache.h>
> +#include <xen/efi.h>
>   #include <xen/init.h>
>   #include <xen/multiboot.h>
>   
> @@ -47,6 +48,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

I *really* hope CONFIG_ARM is not enabled in the arch/x86 subtree...

>   
>   #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

And here

~Andrew

>   
>   #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 3a74e98..abaebd4 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 99ff93e..4d888ab 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -68,6 +68,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__
>   

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

* Re: [PATCH for-xen-4.5 v4 15/18] x86: move video data to boot_info
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 15/18] x86: move video " Daniel Kiper
@ 2014-10-17 22:55   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 22:55 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 17/10/2014 15:12, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

After adjusting for previously-expressed issues,

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.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 c1a4977..5f990e1 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -33,11 +33,46 @@
>   #include <asm/page.h>
>   #include <asm/setup.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,
> @@ -52,6 +87,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);
> +}
> +
>   boot_info_t __init *__init_boot_info(u32 mbd_pa)
>   {
>       mbd_t *mbd = __va(mbd_pa);
> @@ -155,6 +231,8 @@ boot_info_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 d8b30c1..8ee3e93 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 6417419..05f9e93 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;
> @@ -592,8 +522,6 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
>        * 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)) );
> @@ -621,20 +549,20 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
>       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");
> @@ -642,15 +570,15 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
>       }
>   
>       /* 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 abaebd4..6212bed 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 4d888ab..97f8a3b 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -20,6 +20,7 @@
>   #define __BOOT_INFO_H__
>   
>   #include <xen/types.h>
> +#include <xen/video.h>
>   
>   #include <asm/e820.h>
>   #include <asm/mbd.h>
> @@ -80,6 +81,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 */

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

* Re: [PATCH for-xen-4.5 v4 16/18] x86: move HDD data to boot_info
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 16/18] x86: move HDD " Daniel Kiper
@ 2014-10-17 22:57   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 22:57 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 17/10/2014 15:12, Daniel Kiper wrote:
> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>

After adjusting for previously-expressed issues,

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.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              |    6 ++----
>   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(+), 28 deletions(-)
>
> diff --git a/xen/arch/x86/boot_info.c b/xen/arch/x86/boot_info.c
> index 5f990e1..65f9379 100644
> --- a/xen/arch/x86/boot_info.c
> +++ b/xen/arch/x86/boot_info.c
> @@ -73,6 +73,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,
> @@ -90,6 +96,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 @@ boot_info_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 8ee3e93..3311e77 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 05f9e93..6abb61a 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -591,10 +591,8 @@ void __init noreturn __start_xen(boot_info_t *boot_info_ptr)
>       }
>   
>       printk("Disc information:\n");
> -    printk(" Found %d MBR signatures\n",
> -           bootsym(boot_mbr_signature_nr));
> -    printk(" Found %d EDD information structures\n",
> -           bootsym(boot_edd_info_nr));
> +    printk(" Found %d MBR signatures\n", boot_info->mbr_signature_nr);
> +    printk(" Found %d EDD information structures\n", 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 6212bed..b67c731 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 97f8a3b..a495522 100644
> --- a/xen/include/asm-x86/boot_info.h
> +++ b/xen/include/asm-x86/boot_info.h
> @@ -23,6 +23,7 @@
>   #include <xen/video.h>
>   
>   #include <asm/e820.h>
> +#include <asm/edd.h>
>   #include <asm/mbd.h>
>   
>   /*
> @@ -88,6 +89,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. */

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

* Re: [PATCH for-xen-4.5 v4 18/18] xen/x86: add multiboot2 protocol support
  2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 18/18] xen/x86: add multiboot2 protocol support Daniel Kiper
@ 2014-10-17 23:13   ` Andrew Cooper
  0 siblings, 0 replies; 61+ messages in thread
From: Andrew Cooper @ 2014-10-17 23:13 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 17/10/2014 15:12, 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>
> ---
> v4 - suggestions/fixes:
>     - use macro to get multiboot2 data
>       (suggested by Jan Beulich),
>     - use named constant in assembly files
>       (suggested by Andrew Cooper),
>     - rearrange condition for multiboot protocol version
>       detection; fallback to multiboot(1) if protocol
>       is unknown
>       (suggested by Andrew Cooper),
>     - improve multiboot2 header comment in head.S
>       (suggested by Jan Beulich).
>
> 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/Makefile        |    3 +-
>   xen/arch/x86/boot/head.S          |  132 ++++++++++++++++++++++++++++++--
>   xen/arch/x86/boot/reloc.c         |  119 ++++++++++++++++++++++++++++-
>   xen/arch/x86/x86_64/asm-offsets.c |    6 ++
>   xen/include/xen/multiboot2.h      |  153 +++++++++++++++++++++++++++++++++++++
>   5 files changed, 401 insertions(+), 12 deletions(-)
>   create mode 100644 xen/include/xen/multiboot2.h
>
> diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
> index e6ff2b7..031a758 100644
> --- a/xen/arch/x86/boot/Makefile
> +++ b/xen/arch/x86/boot/Makefile
> @@ -1,7 +1,8 @@
>   obj-bin-y += head.o
>   
>   RELOC_DEPS = $(BASEDIR)/include/asm-x86/config.h $(BASEDIR)/include/xen/compiler.h \
> -	     $(BASEDIR)/include/xen/multiboot.h $(BASEDIR)/include/asm-x86/mbd.h
> +	     $(BASEDIR)/include/xen/multiboot.h $(BASEDIR)/include/xen/multiboot2.h \
> +	     $(BASEDIR)/include/asm-x86/mbd.h
>   
>   export RELOC_DEPS
>   
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index 12e41f9..e9a5955 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,82 @@ 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!
> +         *
> +         * Earlier versions of GRUB2 incorrectly calculate Multiboot2 information
> +         * request tag size and read past the end of it 8 bytes. It means that
> +         * these 8 bytes must contain something valid in terms of request tag.
> +         * Fortunately next tag has MULTIBOOT2_TAG_TYPE_MMAP meaning as a request
> +         * and as is it does not change anything in our request because we asked
> +         * for that thing above. However, if request tag ends at unaligned address
> +         * and .align is used then compiler may put random value in void before
> +         * first tag. This could not be accepted by earlier versions of GRUB2 and
> +         * Xen load would fail. So, use .balignl and forcibly fill this void with
> +         * something valid in terms of request tag. However, this thing should not
> +         * change our request in significant way. MULTIBOOT2_TAG_TYPE_END satisfies
> +         * these assumptions because GRUB2 must provide ending tag for list of
> +         * arguments even if it was not explicitly requested.
> +         */
> +        .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 +158,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     MBI_mem_lower(%ebx),%edx
> +        jmp     trampoline_setup
> +
> +multiboot2_proto:
> +        /* Get Multiboot2 information address */
> +        mov     %ebx,%ecx
> +
> +        /* Skip Multiboot2 information fixed part */
> +        add     $MBI2_fixed_sizeof,%ecx
> +
> +0:
> +        /* Get mem_lower from Multiboot2 information */
> +        cmpl    $MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO,(%ecx)
> +        jne     1f
> +
> +        mov     MBI2_mem_lower(%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     MBI2_tag_size(%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 +220,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     MBI_mem_lower(%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 +234,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    %eax                /* Multiboot magic */
>           push    %ebx                /* Multiboot information address */
> -        call    reloc               /* %eax contains trampoline 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 9792fcd..4984b00 100644
> --- a/xen/arch/x86/boot/reloc.c
> +++ b/xen/arch/x86/boot/reloc.c
> @@ -5,19 +5,26 @@
>    * and modules. This is most easily done early with paging disabled.
>    *
>    * Copyright (c) 2009, Citrix Systems, Inc.
> + * Copyright (c) 2013, 2014 Oracle Corp.
>    *
>    * Authors:
>    *    Keir Fraser <keir@xen.org>
> + *    Daniel Kiper
>    */
>   
> -/* entered with %eax = BOOT_TRAMPOLINE */
> +/*
> + * 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"
>       );
>   
> @@ -31,12 +38,19 @@ asm (
>       );
>   
>   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"
>   
> +#define ALIGN_UP(addr, align) \
> +                (((addr) + (typeof(addr))(align) - 1) & ~((typeof(addr))(align) - 1))
> +
> +#define get_mb2_data(tag, type, member) (((type *)(tag))->member)

All the mb2 tag types have a common .type and .size field at the head.  
You should make a struct with a union in it (similar to a domctl/sysctl) 
and avoid all this type punning.

> +
>   static u32 alloc_struct(u32 bytes)
>   {
>       u32 s;
> @@ -127,12 +141,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(multiboot2_fixed_t);
> +
> +    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(multiboot2_fixed_t);
> +
> +    for ( ; ; )
> +    {
> +        switch ( tag->type )
> +        {
> +        case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME:
> +            ptr = (u32)get_mb2_data(tag, multiboot2_tag_string_t, string);
> +            mbd->boot_loader_name = copy_string(ptr);
> +            break;
> +
> +        case MULTIBOOT2_TAG_TYPE_CMDLINE:
> +            ptr = (u32)get_mb2_data(tag, multiboot2_tag_string_t, string);
> +            mbd->cmdline = copy_string(ptr);
> +            break;
> +
> +        case MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO:
> +            mbd->mem_lower = get_mb2_data(tag, multiboot2_tag_basic_meminfo_t, mem_lower);
> +            mbd->mem_upper = get_mb2_data(tag, multiboot2_tag_basic_meminfo_t, mem_upper);
> +            break;
> +
> +        case MULTIBOOT2_TAG_TYPE_MMAP:
> +            mbd->mmap_size = get_mb2_data(tag, multiboot2_tag_mmap_t, size);
> +            mbd->mmap_size -= sizeof(multiboot2_tag_mmap_t);
> +            mbd->mmap_size += sizeof(((multiboot2_tag_mmap_t){0}).entries);
> +            mbd->mmap_size /= get_mb2_data(tag, multiboot2_tag_mmap_t, entry_size);
> +            mbd->mmap_size *= sizeof(memory_map_t);

Yikes.  (want to see about getting a %= in there for the full set of 
operators?)

Is this

> +
> +            mbd->mmap = alloc_struct(mbd->mmap_size);
> +
> +            mmap_src = get_mb2_data(tag, multiboot2_tag_mmap_t, 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 = get_mb2_data(tag, multiboot2_tag_module_t, mod_start);
> +            mbd_mods[mod_idx].end = get_mb2_data(tag, multiboot2_tag_module_t, mod_end);
> +            ptr = (u32)get_mb2_data(tag, multiboot2_tag_module_t, 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));
>       zero_struct((u32)mbd, sizeof(*mbd));
>   
> -    return mb_mbd(mbd, mbi);
> +    if ( mb_magic == MULTIBOOT2_BOOTLOADER_MAGIC )
> +        return mb2_mbd(mbd, mbi);
> +    else
> +        return mb_mbd(mbd, mbi);
>   }
> diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
> index 7364dd6..ac4ce93 100644
> --- a/xen/arch/x86/x86_64/asm-offsets.c
> +++ b/xen/arch/x86/x86_64/asm-offsets.c
> @@ -10,6 +10,7 @@
>   #include <xen/sched.h>
>   #include <xen/bitops.h>
>   #include <xen/multiboot.h>
> +#include <xen/multiboot2.h>
>   #include <compat/xen.h>
>   #include <asm/fixmap.h>
>   #include <asm/hardirq.h>
> @@ -167,5 +168,10 @@ void __dummy__(void)
>       OFFSET(MBI_mem_lower, multiboot_info_t, mem_lower);
>       BLANK();
>   
> +    DEFINE(MBI2_fixed_sizeof, sizeof(multiboot2_fixed_t));
> +    OFFSET(MBI2_tag_size, multiboot2_tag_t, size);
> +    OFFSET(MBI2_mem_lower, multiboot2_tag_basic_meminfo_t, mem_lower);
> +    BLANK();
> +
>       OFFSET(MBD_cmdline, mbd_t, cmdline);
>   }
> diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h
> new file mode 100644
> index 0000000..95eaa76
> --- /dev/null
> +++ b/xen/include/xen/multiboot2.h
> @@ -0,0 +1,153 @@
> +/*
> + *  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 total_size;
> +    u32 reserved;
> +} multiboot2_fixed_t;
> +
> +typedef struct {
> +    u32 type;
> +    u32 size;
> +} multiboot2_tag_t;
> +
> +typedef struct {
> +    u32 type;
> +    u32 size;
> +    char string[0];
> +} multiboot2_tag_string_t;
> +

Which version of the spec are you using?  Can you put a URL somewhere in 
a comment in the source code, probably at the top of this file?

The first mb2 spec I can find on google specifies a common tag header as 
u16 type, u16 flags, u32 size, which is different to these structs here.

~Andrew

> +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] 61+ messages in thread

* Re: [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value
  2014-10-17 16:22         ` Daniel Kiper
@ 2014-10-20  8:00           ` Jan Beulich
  0 siblings, 0 replies; 61+ messages in thread
From: Jan Beulich @ 2014-10-20  8:00 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 17.10.14 at 18:22, <daniel.kiper@oracle.com> wrote:
> OK, please tell me which one from this series you want in 4.5 and
> I will repost all of them with relevant fixes at the beginning
> of next week.

1...4 I see as possible things to still go in.

Jan

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

* Re: [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi
  2014-10-17 22:35   ` Andrew Cooper
@ 2014-10-20  8:38     ` Jan Beulich
  0 siblings, 0 replies; 61+ messages in thread
From: Jan Beulich @ 2014-10-20  8:38 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 18.10.14 at 00:35, <andrew.cooper3@citrix.com> wrote:
> On 17/10/2014 15:12, Daniel Kiper wrote:
>> @@ -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;
> 
> end is surely start + size (give or take a fencepost) ?  How did the 
> pre-existing code work?

You should look at pre-existing code first: setup.c, following the
"Iterate backwards over all superpage-aligned RAM regions"
comment, has

    for ( i = 0; !efi_enabled && i < mbi->mods_count; i++ )
    {
        if ( mod[i].mod_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;
    }

i.e. mod_start after this point no longer holds a byte address, and
mod_end now holds only the size. The EFI code leverages this to
make sure addresses beyond 4Gb can be expressed (which can't
be in multiboot).

>> @@ -723,16 +720,15 @@ void __init noreturn __start_xen(unsigned long mbi_p, boot_info_t *boot_info_ptr
>>        * 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);
> 
> The old code was playing a little fast-and-loose with pointers vs arrays.
> 
> Please convert to the more-appropriate mods[0] as you are transforming 
> the code anyway, which helps highlight the bzimage_headroom() check 
> applies to the dom0 kernel only.

I disagree - arrays getting converted to pointers anyway when used
in expressions makes it rather pointless to use [0], being more code
to type, read, and parse, and hence making things (even if only
slightly) less legible.

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-17 15:49   ` Daniel Kiper
@ 2014-10-23 10:19     ` Jan Beulich
  2014-10-23 11:08       ` Andrew Cooper
  2014-10-23 11:14       ` Stefano Stabellini
  0 siblings, 2 replies; 61+ messages in thread
From: Jan Beulich @ 2014-10-23 10:19 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 17.10.14 at 17:49, <daniel.kiper@oracle.com> wrote:
> What is your main concern here (beside that it is big patch series)?

The size alone is not the reason. As already said, I'm not convinced
that the approach you use is ultimately the right one (and Andrew
seems to agree, at least to some degree). And then, looking at your
track record, apart from some kexec (and even older tool stack)
work there hasn't been much you've been doing earlier particularly
with the kind of fragile initial boot code. Hence I think the only
viable route for you to get MB2 code merged is to just add it
_without_ largely re-writing all sorts of other code. Once that
happened we can then go and see whether the consolidation you're
thinking of is (a) the right approach and (b) you're the one to carry
it out.

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 10:19     ` Jan Beulich
@ 2014-10-23 11:08       ` Andrew Cooper
  2014-10-23 14:57         ` Daniel Kiper
  2014-10-23 11:14       ` Stefano Stabellini
  1 sibling, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-23 11:08 UTC (permalink / raw)
  To: Jan Beulich, Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini, roy.franz,
	ning.sun, ross.philipson, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On 23/10/14 11:19, Jan Beulich wrote:
>>>> On 17.10.14 at 17:49, <daniel.kiper@oracle.com> wrote:
>> What is your main concern here (beside that it is big patch series)?
> The size alone is not the reason. As already said, I'm not convinced
> that the approach you use is ultimately the right one (and Andrew
> seems to agree, at least to some degree). And then, looking at your
> track record, apart from some kexec (and even older tool stack)
> work there hasn't been much you've been doing earlier particularly
> with the kind of fragile initial boot code. Hence I think the only
> viable route for you to get MB2 code merged is to just add it
> _without_ largely re-writing all sorts of other code. Once that
> happened we can then go and see whether the consolidation you're
> thinking of is (a) the right approach and (b) you're the one to carry
> it out.
>
> Jan
>

To add to this a little.  I still can't see a reasonable justification
for the new "multiboot data" type.  I think it would be perfectly
reasonable keep the multiboot1/2 distinction up until the boot_info
stage, and cast the pointer based on multiboot magic.

This would vastly reduce the changes in the boot assembly.

~Andrew

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 10:19     ` Jan Beulich
  2014-10-23 11:08       ` Andrew Cooper
@ 2014-10-23 11:14       ` Stefano Stabellini
  2014-10-23 11:33         ` Jan Beulich
  1 sibling, 1 reply; 61+ messages in thread
From: Stefano Stabellini @ 2014-10-23 11:14 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	andrew.cooper3, Daniel Kiper, roy.franz, ning.sun,
	ross.philipson, xen-devel, qiaowei.ren, richard.l.maliszewski,
	gang.wei, fu.wei

On Thu, 23 Oct 2014, Jan Beulich wrote:
> >>> On 17.10.14 at 17:49, <daniel.kiper@oracle.com> wrote:
> > What is your main concern here (beside that it is big patch series)?

Let me premise that I agree with Jan on the fact that such a delicate
and sizeable set of changes shouldn't go in at this stage.


> The size alone is not the reason. As already said, I'm not convinced
> that the approach you use is ultimately the right one (and Andrew
> seems to agree, at least to some degree). And then, looking at your
> track record, apart from some kexec (and even older tool stack)
> work there hasn't been much you've been doing earlier particularly
> with the kind of fragile initial boot code.

I am sorry Jan, but no track record is required to make a good
contribution, no matter the code it touches. It has never been the case
and I hope that it will never be.

The fact that such a change is not well suited for 4.5 is another story.

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

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

>>> On 23.10.14 at 13:14, <stefano.stabellini@eu.citrix.com> wrote:
> On Thu, 23 Oct 2014, Jan Beulich wrote:
>> The size alone is not the reason. As already said, I'm not convinced
>> that the approach you use is ultimately the right one (and Andrew
>> seems to agree, at least to some degree). And then, looking at your
>> track record, apart from some kexec (and even older tool stack)
>> work there hasn't been much you've been doing earlier particularly
>> with the kind of fragile initial boot code.
> 
> I am sorry Jan, but no track record is required to make a good
> contribution, no matter the code it touches. It has never been the case
> and I hope that it will never be.

And I didn't say it's required (otherwise I wouldn't have, in that
same reply, suggested that a simpler form of what is wanted is
likely going to be fine). But it helps acceptance, especially when
(partly) hard to review things are being proposed.

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 11:08       ` Andrew Cooper
@ 2014-10-23 14:57         ` Daniel Kiper
  2014-10-23 15:26           ` Jan Beulich
  2014-10-23 15:55           ` Andrew Cooper
  0 siblings, 2 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-23 14:57 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, Jan Beulich, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On Thu, Oct 23, 2014 at 12:08:32PM +0100, Andrew Cooper wrote:
> On 23/10/14 11:19, Jan Beulich wrote:
> >>>> On 17.10.14 at 17:49, <daniel.kiper@oracle.com> wrote:
> >> What is your main concern here (beside that it is big patch series)?
> > The size alone is not the reason. As already said, I'm not convinced
> > that the approach you use is ultimately the right one (and Andrew
> > seems to agree, at least to some degree). And then, looking at your
> > track record, apart from some kexec (and even older tool stack)
> > work there hasn't been much you've been doing earlier particularly
> > with the kind of fragile initial boot code. Hence I think the only
> > viable route for you to get MB2 code merged is to just add it
> > _without_ largely re-writing all sorts of other code. Once that
> > happened we can then go and see whether the consolidation you're
> > thinking of is (a) the right approach and (b) you're the one to carry
> > it out.
> >
> > Jan
> >
>
> To add to this a little.  I still can't see a reasonable justification
> for the new "multiboot data" type.  I think it would be perfectly
> reasonable keep the multiboot1/2 distinction up until the boot_info
> stage, and cast the pointer based on multiboot magic.

multiboot1 and multiboot2 are completely different things. If we do what
you suggest then at least we will be forced to complicate assembly code
parsing cmdline in xen/arch/x86/boot/cmdline.S. We could also stay with
multiboot1 stuff but then we will be forced to put all stuff which we are
able to put in multiboot1. However, we are not able to put at least EFI_HANDLE
and EFI_SYSTEM_TABLE from multiboot2 (which are a must on EFI; maybe we
want other data from multiboot2 protocol too) in multiboot1 struct because
there is not designed place for that. It means that we must add another
global variables which will appear from nowhere in Xen code (as usual
in case of global variables).

I understand that gains are not clearly visible at this stage of development
because there is lack of relevant multiboot2 + EFI code on top of this patches.
However, I hope that above explanation and earlier ones will clear some
of your doubts.

Guys, if you wish I can do what Jan suggest. However, personally I think
that it will complicate things more which are already complicated enough.
I can understand that Xen was tied to multiboot1 protocol at early stage of
development. Even I am able to understand that this thing was not changed
during introduction of EFI code. However, I think that right know, when we
introduce third boot protocol, mutliboot2, there is not longer any excuse to
have it build in early and in main Xen code especially. So, IMO we should
do all cleanups and fixes first and then put all multiboot2 + EFI stuff
on top of it. If we reverse the order then I do not believe that cleanup
will be done in foreseeable future.

Daniel

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 14:57         ` Daniel Kiper
@ 2014-10-23 15:26           ` Jan Beulich
  2014-10-23 15:50             ` Daniel Kiper
  2014-10-23 15:55           ` Andrew Cooper
  1 sibling, 1 reply; 61+ messages in thread
From: Jan Beulich @ 2014-10-23 15:26 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 23.10.14 at 16:57, <daniel.kiper@oracle.com> wrote:
> multiboot1 and multiboot2 are completely different things. If we do what
> you suggest then at least we will be forced to complicate assembly code
> parsing cmdline in xen/arch/x86/boot/cmdline.S. We could also stay with
> multiboot1 stuff but then we will be forced to put all stuff which we are
> able to put in multiboot1. However, we are not able to put at least 
> EFI_HANDLE
> and EFI_SYSTEM_TABLE from multiboot2 (which are a must on EFI; maybe we
> want other data from multiboot2 protocol too) in multiboot1 struct because
> there is not designed place for that. It means that we must add another
> global variables which will appear from nowhere in Xen code (as usual
> in case of global variables).

There's nothing wrong with adding global variables, even less so
when they're __initdata.

> I understand that gains are not clearly visible at this stage of development
> because there is lack of relevant multiboot2 + EFI code on top of this 
> patches.
> However, I hope that above explanation and earlier ones will clear some
> of your doubts.
> 
> Guys, if you wish I can do what Jan suggest. However, personally I think
> that it will complicate things more which are already complicated enough.
> I can understand that Xen was tied to multiboot1 protocol at early stage of
> development. Even I am able to understand that this thing was not changed
> during introduction of EFI code. However, I think that right know, when we
> introduce third boot protocol, mutliboot2, there is not longer any excuse to
> have it build in early and in main Xen code especially. So, IMO we should
> do all cleanups and fixes first and then put all multiboot2 + EFI stuff
> on top of it. If we reverse the order then I do not believe that cleanup
> will be done in foreseeable future.

Repeating the same arguments over and over won't make them any
better. And if MB1, MB2, and EFI are (reasonably) separate rather than
all intermixed, maybe that's going to be the more maintainable state in
the end anyway? We just can't tell without the MB2 pieces (separately)
in place yet.

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 15:26           ` Jan Beulich
@ 2014-10-23 15:50             ` Daniel Kiper
  2014-10-23 16:04               ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: Daniel Kiper @ 2014-10-23 15:50 UTC (permalink / raw)
  To: Jan Beulich
  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 Thu, Oct 23, 2014 at 04:26:22PM +0100, Jan Beulich wrote:
> >>> On 23.10.14 at 16:57, <daniel.kiper@oracle.com> wrote:
> > multiboot1 and multiboot2 are completely different things. If we do what
> > you suggest then at least we will be forced to complicate assembly code
> > parsing cmdline in xen/arch/x86/boot/cmdline.S. We could also stay with
> > multiboot1 stuff but then we will be forced to put all stuff which we are
> > able to put in multiboot1. However, we are not able to put at least
> > EFI_HANDLE
> > and EFI_SYSTEM_TABLE from multiboot2 (which are a must on EFI; maybe we
> > want other data from multiboot2 protocol too) in multiboot1 struct because
> > there is not designed place for that. It means that we must add another
> > global variables which will appear from nowhere in Xen code (as usual
> > in case of global variables).
>
> There's nothing wrong with adding global variables, even less so
> when they're __initdata.
>
> > I understand that gains are not clearly visible at this stage of development
> > because there is lack of relevant multiboot2 + EFI code on top of this
> > patches.
> > However, I hope that above explanation and earlier ones will clear some
> > of your doubts.
> >
> > Guys, if you wish I can do what Jan suggest. However, personally I think
> > that it will complicate things more which are already complicated enough.
> > I can understand that Xen was tied to multiboot1 protocol at early stage of
> > development. Even I am able to understand that this thing was not changed
> > during introduction of EFI code. However, I think that right know, when we
> > introduce third boot protocol, mutliboot2, there is not longer any excuse to
> > have it build in early and in main Xen code especially. So, IMO we should
> > do all cleanups and fixes first and then put all multiboot2 + EFI stuff
> > on top of it. If we reverse the order then I do not believe that cleanup
> > will be done in foreseeable future.
>
> Repeating the same arguments over and over won't make them any
> better. And if MB1, MB2, and EFI are (reasonably) separate rather than
> all intermixed, maybe that's going to be the more maintainable state in
> the end anyway? We just can't tell without the MB2 pieces (separately)
> in place yet.

OK, AIUI you suggest that I should parse all multiboot2 data in reloc.c
and put all things in multiboot1 struct which lives on trampoline. Then
I should add global variables for EFI_HANDLE and EFI_SYSTEM_TABLE somewhere
in x86_64.S and initialize them from reloc.c. After that I should call
efi_start() immediately after reloc() if Xen runs on EFI platform.
Am I right?

Daniel

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 14:57         ` Daniel Kiper
  2014-10-23 15:26           ` Jan Beulich
@ 2014-10-23 15:55           ` Andrew Cooper
  2014-10-23 18:04             ` konrad wilk
  1 sibling, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-23 15:55 UTC (permalink / raw)
  To: Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, Jan Beulich, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On 23/10/14 15:57, Daniel Kiper wrote:
> On Thu, Oct 23, 2014 at 12:08:32PM +0100, Andrew Cooper wrote:
>> On 23/10/14 11:19, Jan Beulich wrote:
>>>>>> On 17.10.14 at 17:49, <daniel.kiper@oracle.com> wrote:
>>>> What is your main concern here (beside that it is big patch series)?
>>> The size alone is not the reason. As already said, I'm not convinced
>>> that the approach you use is ultimately the right one (and Andrew
>>> seems to agree, at least to some degree). And then, looking at your
>>> track record, apart from some kexec (and even older tool stack)
>>> work there hasn't been much you've been doing earlier particularly
>>> with the kind of fragile initial boot code. Hence I think the only
>>> viable route for you to get MB2 code merged is to just add it
>>> _without_ largely re-writing all sorts of other code. Once that
>>> happened we can then go and see whether the consolidation you're
>>> thinking of is (a) the right approach and (b) you're the one to carry
>>> it out.
>>>
>>> Jan
>>>
>> To add to this a little.  I still can't see a reasonable justification
>> for the new "multiboot data" type.  I think it would be perfectly
>> reasonable keep the multiboot1/2 distinction up until the boot_info
>> stage, and cast the pointer based on multiboot magic.

Answering out-of-order:


> I understand that gains are not clearly visible at this stage of development
> because there is lack of relevant multiboot2 + EFI code on top of this patches.

This is entirely the problem.  Acceptance of big changes like this are
first and formost based on the benefits of the changes.

For a change like this, the benefits should be completely obvious to the
reviewers, and this is not the case.  At this point, there are large
numbers of changes all over the boot code.  You have asserted that they
cause an improvement, but have not succeeded is persuading either Jan or
myself.

This is not to say that there are not good reasons, but they are not
obvious.  Furthermore, they have remained not obvious all the way
through review.

> multiboot1 and multiboot2 are completely different things. If we do what
> you suggest then at least we will be forced to complicate assembly code
> parsing cmdline in xen/arch/x86/boot/cmdline.S.

This is a good reason, but it shouldn't become apparent from an email
thread like this.  It should ideally be in the design document
accompanying the series.

> We could also stay with
> multiboot1 stuff but then we will be forced to put all stuff which we are
> able to put in multiboot1. However, we are not able to put at least EFI_HANDLE
> and EFI_SYSTEM_TABLE from multiboot2 (which are a must on EFI; maybe we
> want other data from multiboot2 protocol too) in multiboot1 struct because
> there is not designed place for that. It means that we must add another
> global variables which will appear from nowhere in Xen code (as usual
> in case of global variables).

Globals are fine.

>
> Guys, if you wish I can do what Jan suggest. However, personally I think
> that it will complicate things more which are already complicated enough.
> I can understand that Xen was tied to multiboot1 protocol at early stage of
> development. Even I am able to understand that this thing was not changed
> during introduction of EFI code. However, I think that right know, when we
> introduce third boot protocol, mutliboot2, there is not longer any excuse to
> have it build in early and in main Xen code especially. So, IMO we should
> do all cleanups and fixes first and then put all multiboot2 + EFI stuff
> on top of it. If we reverse the order then I do not believe that cleanup
> will be done in foreseeable future.

One deep problem is that the series is trying to do two independent at
the same time, both in the same area of code.

On the one hand, you have "support multiboot2", whose end goal is
obvious and unquestionably a good thing.  On the other hand, you have
"unify all boot paths", and are using it as a prerequisite to "support
multiboot2" when it really is not a prerequisite.

Furthermore, there is still an open question of whether "unify all boot
paths" is indeed a clever idea in the first place.  Again, this is
ideally something which should have been argued over / decided upon as
part of the design review.  (People on the list might notice a
reoccurring theme there, when it comes to doing large chunks of work.)

If you were to cut the problem in half and just do the multiboot2
support, I suspect you would find it much easier to get the multiboot2
series accepted.  At that point, with the code in-tree, you are in a far
better position to make an argument for unifying the boot paths.

~Andrew

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 15:50             ` Daniel Kiper
@ 2014-10-23 16:04               ` Jan Beulich
  2014-10-23 17:55                 ` konrad wilk
  0 siblings, 1 reply; 61+ messages in thread
From: Jan Beulich @ 2014-10-23 16:04 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 23.10.14 at 17:50, <daniel.kiper@oracle.com> wrote:
> OK, AIUI you suggest that I should parse all multiboot2 data in reloc.c
> and put all things in multiboot1 struct which lives on trampoline. Then
> I should add global variables for EFI_HANDLE and EFI_SYSTEM_TABLE somewhere
> in x86_64.S and initialize them from reloc.c. After that I should call
> efi_start() immediately after reloc() if Xen runs on EFI platform.

I wouldn't call this "parse", but beyond that it sounds roughly right.
Whether you need global variables or can find some other
mechanism to propagate the EFI specific things is secondary.

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 16:04               ` Jan Beulich
@ 2014-10-23 17:55                 ` konrad wilk
  2014-10-24  9:09                   ` Jan Beulich
  0 siblings, 1 reply; 61+ messages in thread
From: konrad wilk @ 2014-10-23 17:55 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	Andrew Cooper, Daniel Kiper, roy.franz, ning.sun, ross.philipson,
	xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On 10/23/2014 12:04 PM, Jan Beulich wrote:
>>>> On 23.10.14 at 17:50, <daniel.kiper@oracle.com> wrote:
>> OK, AIUI you suggest that I should parse all multiboot2 data in reloc.c
>> and put all things in multiboot1 struct which lives on trampoline. Then
>> I should add global variables for EFI_HANDLE and EFI_SYSTEM_TABLE somewhere
>> in x86_64.S and initialize them from reloc.c. After that I should call
>> efi_start() immediately after reloc() if Xen runs on EFI platform.
>
> I wouldn't call this "parse", but beyond that it sounds roughly right.
> Whether you need global variables or can find some other
> mechanism to propagate the EFI specific things is secondary.

This seems to lead to more spaghetti code - why not make it a more nice 
mechanism right away? Is that because you want to have this in a 
separate "bin" in case it has bugs and won't influence the rest of the code?

And then later if it all works then integrate and cleanup? Or skip that 
altogether?

>
> Jan
>

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 15:55           ` Andrew Cooper
@ 2014-10-23 18:04             ` konrad wilk
  2014-10-23 21:55               ` Andrew Cooper
  0 siblings, 1 reply; 61+ messages in thread
From: konrad wilk @ 2014-10-23 18:04 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	Daniel Kiper, ross.philipson, roy.franz, ning.sun, Jan Beulich,
	xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei


> Furthermore, there is still an open question of whether "unify all boot
> paths" is indeed a clever idea in the first place.  Again, this is
> ideally something which should have been argued over / decided upon as
> part of the design review.  (People on the list might notice a
> reoccurring theme there, when it comes to doing large chunks of work.)
>

And it _was_ discussed at the Xen hackathon multiple times - where it 
seems it was the perfect place to hash this out.

Or are we saying that any big project in Xen MUST have a design document 
with it? If so we really need to document that somewhere.

This is frustrating.

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 18:04             ` konrad wilk
@ 2014-10-23 21:55               ` Andrew Cooper
  2014-10-24  7:07                 ` Daniel Kiper
  0 siblings, 1 reply; 61+ messages in thread
From: Andrew Cooper @ 2014-10-23 21:55 UTC (permalink / raw)
  To: konrad wilk, Daniel Kiper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	ross.philipson, roy.franz, ning.sun, Jan Beulich, xen-devel,
	qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

On 23/10/2014 19:04, konrad wilk wrote:
>
>> Furthermore, there is still an open question of whether "unify all boot
>> paths" is indeed a clever idea in the first place.  Again, this is
>> ideally something which should have been argued over / decided upon as
>> part of the design review.  (People on the list might notice a
>> reoccurring theme there, when it comes to doing large chunks of work.)
>>
>
> And it _was_ discussed at the Xen hackathon multiple times - where it
> seems it was the perfect place to hash this out.

The majority of the hackathon revolved around what was needed to get EFI
multiboot2 to work.  At the time, there were no patches (if I recall
correctly), and most of the discussion was around what functionality we
needed out of grub to make it work nicely, and what Linux did for EFI
booting.

>
> Or are we saying that any big project in Xen MUST have a design
> document with it? If so we really need to document that somewhere.

I am not in a position to insist on anything.

I have, however, found design documents to be very useful starting
points to get appropriate architectural input from interested parties,
as well as getting agreement in principle for how to proceed.

I will certainly be submitting design documents for any major work I do,
and I hope others will follow suit.

>
> This is frustrating.

I agree.  With my XenServer hat on, we would love multiboot2 support in
Xen 4.5.

However, just throwing patches in would be completely remiss of the
maintainers.  This critical feedback is nothing personal; it reflects
the fact that, in my opinion, the patch series is not of a sufficient
quality to be accepted.  (Note that of the patches are Reviewed-by me,
which I consider to be good quality.)  The flip side of all of this is
that I expect the community to hold me and my patches to the same high
standards; after all, it is Xen which benefits as a result.

As I have indicated before, most of my concerns are caused by a lack of
understanding of *why* changes have been made the way they have.  After
the monolithic patch was split into these 18-or-so, the individual
changes became apparent.  This was good, but still doesn't help with the
*why*.

Take as a perfect example the MBD structure.  It took until this
argument thread for me to understand why it was a good idea in the
context of supporting multiboot1 and multiboot2.  Now that I understand
why, I consider it a good idea.  The problem is that the *why* should be
clearly explained in the patch commit message, (and possibly even in
brief beside the relevant code).  It should not take an argument of this
magnitude to gain a basic understanding of the reasoning behind the changes.

The underlying issue here is that the patch series is trying to do two
completely orthogonal things at once.

Supporting multiboot2 necessarily involves playing with the boot
assembly code, which very likely involves untangling the multiboot1-isms
while doing so.

Unifying the boot paths is completely independent, albeit related.  I
will agree that, in principle, swapping a rats nest of random global
variables for a dedicated collection is a good thing.  Even more so as
it allows the use of more common code on legacy and efi boot paths. 
Implementing this is purely an exercise in shuffling.

The problem is that still, these two end goals are mixed all the way
through this series.  It has taken me until this iteration to work out
that the two goals were completely orthogonal.  Again, this is down to
my lack of understanding of why the changes have been made in the way
they have, which is a fault of the quality of explanation presented with
the series.


To summarise,

I am not against either of the changes per se, but do still have
unresolved issues which give me concerns against the series as a whole,
in its current form.

I highly suggest that multiboot2 is perused independently, (and probably
ahead of) unification.  The first is a new functional piece, while the
second is a massive quantity of cleanup.  These are both good things
independently, but should not be mixed together, especially as they are
causing confusion of each other during review.

I hope I have not ranted for too long, and I hope I am not being
unreasonable (and if you think I am, please call me out on it;  I wont
take it personally)

~Andrew

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 21:55               ` Andrew Cooper
@ 2014-10-24  7:07                 ` Daniel Kiper
  0 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-24  7:07 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini, roy.franz,
	ning.sun, Jan Beulich, ross.philipson, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, fu.wei

On Thu, Oct 23, 2014 at 10:55:29PM +0100, Andrew Cooper wrote:
> On 23/10/2014 19:04, konrad wilk wrote:

[...]

> > This is frustrating.
>
> I agree.  With my XenServer hat on, we would love multiboot2 support in
> Xen 4.5.
>
> However, just throwing patches in would be completely remiss of the
> maintainers.  This critical feedback is nothing personal; it reflects
> the fact that, in my opinion, the patch series is not of a sufficient
> quality to be accepted.  (Note that of the patches are Reviewed-by me,

I have never said that it should be accepted as is or with bugs. I am
trying to workout the best solution which will improve Xen code and
add missing feature. The best possible Xen code quality is my goal too.

> which I consider to be good quality.)  The flip side of all of this is
> that I expect the community to hold me and my patches to the same high
> standards; after all, it is Xen which benefits as a result.
>
> As I have indicated before, most of my concerns are caused by a lack of
> understanding of *why* changes have been made the way they have.  After
> the monolithic patch was split into these 18-or-so, the individual
> changes became apparent.  This was good, but still doesn't help with the
> *why*.

AIUI the problem is not in idea per se but in the lack of good
explanation of it? Am I right?

> Take as a perfect example the MBD structure.  It took until this
> argument thread for me to understand why it was a good idea in the
> context of supporting multiboot1 and multiboot2.  Now that I understand
> why, I consider it a good idea.  The problem is that the *why* should be
> clearly explained in the patch commit message, (and possibly even in
> brief beside the relevant code).  It should not take an argument of this
> magnitude to gain a basic understanding of the reasoning behind the changes.

Taking into account above thing may we consider patches #5 (x86/boot/reloc: create
generic alloc and copy functions), #6 (x86: introduce MultiBoot Data (MBD) type),
#17 (x86/boot: use %ecx instead of %eax) and #18 (xen/x86: add multiboot2 protocol
support) as a base for further EFI + multiboot2 development. If yes then I will
prepare relevant patches on top of them and post all things as whole series (with
relevant comments). When it be merged then we could back to discussion about
further boot_info development. I think this is better solution than one which
I sent you yesterday.

> The underlying issue here is that the patch series is trying to do two
> completely orthogonal things at once.
>
> Supporting multiboot2 necessarily involves playing with the boot
> assembly code, which very likely involves untangling the multiboot1-isms
> while doing so.
>
> Unifying the boot paths is completely independent, albeit related.  I
> will agree that, in principle, swapping a rats nest of random global
> variables for a dedicated collection is a good thing.  Even more so as
> it allows the use of more common code on legacy and efi boot paths.
> Implementing this is purely an exercise in shuffling.

As I can see you caught the plot. Great!

> The problem is that still, these two end goals are mixed all the way
> through this series.  It has taken me until this iteration to work out
> that the two goals were completely orthogonal.  Again, this is down to
> my lack of understanding of why the changes have been made in the way
> they have, which is a fault of the quality of explanation presented with
> the series.

OK.

> To summarise,
>
> I am not against either of the changes per se, but do still have

Great!

> unresolved issues which give me concerns against the series as a whole,
> in its current form.

OK, lat's back to discussion about that after merging EFI + multiboot2 stuff.

> I highly suggest that multiboot2 is perused independently, (and probably
> ahead of) unification.  The first is a new functional piece, while the
> second is a massive quantity of cleanup.  These are both good things
> independently, but should not be mixed together, especially as they are
> causing confusion of each other during review.

OK.

Daniel

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-23 17:55                 ` konrad wilk
@ 2014-10-24  9:09                   ` Jan Beulich
  0 siblings, 0 replies; 61+ messages in thread
From: Jan Beulich @ 2014-10-24  9:09 UTC (permalink / raw)
  To: konrad wilk
  Cc: Juergen Gross, keir, ian.campbell, stefano.stabellini,
	Andrew Cooper, Daniel Kiper, roy.franz, ning.sun, ross.philipson,
	xen-devel, qiaowei.ren, richard.l.maliszewski, gang.wei, fu.wei

>>> On 23.10.14 at 19:55, <konrad.wilk@oracle.com> wrote:
> On 10/23/2014 12:04 PM, Jan Beulich wrote:
>>>>> On 23.10.14 at 17:50, <daniel.kiper@oracle.com> wrote:
>>> OK, AIUI you suggest that I should parse all multiboot2 data in reloc.c
>>> and put all things in multiboot1 struct which lives on trampoline. Then
>>> I should add global variables for EFI_HANDLE and EFI_SYSTEM_TABLE somewhere
>>> in x86_64.S and initialize them from reloc.c. After that I should call
>>> efi_start() immediately after reloc() if Xen runs on EFI platform.
>>
>> I wouldn't call this "parse", but beyond that it sounds roughly right.
>> Whether you need global variables or can find some other
>> mechanism to propagate the EFI specific things is secondary.
> 
> This seems to lead to more spaghetti code - why not make it a more nice 
> mechanism right away? Is that because you want to have this in a 
> separate "bin" in case it has bugs and won't influence the rest of the code?
> 
> And then later if it all works then integrate and cleanup? Or skip that 
> altogether?

Whether and how much cleanup would subsequently be desirable
can only be reasonably told at the point we know/see what is
needed for MB2 support. Right now the re-write looks more to be
for the sake of doing a re-write. Please keep in mind that unified
code paths and data fields aren't always advantageous, as the
sharing can also lead to subtle bugs for one of the handled cases.

Jan

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

* Re: [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support
  2014-10-17 18:02 ` Roy Franz
@ 2014-10-27 11:09   ` Daniel Kiper
  0 siblings, 0 replies; 61+ messages in thread
From: Daniel Kiper @ 2014-10-27 11:09 UTC (permalink / raw)
  To: Roy Franz
  Cc: jgross, keir, Ian Campbell, andrew.cooper3, Stefano Stabellini,
	ross.philipson, ning.sun, Jan Beulich, xen-devel, qiaowei.ren,
	richard.l.maliszewski, gang.wei, Fu Wei

On Fri, Oct 17, 2014 at 11:02:18AM -0700, Roy Franz wrote:
> On Fri, Oct 17, 2014 at 7:11 AM, Daniel Kiper <daniel.kiper@oracle.com> wrote:
> > Hi all,
> >
> > 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.
> >
> > I took into account all suggestions sent to me up until now.
> >
> > ARM build has been tested. However, I am not able to test generated
> > binaries because I do not have a required hardware under my feet.
> > Could you do some tests guys?
>
> This boots to dom0 for me using the FVP arm64 model, and booting
> using EFI. (I don't have a setup for testing non-EFI boot)

Great! Thanks for doing this test.

Daniel

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

end of thread, other threads:[~2014-10-27 11:11 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-17 14:11 [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Daniel Kiper
2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 01/18] xen/makefile: clean target should remove xen.efi binary Daniel Kiper
2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 02/18] x86/boot: fix reloc.S build dependencies Daniel Kiper
2014-10-17 14:51   ` Jan Beulich
2014-10-17 16:10     ` Daniel Kiper
2014-10-17 16:22       ` Jan Beulich
2014-10-17 14:56   ` Andrew Cooper
2014-10-17 15:10     ` Jan Beulich
2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 03/18] x86: define cmdline_cook() loader_name argument as a const Daniel Kiper
2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 04/18] x86/boot: use constant in head.S instead of hardcoded value Daniel Kiper
2014-10-17 15:00   ` Andrew Cooper
2014-10-17 15:52     ` Daniel Kiper
2014-10-17 16:18       ` Jan Beulich
2014-10-17 16:22         ` Daniel Kiper
2014-10-20  8:00           ` Jan Beulich
2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 05/18] x86/boot/reloc: create generic alloc and copy functions Daniel Kiper
2014-10-17 16:04   ` Andrew Cooper
2014-10-17 17:11     ` Daniel Kiper
2014-10-17 17:22       ` Andrew Cooper
2014-10-17 14:11 ` [PATCH for-xen-4.5 v4 06/18] x86: introduce MultiBoot Data (MBD) type Daniel Kiper
2014-10-17 17:14   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 07/18] x86/efi: add place_string_u32() function Daniel Kiper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 08/18] x86: introduce boot_info structure Daniel Kiper
2014-10-17 20:55   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 09/18] x86: move boot_loader_name from mbi to boot_info Daniel Kiper
2014-10-17 21:05   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 10/18] x86: move cmdline " Daniel Kiper
2014-10-17 21:27   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 11/18] x86: move legacy BIOS memory map stuff " Daniel Kiper
2014-10-17 22:08   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 12/18] x86: move modules data from mbi to boot_info and remove mbi Daniel Kiper
2014-10-17 22:35   ` Andrew Cooper
2014-10-20  8:38     ` Jan Beulich
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 13/18] x86: move EFI memory map stuff to boot_info Daniel Kiper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 14/18] x86: move MPS, ACPI and SMBIOS data " Daniel Kiper
2014-10-17 22:51   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 15/18] x86: move video " Daniel Kiper
2014-10-17 22:55   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 16/18] x86: move HDD " Daniel Kiper
2014-10-17 22:57   ` Andrew Cooper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 17/18] x86/boot: use %ecx instead of %eax Daniel Kiper
2014-10-17 14:12 ` [PATCH for-xen-4.5 v4 18/18] xen/x86: add multiboot2 protocol support Daniel Kiper
2014-10-17 23:13   ` Andrew Cooper
2014-10-17 14:42 ` [PATCH for-xen-4.5 v4 00/18] xen: Break multiboot (v1) dependency and add multiboot2 support Jan Beulich
2014-10-17 15:49   ` Daniel Kiper
2014-10-23 10:19     ` Jan Beulich
2014-10-23 11:08       ` Andrew Cooper
2014-10-23 14:57         ` Daniel Kiper
2014-10-23 15:26           ` Jan Beulich
2014-10-23 15:50             ` Daniel Kiper
2014-10-23 16:04               ` Jan Beulich
2014-10-23 17:55                 ` konrad wilk
2014-10-24  9:09                   ` Jan Beulich
2014-10-23 15:55           ` Andrew Cooper
2014-10-23 18:04             ` konrad wilk
2014-10-23 21:55               ` Andrew Cooper
2014-10-24  7:07                 ` Daniel Kiper
2014-10-23 11:14       ` Stefano Stabellini
2014-10-23 11:33         ` Jan Beulich
2014-10-17 18:02 ` Roy Franz
2014-10-27 11:09   ` Daniel Kiper

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.