Skip to content
  • Daniel Henrique Barboza's avatar
    ef80a708
    ivshmem.c: change endianness to LITTLE_ENDIAN · ef80a708
    Daniel Henrique Barboza authored
    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.
    
    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: cb06608e ("ivshmem: convert to memory API")
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/168
    
    
    Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Message-Id: <20211124092948.335389-2-danielhb413@gmail.com>
    Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
    ef80a708
    ivshmem.c: change endianness to LITTLE_ENDIAN
    Daniel Henrique Barboza authored
    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.
    
    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: cb06608e ("ivshmem: convert to memory API")
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/168
    
    
    Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Message-Id: <20211124092948.335389-2-danielhb413@gmail.com>
    Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
Loading