Update to latest version of TEE Internal Core API

Update the test TAs and xtest to use a the lastest version, 1.3.1, of
TEE Internal Core API. This is basically a matter of replacing a few
uint32_t pointers with size_t pointers instead.

Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/host/xtest/CMakeLists.txt b/host/xtest/CMakeLists.txt
index 84275d1..776787b 100644
--- a/host/xtest/CMakeLists.txt
+++ b/host/xtest/CMakeLists.txt
@@ -16,8 +16,6 @@
 	set (OPENSSL_PRIVATE_LINK OpenSSL::Crypto)
 endif()
 
-add_compile_options(-D__OPTEE_CORE_API_COMPAT_1_1=1)
-
 find_package(Python REQUIRED)
 
 include(GNUInstallDirs)
diff --git a/host/xtest/Makefile b/host/xtest/Makefile
index 105ad64..8505629 100644
--- a/host/xtest/Makefile
+++ b/host/xtest/Makefile
@@ -33,8 +33,6 @@
 $(if $(filter arm, $(1)),32,$(if $(filter aarch64, $(1)),64,unknown-arch))
 endef
 
-CFLAGS += -D__OPTEE_CORE_API_COMPAT_1_1=1
-
 # OpenSSL is used by:
 # - GP tests series 8500
 # - Mbed TLS test 8103
diff --git a/ta/aes_perf/ta_aes_perf.c b/ta/aes_perf/ta_aes_perf.c
index 01ce89e..b16d070 100644
--- a/ta/aes_perf/ta_aes_perf.c
+++ b/ta/aes_perf/ta_aes_perf.c
@@ -89,16 +89,16 @@
 	int unit = 0;
 	void *in = NULL;
 	void *out = NULL;
-	uint32_t insz = 0;
-	uint32_t outsz = 0;
+	size_t insz = 0;
+	size_t outsz = 0;
 	uint32_t exp_param_types = TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT,
 						   TEE_PARAM_TYPE_MEMREF_INOUT,
 						   TEE_PARAM_TYPE_VALUE_INPUT,
 						   TEE_PARAM_TYPE_NONE);
 	bool secure_in = false;
 	bool secure_out = false;
-	TEE_Result (*do_update)(TEE_OperationHandle, const void *, uint32_t,
-				void *, uint32_t *) = NULL;
+	TEE_Result (*do_update)(TEE_OperationHandle, const void *, size_t,
+				void *, size_t *) = NULL;
 
 	if (param_types != exp_param_types)
 		return TEE_ERROR_BAD_PARAMETERS;
diff --git a/ta/concurrent/ta_entry.c b/ta/concurrent/ta_entry.c
index e80c988..aa8a286 100644
--- a/ta/concurrent/ta_entry.c
+++ b/ta/concurrent/ta_entry.c
@@ -83,7 +83,7 @@
 	TEE_Result res = TEE_ERROR_GENERIC;
 	TEE_OperationHandle op = TEE_HANDLE_NULL;
 	void *out = NULL;
-	uint32_t out_len = 0;
+	size_t out_len = 0;
 	size_t num_rounds = 0;
 	uint32_t req_param_types =
 		TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT,
diff --git a/ta/concurrent_large/ta_entry.c b/ta/concurrent_large/ta_entry.c
index d881a41..2be5b9e 100644
--- a/ta/concurrent_large/ta_entry.c
+++ b/ta/concurrent_large/ta_entry.c
@@ -83,7 +83,7 @@
 	TEE_Result res = TEE_ERROR_GENERIC;
 	TEE_OperationHandle op = TEE_HANDLE_NULL;
 	void *out = NULL;
-	uint32_t out_len = 0;
+	size_t out_len = 0;
 	size_t num_rounds = 0;
 	uint32_t req_param_types =
 		TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INOUT,
diff --git a/ta/hash_perf/ta_hash_perf.c b/ta/hash_perf/ta_hash_perf.c
index 716b79d..302b87c 100644
--- a/ta/hash_perf/ta_hash_perf.c
+++ b/ta/hash_perf/ta_hash_perf.c
@@ -43,8 +43,8 @@
 	int n = 0;
 	void *in = NULL;
 	void *out = NULL;
-	uint32_t insz = 0;
-	uint32_t outsz = 0;
+	size_t insz = 0;
+	size_t outsz = 0;
 	uint32_t offset = 0;
 	uint32_t exp_param_types = TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
 						   TEE_PARAM_TYPE_MEMREF_OUTPUT,
diff --git a/ta/os_test/os_test.c b/ta/os_test/os_test.c
index 0e68cc6..7a74c92 100644
--- a/ta/os_test/os_test.c
+++ b/ta/os_test/os_test.c
@@ -74,7 +74,7 @@
 					char *nbuf __unused, char **bbuf, size_t *bblen)
 {
 	TEE_Result res = TEE_ERROR_GENERIC;
-	uint32_t block_len = 0;
+	size_t block_len = 0;
 
 	*bbuf = NULL;
 	*bblen = 0;
@@ -117,10 +117,10 @@
 	char nbuf_small[256] = { };
 	char vbuf[256] = { };
 	char vbuf2[256] = { };
-	uint32_t nblen = sizeof(nbuf);
-	uint32_t nblen_small = 0;
-	uint32_t vblen = sizeof(vbuf);
-	uint32_t vblen2 = sizeof(vbuf2);
+	size_t nblen = sizeof(nbuf);
+	size_t nblen_small = 0;
+	size_t vblen = sizeof(vbuf);
+	size_t vblen2 = sizeof(vbuf2);
 	char *bbuf = NULL;
 	size_t bblen = 0;
 
@@ -131,7 +131,8 @@
 		return res;
 	}
 	if (nblen != strlen(nbuf) + 1) {
-		EMSG("Name has wrong size: %u vs %zu", nblen, strlen(nbuf) + 1);
+		EMSG("Name has wrong size: %zu vs %zu",
+		     nblen, strlen(nbuf) + 1);
 		return TEE_ERROR_GENERIC;
 	}
 
diff --git a/ta/socket/ta_entry.c b/ta/socket/ta_entry.c
index f2547e0..698aa6a 100644
--- a/ta/socket/ta_entry.c
+++ b/ta/socket/ta_entry.c
@@ -167,12 +167,14 @@
 
 static TEE_Result ta_entry_recv(uint32_t param_types, TEE_Param params[4])
 {
+	TEE_Result res = TEE_SUCCESS;
 	struct sock_handle *h = NULL;
 	uint32_t req_param_types =
 		TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
 				TEE_PARAM_TYPE_MEMREF_OUTPUT,
 				TEE_PARAM_TYPE_VALUE_INPUT,
 				TEE_PARAM_TYPE_NONE);
+	uint32_t sz = 0;
 
 	if (param_types != req_param_types) {
 		EMSG("got param_types 0x%x, expected 0x%x",
@@ -184,8 +186,11 @@
 		return TEE_ERROR_BAD_PARAMETERS;
 
 	h = params[0].memref.buffer;
-	return h->socket->recv(h->ctx, params[1].memref.buffer,
-			       &params[1].memref.size, params[2].value.a);
+	sz = params[1].memref.size;
+	res = h->socket->recv(h->ctx, params[1].memref.buffer, &sz,
+			      params[2].value.a);
+	params[1].memref.size = sz;
+	return res;
 }
 
 static TEE_Result ta_entry_error(uint32_t param_types, TEE_Param params[4])
@@ -213,12 +218,14 @@
 
 static TEE_Result ta_entry_ioctl(uint32_t param_types, TEE_Param params[4])
 {
+	TEE_Result res = TEE_SUCCESS;
 	struct sock_handle *h = NULL;
 	uint32_t req_param_types =
 		TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
 				TEE_PARAM_TYPE_MEMREF_INOUT,
 				TEE_PARAM_TYPE_VALUE_INPUT,
 				TEE_PARAM_TYPE_NONE);
+	uint32_t sz = 0;
 
 	if (param_types != req_param_types) {
 		EMSG("got param_types 0x%x, expected 0x%x",
@@ -230,9 +237,11 @@
 		return TEE_ERROR_BAD_PARAMETERS;
 
 	h = params[0].memref.buffer;
-	return h->socket->ioctl(h->ctx, params[2].value.a,
-				params[1].memref.buffer,
-				&params[1].memref.size);
+	sz = params[1].memref.size;
+	res = h->socket->ioctl(h->ctx, params[2].value.a,
+			       params[1].memref.buffer, &sz);
+	params[1].memref.size = sz;
+	return res;
 }
 
 
diff --git a/ta/storage/storage.c b/ta/storage/storage.c
index f63134d..4ad8f8c 100644
--- a/ta/storage/storage.c
+++ b/ta/storage/storage.c
@@ -166,6 +166,7 @@
 {
 	TEE_ObjectHandle o = VAL2HANDLE(params[1].value.a);
 	TEE_Result res = TEE_SUCCESS;
+	size_t sz = 0;
 	void *b0 = NULL;
 
 	ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
@@ -177,8 +178,9 @@
 	if (!b0)
 		return TEE_ERROR_OUT_OF_MEMORY;
 
-	res = TEE_ReadObjectData(o, b0, params[0].memref.size,
-				 &params[1].value.b);
+	sz = params[1].value.b;
+	res = TEE_ReadObjectData(o, b0, params[0].memref.size, &sz);
+	params[1].value.b = sz;
 	if (!res)
 		TEE_MemMove(params[0].memref.buffer, b0, params[0].memref.size);
 	TEE_Free(b0);
@@ -397,8 +399,8 @@
 static TEE_Result check_obj(TEE_ObjectInfo *o1, TEE_ObjectInfo *o2)
 {
 	if ((o1->objectType != o2->objectType) ||
-	    (o1->keySize != o2->keySize) ||
-	    (o1->maxKeySize != o2->maxKeySize) ||
+	    (o1->objectSize != o2->objectSize) ||
+	    (o1->maxObjectSize != o2->maxObjectSize) ||
 	    (o1->objectUsage != o2->objectUsage))
 		return TEE_ERROR_GENERIC;
 	return TEE_SUCCESS;
diff --git a/ta/storage_benchmark/benchmark.c b/ta/storage_benchmark/benchmark.c
index 8852b96..0027309 100644
--- a/ta/storage_benchmark/benchmark.c
+++ b/ta/storage_benchmark/benchmark.c
@@ -149,7 +149,7 @@
 	TEE_Time stop_time = { };
 	size_t remain_bytes = data_size;
 	TEE_Result res = TEE_SUCCESS;
-	uint32_t read_bytes = 0;
+	size_t read_bytes = 0;
 
 	TEE_GetSystemTime(&start_time);
 
@@ -192,7 +192,7 @@
 	TEE_Time stop_time = { };
 	size_t remain_bytes = data_size;
 	TEE_Result res = TEE_SUCCESS;
-	uint32_t read_bytes = 0;
+	size_t read_bytes = 0;
 
 	TEE_GetSystemTime(&start_time);
 
@@ -215,7 +215,7 @@
 		}
 
 		if (read_bytes != write_size) {
-			EMSG("Partial data read, bytes=%u", read_bytes);
+			EMSG("Partial data read, bytes=%zu", read_bytes);
 			res = TEE_ERROR_CORRUPT_OBJECT;
 			goto exit;
 		}
@@ -267,7 +267,7 @@
 
 	tmp_data_size = data_size;
 	while (tmp_data_size > 0) {
-		uint32_t read_bytes = 0;
+		size_t read_bytes = 0;
 
 		res = TEE_ReadObjectData(object, chunk_buf, chunk_size,
 				&read_bytes);
diff --git a/ta/ta_common.mk b/ta/ta_common.mk
index dfa0df3..b8ce142 100644
--- a/ta/ta_common.mk
+++ b/ta/ta_common.mk
@@ -1,4 +1,3 @@
-CFG_TA_OPTEE_CORE_API_COMPAT_1_1=y
 # Note that it is important that that $(BINARY) is set before we include
 # ta_dev_kit.mk. In the optee_test this is done in the individual TA Makefiles.
 include $(TA_DEV_KIT_DIR)/mk/ta_dev_kit.mk