Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3577
-gerrit
commit 8b635bb43568c0e9171bbdfb4e3a9e704759d041
Author: Gabe Black <gabeblack(a)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 its original location in
CBFS overlaps with its new location. That's only guaranteed to work if you use
memmove instead of memcpy.
In the case that the copy is 'sane', i.e. dest <= src, we can just call
memcpy, which gets us the processor-optimized code. We've got no statistics
on how common the overlapping case is.
Change-Id: Id550138c875907749fff05f330fcd2fb5f9ed924
Signed-off-by: Gabe Black <gabeblack(a)chromium.org>
---
src/arch/armv7/Kconfig | 8 ++++++++
src/lib/Makefile.inc | 3 ++-
src/lib/cbfs_core.c | 2 +-
src/lib/memmove.c | 31 ++++++++++++++++++++++++++++---
4 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/arch/armv7/Kconfig b/src/arch/armv7/Kconfig
index 488ca97..eea6d40 100644
--- a/src/arch/armv7/Kconfig
+++ b/src/arch/armv7/Kconfig
@@ -49,4 +49,12 @@ config ARM_DCACHE_POLICY_WRITETHROUGH
bool
default n
+config HAVE_ARCH_MEMSET
+ bool
+ default n
+
+config HAVE_ARCH_MEMCPY
+ bool
+ default n
+
endmenu
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index d44f4a7..88c34c1 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
@@ -115,7 +116,7 @@ endif
ifneq ($(CONFIG_HAVE_ARCH_MEMCPY),y)
smm-y += memcpy.c
endif
-smm-y += cbfs.c memcmp.c
+smm-y += cbfs.c memcmp.c memmove.c
smm-$(CONFIG_CONSOLE_SERIAL8250) += uart8250.c
smm-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
smm-$(CONFIG_USBDEBUG) += usbdebug.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:
diff --git a/src/lib/memmove.c b/src/lib/memmove.c
index 241917c..e567da5 100644
--- a/src/lib/memmove.c
+++ b/src/lib/memmove.c
@@ -1,13 +1,38 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
#include <string.h>
+
void *memmove(void *vdest, const void *vsrc, size_t count)
{
const char *src = vsrc;
char *dest = vdest;
+ /* N.B. You may be tempted to not copy in the case
+ * that dest == src. Please don't make that mistake.
+ */
if (dest <= src) {
- while (count--) {
- *dest++ = *src++;
- }
+ /* easy way to get the processor-optimized copy */
+ memcpy(vdest, vsrc, count);
} else {
src += count - 1;
dest += count - 1;
Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3577
-gerrit
commit 508606d5e805e2669d9b6ad7ed9695bfd0970fb0
Author: Gabe Black <gabeblack(a)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(a)chromium.org>
---
src/arch/armv7/Kconfig | 8 ++++++++
src/lib/Makefile.inc | 3 ++-
src/lib/cbfs_core.c | 2 +-
src/lib/memmove.c | 23 +++++++++++++++++++++++
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/arch/armv7/Kconfig b/src/arch/armv7/Kconfig
index 488ca97..eea6d40 100644
--- a/src/arch/armv7/Kconfig
+++ b/src/arch/armv7/Kconfig
@@ -49,4 +49,12 @@ config ARM_DCACHE_POLICY_WRITETHROUGH
bool
default n
+config HAVE_ARCH_MEMSET
+ bool
+ default n
+
+config HAVE_ARCH_MEMCPY
+ bool
+ default n
+
endmenu
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index d44f4a7..88c34c1 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
@@ -115,7 +116,7 @@ endif
ifneq ($(CONFIG_HAVE_ARCH_MEMCPY),y)
smm-y += memcpy.c
endif
-smm-y += cbfs.c memcmp.c
+smm-y += cbfs.c memcmp.c memmove.c
smm-$(CONFIG_CONSOLE_SERIAL8250) += uart8250.c
smm-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
smm-$(CONFIG_USBDEBUG) += usbdebug.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:
diff --git a/src/lib/memmove.c b/src/lib/memmove.c
index 241917c..b4f5b92 100644
--- a/src/lib/memmove.c
+++ b/src/lib/memmove.c
@@ -1,4 +1,27 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
#include <string.h>
+
void *memmove(void *vdest, const void *vsrc, size_t count)
{
const char *src = vsrc;
the following patch was just integrated into master:
commit 8cfa33eb7c93c0b4fb24a520b4c521591720999d
Author: Gabe Black <gabeblack(a)chromium.org>
Date: Tue Jun 11 21:58:18 2013 -0400
am335x: Implement support for the UART.
This patch was started by Dave Hendricks and implements the procedure for
setting up the UART as described in the manual. Some unused code was removed.
Change-Id: If26a424cac401ef3eafaec081147f41184fbcee9
Signed-off-by: Gabe Black <gabeblack(a)chromium.org>
Reviewed-on: http://review.coreboot.org/3490
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
Tested-by: build bot (Jenkins)
See http://review.coreboot.org/3490 for details.
-gerrit
the following patch was just integrated into master:
commit 8522f9940af8291772e37eef077339d6f3ffcda9
Author: Andrew Wu <arw(a)dmp.com.tw>
Date: Fri Jul 5 17:29:41 2013 +0800
Add support for DMP Vortex86EX PCI mainboard.
Change-Id: I8d42f765519e356d8f0cc6ed339d9b74f0a3e4d7
Signed-off-by: Andrew Wu <arw(a)dmp.com.tw>
Reviewed-on: http://review.coreboot.org/3610
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
See http://review.coreboot.org/3610 for details.
-gerrit