ARM/multiboot: use more flexible node naming
PATCH 1/1 ARM/multiboot: use more flexible node naming
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.
[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)
xen/common/device_tree.c +50 -7
@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];
@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Signature · 1 line
1.7.12.1
Is there a chance to get NetBSD Dom0 [1] to boot to justify that your approach is *really* generic.
xen,linux-zimage and xen,linux-initrd do not sound generic but xen,dom0-kernel and xen,ramdisk do sound generic at least.
Christoph
[1] NetBSD Dom0 hasn't been ported to ARM yet.
Quoted 105 lines · Andre Przywara
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +50
-7@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Quoted 5 lines · Christoph
Is there a chance to get NetBSD Dom0 [1] to boot to justify that your approach is *really* generic.
xen,linux-zimage and xen,linux-initrd do not sound generic but xen,dom0-kernel and xen,ramdisk do sound generic at least.
Does NetBSD follow the Linux zImage boot protocol (Documentation/arm/Booting.txt in a Linux source tree)?
If not then you need to define (or link to) the NetBSD boot protocol and we probably will eventually need xen,netbsd-fooimg and suitable code in Xen to handle that format.
Quoted 1 line
[1] NetBSD Dom0 hasn't been ported to ARM yet.
So surely you have answered your own question then, unless you are asking Andre to port NetBSD to ARM? I don't think that is a reasonable prerequisite for this patch.
Quoted 109 lines · Andre Przywara
Quoted 105 lines
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +50
-7@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Quoted 14 lines · Ian Campbell
Quoted 5 lines · Christoph
Is there a chance to get NetBSD Dom0 [1] to boot to justify that your approach is *really* generic.
xen,linux-zimage and xen,linux-initrd do not sound generic but xen,dom0-kernel and xen,ramdisk do sound generic at least.
Does NetBSD follow the Linux zImage boot protocol (
Documentation/arm/Booting.txtin a Linux source tree)?If not then you need to define (or link to) the NetBSD boot protocol and we probably will eventually need xen,netbsd-fooimg and suitable code in Xen to handle that format.
Quoted 5 lines
Quoted 1 line
[1] NetBSD Dom0 hasn't been ported to ARM yet.
So surely you have answered your own question then, unless you are asking Andre to port NetBSD to ARM? I don't think that is a reasonable prerequisite for this patch.
No, it is not a prerequisite. My question is related to the design if it is "I allow Linux only to boot" or "I allow any Dom0 to boot".
Christoph
Quoted 112 lines
Quoted 110 lines · Andre Przywara
Quoted 105 lines
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +50
-7@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Quoted 15 lines · Christoph
Quoted 14 lines · Ian Campbell
Quoted 5 lines · Christoph
Is there a chance to get NetBSD Dom0 [1] to boot to justify that your approach is *really* generic.
xen,linux-zimage and xen,linux-initrd do not sound generic but xen,dom0-kernel and xen,ramdisk do sound generic at least.
Does NetBSD follow the Linux zImage boot protocol (
Documentation/arm/Booting.txtin a Linux source tree)?If not then you need to define (or link to) the NetBSD boot protocol and we probably will eventually need xen,netbsd-fooimg and suitable code in Xen to handle that format.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
[1] NetBSD Dom0 hasn't been ported to ARM yet.
So surely you have answered your own question then, unless you are asking Andre to port NetBSD to ARM? I don't think that is a reasonable prerequisite for this patch.
No, it is not a prerequisite. My question is related to the design if it is "I allow Linux only to boot" or "I allow any Dom0 to boot".
The design allows for any dom0, since it includes a compatibility string which corresponds to the boot protocol to use. The implementation currently only covers Linux though.
Quoted 115 lines
Christoph
Quoted 112 lines
Quoted 110 lines · Andre Przywara
Quoted 105 lines
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +50
-7@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Quoted 22 lines · Ian Campbell
Quoted 21 lines · Christoph
Quoted 19 lines · Ian Campbell
Quoted 5 lines · Christoph
Is there a chance to get NetBSD Dom0 [1] to boot to justify that your approach is *really* generic.
xen,linux-zimage and xen,linux-initrd do not sound generic but xen,dom0-kernel and xen,ramdisk do sound generic at least.
Does NetBSD follow the Linux zImage boot protocol (
Documentation/arm/Booting.txtin a Linux source tree)?If not then you need to define (or link to) the NetBSD boot protocol and we probably will eventually need xen,netbsd-fooimg and suitable code in Xen to handle that format.
Quoted 1 line
[1] NetBSD Dom0 hasn't been ported to ARM yet.
So surely you have answered your own question then, unless you are asking Andre to port NetBSD to ARM? I don't think that is a reasonable prerequisite for this patch.
Quoted 6 lines
Quoted 2 lines
No, it is not a prerequisite. My question is related to the design if it is "I allow Linux only to boot" or "I allow any Dom0 to boot".
The design allows for any dom0, since it includes a compatibility string which corresponds to the boot protocol to use. The implementation currently only covers Linux though.
I think the whole discussion is somewhat moot here, as NetBSD does not seem to support device trees. I see FreeBSD has support for it, but with some quick googling I cannot find anything in NetBSD.
Regards,
Andre.
Quoted 113 lines
Quoted 111 lines
Quoted 110 lines
Quoted 108 lines · Andre Przywara
Quoted 105 lines
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +50
-7@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Hi,
I have also modified this function with my patch series "Allow Xen to boot with a raw Device Tree". Can you rebase this patch on top of this serie?
Other comments below.
Quoted 4 lines · Andre Przywara
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
Quoted 8 lines
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.
The ePAR (section 2.2.1) requires the unit-address (name@unit-address) to match the first address of the "reg" property. I think, with this solution we doesn't comply to the specification.
If the bootloader is able to add "boot,kernel" and "boot,initramfs" to the compatible property, we should have a generic solution for multiboot.
Quoted 12 lines
[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +0
-0
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 442
Quoted 4 lines
xen/common/device_tree.c +1
-0@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = {
These variable are only used durint the initialization, you should add __initconst.
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 446
Quoted 4 lines
xen/common/device_tree.c +4
-0+"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL
Xen uses spaces instead of tabulations.
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 449
Quoted 3 lines
xen/common/device_tree.c +3
-0+}; + +static const char *const initrd_module_names[] = {
__initconst
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 453
Quoted 4 lines
xen/common/device_tree.c +4
-0+"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL
tabulations
Quoted 11 lines
xen/common/device_tree.c +3
-1+}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 467
Quoted 10 lines
xen/common/device_tree.c +2
-6int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ; -else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++)
the coding style for "for" is for ( ... )
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 468
Quoted 1 line
xen/common/device_tree.c +1
-0+if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) {
newline before {
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 473
Quoted 5 lines
xen/common/device_tree.c +5
-0+ nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++)
for ( ... )
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 474
Quoted 1 line
xen/common/device_tree.c +1
-0+if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) {
newline before {
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 479
Quoted 5 lines
xen/common/device_tree.c +5
-0+ nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) {
newline before {
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 480
Quoted 1 line
xen/common/device_tree.c +1
-0+char *s;
there is a tabulation here.
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 482
Quoted 2 lines
xen/common/device_tree.c +2
-0+ +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) {
newline before {
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 483
Quoted 1 line
xen/common/device_tree.c +1
-0+early_panic ("%s not a known xen multiboot type\n" , name);
early_panic is a bit tough, can we simply ignore the node?
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 487
Quoted 4 lines
xen/common/device_tree.c +4
-0+return ; + } + s =strchr (name,'@' ); +if (s ==NULL )
if ( ... )
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 489
Quoted 2 lines
xen/common/device_tree.c +2
-0+ nr = early_info.modules.nr_mods +1 ; + else {
newline before {
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 494
Quoted 5 lines
xen/common/device_tree.c +5
-0+ nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) {
if ( ... )
You should also check nr < 0. Strtoll could return a negative value.
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 496
Quoted 2 lines
xen/common/device_tree.c +2
-0+early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST );
indentation here.
xen/common/device_tree.c static int __init early_scan_node(const void *fdt, · line 537
Quoted 11 lines
xen/common/device_tree.c +4
-0+return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);
Do we consider the multiboot node can live outside /chosen?
Quoted 4 lines
xen/common/device_tree.c +0
-0return 0 ; }
Signature · 1 line
Julien Grall
Quoted 22 lines · Julien Grall
Hi,
I have also modified this function with my patch series "Allow Xen to boot with a raw Device Tree". Can you rebase this patch on top of this serie?
Other comments below.
Quoted 4 lines · Andre Przywara
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
Quoted 8 lines
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.
Quoted 3 lines
The ePAR (section 2.2.1) requires the unit-address (name@unit-address) to match the first address of the "reg" property. I think, with this solution we doesn't comply to the specification.
Yes, you are right. As it seems to be of no use to use the start address to do the enumeration (in my testing I load the initrd at a lower address for instance), I will drop this part of the patch and rely on proper, though generic naming of the nodes instead.
Quoted 21 lines
If the bootloader is able to add "boot,kernel" and "boot,initramfs" to the compatible property, we should have a generic solution for multiboot.
Quoted 17 lines
[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +0
-0@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); }
Quoted 4 lines
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 442
Quoted 1 line
xen/common/device_tree.c +1
-0+static const char *const kernel_module_names[] = {These variable are only used durint the initialization, you should add
__initconst.
As already discussed on IRC, it seems like __initconst is not yet upstream and __initdata doesn't work yet, either. So I will keep this part as it is for now with the option to fix this later.
Quoted 6 lines
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 446
Quoted 4 lines
xen/common/device_tree.c +4
-0+"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL Xen uses spaces instead of tabulations.
Sorry for all these whitespace issues. Seems like the switch between u-boot and Xen didn't switch the whole context ;-)
....
Quoted 4 lines
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 483
Quoted 2 lines
xen/common/device_tree.c +1
-0+early_panic ("%s not a known xen multiboot type\n" , name);
early_panicis a bit tough, can we simply ignore the node?
In fact this was copied from the place before. Not sure if the situation has now changed with the wider, not necessarily Xen-centric scope of the modules. But in fact we could print a warning about this. If there is no kernel module specified, we will panic later anyways.
....
Quoted 11 lines
xen/common/device_tree.c static int __init early_scan_node(const void *fdt, · line 540
Quoted 9 lines
xen/common/device_tree.c +2
-0@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);Do we consider the multiboot node can live outside /chosen?
Did we care for the old node type? I just copied what was used before.
Maybe for bootloaders it is technically easier to put it under the root node, so as long as it doesn't hurt us, I'd like to keep it this way.
Will send out a reworked version ASAP.
Thanks for the review,
Andre.
Quoted 58 lines · Andre Przywara
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +16
-5@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ;
xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 474
Quoted 10 lines
xen/common/device_tree.c +8
-2-else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) {
I think Julien's big dtb series adds a helper which would make this simpler?
That could be a later fix up, are there any other ordering constraints with that series?
Quoted 36 lines
xen/common/device_tree.c +26
-0+ nr =MOD_INITRD ; +break ; + } + +if (nr ==-1 ) { +char *s; + +if (fdt_node_check_compatible (fdt, node,"boot,module" ) !=0 ) { +early_panic ("%s not a known xen multiboot type\n" , name); +return ; + } + s =strchr (name,'@' ); +if (s ==NULL ) + nr = early_info.modules.nr_mods +1 ; +else { + nr =simple_strtoll (s +1 ,NULL ,10 ) +1 ; + } + } + +if (nr >=NR_MODULES ) { +early_panic ("only supporting %d multiboot modules\n" , +NR_MODULES -MOD_DISCARD_FIRST ); +return ; + } mod = &early_info.modules.module[nr];@@ -492,6 +533,8 @@ static int __init early_scan_node(const void *fdt,process_cpu_node (fdt, node, name, address_cells, size_cells); else if ( device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ) process_multiboot_node(fdt, node, name, address_cells, size_cells); + else if ( device_tree_node_compatible(fdt, node, "boot,module" ) ) + process_multiboot_node(fdt, node, name, address_cells, size_cells);return 0 ; }
Quoted 73 lines · Ian Campbell
Quoted 58 lines · Andre Przywara
For the current "multiboot" on ARM support we look for a compatible string of "xen,multiboot-module" in the device tree, and then use "xen,linux-zimage" and "xen,linux-initrd" to differentiate between the two supported module types.
To meet the more generic multiboot proposal in the device tree [1], allow Xen to be more flexible in the compatible naming and also use the new generic base name "boot,module".
The mapping to either Dom0 kernel or RAM disk works either by providing a more specific name ("xen,dom0-kernel" and "xen,ramdisk"), or by using the enumeration order of the device tree nodes (module@0 = kernel, module@1 = initrd). This allows bootloaders without any specific Xen knowledge to boot Xen anyways.[1] http://lists.xen.org/archives/html/xen-devel/2013-09/msg00083.html
Signed-off-by Andre Przywara <[email protected]>--- xen/common/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-)xen/common/device_tree.c +16
-5@@ -439,22 +439,63 @@ static void __init process_cpu_node(const void *fdt, int node,cpumask_set_cpu (start, &cpu_possible_map); } +static const char *const kernel_module_names[] = { +"xen,linux-zimage" , +"xen,dom0-kernel" , +"boot,kernel" , +NULL +}; + +static const char *const initrd_module_names[] = { +"xen,linux-initrd" , +"xen,ramdisk" , +"boot,ramdisk" , +NULL +}; +static void __init process_multiboot_node (const void *fdt,int node,const char *name,u32 address_cells,u32 size_cells) {const struct fdt_property *prop;const u32 *cell; -int nr; +int nr =-1 ;struct dt_mb_module *mod;int len; +const char *const * name_list; -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 ) - nr =MOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 ) - nr =MOD_INITRD ;xen/common/device_tree.c static void __init process_cpu_node(const void *fdt, int node, · line 474
Quoted 10 lines
xen/common/device_tree.c +8
-2-else -early_panic ("%s not a known xen multiboot type\n" , name); +for (name_list = kernel_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) { + nr =MOD_KERNEL ; +break ; + } + +for (name_list = initrd_module_names; *name_list !=NULL ; name_list++) +if (fdt_node_check_compatible (fdt, node, *name_list) ==0 ) {I think Julien's big dtb series adds a helper which would make this simpler?
Quoted 2 lines
That could be a later fix up, are there any other ordering constraints with that series?
Not that I am aware of. I think I will send out my new version so far for discussion and review and will happily rebase it later on if needed.
Thanks,
Andre.