@@ -336,6 +336,16 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
cmd->start = (uintptr_t) addr;
cmd->length = length;
+ /* On demand access and entire address space means implicit.
+ * In that case set the value in the command to what kernel expects.
+ */
+ if (access & IBV_ACCESS_ON_DEMAND) {
+ if (length == SIZE_MAX && addr)
+ return EINVAL;
+ if (length == SIZE_MAX)
+ cmd->length = UINT64_MAX;
+ }
+
cmd->hca_va = hca_va;
cmd->pd_handle = pd->handle;
cmd->access_flags = access;