]> www.infradead.org Git - users/jedix/linux-maple.git/commit
IB/mlx4: Fix unaligned access in send_reply_to_slave
authorshamir rabinovitch <shamir.rabinovitch@oracle.com>
Wed, 18 May 2016 10:18:10 +0000 (06:18 -0400)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 25 May 2016 03:48:47 +0000 (20:48 -0700)
commitb4959a25e54129e82ffd7bbbc49be1b96c25b9c4
tree38553cc2ab024c26332104ad80b5c5a28cd3fdd7
parent8502173071b6117bb7f8e3230bca549cb77f80fd
IB/mlx4: Fix unaligned access in send_reply_to_slave

The problem is that the function 'send_reply_to_slave' gets the
'req_sa_mad' as a pointer whose address is only aliged to 4 bytes
but is 8 bytes in size.  This can result in unaligned access faults
on certain architectures.

Sowmini Varadhan pointed to this reply from Dave Miller that say
that memcpy should not be used to solve alignment issues:
https://lkml.org/lkml/2015/10/21/352

Optimization of memcpy to 'ldx' instruction can only happen if the
compiler knows that the size of the data we are copying is 8 bytes
and it assumes it is aligned to 8 bytes. If the compiler know the
type is not aligned to 8 it must not optimize the 8 byte copy.
Defining the data type as aligned to 4 forces the compiler to treat
all accesses as though they aren't aligned and avoids the 'ldx'
optimization.

Full credit for the idea goes to Jason Gunthorpe
<jgunthorpe@obsidianresearch.com>.

Orabug: 23311415

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx4/mcg.c