public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1 3/4] arm64: Add arm64 kexec support
Date: Thu, 21 Jul 2016 11:31:21 +0100	[thread overview]
Message-ID: <20160721103120.GB20559@leverpostej> (raw)
In-Reply-To: <1469042361.2977.90.camel@infradead.org>

On Wed, Jul 20, 2016 at 12:19:21PM -0700, Geoff Levand wrote:
> > > +static uint64_t read_sink(const char *command_line)
> > > +{
> > > +> > 	> > uint64_t v;
> > > +> > 	> > const char *p;
> > > +
> > > +> > 	> > if (arm64_opts.port)
> > > +> > 	> > 	> > return arm64_opts.port;
> > > +
> > > +#if defined(ARM64_DEBUG_PORT)
> > > +> > 	> > return (uint64_t)(ARM64_DEBUG_PORT);
> > > +#endif
> > > +> > 	> > if (!command_line)
> > > +> > 	> > 	> > return 0;
> > > +
> > > +> > 	> > if (!(p = strstr(command_line, "earlyprintk=")) &&
> > > +> > 	> > 	> > !(p = strstr(command_line, "earlycon=")))
> > > +> > 	> > 	> > return 0;
> > > +
> > > +> > 	> > while (*p != ',')
> > > +> > 	> > 	> > p++;
> > > +
> > > +> > 	> > p++;
> > > +
> > > +> > 	> > while (isspace(*p))
> > > +> > 	> > 	> > p++;
> > 
> > Why do we skip spaces? As far as I am aware, there should not be any
> > spaces in the option.
> 
> Sure, I can remove it.
> 
> > > +
> > > +> > 	> > if (*p == 0)
> > > +> > 	> > 	> > return 0;
> > > +
> > > +> > 	> > errno = 0;
> > > +
> > > +> > 	> > v = strtoull(p, NULL, 0);
> > > +
> > > +> > 	> > if (errno)
> > > +> > 	> > 	> > return 0;
> > > +
> > > +> > 	> > return v;
> > > +}
> > 
> > It looks like the purgatory code expects angel SWI as the earlycon,
> 
> Maybe you saw the debug_brk macro in entry.S?  I should remove
> that and just loop.

Ah, sorry. For some reason I got that confused with the sink code. My
bad.

Now I see that's assuming an 8-bit MMIO register.

> > whereas many other earlycons exist (with pl011 being extremely popular).
> > Regardless, if we assume a particular UART type, we should explicitly
> > verify that here. Otherwise the purgatory code will likely bring down
> > the system, and it will be very painful to debug.
> > 
> > Please explicitly check for the supported earlycon name.
> 
> Purgatory just writes bytes to the address given.  Are there
> UARTs that don't have TX as the first port?

I'm not sure, but it's certainly possible. The generic earlycon binding
doesn't guarantee that the first address is a TX register. Even if they
don't exist today, they could in a month's time, so I don't think we
should assume anything.

Additionally, the width of that TX register can differ (e.g.
uart8250,mmio vs uart8250,mmio32), and some UARTs aren't very forgiving
if accessed with the wrong width.

> To be safe, we could do a check when we get the address from
> an earlycon parameter. 

Yup. I think you need a whitelist of UARTs that can be handled, along
with parsing for their options (e.g. mmio vs mmio32), giving up if
unknown options are spotted.

> Here's what I found in the dts'.  The
> first three are OK, but I don't know about the others.  

I believe you can find the full set with:

$ git grep EARLYCON_DECLARE

[...]

> > > +> > 	> > if (result)
> > > +> > 	> > 	> > fprintf(stderr, "kexec: Warning: No device tree available.\n");
> > 
> > There are other reasons we'd return an error (e.g. mismatched enable
> > methods), so this is somewhat misleading.
> > 
> > I believe that in all cases we log the specific reason first anyway, so
> > perhaps it's best to jsut remove this warning.
> 
> Yes, this could be removed.
> 
> > Won't this also be very noisy in the case of ACPI with a stub DTB? In
> > that case ther are no cpu nodes, and may be no memory nodes.
> 
> Should we just remove check_cpu_nodes and everything associated with
> it?  It is a lot of code, and all it does now is issue warnings.
> It is still around from the early days of spin_table support.  

That sounds fine to me.

> As for memory nodes, we currently look at the dt, then fall back
> to iomem. We could switch the order, iomem then dt, but then
> those just issue dbgprintf's.

Sure.

> > > +int arm64_process_image_header(const struct arm64_image_header *h)
> > > +{
> > > +#if !defined(KERNEL_IMAGE_SIZE)
> > > +# define KERNEL_IMAGE_SIZE (768 * 1024)
> > > +#endif
> > > +
> > > +> > 	> > if (!arm64_header_check_magic(h))
> > > +> > 	> > 	> > return -EINVAL;
> > > +
> > > +> > 	> > if (h->image_size) {
> > > +> > 	> > 	> > arm64_mem.text_offset = le64_to_cpu(h->text_offset);
> > > +> > 	> > 	> > arm64_mem.image_size = le64_to_cpu(h->image_size);
> > > +> > 	> > } else {
> > > +> > 	> > 	> > /* For 3.16 and older kernels. */
> > > +> > 	> > 	> > arm64_mem.text_offset = 0x80000;
> > > +> > 	> > 	> > arm64_mem.image_size = KERNEL_IMAGE_SIZE;
> > > +> > 	> > }
> > > +
> > > +> > 	> > return 0;
> > > +}
> > 
> > A v3.16 defconfig Image with the Linaro 14.09 GCC 4.9 toolchain is
> > 6.3MB, so the chosen value for KERNEL_IMAGE_SIZE is far too small. I'm
> > not sure what to suggest as a better value, however, as I know that some
> > configurations are far bigger than that.
> 
> OK, I'll make it bigger, say 7.  When I set this up I expected
> the distro maintainer to choose KERNEL_IMAGE_SIZE to match their
> needs.

To give some headroom, bumping to 16 or so is probably a safer bet.

Perhaps it's worth logging a warning that we're guessing the effective
image size in this case? That could avoid a lot of head-scratching if
things do end up overlapping.

> > Do we expect to kexec to a v3.16 or earlier kernel, given we need a much
> > newer first kernel to have kexec in the first place? We could mandate
> > having a header with a non-zero image_size (i.e. the target kernel has
> > to be v3.16 or newer).
> 
> Kexec could be installed as a bootloader, and users may want the
> ability to boot older installations, so I think it worthwile to
> have.

Sure. I was under the impression that most distros had chosen v3.16 or
later, but I have no problem with trying to support earlier kernels.

Thanks,
Mark.

  reply	other threads:[~2016-07-21 10:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-19 23:28 [PATCH v1 0/4] arm64 kexec-tools patches Geoff Levand
2016-07-19 23:28 ` [PATCH v1 2/4] kexec: Add common device tree routines Geoff Levand
2016-07-22  7:19   ` AKASHI Takahiro
2016-07-27 18:11     ` Geoff Levand
2016-07-19 23:28 ` [PATCH v1 1/4] kexec: (bugfix) calc correct end address of memory ranges in device tree Geoff Levand
2016-07-27 22:45   ` Thiago Jung Bauermann
2016-07-27 23:23     ` Russell King - ARM Linux
2016-07-28 23:54       ` Thiago Jung Bauermann
2016-07-29  8:27         ` Russell King - ARM Linux
2016-07-29 17:12           ` Geoff Levand
2016-07-29 17:23             ` Russell King - ARM Linux
2016-08-01  4:52               ` AKASHI Takahiro
2016-09-06  0:29                 ` Memory range end be inclusive or exclusive? " AKASHI Takahiro
2016-10-31  8:50                   ` AKASHI Takahiro
2016-11-07  8:17                     ` Simon Horman
2016-07-19 23:28 ` [PATCH v1 4/4] arm64: Add support for binary image files Geoff Levand
2016-07-19 23:28 ` [PATCH v1 3/4] arm64: Add arm64 kexec support Geoff Levand
2016-07-20 15:39   ` Mark Rutland
2016-07-20 19:19     ` Geoff Levand
2016-07-21 10:31       ` Mark Rutland [this message]
2016-07-21 10:50         ` Robin Murphy
2016-07-21 21:49           ` Geoff Levand
2016-07-22  4:08             ` Pratyush Anand
2016-07-22  5:33               ` AKASHI Takahiro
2016-07-22  9:54               ` Mark Rutland
2016-07-22 10:03               ` Robin Murphy
2016-07-22 13:56                 ` Pratyush Anand
2016-07-22 17:59                   ` Robin Murphy
2016-07-25 21:56                 ` Geoff Levand
2016-07-20 17:53   ` Pratyush Anand
2016-07-20 20:33     ` Geoff Levand
2016-07-20 20:54   ` [PATCH v1.2 " Geoff Levand
2016-07-22  7:12     ` AKASHI Takahiro
2016-07-26  0:37       ` Geoff Levand
2016-07-25 14:28     ` Ruslan Bilovol
2016-07-25 20:50       ` Geoff Levand
2016-07-26  1:36         ` Ruslan Bilovol
2016-07-26  8:16           ` AKASHI Takahiro
2016-07-26 21:26             ` Ruslan Bilovol
2016-07-26 21:54               ` Geoff Levand
2016-07-20  4:30 ` [PATCH v1 0/4] arm64 kexec-tools patches AKASHI Takahiro
2016-07-26 23:05 ` Simon Horman
2016-07-27  5:57   ` AKASHI Takahiro
2016-07-28 18:09   ` Geoff Levand
2016-07-29  0:31     ` Simon Horman

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=20160721103120.GB20559@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox