public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/core: Fix unaligned accesses
@ 2015-04-29 20:56 David Ahern
       [not found] ` <1430340983-12538-1-git-send-email-david.ahern-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2015-04-29 20:56 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, roland-DgEjT+Ai2ygdnm+yROfE0A
  Cc: David Ahern

Addresses the following kernel logs seen during boot of sparc systems:

Kernel unaligned access at TPC[103bce50] cm_find_listen+0x34/0xf8 [ib_cm]
Kernel unaligned access at TPC[103bce50] cm_find_listen+0x34/0xf8 [ib_cm]
Kernel unaligned access at TPC[103bce50] cm_find_listen+0x34/0xf8 [ib_cm]
Kernel unaligned access at TPC[103bce50] cm_find_listen+0x34/0xf8 [ib_cm]
Kernel unaligned access at TPC[103bce50] cm_find_listen+0x34/0xf8 [ib_cm]

Signed-off-by: David Ahern <david.ahern-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 drivers/infiniband/core/cm.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index e28a494..5102cfe 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -439,11 +439,23 @@ static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id)
 
 static void cm_mask_copy(u8 *dst, u8 *src, u8 *mask)
 {
+	unsigned long *plsrc, *plmask, *pldst;
 	int i;
 
-	for (i = 0; i < IB_CM_COMPARE_SIZE / sizeof(unsigned long); i++)
-		((unsigned long *) dst)[i] = ((unsigned long *) src)[i] &
-					     ((unsigned long *) mask)[i];
+	/* unsigned longs can use extended load operations which
+	 * can require 8-byte alignments. dst, src and mask are
+	 * not guaranteed to be aligned.
+	 */
+	pldst = (unsigned long *) dst;
+	plsrc = (unsigned long *) src;
+	plmask = (unsigned long *) mask;
+	for (i = 0; i < IB_CM_COMPARE_SIZE / sizeof(unsigned long); i++) {
+		unsigned long lsrc, lmask;
+
+		lsrc = get_unaligned(&plsrc[i]);
+		lmask = get_unaligned(&plmask[i]);
+		put_unaligned(lsrc & lmask, &pldst[i]);
+	}
 }
 
 static int cm_compare_data(struct ib_cm_compare_data *src_data,
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-04-29 22:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-29 20:56 [PATCH] IB/core: Fix unaligned accesses David Ahern
     [not found] ` <1430340983-12538-1-git-send-email-david.ahern-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 21:18   ` Jason Gunthorpe
     [not found]     ` <20150429211822.GA25951-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 21:24       ` David Ahern
     [not found]         ` <55414C03.40902-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 21:30           ` Jason Gunthorpe
     [not found]             ` <20150429213042.GA28812-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 21:38               ` David Ahern
     [not found]                 ` <55414F4E.5020209-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 21:51                   ` Jason Gunthorpe
     [not found]                     ` <20150429215123.GA29809-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 21:59                       ` David Ahern
     [not found]                         ` <55415438.1040205-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 22:15                           ` Jason Gunthorpe
     [not found]                             ` <20150429221537.GB31415-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 22:34                               ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox