NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/58680 ([PATCH] Wrong byte order of config space write in big-endian virtio over PCI)



Synopsis: [PATCH] Wrong byte order of config space write in big-endian virtio over PCI

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh%NetBSD.org@localhost
State-Changed-When: Fri, 27 Sep 2024 18:49:06 +0000
State-Changed-Why:
https://mail-index.netbsd.org/source-changes/2024/09/25/msg153546.html

Module Name:    src
Committed By:   christos
Date:           Wed Sep 25 17:12:47 UTC 2024

Modified Files:
        src/sys/dev/pci: virtio_pci.c

Log Message:
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.54 -r1.55 src/sys/dev/pci/virtio_pci.c





Home | Main Index | Thread Index | Old Index