virtio-modern: fix PCI common read/write functions on big endian targets

Virtio modern has the common data organized in little endian, but
on powerpc64 BE it was reading and writing in the wrong endian.

Submitted by:	Leonardo Bianconi <leonardo.bianconi@eldorado.org.br>
Reviewed by:	bryanv, alfredo
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28947
This commit is contained in:
Alfredo Dal'Ava Junior 2021-05-07 02:40:35 -03:00
parent d5b20eaafc
commit fb53b42e36

View File

@ -1315,13 +1315,15 @@ vtpci_modern_read_common_1(struct vtpci_modern_softc *sc, bus_size_t off)
static uint16_t
vtpci_modern_read_common_2(struct vtpci_modern_softc *sc, bus_size_t off)
{
return (bus_read_2(&sc->vtpci_common_res_map.vtrm_map, off));
return virtio_htog16(true,
bus_read_2(&sc->vtpci_common_res_map.vtrm_map, off));
}
static uint32_t
vtpci_modern_read_common_4(struct vtpci_modern_softc *sc, bus_size_t off)
{
return (bus_read_4(&sc->vtpci_common_res_map.vtrm_map, off));
return virtio_htog32(true,
bus_read_4(&sc->vtpci_common_res_map.vtrm_map, off));
}
static void
@ -1335,14 +1337,16 @@ static void
vtpci_modern_write_common_2(struct vtpci_modern_softc *sc, bus_size_t off,
uint16_t val)
{
bus_write_2(&sc->vtpci_common_res_map.vtrm_map, off, val);
bus_write_2(&sc->vtpci_common_res_map.vtrm_map,
off, virtio_gtoh16(true, val));
}
static void
vtpci_modern_write_common_4(struct vtpci_modern_softc *sc, bus_size_t off,
uint32_t val)
{
bus_write_4(&sc->vtpci_common_res_map.vtrm_map, off, val);
bus_write_4(&sc->vtpci_common_res_map.vtrm_map,
off, virtio_gtoh32(true, val));
}
static void