[OE-core] [PATCH v2] mtd-utils: Fix alignment trap triggered by NEON instructions

jackie.huang at windriver.com jackie.huang at windriver.com
Wed Oct 22 08:47:57 UTC 2014


From: Yuanjie Huang <Yuanjie.Huang at windriver.com>

NEON instruction VLD1.64 was used to copy 64 bits data after type
casting, and they will trigger alignment trap.
This patch uses memcpy to avoid alignment problem.

Signed-off-by: Yuanjie Huang <Yuanjie.Huang at windriver.com>
Signed-off-by: Jackie Huang <jackie.huang at windriver.com>
---
 .../mtd/mtd-utils/fix-armv7-neon-alignment.patch   | 44 ++++++++++++++++++++++
 meta/recipes-devtools/mtd/mtd-utils_git.bb         |  1 +
 2 files changed, 45 insertions(+)
 create mode 100644 meta/recipes-devtools/mtd/mtd-utils/fix-armv7-neon-alignment.patch

diff --git a/meta/recipes-devtools/mtd/mtd-utils/fix-armv7-neon-alignment.patch b/meta/recipes-devtools/mtd/mtd-utils/fix-armv7-neon-alignment.patch
new file mode 100644
index 0000000..05f1629
--- /dev/null
+++ b/meta/recipes-devtools/mtd/mtd-utils/fix-armv7-neon-alignment.patch
@@ -0,0 +1,44 @@
+Upstream-Status: Pending
+
+NEON instruction VLD1.64 was used to copy 64 bits data after type
+casting, and they will trigger alignment trap.
+This patch uses memcpy to avoid alignment problem.
+
+Signed-off-by: Yuanjie Huang <Yuanjie.Huang at windriver.com>
+
+diff --git a/mkfs.ubifs/key.h b/mkfs.ubifs/key.h
+index d3a02d4..e7e9218 100644
+--- a/mkfs.ubifs/key.h
++++ b/mkfs.ubifs/key.h
+@@ -141,10 +141,12 @@ static inline void data_key_init(union ubifs_key *key, ino_t inum,
+  */
+ static inline void key_write(const union ubifs_key *from, void *to)
+ {
+-	union ubifs_key *t = to;
++	__le32 x[2];
+ 
+-	t->j32[0] = cpu_to_le32(from->u32[0]);
+-	t->j32[1] = cpu_to_le32(from->u32[1]);
++	x[0] = cpu_to_le32(from->u32[0]);
++	x[1] = cpu_to_le32(from->u32[1]);
++
++	memcpy(to, &x, 8);
+ 	memset(to + 8, 0, UBIFS_MAX_KEY_LEN - 8);
+ }
+ 
+@@ -156,10 +158,12 @@ static inline void key_write(const union ubifs_key *from, void *to)
+  */
+ static inline void key_write_idx(const union ubifs_key *from, void *to)
+ {
+-	union ubifs_key *t = to;
++	__le32 x[2];
++
++	x[0] = cpu_to_le32(from->u32[0]);
++	x[1] = cpu_to_le32(from->u32[1]);
+ 
+-	t->j32[0] = cpu_to_le32(from->u32[0]);
+-	t->j32[1] = cpu_to_le32(from->u32[1]);
++	memcpy(to, &x, 8);
+ }
+ 
+ /**
diff --git a/meta/recipes-devtools/mtd/mtd-utils_git.bb b/meta/recipes-devtools/mtd/mtd-utils_git.bb
index f78bc7e..52297c6 100644
--- a/meta/recipes-devtools/mtd/mtd-utils_git.bb
+++ b/meta/recipes-devtools/mtd/mtd-utils_git.bb
@@ -10,6 +10,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
 SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
 SRC_URI = "git://git.infradead.org/mtd-utils.git \
 		file://add-exclusion-to-mkfs-jffs2-git-2.patch \
+		file://fix-armv7-neon-alignment.patch \
 "
 
 PV = "1.5.1+git${SRCPV}"
-- 
2.0.0




More information about the Openembedded-core mailing list