]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
virtio_mmio: fix access width for mmio
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 17 Mar 2015 01:41:30 +0000 (12:11 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 17 Mar 2015 01:42:21 +0000 (12:12 +1030)
commit704a0b5f234db26de5203740999e39523cfa4e3a
treecf3a203aa1deeaebb736e3e822edd31badf0cbfc
parenta4994b810d52ccb26de922c8d231fe05d14610d4
virtio_mmio: fix access width for mmio

Going over the virtio mmio code, I noticed that it doesn't correctly
access modern device config values using "natural" accessors: it uses
readb to get/set them byte by byte, while the virtio 1.0 spec explicitly states:

4.2.2.2 Driver Requirements: MMIO Device Register Layout

...

The driver MUST only use 32 bit wide and aligned reads and writes to
access the control registers described in table 4.1.
For the device-specific configuration space, the driver MUST use
8 bit wide accesses for 8 bit wide fields, 16 bit wide and aligned
accesses for 16 bit wide fields and 32 bit wide and aligned accesses for
32 and 64 bit wide fields.

Borrow code from virtio_pci_modern to do this correctly.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/virtio/virtio_mmio.c