xtest: add a SDP test in the non-regression suite
xtest regression test #1014 is dedicated to secure data path.
It is enable only upon CFG_SECURE_DATA_PATH=y.
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
diff --git a/host/xtest/sdp_basic.c b/host/xtest/sdp_basic.c
index d843c04..3194951 100644
--- a/host/xtest/sdp_basic.c
+++ b/host/xtest/sdp_basic.c
@@ -37,9 +37,9 @@
#include <tee_client_api_extensions.h>
#include <unistd.h>
-#include "include/uapi/linux/ion.h"
-#include "ta_sdp_basic.h"
#include "crypto_common.h"
+#include "sdp_basic.h"
+#include "xtest_test.h"
/*
* SDP basic test setup overview.
@@ -78,21 +78,6 @@
TEEC_Session sess;
};
-/* exported to xtest */
-int allocate_ion_buffer(size_t size, int heap_id);
-
-/* non zero value forces buffer to be mappeable from nonsecure */
-#define BUF_MUST_MAP 0
-
-#define DEFAULT_ION_HEAP_TYPE ION_HEAP_TYPE_UNMAPPED
-
-enum test_target_ta {
- TEST_NS_TO_TA,
- TEST_NS_TO_PTA,
- TEST_TA_TO_TA,
- TEST_TA_TO_PTA,
-};
-
int allocate_ion_buffer(size_t size, int heap_id)
{
struct ion_allocation_data alloc_data;
@@ -153,8 +138,6 @@
static int create_tee_ctx(struct tee_ctx *ctx, enum test_target_ta target_ta)
{
TEEC_Result teerc;
- TEEC_UUID ta_uuid = TA_SDP_BASIC_UUID;
- TEEC_UUID pta_uuid = PTA_INVOKE_TESTS_UUID;
TEEC_UUID *uuid;
uint32_t err_origin;
@@ -162,10 +145,10 @@
case TEST_NS_TO_TA:
case TEST_TA_TO_TA:
case TEST_TA_TO_PTA:
- uuid = &ta_uuid;
+ uuid = &sdp_basic_ta_uuid;
break;
case TEST_NS_TO_PTA:
- uuid = &pta_uuid;
+ uuid = &pta_invoke_tests_ta_uuid;
break;
default:
return -1;
@@ -422,9 +405,8 @@
}
-static int sdp_basic_test(enum test_target_ta ta,
- size_t size, size_t loop, int ion_heap,
- int rnd_offset)
+int sdp_basic_test(enum test_target_ta ta, size_t size, size_t loop,
+ int ion_heap, int rnd_offset)
{
struct tee_ctx *ctx = NULL;
unsigned char *test_buf = NULL;
diff --git a/host/xtest/sdp_basic.h b/host/xtest/sdp_basic.h
new file mode 100644
index 0000000..117eb77
--- /dev/null
+++ b/host/xtest/sdp_basic.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef XTEST_SDP_BASIC_H
+#define XTEST_SDP_BASIC_H
+
+#include "include/uapi/linux/ion.h"
+#include "ta_sdp_basic.h"
+
+#define DEFAULT_ION_HEAP_TYPE ION_HEAP_TYPE_UNMAPPED
+
+enum test_target_ta {
+ TEST_NS_TO_TA,
+ TEST_NS_TO_PTA,
+ TEST_TA_TO_TA,
+ TEST_TA_TO_PTA,
+};
+
+int allocate_ion_buffer(size_t size, int heap_id);
+int sdp_basic_test(enum test_target_ta ta,
+ size_t size, size_t loop, int ion_heap,
+ int rnd_offset);
+
+#endif /* XTEST_SDP_BASIC_H */
diff --git a/host/xtest/xtest_1000.c b/host/xtest/xtest_1000.c
index 785d434..b20fd4e 100644
--- a/host/xtest/xtest_1000.c
+++ b/host/xtest/xtest_1000.c
@@ -30,6 +30,7 @@
#include <ta_rpc_test.h>
#include <ta_sims_test.h>
#include <ta_concurrent.h>
+#include <sdp_basic.h>
static void xtest_tee_test_1001(ADBG_Case_t *Case_p);
static void xtest_tee_test_1004(ADBG_Case_t *Case_p);
@@ -42,6 +43,9 @@
static void xtest_tee_test_1011(ADBG_Case_t *Case_p);
static void xtest_tee_test_1012(ADBG_Case_t *Case_p);
static void xtest_tee_test_1013(ADBG_Case_t *Case_p);
+#ifdef CFG_SECURE_DATA_PATH
+static void xtest_tee_test_1014(ADBG_Case_t *Case_p);
+#endif
ADBG_CASE_DEFINE(regression, 1001, xtest_tee_test_1001, "Core self tests");
ADBG_CASE_DEFINE(regression, 1004, xtest_tee_test_1004, "Test User Crypt TA");
@@ -60,6 +64,10 @@
"Test Single Instance Multi Session features with SIMS TA");
ADBG_CASE_DEFINE(regression, 1013, xtest_tee_test_1013,
"Test concurency with concurrent TA");
+#ifdef CFG_SECURE_DATA_PATH
+ADBG_CASE_DEFINE(regression, 1014, xtest_tee_test_1014,
+ "Test secure data path against SDP TAs and pTAs");
+#endif
struct xtest_crypto_session {
ADBG_Case_t *c;
@@ -1072,3 +1080,41 @@
Do_ADBG_EndSubCase(c, "Using large concurrency TA");
#endif
}
+
+#ifdef CFG_SECURE_DATA_PATH
+static void xtest_tee_test_1014(ADBG_Case_t *c)
+{
+ UNUSED(c);
+
+ int size = 17000;
+ int loop = 10;
+ int ion_heap = DEFAULT_ION_HEAP_TYPE;
+ int rnd_offset = 1;
+ int test;
+ int ret;
+
+ test = TEST_NS_TO_TA;
+ Do_ADBG_BeginSubCase(c, "SDP: NonSecure client invokes a SDP TA");
+ ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset);
+ ADBG_EXPECT(c, 0, ret);
+ Do_ADBG_EndSubCase(c, "SDP: NonSecure client invokes a SDP TA");
+
+ test = TEST_TA_TO_TA;
+ Do_ADBG_BeginSubCase(c, "SDP: SDP TA invokes a SDP TA");
+ ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset);
+ ADBG_EXPECT(c, 0, ret);
+ Do_ADBG_EndSubCase(c, "SDP: SDP TA invokes a SDP TA");
+
+ test = TEST_TA_TO_PTA;
+ Do_ADBG_BeginSubCase(c, "SDP: SDP TA invokes a SDP pTA");
+ ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset);
+ ADBG_EXPECT(c, 0, ret);
+ Do_ADBG_EndSubCase(c, "SDP: SDP TA invokes a SDP pTA");
+
+ test = TEST_NS_TO_PTA;
+ Do_ADBG_BeginSubCase(c, "SDP: NonSecure client invokes SDP pTA (should fail)");
+ ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset);
+ ADBG_EXPECT(c, 1, ret);
+ Do_ADBG_EndSubCase(c, "SDP: NonSecure client invokes SDP pTA (should fail)");
+}
+#endif
diff --git a/host/xtest/xtest_test.c b/host/xtest/xtest_test.c
index 9698de4..95f2ac8 100644
--- a/host/xtest/xtest_test.c
+++ b/host/xtest/xtest_test.c
@@ -29,6 +29,7 @@
#include <__tee_isocket_defines.h>
#include <__tee_tcpsocket_defines.h>
#include <__tee_udpsocket_defines.h>
+#include <ta_sdp_basic.h>
#ifdef WITH_GP_TESTS
#include <tee_api_types.h>
#include <TTA_DS_protocol.h>
@@ -100,6 +101,7 @@
const TEEC_UUID concurrent_large_ta_uuid = TA_CONCURRENT_LARGE_UUID;
const TEEC_UUID storage_benchmark_ta_uuid = TA_STORAGE_BENCHMARK_UUID;
const TEEC_UUID socket_ta_uuid = TA_SOCKET_UUID;
+const TEEC_UUID sdp_basic_ta_uuid = TA_SDP_BASIC_UUID;
#ifdef WITH_GP_TESTS
const TEEC_UUID gp_tta_ds_uuid = TA_TTA_DS_UUID;
#endif
diff --git a/host/xtest/xtest_test.h b/host/xtest/xtest_test.h
index 6bc7159..141376d 100644
--- a/host/xtest/xtest_test.h
+++ b/host/xtest/xtest_test.h
@@ -127,6 +127,7 @@
extern const TEEC_UUID concurrent_large_ta_uuid;
extern const TEEC_UUID storage_benchmark_ta_uuid;
extern const TEEC_UUID socket_ta_uuid;
+extern const TEEC_UUID sdp_basic_ta_uuid;
extern char *_device;
#endif /*XTEST_TEST_H*/