From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Thu, 21 Dec 2017 08:18:53 +0100 Subject: [U-Boot] [PATCH] bootm: flush cache on aligned region In-Reply-To: <20171220171228.16270-1-yurovsky@gmail.com> References: <20171220171228.16270-1-yurovsky@gmail.com> Message-ID: <20171221081853.0ebfba68@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi your name, On Wed, 20 Dec 2017 09:12:28 -0800 your name wrote: > From: Andrey Yurovsky >=20 > bootm_load_os() uses flush_cache() on the region where the OS image is > loaded however the OS image may be part of a FIT image and thereby may > not be aligned with respect to the machine's cache lines. Give > flush_cache() an aligned start of the region to avoid misalignment. >=20 > Signed-off-by: Andrey Yurovsky > --- > common/bootm.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/common/bootm.c b/common/bootm.c > index adb12137c7..948807af25 100644 > --- a/common/bootm.c > +++ b/common/bootm.c > @@ -447,7 +447,10 @@ static int bootm_load_os(bootm_headers_t *images, un= signed long *load_end, > bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); > return err; > } > - flush_cache(load, ALIGN(*load_end - load, ARCH_DMA_MINALIGN)); > + > + ulong load_a =3D ALIGN(load, ARCH_DMA_MINALIGN); > + This is WRONG. ALIGN() only ever _increases_ the value passed to it, so the first ARCH_DMA_MINALIGN - 1 bytes of the image may not be flushed in the worst case. > + flush_cache(load_a, ALIGN(*load_end - load_a, ARCH_DMA_MINALIGN)); > =20 > debug(" kernel loaded at 0x%08lx, end =3D 0x%08lx\n", load, *load_end= ); > bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED); Lothar Wa=C3=9Fmann