From: Reuben Dowle <reuben.dowle@4rf.com>
To: u-boot@lists.denx.de
Subject: [PATCH] Fix data abort caused by mis-aligning fit data in
Date: Mon, 24 Aug 2020 20:05:24 +0000 [thread overview]
Message-ID: <d7e904965fdf4620b73b793c5650f6eb@4rf.com> (raw)
In-Reply-To: <20200824142644.GA13719@bill-the-cat>
Should I submit a new patch with the alignment set to 8 bytes? I would think a hard coded 8 bytes would not be the best solution, since not all architectures will need that much alignment. I suspect some would work with any alignment, and most 32-bit archs would be fine with 4-byte alignment.
Our released software is actually using a patch to align to 4096 bytes, but I knew that was unnecessarily large. I was not really sure what would be an appropriate value here, and took a guess at ARCH_DMA_MINALIGN when I cleaned it up for submitting upstream. Is there a better define to use?
I am also interested to know where the 8 byte alignment requirement is documented.
Reuben
> -----Original Message-----
> From: Tom Rini <trini@konsulko.com>
> Sent: Tuesday, 25 August 2020 2:27 am
> To: Reuben Dowle <reuben.dowle@4rf.com>
> Cc: u-boot at lists.denx.de
> Subject: Re: [PATCH] Fix data abort caused by mis-aligning fit data in
>
> On Fri, Jul 24, 2020 at 05:19:39AM +0000, Reuben Dowle wrote:
>
> > Attempting to place device tree immediately after an image in memory
> > can lead to mis-aligned data accesses if that image size is not
> > divisible by the alignment requirements of the architecture.
> >
> > Data aborts caused by this were observed on a custom Marvel A388 based
> > system, where the image was a uboot FIT file. The total size varies
> > depending on the uboot device tree size, which does not always lead to
> correct alignment.
> >
> > Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
> > ---
> > common/spl/spl_fit.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index
> > 365104f..d221075 100644
> > --- a/common/spl/spl_fit.c
> > +++ b/common/spl/spl_fit.c
> > @@ -349,9 +349,9 @@ static int spl_fit_append_fdt(struct
> > spl_image_info *spl_image,
> >
> > /*
> > * Use the address following the image as target address for the
> > - * device tree.
> > + * device tree. Ensure that address is appropriately aligned.
> > */
> > - image_info.load_addr = spl_image->load_addr + spl_image->size;
> > + image_info.load_addr = ALIGN(spl_image->load_addr + spl_image-
> >size,
> > +ARCH_DMA_MINALIGN);
> >
> > /* Figure out which device tree the board wants to use */
> > node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
> index++);
>
> Sorry for the late reply here. While we do need to ensure that the device
> tree is aligned, the documented alignment requirement for all platforms is 8
> byte, so we should document and use that here in case future platforms
> require a higher alignment. Thanks!
>
> --
> Tom
next prev parent reply other threads:[~2020-08-24 20:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 5:19 [PATCH] Fix data abort caused by mis-aligning fit data in Reuben Dowle
2020-08-24 14:26 ` Tom Rini
2020-08-24 20:05 ` Reuben Dowle [this message]
2020-08-24 20:39 ` Tom Rini
2020-08-24 21:18 ` Reuben Dowle
2020-08-24 21:22 ` Tom Rini
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=d7e904965fdf4620b73b793c5650f6eb@4rf.com \
--to=reuben.dowle@4rf.com \
--cc=u-boot@lists.denx.de \
/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