refactor: set vcpu in preempted state
The function `vcpu_set_processing_interrupt` is refactored
to set the preempted vcpu state as `VCPU_STATE_PREEMPTED`.
This refactor opens the possibility to drop other instances
in which the `VCPU_STATE_PREEMPTED` is used.
This is completed in the subsequent patches.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I02f5d92e15aa850b73ededea37fd7fbe5ba41a52
diff --git a/src/vcpu.c b/src/vcpu.c
index 68be2e9..ca0728f 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -317,11 +317,16 @@
}
void vcpu_set_processing_interrupt(struct vcpu_locked vcpu_locked,
- uint32_t intid, struct vcpu *preempted)
+ uint32_t intid,
+ struct vcpu_locked preempted_locked)
{
struct vcpu *target_vcpu = vcpu_locked.vcpu;
- target_vcpu->preempted_vcpu = preempted;
+ if (preempted_locked.vcpu != NULL) {
+ target_vcpu->preempted_vcpu = preempted_locked.vcpu;
+ preempted_locked.vcpu->state = VCPU_STATE_PREEMPTED;
+ }
+
target_vcpu->processing_secure_interrupt = true;
target_vcpu->current_sec_interrupt_id = intid;
}