From: Alexander Stein Date: Mon, 9 Aug 2010 08:57:32 +0200 Subject: [U-Boot] [PATCH] memmove_wd: Allow overlapping memory area In-Reply-To: <20100808221819.4BEE71536EF@gemini.denx.de> References: <1279701826-20083-1-git-send-email-alexander.stein@systec-electronic.com> <20100808221819.4BEE71536EF@gemini.denx.de> Message-ID: <201008090857.32705.alexander.stein@systec-electronic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Wolfgang, Am Montag, 9. August 2010, 00:18:19 schrieb Wolfgang Denk: > In message <1279701826-20083-1-git-send-email-alexander.stein@systec- electronic.com> you wrote: > > Signed-off-by: Alexander Stein > > --- > > > > 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