提交 968a5627 编写于 作者: P Paolo Bonzini

memory: correctly handle endian-swapped 64-bit accesses

Reviewed-by: NRichard Henderson <rth@twiddle.net>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 ce5d2f33
......@@ -2263,15 +2263,21 @@ static inline uint64_t ldq_phys_internal(hwaddr addr,
false);
if (l < 8 || !memory_access_is_direct(section->mr, false)) {
/* I/O case */
/* XXX This is broken when device endian != cpu endian.
Fix and add "endian" variable check */
#ifdef TARGET_WORDS_BIGENDIAN
val = io_mem_read(section->mr, addr1, 4) << 32;
val |= io_mem_read(section->mr, addr1 + 4, 4);
#else
val = io_mem_read(section->mr, addr1, 4);
val |= io_mem_read(section->mr, addr1 + 4, 4) << 32;
#endif
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = bswap64(val);
}
#else
if (endian == DEVICE_BIG_ENDIAN) {
val = bswap64(val);
}
#endif
} else {
/* RAM case */
......
......@@ -957,6 +957,9 @@ static void adjust_endianness(MemoryRegion *mr, uint64_t *data, unsigned size)
case 4:
*data = bswap32(*data);
break;
case 8:
*data = bswap64(*data);
break;
default:
abort();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册