bootm: flush cache on aligned region
PATCH 1/1 bootm: flush cache on aligned region
From: Andrey Yurovsky <[email protected]>
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.
--- common/bootm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
common/bootm.c +4 -1
@@ -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 );
Signature · 1 line
2.14.3
PATCH 1/1 bootm: flush cache on aligned region
Hi your name,
Quoted 17 lines · On Wed, 20 Dec 2017 09:12:28 -0800 your name wrote:
From: Andrey Yurovsky <[email protected]>
bootm_load_os()usesflush_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. Giveflush_cache()an aligned start of the region to avoid misalignment.Signed-off-by Andrey Yurovsky <[email protected]>--- common/bootm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)common/bootm.c +0
-0
common/bootm.c static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end, · line 452
Quoted 7 lines
common/bootm.c +3
-1@@ -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.
common/bootm.c static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end, · line 456
Quoted 4 lines
common/bootm.c +1
-0+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