summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vmd.h
diff options
context:
space:
mode:
authorpd <pd@cvs.openbsd.org>2020-06-28 16:52:46 +0000
committerpd <pd@cvs.openbsd.org>2020-06-28 16:52:46 +0000
commit25e11d3465eacea854fb5a6a748931d53ccd10dd (patch)
treeadd2f22f6a45c6105595b2cc40478eccbef1bc5e /usr.sbin/vmd/vmd.h
parentf82eff1fc0c703b464502c887036a4207aa13621 (diff)
vmd(8): Eliminate libevent state corruption
libevent functions for com, pic and rtc are now only called on event_thread. vcpu exit handlers send messages on a dev pipe and callbacks on these events do the event management (event_add, evtimer_add, etc). Previously, libevent state was mutated by two threads, event_thread, that runs all the callbacks and the vcpu thread when running exit handlers. This could have lead to libevent state corruption. Patch from Dave Voutila <dave@sisu.io> ok claudio@ tested by abieber@ and brynet@
Diffstat (limited to 'usr.sbin/vmd/vmd.h')
-rw-r--r--usr.sbin/vmd/vmd.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h
index d7efb329e53..8c77025f6dc 100644
--- a/usr.sbin/vmd/vmd.h
+++ b/usr.sbin/vmd/vmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.h,v 1.98 2019/12/12 03:53:38 pd Exp $ */
+/* $OpenBSD: vmd.h,v 1.99 2020/06/28 16:52:45 pd Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -354,6 +354,21 @@ struct vmd {
int vmd_ptmfd;
};
+struct vm_dev_pipe {
+ int read;
+ int write;
+ struct event read_ev;
+};
+
+enum pipe_msg_type {
+ I8253_RESET_CHAN_0 = 0,
+ I8253_RESET_CHAN_1 = 1,
+ I8253_RESET_CHAN_2 = 2,
+ NS8250_ZERO_READ,
+ NS8250_RATELIMIT,
+ MC146818_RESCHEDULE_PER
+};
+
static inline struct sockaddr_in *
ss2sin(struct sockaddr_storage *ss)
{
@@ -442,6 +457,9 @@ int vmm_pipe(struct vmd_vm *, int, void (*)(int, short, void *));
/* vm.c */
int start_vm(struct vmd_vm *, int);
__dead void vm_shutdown(unsigned int);
+void vm_pipe_init(struct vm_dev_pipe *, void (*)(int, short, void *));
+void vm_pipe_send(struct vm_dev_pipe *, enum pipe_msg_type);
+enum pipe_msg_type vm_pipe_recv(struct vm_dev_pipe *);
/* control.c */
int config_init(struct vmd *);