Updating parameters for SPCI memory sharing calls to match beta spec.

Bug: 132420445
Change-Id: I7b3ef367e9e1b9027d0d827c522035fb80900088
diff --git a/inc/hf/api.h b/inc/hf/api.h
index f8de195..c5ebe2a 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -62,6 +62,6 @@
 			       const struct vcpu *current, struct vcpu **next);
 struct spci_value api_spci_mem_send(uint32_t share_func, ipaddr_t address,
 				    uint32_t page_count,
-				    uint32_t remaining_fragment_count,
-				    uint32_t length, uint32_t handle,
-				    struct vcpu *current, struct vcpu **next);
+				    uint32_t fragment_length, uint32_t length,
+				    uint32_t cookie, struct vcpu *current,
+				    struct vcpu **next);
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index ad26137..eec0df6 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -131,40 +131,42 @@
 		.arg4 = attributes});
 }
 
-static inline struct spci_value spci_mem_donate(
-	uint32_t remaining_fragment_count, uint32_t length, uint32_t handle)
+static inline struct spci_value spci_mem_donate(uint32_t fragment_length,
+						uint32_t length,
+						uint32_t cookie)
 {
 	return spci_call((struct spci_value){.func = SPCI_MEM_DONATE_32,
-					     .arg3 = remaining_fragment_count,
+					     .arg3 = fragment_length,
 					     .arg4 = length,
-					     .arg5 = handle});
+					     .arg5 = cookie});
 }
 
-static inline struct spci_value spci_mem_lend(uint32_t remaining_fragment_count,
-					      uint32_t length, uint32_t handle)
+static inline struct spci_value spci_mem_lend(uint32_t fragment_length,
+					      uint32_t length, uint32_t cookie)
 {
 	return spci_call((struct spci_value){.func = SPCI_MEM_LEND_32,
-					     .arg3 = remaining_fragment_count,
+					     .arg3 = fragment_length,
 					     .arg4 = length,
-					     .arg5 = handle});
+					     .arg5 = cookie});
 }
 
-static inline struct spci_value spci_mem_share(
-	uint32_t remaining_fragment_count, uint32_t length, uint32_t handle)
+static inline struct spci_value spci_mem_share(uint32_t fragment_length,
+					       uint32_t length, uint32_t cookie)
 {
 	return spci_call((struct spci_value){.func = SPCI_MEM_SHARE_32,
-					     .arg3 = remaining_fragment_count,
+					     .arg3 = fragment_length,
 					     .arg4 = length,
-					     .arg5 = handle});
+					     .arg5 = cookie});
 }
 
-static inline struct spci_value hf_spci_mem_relinquish(
-	uint32_t remaining_fragment_count, uint32_t length, uint32_t handle)
+static inline struct spci_value hf_spci_mem_relinquish(uint32_t fragment_length,
+						       uint32_t length,
+						       uint32_t cookie)
 {
 	return spci_call((struct spci_value){.func = HF_SPCI_MEM_RELINQUISH,
-					     .arg3 = remaining_fragment_count,
+					     .arg3 = fragment_length,
 					     .arg4 = length,
-					     .arg5 = handle});
+					     .arg5 = cookie});
 }
 
 /**
diff --git a/src/api.c b/src/api.c
index 062a495..5ddc5f9 100644
--- a/src/api.c
+++ b/src/api.c
@@ -379,6 +379,7 @@
 	case SPCI_MEM_SHARE_32:
 	case HF_SPCI_MEM_RELINQUISH:
 		return (struct spci_value){.func = receiver->mailbox.recv_func,
+					   .arg3 = receiver->mailbox.recv_size,
 					   .arg4 = receiver->mailbox.recv_size};
 	default:
 		/* This should never be reached, but return an error in case. */
@@ -1423,9 +1424,9 @@
 
 struct spci_value api_spci_mem_send(uint32_t share_func, ipaddr_t address,
 				    uint32_t page_count,
-				    uint32_t remaining_fragment_count,
-				    uint32_t length, uint32_t handle,
-				    struct vcpu *current, struct vcpu **next)
+				    uint32_t fragment_length, uint32_t length,
+				    uint32_t cookie, struct vcpu *current,
+				    struct vcpu **next)
 {
 	struct vm *from = current->vm;
 	struct vm *to;
@@ -1443,8 +1444,8 @@
 		return spci_error(SPCI_INVALID_PARAMETERS);
 	}
 
-	if (handle == 0 && remaining_fragment_count != 0) {
-		/* Handle is required if there are multiple fragments. */
+	if ((cookie == 0) != (fragment_length == length)) {
+		/* Cookie is required iff there are multiple fragments. */
 		return spci_error(SPCI_INVALID_PARAMETERS);
 	}
 
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index 73413cf..0c4fe92 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -76,7 +76,8 @@
 							cacheability[l],
 							shareability[k]);
 					EXPECT_SPCI_ERROR(
-						send_function(0, msg_size, 0),
+						send_function(msg_size,
+							      msg_size, 0),
 						SPCI_INVALID_PARAMETERS);
 				}
 				for (l = 0; l < ARRAY_SIZE(device); ++l) {
@@ -91,7 +92,8 @@
 							device[l],
 							shareability[k]);
 					EXPECT_SPCI_ERROR(
-						send_function(0, msg_size, 0),
+						send_function(msg_size,
+							      msg_size, 0),
 						SPCI_INVALID_PARAMETERS);
 				}
 			}
@@ -149,7 +151,7 @@
 			constituent_count, 0, 0, SPCI_MEMORY_RW_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 	}
 }
@@ -176,7 +178,7 @@
 				SPCI_MEMORY_CACHE_WRITE_BACK,
 				SPCI_MEMORY_OUTER_SHAREABLE);
 			EXPECT_SPCI_ERROR(
-				hf_spci_mem_relinquish(0, msg_size, 0),
+				hf_spci_mem_relinquish(msg_size, msg_size, 0),
 				SPCI_INVALID_PARAMETERS);
 		}
 	}
@@ -211,7 +213,7 @@
 		SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(run_res.func, SPCI_YIELD_32);
@@ -254,7 +256,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be returned. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -316,7 +318,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 	run_res = spci_run(SERVICE_VM1, 0);
 
 	/* Let the memory be returned. */
@@ -359,7 +361,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/*
 	 * Let the service access the memory, and try and fail to relinquish it.
@@ -391,7 +393,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be returned. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -429,7 +431,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be returned. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -464,7 +466,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be returned. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -477,7 +479,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Observe the service doesn't fault when accessing the memory. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -506,7 +508,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be returned. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -519,7 +521,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -620,7 +622,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -641,7 +643,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -680,7 +682,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -701,7 +703,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	/*
@@ -739,7 +741,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 	run_res = spci_run(SERVICE_VM1, 0);
 
 	/* Let the memory be returned. */
@@ -752,7 +754,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -790,7 +792,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be sent from VM1 to VM2. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -837,7 +839,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be received. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -888,7 +890,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 }
 
@@ -912,7 +914,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_lend(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 }
 
@@ -936,7 +938,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_share(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 }
 
@@ -965,7 +967,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	msg_size = spci_memory_region_init(
@@ -973,7 +975,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	msg_size = spci_memory_region_init(
@@ -981,7 +983,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	/* Successfully donate to VM1. */
@@ -990,7 +992,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Receive and return memory from VM1. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1030,15 +1032,16 @@
 				SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 				SPCI_MEMORY_CACHE_WRITE_BACK,
 				SPCI_MEMORY_OUTER_SHAREABLE);
-			EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
-					  SPCI_INVALID_PARAMETERS);
+			EXPECT_SPCI_ERROR(
+				spci_mem_donate(msg_size, msg_size, 0),
+				SPCI_INVALID_PARAMETERS);
 			msg_size = spci_memory_region_init(
 				mb.send, HF_PRIMARY_VM_ID, SERVICE_VM1,
 				constituents, ARRAY_SIZE(constituents), 0, 0,
 				SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 				SPCI_MEMORY_CACHE_WRITE_BACK,
 				SPCI_MEMORY_OUTER_SHAREABLE);
-			EXPECT_SPCI_ERROR(spci_mem_lend(0, msg_size, 0),
+			EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size, 0),
 					  SPCI_INVALID_PARAMETERS);
 		}
 	}
@@ -1068,7 +1071,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_lend(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	/* Lend memory to VM1. */
@@ -1077,7 +1080,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Receive and return memory from VM1. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1115,7 +1118,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1135,7 +1138,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1172,7 +1175,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1198,7 +1201,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1241,7 +1244,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1266,7 +1269,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1311,7 +1314,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Attempt to execute from memory. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1323,7 +1326,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_NX,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -1358,7 +1361,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RO_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Attempt to execute from memory. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1370,7 +1373,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RO_NX,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -1403,7 +1406,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1418,7 +1421,7 @@
 			ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 	}
 
@@ -1428,7 +1431,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 }
 
 /**
@@ -1458,7 +1461,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1477,7 +1480,7 @@
 			ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 	}
 
@@ -1487,7 +1490,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 }
 
 /**
@@ -1517,7 +1520,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1557,7 +1560,7 @@
 			ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RO_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_lend(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 	}
 }
@@ -1588,7 +1591,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Let the memory be accessed. */
 	run_res = spci_run(SERVICE_VM1, 0);
@@ -1618,7 +1621,7 @@
 			ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RO_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_share(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 	}
 }
@@ -1647,7 +1650,7 @@
 		ARRAY_SIZE(constituents), 0, SPCI_MEMORY_REGION_FLAG_CLEAR,
 		SPCI_MEMORY_RO_X, SPCI_MEMORY_NORMAL_MEM,
 		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_share(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_share(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Check that it has been cleared. */
 	for (i = 0; i < PAGE_SIZE * 2; ++i) {
@@ -1688,7 +1691,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -1710,7 +1713,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM2, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -1750,7 +1753,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM1, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
@@ -1772,7 +1775,7 @@
 		ARRAY_SIZE(constituents), 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	run_res = spci_run(SERVICE_VM2, 0);
 	EXPECT_EQ(exception_handler_receive_exception_count(&run_res, mb.recv),
diff --git a/test/vmapi/primary_with_secondaries/services/memory.c b/test/vmapi/primary_with_secondaries/services/memory.c
index d10044b..38b292d 100644
--- a/test/vmapi/primary_with_secondaries/services/memory.c
+++ b/test/vmapi/primary_with_secondaries/services/memory.c
@@ -78,7 +78,7 @@
 		ARRAY_SIZE(constituents), 0, SPCI_MEMORY_REGION_FLAG_CLEAR,
 		SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	exception_setup(NULL, exception_handler_yield);
 
@@ -101,7 +101,7 @@
 		ARRAY_SIZE(constituents), 0, SPCI_MEMORY_REGION_FLAG_CLEAR,
 		SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_lend(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_lend(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	exception_setup(NULL, exception_handler_yield);
 
@@ -152,7 +152,7 @@
 			SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
 		EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-		EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func,
+		EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func,
 			  SPCI_SUCCESS_32);
 
 		/*
@@ -259,7 +259,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 	EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Ensure that we are unable to modify memory any more. */
 	ptr[0] = 'c';
@@ -292,14 +292,14 @@
 		send_buf, SERVICE_VM1, HF_PRIMARY_VM_ID, &constituent, 1, 0, 0,
 		SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Attempt to donate the memory to another VM. */
 	msg_size = spci_memory_region_init(
 		send_buf, hf_vm_get_id(), SERVICE_VM2, &constituent, 1, 0, 0,
 		SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
 		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	spci_yield();
@@ -355,7 +355,7 @@
 		memory_region->constituent_count, 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Fail to donate the memory from the primary to VM2. */
 	msg_size = spci_memory_region_init(
@@ -364,7 +364,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 	EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-	EXPECT_SPCI_ERROR(spci_mem_donate(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_donate(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 	spci_yield();
 }
@@ -420,7 +420,7 @@
 			SPCI_MEMORY_OUTER_SHAREABLE);
 		/* Relevant information read, mailbox can be cleared. */
 		EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-		EXPECT_EQ(hf_spci_mem_relinquish(0, msg_size, 0).func,
+		EXPECT_EQ(hf_spci_mem_relinquish(msg_size, msg_size, 0).func,
 			  SPCI_SUCCESS_32);
 
 		/*
@@ -468,7 +468,7 @@
 			SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
 		EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-		EXPECT_SPCI_ERROR(hf_spci_mem_relinquish(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(hf_spci_mem_relinquish(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 
 		/* Ensure we still have access to the memory. */
@@ -501,7 +501,7 @@
 		memory_region->constituent_count, 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(hf_spci_mem_relinquish(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(hf_spci_mem_relinquish(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	/* Give the memory back and notify the sender. */
@@ -510,7 +510,8 @@
 		memory_region->constituent_count, 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(hf_spci_mem_relinquish(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(hf_spci_mem_relinquish(msg_size, msg_size, 0).func,
+		  SPCI_SUCCESS_32);
 
 	/* Ensure we cannot lend from the primary to another secondary. */
 	msg_size = spci_memory_region_init(
@@ -518,7 +519,7 @@
 		memory_region->constituent_count, 0, 0, SPCI_MEMORY_RW_X,
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_SPCI_ERROR(spci_mem_lend(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	/* Ensure we cannot share from the primary to another secondary. */
@@ -528,7 +529,7 @@
 		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 		SPCI_MEMORY_OUTER_SHAREABLE);
 	EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-	EXPECT_SPCI_ERROR(spci_mem_share(0, msg_size, 0),
+	EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size, 0),
 			  SPCI_INVALID_PARAMETERS);
 
 	spci_yield();
@@ -572,7 +573,7 @@
 			SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
 		EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
-		EXPECT_EQ(hf_spci_mem_relinquish(0, msg_size, 0).func,
+		EXPECT_EQ(hf_spci_mem_relinquish(msg_size, msg_size, 0).func,
 			  SPCI_SUCCESS_32);
 	}
 }
@@ -629,7 +630,7 @@
 			&constituent_copy, 1, 0, 0, SPCI_MEMORY_RW_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_EQ(hf_spci_mem_relinquish(0, msg_size, 0).func,
+		EXPECT_EQ(hf_spci_mem_relinquish(msg_size, msg_size, 0).func,
 			  SPCI_SUCCESS_32);
 	}
 }
@@ -738,14 +739,14 @@
 			&constituent_copy, 1, 0, 0, SPCI_MEMORY_RW_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_lend(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_lend(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 		msg_size = spci_memory_region_init(
 			send_buf, HF_PRIMARY_VM_ID, SERVICE_VM2,
 			&constituent_copy, 1, 0, 0, SPCI_MEMORY_RW_X,
 			SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
 			SPCI_MEMORY_OUTER_SHAREABLE);
-		EXPECT_SPCI_ERROR(spci_mem_share(0, msg_size, 0),
+		EXPECT_SPCI_ERROR(spci_mem_share(msg_size, msg_size, 0),
 				  SPCI_INVALID_PARAMETERS);
 	}
 
diff --git a/test/vmapi/primary_with_secondaries/services/unmapped.c b/test/vmapi/primary_with_secondaries/services/unmapped.c
index c956b0f..df00f6c 100644
--- a/test/vmapi/primary_with_secondaries/services/unmapped.c
+++ b/test/vmapi/primary_with_secondaries/services/unmapped.c
@@ -50,7 +50,7 @@
 		SPCI_MEMORY_OUTER_SHAREABLE);
 	exception_setup(NULL, exception_handler_yield);
 
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	*(volatile uint64_t *)(&pages[PAGE_SIZE - 6]);
 	FAIL("Exception not generated by invalid access.");
@@ -87,7 +87,7 @@
 
 	exception_setup(NULL, exception_handler_yield);
 
-	EXPECT_EQ(spci_mem_donate(0, msg_size, 0).func, SPCI_SUCCESS_32);
+	EXPECT_EQ(spci_mem_donate(msg_size, msg_size, 0).func, SPCI_SUCCESS_32);
 
 	/* Branch to instruction whose 2 bytes are now in an unmapped page. */
 	f();