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/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index fca3d0f..6fe3179 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -1083,10 +1083,13 @@
 	int64_t ret;
 
 	if (plat_ffa_vm_managed_exit_supported(current_vcpu->vm)) {
+		uint8_t pmr = plat_interrupts_get_priority_mask();
+
 		/* Mask all interrupts */
 		plat_interrupts_set_priority_mask(0x0);
 
 		current_locked = vcpu_lock(current_vcpu);
+		current_vcpu->priority_mask = pmr;
 		ret = api_interrupt_inject_locked(current_locked,
 						  HF_MANAGED_EXIT_INTID,
 						  current_vcpu, NULL);