kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Pratyush Anand <panand@redhat.com>
Cc: Geoff Levand <geoff@infradead.org>,
	Simon Horman <horms@verge.net.au>,
	Kexec Mailing List <kexec@lists.infradead.org>
Subject: Re: [PATCH v3 1/8] arm64: identify PHYS_OFFSET correctly
Date: Wed, 28 Sep 2016 00:48:08 -0700	[thread overview]
Message-ID: <20160928074806.GA5232@localhost> (raw)
In-Reply-To: <CAHB_GuqcaGxj48RNW_72Q6tMgoat7oRG0LKg0S7mJs8=_Ft8Lw@mail.gmail.com>

On Tue, Sep 27, 2016 at 09:19:51PM +0530, Pratyush Anand wrote:
> On Wed, Sep 7, 2016 at 10:03 AM, AKASHI Takahiro
> <takahiro.akashi@linaro.org> wrote:
> > Due to the kernel patch[1], the current code will not be able to identify
> 
> [1] is mentioned in cover letter only, not here.

Oops, thanks.

> > the correct value of PHYS_OFFSET if some "reserved" memory region, which
> > is likely to be UEFI runtime services code/data, exists at an address below
> > the first "System RAM" regions.
> >
> > This patch fixes this issue.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  kexec/arch/arm64/iomem.h       |  7 +++++++
> >  kexec/arch/arm64/kexec-arm64.c | 22 +++++++++++++++++-----
> >  2 files changed, 24 insertions(+), 5 deletions(-)
> >  create mode 100644 kexec/arch/arm64/iomem.h
> >
> > diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h
> > new file mode 100644
> > index 0000000..7fd66eb
> > --- /dev/null
> > +++ b/kexec/arch/arm64/iomem.h
> > @@ -0,0 +1,7 @@
> > +#ifndef IOMEM_H
> > +#define IOMEM_H
> > +
> > +#define SYSTEM_RAM             "System RAM\n"
> > +#define IOMEM_RESERVED         "reserved\n"
> > +
> > +#endif
> > diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
> > index 7183dac..bc96c76 100644
> > --- a/kexec/arch/arm64/kexec-arm64.c
> > +++ b/kexec/arch/arm64/kexec-arm64.c
> > @@ -21,6 +21,7 @@
> >  #include "crashdump-arm64.h"
> >  #include "dt-ops.h"
> >  #include "fs2dt.h"
> > +#include "iomem.h"
> >  #include "kexec-syscall.h"
> >  #include "arch/options.h"
> >
> > @@ -465,18 +466,28 @@ void add_segment(struct kexec_info *info, const void *buf, size_t bufsz,
> >   * get_memory_ranges_iomem_cb - Helper for get_memory_ranges_iomem.
> >   */
> >
> > +static int count_memory_ranges;
> 
> IMHO improving definition of kexec_iomem_for_each_line() and
> callback() for handling NULL match case would have been a better
> choice than introducing a new static variable. callback() can return
> -ve in case of error, 0 in case of no match and 1 in case of (one)
> match.

Maybe. But we have to be careful not to change other arch's results.
Or follow arm's approach.

-Takahiro AKASHI

> ~Pratyush
> 
> > +
> >  static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
> >         unsigned long long base, unsigned long long length)
> >  {
> >         struct memory_range *r;
> >
> > -       if (nr >= KEXEC_SEGMENT_MAX)
> > +       if (count_memory_ranges >= KEXEC_SEGMENT_MAX)
> >                 return -1;
> >
> > -       r = (struct memory_range *)data + nr;
> > -       r->type = RANGE_RAM;
> > +       r = (struct memory_range *)data + count_memory_ranges;
> > +
> > +       if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)))
> > +               r->type = RANGE_RAM;
> > +       else if (!strncmp(str, IOMEM_RESERVED, strlen(IOMEM_RESERVED)))
> > +               r->type = RANGE_RESERVED;
> > +       else
> > +               return 0;
> > +
> >         r->start = base;
> >         r->end = base + length - 1;
> > +       count_memory_ranges++;
> >
> >         set_phys_offset(r->start);
> >
> > @@ -493,9 +504,10 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
> >  static int get_memory_ranges_iomem(struct memory_range *array,
> >         unsigned int *count)
> >  {
> > -       *count = kexec_iomem_for_each_line("System RAM\n",
> > -               get_memory_ranges_iomem_cb, array);
> > +       count_memory_ranges = 0;
> > +       kexec_iomem_for_each_line(NULL, get_memory_ranges_iomem_cb, array);
> >
> > +       *count = count_memory_ranges;
> >         if (!*count) {
> >                 dbgprintf("%s: failed: No RAM found.\n", __func__);
> >                 return -EFAILED;
> > --
> > 2.9.0
> >

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

  reply	other threads:[~2016-09-28  7:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07  4:33 [PATCH v3 0/8] (kexec-tools) arm64: add kdump support AKASHI Takahiro
2016-09-07  4:33 ` [PATCH v3 1/8] arm64: identify PHYS_OFFSET correctly AKASHI Takahiro
2016-09-27 15:49   ` Pratyush Anand
2016-09-28  7:48     ` AKASHI Takahiro [this message]
2016-10-24 23:02       ` Goel, Sameer
2016-09-07  4:33 ` [PATCH v3 2/8] kexec: generalize and rename get_kernel_stext_sym() AKASHI Takahiro
2016-10-06 13:28   ` Matthias Brugger
2016-10-07  4:18     ` Dave Young
2016-10-07  6:41       ` Pratyush Anand
2016-10-07  6:44     ` Pratyush Anand
2016-09-07  4:33 ` [PATCH v3 3/8] arm64: kdump: identify memory regions AKASHI Takahiro
2016-09-07  4:33 ` [PATCH v3 4/8] arm64: kdump: add elf core header segment AKASHI Takahiro
2016-09-07  4:33 ` [PATCH v3 5/8] arm64: kdump: set up kernel image segment AKASHI Takahiro
2016-09-07  4:33 ` [PATCH v3 6/8] arm64: kdump: set up other segments AKASHI Takahiro
2016-09-07  4:34 ` [PATCH v3 7/8] arm64: kdump: add DT properties to crash dump kernel's dtb AKASHI Takahiro
2016-09-07  4:34 ` [PATCH v3 8/8] arm64: kdump: Add support for binary image files AKASHI Takahiro
2016-09-29  7:52 ` [PATCH v3 0/8] (kexec-tools) arm64: add kdump support Simon Horman
2016-09-29  8:18   ` AKASHI Takahiro
2016-09-29  8:39     ` Simon Horman
2016-09-29 14:26       ` AKASHI Takahiro

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=20160928074806.GA5232@localhost \
    --to=takahiro.akashi@linaro.org \
    --cc=geoff@infradead.org \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=panand@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;
as well as URLs for NNTP newsgroup(s).