fix(ipi): small fixes to the ipi implementation

- Fix the return type for the api_hf_interrupt_send_ipi function. In
the case the target vcpu id is not valid it returns -1 so the type
must be signed.
- Fix the cast in the hf_call in hf_interrupt_send_ipi, the arguments
for this function are uint64_t so cast to this.
- Move hf_ipi_init_interrupt to arch_cpu_init as this is a more
appropriate place for it.
- Lock the cpu when setting and getting the target vCPU with
pending IPI.
- Set the IPI and SRI interrupts to enabled during initialization.

Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I81ca43f767a7bfeb803f65b40f8be403daecfa80
diff --git a/src/hf_ipi.c b/src/hf_ipi.c
index f227ece..3702b49 100644
--- a/src/hf_ipi.c
+++ b/src/hf_ipi.c
@@ -28,6 +28,7 @@
 		.sec_state = INT_DESC_SEC_STATE_S,
 		.priority = IPI_PRIORITY,
 		.valid = true,
+		.enabled = true,
 	};
 
 	plat_interrupts_configure_interrupt(ipi_desc);
@@ -39,9 +40,16 @@
  */
 struct vcpu *hf_ipi_get_pending_target_vcpu(struct cpu *current)
 {
-	struct vcpu *ret = current->ipi_target_vcpu;
+	struct vcpu *ret;
+
+	sl_lock(&current->lock);
+
+	ret = current->ipi_target_vcpu;
 
 	current->ipi_target_vcpu = NULL;
+
+	sl_unlock(&current->lock);
+
 	return ret;
 }
 
@@ -53,7 +61,11 @@
 	struct vcpu *target_vcpu = vm_get_vcpu(vm, target_vcpu_index);
 	struct cpu *target_cpu = target_vcpu->cpu;
 
+	sl_lock(&target_cpu->lock);
+
 	target_cpu->ipi_target_vcpu = target_vcpu;
+
+	sl_unlock(&target_cpu->lock);
 	plat_interrupts_send_sgi(HF_IPI_INTID, target_cpu, true);
 }