aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-03-22 13:02:54 +0000
committerMark Johnston <markj@FreeBSD.org>2023-03-27 12:50:12 +0000
commit3b6598f8742cdab079cbce5485e9ddffbacdc1b4 (patch)
tree3ceae06c62bb1751fb168ca884827226181dce6e
parente6b1b944b5aa1950834f27a8ab9188bcd736844d (diff)
downloadsrc-3b6598f8742cdab079cbce5485e9ddffbacdc1b4.tar.gz
src-3b6598f8742cdab079cbce5485e9ddffbacdc1b4.zip
bhyve: Sleep briefly in the VMEXIT_DEBUG handler
As of commit 0bda8d3e9f7a ("vmm: permit some IPIs to be handled by userspace") and commit 9cc9abf409cc ("bhyve: create all vcpus on startup"), we have a misbehaviour where AP vCPU threads spin until they receive a SIPI. In particular, since they are "suspended", they simply call the VMEXIT_DEBUG handler in a loop, but the handler is a no-op by default. This is tricky to fix since the gdb stub isn't aware of whether a given vCPU is supposed to be running. For 13.2's sake, introduce a simple workaround wherein the VMEXIT_DEBUG handler sleeps for a short period. This ensures that host CPU usage remains sane when VMs are starting without penalizing users of VMEXIT_DEBUG too much. Reviewed by: corvink, jhb MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39174 (cherry picked from commit ef0ac973dbc8c54214ac8c61891abd832cd5b700)
-rw-r--r--usr.sbin/bhyve/bhyverun.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 1becf998b976..5c8265571be9 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -911,6 +911,11 @@ vmexit_debug(struct vmctx *ctx __unused, struct vm_exit *vme __unused,
#ifdef BHYVE_SNAPSHOT
checkpoint_cpu_resume(*pvcpu);
#endif
+ /*
+ * XXX-MJ sleep for a short period to avoid chewing up the CPU in the
+ * window between activation of the vCPU thread and the STARTUP IPI.
+ */
+ usleep(1000);
return (VMEXIT_CONTINUE);
}