Skip to contentSkip to conversation

xen: Allow a default compiled-in command line using Kconfig

PATCH Superseded Zhongze Liu 3 participants 6 messages Mar 6, 2017

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen: Allow a default compiled-in command line using Kconfig

Added 3 new config entries in common/Kconfig:
CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE

These 3 entries enable an embedded command line
to be compiled in the hypervisor.

If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored.

This allows downstreams to set their defaults without modifying the source code all over the place. Also probably useful for the embedded space.

See Also: https://xenproject.atlassian.net/projects/XEN/issues/XEN-41?filter=allopenissues

---
Changed since v1:
* Added the missing CMDLINE_OVERRIDE config entry.
* Combined built-in and boot loader command lines into one command line before calling cmdline_parse() (instead of calling cmdline_parse() twice).
* Handled dom0 command line options (options after " -- " belong to dom0) in the x86 setup routine.

---
 xen/arch/arm/setup.c | 15 ++++++++++--
 xen/arch/x86/setup.c | 66 ++++++++++++++++++++++++++++++++++++++--------------
 xen/common/Kconfig   | 38 ++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+), 20 deletions(-)
xen/arch/arm/setup.c +13 -2
index 92a2de6b70..9a68bda0fe 100644
@@ -706,6 +706,7 @@ void __init start_xen(unsigned long boot_phys_offset,
     int cpus, i;
     paddr_t xen_paddr;
     const char *cmdline;
+    static xen_commandline_t __initdata complete_cmdline;
     struct bootmodule *xen_bootmodule;
     struct domain *dom0;
     struct xen_arch_domainconfig config;
@@ -729,9 +730,19 @@ void __init start_xen(unsigned long boot_phys_offset,
         + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
     fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
 
+#ifdef CONFIG_CMDLINE
+    safe_strcpy(complete_cmdline, CONFIG_CMDLINE);
+    printk("Compiled-in command line: %s\n", complete_cmdline);
+#endif
+
+#ifndef CONFIG_CMDLINE_OVERRIDE
     cmdline = boot_fdt_cmdline(device_tree_flattened);
-    printk("Command line: %s\n", cmdline);
-    cmdline_parse(cmdline);
+    safe_strcat(complete_cmdline, " ");
+    safe_strcat(complete_cmdline, cmdline);
+    printk("Command line: %s\n", complete_cmdline);
+#endif
+
+    cmdline_parse(complete_cmdline);
 
     /* Register Xen's load address as a boot module. */
     xen_bootmodule = add_boot_module(BOOTMOD_XEN,
xen/arch/x86/setup.c +48 -18

106 lines not on this page · raw message

xen/common/Kconfig +38 -0
index f2ecbc43d6..c5f4aaf7e9 100644
@@ -237,4 +237,42 @@ config FAST_SYMBOL_LOOKUP
 	  The only user of this is Live patching.
 
 	  If unsure, say Y.
+
+config CMDLINE_BOOL
+	bool "Built-in hypervisor command line"
+	default n
+	---help---
+	  Allow for specifying boot arguments to the hypervisor at
+	  build time.  On some systems (e.g. embedded ones), it is
+	  necessary or convenient to provide some or all of the
+	  hypervisor boot arguments with the hypervisor itself (that is,
+	  to not rely on the boot loader to provide them.)
+
+	  To compile command line arguments into the hypervisor,
+	  set this option to 'Y', then fill in the
+	  boot arguments in CONFIG_CMDLINE.
+
+config CMDLINE
+	string "Built-in hypervisor command string"
+	depends on CMDLINE_BOOL
+	default ""
+	---help---
+	  Enter arguments here that should be compiled into the hypervisor
+	  image and used at boot time.  If the boot loader provides a
+	  command line at boot time, it is appended to this string to
+	  form the full hypervisor command line, when the system boots.
+
+	  However, you can use the CONFIG_CMDLINE_OVERRIDE option to
+	  change this behavior.
+
+config CMDLINE_OVERRIDE
+	bool "Built-in command line overrides boot loader arguments"
+	default n
+	depends on CMDLINE_BOOL
+	---help---
+	  Set this option to 'Y' to have the hypervisor ignore the boot loader
+	  command line, and use ONLY the built-in command line.
+
+	  This is used to work around broken boot loaders.  This should
+	  be set to 'N' under normal conditions.
 endmenu
Signature · 7 lines
2.12.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

Hello,

Quoted 11 lines · Zhongze Liu

Added 3 new config entries in common/Kconfig:
CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE

These 3 entries enable an embedded command line
to be compiled in the hypervisor.

If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored.

This behavior seems a little odd to me. Why would you want to append the two command line? And more importantly if the same option is passed twice, how will this behave?

For example the compile command line could contain iommu=off, but the bootloader is passing iommu=on. What would be the final state of the IOMMU?

This one is quite simple, but you could have options which set flags. So if you want to override it, the new option would have to unset it.

Quoted 6 lines

This allows downstreams to set their defaults without modifying the source code all over the place. Also probably useful for the embedded space.

See Also: https://xenproject.atlassian.net/projects/XEN/issues/XEN-41?filter=allopenissues

A shorter link is https://xenproject.atlassian.net/browse/XEN-41

Quoted 3 lines

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 06.03.17 at 12:15, <[email protected]> wrote:
Quoted 11 lines · Zhongze Liu

Added 3 new config entries in common/Kconfig:
CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE

These 3 entries enable an embedded command line
to be compiled in the hypervisor.

If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored.

This behavior seems a little odd to me. Why would you want to append the two command line? And more importantly if the same option is passed twice, how will this behave?

Quoted 5 lines

For example the compile command line could contain iommu=off, but the bootloader is passing iommu=on. What would be the final state of the IOMMU?

This one is quite simple, but you could have options which set flags. So if you want to override it, the new option would have to unset it.

I don't understand this concern - overriding an earlier option by a later one is (supposed to be) well defined, and we even suggest this to people when wanting to try out options without having to edit bootloader (or whatever) config files.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 06.03.17 at 12:15, <[email protected]> wrote:
Quoted 11 lines · Zhongze Liu

Added 3 new config entries in common/Kconfig:
CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE

These 3 entries enable an embedded command line
to be compiled in the hypervisor.

If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored.

This behavior seems a little odd to me. Why would you want to append the two command line? And more importantly if the same option is passed twice, how will this behave?

For example the compile command line could contain iommu=off, but the bootloader is passing iommu=on. What would be the final state of the IOMMU?

Quoted 7 lines
Quoted 2 lines

This one is quite simple, but you could have options which set flags. So if you want to override it, the new option would have to unset it.

I don't understand this concern - overriding an earlier option by a later one is (supposed to be) well defined, and we even suggest this to people when wanting to try out options without having to edit bootloader (or whatever) config files.

My concern is not about the override itself but about appending two commandlines option without any explanation whether the built-in commandline will be parsed first.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw
Quoted 28 lines
Quoted 1 line
Quoted 1 line · On 06.03.17 at 12:38, <[email protected]> wrote:
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 06.03.17 at 12:15, <[email protected]> wrote:
Quoted 11 lines · Zhongze Liu

Added 3 new config entries in common/Kconfig:
CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE

These 3 entries enable an embedded command line
to be compiled in the hypervisor.

If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored.

This behavior seems a little odd to me. Why would you want to append the two command line? And more importantly if the same option is passed twice, how will this behave?

For example the compile command line could contain iommu=off, but the bootloader is passing iommu=on. What would be the final state of the IOMMU?

This one is quite simple, but you could have options which set flags. So if you want to override it, the new option would have to unset it.

Quoted 8 lines
Quoted 4 lines

I don't understand this concern - overriding an earlier option by a later one is (supposed to be) well defined, and we even suggest this to people when wanting to try out options without having to edit bootloader (or whatever) config files.

My concern is not about the override itself but about appending two commandlines option without any explanation whether the built-in commandline will be parsed first.

Oh, agreed - as Andrew has also pointed out, the ordering (and hence override behavior) needs to be clearly spelled out here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

2017-03-06 19:42 GMT+08:00 Jan Beulich <[email protected]>:

Quoted 33 lines
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 06.03.17 at 12:38, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 06.03.17 at 12:15, <[email protected]> wrote:
Quoted 11 lines · Zhongze Liu

Added 3 new config entries in common/Kconfig:
CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE

These 3 entries enable an embedded command line
to be compiled in the hypervisor.

If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored.

This behavior seems a little odd to me. Why would you want to append the two command line? And more importantly if the same option is passed twice, how will this behave?

Quoted 5 lines

For example the compile command line could contain iommu=off, but the bootloader is passing iommu=on. What would be the final state of the IOMMU?

This one is quite simple, but you could have options which set flags. So if you want to override it, the new option would have to unset it.

I don't understand this concern - overriding an earlier option by a later one is (supposed to be) well defined, and we even suggest this to people when wanting to try out options without having to edit bootloader (or whatever) config files.

Quoted 9 lines
Quoted 3 lines

My concern is not about the override itself but about appending two commandlines option without any explanation whether the built-in commandline will be parsed first.

Oh, agreed - as Andrew has also pointed out, the ordering (and hence override behavior) needs to be clearly spelled out here.

Jan

Yes, the expression here is indeed quite ambiguous. I'll try to clarify the ordering
of the two commandlines and override behavior.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel