Skip to content

Commit

Permalink
smsc/xpmem: retry with requested if aligned range cannot be mapped
Browse files Browse the repository at this point in the history
The aligned range computed in mca_smsc_xpmem_map_peer_region may
reach past the end of the stack, which may cause the mapping to fail.
Retrying with the requested upper bound has a better chance to succeed.

Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Mar 16, 2022
1 parent 1440592 commit ae71d72
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions opal/mca/smsc/xpmem/smsc_xpmem_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,14 @@ void *mca_smsc_xpmem_map_peer_region(mca_smsc_endpoint_t *endpoint, uint64_t fla

reg->rcache_context = xpmem_attach(xpmem_addr, bound - base, NULL);
if (OPAL_UNLIKELY((void *) -1 == reg->rcache_context)) {
OBJ_RELEASE(reg);
return NULL;
/* retry with the provided range as the upper bound */
bound = (uintptr_t)remote_ptr + size;
reg->bound = (unsigned char *) bound;
reg->rcache_context = xpmem_attach(xpmem_addr, bound - base, NULL);
if (OPAL_UNLIKELY((void *) -1 == reg->rcache_context)) {
OBJ_RELEASE(reg);
return NULL;
}
}

opal_memchecker_base_mem_defined(reg->rcache_context, bound - base);
Expand Down Expand Up @@ -307,5 +313,5 @@ mca_smsc_xpmem_module_t mca_smsc_xpmem_module = {
.copy_from = mca_smsc_xpmem_copy_from,
.map_peer_region = mca_smsc_xpmem_map_peer_region,
.unmap_peer_region = mca_smsc_xpmem_unmap_peer_region,
},
},
};

0 comments on commit ae71d72

Please sign in to comment.