Test: Add Secure Client 2 test partition

Adds the Secure Client 2 test partition, which provides a service to
call test functions by ID within the execution context of this
partition.

This makes it possible to test scenarios involving multiple partitions.

Change-Id: I6183fc1d0f9d6f23c01e638ce9589afdb919eb47
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/interface/include/psa_manifest/pid.h b/interface/include/psa_manifest/pid.h
index 0ff494e..322157b 100644
--- a/interface/include/psa_manifest/pid.h
+++ b/interface/include/psa_manifest/pid.h
@@ -27,8 +27,9 @@
 #define TFM_SP_IPC_CLIENT_TEST                                         (266)
 #define TFM_IRQ_TEST_1                                                 (267)
 #define TFM_SP_SST_TEST                                                (268)
+#define TFM_SP_SECURE_CLIENT_2                                         (269)
 
-#define TFM_MAX_USER_PARTITIONS                                        (13)
+#define TFM_MAX_USER_PARTITIONS                                        (14)
 
 #ifdef __cplusplus
 }
diff --git a/interface/include/psa_manifest/sid.h b/interface/include/psa_manifest/sid.h
index 4a2895d..5f2111a 100644
--- a/interface/include/psa_manifest/sid.h
+++ b/interface/include/psa_manifest/sid.h
@@ -130,6 +130,10 @@
 #define TFM_SST_TEST_PREPARE_SID                                   (0x0000F0C0U)
 #define TFM_SST_TEST_PREPARE_VERSION                               (1U)
 
+/******** TFM_SP_SECURE_CLIENT_2 ********/
+#define TFM_SECURE_CLIENT_2_SID                                    (0x0000F0E0U)
+#define TFM_SECURE_CLIENT_2_VERSION                                (1U)
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/interface/include/tfm_veneers.h b/interface/include/tfm_veneers.h
index 0bcef49..a2cc495 100644
--- a/interface/include/tfm_veneers.h
+++ b/interface/include/tfm_veneers.h
@@ -137,6 +137,11 @@
 psa_status_t tfm_tfm_sst_test_prepare_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+/******** TFM_SP_SECURE_CLIENT_2 ********/
+psa_status_t tfm_tfm_secure_client_2_call_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/ext/common/armclang/tfm_common_s.sct b/platform/ext/common/armclang/tfm_common_s.sct
index 59e1b72..5c53ee1 100644
--- a/platform/ext/common/armclang/tfm_common_s.sct
+++ b/platform/ext/common/armclang/tfm_common_s.sct
@@ -153,6 +153,13 @@
     }
 #endif /* TFM_ENABLE_IRQ_TEST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    TFM_SP_SECURE_CLIENT_2_LINKER +0 ALIGN 32 {
+        *tfm_secure_client_2.* (+RO)
+        *(TFM_SP_SECURE_CLIENT_2_ATTR_FN)
+    }
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
     /*
      * This empty, zero long execution region is here to mark the end address
      * of APP RoT code.
@@ -248,6 +255,19 @@
 #endif
 #endif /* TFM_ENABLE_IRQ_TEST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    TFM_SP_SECURE_CLIENT_2_LINKER_DATA +0 ALIGN 32 {
+        *tfm_secure_client_2.* (+RW +ZI)
+        *(TFM_SP_SECURE_CLIENT_2_ATTR_RW)
+        *(TFM_SP_SECURE_CLIENT_2_ATTR_ZI)
+    }
+
+#if defined (TFM_PSA_API)
+    TFM_SP_SECURE_CLIENT_2_LINKER_STACK +0 ALIGN 128 EMPTY 0x180 {
+    }
+#endif
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
     /*
      * This empty, zero long execution region is here to mark the end address
      * of APP RoT RW and Stack.
diff --git a/platform/ext/common/gcc/tfm_common_s.ld b/platform/ext/common/gcc/tfm_common_s.ld
index 9e6624a..5d74c2d 100644
--- a/platform/ext/common/gcc/tfm_common_s.ld
+++ b/platform/ext/common/gcc/tfm_common_s.ld
@@ -121,6 +121,11 @@
         LONG (ADDR(.TFM_SP_SST_TEST_LINKER_DATA))
         LONG (SIZEOF(.TFM_SP_SST_TEST_LINKER_DATA))
 #endif /* TFM_PARTITION_TEST_SST */
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+        LONG (LOADADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_DATA))
+        LONG (ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_DATA))
+        LONG (SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER_DATA))
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
 #if defined (S_RAM_CODE_START)
         LONG (LOADADDR(.TFM_RAM_CODE))
         LONG (ADDR(.TFM_RAM_CODE))
@@ -234,6 +239,14 @@
         LONG (SIZEOF(.TFM_SP_SST_TEST_LINKER_STACK))
 #endif
 #endif /* TFM_PARTITION_TEST_SST */
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+        LONG (ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_BSS))
+        LONG (SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER_BSS))
+#if defined(TFM_PSA_API)
+        LONG (ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_STACK))
+        LONG (SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER_STACK))
+#endif
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
         __zero_table_end__ = .;
     } > FLASH
 
@@ -458,6 +471,20 @@
     Image$$TFM_IRQ_TEST_1_LINKER$$Limit = ADDR(.TFM_IRQ_TEST_1_LINKER) + SIZEOF(.TFM_IRQ_TEST_1_LINKER);
 #endif /* TFM_ENABLE_IRQ_TEST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    .TFM_SP_SECURE_CLIENT_2_LINKER : ALIGN(32)
+    {
+        *tfm_secure_client_2.*(.text*)
+        *tfm_secure_client_2.*(.rodata*)
+        *(TFM_SP_SECURE_CLIENT_2_ATTR_FN)
+        . = ALIGN(32);
+    } > FLASH
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER$$RO$$Base = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER);
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER$$RO$$Limit = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER) + SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER);
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER$$Base = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER);
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER$$Limit = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER) + SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER);
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
     /**** APPLICATION RoT RO part (CODE + RODATA) end here */
     Image$$TFM_APP_CODE_END$$Base = .;
 
@@ -696,6 +723,39 @@
 
 #endif /* TFM_ENABLE_IRQ_TEST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    .TFM_SP_SECURE_CLIENT_2_LINKER_DATA : ALIGN(32)
+    {
+        *tfm_secure_client_2.*(.data*)
+        *(TFM_SP_SECURE_CLIENT_2_ATTR_RW)
+        . = ALIGN(32);
+    } > RAM AT> FLASH
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER_DATA$$RW$$Base = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_DATA);
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER_DATA$$RW$$Limit = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_DATA) + SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER_DATA);
+
+    .TFM_SP_SECURE_CLIENT_2_LINKER_BSS : ALIGN(32)
+    {
+        start_of_TFM_SP_SECURE_CLIENT_2_LINKER = .;
+        *tfm_secure_client_2.*(.bss*)
+        *tfm_secure_client_2.*(COMMON)
+        *(TFM_SP_SECURE_CLIENT_2_ATTR_ZI)
+        . += (. - start_of_TFM_SP_SECURE_CLIENT_2_LINKER) ? 0 : 4;
+        . = ALIGN(32);
+    } > RAM AT> RAM
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER_DATA$$ZI$$Base = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_BSS);
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER_DATA$$ZI$$Limit = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_BSS) + SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER_BSS);
+
+#if defined (TFM_PSA_API)
+    .TFM_SP_SECURE_CLIENT_2_LINKER_STACK : ALIGN(128)
+    {
+        . += 0x180;
+    } > RAM
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER_STACK$$ZI$$Base = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_STACK);
+    Image$$TFM_SP_SECURE_CLIENT_2_LINKER_STACK$$ZI$$Limit = ADDR(.TFM_SP_SECURE_CLIENT_2_LINKER_STACK) + SIZEOF(.TFM_SP_SECURE_CLIENT_2_LINKER_STACK);
+#endif
+
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
     /**** APPLICATION RoT DATA end here */
     Image$$TFM_APP_RW_STACK_END$$Base = .;
 
diff --git a/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc b/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc
index e600056..bb7c694 100644
--- a/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc
+++ b/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc
@@ -20,6 +20,7 @@
 #include "test/test_services/tfm_ipc_client/psa_manifest/tfm_ipc_client_partition.h"
 #include "test/test_services/tfm_irq_test_service_1/psa_manifest/tfm_irq_test_service_1.h"
 #include "test/test_services/tfm_sst_test_service/psa_manifest/tfm_sst_test_service.h"
+#include "test/test_services/tfm_secure_client_2/psa_manifest/tfm_secure_client_2.h"
 #include "cmsis_compiler.h"
 
 /* Definitions of the signals of the IRQs (if any) */
diff --git a/secure_fw/core/tfm_secure_irq_handlers.inc b/secure_fw/core/tfm_secure_irq_handlers.inc
index 9b78b95..c6a29f7 100644
--- a/secure_fw/core/tfm_secure_irq_handlers.inc
+++ b/secure_fw/core/tfm_secure_irq_handlers.inc
@@ -20,6 +20,7 @@
 #include "test/test_services/tfm_ipc_client/psa_manifest/tfm_ipc_client_partition.h"
 #include "test/test_services/tfm_irq_test_service_1/psa_manifest/tfm_irq_test_service_1.h"
 #include "test/test_services/tfm_sst_test_service/psa_manifest/tfm_sst_test_service.h"
+#include "test/test_services/tfm_secure_client_2/psa_manifest/tfm_secure_client_2.h"
 #include "psa_manifest/pid.h"
 
 /* Definitions of the signals of the IRQs */
diff --git a/secure_fw/ns_callable/tfm_veneers.c b/secure_fw/ns_callable/tfm_veneers.c
index ade23cf..f9fa21e 100644
--- a/secure_fw/ns_callable/tfm_veneers.c
+++ b/secure_fw/ns_callable/tfm_veneers.c
@@ -131,6 +131,11 @@
 psa_status_t tfm_sst_test_prepare(psa_invec *, size_t, psa_outvec *, size_t);
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+/******** TFM_SP_SECURE_CLIENT_2 ********/
+psa_status_t tfm_secure_client_2_call(psa_invec *, size_t, psa_outvec *, size_t);
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 
 #define TFM_VENEER_FUNCTION(partition_name, sfn_name) \
     __tfm_secure_gateway_attributes__ \
@@ -265,3 +270,8 @@
 TFM_VENEER_FUNCTION(TFM_SP_SST_TEST, tfm_sst_test_prepare)
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+/******** TFM_SP_SECURE_CLIENT_2 ********/
+TFM_VENEER_FUNCTION(TFM_SP_SECURE_CLIENT_2, tfm_secure_client_2_call)
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
diff --git a/secure_fw/services/tfm_service_list.inc b/secure_fw/services/tfm_service_list.inc
index 11fbee4..b9f0559 100644
--- a/secure_fw/services/tfm_service_list.inc
+++ b/secure_fw/services/tfm_service_list.inc
@@ -23,6 +23,7 @@
 #include "test/test_services/tfm_ipc_client/psa_manifest/tfm_ipc_client_partition.h"
 #include "test/test_services/tfm_irq_test_service_1/psa_manifest/tfm_irq_test_service_1.h"
 #include "test/test_services/tfm_sst_test_service/psa_manifest/tfm_sst_test_service.h"
+#include "test/test_services/tfm_secure_client_2/psa_manifest/tfm_secure_client_2.h"
 
 const struct tfm_spm_service_db_t service_db[] =
 {
@@ -480,6 +481,19 @@
     },
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    /******** TFM_SP_SECURE_CLIENT_2 ********/
+    {
+        .name = "TFM_SECURE_CLIENT_2",
+        .partition_id = TFM_SP_SECURE_CLIENT_2,
+        .signal = TFM_SECURE_CLIENT_2_SIGNAL,
+        .sid = 0x0000F0E0,
+        .non_secure_client = false,
+        .version = 1,
+        .version_policy = TFM_VERSION_POLICY_STRICT
+    },
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 };
 
 /**************************************************************************/
@@ -849,6 +863,17 @@
     },
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    /******** TFM_SP_SECURE_CLIENT_2 ********/
+    {
+        .service_db = NULL,
+        .partition = NULL,
+        .handle_list = {0},
+        .msg_queue = {0},
+        .list = {0},
+    },
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 };
 
 #endif /* __TFM_SERVICE_LIST_INC__ */
diff --git a/secure_fw/spm/tfm_spm_db.inc b/secure_fw/spm/tfm_spm_db.inc
index 062eda4..43bd2bc 100644
--- a/secure_fw/spm/tfm_spm_db.inc
+++ b/secure_fw/spm/tfm_spm_db.inc
@@ -60,6 +60,10 @@
 #define TFM_PARTITION_TFM_SP_SST_TEST_IRQ_COUNT 0
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+#define TFM_PARTITION_TFM_SP_SECURE_CLIENT_2_IRQ_COUNT 0
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 /**************************************************************************/
 /** Declarations of partition init functions */
 /**************************************************************************/
@@ -111,6 +115,10 @@
 extern void tfm_sst_test_init(void);
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+extern void tfm_secure_client_2_init(void);
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 /**************************************************************************/
 /** Memory region declarations */
 /**************************************************************************/
@@ -279,6 +287,19 @@
 REGION_DECLARE(Image$$, TFM_SP_SST_TEST_LINKER, _STACK$$ZI$$Limit);
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, $$Base);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, $$Limit);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, $$RO$$Base);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, $$RO$$Limit);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$RW$$Base);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$RW$$Limit);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$ZI$$Base);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$ZI$$Limit);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, _STACK$$ZI$$Base);
+REGION_DECLARE(Image$$, TFM_SP_SECURE_CLIENT_2_LINKER, _STACK$$ZI$$Limit);
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 #endif /* defined(TFM_PSA_API) */
 
 #ifndef TFM_PSA_API
@@ -409,6 +430,15 @@
         )) / sizeof(uint32_t)];
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+static uint32_t ctx_stack_TFM_SP_SECURE_CLIENT_2[
+        (sizeof(struct interrupted_ctx_stack_frame_t) +
+            (TFM_PARTITION_TFM_SP_SECURE_CLIENT_2_IRQ_COUNT) * (
+                sizeof(struct interrupted_ctx_stack_frame_t) +
+                sizeof(struct handler_ctx_stack_frame_t)
+        )) / sizeof(uint32_t)];
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 
 uint32_t *ctx_stack_list[] =
 {
@@ -445,6 +475,9 @@
 #ifdef TFM_PARTITION_TEST_SST
     ctx_stack_TFM_SP_SST_TEST,
 #endif /* TFM_PARTITION_TEST_SST */
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    ctx_stack_TFM_SP_SECURE_CLIENT_2,
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
 };
 #endif /* !defined(TFM_PSA_API) */
 
@@ -473,6 +506,7 @@
 #ifdef TFM_PARTITION_TEST_SECURE_SERVICES
 static int32_t dependencies_TFM_SP_SECURE_TEST_PARTITION[] =
 {
+    TFM_SECURE_CLIENT_2_SID,
     TFM_CRYPTO_SID,
     TFM_SST_SET_SID,
     TFM_SST_GET_SID,
@@ -670,7 +704,7 @@
                               ,
         .partition_priority   = TFM_PRIORITY(NORMAL),
         .partition_init       = tfm_secure_client_service_init,
-        .dependencies_num     = 16,
+        .dependencies_num     = 17,
         .p_dependencies       = dependencies_TFM_SP_SECURE_TEST_PARTITION,
     },
 #endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
@@ -739,6 +773,22 @@
     },
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    {
+#ifdef TFM_PSA_API
+        .psa_framework_version = 0x0100,
+#endif /* defined(TFM_PSA_API) */
+        .partition_id         = TFM_SP_SECURE_CLIENT_2,
+        .partition_flags      = SPM_PART_FLAG_IPC
+                              | SPM_PART_FLAG_APP_ROT
+                              ,
+        .partition_priority   = TFM_PRIORITY(NORMAL),
+        .partition_init       = tfm_secure_client_2_init,
+        .dependencies_num     = 0,
+        .p_dependencies       = NULL,
+    },
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 };
 
 /**************************************************************************/
@@ -834,6 +884,10 @@
     NULL,
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    NULL,
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 };
 
 /**************************************************************************/
@@ -1034,6 +1088,21 @@
     },
 #endif /* TFM_PARTITION_TEST_SST */
 
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    {
+        .code_start           = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, $$Base),
+        .code_limit           = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, $$Limit),
+        .ro_start             = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, $$RO$$Base),
+        .ro_limit             = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, $$RO$$Limit),
+        .rw_start             = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$RW$$Base),
+        .rw_limit             = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$RW$$Limit),
+        .zi_start             = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$ZI$$Base),
+        .zi_limit             = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, _DATA$$ZI$$Limit),
+        .stack_bottom         = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, _STACK$$ZI$$Base),
+        .stack_top            = PART_REGION_ADDR(TFM_SP_SECURE_CLIENT_2_LINKER, _STACK$$ZI$$Limit),
+    },
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 };
 #endif /* defined(TFM_PSA_API) */
 
@@ -1195,6 +1264,18 @@
     },
 #endif /* TFM_PARTITION_TEST_SST */
 
+    /* -----------------------------------------------------------------------*/
+    /* - Partition DB record for TFM_SP_SECURE_CLIENT_2 */
+    /* -----------------------------------------------------------------------*/
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+    {
+    /* Runtime data */
+        .runtime_data             = {},
+        .static_data              = NULL,
+        .platform_data_list       = NULL,
+    },
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+
 };
 
 struct spm_partition_db_t g_spm_partition_db = {
diff --git a/test/test_services/CMakeLists.inc b/test/test_services/CMakeLists.inc
index b020a6b..8e9a370 100644
--- a/test/test_services/CMakeLists.inc
+++ b/test/test_services/CMakeLists.inc
@@ -48,7 +48,9 @@
 if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES)
 	message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ")
 elseif (TFM_PARTITION_TEST_SECURE_SERVICES)
-	list(APPEND ALL_SRC_C_S "${CORE_TEST_DIR}/tfm_secure_client_service/tfm_secure_client_service.c")
+	list(APPEND ALL_SRC_C_S "${CORE_TEST_DIR}/tfm_secure_client_service/tfm_secure_client_service.c"
+		"${CORE_TEST_DIR}/tfm_secure_client_2/tfm_secure_client_2.c"
+		"${CORE_TEST_DIR}/tfm_secure_client_2/tfm_secure_client_2_api.c")
 
 	list(APPEND ALL_SRC_C_NS "${CORE_TEST_DIR}/tfm_secure_client_service/tfm_secure_client_service_api.c")
 endif()
diff --git a/test/test_services/tfm_secure_client_2/psa_manifest/tfm_secure_client_2.h b/test/test_services/tfm_secure_client_2/psa_manifest/tfm_secure_client_2.h
new file mode 100644
index 0000000..a8b1f2f
--- /dev/null
+++ b/test/test_services/tfm_secure_client_2/psa_manifest/tfm_secure_client_2.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_SECURE_CLIENT_2_H__
+#define __PSA_MANIFEST_TFM_SECURE_CLIENT_2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TFM_SECURE_CLIENT_2_SIGNAL                              (1U << (0 + 4))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_SECURE_CLIENT_2_H__ */
diff --git a/test/test_services/tfm_secure_client_2/tfm_secure_client_2.c b/test/test_services/tfm_secure_client_2/tfm_secure_client_2.c
new file mode 100644
index 0000000..48323d3
--- /dev/null
+++ b/test/test_services/tfm_secure_client_2/tfm_secure_client_2.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifdef TFM_PSA_API
+#include "psa/service.h"
+#include "psa_manifest/tfm_secure_client_2.h"
+#else
+#include "psa/client.h"
+#endif
+
+static psa_status_t secure_client_2_dispatch(int32_t id, const void *arg,
+                                             size_t arg_len)
+{
+    switch (id) {
+    default:
+        return PSA_ERROR_PROGRAMMER_ERROR;
+    }
+}
+
+#ifdef TFM_PSA_API
+#define SECURE_CLIENT_2_MAX_ARG_LEN 8U
+
+void tfm_secure_client_2_init(void)
+{
+    psa_msg_t msg;
+    size_t len;
+    char arg[SECURE_CLIENT_2_MAX_ARG_LEN] __attribute__((__aligned__(8)));
+
+    while (1) {
+        (void)psa_wait(TFM_SECURE_CLIENT_2_SIGNAL, PSA_BLOCK);
+        if (psa_get(TFM_SECURE_CLIENT_2_SIGNAL, &msg) != PSA_SUCCESS) {
+            continue;
+        }
+        switch (msg.type) {
+        case PSA_IPC_CONNECT:
+        case PSA_IPC_DISCONNECT:
+            psa_reply(msg.handle, PSA_SUCCESS);
+            break;
+        default:
+            len = psa_read(msg.handle, 0, arg, SECURE_CLIENT_2_MAX_ARG_LEN);
+            psa_reply(msg.handle, secure_client_2_dispatch(msg.type, arg, len));
+            break;
+        }
+    }
+}
+#else /* TFM_PSA_API */
+psa_status_t tfm_secure_client_2_init(void)
+{
+    return PSA_SUCCESS;
+}
+
+psa_status_t tfm_secure_client_2_call(psa_invec *in_vec, size_t in_len,
+                                      psa_outvec *out_vec, size_t out_len)
+{
+    int32_t id;
+
+    (void)out_vec;
+
+    if (in_len != 2 || out_len != 0 || in_vec[0].len != sizeof(id)) {
+        return PSA_ERROR_PROGRAMMER_ERROR;
+    }
+
+    id = *((int32_t *)in_vec[0].base);
+
+    return secure_client_2_dispatch(id, in_vec[1].base, in_vec[1].len);
+}
+#endif /* TFM_PSA_API */
diff --git a/test/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml b/test/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml
new file mode 100644
index 0000000..98020b7
--- /dev/null
+++ b/test/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml
@@ -0,0 +1,40 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+{
+  "psa_framework_version": 1.0,
+  "name": "TFM_SP_SECURE_CLIENT_2",
+  "type": "APPLICATION-ROT",
+  "priority": "NORMAL",
+  "entry_point": "tfm_secure_client_2_init",
+  "stack_size": "0x180",
+  "secure_functions": [
+    {
+      "name": "TFM_SECURE_CLIENT_2_CALL",
+      "signal": "TFM_SECURE_CLIENT_2_CALL",
+      "non_secure_clients": false,
+      "version": 1,
+      "version_policy": "STRICT"
+    },
+  ],
+  "services": [
+    {
+      "name": "TFM_SECURE_CLIENT_2",
+      "sid": "0x0000F0E0",
+      "non_secure_clients": false,
+      "version": 1,
+      "version_policy": "STRICT"
+    }
+  ],
+  "dependencies": [
+  ],
+  "linker_pattern": {
+    "object_list": [
+      "*tfm_secure_client_2.*"
+    ]
+  }
+}
diff --git a/test/test_services/tfm_secure_client_2/tfm_secure_client_2_api.c b/test/test_services/tfm_secure_client_2/tfm_secure_client_2_api.c
new file mode 100644
index 0000000..b5beb9a
--- /dev/null
+++ b/test/test_services/tfm_secure_client_2/tfm_secure_client_2_api.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "tfm_secure_client_2_api.h"
+#include "psa/client.h"
+
+#ifdef TFM_PSA_API
+#include "psa_manifest/sid.h"
+#else
+#include "tfm_veneers.h"
+#endif
+
+__attribute__((section("SFN")))
+psa_status_t tfm_secure_client_2_call_test(int32_t id, const void *arg,
+                                           size_t arg_len)
+{
+#ifdef TFM_PSA_API
+    psa_handle_t handle;
+    psa_status_t status;
+    psa_invec in_vec[] = {
+        { .base = arg, .len = arg_len },
+    };
+
+    handle = psa_connect(TFM_SECURE_CLIENT_2_SID, TFM_SECURE_CLIENT_2_VERSION);
+    if (!PSA_HANDLE_IS_VALID(handle)) {
+        return PSA_ERROR_GENERIC_ERROR;
+    }
+
+    /* Pass the ID through the type parameter of psa_call() */
+    status = psa_call(handle, id, in_vec, 1, NULL, 0);
+    psa_close(handle);
+
+    return status;
+#else
+    /* Pack the ID in the invec */
+    psa_invec in_vec[] = {
+        { .base = &id, .len = sizeof(id) },
+        { .base = arg, .len = arg_len },
+    };
+
+    return tfm_tfm_secure_client_2_call_veneer(in_vec, 2, NULL, 0);
+#endif
+}
diff --git a/test/test_services/tfm_secure_client_2/tfm_secure_client_2_api.h b/test/test_services/tfm_secure_client_2/tfm_secure_client_2_api.h
new file mode 100644
index 0000000..b155026
--- /dev/null
+++ b/test/test_services/tfm_secure_client_2/tfm_secure_client_2_api.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_SECURE_CLIENT_2_API_H__
+#define __TFM_SECURE_CLIENT_2_API_H__
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "psa/error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Calls the test function with the supplied ID within the execution
+ *        context of the Secure Client 2 partition and returns the resulting
+ *        status.
+ *
+ * \param[in] id       The ID of the test function
+ * \param[in] arg      Pointer to argument to pass to test function
+ * \param[in] arg_len  Length of argument in bytes
+ *
+ * \return Returns error code as specified in \ref psa_status_t
+ */
+psa_status_t tfm_secure_client_2_call_test(int32_t id, const void *arg,
+                                           size_t arg_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_SECURE_CLIENT_2_API_H__ */
diff --git a/test/test_services/tfm_secure_client_service/tfm_test_client_service.yaml b/test/test_services/tfm_secure_client_service/tfm_test_client_service.yaml
index b47e31f..24bbdc2 100644
--- a/test/test_services/tfm_secure_client_service/tfm_test_client_service.yaml
+++ b/test/test_services/tfm_secure_client_service/tfm_test_client_service.yaml
@@ -37,6 +37,7 @@
     }
   ],
   "dependencies": [
+    "TFM_SECURE_CLIENT_2",
     "TFM_CRYPTO",
     "TFM_SST_SET",
     "TFM_SST_GET",
diff --git a/tools/tfm_manifest_list.yaml b/tools/tfm_manifest_list.yaml
index 289394e..c1f54cd 100644
--- a/tools/tfm_manifest_list.yaml
+++ b/tools/tfm_manifest_list.yaml
@@ -149,6 +149,17 @@
       "version_major": 0,
       "version_minor": 1,
       "pid": 268
+    },
+    {
+      "name": "TF-M Secure Client 2 Service",
+      "short_name": "TFM_SP_SECURE_CLIENT_2",
+      "manifest": "test/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml",
+      "tfm_extensions": true,
+      "tfm_partition_ipc": true,
+      "conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
+      "version_major": 0,
+      "version_minor": 1,
+      "pid": 269
     }
   ]
 }