mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 17:28:13 +00:00
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. Backports commit c99a29e702528698c0ce2590f06ca7ff239f7c39 from qemu
This commit is contained in:
parent
11709d0afa
commit
23f5b17a08
2 changed files with 7 additions and 1 deletions
|
@ -22,6 +22,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;
|
||||
|
|
|
@ -1064,7 +1064,7 @@ static const MemoryRegionOps ram_device_mem_ops = {
|
|||
memory_region_ram_device_write,
|
||||
NULL,
|
||||
NULL,
|
||||
DEVICE_NATIVE_ENDIAN,
|
||||
DEVICE_HOST_ENDIAN,
|
||||
// valid
|
||||
{
|
||||
1, 8,
|
||||
|
|
Loading…
Reference in a new issue