]> Git Repo - qemu.git/commitdiff
memory: Introduce DEVICE_HOST_ENDIAN for ram device
authorYongji Xie <[email protected]>
Mon, 27 Feb 2017 04:52:44 +0000 (12:52 +0800)
committerPaolo Bonzini <[email protected]>
Fri, 3 Mar 2017 15:40:03 +0000 (16:40 +0100)
At the moment ram device's memory regions are DEVICE_NATIVE_ENDIAN. It's
incorrect. This memory region is backed by a MMIO area in host, so the
uint64_t data that MemoryRegionOps read from/write to this area should be
host-endian rather than target-endian. Hence, current code does not work
when target and host endianness are different which is the most common case
on PPC64. To fix it, this introduces DEVICE_HOST_ENDIAN for the ram device.

This has been tested on PPC64 BE/LE host/guest in all possible combinations
including TCG.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Yongji Xie <[email protected]>
Message-Id: <1488171164[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
include/exec/cpu-common.h
memory.c

index 8c305aa4fa02bdc27a8e9c3bb46d95d9ec4ec03d..b62f0d82e49eca74950bb0c8d441a64dff0da650 100644 (file)
@@ -36,6 +36,12 @@ enum device_endian {
     DEVICE_LITTLE_ENDIAN,
 };
 
+#if defined(HOST_WORDS_BIGENDIAN)
+#define DEVICE_HOST_ENDIAN DEVICE_BIG_ENDIAN
+#else
+#define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN
+#endif
+
 /* address in the RAM (different from a physical address) */
 #if defined(CONFIG_XEN_BACKEND)
 typedef uint64_t ram_addr_t;
index d61caee86755e54ff766ad69d67f50f28e098325..573fa6e5f61126dde9e45dd6412a854405d1ca56 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -1182,7 +1182,7 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr,
 static const MemoryRegionOps ram_device_mem_ops = {
     .read = memory_region_ram_device_read,
     .write = memory_region_ram_device_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_HOST_ENDIAN,
     .valid = {
         .min_access_size = 1,
         .max_access_size = 8,
This page took 0.030352 seconds and 4 git commands to generate.