Ronald G. Minnich (rminnich@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3577
-gerrit
commit b28eb30bb29fd7ddfaf5709bd84008fa5c24b170 Author: Gabe Black gabeblack@chromium.org Date: Mon Jul 1 04:28:23 2013 -0700
CBFS: Use memmove instead of memcpy when loading a file from CBFS.
It might be the case that a file is being loaded from a portion of CBFS which has already been loaded into a limitted bit of memory somewhere, and we want to load that file in place, effectively, so that it's original location in CBFS overlaps with its new location. That's only guaranteed to work if you use memmove instead of memcpy.
One significant downside of this change is that there aren't yet architecture optimized (aka not horribly performing) implementations of memmove available for either x86 or ARM. It's not clear whether the performance difference would be significant enough to notice in practice since the things in CBFS are probably not that big. It might still be a good idea to hold off on this change until optimized versions are available to avoid any potential performance hit.
This also means that memmove needs to be built into the bootblock.
Change-Id: Id550138c875907749fff05f330fcd2fb5f9ed924 Signed-off-by: Gabe Black gabeblack@chromium.org --- src/lib/Makefile.inc | 1 + src/lib/cbfs_core.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index d44f4a7..50092b6 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -26,6 +26,7 @@ ifneq ($(CONFIG_HAVE_ARCH_MEMCPY),y) bootblock-y += memcpy.c endif bootblock-y += memcmp.c +bootblock-y += memmove.c
ifneq ($(CONFIG_HAVE_ARCH_MEMSET),y) romstage-y += memset.c diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c index 852b37f..39c1ff6 100644 --- a/src/lib/cbfs_core.c +++ b/src/lib/cbfs_core.c @@ -195,7 +195,7 @@ int cbfs_decompress(int algo, void *src, void *dst, int len) { switch (algo) { case CBFS_COMPRESS_NONE: - memcpy(dst, src, len); + memmove(dst, src, len); return 0; #ifdef CBFS_CORE_WITH_LZMA case CBFS_COMPRESS_LZMA: