diff options
author | Yongji Xie <xyjxie@linux.vnet.ibm.com> | 2017-02-27 12:52:44 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-03-03 16:40:03 +0100 |
commit | c99a29e702528698c0ce2590f06ca7ff239f7c39 (patch) | |
tree | 5c261dda694a0dcf9410c12305b4a83c6326d6d8 | |
parent | 11953be792998c43bf2cad4ad3deaeaeaf89dbb4 (diff) | |
download | qemu-c99a29e702528698c0ce2590f06ca7ff239f7c39.zip qemu-c99a29e702528698c0ce2590f06ca7ff239f7c39.tar.gz qemu-c99a29e702528698c0ce2590f06ca7ff239f7c39.tar.bz2 |
memory: Introduce DEVICE_HOST_ENDIAN for ram device
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 <pbonzini@redhat.com>
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Message-Id: <1488171164-28319-1-git-send-email-xyjxie@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | include/exec/cpu-common.h | 6 | ||||
-rw-r--r-- | memory.c | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 8c305aa..b62f0d8 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -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; @@ -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, |