refactor: create vcpu_secure_interrupt_complete
Created the function vcpu_secure_interrupt_complete as a direct
replacement to plat_ffa_reset_secure_interrupt_flags.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I416c81c516dc8f3f6ea1b73de21424e4b7dc4d09
diff --git a/inc/hf/vcpu.h b/inc/hf/vcpu.h
index 6041557..92bb929 100644
--- a/inc/hf/vcpu.h
+++ b/inc/hf/vcpu.h
@@ -401,6 +401,7 @@
uint8_t priority);
void vcpu_interrupt_inject(struct vcpu_locked target_locked, uint32_t intid);
void vcpu_enter_secure_interrupt_rtm(struct vcpu_locked vcpu_locked);
+
bool vcpu_interrupt_queue_push(struct vcpu_locked vcpu_locked,
uint32_t vint_id);
bool vcpu_interrupt_queue_pop(struct vcpu_locked vcpu_locked,
@@ -410,3 +411,5 @@
bool vcpu_is_interrupt_in_queue(struct vcpu_locked vcpu_locked,
uint32_t vint_id);
bool vcpu_is_interrupt_queue_empty(struct vcpu_locked vcpu_locked);
+
+void vcpu_secure_interrupt_complete(struct vcpu_locked vcpu_locked);
diff --git a/src/arch/aarch64/plat/ffa/spmc.c b/src/arch/aarch64/plat/ffa/spmc.c
index 7537ba7..2074eee 100644
--- a/src/arch/aarch64/plat/ffa/spmc.c
+++ b/src/arch/aarch64/plat/ffa/spmc.c
@@ -1116,19 +1116,6 @@
}
/**
- * Indicate that secure interrupt processing is complete and clear corresponding
- * fields.
- */
-static void plat_ffa_reset_secure_interrupt_flags(
- struct vcpu_locked current_locked)
-{
- struct vcpu *current;
-
- current = current_locked.vcpu;
- current->preempted_vcpu = NULL;
-}
-
-/**
* Check if current VM can resume target VM using FFA_RUN ABI.
*/
bool plat_ffa_run_checks(struct vcpu_locked current_locked,
@@ -1247,7 +1234,7 @@
* Clear fields corresponding to secure interrupt
* handling.
*/
- plat_ffa_reset_secure_interrupt_flags(current_locked);
+ vcpu_secure_interrupt_complete(current_locked);
}
}
@@ -1355,11 +1342,7 @@
/* Restore interrupt priority mask. */
plat_interrupts_set_priority_mask(current->priority_mask);
- /*
- * Clear fields corresponding to secure interrupt
- * handling.
- */
- current->implicit_completion_signal = false;
+ vcpu_secure_interrupt_complete(current_locked);
}
/*
@@ -1803,7 +1786,7 @@
plat_interrupts_end_of_interrupt(intid);
/* Clear fields corresponding to secure interrupt handling. */
- plat_ffa_reset_secure_interrupt_flags(target_vcpu_locked);
+ vcpu_secure_interrupt_complete(target_vcpu_locked);
plat_ffa_disable_vm_interrupts(target_vm_locked);
/* Resume current vCPU. */
@@ -1871,7 +1854,7 @@
struct vcpu *current = current_locked.vcpu;
/* Reset the fields tracking secure interrupt processing. */
- plat_ffa_reset_secure_interrupt_flags(current_locked);
+ vcpu_secure_interrupt_complete(current_locked);
/* SPMC scheduled call chain is completely unwound. */
plat_ffa_exit_spmc_schedule_mode(current_locked);
@@ -1920,7 +1903,7 @@
target_locked = vcpus_locked.vcpu2;
/* Reset the fields tracking secure interrupt processing. */
- plat_ffa_reset_secure_interrupt_flags(current_locked);
+ vcpu_secure_interrupt_complete(current_locked);
/* SPMC scheduled call chain is completely unwound. */
plat_ffa_exit_spmc_schedule_mode(current_locked);
@@ -2292,7 +2275,7 @@
struct two_vcpu_locked vcpus_locked;
/* Reset the fields tracking secure interrupt processing. */
- plat_ffa_reset_secure_interrupt_flags(current_locked);
+ vcpu_secure_interrupt_complete(current_locked);
/* SPMC scheduled call chain is completely unwound. */
plat_ffa_exit_spmc_schedule_mode(current_locked);
diff --git a/src/vcpu.c b/src/vcpu.c
index 5336052..b5f0d2f 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -506,3 +506,16 @@
return false;
}
+
+/**
+ * When interrupt handling is complete the preempted_vcpu field should go back
+ * to NULL.
+ */
+void vcpu_secure_interrupt_complete(struct vcpu_locked vcpu_locked)
+{
+ struct vcpu *vcpu;
+
+ vcpu = vcpu_locked.vcpu;
+ vcpu->preempted_vcpu = NULL;
+ vcpu->implicit_completion_signal = false;
+}