Skip to content
Commit 73898db0 authored by Haggai Abramovsky's avatar Haggai Abramovsky Committed by David S. Miller
Browse files

net/mlx4: Avoid wrong virtual mappings



The dma_alloc_coherent() function returns a virtual address which can
be used for coherent access to the underlying memory.  On some
architectures, like arm64, undefined behavior results if this memory is
also accessed via virtual mappings that are not coherent.  Because of
their undefined nature, operations like virt_to_page() return garbage
when passed virtual addresses obtained from dma_alloc_coherent().  Any
subsequent mappings via vmap() of the garbage page values are unusable
and result in bad things like bus errors (synchronous aborts in ARM64
speak).

The mlx4 driver contains code that does the equivalent of:
vmap(virt_to_page(dma_alloc_coherent)), this results in an OOPs when the
device is opened.

Prevent Ethernet driver to run this problematic code by forcing it to
allocate contiguous memory. As for the Infiniband driver, at first we
are trying to allocate contiguous memory, but in case of failure roll
back to work with fragmented memory.

Signed-off-by: default avatarHaggai Abramovsky <hagaya@mellanox.com>
Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Reported-by: default avatarDavid Daney <david.daney@cavium.com>
Tested-by: default avatarSinan Kaya <okaya@codeaurora.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 035cd6ba
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment