Module Name: src
Committed By: martin
Date: Thu Nov 28 16:33:25 UTC 2024
Modified Files:
src/sys/dev/pci [netbsd-10]: virtio_pci.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1018):
sys/dev/pci/virtio_pci.c: revision 1.55
Wrong byte order of config space write in big-endian (gorg)
In virtio_pci.c, the function virtio_pci_bus_space_write_8 writes
the first 4 bytes and second 4 bytes of an 8-byte value in the same
or swapped order within the device's config space depending on the
endianness of the system it is compiled for. However, the BUS_ADDR_LO32
and BUS_ADDR_HI32 always produce the least-significant and
most-significant 4 bytes of an 8-byte value, respectively, regardless
of the endianness of the system. Since virtio_pci_bus_space_write_8
is always used only for writing to little-endian parts of the config
space, the least significant 4 bytes must always be written to the
first 4 bytes in the config space value, and the most significant
4 bytes must always be written to the last 4 bytes of the config
space value. Therefore, swapping the byte order produces incorrect
behaviour on big-endian systems.
The incorrect behaviour seems to have been introduced in revision
1.19 of virtio_pci.c, which this change would mostly reversed
To generate a diff of this commit:
cvs rdiff -u -r1.38.4.4 -r1.38.4.5 src/sys/dev/pci/virtio_pci.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.38.4.4 src/sys/dev/pci/virtio_pci.c:1.38.4.5
--- src/sys/dev/pci/virtio_pci.c:1.38.4.4 Wed Oct 2 18:20:48 2024
+++ src/sys/dev/pci/virtio_pci.c Thu Nov 28 16:33:25 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.38.4.4 2024/10/02 18:20:48 martin Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.38.4.5 2024/11/28 16:33:25 martin Exp $ */
/*
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.38.4.4 2024/10/02 18:20:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.38.4.5 2024/11/28 16:33:25 martin Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -726,13 +726,8 @@ static __inline void
virtio_pci_bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, uint64_t value)
{
-#if _QUAD_HIGHWORD
bus_space_write_4(iot, ioh, offset, BUS_ADDR_LO32(value));
bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_HI32(value));
-#else
- bus_space_write_4(iot, ioh, offset, BUS_ADDR_HI32(value));
- bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_LO32(value));
-#endif
}
static void