summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2016-03-09 07:41:26 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2016-03-09 07:41:26 +0000
commitb49f26e5e2d126c1e74ce57816297bbc2b2baa65 (patch)
treeff6f0cf8a1f404ff91b189e940c3084cef3a829d
parentcb3c5b79be491c15ac84f236cfb0ce17de21f912 (diff)
Induce an exit in a running vcpu if an interrupt is asserted (pending).
Needed for ongoing interrupt controller work.
-rw-r--r--sys/arch/amd64/amd64/vmm.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index 4637e2e4f12..1593aa8b06e 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.43 2016/03/08 08:43:50 mlarkin Exp $ */
+/* $OpenBSD: vmm.c,v 1.44 2016/03/09 07:41:25 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -594,6 +594,25 @@ vm_intr_pending(struct vm_intr_params *vip)
vcpu->vc_intr = vip->vip_intr;
+#ifdef MULTIPROCESSOR
+ /*
+ * If the vcpu is running on another PCPU, attempt to force it
+ * to exit to process the pending interrupt. This could race as
+ * it could be running when we do the check but be stopped by the
+ * time we send the IPI. In this case, there is a small extra
+ * overhead to process the IPI but no other side effects.
+ *
+ * There is also a chance that the vcpu may have interrupts blocked.
+ * That's ok as that condition will be checked on exit, and we will
+ * simply re-enter the guest. This "fast notification" is done only
+ * as an optimization.
+ */
+ if (vcpu->vc_state == VCPU_STATE_RUNNING) {
+ x86_send_ipi(vcpu->vc_last_pcpu, X86_IPI_NOP);
+ }
+#endif /* MULTIPROCESSOR */
+
+
return (0);
}