qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, aik@ozlabs.ru,
	zhong@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] memory: make ram device read/write endian sensitive
Date: Tue, 21 Feb 2017 09:21:37 -0700	[thread overview]
Message-ID: <20170221092137.5b6cecbb@t450s.home> (raw)
In-Reply-To: <1487659615-15820-1-git-send-email-xyjxie@linux.vnet.ibm.com>

On Tue, 21 Feb 2017 14:46:55 +0800
Yongji Xie <xyjxie@linux.vnet.ibm.com> wrote:

> At the moment ram device's memory regions are NATIVE_ENDIAN. This does
> not work on PPC64 because VFIO PCI device is little endian but PPC64
> always defines static macro TARGET_WORDS_BIGENDIAN.
> 
> This fixes endianness for ram device the same way as it is done
> for VFIO region in commit 6758008e2c4e79fb6bd04fe8e7a41665fa583965.

The referenced commit was to vfio code where the endianness is fixed,
here you're modifying shared generic code to assume the same
endianness as vfio.  That seems wrong.  Should
memory_region_init_ram_device_ptr() instead take an endian option and
ram_device_mem_ops should take the backing endianness into account?
Thanks,

Alex
 
> Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
> ---
>  memory.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index 6c58373..1ccb99f 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1139,13 +1139,13 @@ static uint64_t memory_region_ram_device_read(void *opaque,
>          data = *(uint8_t *)(mr->ram_block->host + addr);
>          break;
>      case 2:
> -        data = *(uint16_t *)(mr->ram_block->host + addr);
> +        data = le16_to_cpu(*(uint16_t *)(mr->ram_block->host + addr));
>          break;
>      case 4:
> -        data = *(uint32_t *)(mr->ram_block->host + addr);
> +        data = le32_to_cpu(*(uint32_t *)(mr->ram_block->host + addr));
>          break;
>      case 8:
> -        data = *(uint64_t *)(mr->ram_block->host + addr);
> +        data = le64_to_cpu(*(uint64_t *)(mr->ram_block->host + addr));
>          break;
>      }
>  
> @@ -1166,13 +1166,13 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr,
>          *(uint8_t *)(mr->ram_block->host + addr) = (uint8_t)data;
>          break;
>      case 2:
> -        *(uint16_t *)(mr->ram_block->host + addr) = (uint16_t)data;
> +        *(uint16_t *)(mr->ram_block->host + addr) = cpu_to_le16((uint16_t)data);
>          break;
>      case 4:
> -        *(uint32_t *)(mr->ram_block->host + addr) = (uint32_t)data;
> +        *(uint32_t *)(mr->ram_block->host + addr) = cpu_to_le32((uint32_t)data);
>          break;
>      case 8:
> -        *(uint64_t *)(mr->ram_block->host + addr) = data;
> +        *(uint64_t *)(mr->ram_block->host + addr) = cpu_to_le64(data);
>          break;
>      }
>  }
> @@ -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_LITTLE_ENDIAN,
>      .valid = {
>          .min_access_size = 1,
>          .max_access_size = 8,

  reply	other threads:[~2017-02-21 16:21 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21  6:46 [Qemu-devel] [PATCH] memory: make ram device read/write endian sensitive Yongji Xie
2017-02-21 16:21 ` Alex Williamson [this message]
2017-02-21 16:34   ` Paolo Bonzini
2017-02-21 18:09     ` Peter Maydell
2017-02-21 18:44       ` Alex Williamson
2017-02-22  7:54         ` Yongji Xie
2017-02-22 10:53         ` Paolo Bonzini
2017-02-21 18:53       ` Paolo Bonzini
2017-02-21 19:40         ` Peter Maydell
2017-02-23  4:20 ` Alexey Kardashevskiy
2017-02-23  8:35   ` Paolo Bonzini
2017-02-23 10:02     ` Peter Maydell
2017-02-23 10:10       ` Paolo Bonzini
2017-02-23 10:23         ` Peter Maydell
2017-02-23 10:33           ` Paolo Bonzini
2017-02-23 11:34             ` Peter Maydell
2017-02-23 11:43               ` Paolo Bonzini
2017-02-23 12:26                 ` Peter Maydell
2017-02-23 12:53                   ` Paolo Bonzini
2017-02-23 14:35                     ` Peter Maydell
2017-02-23 15:21                       ` Paolo Bonzini
2017-02-23 15:29                         ` Peter Maydell
2017-02-23 15:58                           ` Paolo Bonzini
2017-02-23 16:08                             ` Peter Maydell
2017-02-23 16:15                               ` Paolo Bonzini
2017-02-23 17:14                                 ` Yongji Xie
2017-02-24  3:28                                   ` David Gibson
2017-02-23 23:36                           ` Paul Mackerras
2017-02-23 15:39                         ` Alex Williamson
2017-02-23 15:47                           ` Paolo Bonzini
2017-02-23 16:08                             ` Alex Williamson
2017-02-24  3:26                 ` David Gibson
2017-02-23 11:04     ` Alexey Kardashevskiy
2017-02-27  2:25   ` Michael Roth
2017-02-27  3:25     ` Alexey Kardashevskiy
2017-02-27  4:28       ` 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=20170221092137.5b6cecbb@t450s.home \
    --to=alex.williamson@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).