git: fb53b42e36a9 - main - virtio-modern: fix PCI common read/write functions on big endian targets
Alfredo Dal'Ava Junior
alfredo at FreeBSD.org
Fri May 7 02:54:05 UTC 2021
The branch main has been updated by alfredo:
URL: https://cgit.FreeBSD.org/src/commit/?id=fb53b42e36a9745d0a33821175a962c7a15eeeaa
commit fb53b42e36a9745d0a33821175a962c7a15eeeaa
Author: Alfredo Dal'Ava Junior <alfredo at FreeBSD.org>
AuthorDate: 2021-05-07 05:40:35 +0000
Commit: Alfredo Dal'Ava Junior <alfredo at FreeBSD.org>
CommitDate: 2021-05-07 05:40:35 +0000
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 at 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
---
sys/dev/virtio/pci/virtio_pci_modern.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sys/dev/virtio/pci/virtio_pci_modern.c b/sys/dev/virtio/pci/virtio_pci_modern.c
index 7029d2ff76ce..33fdebf19402 100644
--- a/sys/dev/virtio/pci/virtio_pci_modern.c
+++ b/sys/dev/virtio/pci/virtio_pci_modern.c
@@ -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
More information about the dev-commits-src-main
mailing list