refactor: move StMM to cactus tertiary

Reuse existing cactus tertiary partition for StMM testing rather than
adding an additional partition.

Signed-off-by: Kathleen Capella <kathleen.capella@arm.com>
Change-Id: I0c40758cc8f5e7cb2239c80346ad785c0d6888e5
diff --git a/include/runtime_services/ffa_endpoints.h b/include/runtime_services/ffa_endpoints.h
index e25ea0a..26297bc 100644
--- a/include/runtime_services/ffa_endpoints.h
+++ b/include/runtime_services/ffa_endpoints.h
@@ -14,7 +14,6 @@
 #define SECONDARY_UUID {0x092358d1, 0xb94723f0, 0x64447c82, 0xc88f57f5}
 #define TERTIARY_UUID {0x735cb579, 0xb9448c1d, 0xe1619385, 0xd2d80a77}
 #define IVY_UUID {0xd883baea, 0xaf4eafba, 0xfdf74481, 0xa744e5cb}
-#define STMM_UUID {0xdcae8d37, 0x46446bf0, 0xab401483, 0xa3873c93}
 #define EL3_SPMD_LP_UUID {0xe98e43ad, 0xb7db524f, 0x47a3bf57, 0x1588f4e3}
 
 /* vcpu_count of cactus SPs. */
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 0f54ef9..8554709 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -236,10 +236,7 @@
 			(SP_RX_TX_SIZE / 2),
 			MT_RW_DATA);
 
-	/* Skip additional mapping for cactus StMM. */
-	if (vm_id != SP_ID(5)) {
-		mmap_add(cactus_mmap);
-	}
+	mmap_add(cactus_mmap);
 	init_xlat_tables();
 }
 
@@ -314,7 +311,7 @@
 		sp_handler_spin_lock_init();
 
 		if (boot_info_header != NULL) {
-			cactus_map_boot_info(boot_info_header, ffa_id == SP_ID(5));
+			cactus_map_boot_info(boot_info_header, ffa_id == SP_ID(3));
 		}
 	}
 
@@ -344,18 +341,18 @@
 	 * Print FF-A boot info if requested in manifest via FF-A boot info
 	 * protocol.
 	 */
-	if (ffa_id == SP_ID(1) || ffa_id == SP_ID(5)) {
+	if (ffa_id == SP_ID(1) || ffa_id == SP_ID(3)) {
 		cactus_print_boot_info(boot_info_header);
 	}
 
 	cactus_print_memory_layout(ffa_id);
 
 	/*
-	 * Cactus-tertiary and cactus-stmm make use of FFA_RXTX_MAP API
-	 * instead of specifying `rx_tx-info` in their manifests, as done by the
-	 * primary and secondary cactus partitions.
+	 * Cactus-tertiary makes use of FFA_RXTX_MAP API instead of specifying
+	 * `rx_tx-info` in its manifest, as done by the primary and secondary
+	 * cactus partitions.
 	 */
-	if (ffa_id == SP_ID(3) || ffa_id == SP_ID(5)) {
+	if (ffa_id == SP_ID(3)) {
 		VERBOSE("Mapping RXTX Region\n");
 		CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
 		if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
@@ -369,7 +366,7 @@
 	ret = register_secondary_entrypoint();
 
 	/* FFA_SECONDARY_EP_REGISTER interface is not supported for UP SP. */
-	if (ffa_id == SP_ID(3) || ffa_id == SP_ID(5)) {
+	if (ffa_id == SP_ID(3)) {
 		EXPECT(ffa_func_id(ret), FFA_ERROR);
 		EXPECT(ffa_error_code(ret), FFA_ERROR_NOT_SUPPORTED);
 	} else {
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus-stmm.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-stmm.dts
deleted file mode 100644
index e8e9f0c..0000000
--- a/spm/cactus/plat/arm/fvp/fdts/cactus-stmm.dts
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-/dts-v1/;
-
-/ {
-
-	/*
-	 * FF-A compatible Secure Partition Manager parses the
-	 * config file and fetch the following booting arguments to
-	 * pass on to the StandAloneMM(StMM) Secure Partition.
-	 */
-	compatible = "arm,ffa-manifest-1.0";
-
-	description = "FVP Base StandaloneMm";
-	ffa-version = <0x00010002>; /* 31:16 - Major, 15:0 - Minor */
-	uuid = <0xdcae8d37 0x46446bf0 0xab401483 0xa3873c93>;
-	id = <0x8001>;
-	execution-ctx-count = <1>;
-	exception-level = <0x2>; /* SEL1*/
-	execution-state = <0>; /* AArch64*/
-	load-address = <0x0 0x7700000>;
-	entrypoint-offset = <0x00003000>; /*Image after manifest and HOB list. */
-	image-size = <0x0 0x00300000>;
-	xlat-granule = <0>; /* 4KiB */
-	boot_info_reg = <0>; /* x0 */
-	boot-order = <5>;
-	messaging-method = <0x3>;
-	power-management-messages = <0>;
-	gp-register-num = <0>;
-
-	/* Boot Info */
-	boot-info {
-		compatible = "arm,ffa-manifest-boot-info";
-		hob_list;
-	};
-
-	/*
-	 * Device regions of StMM manifest not included, given they
-	 * are not used in the hob.
-	 */
-	memory-regions {
-		compatible = "arm,ffa-manifest-memory-regions";
-		/*
-		 * SPM Payload memory. Mapped as code region for S-EL0
-		 * Similar to ARM_SP_IMAGE_MMAP.
-		 */
-		stmm_region {
-			description = "image";
-			base-address = <0x0 0xfd200000>;
-			pages-count = <0x300>;
-			/* StMM will remap the regions during runtime */
-			attributes = <0x5>;
-		};
-
-		/*
-		 * Memory shared between EL3 and S-EL0.
-		 * Similar to ARM_SPM_BUF_EL0_MMAP.
-		 */
-		rx-tx-buffers {
-			description = "shared-buff";
-			base-address = <0x0 0xfd500000>;
-			pages-count = <0x100>;
-			attributes = <0x3>;
-		};
-
-		/*
-		 * Memory shared between Normal world and S-EL0.
-		 * Similar to ARM_SP_IMAGE_NS_BUF_MMAP.
-		 */
-		ns_comm_buffer {
-			/*
-			 * Description is needed for StMM to identify
-			 * ns-communication buffer.
-			 */
-			description = "ns-comm";
-			base-address = <0x80000000>;
-			pages-count = <0x1>;
-			attributes = <0xB>;
-		};
-
-		/*
-		 * Heap used by SP to allocate memory for DMA.
-		 */
-		heap {
-			/*
-			 * Description is needed for StMM to identify
-			 * heap buffer.
-			 */
-			description = "heap";
-			base-address = <0x0 0xff100000>;
-			pages-count = <0x7>;
-			attributes = <0x3>;
-		};
-	};
-};
-
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
index d1ffa2f..6c0ea57 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
@@ -24,7 +24,8 @@
 	exception-level = <2>; /* S-EL1 */
 	execution-state = <0>; /* AARCH64 */
 	load-address = <0x7200000>;
-	entrypoint-offset = <0x00002000>;
+	image-size = <0x300000>;
+	entrypoint-offset = <0x00003000>; /*Image after manifest and HOB list. */
 	xlat-granule = <0>; /* 4KiB */
 	boot-order = <2>;
 	notification-support;
@@ -32,6 +33,15 @@
 	managed-exit; /* Managed exit is supported */
 	managed-exit-virq;
 
+	/* Boot protocol */
+	gp-register-num = <0>;
+
+	/* Boot Info */
+	boot-info {
+		compatible = "arm,ffa-manifest-boot-info";
+		hob_list;
+	};
+
 	memory-regions {
 		compatible = "arm,ffa-manifest-memory-regions";
 
@@ -50,5 +60,37 @@
 			base-address = <0x00008800 0x80001000>;
 			attributes = <0xb>; /* NS / read-write */
 		};
+
+		/* StMM-specific region used for HOB list testing. */
+		rx-tx-buffers {
+			description = "shared-buff";
+			base-address = <0x0 0xfd500000>;
+			pages-count = <0x100>;
+			attributes = <0x3>;
+		};
+
+		/* StMM-specific region used for HOB list testing. */
+		ns_comm_buffer {
+			/*
+			 * Description is needed for StMM to identify
+			 * ns-communication buffer.
+			 */
+			description = "ns-comm";
+			base-address = <0x80000000>;
+			pages-count = <0x1>;
+			attributes = <0xB>;
+		};
+
+		/* StMM-specific region used for HOB list testing. */
+		heap {
+			/*
+			 * Description is needed for StMM to identify
+			 * heap buffer.
+			 */
+			description = "heap";
+			base-address = <0x0 0xff100000>;
+			pages-count = <0x7>;
+			attributes = <0x3>;
+		};
 	};
 };
diff --git a/spm/cactus/plat/arm/fvp/platform.mk b/spm/cactus/plat/arm/fvp/platform.mk
index 0125d00..c7b01bb 100644
--- a/spm/cactus/plat/arm/fvp/platform.mk
+++ b/spm/cactus/plat/arm/fvp/platform.mk
@@ -15,4 +15,3 @@
 FDTS_CP_LIST		= ${FVP_CACTUS_BASE}/fdts/cactus.dts
 FDTS_CP_LIST		+= ${FVP_CACTUS_BASE}/fdts/cactus-secondary.dts
 FDTS_CP_LIST		+= ${FVP_CACTUS_BASE}/fdts/cactus-tertiary.dts
-FDTS_CP_LIST		+= ${FVP_CACTUS_BASE}/fdts/cactus-stmm.dts
diff --git a/spm/common/sp_tests/sp_test_ffa.c b/spm/common/sp_tests/sp_test_ffa.c
index a63fa5e..e7dd720 100644
--- a/spm/common/sp_tests/sp_test_ffa.c
+++ b/spm/common/sp_tests/sp_test_ffa.c
@@ -22,9 +22,8 @@
 static uint32_t spm_version;
 
 static const struct ffa_uuid sp_uuids[] = {
-		{PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}, {IVY_UUID},
-		{STMM_UUID}, {EL3_SPMD_LP_UUID}
-};
+		{PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}, {IVY_UUID}, {EL3_SPMD_LP_UUID}
+	};
 
 static const struct ffa_partition_info ffa_expected_partition_info[] = {
 	/* Primary partition info */
@@ -67,14 +66,6 @@
 			       FFA_PARTITION_DIRECT_REQ_SEND),
 		.uuid = {IVY_UUID}
 	},
-	{
-		.id = SP_ID(5),
-		.exec_context = 1,
-		.properties = (FFA_PARTITION_AARCH64_EXEC |
-			       FFA_PARTITION_DIRECT_REQ_RECV |
-			       FFA_PARTITION_DIRECT_REQ_SEND),
-		.uuid = {STMM_UUID}
-	},
 	/* EL3 SPMD logical partition */
 	{
 		.id = SP_ID(0x7FC0),
@@ -169,7 +160,7 @@
 	 * we assume they dont exist and skip further tests to avoid
 	 * failures on platforms without el3 spmd logical partitions.
 	 */
-	ret = ffa_partition_info_get_regs(sp_uuids[5], 0, 0);
+	ret = ffa_partition_info_get_regs(sp_uuids[4], 0, 0);
 	if ((ffa_func_id(ret) == FFA_ERROR) &&
 	    ((ffa_error_code(ret) == FFA_ERROR_NOT_SUPPORTED) ||
 	    (ffa_error_code(ret) == FFA_ERROR_INVALID_PARAMETER))) {
diff --git a/tools/generate_json/generate_json.sh b/tools/generate_json/generate_json.sh
index 11ee2ee..463b110 100755
--- a/tools/generate_json/generate_json.sh
+++ b/tools/generate_json/generate_json.sh
@@ -69,15 +69,6 @@
 	"physical-load-address": "0x7200000",
 	"owner": "Plat",
 	"package": "tl_pkg",
-	"size": "0x100000"
-},
-
-"cactus-stmm" : {
-	"image": "cactus.bin",
-	"pm": "cactus-stmm.dts",
-	"physical-load-address": "0x7700000",
-	"owner": "Plat",
-	"package": "tl_pkg",
 	"size": "0x300000"
 EOF
 	PARTITION_ALREADY_PRESENT=true