Comment 8 for bug 1866772

Revision history for this message
Colin Ian King (colin-king) wrote :

Replacing memcpy with unoptimized char copying avoids this issue, so it seems to be a misaligned read issue.

diff --git a/fs/libfs.c b/fs/libfs.c
index 77709c5923a8..f99e265b6d81 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -786,6 +786,8 @@ ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
                                const void *from, size_t available)
 {
        loff_t pos = *ppos;
+ char *p1, *p2;
+ size_t i;

        if (pos < 0)
                return -EINVAL;
@@ -798,8 +800,14 @@ ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
                        (unsigned long long)available,
                        (unsigned long long)pos,
                        (unsigned long long)count);
+
+ p1 = to;
+ p2 = from + pos;
+
+ for (i = 0; i < count; i++,p1++,p2++)
+ *p1 = *p2;

- memcpy(to, from + pos, count);
+ //memcpy(to, from + pos, count);
        *ppos = pos + count;

        return count;

This is called from acpi_data_show() which does:

rc = memory_read_from_buffer(buf, count, &offset, base,
                                     data_attr->attr.size);

On a second read, the contents of offset is odd making base + offset odd on the source address of a memcpy(). I thought memcpy could handle that.