summaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-07-22 15:54:37 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-07-25 08:12:28 -0500
commite7342aa39b3193473ded24cbf2233930665796e9 (patch)
tree020ff8382b6888fcb2c8949739274ef72f437d42 /memory.c
parent547e9201c52629eef71b0eb8cb48dacc50bcf759 (diff)
downloadqemu-e7342aa39b3193473ded24cbf2233930665796e9.tar.gz
qemu-e7342aa39b3193473ded24cbf2233930665796e9.tar.bz2
qemu-e7342aa39b3193473ded24cbf2233930665796e9.zip
memory: check memory region endianness, not target's
When combining multiple accesses into a single value, we need to do so in the device's desired endianness. The target endianness does not have any influence. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Message-id: 1374501278-31549-28-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/memory.c b/memory.c
index 8bb61f2886..1494e955d4 100644
--- a/memory.c
+++ b/memory.c
@@ -339,6 +339,15 @@ static void flatview_simplify(FlatView *view)
}
}
+static bool memory_region_big_endian(MemoryRegion *mr)
+{
+#ifdef TARGET_WORDS_BIGENDIAN
+ return mr->ops->endianness != DEVICE_LITTLE_ENDIAN;
+#else
+ return mr->ops->endianness == DEVICE_BIG_ENDIAN;
+#endif
+}
+
static bool memory_region_wrong_endianness(MemoryRegion *mr)
{
#ifdef TARGET_WORDS_BIGENDIAN
@@ -454,13 +463,15 @@ static void access_with_adjusted_size(hwaddr addr,
/* FIXME: support unaligned access? */
access_size = MAX(MIN(size, access_size_max), access_size_min);
access_mask = -1ULL >> (64 - access_size * 8);
- for (i = 0; i < size; i += access_size) {
-#ifdef TARGET_WORDS_BIGENDIAN
- access(mr, addr + i, value, access_size,
- (size - access_size - i) * 8, access_mask);
-#else
- access(mr, addr + i, value, access_size, i * 8, access_mask);
-#endif
+ if (memory_region_big_endian(mr)) {
+ for (i = 0; i < size; i += access_size) {
+ access(mr, addr + i, value, access_size,
+ (size - access_size - i) * 8, access_mask);
+ }
+ } else {
+ for (i = 0; i < size; i += access_size) {
+ access(mr, addr + i, value, access_size, i * 8, access_mask);
+ }
}
}