Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754171AbbELXl0 (ORCPT ); Tue, 12 May 2015 19:41:26 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:33415 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933934AbbELXlX (ORCPT ); Tue, 12 May 2015 19:41:23 -0400 MIME-Version: 1.0 In-Reply-To: References: <1428518512-13460-1-git-send-email-mjg59@coreos.com> <1428611100-23337-1-git-send-email-mjg59@srcf.ucam.org> <20150512092821.GA10900@gmail.com> Date: Tue, 12 May 2015 16:41:22 -0700 X-Google-Sender-Auth: KU2kHAwsR2BZiZs_n3kKkiFrDP0 Message-ID: Subject: Re: [PATCH V2] x86: Allow built-in command line to work in early kernel init From: Yinghai Lu To: Matthew Garrett Cc: Ingo Molnar , Matthew Garrett , "the arch/x86 maintainers" , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , Linux Kernel Mailing List , Matthew Garrett Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2015 Lines: 77 On Tue, May 12, 2015 at 11:42 AM, Matthew Garrett 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 > #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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/