qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] memory: Introduce DEVICE_HOST_ENDIAN for ram


From: Alexey Kardashevskiy
Subject: Re: [Qemu-devel] [PATCH v2] memory: Introduce DEVICE_HOST_ENDIAN for ram device
Date: Tue, 28 Feb 2017 12:04:26 +1100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

On 28/02/17 11:41, David Gibson wrote:
> 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 <address@hidden>
>> Signed-off-by: Yongji Xie <address@hidden>
> 
> Reviewed-by: David Gibson <address@hidden>
> 
> 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.


In order to match memory_region_wrong_endianness(), it could be
DEVICE_CORRECT_ENDIAN :)

Just joking :)


> 
>> ---
>>  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,
> 


-- 
Alexey

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]