From patchwork Wed Sep 30 20:48:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix hopefully last stopper bug for CBFS. Plan to get rid of non-CBFS Date: Wed, 30 Sep 2009 20:48:01 -0000 From: Patrick Georgi X-Patchwork-Id: 314 Message-Id: <1254343682.9254.22.camel@tetris> To: coreboot@coreboot.org Am Mittwoch, den 30.09.2009, 18:16 +0200 schrieb Patrick Georgi: > Pending the review of the prefix/suffix calculations (by me and > hopefully others), this is Review done, one bug found and hunted down. See new patch It's > Signed-off-by: Patrick Georgi and considered ready for commit by me. Regards, Patrick Acked-by: Ronald G. Minnich Index: src/boot/selfboot.c =================================================================== --- src/boot/selfboot.c (Revision 4695) +++ src/boot/selfboot.c (Arbeitskopie) @@ -423,14 +423,13 @@ { struct segment *ptr; - unsigned long required_bounce_size = lb_end - lb_start; + unsigned long bounce_high = lb_end; for(ptr = head->next; ptr != head; ptr = ptr->next) { if (!overlaps_coreboot(ptr)) continue; - unsigned long bounce = ptr->s_dstaddr + ptr->s_memsz - lb_start; - if (bounce > required_bounce_size) - required_bounce_size = bounce; + if (ptr->s_dstaddr + ptr->s_memsz > bounce_high) + bounce_high = ptr->s_dstaddr + ptr->s_memsz; } - get_bounce_buffer(mem, required_bounce_size); + get_bounce_buffer(mem, bounce_high - lb_start); if (!bounce_buffer) { printk_err("Could not find a bounce buffer...\n"); return 0; @@ -502,6 +501,24 @@ /* Zero the extra bytes */ memset(middle, 0, end - middle); } + /* Copy the data that's outside the area that shadows coreboot_ram */ + printk_debug("dest %lx, end %lx, bouncebuffer %lx\n", dest, end, bounce_buffer); + if ((unsigned long)end > bounce_buffer) { + if ((unsigned long)dest < bounce_buffer) { + unsigned long from = dest; + unsigned long to = lb_start-(bounce_buffer-(unsigned long)dest); + unsigned long amount = bounce_buffer-(unsigned long)dest; + printk_debug("move prefix around: from %lx, to %lx, amount: %lx\n", from, to, amount); + memcpy(to, from, amount); + } + if ((unsigned long)end > bounce_buffer + (lb_end - lb_start)) { + unsigned long from = bounce_buffer + (lb_end - lb_start); + unsigned long to = lb_end; + unsigned long amount = end - from; + printk_debug("move suffix around: from %lx, to %lx, amount: %lx\n", from, to, amount); + memcpy(to, from, amount); + } + } } } return 1;