@@ -1133,9 +1133,10 @@ static void smcr_buf_unuse(struct smc_buf_desc *buf_desc, bool is_rmb,
smc_buf_free(lgr, is_rmb, buf_desc);
} else {
- /* memzero_explicit provides potential memory barrier semantics */
- memzero_explicit(buf_desc->cpu_addr, buf_desc->len);
- WRITE_ONCE(buf_desc->used, 0);
+ memset(buf_desc->cpu_addr, 0, buf_desc->len);
+ /* make sure buf_desc->used not be reordered ahead */
+ smp_mb__before_atomic();
+ xchg(&buf_desc->used, 0);
}
}
@@ -1146,17 +1147,21 @@ static void smc_buf_unuse(struct smc_connection *conn,
if (!lgr->is_smcd && conn->sndbuf_desc->is_vm) {
smcr_buf_unuse(conn->sndbuf_desc, false, lgr);
} else {
- memzero_explicit(conn->sndbuf_desc->cpu_addr, conn->sndbuf_desc->len);
- WRITE_ONCE(conn->sndbuf_desc->used, 0);
+ memset(conn->sndbuf_desc->cpu_addr, 0, conn->sndbuf_desc->len);
+ /* make sure buf_desc->used not be reordered ahead */
+ smp_mb__before_atomic();
+ xchg(&conn->sndbuf_desc->used, 0);
}
}
if (conn->rmb_desc) {
if (!lgr->is_smcd) {
smcr_buf_unuse(conn->rmb_desc, true, lgr);
} else {
- memzero_explicit(conn->rmb_desc->cpu_addr,
- conn->rmb_desc->len + sizeof(struct smcd_cdc_msg));
- WRITE_ONCE(conn->rmb_desc->used, 0);
+ memset(conn->rmb_desc->cpu_addr, 0,
+ conn->rmb_desc->len + sizeof(struct smcd_cdc_msg));
+ /* make sure buf_desc->used not be reordered ahead */
+ smp_mb__before_atomic();
+ xchg(&conn->rmb_desc->used, 0);
}
}
}