lkml.org 
[lkml]   [2015]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH V2] x86: Allow built-in command line to work in early kernel init
From
On Tue, May 12, 2015 at 11:42 AM, Matthew Garrett
<matthew.garrett@coreos.com> wrote:
> Ok, maybe something more like this? It even gets rid of some of the
> #ifdefs in setup.c.
>
> diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c
> index 625d21b..9ddffd0 100644
> --- a/arch/x86/boot/cmdline.c
> +++ b/arch/x86/boot/cmdline.c
> @@ -12,8 +12,15 @@
> * Simple command-line parser for early boot.
> */
>
> +#include <asm/cmdline_append.h>
> #include "boot.h"
>
> +#ifdef CONFIG_CMDLINE_BOOL
> +static char builtin_cmdline[] = CONFIG_CMDLINE;
> +#else
> +static char *builtin_cmdline;
> +#endif
> +
> static inline int myisspace(u8 c)
> {
> return c <= ' '; /* Close enough approximation */
> @@ -156,3 +163,38 @@ int __cmdline_find_option_bool(unsigned long
> cmdline_ptr, const char *option)
>
> return 0; /* Buffer overrun */
> }
> +
> +int __cmdline_init(unsigned long cmdline_ptr, struct boot_params *params)
> +{
> + addr_t cptr;
> + int i = 0;
> +
> + if (!builtin_cmdline)
> + return 0;
> +
> + if (!cmdline_ptr)
> + return -1; /* No command line */
> +
> + set_fs(cmdline_ptr >> 4);
> + cptr = cmdline_ptr & 0xf;
> +
> + if (append_cmdline) {
> + while (cptr < 0x10000) {
> + char c = rdfs8(cptr);
> + if (!c) {
> + wrfs8(' ', cptr++);
> + break;
> + }
> + cptr++;
> + }
> + }
> +
> + while (builtin_cmdline[i] && cptr < 0xffff)
> + wrfs8(builtin_cmdline[i++], cptr++);
> +
> + wrfs8('\0', cptr);
> +
> + params->setup_flags |= SETUP_CMDLINE_APPENDED;
> +
> + return 0;
> +}

You can not assume that you can use buffer after cmd_line from bootloader
blindly.

Thanks

Yinghai


\
 
 \ /
  Last update: 2015-05-13 02:01    [W:0.063 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site