All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: KarimAllah Ahmed <karahmed@amazon.de>
Cc: Baoquan He <bhe@redhat.com>,
	x86@kernel.org, kexec@lists.infradead.org,
	Haren Myneni <hbabu@us.ibm.com>, Ingo Molnar <mingo@redhat.com>,
	Eric Biederman <ebiederm@xmission.com>,
	aliguori@amazon.com, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Dave Young <dyoung@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] prepend elfcorehdr instead of appending it to the crash-kernel command-line.
Date: Thu, 14 May 2015 10:34:37 -0400	[thread overview]
Message-ID: <20150514143437.GD21327@redhat.com> (raw)
In-Reply-To: <1431511554-16861-1-git-send-email-karahmed@amazon.de>

On Wed, May 13, 2015 at 12:05:54PM +0200, KarimAllah Ahmed wrote:
> Any parameter passed after '--' in the kernel command-line will not be parsed
> by the kernel at all, instead it will be passed directly to init process.
> 
> Currently the kernel appends elfcorehdr=<paddr> to the cmdline passed from kexec
> load, and if this command-line is used to pass parameters to init process this
> means that 'elfcorehdr' will not be parsed as a kernel parameter at all which
> will be a problem for vmcore subsystem since it will know nothing about the
> location of the ELF structure!
> 
> Prepending 'elfcorehdr' instead of appending it fixes this problem since it
> ensures that it always comes before '--' and so it's always parsed as a kernel
> command-line parameter.
> 
> Even with this patch things can still go wrong if 'CONFIG_CMDLINE' was also used
> to embedd a command-line to the crash dump kernel and this command-line contains
> '--' since the current behavior of the kernel is to actually append the boot
> loader command-line to the embedded command-line.
> 
> Signed-off-by: KarimAllah Ahmed <karahmed@amazon.de>

Looks good to me. 

We might require a similar change in kexec-tools for old systemcall?

Acked-by: Vivek Goyal <vgoyal@redhat.com>

Thanks
Vivek

> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Cc: Haren Myneni <hbabu@us.ibm.com>
> Cc: Eric Biederman <ebiederm@xmission.com>
> ---
>  arch/x86/kernel/kexec-bzimage64.c |   11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
> index ca05f86..ca83f7ac 100644
> --- a/arch/x86/kernel/kexec-bzimage64.c
> +++ b/arch/x86/kernel/kexec-bzimage64.c
> @@ -72,15 +72,16 @@ static int setup_cmdline(struct kimage *image, struct boot_params *params,
>  			 unsigned long cmdline_len)
>  {
>  	char *cmdline_ptr = ((char *)params) + cmdline_offset;
> -	unsigned long cmdline_ptr_phys, len;
> +	unsigned long cmdline_ptr_phys, len = 0;
>  	uint32_t cmdline_low_32, cmdline_ext_32;
>  
> -	memcpy(cmdline_ptr, cmdline, cmdline_len);
>  	if (image->type == KEXEC_TYPE_CRASH) {
> -		len = sprintf(cmdline_ptr + cmdline_len - 1,
> -			" elfcorehdr=0x%lx", image->arch.elf_load_addr);
> -		cmdline_len += len;
> +		len = sprintf(cmdline_ptr,
> +			"elfcorehdr=0x%lx ", image->arch.elf_load_addr);
>  	}
> +	memcpy(cmdline_ptr + len, cmdline, cmdline_len);
> +	cmdline_len += len;
> +
>  	cmdline_ptr[cmdline_len - 1] = '\0';
>  
>  	pr_debug("Final command line is: %s\n", cmdline_ptr);
> -- 
> 1.7.9.5

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

      reply	other threads:[~2015-05-14 14:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 10:05 [PATCH] prepend elfcorehdr instead of appending it to the crash-kernel command-line KarimAllah Ahmed
2015-05-14 14:34 ` Vivek Goyal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150514143437.GD21327@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=aliguori@amazon.com \
    --cc=bhe@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=hbabu@us.ibm.com \
    --cc=hpa@zytor.com \
    --cc=karahmed@amazon.de \
    --cc=kexec@lists.infradead.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.