From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PULL 18/19] memory: Introduce DEVICE_HOST_ENDIAN for ram device
Date: Wed, 1 Mar 2017 13:29:49 +0100 [thread overview]
Message-ID: <20170301122950.3587-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20170301122950.3587-1-pbonzini@redhat.com>
From: Yongji Xie <xyjxie@linux.vnet.ibm.com>
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>
---
include/exec/cpu-common.h | 6 ++++++
memory.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index bd15853..eef74df 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;
diff --git a/memory.c b/memory.c
index d61caee..573fa6e 100644
--- 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,
--
2.9.3
next prev parent reply other threads:[~2017-03-01 12:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-01 12:29 [Qemu-devel] [PULL v4 00/19] KVM and cpu-exec patches for 2.9 soft freeze Paolo Bonzini
2017-03-01 12:29 ` [Qemu-devel] [PULL 10/19] KVM: do not use sigtimedwait to catch SIGBUS Paolo Bonzini
2017-03-01 12:29 ` Paolo Bonzini [this message]
2017-03-01 12:29 ` [Qemu-devel] [PULL 19/19] vl: disable default cdrom when using explicitely scsi-hd Paolo Bonzini
2017-03-01 13:05 ` [Qemu-devel] [PULL v4 00/19] KVM and cpu-exec patches for 2.9 soft freeze Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2017-02-28 16:13 Paolo Bonzini
2017-02-28 16:14 ` [Qemu-devel] [PULL 18/19] memory: Introduce DEVICE_HOST_ENDIAN for ram device Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170301122950.3587-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xyjxie@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).