From: David Gibson <david@gibson.dropbear.id.au>
To: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Cc: pbonzini@redhat.com, crosthwaite.peter@gmail.com,
rth@twiddle.net, qemu-devel@nongnu.org,
alex.williamson@redhat.com, aik@ozlabs.ru,
peter.maydell@linaro.org, paulus@samba.org,
mdroth@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2] memory: Introduce DEVICE_HOST_ENDIAN for ram device
Date: Tue, 28 Feb 2017 11:41:01 +1100 [thread overview]
Message-ID: <20170228004101.GG17615@umbus.fritz.box> (raw)
In-Reply-To: <1488171164-28319-1-git-send-email-xyjxie@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2428 bytes --]
On Mon, Feb 27, 2017 at 12:52:44PM +0800, Yongji Xie wrote:
> 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>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
The effect of the patch is certainly correct. I remain a little
concerned that the name "host endian" might cause more confusion than
it resolves, but a better term isn't immediately obvious to me.
> ---
> include/exec/cpu-common.h | 6 ++++++
> 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 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 ed8b5aa..17cfada 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1180,7 +1180,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,
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-02-28 0:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 4:52 [Qemu-devel] [PATCH v2] memory: Introduce DEVICE_HOST_ENDIAN for ram device Yongji Xie
2017-02-28 0:41 ` David Gibson [this message]
2017-02-28 1:04 ` Alexey Kardashevskiy
2017-02-28 10:12 ` Yongji Xie
2017-03-01 0:35 ` David Gibson
2017-03-01 3:23 ` Yongji Xie
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=20170228004101.GG17615@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=crosthwaite.peter@gmail.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=paulus@samba.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=xyjxie@linux.vnet.ibm.com \
--cc=zhong@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).