Skip to content
  • Peter Maydell's avatar
    c6445544
    hw/arm/smmu: Handle big-endian hosts correctly · c6445544
    Peter Maydell authored
    
    
    The implementation of the SMMUv3 has multiple places where it reads a
    data structure from the guest and directly operates on it without
    doing a guest-to-host endianness conversion.  Since all SMMU data
    structures are little-endian, this means that the SMMU doesn't work
    on a big-endian host.  In particular, this causes the Avocado test
      machine_aarch64_virt.py:Aarch64VirtMachine.test_alpine_virt_tcg_gic_max
    to fail on an s390x host.
    
    Add appropriate byte-swapping on reads and writes of guest in-memory
    data structures so that the device works correctly on big-endian
    hosts.
    
    As part of this we constrain queue_read() to operate only on Cmd
    structs and queue_write() on Evt structs, because in practice these
    are the only data structures the two functions are used with, and we
    need to know what the data structure is to be able to byte-swap its
    parts correctly.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Tested-by: default avatarThomas Huth <thuth@redhat.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
    Message-id: 20230717132641.764660-1-peter.maydell@linaro.org
    Cc: qemu-stable@nongnu.org
    c6445544
    hw/arm/smmu: Handle big-endian hosts correctly
    Peter Maydell authored
    
    
    The implementation of the SMMUv3 has multiple places where it reads a
    data structure from the guest and directly operates on it without
    doing a guest-to-host endianness conversion.  Since all SMMU data
    structures are little-endian, this means that the SMMU doesn't work
    on a big-endian host.  In particular, this causes the Avocado test
      machine_aarch64_virt.py:Aarch64VirtMachine.test_alpine_virt_tcg_gic_max
    to fail on an s390x host.
    
    Add appropriate byte-swapping on reads and writes of guest in-memory
    data structures so that the device works correctly on big-endian
    hosts.
    
    As part of this we constrain queue_read() to operate only on Cmd
    structs and queue_write() on Evt structs, because in practice these
    are the only data structures the two functions are used with, and we
    need to know what the data structure is to be able to byte-swap its
    parts correctly.
    
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Tested-by: default avatarThomas Huth <thuth@redhat.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
    Message-id: 20230717132641.764660-1-peter.maydell@linaro.org
    Cc: qemu-stable@nongnu.org
Loading