feat(interrupts): prioritize servicing queued virtual interrupts

Upon invocation of HF_INTERRUPT_GET by partition, SPMC shall return a
virtual interrupt from the vcpu's queue. If the queue is empty, it
shall return the numerically lowest pending interrupt from the
interrupt bitmap.

Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: Icee8a23349c7755e8620c5c97d0e8e81a5b9192a
diff --git a/src/api.c b/src/api.c
index fce8e17..67dd6bf 100644
--- a/src/api.c
+++ b/src/api.c
@@ -2357,18 +2357,16 @@
  * acknowledges it (i.e. marks it as no longer pending). Returns
  * HF_INVALID_INTID if there are no pending interrupts.
  */
-uint32_t api_interrupt_get(struct vcpu *current)
+uint32_t api_interrupt_get(struct vcpu_locked current_locked)
 {
 	uint32_t i;
 	uint32_t first_interrupt = HF_INVALID_INTID;
-	struct vcpu_locked current_locked;
-	struct interrupts *interrupts = &current->interrupts;
+	struct interrupts *interrupts = &current_locked.vcpu->interrupts;
 
 	/*
 	 * Find the first enabled and pending interrupt ID, return it, and
 	 * deactivate it.
 	 */
-	current_locked = vcpu_lock(current);
 	for (i = 0; i < HF_NUM_INTIDS / INTERRUPT_REGISTER_BITS; ++i) {
 		uint32_t enabled_and_pending =
 			interrupts->interrupt_enabled.bitmap[i] &
@@ -2389,7 +2387,6 @@
 		}
 	}
 
-	vcpu_unlock(&current_locked);
 	return first_interrupt;
 }