Kick process if we try to wake up a vCPU which is already running.
This is necessary for interrupt injection to work to a vCPU which is
running on a different physical CPU.
Bug: 117270899
Change-Id: Icfd1105d3d3b2105300f8b8620a2c0fceac655bc
diff --git a/main.c b/main.c
index a1f1e38..26c5cab 100644
--- a/main.c
+++ b/main.c
@@ -136,7 +136,14 @@
break;
vm = &hf_vms[ret.wake_up.vm_id - 1];
if (ret.wake_up.vcpu < vm->vcpu_count) {
- hf_vcpu_wake_up(&vm->vcpu[ret.wake_up.vcpu]);
+ if (hf_vcpu_wake_up(&vm->vcpu[ret.wake_up.vcpu]) == 0) {
+ /*
+ * The task was already running (presumably on a
+ * different physical CPU); interrupt it. This gives
+ * Hafnium a chance to inject any new interrupts.
+ */
+ kick_process(vm->vcpu[ret.wake_up.vcpu].task);
+ }
} else if (ret.wake_up.vcpu == HF_INVALID_VCPU) {
/* TODO: pick one to interrupt. */
pr_warning("No vcpu to wake.");