Thread (1 message) 1 message, 1 author, 2012-07-23

Re: uverbs message alignment

From: Jason Gunthorpe <hidden>
Date: 2012-07-23 18:30:27

On Sat, Jul 21, 2012 at 05:15:26AM +0000, Hefty, Sean wrote:
quoted
struct c4iw_create_raw_qp_req {
         struct ibv_create_qp ibv_req;
         __u32 port;
         __u32 vlan_pri;
         __u32 nfids;
};
struct ibv_create_qp contains a u64, which will force the size of
the structure to 64-bit.  You should to add an additional 32-bits of
padding.
Specifically, the padding Sean is talking about is here:

struct c4iw_create_raw_qp_req {
        struct ibv_create_qp ibv_req;
        __u32 port;
        __u32 vlan_pri;
        __u32 nfids;
        __u32 _rsvd0;  // <<<---- pad
};

And similarly in your driver's header. Things are setup so that
device_data does not have to be a multple of 8 bytes long, but it is
guarenteed to be 8 byte aligned.

However as long as you include ibv_req in your struct you have to be a
multiple of 8 bytes long so, you may want to construct your
driver_data the same way that userspace does. Remove the ibv_req from
the struct and cast from driver_data. This avoids this sort of
problem completely.

Also, always ensure structs you are passing between kernel and user
space have no implicit padding at all.

Jason
--
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help