mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: kexec@lists.infradead.org, Eric Biederman <ebiederm@xmission.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Put each per-cpu kdump ELF notes into a single page
Date: Fri, 12 Sep 2014 00:15:37 +0200	[thread overview]
Message-ID: <20140912001537.5f877fe7@hananiah.suse.cz> (raw)
In-Reply-To: <20140911211637.GF17140@redhat.com>

On Thu, 11 Sep 2014 17:16:37 -0400
Vivek Goyal <vgoyal@redhat.com> wrote:

> On Thu, Sep 11, 2014 at 10:43:30PM +0200, Petr Tesarik wrote:
> > On Thu, 11 Sep 2014 16:01:10 -0400
> > Vivek Goyal <vgoyal@redhat.com> wrote:
> > 
> > > On Fri, Sep 05, 2014 at 06:33:14PM +0200, Petr Tesarik wrote:
> > > > On architectures that use percpu-vm, the percpu region is not guaranteed
> > > > to be contiguous in physical space.
> > > 
> > > Petr,
> > > 
> > > Which are those arches?
> > 
> > All except nommu. Actually, percpu-km will be used instead even on MMU
> > if SMP is disabled, but since SMP is pretty standard now, I guess the
> > vast majority of all kernels out there is affected. ;-)
> 
> Hi Petr,
> 
> To make sure I understand it correctly I will just summarize what you
> said.
> 
> alloc_percpu() code does not guarantee that an object will be on physically
> contiguous pages if object crosses page boundary. That's why we are forcing
> allocation of object aligned to nearest higher power of two boundary of
> object size and that way object will always be on same page (as long as object
> is not bigger than a page).
> 
> Is that a fair summary?

Yes. I might add a note why physically contiguous memory is needed
here, but maybe it's obvious to anyone dealing with kdump.

Thanks,
Petr Tesarik

> Thanks
> Vivek
>  
> > 
> > > > However, fs/proc/vmcore.c expects
> > > > all ELF notes to be contiguous. If the ELF note happens to occupy
> > > > two non-adjacent physical pages, part of the note may be read from an
> > > > incorrect memory location by the kdump kernel, resulting in failure to
> > > > initialize /proc/vmcore (if the content of the following physical page,
> > > > incorrectly interpreted as an ELF note specifies a large number), wrong
> > > > register values or other apparent random memory corruption.
> > > > 
> > > > There is currently no mechanism to pass the virtual-to-physical mapping
> > > > of the percpu allocation to the kdump kernel. So, instead, I'm changing
> > > > the alignment of the ELF note buffer. Since sizeof(note_buf_t) is less
> > > > than PAGE_SIZE, aligning the buffer to the nearest higher power of 2
> > > > is enough to make sure that the buffer cannot cross a page boundary,
> > > > effectively ensuring that the whole buffer is contiguous in physical
> > > > space.
> > > > 
> > > > Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> > > > ---
> > > >  kernel/kexec.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/kernel/kexec.c b/kernel/kexec.c
> > > > index 2bee072..cdab59d 100644
> > > > --- a/kernel/kexec.c
> > > > +++ b/kernel/kexec.c
> > > > @@ -1610,7 +1610,8 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
> > > >  static int __init crash_notes_memory_init(void)
> > > >  {
> > > >  	/* Allocate memory for saving cpu registers. */
> > > > -	crash_notes = alloc_percpu(note_buf_t);
> > > > +	crash_notes = __alloc_percpu(sizeof(note_buf_t),
> > > > +				     roundup_pow_of_two(sizeof(note_buf_t)));
> > > 
> > > I think some of the changelog should show up here as comment in short
> > > form. I don't think it is obvious that why we are using __alloc_percpu()
> > > and why aligning to nearst higher power of 2 is needed here. Please also
> > > mention here which arches run into issues.
> > 
> > OK, I'll add it as a comment in the code. I'll see if I can make it
> > short but still understandable.
> > 
> > Thanks,
> > Petr Tesarik
> > 
> > > Thanks
> > > Vivek
> > > 
> > > >  	if (!crash_notes) {
> > > >  		pr_warn("Kexec: Memory allocation for saving cpu register states failed\n");
> > > >  		return -ENOMEM;
> > > > -- 
> > > > 1.8.4.5
> > > > 
> > > > _______________________________________________
> > > > kexec mailing list
> > > > kexec@lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/kexec
> > > 
> > > _______________________________________________
> > > kexec mailing list
> > > kexec@lists.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/kexec
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec


  reply	other threads:[~2014-09-11 22:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 16:33 Petr Tesarik
2014-09-11 19:37 ` Petr Tesarik
2014-09-11 20:01 ` Vivek Goyal
2014-09-11 20:43   ` Petr Tesarik
2014-09-11 21:16     ` Vivek Goyal
2014-09-11 22:15       ` Petr Tesarik [this message]
2014-09-12 11:52         ` Vivek Goyal

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=20140912001537.5f877fe7@hananiah.suse.cz \
    --to=ptesarik@suse.cz \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgoyal@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®