[openib-general] Re: ia64: kernel unaligned access in ipoib

Michael S. Tsirkin mst at mellanox.co.il
Mon May 29 08:53:50 PDT 2006


Quoting r. Roland Dreier <rdreier at cisco.com>:
> Subject: Re: ia64: kernel unaligned access in ipoib
> 
>  > When running ipoib on an ia64 machine, I sometimes see
>  > kernel unaligned access to 0xe0000002ffb53f0c, ip=0xa00000020041b450
>  > kernel unaligned access to 0xe0000002ffb53f14, ip=0xa00000020041b470
>  > 
>  > where 0xa00000020041b450 and 0xa00000020041b470 appear to be
>  > inside ipoib path_rec_create function.
> 
> I don't see any obvious misaligned accesses in path_rec_create().  And
> unfortunately I don't have any IA64 machines handy to track this down.
> So you're on your own on this one...

It seems Jack has found it (see below). Since you cast the pointer to struct
ib_gid type, and then pass a struct pointer to memcpy, it assumes the address is
naturally aligned and replaces memcpy with inline st8/ld8 instructions which
can't operate on misaligned addresses.

Here's a list of places that cast a misaligned address to union ib_gid:

~>grep -n -e '->ha + 4' *c

ipoib_main.c:507:       path = __path_find(dev, (union ib_gid *) (skb->dst->neighbour->ha + 4));
ipoib_main.c:510:                                      (union ib_gid *) (skb->dst->neighbour->ha + 4));
ipoib_main.c:560:       ipoib_mcast_send(dev, (union ib_gid *) (skb->dst->neighbour->ha + 4), skb);
ipoib_main.c:776:                 IPOIB_GID_ARG(*((union ib_gid *) (n->ha +
4))));

So, I think the fix will be
1. pass gid inside a void * without cast so that the compiler does not assume
   its aligned
2. fix IPOIB_GID_FMT/IPOIB_GID_ARG to read the gid byte by byte and not
   by 16 byte chunks

-----------

From: "Jack Morgenstein" <jackm at mellanox.co.il>
Subject: Possible IA64 unaligned access?

file: ipoib_main.c, proc neigh_add_path:
Parameters to path_rec_create might be 4-byte aligned!
 if (!path) {
  path path_rec_create(dev,
           (union ib_gid *) (skb->dst->neighbour->ha + 4));
  if (!path)
   goto err_path;
  __path_add(dev, path);
 }

-- 
MST



More information about the general mailing list