Skip to content

Commit

Permalink
RDMA completion debug logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95858 committed Dec 3, 2023
1 parent 3939362 commit 03ec957
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/src/mmalloc/mmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <time.h>
#include <errno.h>
#include <pthread.h>
#include <assert.h>
#include "mmalloc.h"
#include "../coll/rbt.h"
#include "ovis-test/test.h"
Expand Down Expand Up @@ -104,6 +105,24 @@ static int compare_addr(void *node_key, const void *val_key)

static mm_region_t mmr;

void mm_validate_access(void *addr, size_t size)
{
struct rbn *rbn;
struct mm_prefix *pfx;
assert((uint64_t)addr >= (uint64_t)mmr->start);
assert(((uint64_t)addr + (uint64_t)size) <
((uint64_t)mmr->start + (uint64_t)mmr->size));
RBT_FOREACH(rbn, &mmr->addr_tree) {
pfx = container_of(rbn, struct mm_prefix, addr_node);
if ((uint64_t)addr < (uint64_t)pfx) {
assert((uint64_t)addr + (uint64_t)size < (uint64_t)pfx);
} else {
size_t size = pfx->count << mmr->grain_bits;
assert((uint64_t)addr > (uint64_t)pfx + (uint64_t)size);
}
}
}

void mm_get_info(struct mm_info *mmi)
{
mmi->grain = mmr->grain;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/zap/sock/zap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ void __sock_io_free(struct z_sock_ep *sep, struct z_sock_io *io)
*/
static void process_sep_msg_read_resp(struct z_sock_ep *sep)
{
void mm_validate_access(void *addr, size_t size);
struct z_sock_io *io;
struct sock_msg_read_resp *msg;
uint32_t data_len;
Expand Down Expand Up @@ -709,6 +710,9 @@ static void process_sep_msg_read_resp(struct z_sock_ep *sep)
data_len, 0);
switch (rc) {
case 0:
/* Verify that the dst_ptr is not
reallocated/free in the mmr */
mm_validate_access(io->dst_ptr, data_len);
memcpy(io->dst_ptr, msg->data, data_len);
break;
case EACCES:
Expand Down

0 comments on commit 03ec957

Please sign in to comment.