summaryrefslogtreecommitdiff
path: root/cmd/elf.c
diff options
context:
space:
mode:
authorKurban Mallachiev <mallachiev@ispras.ru>2019-02-07 14:19:45 +0300
committerTom Rini <trini@konsulko.com>2019-02-19 08:55:43 -0500
commit957f51e86367e14be9e40cfe5cc3a494fc17abcf (patch)
tree048c49cbee2c09a6d8230e5889e3b17264557930 /cmd/elf.c
parenteaba7df7041ebdd6cff3702d87d6bdb6870ec5e3 (diff)
downloadu-boot-957f51e86367e14be9e40cfe5cc3a494fc17abcf.tar.gz
u-boot-957f51e86367e14be9e40cfe5cc3a494fc17abcf.tar.bz2
u-boot-957f51e86367e14be9e40cfe5cc3a494fc17abcf.zip
elf: fix cache flushing in 'bootelf -p' command
Currently there are two problems in 'bootelf -p' (load elf by segments) command: - bss section is not flushed, so booted elf can have non zero values in bss; - at least on ARM there are 'CACHE: Misaligned operation at range...' warnings Use p_memsz instead of p_filesz during cache flushing for elf segment. p_filesz doesn't include zero initialized memory (e.g. bss section), which also should be flushed. Align these cache flushes to line boundaries. Signed-off-by: Kurban Mallachiev <mallachiev@ispras.ru>
Diffstat (limited to 'cmd/elf.c')
-rw-r--r--cmd/elf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd/elf.c b/cmd/elf.c
index 7bad1f80d4..d883be4193 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -53,7 +53,8 @@ static unsigned long load_elf64_image_phdr(unsigned long addr)
if (phdr->p_filesz != phdr->p_memsz)
memset(dst + phdr->p_filesz, 0x00,
phdr->p_memsz - phdr->p_filesz);
- flush_cache((unsigned long)dst, phdr->p_filesz);
+ flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
+ roundup(phdr->p_memsz, ARCH_DMA_MINALIGN));
++phdr;
}
@@ -167,7 +168,8 @@ static unsigned long load_elf_image_phdr(unsigned long addr)
if (phdr->p_filesz != phdr->p_memsz)
memset(dst + phdr->p_filesz, 0x00,
phdr->p_memsz - phdr->p_filesz);
- flush_cache((unsigned long)dst, phdr->p_filesz);
+ flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
+ roundup(phdr->p_memsz, ARCH_DMA_MINALIGN));
++phdr;
}