Skip to contentSkip to conversation

ARM: parse separate DT properties for different commandlines

PATCH Superseded Andre Przywara 2 participants 3 messages May 31, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: parse separate DT properties for different commandlines

Currently we use the chosen/bootargs property as the Xen commandline and rely on xen,dom0-bootargs for Dom0. However this brings issues with bootloaders, which usually build bootargs by bootscripts for a Linux kernel - and not for the entirely different Xen hypervisor. Introduce a new possible device tree property "xen,xen-bootargs" explicitly for the Xen hypervisor and make the selection of which to use more fine grained:
- If xen,xen-bootargs is present, it will be used for Xen.
- If xen,dom0-bootargs is present, it will be used for Dom0.
- If xen,xen-bootargs is _not_ present, but xen,dom0-bootargs is, bootargs will be used for Xen. Like the current situation.
- If no Xen specific properties are present, bootargs is for Dom0.
- If xen,xen-bootargs is present, but xen,dom0-bootargs is missing, bootargs will be used for Dom0.

The aim is to allow common bootscripts to boot both Xen and native Linux with the same device tree blob. If needed, one could hard-code the Xen commandline into the DTB, leaving bootargs for Dom0 to be set by the (non Xen-aware) bootloader.
I also have a simple patch for u-boot to transfer the content of the "xen_bootargs" environment variable into the xen,xen-bootargs dtb property.
If you like this approach, I will send the u-boot patch to their ML.

---
 xen/arch/arm/domain_build.c | 14 +++++++++++---
 xen/common/device_tree.c    |  7 ++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)
xen/arch/arm/domain_build.c +11 -3
index b92c64b..952adb3 100644
@@ -139,6 +139,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
                             u32 address_cells, u32 size_cells)
 {
     const char *bootargs = NULL;
+    int had_dom0_bootargs = 0;
     int prop;
 
     if ( early_info.modules.nr_mods >= 1 &&
@@ -169,12 +170,19 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
          */
         if ( device_tree_node_matches(fdt, node, "chosen") )
         {
-            if ( strcmp(prop_name, "bootargs") == 0 )
+            if ( strcmp(prop_name, "xen,xen-bootargs") == 0 )
+                continue;
+            if ( strcmp(prop_name, "xen,dom0-bootargs") == 0 )
+            {
+                had_dom0_bootargs = 1;
+                bootargs = prop_data;
                 continue;
-            else if ( strcmp(prop_name, "xen,dom0-bootargs") == 0 )
+            }
+            if ( strcmp(prop_name, "bootargs") == 0 )
             {
-                if ( !bootargs )
+                if ( !bootargs  && !had_dom0_bootargs ) {
                     bootargs = prop_data;
+                }
                 continue;
             }
         }
xen/common/device_tree.c +6 -1
index 84d704d..c25e6d4 100644
@@ -325,7 +325,12 @@ const char *device_tree_bootargs(const void *fdt)
     if ( node < 0 )
         return NULL;
 
-    prop = fdt_get_property(fdt, node, "bootargs", NULL);
+    prop = fdt_get_property(fdt, node, "xen,xen-bootargs", NULL);
+    if ( prop == NULL ) {
+    	if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL)) {
+            prop = fdt_get_property(fdt, node, "bootargs", NULL);
+        }
+    }
     if ( prop == NULL )
         return NULL;
 
Signature · 1 line
1.7.12.1
#1 lore raw
Quoted 15 lines · Andre Przywara

Currently we use the chosen/bootargs property as the Xen commandline and rely on xen,dom0-bootargs for Dom0. However this brings issues with bootloaders, which usually build bootargs by bootscripts for a Linux kernel - and not for the entirely different Xen hypervisor. Introduce a new possible device tree property "xen,xen-bootargs" explicitly for the Xen hypervisor and make the selection of which to use more fine grained:
- If xen,xen-bootargs is present, it will be used for Xen.
- If xen,dom0-bootargs is present, it will be used for Dom0.
- If xen,xen-bootargs is _not_ present, but xen,dom0-bootargs is, bootargs will be used for Xen. Like the current situation.
- If no Xen specific properties are present, bootargs is for Dom0.
- If xen,xen-bootargs is present, but xen,dom0-bootargs is missing, bootargs will be used for Dom0.

Quoted 8 lines

The aim is to allow common bootscripts to boot both Xen and native Linux with the same device tree blob. If needed, one could hard-code the Xen commandline into the DTB, leaving bootargs for Dom0 to be set by the (non Xen-aware) bootloader.
I also have a simple patch for u-boot to transfer the content of the "xen_bootargs" environment variable into the xen,xen-bootargs dtb property.
If you like this approach, I will send the u-boot patch to their ML.

I think I've traced through all 8 possibilities and the results seem to make sense...

Quoted 28 lines
---
 xen/arch/arm/domain_build.c | 14 +++++++++++---
 xen/common/device_tree.c    |  7 ++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)
xen/arch/arm/domain_build.c +6 -1
index b92c64b..952adb3 100644
@@ -139,6 +139,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
                             u32 address_cells, u32 size_cells)
 {
     const char *bootargs = NULL;
+    int had_dom0_bootargs = 0;
     int prop;
 
     if ( early_info.modules.nr_mods >= 1 &&
@@ -169,12 +170,19 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
          */
         if ( device_tree_node_matches(fdt, node, "chosen") )
         {
-            if ( strcmp(prop_name, "bootargs") == 0 )
+            if ( strcmp(prop_name, "xen,xen-bootargs") == 0 )
+                continue;
+            if ( strcmp(prop_name, "xen,dom0-bootargs") == 0 )
+            {
+                had_dom0_bootargs = 1;

xen/arch/arm/domain_build.c static int write_properties(struct domain *d, struct kernel_info *kinfo, · line 185

Quoted 10 lines
xen/arch/arm/domain_build.c +5 -2
+                bootargs = prop_data;
                 continue;
-            else if ( strcmp(prop_name, "xen,dom0-bootargs") == 0 )
+            }
+            if ( strcmp(prop_name, "bootargs") == 0 )
             {
-                if ( !bootargs )
+                if ( !bootargs  && !had_dom0_bootargs ) {
                     bootargs = prop_data;
+                }

Xen coding style doesn't require {} around single lines.

Quoted 8 lines
xen/arch/arm/domain_build.c +0 -0
                 continue;
             }
         }
xen/common/device_tree.c +0 -0
index 84d704d..c25e6d4 100644

xen/common/device_tree.c const char *device_tree_bootargs(const void *fdt) · line 329

Quoted 6 lines
xen/common/device_tree.c +2 -1
@@ -325,7 +325,12 @@ const char *device_tree_bootargs(const void *fdt)
     if ( node < 0 )
         return NULL;
 
-    prop = fdt_get_property(fdt, node, "bootargs", NULL);
+    prop = fdt_get_property(fdt, node, "xen,xen-bootargs", NULL);
+    if ( prop == NULL ) {

Coding style is { on the next line

xen/common/device_tree.c const char *device_tree_bootargs(const void *fdt) · line 332

Quoted 3 lines
xen/common/device_tree.c +3 -0
+    	if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL)) {
+            prop = fdt_get_property(fdt, node, "bootargs", NULL);
+        }

There's a hard tab here, but you don't need the {} anyway. To avoid ambiguity I would stick with the outer one though.

Quoted 4 lines
xen/common/device_tree.c +1 -0
+    }
     if ( prop == NULL )
         return NULL;
 
#2 lore raw
Quoted 25 lines · Ian Campbell
Quoted 15 lines · Andre Przywara

Currently we use the chosen/bootargs property as the Xen commandline and rely on xen,dom0-bootargs for Dom0. However this brings issues with bootloaders, which usually build bootargs by bootscripts for a Linux kernel - and not for the entirely different Xen hypervisor. Introduce a new possible device tree property "xen,xen-bootargs" explicitly for the Xen hypervisor and make the selection of which to use more fine grained:
- If xen,xen-bootargs is present, it will be used for Xen.
- If xen,dom0-bootargs is present, it will be used for Dom0.
- If xen,xen-bootargs is _not_ present, but xen,dom0-bootargs is, bootargs will be used for Xen. Like the current situation.
- If no Xen specific properties are present, bootargs is for Dom0.
- If xen,xen-bootargs is present, but xen,dom0-bootargs is missing, bootargs will be used for Dom0.

Quoted 8 lines

The aim is to allow common bootscripts to boot both Xen and native Linux with the same device tree blob. If needed, one could hard-code the Xen commandline into the DTB, leaving bootargs for Dom0 to be set by the (non Xen-aware) bootloader.
I also have a simple patch for u-boot to transfer the content of the "xen_bootargs" environment variable into the xen,xen-bootargs dtb property.
If you like this approach, I will send the u-boot patch to their ML.

Quoted 2 lines

I think I've traced through all 8 possibilities and the results seem to make sense...

Sorry about the coding style issues, I am doing u-boot/Linux/Xen context switching currently. Some of the braces are leftovers from debugging (to check all 8 possibilities ;-) Will send a fixed version.

Thanks for the review,
Andre.

Quoted 71 lines
Quoted 28 lines
---
  xen/arch/arm/domain_build.c | 14 +++++++++++---
  xen/common/device_tree.c    |  7 ++++++-
  2 files changed, 17 insertions(+), 4 deletions(-)
xen/arch/arm/domain_build.c +6 -1
index b92c64b..952adb3 100644
@@ -139,6 +139,7 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
                              u32 address_cells, u32 size_cells)
  {
      const char *bootargs = NULL;
+    int had_dom0_bootargs = 0;
      int prop;
 
      if ( early_info.modules.nr_mods >= 1 &&
@@ -169,12 +170,19 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
           */
          if ( device_tree_node_matches(fdt, node, "chosen") )
          {
-            if ( strcmp(prop_name, "bootargs") == 0 )
+            if ( strcmp(prop_name, "xen,xen-bootargs") == 0 )
+                continue;
+            if ( strcmp(prop_name, "xen,dom0-bootargs") == 0 )
+            {
+                had_dom0_bootargs = 1;

xen/arch/arm/domain_build.c static int write_properties(struct domain *d, struct kernel_info *kinfo, · line 185

Quoted 10 lines
xen/arch/arm/domain_build.c +5 -2
+                bootargs = prop_data;
                  continue;
-            else if ( strcmp(prop_name, "xen,dom0-bootargs") == 0 )
+            }
+            if ( strcmp(prop_name, "bootargs") == 0 )
              {
-                if ( !bootargs )
+                if ( !bootargs  && !had_dom0_bootargs ) {
                      bootargs = prop_data;
+                }

Xen coding style doesn't require {} around single lines.

Quoted 8 lines
xen/arch/arm/domain_build.c +0 -0
                  continue;
              }
          }
xen/common/device_tree.c +0 -0
index 84d704d..c25e6d4 100644

xen/common/device_tree.c const char *device_tree_bootargs(const void *fdt) · line 329

Quoted 6 lines
xen/common/device_tree.c +2 -1
@@ -325,7 +325,12 @@ const char *device_tree_bootargs(const void *fdt)
      if ( node < 0 )
          return NULL;
 
-    prop = fdt_get_property(fdt, node, "bootargs", NULL);
+    prop = fdt_get_property(fdt, node, "xen,xen-bootargs", NULL);
+    if ( prop == NULL ) {

Coding style is { on the next line

xen/common/device_tree.c const char *device_tree_bootargs(const void *fdt) · line 332

Quoted 3 lines
xen/common/device_tree.c +3 -0
+    	if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL)) {
+            prop = fdt_get_property(fdt, node, "bootargs", NULL);
+        }

There's a hard tab here, but you don't need the {} anyway. To avoid ambiguity I would stick with the outer one though.

Quoted 4 lines
xen/common/device_tree.c +1 -0
+    }
      if ( prop == NULL )
          return NULL;