public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] bootm: flush cache on aligned region
@ 2017-12-20 17:12 your name
  2017-12-21  7:18 ` Lothar Waßmann
  0 siblings, 1 reply; 2+ messages in thread
From: your name @ 2017-12-20 17:12 UTC (permalink / raw)
  To: u-boot

From: Andrey Yurovsky <yurovsky@gmail.com>

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.

Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
---
 common/bootm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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, unsigned long *load_end,
 		bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 		return err;
 	}
-	flush_cache(load, ALIGN(*load_end - load, ARCH_DMA_MINALIGN));
+
+	ulong load_a = ALIGN(load, ARCH_DMA_MINALIGN);
+
+	flush_cache(load_a, ALIGN(*load_end - load_a, ARCH_DMA_MINALIGN));
 
 	debug("   kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end);
 	bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED);
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] bootm: flush cache on aligned region
  2017-12-20 17:12 [U-Boot] [PATCH] bootm: flush cache on aligned region your name
@ 2017-12-21  7:18 ` Lothar Waßmann
  0 siblings, 0 replies; 2+ messages in thread
From: Lothar Waßmann @ 2017-12-21  7:18 UTC (permalink / raw)
  To: u-boot

Hi your name,

On Wed, 20 Dec 2017 09:12:28 -0800 your name wrote:
> From: Andrey Yurovsky <yurovsky@gmail.com>
> 
> 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.
> 
> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
> ---
>  common/bootm.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 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, unsigned long *load_end,
>  		bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
>  		return err;
>  	}
> -	flush_cache(load, ALIGN(*load_end - load, ARCH_DMA_MINALIGN));
> +
> +	ulong load_a = 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));
>  
>  	debug("   kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end);
>  	bootstage_mark(BOOTSTAGE_ID_KERNEL_LOADED);


Lothar Waßmann

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-21  7:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-20 17:12 [U-Boot] [PATCH] bootm: flush cache on aligned region your name
2017-12-21  7:18 ` Lothar Waßmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox