xen: Allow a default compiled-in command line using Kconfig
PATCH v5 1/1 xen: Allow a default compiled-in command line using Kconfig
Added 2 new config entries in common/Kconfig:
CMDLINE and CMDLINE_OVERRIDE
Modifed common/kernel.c:cmdline_parse().
The 2 new entries allow an embedded command line to be compiled in the hypervisor. Both of them depends on EXPERT = "y".
If CMDLINE is set, it will be parsed prior to the bootloader command line. This order of parsing implies that if any non-cumulative options are set in both CMDLINE and the bootloader command line, only the ones in the latter will take effect. Further more, if CMDLINE_OVERRIDE is set to y, the whole bootloader command line will be ignored, which will be useful to work around broken bootloaders. A wrapper to the original common/kernel.c:cmdline_parse() was introduced to complete this task.
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/browse/XEN-41)
---
Changed since v4:
* Make the option CMDLINE depend on EXPERT = "y", and CMDLINE_OVERRIDE
depends on EXPERT = "y" && CMDLINE != "" * Move the code dealing with dom0 options back to arch/x86/setup.c * cmdline_parse is now a wrapper to the the original cmdline_parse(). --- xen/common/Kconfig | 22 ++++++++++++++++++++++ xen/common/kernel.c | 24 +++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-)
xen/common/Kconfig +22 -0
@@ -237,4 +237,26 @@ config FAST_SYMBOL_LOOKUP The only user of this is Live patching. If unsure, say Y. + +config CMDLINE + string "Built-in hypervisor command string" + default "" + depends on EXPERT = "y" + ---help--- + Enter arguments here that should be compiled into the hypervisor + image and used at boot time. When the system boots, this string + will be parsed prior to the bootloader command line. So if a + non-cumulative option is set both in this string and in the + bootloader command line, only the latter one will take effect. + +config CMDLINE_OVERRIDE + bool "Built-in command line overrides bootloader arguments" + default n + depends on EXPERT = "y" && CMDLINE != "" + ---help--- + Set this option to 'Y' to have the hypervisor ignore the bootloader + command line, and use ONLY the built-in command line. + + This is used to work around broken bootloaders. This should + be set to 'N' under normal conditions. endmenu
xen/common/kernel.c +21 -3
@@ -23,6 +23,7 @@enum system_state system_state = SYS_STATE_early_boot;xen_commandline_t saved_cmdline; +const char opt_builtin_cmdline[] =CONFIG_CMDLINE ;static void __init assign_integer_param (const struct kernel_param *param,uint64_t val)
@@ -46,7 +47,7 @@ static void __init assign_integer_param( } } -void __init cmdline_parse (const char *cmdline) +static void __init do_cmdline_parse (const char *cmdline) {char opt[100 ], *optval, *optkey, *q;const char *p = cmdline;
@@ -56,8 +57,6 @@ void __init cmdline_parse(const char *cmdline)if ( cmdline ==NULL )return ; -safe_strcpy (saved_cmdline, cmdline); -for ( ; ; ) {/* Skip whitespace. */
@@ -147,6 +146,25 @@ void __init cmdline_parse(const char *cmdline) } } +/** +* cmdline_parse -- parses the xen command line. +* If CONFIG_CMDLINE is set, it would be parsed prior to @cmdline. +* But if CONFIG_CMDLINE_OVERRIDE is set to y, @cmdline will be ignored. +*/ +void __init cmdline_parse (const char *cmdline) +{ +if (strlen (opt_builtin_cmdline) ) + { +printk ("Built-in command line: %s\n" , opt_builtin_cmdline); +do_cmdline_parse (opt_builtin_cmdline); + } + +#ifndef CONFIG_CMDLINE_OVERRIDE +safe_strcpy (saved_cmdline, cmdline); +do_cmdline_parse (cmdline); +#endif +} +int __init parse_bool (const char *s) { if ( !strcmp("no", s) ||
Signature · 7 lines
2.12.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 18.03.17 at 07:31, <[email protected]> wrote:
xen/common/Kconfig +6
-0@@ -237,4 +237,26 @@ config FAST_SYMBOL_LOOKUP The only user of this is Live patching. If unsure, say Y. + +config CMDLINE + string "Built-in hypervisor command string" + default "" + depends on EXPERT = "y" + ---help---
xen/common/Kconfig config FAST_SYMBOL_LOOKUP · line 255
Quoted 10 lines
xen/common/Kconfig +10
-0+ Enter arguments here that should be compiled into the hypervisor + image and used at boot time. When the system boots, this string + will be parsed prior to the bootloader command line. So if a + non-cumulative option is set both in this string and in the + bootloader command line, only the latter one will take effect. + +config CMDLINE_OVERRIDE + bool "Built-in command line overrides bootloader arguments" + default n + depends on EXPERT = "y" && CMDLINE != ""
The CMDLINE part is sufficient here, as it can't be other than empty when EXPERT <> "y".
xen/common/kernel.c line 26
Quoted 7 lines
xen/common/kernel.c +1
-0@@ -23,6 +23,7 @@enum system_state system_state = SYS_STATE_early_boot;xen_commandline_t saved_cmdline; +const char opt_builtin_cmdline[] =CONFIG_CMDLINE ;
static and __initconst.
xen/common/kernel.c static void __init assign_integer_param( · line 51
Quoted 7 lines
xen/common/kernel.c +1
-1@@ -46,7 +47,7 @@ static void __init assign_integer_param( } } -void __init cmdline_parse (const char *cmdline) +static void __init do_cmdline_parse (const char *cmdline) {
Please omit the "do".
Quoted 11 lines
xen/common/kernel.c +0
-2@@ -56,8 +57,6 @@ void __init cmdline_parse(const char *cmdline)if ( cmdline ==NULL )return ; -safe_strcpy (saved_cmdline, cmdline); -for ( ; ; ) {/* Skip whitespace. */ @@ -147,6 +146,25 @@ void __init cmdline_parse(const char *cmdline) }
xen/common/kernel.c void __init cmdline_parse(const char *cmdline) · line 156
Quoted 10 lines
xen/common/kernel.c +8
-0} +/** +* cmdline_parse -- parses the xen command line. +* If CONFIG_CMDLINE is set, it would be parsed prior to @cmdline. +* But if CONFIG_CMDLINE_OVERRIDE is set to y, @cmdline will be ignored. +*/ +void __init cmdline_parse (const char *cmdline) +{ +if (strlen (opt_builtin_cmdline) )
This can be had cheaper with just checking the first byte.
xen/common/kernel.c void __init cmdline_parse(const char *cmdline) · line 163
Quoted 7 lines
xen/common/kernel.c +7
-0+ { +printk ("Built-in command line: %s\n" , opt_builtin_cmdline); +do_cmdline_parse (opt_builtin_cmdline); + } + +#ifndef CONFIG_CMDLINE_OVERRIDE +safe_strcpy (saved_cmdline, cmdline);
Note how the original placement was after a NULL check.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel