aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2018-03-15 21:18:14 -0600
committerJason Gunthorpe <jgg@mellanox.com>2018-03-19 11:41:40 -0600
commit958d2c1ba37680b765a089dc374cc199fb61619b (patch)
tree87a9c84265096138f232de4a8f8df6ce3ac821f3
parentIB/mlx5: Set the default active rate and width to QDR and 4X (diff)
downloadlinux-dev-958d2c1ba37680b765a089dc374cc199fb61619b.tar.xz
linux-dev-958d2c1ba37680b765a089dc374cc199fb61619b.zip
RDMA/bnxt: Fix structure layout for bnxt_re_pd_resp
What is going on here is a bit subtle, in the kernel there is no problem because the struct is copied using copy_from_user, so it can safely have an 8 byte alignment, however in userspace it must be constructed by concatenation with the ib_uverbs_alloc_pd_resp struct. This is due to the required memory layout to execute the command. Since ibv_uverbs_alloc_pd_resp is only 4 bytes long, this causes misalignment, and the user space will experience an unexpected padding. Currently it works around this via pointer maths. Make everything more robust by having the compiler reduce the alignment of the struct to 4. The userspace has assertions to ensure this works properly in all situations. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--include/uapi/rdma/bnxt_re-abi.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/uapi/rdma/bnxt_re-abi.h b/include/uapi/rdma/bnxt_re-abi.h
index db54115be044..2d3c9aac661a 100644
--- a/include/uapi/rdma/bnxt_re-abi.h
+++ b/include/uapi/rdma/bnxt_re-abi.h
@@ -53,11 +53,16 @@ struct bnxt_re_uctx_resp {
__u32 rsvd;
};
+/*
+ * This struct is placed after the ib_uverbs_alloc_pd_resp struct, which is
+ * not 8 byted aligned. To avoid undesired padding in various cases we have to
+ * set this struct to packed.
+ */
struct bnxt_re_pd_resp {
__u32 pdid;
__u32 dpi;
__u64 dbr;
-};
+} __attribute__((packed, aligned(4)));
struct bnxt_re_cq_req {
__u64 cq_va;