Merge "refactor(ffa-notification): deprecate per-vCPU notification test coverage"
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
index fe04751..9a63d85 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
@@ -17,23 +17,6 @@
 #include <spm_test_helpers.h>
 #include <test_helpers.h>
 
-/**
- * Defining variables to test the per-vCPU notifications.
- * The conceived test follows the same logic, despite the sender receiver type
- * of endpoint (VM or secure partition).
- * Using global variables because these need to be accessed in the cpu on handler
- * function 'request_notification_get_per_vcpu_on_handler'.
- * In each specific test function, change 'per_vcpu_receiver' and
- * 'per_vcpu_sender' have the logic work for:
- * - NWd to SP;
- * - SP to NWd;
- * - SP to SP.
- */
-static ffa_id_t per_vcpu_receiver;
-static ffa_id_t per_vcpu_sender;
-uint32_t per_vcpu_flags_get;
-static event_t per_vcpu_finished[PLATFORM_CORE_COUNT];
-
 static const struct ffa_uuid expected_sp_uuids[] = {
 		{PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}
 };
@@ -958,338 +941,6 @@
 }
 
 /**
- * CPU_ON handler for testing per-vCPU notifications to SPs (either from VMs
- * or from SPs). It requests the SP to retrieve its pending notifications
- * within its current Execution Context. The SP shall obtain all per-vCPU
- * targeted to the running vCPU.
- */
-static test_result_t request_notification_get_per_vcpu_on_handler(void)
-{
-	unsigned int core_pos = get_current_core_id();
-	test_result_t result = TEST_RESULT_FAIL;
-
-	uint64_t exp_from_vm = 0;
-	uint64_t exp_from_sp = 0;
-
-	if (IS_SP_ID(per_vcpu_sender)) {
-		exp_from_sp = FFA_NOTIFICATION(core_pos);
-	} else {
-		exp_from_vm = FFA_NOTIFICATION(core_pos);
-	}
-
-	VERBOSE("Request get per-vCPU notification to %x, core: %u.\n",
-		 per_vcpu_receiver, core_pos);
-
-	/*
-	 * Request to get notifications sent to the respective vCPU.
-	 * Check also if NPI was handled by the receiver. It should have been
-	 * pended at notifications set, in the respective vCPU.
-	 */
-	if (!notification_get_and_validate(
-		per_vcpu_receiver, exp_from_sp, exp_from_vm, core_pos,
-		per_vcpu_flags_get, true)) {
-		goto out;
-	}
-
-	result = TEST_RESULT_SUCCESS;
-
-out:
-	INFO("Request get per-vCPU notification to %x, core: %u.\n",
-		 per_vcpu_receiver, core_pos);
-	/* Tell the lead CPU that the calling CPU has completed the test. */
-	tftf_send_event(&per_vcpu_finished[core_pos]);
-
-	return result;
-}
-
-static test_result_t base_npi_enable_per_cpu(bool enable)
-{
-	test_result_t result = TEST_RESULT_FAIL;
-	uint32_t core_pos = get_current_core_id();
-
-	VERBOSE("Request SP %x to enable NPI in core %u\n",
-		 per_vcpu_receiver, core_pos);
-
-	result = TEST_RESULT_SUCCESS;
-
-	/* Tell the lead CPU that the calling CPU has completed the test. */
-	tftf_send_event(&per_vcpu_finished[core_pos]);
-
-	return result;
-}
-
-static test_result_t npi_enable_per_vcpu_on_handler(void)
-{
-	return base_npi_enable_per_cpu(true);
-}
-
-static test_result_t npi_disable_per_vcpu_on_handler(void)
-{
-	return base_npi_enable_per_cpu(false);
-}
-/**
- * Base function to test signaling of per-vCPU notifications.
- * Test whole flow between two FF-A endpoints: binding, getting notification
- * info, and getting pending notifications.
- * Each vCPU will receive a notification whose ID is the same as the core
- * position.
- */
-static test_result_t base_test_per_vcpu_notifications(ffa_id_t sender,
-						      ffa_id_t receiver)
-{
-	/*
-	 * Manually set variables to validate what should be the return of to
-	 * FFA_NOTIFICATION_INFO_GET.
-	 */
-	uint16_t exp_ids[FFA_NOTIFICATIONS_INFO_GET_MAX_IDS] = {
-		receiver, 0, 1, 2,
-		receiver, 3, 4, 5,
-		receiver, 6, 7, 0,
-		0, 0, 0, 0,
-		0, 0, 0, 0,
-	};
-	uint32_t exp_lists_count = 3;
-	uint32_t exp_lists_sizes[FFA_NOTIFICATIONS_INFO_GET_MAX_IDS] = {
-		3, 3, 2, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	};
-
-	const bool exp_more_notif_pending = false;
-	test_result_t result = TEST_RESULT_SUCCESS;
-	uint64_t notifications_to_unbind = 0;
-
-	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
-
-	per_vcpu_flags_get = IS_SP_ID(sender)
-				? FFA_NOTIFICATIONS_FLAG_BITMAP_SP
-				: FFA_NOTIFICATIONS_FLAG_BITMAP_VM;
-
-	/* Setting global variables to be accessed by the cpu_on handler. */
-	per_vcpu_receiver = receiver;
-	per_vcpu_sender = sender;
-
-	INFO("Execute npi_enable_per_vcpu_on_handler\n");
-	/* Boot all cores and enable the NPI in all of them. */
-	if (spm_run_multi_core_test(
-		(uintptr_t)npi_enable_per_vcpu_on_handler,
-		per_vcpu_finished) != TEST_RESULT_SUCCESS) {
-		return TEST_RESULT_FAIL;
-	}
-
-	/*
-	 * Prepare notifications bitmap to request Cactus to bind them as
-	 * per-vCPU.
-	 */
-	for (unsigned int i = 0; i < PLATFORM_CORE_COUNT; i++) {
-		notifications_to_unbind |= FFA_NOTIFICATION(i);
-
-		uint32_t flags = FFA_NOTIFICATIONS_FLAG_PER_VCPU  |
-				 FFA_NOTIFICATIONS_FLAGS_VCPU_ID((uint16_t)i);
-
-		flags |= (IS_SP_ID(sender))
-				? FFA_NOTIFICATIONS_FLAG_DELAY_SRI
-				: 0;
-
-		if (!notification_bind_and_set(sender,
-					       receiver,
-					       FFA_NOTIFICATION(i),
-					       flags)) {
-			return TEST_RESULT_FAIL;
-		}
-	}
-
-	/* Call FFA_NOTIFICATION_INFO_GET and validate return. */
-	if (!notifications_info_get(exp_ids, exp_lists_count, exp_lists_sizes,
-				    FFA_NOTIFICATIONS_INFO_GET_MAX_IDS,
-				    exp_more_notif_pending)) {
-		ERROR("Info Get Failed....\n");
-		result = TEST_RESULT_FAIL;
-		goto out;
-	}
-
-	/*
-	 * Request SP to get notifications in core 0, as this is not iterated
-	 * at the CPU ON handler.
-	 * Set `check_npi_handled` to true, as the receiver is supposed to be
-	 * preempted by the NPI.
-	 */
-	if (!notification_get_and_validate(
-		receiver, IS_SP_ID(sender) ? FFA_NOTIFICATION(0) : 0,
-		!IS_SP_ID(sender) ? FFA_NOTIFICATION(0) : 0, 0,
-		per_vcpu_flags_get, true)) {
-		result = TEST_RESULT_FAIL;
-	}
-
-	INFO("Execute request_notification_get_per_vcpu_on_handler\n");
-	/*
-	 * Bring up all the cores, and request the receiver to get notifications
-	 * in each one of them.
-	 */
-	if (spm_run_multi_core_test(
-		(uintptr_t)request_notification_get_per_vcpu_on_handler,
-		per_vcpu_finished) != TEST_RESULT_SUCCESS) {
-		result = TEST_RESULT_FAIL;
-	}
-
-out:
-	INFO("UNbind message on CPU:%lx\n", read_mpidr_el1());
-	/* As a clean-up, unbind notifications. */
-	if (!request_notification_unbind(receiver, receiver,
-					 sender,
-					 notifications_to_unbind,
-					 CACTUS_SUCCESS, 0)) {
-		result = TEST_RESULT_FAIL;
-	}
-
-	INFO("Execute npi_disable_per_vcpu_on_handler\n");
-	/* Boot all cores and DISABLE the NPI in all of them. */
-	if (spm_run_multi_core_test(
-		(uintptr_t)npi_disable_per_vcpu_on_handler,
-		per_vcpu_finished) != TEST_RESULT_SUCCESS) {
-		return TEST_RESULT_FAIL;
-	}
-
-	return result;
-}
-
-/**
- * Test to validate a VM can signal a per-vCPU notification to an SP.
- */
-test_result_t test_ffa_notifications_vm_signals_sp_per_vcpu(void)
-{
-	return base_test_per_vcpu_notifications(0, SP_ID(1));
-}
-
-/**
- * Test to validate an SP can signal a per-vCPU notification to an SP.
- */
-test_result_t test_ffa_notifications_sp_signals_sp_per_vcpu(void)
-{
-	return base_test_per_vcpu_notifications(SP_ID(1), SP_ID(2));
-}
-
-static test_result_t notification_get_per_vcpu_on_handler(void)
-{
-	unsigned int core_pos = get_current_core_id();
-	test_result_t result = TEST_RESULT_SUCCESS;
-
-	VERBOSE("Getting per-vCPU notifications from %x, core: %u.\n",
-		 per_vcpu_receiver, core_pos);
-
-	if (!notification_get_and_validate(per_vcpu_receiver,
-					   FFA_NOTIFICATION(core_pos), 0,
-					   core_pos,
-					   FFA_NOTIFICATIONS_FLAG_BITMAP_SP,
-					   false)) {
-		result = TEST_RESULT_FAIL;
-	}
-
-	/* Tell the lead CPU that the calling CPU has completed the test. */
-	tftf_send_event(&per_vcpu_finished[core_pos]);
-
-	return result;
-}
-
-/**
- * Test whole flow from binding, to getting notifications' info, and getting
- * pending notifications, namely signaling of notifications from SP to a VM.
- * Each vCPU will receive a notification whose ID is the same as the core
- * position.
- */
-test_result_t test_ffa_notifications_sp_signals_vm_per_vcpu(void)
-{
-	/* Making a VM the receiver, and an SP the sender */
-	per_vcpu_receiver = VM_ID(1);
-	per_vcpu_sender = SP_ID(2);
-
-	/**
-	 * Manually set variables to validate what should be the return of to
-	 * FFA_NOTIFICATION_INFO_GET.
-	 */
-	uint16_t exp_ids[FFA_NOTIFICATIONS_INFO_GET_MAX_IDS] = {
-		per_vcpu_receiver, 0, 1, 2,
-		per_vcpu_receiver, 3, 4, 5,
-		per_vcpu_receiver, 6, 7, 0,
-		0, 0, 0, 0,
-		0, 0, 0, 0,
-	};
-	uint32_t exp_lists_count = 3;
-	uint32_t exp_lists_sizes[FFA_NOTIFICATIONS_INFO_GET_MAX_IDS] = {
-		3, 3, 2, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	};
-
-	const bool exp_more_notif_pending = false;
-	test_result_t result = TEST_RESULT_SUCCESS;
-	uint64_t notifications_to_unbind = 0;
-	struct ffa_value ret;
-
-	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
-
-	/* Create bitmap for receiver. */
-	if (!notifications_bitmap_create(per_vcpu_receiver,
-					 PLATFORM_CORE_COUNT)) {
-		return TEST_RESULT_FAIL;
-	}
-
-	/* Bind notifications, and request Cactus SP to set them. */
-	for (uint32_t i = 0U; i < PLATFORM_CORE_COUNT; i++) {
-		notifications_to_unbind |= FFA_NOTIFICATION(i);
-
-		uint32_t flags = FFA_NOTIFICATIONS_FLAG_DELAY_SRI |
-				 FFA_NOTIFICATIONS_FLAG_PER_VCPU  |
-				 FFA_NOTIFICATIONS_FLAGS_VCPU_ID((uint16_t)i);
-
-		if (!notification_bind_and_set(per_vcpu_sender,
-					      per_vcpu_receiver,
-					      FFA_NOTIFICATION(i),
-					      flags)) {
-			return TEST_RESULT_FAIL;
-		};
-	}
-
-	/* Call FFA_NOTIFICATION_INFO_GET and validate return. */
-	if (!notifications_info_get(exp_ids, exp_lists_count, exp_lists_sizes,
-				    FFA_NOTIFICATIONS_INFO_GET_MAX_IDS,
-				    exp_more_notif_pending)) {
-		ERROR("Info Get Failed....\n");
-		return TEST_RESULT_FAIL;
-	}
-
-	/*
-	 * Get notifications in core 0, as it is not iterated at the CPU ON
-	 * handler.
-	 */
-	if (!notification_get_and_validate(per_vcpu_receiver,
-					   FFA_NOTIFICATION(0), 0, 0,
-					   FFA_NOTIFICATIONS_FLAG_BITMAP_SP,
-					   false)) {
-		result = TEST_RESULT_FAIL;
-	}
-
-	/* Bring up all the cores, and get notifications in each one of them. */
-	if (spm_run_multi_core_test(
-		(uintptr_t)notification_get_per_vcpu_on_handler,
-		per_vcpu_finished) != TEST_RESULT_SUCCESS) {
-		ERROR("Failed to get per-vCPU notifications\n");
-		result = TEST_RESULT_FAIL;
-	}
-
-	/* As a clean-up, unbind notifications. */
-	ret = ffa_notification_unbind(per_vcpu_sender, per_vcpu_receiver,
-				      notifications_to_unbind);
-	if (is_ffa_call_error(ret)) {
-		result = TEST_RESULT_FAIL;
-	}
-
-	if (!notifications_bitmap_destroy(per_vcpu_receiver)) {
-		result = TEST_RESULT_FAIL;
-	}
-
-	return result;
-}
-
-/**
  * Test to validate behavior in SWd if the SRI is not delayed. If the
  * notification setter handled a managed exit it is indicative the SRI was
  * sent immediately.
@@ -1476,91 +1127,3 @@
 
 	return result;
 }
-
-test_result_t notifications_set_per_vcpu_on_handler(void)
-{
-	unsigned int core_pos = get_current_core_id();
-	test_result_t result = TEST_RESULT_FAIL;
-
-	if (!notification_set(per_vcpu_receiver, per_vcpu_sender,
-			      FFA_NOTIFICATIONS_FLAG_DELAY_SRI |
-			      FFA_NOTIFICATIONS_FLAG_PER_VCPU  |
-			      FFA_NOTIFICATIONS_FLAGS_VCPU_ID(0),
-			      FFA_NOTIFICATION(core_pos))) {
-		goto out;
-	}
-
-	result = TEST_RESULT_SUCCESS;
-
-out:
-	/* Tell the lead CPU that the calling CPU has completed the test. */
-	tftf_send_event(&per_vcpu_finished[core_pos]);
-
-	return result;
-}
-
-test_result_t test_ffa_notifications_mp_sp_signals_up_sp(void)
-{
-	ffa_notification_bitmap_t to_bind = 0;
-
-	/* prepare info get variables. */
-
-	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
-
-	/* Setting per-vCPU sender and receiver IDs. */
-	per_vcpu_sender = SP_ID(2); /* MP SP */
-	per_vcpu_receiver = SP_ID(3); /* UP SP */
-
-	schedule_receiver_interrupt_init();
-
-	/* Prepare notifications bitmap to have one bit platform core. */
-	for (uint32_t i = 0; i < PLATFORM_CORE_COUNT; i++) {
-		to_bind |= FFA_NOTIFICATION(i);
-	}
-
-	/* Request receiver to bind a set of notifications to the sender. */
-	if (!request_notification_bind(per_vcpu_receiver, per_vcpu_receiver,
-				       per_vcpu_sender, to_bind,
-				       FFA_NOTIFICATIONS_FLAG_PER_VCPU,
-				       CACTUS_SUCCESS, 0)) {
-		return TEST_RESULT_FAIL;
-	}
-
-	/*
-	 * Boot up system, and then request sender to signal notification from
-	 * every core into into receiver's only vCPU. Delayed SRI.
-	 */
-	if (!notification_set(per_vcpu_receiver, per_vcpu_sender,
-			     FFA_NOTIFICATIONS_FLAG_DELAY_SRI |
-			     FFA_NOTIFICATIONS_FLAG_PER_VCPU |
-			     FFA_NOTIFICATIONS_FLAGS_VCPU_ID(0),
-			     FFA_NOTIFICATION(0))) {
-		return TEST_RESULT_FAIL;
-	}
-
-	if (spm_run_multi_core_test(
-		(uintptr_t)notifications_set_per_vcpu_on_handler,
-		per_vcpu_finished) != TEST_RESULT_SUCCESS) {
-		return TEST_RESULT_FAIL;
-	}
-
-	if (!check_schedule_receiver_interrupt_handled()) {
-		return TEST_RESULT_FAIL;
-	}
-
-	if (!notification_get_and_validate(per_vcpu_receiver, to_bind, 0, 0,
-		FFA_NOTIFICATIONS_FLAG_BITMAP_SP, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
-	/* Request unbind. */
-	if (!request_notification_unbind(per_vcpu_receiver, per_vcpu_receiver,
-					per_vcpu_sender, to_bind,
-					CACTUS_SUCCESS, 0)) {
-		return TEST_RESULT_FAIL;
-	}
-
-	schedule_receiver_interrupt_deinit();
-
-	return TEST_RESULT_SUCCESS;
-}
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index 60470fe..9c674a9 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -229,16 +229,8 @@
                function="test_ffa_notifications_sp_signals_sp_delayed_sri" />
      <testcase name="Notifications unbind while pending"
                function="test_ffa_notifications_unbind_pending" />
-     <testcase name="Notifications MP SP signals UP SP per-vCPU"
-               function="test_ffa_notifications_mp_sp_signals_up_sp" />
      <testcase name="Notifications info get no data"
                function="test_ffa_notifications_info_get_none" />
-     <testcase name="Notifications VM signals SP per-vCPU"
-               function="test_ffa_notifications_vm_signals_sp_per_vcpu" />
-     <testcase name="Notifications SP signals SP per-vCPU"
-               function="test_ffa_notifications_sp_signals_sp_per_vcpu" />
-     <testcase name="Notifications SP signals VM per-vCPU"
-               function="test_ffa_notifications_sp_signals_vm_per_vcpu" />
      <testcase name="Notifications VM signals SP, with SRI flag set and fail"
                function="test_ffa_notifications_vm_signals_sp_delay_sri_fail" />
   </testsuite>