[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 10/21] xen/arm: don't add duplicate boot modules



Don't add duplicate boot modules (same kind and same start address).

Don't try to add cmdline for "xen,domain" compatible nodes. It will be
added later directly by kernel_probe.

Mark kernels and ramdisks of "xen,domain" nodes as BOOTMOD_KERNEL_DOMAIN
and BOOTMOD_RAMDISK_DOMAIN respectively, to avoid getting confused in
kernel_probe, where we try to guess which is the dom0 kernel and initrd
to be compatible with older versions of the multiboot spec.

Signed-off-by: Stefano Stabellini <stefanos@xxxxxxxxxx>

---
Changes in v2:
- new patch
---
 xen/arch/arm/bootfdt.c      | 27 +++++++++++++++++++++------
 xen/arch/arm/setup.c        |  9 +++++++++
 xen/include/asm-arm/setup.h |  2 ++
 3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index b3e1e00..f005c50 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -174,7 +174,12 @@ static void __init process_multiboot_node(const void *fdt, 
int node,
     paddr_t start, size;
     const char *cmdline;
     int len;
+    int parent_node;
 
+    parent_node = fdt_parent_offset(fdt, node);
+    if ( parent_node < 0 )
+        panic("node %s missing a parent\n", name);
+ 
     prop = fdt_get_property(fdt, node, "reg", &len);
     if ( !prop )
         panic("node %s missing `reg' property\n", name);
@@ -220,13 +225,23 @@ static void __init process_multiboot_node(const void 
*fdt, int node,
             kind = BOOTMOD_XSM;
     }
 
-    prop = fdt_get_property(fdt, node, "bootargs", &len);
-    if ( prop )
+    if ( fdt_node_check_compatible(fdt, parent_node, "xen,domain") != 0 )
+    {
+        prop = fdt_get_property(fdt, node, "bootargs", &len);
+        if ( prop )
+        {
+            if ( len > BOOTMOD_MAX_CMDLINE )
+                panic("module %s command line too long\n", name);
+            cmdline = prop->data;
+            safe_strcpy(dom0_cmdline, cmdline);
+        }
+    }
+    else
     {
-        if ( len > BOOTMOD_MAX_CMDLINE )
-            panic("module %s command line too long\n", name);
-        cmdline = prop->data;
-        safe_strcpy(dom0_cmdline, cmdline);
+        if ( kind == BOOTMOD_KERNEL )
+            kind = BOOTMOD_KERNEL_DOMAIN;
+        if ( kind == BOOTMOD_RAMDISK )
+            kind = BOOTMOD_RAMDISK_DOMAIN;
     }
  
     add_boot_module(kind, start, size);
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 188b2cb..d4316c7 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -207,6 +207,7 @@ struct bootmodule *add_boot_module(bootmodule_kind kind,
 {
     struct bootmodules *mods = &bootinfo.modules;
     struct bootmodule *mod;
+    int i;
 
     if ( mods->nr_mods == MAX_MODULES )
     {
@@ -214,6 +215,12 @@ struct bootmodule *add_boot_module(bootmodule_kind kind,
                boot_module_kind_as_string(kind), start, start + size);
         return NULL;
     }
+    for ( i = 0 ; i < mods->nr_mods ; i++ )
+    {
+        mod = &mods->module[i];
+        if ( mod->kind == kind && mod->start == start )
+            return mod;
+    }
 
     mod = &mods->module[mods->nr_mods++];
     mod->kind = kind;
@@ -246,6 +253,8 @@ const char * __init 
boot_module_kind_as_string(bootmodule_kind kind)
     case BOOTMOD_KERNEL:  return "Kernel";
     case BOOTMOD_RAMDISK: return "Ramdisk";
     case BOOTMOD_XSM:     return "XSM";
+    case BOOTMOD_KERNEL_DOMAIN:  return "DomU Kernel";
+    case BOOTMOD_RAMDISK_DOMAIN: return "DomU Ramdisk";
     case BOOTMOD_UNKNOWN: return "Unknown";
     default: BUG();
     }
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 6d08eb4..f8f3eff 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -16,6 +16,8 @@ typedef enum {
     BOOTMOD_KERNEL,
     BOOTMOD_RAMDISK,
     BOOTMOD_XSM,
+    BOOTMOD_KERNEL_DOMAIN,
+    BOOTMOD_RAMDISK_DOMAIN,
     BOOTMOD_UNKNOWN
 }  bootmodule_kind;
 
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.