fix(interrupts): dont enable virtual maintenance interrupts

SPMC enables the following virtual maintenance interrupts by default
for each Secure Partition:
  > MANAGED_EXIT_INTERRUPT_ID
  > NOTIFICATION_PENDING_INTERRUPT_INTID

Hence, no need to send a request to SPs to enable them.

Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: I7fc605b9b78ad759728909cd28ad2d2083c5de54
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index b1349dd..9fc7579 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -429,11 +429,6 @@
 bool spm_core_sp_init(ffa_id_t sp_id);
 
 /**
- * Enable/Disable managed exit interrupt for the provided SP.
- */
-bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable);
-
-/**
  * Initializes the Mailbox for other SPM related tests that need to use
  * RXTX buffers.
  */
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index f499579..bd82fd9 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -241,22 +241,6 @@
 	return true;
 }
 
-bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable)
-{
-	struct ffa_value ret;
-
-	ret = cactus_interrupt_cmd(HYP_ID, sp_id, MANAGED_EXIT_INTERRUPT_ID,
-				   enable, INTERRUPT_TYPE_FIQ);
-
-	if (!is_ffa_direct_response(ret) ||
-	    cactus_get_response(ret) != CACTUS_SUCCESS) {
-		ERROR("Failed to enable Managed exit interrupt\n");
-		return false;
-	}
-
-	return true;
-}
-
 /*
  * Initializes the Mailbox for other SPM related tests that need to use
  * RXTX buffers.
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c b/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
index 089334f..0aaf5e3 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_interrupts.c
@@ -57,28 +57,25 @@
  * @Test_Aim@ Test non-secure interrupts while a Secure Partition capable
  * of managed exit is executing.
  *
- * 1. Enable managed exit interrupt by sending interrupt_enable command to
- *    Cactus.
- *
- * 2. Register a handler for the non-secure timer interrupt. Program it to fire
+ * 1. Register a handler for the non-secure timer interrupt. Program it to fire
  *    in a certain time.
  *
- * 3. Send a direct request request to Cactus SP to execute in busy loop.
+ * 2. Send a direct request to Cactus SP to execute in busy loop.
  *
- * 4. While executing in busy loop, the non-secure timer should
+ * 3. While executing in busy loop, the non-secure timer should
  *    fire and trap into SPM running at S-EL2 as FIQ.
  *
- * 5. SPM injects a managed exit virtual FIQ into Cactus (as configured in the
+ * 4. SPM injects a managed exit virtual FIQ into Cactus (as configured in the
  *    interrupt enable call), causing it to run its interrupt handler.
  *
- * 6. Cactus's managed exit handler acknowledges interrupt arrival by
+ * 5. Cactus's managed exit handler acknowledges interrupt arrival by
  *    requesting the interrupt id to the SPMC, and check if it is the
  *    MANAGED_EXIT_INTERRUPT_ID.
  *
- * 7. Check whether the pending non-secure timer interrupt successfully got
+ * 6. Check whether the pending non-secure timer interrupt successfully got
  *    handled in TFTF.
  *
- * 8. Send a direct message request command to resume Cactus's execution.
+ * 7. Send a direct message request command to resume Cactus's execution.
  *    It resumes in the sleep loop and completes it. It then returns with
  *    a direct message response. Check if time lapsed is greater than
  *    sleeping time.
@@ -91,11 +88,6 @@
 
 	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
 
-	/* Enable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(RECEIVER, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	ret = program_timer(TIMER_DURATION);
 	if (ret < 0) {
 		ERROR("Failed to program timer (%d)\n", ret);
@@ -144,11 +136,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Disable Managed exit interrupt. */
-	if (!spm_set_managed_exit_int(RECEIVER, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return TEST_RESULT_SUCCESS;
 }
 
@@ -251,53 +238,47 @@
  * while the second SP is processing a direct request message sent by the first
  * SP. We choose SP(1) as the first SP and SP(3) as the second SP.
  *
- * 1. Enable managed exit interrupt by sending interrupt_enable command to both
- *    the Cactus SPs.
- *
- * 2. Register a handler for the non-secure timer interrupt. Program it to fire
+ * 1. Register a handler for the non-secure timer interrupt. Program it to fire
  *    in a certain time.
  *
- * 3. Send a direct request to the first SP(i.e., SP(1)) to forward sleep command to
+ * 2. Send a direct request to the first SP(i.e., SP(1)) to forward sleep command to
  *    the second SP(i.e., SP(3)).
  *
- * 4. While the second SP is running the busy loop, non-secure interrupt would
+ * 3. While the second SP is running the busy loop, non-secure interrupt would
  *    trigger during this time.
  *
- * 5. The interrupt will be trapped to SPMC as FIQ. SPMC will inject the managed
+ * 4. The interrupt will be trapped to SPMC as FIQ. SPMC will inject the managed
  *    exit signal to the second SP through vIRQ conduit and perform eret to
  *    resume execution in the second SP.
  *
- * 6. The second SP sends the managed exit direct response to the first SP
+ * 5. The second SP sends the managed exit direct response to the first SP
  *    through its interrupt handler for managed exit.
  *
- * 7. SPMC proactively injects managed exit signal to the first SP through vFIQ
+ * 6. SPMC proactively injects managed exit signal to the first SP through vFIQ
  *    conduit and resumes it using eret.
  *
- * 8. The first Cactus SP sends the managed exit direct response to TFTF through
+ * 7. The first Cactus SP sends the managed exit direct response to TFTF through
  *    its interrupt handler for managed exit.
  *
- * 9. TFTF checks the return value in the direct message response from the first SP
+ * 8. TFTF checks the return value in the direct message response from the first SP
  *    and ensures it is managed signal interrupt ID.
  *
- * 10. Check whether the pending non-secure timer interrupt successfully got
- *     handled in the normal world by TFTF.
+ * 9. Check whether the pending non-secure timer interrupt successfully got
+ *    handled in the normal world by TFTF.
  *
- * 11. Send a dummy direct message request command to resume the first SP's execution.
+ * 10. Send a dummy direct message request command to resume the first SP's execution.
  *
- * 12. The first SP direct message request returns with managed exit response. It
+ * 11. The first SP direct message request returns with managed exit response. It
  *     then sends a dummy direct message request command to resume the second SP's
  *     execution.
  *
- * 13. The second SP resumes in the sleep routine and sends a direct message
+ * 12. The second SP resumes in the sleep routine and sends a direct message
  *     response to the first SP.
  *
- * 14. The first SP checks if time lapsed is not lesser than sleep time and if
+ * 13. The first SP checks if time lapsed is not lesser than sleep time and if
  *     successful, sends direct message response to the TFTF.
  *
- * 15. TFTF ensures the direct message response did not return with an error.
- *
- * 16. TFTF further disables the managed exit virtual interrupt for both the
- *     Cactus SPs.
+ * 14. TFTF ensures the direct message response did not return with an error.
  *
  */
 test_result_t test_ffa_ns_interrupt_managed_exit_chained(void)
@@ -307,12 +288,6 @@
 
 	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
 
-	/* Enable managed exit interrupt in the secure side. */
-	if (!spm_set_managed_exit_int(RECEIVER, true) ||
-		!spm_set_managed_exit_int(RECEIVER_3, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	ret = program_timer(TIMER_DURATION);
 	if (ret < 0) {
 		ERROR("Failed to program timer (%d)\n", ret);
@@ -359,12 +334,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Disable Managed exit interrupt. */
-	if (!spm_set_managed_exit_int(RECEIVER, false) ||
-		!spm_set_managed_exit_int(RECEIVER_3, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return TEST_RESULT_SUCCESS;
 }
 
@@ -375,49 +344,43 @@
  * message sent by the first SP. We choose SP(1) as the first SP and SP(2) as
  * the second SP.
  *
- * 1. Enable managed exit interrupt by sending interrupt_enable command to
- *    the first Cactus SP in the call chain.
- *
- * 2. Register a handler for the non-secure timer interrupt. Program it to fire
+ * 1. Register a handler for the non-secure timer interrupt. Program it to fire
  *    in a certain time.
  *
- * 3. Send a direct request to the first SP(i.e., SP(1)) to forward sleep command to
+ * 2. Send a direct request to the first SP(i.e., SP(1)) to forward sleep command to
  *    the second SP(i.e., SP(2)).
  *
- * 4. While the second SP is running the busy loop, non-secure interrupt would
+ * 3. While the second SP is running the busy loop, non-secure interrupt would
  *    trigger during this time.
  *
- * 5. The interrupt will be trapped to SPMC as FIQ. SPMC finds the source of
+ * 4. The interrupt will be trapped to SPMC as FIQ. SPMC finds the source of
  *    the interrupted direct message request and prepares the return status
  *    as FFA_INTERRUPT.
  *
- * 6. SPMC injects managed exit signal to the first SP through vFIQ
+ * 5. SPMC injects managed exit signal to the first SP through vFIQ
  *    conduit and resumes it using eret.
  *
- * 7. The first Cactus SP sends the managed exit direct response to TFTF through
+ * 6. The first Cactus SP sends the managed exit direct response to TFTF through
  *    its interrupt handler for managed exit.
  *
- * 8. TFTF checks the return value in the direct message response from the first SP
+ * 7. TFTF checks the return value in the direct message response from the first SP
  *    and ensures it is managed signal interrupt ID.
  *
- * 9. Check whether the pending non-secure timer interrupt successfully got
+ * 8. Check whether the pending non-secure timer interrupt successfully got
  *    handled in the normal world by TFTF.
  *
- * 10. Send a dummy direct message request command to resume the first SP's execution.
+ * 9. Send a dummy direct message request command to resume the first SP's execution.
  *
- * 11. The first SP direct message request returns with FFA_INTERRUPT status. It
+ * 10. The first SP direct message request returns with FFA_INTERRUPT status. It
  *     then resumes the second SP's execution using FFA_RUN ABI.
  *
- * 12. The second SP resumes in the sleep routine and sends a direct message
+ * 11. The second SP resumes in the sleep routine and sends a direct message
  *     response to the first SP.
  *
- * 13. The first SP checks if time lapsed is not lesser than sleep time and if
+ * 12. The first SP checks if time lapsed is not lesser than sleep time and if
  *     successful, sends direct message response to the TFTF.
  *
- * 14. TFTF ensures the direct message response did not return with an error.
- *
- * 15. TFTF further disables the managed exit virtual interrupt for the first
- *     Cactus SP.
+ * 13. TFTF ensures the direct message response did not return with an error.
  *
  */
 test_result_t test_ffa_SPx_ME_SPy_signaled(void)
@@ -427,11 +390,6 @@
 
 	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
 
-	/* Enable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(RECEIVER, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	ret = program_timer(TIMER_DURATION);
 	if (ret < 0) {
 		ERROR("Failed to program timer (%d)\n", ret);
@@ -478,11 +436,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Disable Managed exit interrupt. */
-	if (!spm_set_managed_exit_int(RECEIVER, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return TEST_RESULT_SUCCESS;
 }
 
@@ -492,53 +445,47 @@
  * interrupt triggers while the second SP is processing a direct request message
  * sent by the first SP. We choose SP(2) as the first SP and SP(1) as the second SP.
  *
- * 1. Enable managed exit interrupt by sending interrupt_enable command to
- *    the second Cactus SP in the call chain.
- *
- * 2. Register a handler for the non-secure timer interrupt. Program it to fire
+ * 1. Register a handler for the non-secure timer interrupt. Program it to fire
  *    in a certain time.
  *
- * 3. Send a direct request to the first SP(i.e., SP(2)) to forward sleep command to
+ * 2. Send a direct request to the first SP(i.e., SP(2)) to forward sleep command to
  *    the second SP(i.e., SP(1)).
  *
- * 4. While the second SP is running the busy loop, non-secure interrupt would
+ * 3. While the second SP is running the busy loop, non-secure interrupt would
  *    trigger during this time.
  *
- * 5. The interrupt will be trapped to SPMC as FIQ. SPMC will inject the managed
+ * 4. The interrupt will be trapped to SPMC as FIQ. SPMC will inject the managed
  *    exit signal to the second SP through vFIQ conduit and perform eret to
  *    resume execution in the second SP.
  *
- * 6. The second SP sends the managed exit direct response to the first SP
+ * 5. The second SP sends the managed exit direct response to the first SP
  *    through its interrupt handler for managed exit. Note that SPMC does not
  *    change the state of the non-secure interrupt at the GIC interface. SPMC
  *    resumes the first SP but execution immediately traps to fiq handler of
  *    SPMC.
  *
- * 7. SPMC returns control to the normal world with the help of SPMD through
+ * 6. SPMC returns control to the normal world with the help of SPMD through
  *    FFA_INTERRUPT ABI for TFTF to handle the non-secure interrupt.
  *
- * 8. TFTF checks the direct message request to the first SP returned with a
+ * 7. TFTF checks the direct message request to the first SP returned with a
  *    FFA_INTERRUPT status.
  *
- * 9. Check whether the pending non-secure timer interrupt successfully got
+ * 8. Check whether the pending non-secure timer interrupt successfully got
  *    handled in the normal world by TFTF.
  *
- * 10. Resume the first Cactus SP using FFA_RUN ABI.
+ * 9. Resume the first Cactus SP using FFA_RUN ABI.
  *
- * 11. The first SP direct message request returns with managed exit response. It
+ * 10. The first SP direct message request returns with managed exit response. It
  *     then sends a dummy direct message request command to resume the second SP's
  *     execution.
  *
- * 12. The second SP resumes in the sleep routine and sends a direct message
+ * 11. The second SP resumes in the sleep routine and sends a direct message
  *     response to the first SP.
  *
- * 13. The first SP checks if time lapsed is not lesser than sleep time and if
+ * 12. The first SP checks if time lapsed is not lesser than sleep time and if
  *     successful, sends direct message response to the TFTF.
  *
- * 14. TFTF ensures the direct message response did not return with an error.
- *
- * 15. TFTF further disables the managed exit virtual interrupt for the second
- *     Cactus SP.
+ * 13. TFTF ensures the direct message response did not return with an error.
  *
  */
 test_result_t test_ffa_SPx_signaled_SPy_ME(void)
@@ -549,11 +496,6 @@
 
 	CHECK_SPMC_TESTING_SETUP(1, 1, expected_sp_uuids);
 
-	/* Enable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(RECEIVER, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	ret = program_timer(TIMER_DURATION);
 	if (ret < 0) {
 		ERROR("Failed to program timer (%d)\n", ret);
@@ -610,11 +552,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Disable Managed exit interrupt. */
-	if (!spm_set_managed_exit_int(RECEIVER, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return TEST_RESULT_SUCCESS;
 }
 
@@ -626,7 +563,7 @@
  * 1. Register a handler for the non-secure timer interrupt. Program it to fire
  *    in a certain time.
  *
- * 2. Send a direct request request to Cactus SP to execute in busy loop.
+ * 2. Send a direct request to Cactus SP to execute in busy loop.
  *
  * 3. While executing in busy loop, the non-secure timer should fire. Cactus SP
  *    should be NOT be preempted by non-secure interrupt.
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 e900ae3..f00c803 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
@@ -695,28 +695,6 @@
 }
 
 /**
- * Enable the Notification Pending Interrupt for the target SP.
- */
-static bool notification_pending_interrupt_sp_enable(ffa_id_t receiver,
-						     bool enable)
-{
-	VERBOSE("Configuring NPI to receiver: %x\n", receiver);
-	struct ffa_value ret = cactus_interrupt_cmd(
-		HYP_ID, receiver, NOTIFICATION_PENDING_INTERRUPT_INTID,
-		enable, INTERRUPT_TYPE_IRQ);
-
-
-	if (!is_ffa_direct_response(ret) ||
-	     cactus_get_response(ret) != CACTUS_SUCCESS) {
-		ERROR("Failed to configure NPI in SP %x core: %x\n",
-		      receiver, get_current_core_id());
-		return false;
-	}
-
-	return true;
-}
-
-/**
  * Disable the Schedule Receiver Interrupt and unregister the respective
  * handler.
  */
@@ -761,11 +739,6 @@
 
 	schedule_receiver_interrupt_init();
 
-	/* Enable NPI. */
-	if (!notification_pending_interrupt_sp_enable(receiver, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	if (!notification_bind_and_set(sender, receiver, notifications,
 				       FFA_NOTIFICATIONS_FLAG_DELAY_SRI)) {
 		return TEST_RESULT_FAIL;
@@ -798,11 +771,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Disable NPI. */
-	if (!notification_pending_interrupt_sp_enable(receiver, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	schedule_receiver_interrupt_deinit();
 
 	return TEST_RESULT_SUCCESS;
@@ -1040,11 +1008,6 @@
 		goto out;
 	}
 
-	if (!notification_pending_interrupt_sp_enable(per_vcpu_receiver,
-						      enable)) {
-		goto out;
-	}
-
 	result = TEST_RESULT_SUCCESS;
 
 out:
@@ -1111,11 +1074,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Enable NPI in lead core. */
-	if (!notification_pending_interrupt_sp_enable(receiver, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	/*
 	 * Prepare notifications bitmap to request Cactus to bind them as
 	 * per-vCPU.
@@ -1183,11 +1141,6 @@
 		return TEST_RESULT_FAIL;
 	}
 
-	/* Disable the NPI in the receiver. */
-	if (!notification_pending_interrupt_sp_enable(receiver, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return result;
 }
 
@@ -1351,11 +1304,6 @@
 	ids[0] = receiver;
 	lists_count = 1;
 
-	/* Enable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(sender, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	schedule_receiver_interrupt_init();
 
 	/* Request receiver to bind a set of notifications to the sender. */
@@ -1413,11 +1361,6 @@
 
 	schedule_receiver_interrupt_deinit();
 
-	/* Disable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(sender, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return result;
 }
 
@@ -1443,11 +1386,6 @@
 	ids[0] = receiver;
 	lists_count = 1;
 
-	/* Enable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(sender, true)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	schedule_receiver_interrupt_init();
 
 	/* Request receiver to bind a set of notifications to the sender. */
@@ -1529,11 +1467,6 @@
 
 	schedule_receiver_interrupt_deinit();
 
-	/* Disable managed exit interrupt as FIQ in the secure side. */
-	if (!spm_set_managed_exit_int(sender, false)) {
-		return TEST_RESULT_FAIL;
-	}
-
 	return result;
 }
 
@@ -1577,8 +1510,6 @@
 
 	schedule_receiver_interrupt_init();
 
-	notification_pending_interrupt_sp_enable(per_vcpu_receiver, true);
-
 	/* Prepare notifications bitmap to have one bit platform core. */
 	for (uint32_t i = 0; i < PLATFORM_CORE_COUNT; i++) {
 		to_bind |= FFA_NOTIFICATION(i);
@@ -1628,7 +1559,5 @@
 
 	schedule_receiver_interrupt_deinit();
 
-	notification_pending_interrupt_sp_enable(per_vcpu_receiver, false);
-
 	return TEST_RESULT_SUCCESS;
 }