Lock vCPU when accessing enabled_and_pending_count.
Change-Id: Ic71d89c3b7a8acec71ac593228219e4044e58664
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index 621b847..0658051 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -391,16 +391,22 @@
* Not switching vCPUs, set the bit for the current vCPU
* directly in the register.
*/
+ struct vcpu *vcpu = current();
+
+ sl_lock(&vcpu->lock);
set_virtual_interrupt_current(
- current()->interrupts.enabled_and_pending_count > 0);
+ vcpu->interrupts.enabled_and_pending_count > 0);
+ sl_unlock(&vcpu->lock);
} else {
/*
* About to switch vCPUs, set the bit for the vCPU to which we
* are switching in the saved copy of the register.
*/
+ sl_lock(&ret.new->lock);
set_virtual_interrupt(
&ret.new->regs,
ret.new->interrupts.enabled_and_pending_count > 0);
+ sl_unlock(&ret.new->lock);
}
return ret;