diff mbox series

[rdma-core,2/3] verbs: Fix implicit ODP MR support for 32 bit systems

Message ID 1551113128-16917-3-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show
Series verbs: Implicit ODP support | expand

Commit Message

Yishai Hadas Feb. 25, 2019, 4:45 p.m. UTC
From: Moni Shoua <monis@mellanox.com>

One of the conditions to recognize an implicit ODP MR in kernel is
having length of UINT64_MAX. Since the type of the parameter 'length'
in ibv_reg_mr() is size_t which is 32 bit long, it is impossible for
an application that runs on a 32 bit system to pass this value to the
library.

To solve this, let ibv_cmd_reg_mr() replace SIZE_MAX with UINT64_MAX
when building the command to the kernel. On 64 bit systems this has no
effect. On 32 bit systems set a value that the kernel understands as a
request for implicit ODP MR.

Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 libibverbs/cmd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c
index ec551e2..7bcaeea 100644
--- a/libibverbs/cmd.c
+++ b/libibverbs/cmd.c
@@ -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;