From da78aab7d610fb8638ae319e07becf7ae96bce62 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Wed, 5 Sep 2007 01:54:28 +0000 Subject: [PATCH] properzero.diff changes the memset to only clean up the area which is not memcopied to. Signed-off-by: Alex Beregszaszi Acked-by: Stefan Reinauer git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@490 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- lib/elfboot.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/elfboot.c b/lib/elfboot.c index c94fa4102a..9f4661e810 100644 --- a/lib/elfboot.c +++ b/lib/elfboot.c @@ -112,16 +112,13 @@ static int load_elf_segments(struct lb_memory *mem,unsigned char *header, int he /* Verify the memory addresses in the segment are valid */ if (!valid_area(mem, phdr[i].p_paddr, size)) goto out; - /* let's just be stupid about this. Bzero the whole area we are copying to, - * then copy out the data, which may be a subset of the total area. - * the cache, after all, is your friend. - */ - printk(BIOS_INFO, "Set %p to 0 for %d bytes\n", (unsigned char *)phdr[i].p_paddr, phdr[i].p_memsz); - memset((unsigned char *)phdr[i].p_paddr, 0, phdr[i].p_memsz); /* ok, copy it out */ printk(BIOS_INFO, "Copy to %p from %p for %d bytes\n", (unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size); memcpy((unsigned char *)phdr[i].p_paddr, &header[phdr[i].p_offset], size); - + if (size < phdr[i].p_memsz) { + printk(BIOS_INFO, "Set %p to 0 for %d bytes\n", (unsigned char *)phdr[i].p_paddr, phdr[i].p_memsz-size); + memset((unsigned char *)phdr[i].p_paddr+size, 0, phdr[i].p_memsz-size); + } } return 1; out: