All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9] xen: Allow a default compiled-in command line using Kconfig
@ 2017-03-21 16:41 Zhongze Liu
  2017-03-21 16:42 ` Wei Liu
  2017-03-21 16:44 ` [PATCH v9] " Jan Beulich
  0 siblings, 2 replies; 9+ messages in thread
From: Zhongze Liu @ 2017-03-21 16:41 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Zhongze Liu, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Jan Beulich

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)

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. Furthermore, 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.

Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
Changed since v8:
  * Changed the CMDLINE's "depends on EXPERT='y'" into a
    conditional prompt.
---
 xen/common/Kconfig  | 21 +++++++++++++++++++++
 xen/common/kernel.c | 30 ++++++++++++++++++++++++------
 2 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index f2ecbc43d6..5334be38a9 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -237,4 +237,25 @@ config FAST_SYMBOL_LOOKUP
 	  The only user of this is Live patching.
 
 	  If unsure, say Y.
+
+config CMDLINE
+	string "Built-in hypervisor command string" if EXPERT = "y"
+	default ""
+	---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 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
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 4b87c60845..64920e8304 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -23,6 +23,7 @@
 enum system_state system_state = SYS_STATE_early_boot;
 
 xen_commandline_t saved_cmdline;
+static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
 static void __init assign_integer_param(
     const struct kernel_param *param, uint64_t val)
@@ -46,18 +47,13 @@ static void __init assign_integer_param(
     }
 }
 
-void __init cmdline_parse(const char *cmdline)
+static void __init _cmdline_parse(const char *cmdline)
 {
     char opt[100], *optval, *optkey, *q;
     const char *p = cmdline;
     const struct kernel_param *param;
     int bool_assert;
 
-    if ( cmdline == NULL )
-        return;
-
-    safe_strcpy(saved_cmdline, cmdline);
-
     for ( ; ; )
     {
         /* Skip whitespace. */
@@ -147,6 +143,28 @@ 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 ( opt_builtin_cmdline[0] )
+    {
+        printk("Built-in command line: %s\n", opt_builtin_cmdline);
+        _cmdline_parse(opt_builtin_cmdline);
+    }
+
+#ifndef CONFIG_CMDLINE_OVERRIDE
+    if ( cmdline == NULL )
+        return;
+
+    safe_strcpy(saved_cmdline, cmdline);
+    _cmdline_parse(cmdline);
+#endif
+}
+
 int __init parse_bool(const char *s)
 {
     if ( !strcmp("no", s) ||
-- 
2.12.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v9] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21 16:41 [PATCH v9] xen: Allow a default compiled-in command line using Kconfig Zhongze Liu
@ 2017-03-21 16:42 ` Wei Liu
  2017-03-21 16:55   ` Stefano Stabellini
  2017-03-21 16:44 ` [PATCH v9] " Jan Beulich
  1 sibling, 1 reply; 9+ messages in thread
From: Wei Liu @ 2017-03-21 16:42 UTC (permalink / raw)
  To: Zhongze Liu
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, xen-devel

On Wed, Mar 22, 2017 at 12:41:01AM +0800, Zhongze Liu wrote:
> 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)
> 
> 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. Furthermore, 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.
> 
> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---

Your previous patch was fixed up by Jan and applied.

In the future please check the staging branch instead of master.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v9] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21 16:41 [PATCH v9] xen: Allow a default compiled-in command line using Kconfig Zhongze Liu
  2017-03-21 16:42 ` Wei Liu
@ 2017-03-21 16:44 ` Jan Beulich
  1 sibling, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2017-03-21 16:44 UTC (permalink / raw)
  To: Zhongze Liu
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, xen-devel

>>> On 21.03.17 at 17:41, <blackskygg@gmail.com> wrote:
> Changed since v8:
>   * Changed the CMDLINE's "depends on EXPERT='y'" into a
>     conditional prompt.

I'm not sure why you've sent this - the patch went in 2 hours ago,
and I actually did send you the mail about the problem after fixing
it and having pushed.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v9] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21 16:42 ` Wei Liu
@ 2017-03-21 16:55   ` Stefano Stabellini
  2017-03-22  0:36     ` [PATCH v6] " Zhongze Liu
  0 siblings, 1 reply; 9+ messages in thread
From: Stefano Stabellini @ 2017-03-21 16:55 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, Zhongze Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, xen-devel

On Tue, 21 Mar 2017, Wei Liu wrote:
> On Wed, Mar 22, 2017 at 12:41:01AM +0800, Zhongze Liu wrote:
> > 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)
> > 
> > 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. Furthermore, 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.
> > 
> > Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
> > Reviewed-by: Jan Beulich <jbeulich@suse.com>
> > Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Tim Deegan <tim@xen.org>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > ---
> 
> Your previous patch was fixed up by Jan and applied.

Conghratulations for your first contribution!

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v6] xen: Allow a default compiled-in command line using Kconfig
  2017-03-21 16:55   ` Stefano Stabellini
@ 2017-03-22  0:36     ` Zhongze Liu
  0 siblings, 0 replies; 9+ messages in thread
From: Zhongze Liu @ 2017-03-22  0:36 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: Wei Liu, George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Jan Beulich, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1796 bytes --]

2017年3月22日星期三,Stefano Stabellini <sstabellini@kernel.org> 写道:

> On Tue, 21 Mar 2017, Wei Liu wrote:
> > On Wed, Mar 22, 2017 at 12:41:01AM +0800, Zhongze Liu wrote:
> > > 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)
> > >
> > > 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. Furthermore, 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.
> > >
> > > Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
> > > Reviewed-by: Jan Beulich <jbeulich@suse.com>
> > > Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> > > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > > Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> > > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > > Cc: Jan Beulich <jbeulich@suse.com>
> > > Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > > Cc: Tim Deegan <tim@xen.org>
> > > Cc: Wei Liu <wei.liu2@citrix.com>
> > > ---
> >
> > Your previous patch was fixed up by Jan and applied.
>
> Conghratulations for your first contribution!
>

Thanks.
I've really learnt a lot here.
This community is awesome.
And Xen rocks!

Cheers!

Zhongze Liu.

[-- Attachment #1.2: Type: text/html, Size: 2446 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6] xen: Allow a default compiled-in command line using Kconfig
  2017-03-20 16:50 ` Jan Beulich
@ 2017-03-21  8:42   ` Zhongze Liu
  0 siblings, 0 replies; 9+ messages in thread
From: Zhongze Liu @ 2017-03-21  8:42 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, xen-devel

2017-03-21 0:50 GMT+08:00 Jan Beulich <JBeulich@suse.com>:
>>>> On 20.03.17 at 17:32, <blackskygg@gmail.com> wrote:
>> Added 2 new config entries in common/Kconfig:
>>     CMDLINE and CMDLINE_OVERRIDE
>> Modifed common/kernel.c:cmdline_parse().
>>
>> The 2 new entries enable an embedded command line to be compiled
>> in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
>> depends on CMDLINE != "".
>>
>> 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)
>>
>> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> albeit I think the commit message should have what is now the 4th
> paragraph first, with what are currently 1st and 2nd paragraphs
> dropped altogether.
>

Agree. That looks better.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6] xen: Allow a default compiled-in command line using Kconfig
  2017-03-20 16:32 [PATCH v6] " Zhongze Liu
  2017-03-20 16:50 ` Jan Beulich
@ 2017-03-20 22:17 ` Stefano Stabellini
  1 sibling, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2017-03-20 22:17 UTC (permalink / raw)
  To: Zhongze Liu
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Jan Beulich, xen-devel

On Tue, 21 Mar 2017, Zhongze Liu wrote:
> Added 2 new config entries in common/Kconfig:
>     CMDLINE and CMDLINE_OVERRIDE
> Modifed common/kernel.c:cmdline_parse().
> 
> The 2 new entries enable an embedded command line to be compiled
> in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
> depends on CMDLINE != "".
> 
> 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)
> 
> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: George Dunlap <George.Dunlap@eu.citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Tim Deegan <tim@xen.org>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
> Changed since v5:
>   * remove the redundent EXPERT = "y" dependency from config CMDLINE_OVERRIDE
>   * make opt_builtin_cmdline[] static and __initconst
>   * changed the name do_cmdline_parse() to _cmdline_parse()
>   * do a NULL check before copying cmdline to saved_cmdline
>   * check the first byte of opt_builtin_cmdline to determine whether it's
>     empty or not.
> ---
>  xen/common/Kconfig  | 22 ++++++++++++++++++++++
>  xen/common/kernel.c | 30 ++++++++++++++++++++++++------
>  2 files changed, 46 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/common/Kconfig b/xen/common/Kconfig
> index f2ecbc43d6..e1c90b739a 100644
> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -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 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
> diff --git a/xen/common/kernel.c b/xen/common/kernel.c
> index 4b87c60845..64920e8304 100644
> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -23,6 +23,7 @@
>  enum system_state system_state = SYS_STATE_early_boot;
>  
>  xen_commandline_t saved_cmdline;
> +static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
>  
>  static void __init assign_integer_param(
>      const struct kernel_param *param, uint64_t val)
> @@ -46,18 +47,13 @@ static void __init assign_integer_param(
>      }
>  }
>  
> -void __init cmdline_parse(const char *cmdline)
> +static void __init _cmdline_parse(const char *cmdline)
>  {
>      char opt[100], *optval, *optkey, *q;
>      const char *p = cmdline;
>      const struct kernel_param *param;
>      int bool_assert;
>  
> -    if ( cmdline == NULL )
> -        return;
> -
> -    safe_strcpy(saved_cmdline, cmdline);
> -
>      for ( ; ; )
>      {
>          /* Skip whitespace. */
> @@ -147,6 +143,28 @@ 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 ( opt_builtin_cmdline[0] )
> +    {
> +        printk("Built-in command line: %s\n", opt_builtin_cmdline);
> +        _cmdline_parse(opt_builtin_cmdline);
> +    }
> +
> +#ifndef CONFIG_CMDLINE_OVERRIDE
> +    if ( cmdline == NULL )
> +        return;
> +
> +    safe_strcpy(saved_cmdline, cmdline);
> +    _cmdline_parse(cmdline);
> +#endif
> +}
> +
>  int __init parse_bool(const char *s)
>  {
>      if ( !strcmp("no", s) ||
> -- 
> 2.12.0
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v6] xen: Allow a default compiled-in command line using Kconfig
  2017-03-20 16:32 [PATCH v6] " Zhongze Liu
@ 2017-03-20 16:50 ` Jan Beulich
  2017-03-21  8:42   ` Zhongze Liu
  2017-03-20 22:17 ` Stefano Stabellini
  1 sibling, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2017-03-20 16:50 UTC (permalink / raw)
  To: Zhongze Liu
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, xen-devel

>>> On 20.03.17 at 17:32, <blackskygg@gmail.com> wrote:
> Added 2 new config entries in common/Kconfig:
>     CMDLINE and CMDLINE_OVERRIDE
> Modifed common/kernel.c:cmdline_parse().
> 
> The 2 new entries enable an embedded command line to be compiled
> in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
> depends on CMDLINE != "".
> 
> 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)
> 
> Signed-off-by: Zhongze Liu <blackskygg@gmail.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

albeit I think the commit message should have what is now the 4th
paragraph first, with what are currently 1st and 2nd paragraphs
dropped altogether.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v6] xen: Allow a default compiled-in command line using Kconfig
@ 2017-03-20 16:32 Zhongze Liu
  2017-03-20 16:50 ` Jan Beulich
  2017-03-20 22:17 ` Stefano Stabellini
  0 siblings, 2 replies; 9+ messages in thread
From: Zhongze Liu @ 2017-03-20 16:32 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Zhongze Liu, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Jan Beulich

Added 2 new config entries in common/Kconfig:
    CMDLINE and CMDLINE_OVERRIDE
Modifed common/kernel.c:cmdline_parse().

The 2 new entries enable an embedded command line to be compiled
in the hypervisor. CMDLINE depends on EXPERT = "y", and CMDLINE_OVERRIDE
depends on CMDLINE != "".

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)

Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
Changed since v5:
  * remove the redundent EXPERT = "y" dependency from config CMDLINE_OVERRIDE
  * make opt_builtin_cmdline[] static and __initconst
  * changed the name do_cmdline_parse() to _cmdline_parse()
  * do a NULL check before copying cmdline to saved_cmdline
  * check the first byte of opt_builtin_cmdline to determine whether it's
    empty or not.
---
 xen/common/Kconfig  | 22 ++++++++++++++++++++++
 xen/common/kernel.c | 30 ++++++++++++++++++++++++------
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index f2ecbc43d6..e1c90b739a 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -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 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
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 4b87c60845..64920e8304 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -23,6 +23,7 @@
 enum system_state system_state = SYS_STATE_early_boot;
 
 xen_commandline_t saved_cmdline;
+static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
 static void __init assign_integer_param(
     const struct kernel_param *param, uint64_t val)
@@ -46,18 +47,13 @@ static void __init assign_integer_param(
     }
 }
 
-void __init cmdline_parse(const char *cmdline)
+static void __init _cmdline_parse(const char *cmdline)
 {
     char opt[100], *optval, *optkey, *q;
     const char *p = cmdline;
     const struct kernel_param *param;
     int bool_assert;
 
-    if ( cmdline == NULL )
-        return;
-
-    safe_strcpy(saved_cmdline, cmdline);
-
     for ( ; ; )
     {
         /* Skip whitespace. */
@@ -147,6 +143,28 @@ 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 ( opt_builtin_cmdline[0] )
+    {
+        printk("Built-in command line: %s\n", opt_builtin_cmdline);
+        _cmdline_parse(opt_builtin_cmdline);
+    }
+
+#ifndef CONFIG_CMDLINE_OVERRIDE
+    if ( cmdline == NULL )
+        return;
+
+    safe_strcpy(saved_cmdline, cmdline);
+    _cmdline_parse(cmdline);
+#endif
+}
+
 int __init parse_bool(const char *s)
 {
     if ( !strcmp("no", s) ||
-- 
2.12.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-03-22  0:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21 16:41 [PATCH v9] xen: Allow a default compiled-in command line using Kconfig Zhongze Liu
2017-03-21 16:42 ` Wei Liu
2017-03-21 16:55   ` Stefano Stabellini
2017-03-22  0:36     ` [PATCH v6] " Zhongze Liu
2017-03-21 16:44 ` [PATCH v9] " Jan Beulich
  -- strict thread matches above, loose matches on Subject: below --
2017-03-20 16:32 [PATCH v6] " Zhongze Liu
2017-03-20 16:50 ` Jan Beulich
2017-03-21  8:42   ` Zhongze Liu
2017-03-20 22:17 ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.