All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Dave Martin <dave.martin@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [ARM] Use AT() in the linker script to create correct program headers
Date: Wed, 3 Oct 2012 12:44:38 -0600	[thread overview]
Message-ID: <20121003184437.GB12231@obsidianresearch.com> (raw)
In-Reply-To: <20121003104335.GA2254@linaro.org>

On Wed, Oct 03, 2012 at 11:43:35AM +0100, Dave Martin wrote:

> I'm not sure exactly what you mean by linking the DTB into vmlinux.
> I don't think this is supported upstream, at least for ARM.  It could
> be done externally by post-processing vmlinux to add extra sections
> and some boot shim code which initialises the registers appropriately
> for kernel entry ... but you're really inventing a bootloader if you
> start to do that.

We use the existing build infrastructure (see cmd_dt_S_dtb) and add a
4 line patch to head.S to put the dtb address into the right
register. I think it would be great to have a CONFIG_ARM_BUILT_IN_DTB
for applications like mine, but it is really no problem to carry the
head.S patch. The normal build process produces a vmlinux that is self
contained, no post processing required.

> Making a simple bootloader DT-aware is not actually that hard: libfdt
> is intentionally pretty straightforward to integrate.

Sure, but we have several major issues with that entire idea:
 1) Our bootloader (on PPC and ARM) is in redundant NOR flash and
    is limited to 16K. That is just enough to do gzip, elf, cramfs
    and tftpv6 - there is no space left for dtb or fdt code.
 2) Experience using DT with PPC has shown that the vmlinux is very
    sensitive to the DTB. Every DTB/vmlinux combination must be tested
    to ensure it works. By far the best way to manage this *for us* is
    to guarentee that the vmlinux sees only the DTB it was designed
    for by including it in vmlinux.
 3) The DTB *changes*. We change it because we've changed things in the
    programmable part of our environment and we change it because the
    kernel has shifted. Planning for this inevitable change is
    necessary.
 4) On our ARM platforms updating the boot loader in the field is more
    challenging than updating the vmlinux, not impossible, but not
    something we want to do every day. Our PPC boot loader has
    survived without change since 2007, and has booted kernels from
    2.6.12 to 3.6 with and without DT. This is a time tested,
    field proven approach.

Fundamentally we treat the DTB like the .config - an integral,
internal, part of vmlinux.

As far as I can see, the *only* argument to put the DT in the boot
loader is to support standard, distribution kernels.

> It's more than 100 lines, but not _that_ much more, and contains
> some implementation features you probably don't need.

But that is not enough, variations of our platforms use bit bang I2C,
SPI and NOR FLASH to store things like the MAC address and other
DT-relevant information. So, swaths of that code would need to go into
the boot loader/zImage as well.

At that point we may as well take our chances with uBoot. :)

> From my side, I think that the fact this takes arch/arm/vmlinux.lds.S
> closer to some other common arches means that this is low risk and should
> be mostly harmless, but I will take another look at the patch first.

This matches my opinion..

> > > You store vmlinux.gz in a cramfs?  Is that a typo, or have you already
> > > compressed the kernel twice?
> > 
> > The compression can either be intrisic to cramfs or a raw elf that has
> > been gzip'd.
> 
> If you can have files with intrinsic compression such that they don't
> get double-compressed, why can you not do this for zImage?
> 
> Am I still misunderstanding something?

We have two boot modes, one boots ELF.gz (for development), the other
boots ELF in CRAMFS (for deployment). Both are compressed, one is
compressed using gzip and one is compressed using zlib in CRAMFS. It
is hard to see how to store a zImage in CRAMFS and avoid double
de-compression. We never store an ELF.gz in CRAMFS.

Since the entire point of zImage is to introduce compression it is
hard to see *why* we'd want to store a zImage in a CRAMFS.

Jason

WARNING: multiple messages have this Message-ID (diff)
From: jgunthorpe@obsidianresearch.com (Jason Gunthorpe)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] [ARM] Use AT() in the linker script to create correct program headers
Date: Wed, 3 Oct 2012 12:44:38 -0600	[thread overview]
Message-ID: <20121003184437.GB12231@obsidianresearch.com> (raw)
In-Reply-To: <20121003104335.GA2254@linaro.org>

On Wed, Oct 03, 2012 at 11:43:35AM +0100, Dave Martin wrote:

> I'm not sure exactly what you mean by linking the DTB into vmlinux.
> I don't think this is supported upstream, at least for ARM.  It could
> be done externally by post-processing vmlinux to add extra sections
> and some boot shim code which initialises the registers appropriately
> for kernel entry ... but you're really inventing a bootloader if you
> start to do that.

We use the existing build infrastructure (see cmd_dt_S_dtb) and add a
4 line patch to head.S to put the dtb address into the right
register. I think it would be great to have a CONFIG_ARM_BUILT_IN_DTB
for applications like mine, but it is really no problem to carry the
head.S patch. The normal build process produces a vmlinux that is self
contained, no post processing required.

> Making a simple bootloader DT-aware is not actually that hard: libfdt
> is intentionally pretty straightforward to integrate.

Sure, but we have several major issues with that entire idea:
 1) Our bootloader (on PPC and ARM) is in redundant NOR flash and
    is limited to 16K. That is just enough to do gzip, elf, cramfs
    and tftpv6 - there is no space left for dtb or fdt code.
 2) Experience using DT with PPC has shown that the vmlinux is very
    sensitive to the DTB. Every DTB/vmlinux combination must be tested
    to ensure it works. By far the best way to manage this *for us* is
    to guarentee that the vmlinux sees only the DTB it was designed
    for by including it in vmlinux.
 3) The DTB *changes*. We change it because we've changed things in the
    programmable part of our environment and we change it because the
    kernel has shifted. Planning for this inevitable change is
    necessary.
 4) On our ARM platforms updating the boot loader in the field is more
    challenging than updating the vmlinux, not impossible, but not
    something we want to do every day. Our PPC boot loader has
    survived without change since 2007, and has booted kernels from
    2.6.12 to 3.6 with and without DT. This is a time tested,
    field proven approach.

Fundamentally we treat the DTB like the .config - an integral,
internal, part of vmlinux.

As far as I can see, the *only* argument to put the DT in the boot
loader is to support standard, distribution kernels.

> It's more than 100 lines, but not _that_ much more, and contains
> some implementation features you probably don't need.

But that is not enough, variations of our platforms use bit bang I2C,
SPI and NOR FLASH to store things like the MAC address and other
DT-relevant information. So, swaths of that code would need to go into
the boot loader/zImage as well.

At that point we may as well take our chances with uBoot. :)

> From my side, I think that the fact this takes arch/arm/vmlinux.lds.S
> closer to some other common arches means that this is low risk and should
> be mostly harmless, but I will take another look at the patch first.

This matches my opinion..

> > > You store vmlinux.gz in a cramfs?  Is that a typo, or have you already
> > > compressed the kernel twice?
> > 
> > The compression can either be intrisic to cramfs or a raw elf that has
> > been gzip'd.
> 
> If you can have files with intrinsic compression such that they don't
> get double-compressed, why can you not do this for zImage?
> 
> Am I still misunderstanding something?

We have two boot modes, one boots ELF.gz (for development), the other
boots ELF in CRAMFS (for deployment). Both are compressed, one is
compressed using gzip and one is compressed using zlib in CRAMFS. It
is hard to see how to store a zImage in CRAMFS and avoid double
de-compression. We never store an ELF.gz in CRAMFS.

Since the entire point of zImage is to introduce compression it is
hard to see *why* we'd want to store a zImage in a CRAMFS.

Jason

  reply	other threads:[~2012-10-03 18:44 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-30 23:21 [PATCH] [ARM] Use AT() in the linker script to create correct program headers Jason Gunthorpe
2012-09-30 23:21 ` Jason Gunthorpe
2012-10-01 15:39 ` Dave Martin
2012-10-01 15:39   ` Dave Martin
2012-10-01 16:06   ` Jason Gunthorpe
2012-10-01 16:06     ` Jason Gunthorpe
2012-10-01 17:56     ` Dave Martin
2012-10-01 17:56       ` Dave Martin
2012-10-01 18:35       ` Jason Gunthorpe
2012-10-01 18:35         ` Jason Gunthorpe
2012-10-02 10:23         ` Dave Martin
2012-10-02 10:23           ` Dave Martin
2012-10-02 17:47           ` Jason Gunthorpe
2012-10-02 17:47             ` Jason Gunthorpe
2012-10-03 10:43             ` Dave Martin
2012-10-03 10:43               ` Dave Martin
2012-10-03 18:44               ` Jason Gunthorpe [this message]
2012-10-03 18:44                 ` Jason Gunthorpe
2012-10-04 11:36                 ` Dave Martin
2012-10-04 11:36                   ` Dave Martin
2012-10-04 17:59                   ` Jason Gunthorpe
2012-10-04 17:59                     ` Jason Gunthorpe
2012-10-08 10:46                     ` Dave Martin
2012-10-08 10:46                       ` Dave Martin
2012-10-09 18:25                       ` Jason Gunthorpe
2012-10-09 18:25                         ` Jason Gunthorpe
2012-10-10  9:55                         ` Dave Martin
2012-10-10  9:55                           ` Dave Martin
2012-10-12 21:24                           ` Jason Gunthorpe
2012-10-12 21:24                             ` Jason Gunthorpe
2012-10-05  8:45     ` Russell King - ARM Linux
2012-10-05  8:45       ` Russell King - ARM Linux
2012-10-08 10:24       ` Dave Martin
2012-10-08 10:24         ` Dave Martin
2012-10-09 17:37         ` Jason Gunthorpe
2012-10-09 17:37           ` Jason Gunthorpe
2012-10-10  9:18           ` Dave Martin
2012-10-10  9:18             ` Dave Martin

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=20121003184437.GB12231@obsidianresearch.com \
    --to=jgunthorpe@obsidianresearch.com \
    --cc=dave.martin@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.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.