Fix Storage TA ABI TEE_ObjectInfo

With the updated types for GP 1.3 TEE_ObjectInfo contains elements with
the type size_t. If xtest is built for AArch64 while the storage TA is
built for AArch32 the ABI will become incompatible. Fix this by adding
struct ta_storage_obj_info with fixed width integers only and use that
in the TA ABI used by xtest.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
diff --git a/host/xtest/regression_6000.c b/host/xtest/regression_6000.c
index 6843b24..bad8cb6 100644
--- a/host/xtest/regression_6000.c
+++ b/host/xtest/regression_6000.c
@@ -407,9 +407,11 @@
 }
 
 static TEEC_Result fs_get_obj_info(TEEC_Session *sess, uint32_t obj,
-				void *obj_info, size_t info_size)
+				   TEE_ObjectInfo *obj_info)
 {
+	TEEC_Result res = TEEC_SUCCESS;
 	TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
+	struct ta_storage_obj_info oi = { };
 	uint32_t org = 0;
 
 	op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
@@ -417,10 +419,21 @@
 					TEEC_NONE, TEEC_NONE);
 
 	op.params[0].value.a = obj;
-	op.params[1].tmpref.buffer = obj_info;
-	op.params[1].tmpref.size = info_size;
+	op.params[1].tmpref.buffer = &oi;
+	op.params[1].tmpref.size = sizeof(oi);
 
-	return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_GET_OBJ_INFO, &op, &org);
+	res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_GET_OBJ_INFO, &op, &org);
+	if (!res) {
+		obj_info->objectType = oi.object_type;
+		obj_info->objectSize = oi.object_size;
+		obj_info->maxObjectSize = oi.max_object_size;
+		obj_info->objectUsage = oi.object_usage;
+		obj_info->dataSize = oi.data_size;
+		obj_info->dataPosition = oi.data_position;
+		obj_info->handleFlags = oi.handle_flags;
+	}
+
+	return res;
 }
 
 /* Record availability of all secure storage types at runtime */
@@ -1826,8 +1839,7 @@
 		goto exit;
 
 	if (!ADBG_EXPECT_TEEC_SUCCESS(c,
-		fs_get_obj_info(&sess, obj, &obj_info1,
-				sizeof(TEE_ObjectInfo))))
+		fs_get_obj_info(&sess, obj, &obj_info1)))
 		goto exit;
 
 	if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
@@ -1839,8 +1851,7 @@
 		goto exit;
 
 	if (!ADBG_EXPECT_TEEC_SUCCESS(c,
-		fs_get_obj_info(&sess, obj, &obj_info2,
-				sizeof(TEE_ObjectInfo))))
+		fs_get_obj_info(&sess, obj, &obj_info2)))
 		goto exit;
 
 	if (!ADBG_EXPECT_COMPARE_UNSIGNED(c,
@@ -1899,8 +1910,7 @@
 	}
 
 	if (!ADBG_EXPECT_TEEC_SUCCESS(c,
-		fs_get_obj_info(&sess, obj, &obj_info1,
-				sizeof(TEE_ObjectInfo))))
+		fs_get_obj_info(&sess, obj, &obj_info1)))
 		goto exit;
 
 	if (!ADBG_EXPECT_COMPARE_UNSIGNED(c,
@@ -1917,8 +1927,7 @@
 		goto exit;
 
 	if (!ADBG_EXPECT_TEEC_SUCCESS(c,
-		fs_get_obj_info(&sess, obj, &obj_info2,
-				sizeof(TEE_ObjectInfo))))
+		fs_get_obj_info(&sess, obj, &obj_info2)))
 		goto exit;
 
 	if (!ADBG_EXPECT_COMPARE_UNSIGNED(c,
diff --git a/ta/include/ta_storage.h b/ta/include/ta_storage.h
index e61e23b..a4b1bc8 100644
--- a/ta/include/ta_storage.h
+++ b/ta/include/ta_storage.h
@@ -12,6 +12,16 @@
 #define TA_STORAGE2_UUID { 0x731e279e, 0xaafb, 0x4575, \
 	{ 0xa7, 0x71, 0x38, 0xca, 0xa6, 0xf0, 0xcc, 0xa6 } }
 
+struct ta_storage_obj_info {
+	uint32_t object_type;
+	uint32_t object_size;
+	uint32_t max_object_size;
+	uint32_t object_usage;
+	uint32_t data_size;
+	uint32_t data_position;
+	uint32_t handle_flags;
+};
+
 #define TA_STORAGE_CMD_OPEN			0
 #define TA_STORAGE_CMD_CLOSE			1
 #define TA_STORAGE_CMD_READ			2
diff --git a/ta/storage/storage.c b/ta/storage/storage.c
index 3db9d41..93548a3 100644
--- a/ta/storage/storage.c
+++ b/ta/storage/storage.c
@@ -636,6 +636,7 @@
 					    TEE_Param params[4])
 {
 	TEE_Result res = TEE_ERROR_GENERIC;
+	struct ta_storage_obj_info oi = { };
 	TEE_ObjectInfo info = { };
 	TEE_ObjectHandle o = VAL2HANDLE(params[0].value.a);
 
@@ -644,12 +645,19 @@
 			   TEE_PARAM_TYPE_MEMREF_OUTPUT, TEE_PARAM_TYPE_NONE,
 			   TEE_PARAM_TYPE_NONE));
 
-	if (params[1].memref.size < sizeof(info))
+	if (params[1].memref.size < sizeof(oi))
 		return TEE_ERROR_SHORT_BUFFER;
 	res = TEE_GetObjectInfo1(o, &info);
 	if (!res) {
-		params[1].memref.size = sizeof(info);
-		TEE_MemMove(params[1].memref.buffer, &info, sizeof(info));
+		params[1].memref.size = sizeof(oi);
+		oi.object_type = info.objectType;
+		oi.object_size = info.objectSize;
+		oi.max_object_size = info.maxObjectSize;
+		oi.object_usage = info.objectUsage;
+		oi.data_size = info.dataSize;
+		oi.data_position = info.dataPosition;
+		oi.handle_flags = info.handleFlags;
+		TEE_MemMove(params[1].memref.buffer, &oi, sizeof(oi));
 	}
 
 	return res;