[openib-general] [PATCH] IB/core - ib_umad can cause address alignment fault on ia64

Jason Gunthorpe jgunthorpe at obsidianresearch.com
Thu Jan 18 09:37:07 PST 2007


On Thu, Jan 18, 2007 at 06:14:31PM +0200, Michael S. Tsirkin wrote:

> So the issue is that we are casting char *data which has no
> alignment guarantees to 64 bit number. We really must find a way to
> force 64 bit alignment for struct ib_user_mad all over. Would not
> something like the following simple trick work?
 
> struct ib_user_mad_hdr {
> 	.............
> } __attribute__((aligned (8)));

You might get a similar result if you change:

struct ib_user_mad {
        struct ib_user_mad_hdr hdr;
        __u8    data[0];
};

To

struct ib_user_mad {
        struct ib_user_mad_hdr hdr;
        __u64    data[0];
};

Which is more clear since it is the data[0] that has the alignment
requirement not the ib_usr_mad_hdr.. Plus you only get the pad if you
actually need it.

Jason




More information about the general mailing list