Skip to content
  • Benjamin Herrenschmidt's avatar
    virtio-pci: Fix endianness of virtio config · 82afa586
    Benjamin Herrenschmidt authored
    
    
    The virtio config area in PIO space is a bit special. The initial
    header is little endian but the rest (device specific) is guest
    native endian.
    
    The PIO accessors for PCI on machines that don't have native IO ports
    assume that all PIO is little endian, which works fine for everything
    except the above.
    
    A complicated way to fix it would be to split the BAR into two memory
    regions with different endianess settings, but this isn't practical
    to do, besides, the PIO code doesn't honor region endianness anyway
    (I have a patch for that too but it isn't necessary at this stage).
    
    So I decided to go for the quick fix instead which consists of
    reverting the swap in virtio-pci in selected places, hoping that when
    we eventually do a "v2" of the virtio protocols, we sort that out once
    and for all using a fixed endian setting for everything.
    
    Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
    [agraf: keep virtio in libhw and determine endianness through a
            helper function in exec.c]
    Reviewed-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
    82afa586