]> git.ipfire.org Git - thirdparty/qemu.git/commit - exec.c
virtio-pci: Fix endianness of virtio config
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 10 Jan 2012 01:35:11 +0000 (01:35 +0000)
committerAlexander Graf <agraf@suse.de>
Sat, 21 Jan 2012 04:17:01 +0000 (05:17 +0100)
commit82afa58641b0e67abbaf4da6c325ebd7c2513262
tree9e0f2e91ce9e53518b9aecc7e214594ba6d806ed
parent34ba1dc8739196c771281b0ba38c2ccd32c6d1fe
virtio-pci: Fix endianness of virtio config

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: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
[agraf: keep virtio in libhw and determine endianness through a
        helper function in exec.c]
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
exec.c
hw/virtio-pci.c