[U-Boot] [PATCH] memmove_wd: Allow overlapping memory area

Alexander Stein alexander.stein at systec-electronic.com
Mon Aug 9 08:57:32 CEST 2010


Dear Wolfgang,

Am Montag, 9. August 2010, 00:18:19 schrieb Wolfgang Denk:
> In message <1279701826-20083-1-git-send-email-alexander.stein at systec-
electronic.com> you wrote:
> > Signed-off-by: Alexander Stein <alexander.stein at systec-electronic.com>
> > ---
> > 
> >  common/image.c |   11 ++++++++---
> >  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> Why would this be needed?  Do you have an error scenario?

IIRC the problem arose when i downloaded my image to 0x20000000 (SD-RAM) using 
TFTP and my Linux kernel entry point was at 0x20008000. So when 
CONFIG_HW_WATCHDOG is defined u-boot starts copying from the beginning thus 
overriding the source. Finally i got decompression errors upon Linux kernel 
start.
Without CONFIG_HW_WATCHDOG memmove_wd is simply memmove which handled this 
cased correctly.

> > +		if (to <= from)
> > +		{
> > +			memmove (to, from, tail);
> > +			to += tail;
> > +			from += tail;
> > +		} else {
> > +			memmove (to + len - tail, from + len - tail, tail);
> 
> In which way is this supposed to allow overlapping memory areas?

With this change u-boot starts to copy from the end to the beginning thus 
preventing overriding the source. This change was adopted from memmove 
(lib/string.c) which handles this case correctly.

Best regards,
Alexander


More information about the U-Boot mailing list