refactor(test): merge S-EL0 test with ffa_secure_partitions

Merge S-EL0 tests with ffa_secure_partitions test infrastructure. Remove
old S-EL0 test infrastructure, since it is mostly a repeat of what is in
the ffa_secure_partitions test infrastructure.

Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
Change-Id: I17179a1cbfa07c900bd07fec22c13264550f4116
diff --git a/test/hftest/BUILD.gn b/test/hftest/BUILD.gn
index f230951..49597e0 100644
--- a/test/hftest/BUILD.gn
+++ b/test/hftest/BUILD.gn
@@ -36,7 +36,7 @@
   ]
 }
 
-# Testing framework for a secondary EL0 partition.
+# Testing framework for a secondary EL0 partition in the normal world.
 # It's currently just a secondary partition and can't affect the tests directly.
 source_set("hftest_secondary_el0_partition") {
   testonly = true
@@ -45,7 +45,25 @@
 
   sources = [
     "nwd_el0_service.c",
-    "service.c",
+    "service_common.c",
+  ]
+
+  deps = [
+    ":el0_dlog",
+    ":el0_fdt_handler",
+    "//src:panic",
+    "//src/arch/${plat_arch}/hftest:el0_entry",
+  ]
+}
+
+# Testing framework for a S-EL0 partition.
+source_set("hftest_sel0_partition_base") {
+  testonly = true
+
+  public_configs = [ "//test/hftest:hftest_config" ]
+
+  sources = [
+    "sel0_secure_service.c",
   ]
 
   deps = [
@@ -82,6 +100,7 @@
   deps = [
     ":mm",
     ":power_mgmt",
+    ":service_common",
     "//src:dlog",
     "//src:fdt_handler",
     "//src:memiter",
@@ -104,7 +123,7 @@
   ]
 
   sources = [
-    "secure_service.c",
+    "sel1_secure_service.c",
   ]
 
   deps = [
diff --git a/test/hftest/nwd_el0_service.c b/test/hftest/nwd_el0_service.c
index 0c5115a..a000ec8 100644
--- a/test/hftest/nwd_el0_service.c
+++ b/test/hftest/nwd_el0_service.c
@@ -6,9 +6,14 @@
  * https://opensource.org/licenses/BSD-3-Clause.
  */
 
+#include <stdalign.h>
+#include <stdint.h>
+
 #include "test/hftest.h"
 
-noreturn void el0_main(const void *fdt_ptr)
+alignas(4096) uint8_t kstack[4096];
+
+noreturn void kmain(const void *fdt_ptr)
 {
 	hftest_service_main(fdt_ptr);
 }
diff --git a/test/vmapi/el0_partitions/secure_partitions/el0_secure_service.c b/test/hftest/sel0_secure_service.c
similarity index 88%
rename from test/vmapi/el0_partitions/secure_partitions/el0_secure_service.c
rename to test/hftest/sel0_secure_service.c
index c1cf523..2e2f568 100644
--- a/test/vmapi/el0_partitions/secure_partitions/el0_secure_service.c
+++ b/test/hftest/sel0_secure_service.c
@@ -28,7 +28,7 @@
 	return &global_context;
 }
 
-extern void secure_partition_msg_loop(void);
+void test_main_sp(bool);
 
 noreturn void abort(void)
 {
@@ -41,9 +41,9 @@
 	}
 }
 
-noreturn void el0_main(void)
+noreturn void kmain(void)
 {
-	secure_partition_msg_loop();
+	test_main_sp(true);
 
 	/* Do not expect to get to this point, so abort. */
 	abort();
diff --git a/test/hftest/secure_service.c b/test/hftest/sel1_secure_service.c
similarity index 100%
rename from test/hftest/secure_service.c
rename to test/hftest/sel1_secure_service.c
diff --git a/test/hftest/service.c b/test/hftest/service.c
index 6d0cb3c..c52e4b6 100644
--- a/test/hftest/service.c
+++ b/test/hftest/service.c
@@ -11,128 +11,12 @@
 
 #include "hf/arch/vm/interrupts.h"
 
-#include "hf/fdt_handler.h"
-#include "hf/ffa.h"
-#include "hf/memiter.h"
-#include "hf/mm.h"
-#include "hf/std.h"
-
-#include "vmapi/hf/call.h"
-
 #include "test/hftest.h"
+#include "test/hftest_impl.h"
 
 alignas(4096) uint8_t kstack[4096];
 
-HFTEST_ENABLE();
-
-extern struct hftest_test hftest_begin[];
-extern struct hftest_test hftest_end[];
-
-static alignas(HF_MAILBOX_SIZE) uint8_t send[HF_MAILBOX_SIZE];
-static alignas(HF_MAILBOX_SIZE) uint8_t recv[HF_MAILBOX_SIZE];
-
-static hf_ipaddr_t send_addr = (hf_ipaddr_t)send;
-static hf_ipaddr_t recv_addr = (hf_ipaddr_t)recv;
-
-static struct hftest_context global_context;
-
-struct hftest_context *hftest_get_context(void)
-{
-	return &global_context;
-}
-
-/** Find the service with the name passed in the arguments. */
-static hftest_test_fn find_service(struct memiter *args)
-{
-	struct memiter service_name;
-	struct hftest_test *test;
-
-	if (!memiter_parse_str(args, &service_name)) {
-		return NULL;
-	}
-
-	for (test = hftest_begin; test < hftest_end; ++test) {
-		if (test->kind == HFTEST_KIND_SERVICE &&
-		    memiter_iseq(&service_name, test->name)) {
-			return test->fn;
-		}
-	}
-
-	return NULL;
-}
-
-noreturn void abort(void)
-{
-	HFTEST_LOG("Service contained failures.");
-	/* Cause a fault, as a secondary can't power down the machine. */
-	*((volatile uint8_t *)1) = 1;
-
-	/* This should never be reached, but to make the compiler happy... */
-	for (;;) {
-	}
-}
-
-noreturn void hftest_service_main(const void *fdt_ptr)
-{
-	struct memiter args;
-	hftest_test_fn service;
-	struct hftest_context *ctx;
-	struct ffa_value ret;
-	struct fdt fdt;
-
-	/* Prepare the context. */
-
-	/* Set up the mailbox. */
-	ffa_rxtx_map(send_addr, recv_addr);
-
-	/* Receive the name of the service to run. */
-	ret = ffa_msg_wait();
-	ASSERT_EQ(ret.func, FFA_MSG_SEND_32);
-	memiter_init(&args, recv, ffa_msg_send_size(ret));
-	service = find_service(&args);
-	EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
-
-	/* Check the service was found. */
-	if (service == NULL) {
-		HFTEST_LOG_FAILURE();
-		HFTEST_LOG(HFTEST_LOG_INDENT
-			   "Unable to find requested service");
-		abort();
-	}
-
-	if (!fdt_struct_from_ptr(fdt_ptr, &fdt)) {
-		HFTEST_LOG(HFTEST_LOG_INDENT "Unable to access the FDT");
-		abort();
-	}
-
-	/* Clean the context. */
-	ctx = hftest_get_context();
-	memset_s(ctx, sizeof(*ctx), 0, sizeof(*ctx));
-	ctx->abort = abort;
-	ctx->send = send;
-	ctx->recv = recv;
-	if (!fdt_get_memory_size(&fdt, &ctx->memory_size)) {
-		HFTEST_LOG_FAILURE();
-		HFTEST_LOG(HFTEST_LOG_INDENT
-			   "No entry in the FDT on memory size details");
-		abort();
-	}
-
-	/* Pause so the next time cycles are given the service will be run. */
-	ffa_yield();
-
-	/* Let the service run. */
-	service();
-
-	/* Cleanly handle it if the service returns. */
-	if (ctx->failures) {
-		abort();
-	}
-
-	for (;;) {
-		/* Hang if the service returns. */
-	}
-}
+extern void abort(void);
 
 noreturn void kmain(const void *fdt_ptr)
 {
diff --git a/test/hftest/service_common.c b/test/hftest/service_common.c
index bd7840d..25df466 100644
--- a/test/hftest/service_common.c
+++ b/test/hftest/service_common.c
@@ -9,14 +9,28 @@
 #include <stdalign.h>
 #include <stdint.h>
 
+#include "hf/fdt_handler.h"
+#include "hf/ffa.h"
+#include "hf/memiter.h"
 #include "hf/mm.h"
 #include "hf/std.h"
 
+#include "vmapi/hf/call.h"
+
 #include "test/hftest.h"
 #include "test/hftest_impl.h"
 
 HFTEST_ENABLE();
 
+extern struct hftest_test hftest_begin[];
+extern struct hftest_test hftest_end[];
+
+static alignas(HF_MAILBOX_SIZE) uint8_t send[HF_MAILBOX_SIZE];
+static alignas(HF_MAILBOX_SIZE) uint8_t recv[HF_MAILBOX_SIZE];
+
+static hf_ipaddr_t send_addr = (hf_ipaddr_t)send;
+static hf_ipaddr_t recv_addr = (hf_ipaddr_t)recv;
+
 static struct hftest_context global_context;
 
 struct hftest_context *hftest_get_context(void)
@@ -34,3 +48,85 @@
 	for (;;) {
 	}
 }
+
+/** Find the service with the name passed in the arguments. */
+static hftest_test_fn find_service(struct memiter *args)
+{
+	struct memiter service_name;
+	struct hftest_test *test;
+
+	if (!memiter_parse_str(args, &service_name)) {
+		return NULL;
+	}
+
+	for (test = hftest_begin; test < hftest_end; ++test) {
+		if (test->kind == HFTEST_KIND_SERVICE &&
+		    memiter_iseq(&service_name, test->name)) {
+			return test->fn;
+		}
+	}
+
+	return NULL;
+}
+
+noreturn void hftest_service_main(const void *fdt_ptr)
+{
+	struct memiter args;
+	hftest_test_fn service;
+	struct hftest_context *ctx;
+	struct ffa_value ret;
+	struct fdt fdt;
+
+	/* Prepare the context. */
+
+	/* Set up the mailbox. */
+	ffa_rxtx_map(send_addr, recv_addr);
+
+	/* Receive the name of the service to run. */
+	ret = ffa_msg_wait();
+	ASSERT_EQ(ret.func, FFA_MSG_SEND_32);
+	memiter_init(&args, recv, ffa_msg_send_size(ret));
+	service = find_service(&args);
+	EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
+
+	/* Check the service was found. */
+	if (service == NULL) {
+		HFTEST_LOG_FAILURE();
+		HFTEST_LOG(HFTEST_LOG_INDENT
+			   "Unable to find requested service");
+		abort();
+	}
+
+	if (!fdt_struct_from_ptr(fdt_ptr, &fdt)) {
+		HFTEST_LOG(HFTEST_LOG_INDENT "Unable to access the FDT");
+		abort();
+	}
+
+	/* Clean the context. */
+	ctx = hftest_get_context();
+	memset_s(ctx, sizeof(*ctx), 0, sizeof(*ctx));
+	ctx->abort = abort;
+	ctx->send = send;
+	ctx->recv = recv;
+	if (!fdt_get_memory_size(&fdt, &ctx->memory_size)) {
+		HFTEST_LOG_FAILURE();
+		HFTEST_LOG(HFTEST_LOG_INDENT
+			   "No entry in the FDT on memory size details");
+		abort();
+	}
+
+	/* Pause so the next time cycles are given the service will be run. */
+	ffa_yield();
+
+	/* Let the service run. */
+	service();
+
+	/* Cleanly handle it if the service returns. */
+	if (ctx->failures) {
+		abort();
+	}
+
+	for (;;) {
+		/* Hang if the service returns. */
+	}
+}
diff --git a/test/vmapi/BUILD.gn b/test/vmapi/BUILD.gn
index 0c1ee5a..27e8748 100644
--- a/test/vmapi/BUILD.gn
+++ b/test/vmapi/BUILD.gn
@@ -14,7 +14,6 @@
     "arch/${plat_arch}:arch",
     "common:common",
     "el0_partitions:el0_partitions_test",
-    "el0_partitions/secure_partitions:el0_sp_test",
     "ffa_secure_partition_only:ffa_secure_partition_only_test",
     "ffa_secure_partitions:ffa_both_world_partitions_test",
     "primary_only:primary_only_test",
diff --git a/test/vmapi/el0_partitions/secure_partitions/BUILD.gn b/test/vmapi/el0_partitions/secure_partitions/BUILD.gn
deleted file mode 100644
index 6bb21d3..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/BUILD.gn
+++ /dev/null
@@ -1,171 +0,0 @@
-# Copyright 2021 The Hafnium Authors.
-#
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://opensource.org/licenses/BSD-3-Clause.
-
-import("//build/image/image.gni")
-import("//test/hftest/args.gni")
-
-# TODO: Replace with the one from HFTEST common once all patches merge upstream
-source_set("sel1_partition_base_src") {
-  testonly = true
-
-  public_configs = [
-    "//src/arch/aarch64:arch_config",
-    "//test/hftest:hftest_config",
-  ]
-
-  sources = [
-    "secure_service.c",
-  ]
-
-  deps = [
-    "//src:dlog",
-    "//src:panic",
-    "//src:std",
-    "//src/arch/${plat_arch}:entry",
-    "//src/arch/${plat_arch}/hftest:entry",
-    "//src/arch/${plat_arch}/hftest:power_mgmt",
-    "//test/hftest:mm",
-    "//vmlib/${plat_arch}:call",
-  ]
-}
-
-# Testing framework for a secondary S-EL0 partition.
-source_set("sel0_partition_base_src") {
-  testonly = true
-
-  public_configs = [
-    "//test/hftest:hftest_config",
-    "..:config",
-  ]
-
-  sources = [
-    "el0_secure_service.c",
-  ]
-
-  deps = [
-    "//src:panic",
-    "//src/arch/${plat_arch}/hftest:el0_entry",
-    "//test/hftest:el0_dlog",
-    "//test/hftest:el0_fdt_handler",
-  ]
-}
-
-# SP that will boot first, that is required to be MP partition by hafnium today.
-# This will be a S-EL1 partition and is only present to satisfy the above
-# requirement, to play nice with PSCI.
-vm_kernel("primary_sel1_sp") {
-  testonly = true
-
-  sources = [
-    "secure_partition_service.c",
-  ]
-
-  deps = [
-    ":sel1_partition_base_src",
-    "//test/vmapi/common:common",
-  ]
-}
-
-manifest("partition_manifest_primary_sel1_sp") {
-  source = "partition_manifest_primary_sel1_sp.dts"
-  output = "partition_manifest_primary_sel1_sp.dtb"
-}
-
-partition_package("primary_sel1_sp_test_package") {
-  testonly = true
-  files = [ [
-        "partition_manifest_primary_sel1_sp.dtb",
-        "primary_sel1_sp.bin",
-        ":partition_manifest_primary_sel1_sp",
-        ":primary_sel1_sp",
-      ] ]
-  output = "primary_sel1_sp_test_package.img"
-}
-
-vm_kernel("sel0_sp1") {
-  testonly = true
-
-  sources = [
-    "secure_partition_service.c",
-  ]
-  deps = [
-    ":sel0_partition_base_src",
-  ]
-}
-
-manifest("partition_manifest_sel0_sp1") {
-  source = "partition_manifest_sel0_sp1.dts"
-  output = "partition_manifest_sel0_sp1.dtb"
-}
-
-partition_package("sel0_sp1_package") {
-  testonly = true
-  files = [ [
-        "partition_manifest_sel0_sp1.dtb",
-        "sel0_sp1.bin",
-        ":partition_manifest_sel0_sp1",
-        ":sel0_sp1",
-      ] ]
-  output = "sel0_sp1_package.img"
-}
-
-# VM that will control execution of tests in a VM-to-SP set-up
-vm_kernel("vm_primary") {
-  testonly = true
-
-  sources = [
-    "nwd_test_driver.c",
-  ]
-
-  deps = [
-    "//test/hftest:hftest_primary_vm",
-    "//test/vmapi/common:common",
-  ]
-}
-
-manifest("vm_primary_manifest") {
-  source = "partition-manifest-nwd-primary.dts"
-  output = "partition-manifest-nwd-primary.dtb"
-}
-
-partition_package("vm_primary_test_package") {
-  testonly = true
-  files = [ [
-        "partition-manifest-nwd-primary.dtb",
-        "vm_primary.bin",
-        ":vm_primary_manifest",
-        ":vm_primary",
-      ] ]
-  output = "vm_primary_test_package.img"
-}
-
-partitions_json("el0_sp_test") {
-  testonly = true
-
-  sps = [
-    [
-      "primary_sel1_sp_test_package.img",
-      "manifest_primary_sel1_sp.dts",
-      ":primary_sel1_sp_test_package",
-      ":partition_manifest_primary_sel1_sp",
-    ],
-    [
-      "sel0_sp1_package.img",
-      "manifest_sel0_sp1.dts",
-      ":sel0_sp1_package",
-      ":partition_manifest_sel0_sp1",
-    ],
-  ]
-
-  vms = [ [
-        "vm_primary_test_package.img",
-        "manifest.dts",
-        ":vm_primary_test_package",
-        ":vm_primary_test_package",
-      ] ]
-
-  json_file = "ffa_both_world_partitions_test.json"
-}
diff --git a/test/vmapi/el0_partitions/secure_partitions/manifest.dts b/test/vmapi/el0_partitions/secure_partitions/manifest.dts
deleted file mode 100644
index 05b0830..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/manifest.dts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2021 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-/ {
-  hypervisor {
-    compatible = "hafnium,hafnium";
-    ffa_tee_enabled;
-    vm1 {
-      is_ffa_partition;
-      debug_name = "primary_ffa_test";
-      load_address = <0x90000000>;
-    };
-  };
-};
diff --git a/test/vmapi/el0_partitions/secure_partitions/manifest_primary_sel1_sp.dts b/test/vmapi/el0_partitions/secure_partitions/manifest_primary_sel1_sp.dts
deleted file mode 100644
index 6ff2f69..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/manifest_primary_sel1_sp.dts
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2021 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-/ {
-  hypervisor {
-    compatible = "hafnium,hafnium";
-    vm1 {
-      is_ffa_partition;
-      load_address = <0x6280000>;
-      debug_name = "ffa_secure_partition_services";
-      vcpu_count = <8>;
-      mem_size = <0x100000>;
-    };
-  };
-};
diff --git a/test/vmapi/el0_partitions/secure_partitions/nwd_test_driver.c b/test/vmapi/el0_partitions/secure_partitions/nwd_test_driver.c
deleted file mode 100644
index cd9de61..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/nwd_test_driver.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2021 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-#include "hf/dlog.h"
-#include "hf/ffa.h"
-
-#include "vmapi/hf/call.h"
-
-#include "test/hftest.h"
-#include "test/vmapi/ffa.h"
-
-#define RECEIVER_ID_SP_PRIMARY 0x8001
-#define RECEIVER_ID_SP_SECONDARY 0x8002
-
-/**
- * Confirms that SP has expected ID.
- */
-TEST(ffa_dir_msg_to_sp, dir_msg_req)
-{
-	const uint32_t msg[] = {0x00001111, 0x22223333, 0x44445555, 0x66667777,
-				0x88889999};
-	ffa_vm_id_t own_id = hf_vm_get_id();
-	struct ffa_value res;
-
-	res = ffa_msg_send_direct_req(own_id, RECEIVER_ID_SP_PRIMARY, msg[0],
-				      msg[1], msg[2], msg[3], msg[4]);
-
-	EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_RESP_32);
-	EXPECT_EQ(res.arg2, 0);
-	EXPECT_EQ(res.arg3, msg[0]);
-	EXPECT_EQ(res.arg4, msg[1]);
-	EXPECT_EQ(res.arg5, msg[2]);
-	EXPECT_EQ(res.arg6, msg[3]);
-	EXPECT_EQ(res.arg7, msg[4]);
-
-	res = ffa_msg_send_direct_req(own_id, RECEIVER_ID_SP_SECONDARY, msg[0],
-				      msg[1], msg[2], msg[3], msg[4]);
-
-	EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_RESP_32);
-	EXPECT_EQ(res.arg2, 0);
-	EXPECT_EQ(res.arg3, msg[0]);
-	EXPECT_EQ(res.arg4, msg[1]);
-	EXPECT_EQ(res.arg5, msg[2]);
-	EXPECT_EQ(res.arg6, msg[3]);
-	EXPECT_EQ(res.arg7, msg[4]);
-}
diff --git a/test/vmapi/el0_partitions/secure_partitions/partition-manifest-nwd-primary.dts b/test/vmapi/el0_partitions/secure_partitions/partition-manifest-nwd-primary.dts
deleted file mode 100644
index e10e815..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/partition-manifest-nwd-primary.dts
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2020 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-/dts-v1/;
-
-/ {
-  compatible = "arm,ffa-manifest-1.0";
-  debug_name = "partition-manifest";
-
-  /* Properties */
-  ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */
-  uuid = <0xb4b5671e 0x4a904fe1 0xb81ffb13 0xdae1dacb>;
-  execution-ctx-count = <8>;
-  exception-level = <0>; /* S-EL1 */
-  execution-state = <0>; /* AARCH64 */
-  load-address = <0x90000000>;
-  entrypoint-offset = <0x1000>;
-  xlat-granule = <0>; /* 4KiB */
-  messaging-method = <0x3>; /* Direct messaging only */
-};
diff --git a/test/vmapi/el0_partitions/secure_partitions/partition_manifest_primary_sel1_sp.dts b/test/vmapi/el0_partitions/secure_partitions/partition_manifest_primary_sel1_sp.dts
deleted file mode 100644
index d82406a..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/partition_manifest_primary_sel1_sp.dts
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2021 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-/dts-v1/;
-
-/ {
-  compatible = "arm,ffa-manifest-1.0";
-  debug_name = "partition-manifest";
-
-  /* Properties */
-  ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */
-  uuid = <0xb4b5671e 0x4a904fe1 0xb81ffb13 0xdae1dacb>;
-  execution-ctx-count = <8>;
-  exception-level = <2>; /* S-EL1 */
-  execution-state = <0>; /* AARCH64 */
-  load-address = <0x6280000>;
-  entrypoint-offset = <0x1000>;
-  xlat-granule = <0>; /* 4KiB */
-  messaging-method = <0x3>; /* Direct messaging only */
-  boot-order = <1>;
-};
diff --git a/test/vmapi/el0_partitions/secure_partitions/secure_partition_service.c b/test/vmapi/el0_partitions/secure_partitions/secure_partition_service.c
deleted file mode 100644
index e420059..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/secure_partition_service.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2021 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-#include "vmapi/hf/call.h"
-
-#include "test/hftest.h"
-
-noreturn void secure_partition_msg_loop(void)
-{
-	struct ffa_value res;
-
-	res = ffa_msg_wait();
-
-	while (1) {
-		HFTEST_LOG("SP message loop.");
-		EXPECT_EQ(res.func, FFA_MSG_SEND_DIRECT_REQ_32);
-
-		ffa_msg_send_direct_resp(ffa_receiver(res), ffa_sender(res),
-					 res.arg3, res.arg4, res.arg5, res.arg6,
-					 res.arg7);
-	}
-}
diff --git a/test/vmapi/el0_partitions/secure_partitions/secure_service.c b/test/vmapi/el0_partitions/secure_partitions/secure_service.c
deleted file mode 100644
index 973184e..0000000
--- a/test/vmapi/el0_partitions/secure_partitions/secure_service.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2021 The Hafnium Authors.
- *
- * Use of this source code is governed by a BSD-style
- * license that can be found in the LICENSE file or at
- * https://opensource.org/licenses/BSD-3-Clause.
- */
-
-#include <stdalign.h>
-#include <stdint.h>
-
-#include "hf/ffa.h"
-#include "hf/mm.h"
-#include "hf/std.h"
-
-#include "vmapi/hf/call.h"
-
-#include "test/hftest.h"
-
-alignas(4096) uint8_t kstack[4096];
-
-HFTEST_ENABLE();
-
-static struct hftest_context global_context;
-
-struct hftest_context *hftest_get_context(void)
-{
-	return &global_context;
-}
-
-extern void secure_partition_msg_loop(void);
-
-noreturn void abort(void)
-{
-	HFTEST_LOG("Service contained failures.");
-	/* Cause a fault, as a secondary can't power down the machine. */
-	*((volatile uint8_t *)1) = 1;
-
-	/* This should never be reached, but to make the compiler happy... */
-	for (;;) {
-	}
-}
-
-noreturn void kmain(void)
-{
-	/*
-	 * Initialize the stage-1 MMU and identity-map the entire address space.
-	 */
-	if (!hftest_mm_init()) {
-		HFTEST_LOG_FAILURE();
-		HFTEST_LOG(HFTEST_LOG_INDENT "Memory initialization failed");
-		abort();
-	}
-
-	secure_partition_msg_loop();
-
-	/* Do not expect to get to this point, so abort. */
-	abort();
-}
diff --git a/test/vmapi/el0_partitions/secure_partitions/manifest_sel0_sp1.dts b/test/vmapi/ffa_secure_partitions/manifest_services_tertiary_sel0_sp.dts
similarity index 100%
rename from test/vmapi/el0_partitions/secure_partitions/manifest_sel0_sp1.dts
rename to test/vmapi/ffa_secure_partitions/manifest_services_tertiary_sel0_sp.dts
diff --git a/test/vmapi/el0_partitions/secure_partitions/partition_manifest_sel0_sp1.dts b/test/vmapi/ffa_secure_partitions/partition_manifest_services_tertiary_sel0_sp.dts
similarity index 100%
rename from test/vmapi/el0_partitions/secure_partitions/partition_manifest_sel0_sp1.dts
rename to test/vmapi/ffa_secure_partitions/partition_manifest_services_tertiary_sel0_sp.dts