virtio_pci: Limit DMA mask to 44 bits for legacy virtio devices
authorWill Deacon <will.deacon@arm.com>
Wed, 14 Sep 2016 16:33:26 +0000 (17:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2016 15:38:52 +0000 (16:38 +0100)
commit7569d22a820df0e32b9e4f9e257127d92a133d78
tree64a6b87348bb026793ab7124e026065d76891f06
parent0c2f67a6196d6d877fdd2fb1f34da155e39d39db
virtio_pci: Limit DMA mask to 44 bits for legacy virtio devices

commit a0be1db4304f51c99af6b6e515549794182a94df upstream.

Legacy virtio defines the virtqueue base using a 32-bit PFN field, with
a read-only register indicating a fixed page size of 4k.

This can cause problems for DMA allocators that allocate top down from
the DMA mask, which is set to 64 bits. In this case, the addresses are
silently truncated to 44-bit, leading to IOMMU faults, failure to read
from the queue or data corruption.

This patch restricts the coherent DMA mask for legacy PCI virtio devices
to 44 bits, which matches the specification.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Benjamin Serebrin <serebrin@google.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/virtio/virtio_pci_legacy.c