qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: thuth@redhat.com, qemu-ppc@nongnu.org,
	"Claudio Fontana" <cfontana@suse.de>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	david@gibson.dropbear.id.au, clg@kaod.org
Subject: Re: [PATCH for-7.0 v2 1/2] ivshmem.c: change endianness to LITTLE_ENDIAN
Date: Wed, 24 Nov 2021 08:33:31 -0300	[thread overview]
Message-ID: <cf2cfec2-876c-1dc8-50f1-0a79b490527c@gmail.com> (raw)
In-Reply-To: <7d312ca5-82d1-ba63-535d-8024f2033215@redhat.com>



On 11/24/21 08:28, Philippe Mathieu-Daudé wrote:
> On 11/24/21 10:29, Daniel Henrique Barboza wrote:
>> The ivshmem device, as with most PCI devices, uses little endian byte
>> order. However, the endianness of its mmio_ops is marked as
>> DEVICE_NATIVE_ENDIAN. This presents not only the usual problems with big
>> endian hosts but also with PowerPC little endian hosts as well, since
>> the Power architecture in QEMU uses big endian hardware (XIVE controller,
>> PCI Host Bridges, etc) even if the host is in little endian byte order.
> 
> Maybe mention commit f7a199b2b44 ("ivshmem: use little-endian
> int64_t for the protocol")?


Good point. I'll send a v3.

> 
>> As it is today, the IVPosition of the device will be byte swapped when
>> running in Power BE and LE. This can be seen by changing the existing
>> qtest 'ivshmem-test' to run in ppc64 hosts and printing the IVPOSITION
>> regs in test_ivshmem_server() right after the VM ids assert. For x86_64
>> the VM id values read are '0' and '1', for ppc64 (tested in a Power8
>> RHEL 7.9 BE server) and ppc64le (tested in a Power9 RHEL 8.6 LE server)
>> the ids will be '0' and '0x1000000'.
>>
>> Change this device to LITTLE_ENDIAN fixes the issue for Power hosts of
>> both endianness, and every other big-endian architecture that might use
>> this device, without impacting x86 users.
>>
>> Fixes: cb06608e17f8 ("ivshmem: convert to memory API")
>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/168
>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>> ---
>>   hw/misc/ivshmem.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
>> index 1ba4a98377..299837e5c1 100644
>> --- a/hw/misc/ivshmem.c
>> +++ b/hw/misc/ivshmem.c
>> @@ -243,7 +243,7 @@ static uint64_t ivshmem_io_read(void *opaque, hwaddr addr,
>>   static const MemoryRegionOps ivshmem_mmio_ops = {
>>       .read = ivshmem_io_read,
>>       .write = ivshmem_io_write,
>> -    .endianness = DEVICE_NATIVE_ENDIAN,
>> +    .endianness = DEVICE_LITTLE_ENDIAN,
>>       .impl = {
>>           .min_access_size = 4,
>>           .max_access_size = 4,
>>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Thanks!


Daniel

> 


  reply	other threads:[~2021-11-24 11:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  9:29 [PATCH for-7.0 v2 0/2] change ivshmem endianness to LITTLE_ENDIAN Daniel Henrique Barboza
2021-11-24  9:29 ` [PATCH for-7.0 v2 1/2] ivshmem.c: change " Daniel Henrique Barboza
2021-11-24 11:28   ` Philippe Mathieu-Daudé
2021-11-24 11:33     ` Daniel Henrique Barboza [this message]
2021-11-24 12:55     ` Markus Armbruster
2021-11-24 13:09       ` Daniel Henrique Barboza
2021-11-24  9:29 ` [PATCH for-7.0 v2 2/2] ivshmem-test.c: enable test_ivshmem_server for ppc64 arch Daniel Henrique Barboza
2021-11-24 11:29   ` Philippe Mathieu-Daudé
2021-12-15 16:35 ` [PATCH for-7.0 v2 0/2] change ivshmem endianness to LITTLE_ENDIAN Cédric Le Goater

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=cf2cfec2-876c-1dc8-50f1-0a79b490527c@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=cfontana@suse.de \
    --cc=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=marcandre.lureau@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.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).