Commit 0d0f738f authored by David Ahern's avatar David Ahern Committed by Doug Ledford

IB/core: Fix unaligned accesses

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: default avatarDavid Ahern <david.ahern@oracle.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 471e7058
...@@ -437,39 +437,38 @@ static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id) ...@@ -437,39 +437,38 @@ static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id)
return cm_id_priv; return cm_id_priv;
} }
static void cm_mask_copy(u8 *dst, u8 *src, u8 *mask) static void cm_mask_copy(u32 *dst, const u32 *src, const u32 *mask)
{ {
int i; int i;
for (i = 0; i < IB_CM_COMPARE_SIZE / sizeof(unsigned long); i++) for (i = 0; i < IB_CM_COMPARE_SIZE; i++)
((unsigned long *) dst)[i] = ((unsigned long *) src)[i] & dst[i] = src[i] & mask[i];
((unsigned long *) mask)[i];
} }
static int cm_compare_data(struct ib_cm_compare_data *src_data, static int cm_compare_data(struct ib_cm_compare_data *src_data,
struct ib_cm_compare_data *dst_data) struct ib_cm_compare_data *dst_data)
{ {
u8 src[IB_CM_COMPARE_SIZE]; u32 src[IB_CM_COMPARE_SIZE];
u8 dst[IB_CM_COMPARE_SIZE]; u32 dst[IB_CM_COMPARE_SIZE];
if (!src_data || !dst_data) if (!src_data || !dst_data)
return 0; return 0;
cm_mask_copy(src, src_data->data, dst_data->mask); cm_mask_copy(src, src_data->data, dst_data->mask);
cm_mask_copy(dst, dst_data->data, src_data->mask); cm_mask_copy(dst, dst_data->data, src_data->mask);
return memcmp(src, dst, IB_CM_COMPARE_SIZE); return memcmp(src, dst, sizeof(src));
} }
static int cm_compare_private_data(u8 *private_data, static int cm_compare_private_data(u32 *private_data,
struct ib_cm_compare_data *dst_data) struct ib_cm_compare_data *dst_data)
{ {
u8 src[IB_CM_COMPARE_SIZE]; u32 src[IB_CM_COMPARE_SIZE];
if (!dst_data) if (!dst_data)
return 0; return 0;
cm_mask_copy(src, private_data, dst_data->mask); cm_mask_copy(src, private_data, dst_data->mask);
return memcmp(src, dst_data->data, IB_CM_COMPARE_SIZE); return memcmp(src, dst_data->data, sizeof(src));
} }
/* /*
...@@ -538,7 +537,7 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) ...@@ -538,7 +537,7 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
static struct cm_id_private * cm_find_listen(struct ib_device *device, static struct cm_id_private * cm_find_listen(struct ib_device *device,
__be64 service_id, __be64 service_id,
u8 *private_data) u32 *private_data)
{ {
struct rb_node *node = cm.listen_service_table.rb_node; struct rb_node *node = cm.listen_service_table.rb_node;
struct cm_id_private *cm_id_priv; struct cm_id_private *cm_id_priv;
...@@ -953,7 +952,7 @@ int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask, ...@@ -953,7 +952,7 @@ int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
cm_mask_copy(cm_id_priv->compare_data->data, cm_mask_copy(cm_id_priv->compare_data->data,
compare_data->data, compare_data->mask); compare_data->data, compare_data->mask);
memcpy(cm_id_priv->compare_data->mask, compare_data->mask, memcpy(cm_id_priv->compare_data->mask, compare_data->mask,
IB_CM_COMPARE_SIZE); sizeof(compare_data->mask));
} }
cm_id->state = IB_CM_LISTEN; cm_id->state = IB_CM_LISTEN;
......
...@@ -103,7 +103,7 @@ struct cm_req_msg { ...@@ -103,7 +103,7 @@ struct cm_req_msg {
/* local ACK timeout:5, rsvd:3 */ /* local ACK timeout:5, rsvd:3 */
u8 alt_offset139; u8 alt_offset139;
u8 private_data[IB_CM_REQ_PRIVATE_DATA_SIZE]; u32 private_data[IB_CM_REQ_PRIVATE_DATA_SIZE / sizeof(u32)];
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -801,7 +801,7 @@ struct cm_sidr_req_msg { ...@@ -801,7 +801,7 @@ struct cm_sidr_req_msg {
__be16 rsvd; __be16 rsvd;
__be64 service_id; __be64 service_id;
u8 private_data[IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE]; u32 private_data[IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE / sizeof(u32)];
} __attribute__ ((packed)); } __attribute__ ((packed));
struct cm_sidr_rep_msg { struct cm_sidr_rep_msg {
......
...@@ -105,7 +105,8 @@ enum ib_cm_data_size { ...@@ -105,7 +105,8 @@ enum ib_cm_data_size {
IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
IB_CM_SIDR_REP_INFO_LENGTH = 72, IB_CM_SIDR_REP_INFO_LENGTH = 72,
IB_CM_COMPARE_SIZE = 64 /* compare done u32 at a time */
IB_CM_COMPARE_SIZE = (64 / sizeof(u32))
}; };
struct ib_cm_id; struct ib_cm_id;
...@@ -337,8 +338,8 @@ void ib_destroy_cm_id(struct ib_cm_id *cm_id); ...@@ -337,8 +338,8 @@ void ib_destroy_cm_id(struct ib_cm_id *cm_id);
#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL) #define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
struct ib_cm_compare_data { struct ib_cm_compare_data {
u8 data[IB_CM_COMPARE_SIZE]; u32 data[IB_CM_COMPARE_SIZE];
u8 mask[IB_CM_COMPARE_SIZE]; u32 mask[IB_CM_COMPARE_SIZE];
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment