fix(interrupts): save and restore priority mask

To simplify secure interrupt handling, the threshold for interrupts
was changed by modifying the priority mask without saving the current
value of priority mask. This led to overriding of original priority
mask. This patch performs save and restore of priority mask at
appropriate times.

Please note the current design makes the assumption that the target vCPU
of a secure interrupt is pinned to the same physical CPU on which the
secure interrupt triggered. The target vCPU has to be resumed on the current
CPU in order for it to service the virtual interrupt. This design limitation
simplifies the interrupt management implementation in SPMC.

Change-Id: I8571cb81595080a0555346e075591234a78e510d
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
diff --git a/src/api.c b/src/api.c
index d735b9e..ee99eee 100644
--- a/src/api.c
+++ b/src/api.c
@@ -2264,7 +2264,7 @@
 		 */
 		CHECK(!current->processing_secure_interrupt);
 
-		plat_interrupts_set_priority_mask(0xff);
+		plat_interrupts_set_priority_mask(current->priority_mask);
 		current->processing_managed_exit = false;
 	} else {
 		/*
@@ -2297,8 +2297,9 @@
 			/* There is no preempted vCPU to resume. */
 			CHECK(current->preempted_vcpu == NULL);
 
-			/* Unmask interrupts. */
-			plat_interrupts_set_priority_mask(0xff);
+			/* Restore interrupt priority mask. */
+			plat_interrupts_set_priority_mask(
+				current->priority_mask);
 
 			/*
 			 * Clear fields corresponding to secure interrupt