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

Alexander Stein alexander.stein at systec-electronic.com
Mon Aug 9 13:10:37 CEST 2010


Dear Wolfgang,

Am Montag, 9. August 2010, 11:26:56 schrieb Wolfgang Denk:
> > 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
> 
> Don;t do this, then. Such kind of overlap has never been supported.
> Even if it would work in your case of uncompressed images, it is bound
> to fail for compressed ones where the uncompressed code grows faster
> then compressed data get consumed.

Well, that's at least one possibility but it is very annoying that something 
like memmove that works fine so far suddenly stops working when watchdog 
support is enabled.

> > > > +		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.
> 
> You are just shifting the problem to another area, but you are not
> solving it. Without your patch there is a problem when the initial
> area overlaps, with your problem there is one when the tail overlaps.

Well, why is this situation then handled by memmove?

Best regards,
Alexander


More information about the U-Boot mailing list