summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gerdts <mike.gerdts@joyent.com>2018-06-05 04:41:09 +0000
committerTrent Mick <trentm@gmail.com>2018-06-05 04:41:09 +0000
commitc53ef6540a6c3114ed6823c7d18030f2739d7dea (patch)
tree68b9b631c032fbc8ff5dfcb5cb8c3c8b8e010f7a
parent2e89f711f976473351ffb54856bc5738de8778aa (diff)
downloadillumos-joyent-cr4139-OS-6997.tar.gz
OS-6997 bhyve should error check mutexescr4139-OS-6997
-rw-r--r--usr/src/cmd/bhyve/Makefile3
-rw-r--r--usr/src/cmd/bhyve/atkbdc.c5
-rw-r--r--usr/src/cmd/bhyve/bhyverun.c7
-rw-r--r--usr/src/cmd/bhyve/block_if.c3
-rw-r--r--usr/src/cmd/bhyve/gdb.c5
-rw-r--r--usr/src/cmd/bhyve/mevent.c10
-rw-r--r--usr/src/cmd/bhyve/mevent_test.c8
-rw-r--r--usr/src/cmd/bhyve/pci_ahci.c5
-rw-r--r--usr/src/cmd/bhyve/pci_e82545.c5
-rw-r--r--usr/src/cmd/bhyve/pci_emul.c4
-rw-r--r--usr/src/cmd/bhyve/pci_irq.c5
-rw-r--r--usr/src/cmd/bhyve/pci_virtio_block.c6
-rw-r--r--usr/src/cmd/bhyve/pci_virtio_net.c3
-rw-r--r--usr/src/cmd/bhyve/pci_virtio_viona.c4
-rw-r--r--usr/src/cmd/bhyve/pci_xhci.c4
-rw-r--r--usr/src/cmd/bhyve/pm.c7
-rw-r--r--usr/src/cmd/bhyve/ps2kbd.c5
-rw-r--r--usr/src/cmd/bhyve/ps2mouse.c5
-rw-r--r--usr/src/cmd/bhyve/rfb.c1
-rw-r--r--usr/src/cmd/bhyve/sol_lock.c53
-rw-r--r--usr/src/cmd/bhyve/sol_lock.h37
-rw-r--r--usr/src/cmd/bhyve/test/tst/mevent/Makefile2
-rw-r--r--usr/src/cmd/bhyve/uart_emul.c1
-rw-r--r--usr/src/cmd/bhyve/usb_emul.h1
-rw-r--r--usr/src/cmd/bhyve/usb_mouse.c5
-rw-r--r--usr/src/cmd/bhyve/virtio.c5
26 files changed, 191 insertions, 8 deletions
diff --git a/usr/src/cmd/bhyve/Makefile b/usr/src/cmd/bhyve/Makefile
index 554603d4f8..afbad68c20 100644
--- a/usr/src/cmd/bhyve/Makefile
+++ b/usr/src/cmd/bhyve/Makefile
@@ -66,6 +66,7 @@ SRCS = acpi.c \
rfb.c \
rtc.c \
smbiostbl.c \
+ sol_lock.c \
sockstream.c \
task_switch.c \
uart_emul.c \
@@ -87,7 +88,7 @@ ZHYVE_PROG = zhyve
ZHYVE = $(ZHYVE_DIR)/$(ZHYVE_PROG)
MEVENT_TEST_PROG = mevent_test
-MEVENT_TEST_SRCS = mevent.c mevent_test.c
+MEVENT_TEST_SRCS = mevent.c mevent_test.c sol_lock.c
MEVENT_TEST_OBJS = $(MEVENT_TEST_SRCS:.c=.o)
CLEANFILES = $(PROG) $(ZHYVE_PROG) $(MEVENT_TEST_PROG) $(MEVENT_TEST_OBJS)
diff --git a/usr/src/cmd/bhyve/atkbdc.c b/usr/src/cmd/bhyve/atkbdc.c
index 8e71b0507c..f4a12d8a7c 100644
--- a/usr/src/cmd/bhyve/atkbdc.c
+++ b/usr/src/cmd/bhyve/atkbdc.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2014 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Nahanni Systems Inc.
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,6 +45,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "acpi.h"
#include "inout.h"
#include "pci_emul.h"
diff --git a/usr/src/cmd/bhyve/bhyverun.c b/usr/src/cmd/bhyve/bhyverun.c
index b12fba0800..173a1970a2 100644
--- a/usr/src/cmd/bhyve/bhyverun.c
+++ b/usr/src/cmd/bhyve/bhyverun.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
#ifndef __FreeBSD__
#include <sys/stat.h>
+#include "sol_lock.h"
#endif
#include "bhyverun.h"
@@ -134,7 +135,7 @@ static const int BSP = 0;
#ifndef __FreeBSD__
int bcons_wait = 0;
int bcons_connected = 0;
-pthread_mutex_t bcons_wait_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t bcons_wait_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
pthread_cond_t bcons_wait_done = PTHREAD_COND_INITIALIZER;
#endif
@@ -713,7 +714,11 @@ vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
return (VMEXIT_CONTINUE);
}
+#ifdef __FreeBSD__
static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER;
+#else
+static pthread_mutex_t resetcpu_mtx = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+#endif
static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER;
static int
diff --git a/usr/src/cmd/bhyve/block_if.c b/usr/src/cmd/bhyve/block_if.c
index 86978bbda2..8777b42609 100644
--- a/usr/src/cmd/bhyve/block_if.c
+++ b/usr/src/cmd/bhyve/block_if.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2013 Peter Grehan <grehan@freebsd.org>
+ * Copyritht 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,6 +61,8 @@ __FBSDID("$FreeBSD$");
#include "bhyverun.h"
#ifdef __FreeBSD__
#include "mevent.h"
+#else
+#include "sol_lock.h"
#endif
#include "block_if.h"
diff --git a/usr/src/cmd/bhyve/gdb.c b/usr/src/cmd/bhyve/gdb.c
index 4414a05e27..28a411f7f6 100644
--- a/usr/src/cmd/bhyve/gdb.c
+++ b/usr/src/cmd/bhyve/gdb.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2017-2018 John H. Baldwin <jhb@FreeBSD.org>
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,6 +58,10 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <vmmapi.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "bhyverun.h"
#include "mem.h"
#include "mevent.h"
diff --git a/usr/src/cmd/bhyve/mevent.c b/usr/src/cmd/bhyve/mevent.c
index edd5cf14cb..85156df75b 100644
--- a/usr/src/cmd/bhyve/mevent.c
+++ b/usr/src/cmd/bhyve/mevent.c
@@ -66,6 +66,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "mevent.h"
#define MEVENT_MAX 64
@@ -80,7 +84,11 @@ extern char *vmname;
static pthread_t mevent_tid;
static int mevent_timid = 43;
static int mevent_pipefd[2];
+#ifdef __FreeBSD__
static pthread_mutex_t mevent_lmutex = PTHREAD_MUTEX_INITIALIZER;
+#else
+static pthread_mutex_t mevent_lmutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+#endif
struct mevent {
void (*me_func)(int, enum ev_type, void *);
@@ -403,8 +411,6 @@ mevent_handle_pe(port_event_t *pe)
{
struct mevent *mevp = pe->portev_user;
- mevent_qunlock();
-
(*mevp->me_func)(mevp->me_fd, mevp->me_type, mevp->me_param);
mevent_qlock();
diff --git a/usr/src/cmd/bhyve/mevent_test.c b/usr/src/cmd/bhyve/mevent_test.c
index 22e3561fed..24c34f896c 100644
--- a/usr/src/cmd/bhyve/mevent_test.c
+++ b/usr/src/cmd/bhyve/mevent_test.c
@@ -55,11 +55,19 @@
#include <pthread.h>
#include <unistd.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "mevent.h"
#define TEST_PORT 4321
+#ifdef __FreeBSD__
static pthread_mutex_t accept_mutex = PTHREAD_MUTEX_INITIALIZER;
+#else
+static pthread_mutex_t accept_mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+#endif
static pthread_cond_t accept_condvar = PTHREAD_COND_INITIALIZER;
static struct mevent *tevp;
diff --git a/usr/src/cmd/bhyve/pci_ahci.c b/usr/src/cmd/bhyve/pci_ahci.c
index 909d5c19af..2b9016b05f 100644
--- a/usr/src/cmd/bhyve/pci_ahci.c
+++ b/usr/src/cmd/bhyve/pci_ahci.c
@@ -3,6 +3,7 @@
*
* Copyright (c) 2013 Zhixiang Yu <zcore@freebsd.org>
* Copyright (c) 2015-2016 Alexander Motin <mav@FreeBSD.org>
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,6 +56,10 @@ __FBSDID("$FreeBSD$");
#include <inttypes.h>
#include <md5.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "bhyverun.h"
#include "pci_emul.h"
#include "ahci.h"
diff --git a/usr/src/cmd/bhyve/pci_e82545.c b/usr/src/cmd/bhyve/pci_e82545.c
index 121c0fc773..8ca80e6b85 100644
--- a/usr/src/cmd/bhyve/pci_e82545.c
+++ b/usr/src/cmd/bhyve/pci_e82545.c
@@ -2,6 +2,7 @@
* Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
* Copyright (c) 2015 Peter Grehan <grehan@freebsd.org>
* Copyright (c) 2013 Jeremiah Lott, Avere Systems
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,6 +57,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "e1000_regs.h"
#include "e1000_defines.h"
#include "mii.h"
diff --git a/usr/src/cmd/bhyve/pci_emul.c b/usr/src/cmd/bhyve/pci_emul.c
index a35a830f7e..38ee31e2da 100644
--- a/usr/src/cmd/bhyve/pci_emul.c
+++ b/usr/src/cmd/bhyve/pci_emul.c
@@ -60,6 +60,10 @@ __FBSDID("$FreeBSD$");
#include <machine/vmm.h>
#include <vmmapi.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "acpi.h"
#include "bhyverun.h"
#include "inout.h"
diff --git a/usr/src/cmd/bhyve/pci_irq.c b/usr/src/cmd/bhyve/pci_irq.c
index 4ae9ff3582..94d89196f5 100644
--- a/usr/src/cmd/bhyve/pci_irq.c
+++ b/usr/src/cmd/bhyve/pci_irq.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2014 Hudson River Trading LLC
* Written by: John H. Baldwin <jhb@FreeBSD.org>
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,6 +40,10 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <vmmapi.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "acpi.h"
#include "inout.h"
#include "pci_emul.h"
diff --git a/usr/src/cmd/bhyve/pci_virtio_block.c b/usr/src/cmd/bhyve/pci_virtio_block.c
index 0c72c1f503..b22506e27b 100644
--- a/usr/src/cmd/bhyve/pci_virtio_block.c
+++ b/usr/src/cmd/bhyve/pci_virtio_block.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2011 NetApp, Inc.
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,7 +39,6 @@
* http://www.illumos.org/license/CDDL.
*
* Copyright 2014 Pluribus Networks Inc.
- * Copyright 2017 Joyent, Inc.
*/
#include <sys/cdefs.h>
@@ -63,6 +63,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <md5.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "bhyverun.h"
#include "pci_emul.h"
#include "virtio.h"
diff --git a/usr/src/cmd/bhyve/pci_virtio_net.c b/usr/src/cmd/bhyve/pci_virtio_net.c
index 7a1c1f580a..30afae460c 100644
--- a/usr/src/cmd/bhyve/pci_virtio_net.c
+++ b/usr/src/cmd/bhyve/pci_virtio_net.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2011 NetApp, Inc.
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,7 +39,6 @@
* http://www.illumos.org/license/CDDL.
*
* Copyright 2013 Pluribus Networks Inc.
- * Copyright 2017 Joyent, Inc.
*/
#include <sys/cdefs.h>
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
#ifndef __FreeBSD__
#include <poll.h>
#include <libdlpi.h>
+#include "sol_lock.h"
#endif
#include "bhyverun.h"
diff --git a/usr/src/cmd/bhyve/pci_virtio_viona.c b/usr/src/cmd/bhyve/pci_virtio_viona.c
index a671617258..acf44aa3db 100644
--- a/usr/src/cmd/bhyve/pci_virtio_viona.c
+++ b/usr/src/cmd/bhyve/pci_virtio_viona.c
@@ -63,6 +63,10 @@
#include <machine/vmm.h>
#include <vmmapi.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "bhyverun.h"
#include "pci_emul.h"
#include "virtio.h"
diff --git a/usr/src/cmd/bhyve/pci_xhci.c b/usr/src/cmd/bhyve/pci_xhci.c
index 1cb2246486..2435e0f859 100644
--- a/usr/src/cmd/bhyve/pci_xhci.c
+++ b/usr/src/cmd/bhyve/pci_xhci.c
@@ -52,6 +52,10 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_freebsd.h>
#include <xhcireg.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "bhyverun.h"
#include "pci_emul.h"
#include "pci_xhci.h"
diff --git a/usr/src/cmd/bhyve/pm.c b/usr/src/cmd/bhyve/pm.c
index be188b79f2..3a480f34c4 100644
--- a/usr/src/cmd/bhyve/pm.c
+++ b/usr/src/cmd/bhyve/pm.c
@@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
#include <vmmapi.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "acpi.h"
#include "inout.h"
#ifdef __FreeBSD__
@@ -53,11 +57,12 @@ __FBSDID("$FreeBSD$");
#include "pci_irq.h"
#include "pci_lpc.h"
-static pthread_mutex_t pm_lock = PTHREAD_MUTEX_INITIALIZER;
#ifdef __FreeBSD__
+static pthread_mutex_t pm_lock = PTHREAD_MUTEX_INITIALIZER;
static struct mevent *power_button;
static sig_t old_power_handler;
#else
+static pthread_mutex_t pm_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
struct vmctx *pwr_ctx;
#endif
diff --git a/usr/src/cmd/bhyve/ps2kbd.c b/usr/src/cmd/bhyve/ps2kbd.c
index ec3bb9814c..faaaf8a897 100644
--- a/usr/src/cmd/bhyve/ps2kbd.c
+++ b/usr/src/cmd/bhyve/ps2kbd.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Nahanni Systems Inc.
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +39,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "atkbdc.h"
#include "console.h"
diff --git a/usr/src/cmd/bhyve/ps2mouse.c b/usr/src/cmd/bhyve/ps2mouse.c
index cea7210e2a..47488779ec 100644
--- a/usr/src/cmd/bhyve/ps2mouse.c
+++ b/usr/src/cmd/bhyve/ps2mouse.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2015 Tycho Nightingale <tycho.nightingale@pluribusnetworks.com>
* Copyright (c) 2015 Nahanni Systems Inc.
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +39,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "atkbdc.h"
#include "console.h"
diff --git a/usr/src/cmd/bhyve/rfb.c b/usr/src/cmd/bhyve/rfb.c
index d96b45c5da..85a9d0d3a8 100644
--- a/usr/src/cmd/bhyve/rfb.c
+++ b/usr/src/cmd/bhyve/rfb.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#ifndef __FreeBSD__
#include <sys/debug.h>
+#include "sol_lock.h"
#endif
#include "bhyvegc.h"
diff --git a/usr/src/cmd/bhyve/sol_lock.c b/usr/src/cmd/bhyve/sol_lock.c
new file mode 100644
index 0000000000..839412c4b9
--- /dev/null
+++ b/usr/src/cmd/bhyve/sol_lock.c
@@ -0,0 +1,53 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Joyent, Inc.
+ */
+
+#define _SOL_LOCK_C
+#include "sol_lock.h"
+
+int
+_check_mutex_init(pthread_mutex_t *mtx, pthread_mutexattr_t *nattr)
+{
+ pthread_mutexattr_t attr;
+
+ ASSERT3S((nattr), ==, NULL);
+ VERIFY3S(pthread_mutexattr_init(&attr), ==, 0);
+ VERIFY3S(pthread_mutexattr_settype(&attr,
+ PTHREAD_MUTEX_ERRORCHECK), ==, 0);
+ VERIFY3S(pthread_mutex_init((mtx), &attr), ==, 0);
+ VERIFY3S(pthread_mutexattr_destroy(&attr), ==, 0);
+
+ return (0);
+}
+
+int
+_check_mutex_destroy(pthread_mutex_t *mtx)
+{
+ VERIFY3S(pthread_mutex_destroy(mtx), ==, 0);
+ return (0);
+}
+
+int
+_check_mutex_lock(pthread_mutex_t *mtx)
+{
+ VERIFY3S(pthread_mutex_lock(mtx), ==, 0);
+ return (0);
+}
+
+int
+_check_mutex_unlock(pthread_mutex_t *mtx)
+{
+ VERIFY3S(pthread_mutex_unlock(mtx), ==, 0);
+ return (0);
+}
diff --git a/usr/src/cmd/bhyve/sol_lock.h b/usr/src/cmd/bhyve/sol_lock.h
new file mode 100644
index 0000000000..f88b059f84
--- /dev/null
+++ b/usr/src/cmd/bhyve/sol_lock.h
@@ -0,0 +1,37 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Joyent, Inc.
+ */
+
+#ifndef SOL_LOCK_H
+#define SOL_LOCK_H
+
+#include <pthread.h>
+#include <sys/debug.h>
+
+extern int _check_mutex_init(pthread_mutex_t *, pthread_mutexattr_t *);
+extern int _check_mutex_destroy(pthread_mutex_t *);
+extern int _check_mutex_lock(pthread_mutex_t *);
+extern int _check_mutex_unlock(pthread_mutex_t *);
+
+#ifndef _SOL_LOCK_C
+#define pthread_mutex_init(mtx, a) _check_mutex_init((mtx), (a))
+#define pthread_mutex_destroy(mtx) _check_mutex_destroy(mtx)
+#define pthread_mutex_lock(mtx) _check_mutex_lock(mtx)
+#define pthread_mutex_unlock(mtx) _check_mutex_unlock(mtx)
+#endif
+
+#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
+ {{0, 0, 0, PTHREAD_MUTEX_ERRORCHECK, _MUTEX_MAGIC}, {{{0}}}, 0}
+
+#endif
diff --git a/usr/src/cmd/bhyve/test/tst/mevent/Makefile b/usr/src/cmd/bhyve/test/tst/mevent/Makefile
index 047886bc6a..b76c28bca3 100644
--- a/usr/src/cmd/bhyve/test/tst/mevent/Makefile
+++ b/usr/src/cmd/bhyve/test/tst/mevent/Makefile
@@ -21,7 +21,7 @@ EXETESTS = \
read.requeue.exe \
SHTESTS =
-SUPOBJS = mevent.o testlib.o
+SUPOBJS = mevent.o testlib.o ../../../sol_lock.o
include ../../Makefile.com
diff --git a/usr/src/cmd/bhyve/uart_emul.c b/usr/src/cmd/bhyve/uart_emul.c
index 5a47e2e9ef..83f0f25676 100644
--- a/usr/src/cmd/bhyve/uart_emul.c
+++ b/usr/src/cmd/bhyve/uart_emul.c
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
+#include "sol_lock.h"
#endif
#include "mevent.h"
diff --git a/usr/src/cmd/bhyve/usb_emul.h b/usr/src/cmd/bhyve/usb_emul.h
index 083557f64f..b5d08b2a4c 100644
--- a/usr/src/cmd/bhyve/usb_emul.h
+++ b/usr/src/cmd/bhyve/usb_emul.h
@@ -35,6 +35,7 @@
#include <pthread.h>
#ifndef __FreeBSD__
#include <synch.h>
+#include "sol_lock.h"
#endif
#define USB_MAX_XFER_BLOCKS 8
diff --git a/usr/src/cmd/bhyve/usb_mouse.c b/usr/src/cmd/bhyve/usb_mouse.c
index e9fc77ed8a..97f160f56b 100644
--- a/usr/src/cmd/bhyve/usb_mouse.c
+++ b/usr/src/cmd/bhyve/usb_mouse.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2014 Leon Dang <ldang@nahannisys.com>
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +38,10 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "usb_emul.h"
#include "console.h"
#include "bhyvegc.h"
diff --git a/usr/src/cmd/bhyve/virtio.c b/usr/src/cmd/bhyve/virtio.c
index fc0525c9ee..614261d6b8 100644
--- a/usr/src/cmd/bhyve/virtio.c
+++ b/usr/src/cmd/bhyve/virtio.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2013 Chris Torek <torek @ torek net>
+ * Copyright 2018 Joyent, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +38,10 @@ __FBSDID("$FreeBSD$");
#include <pthread.h>
#include <pthread_np.h>
+#ifndef __FreeBSD__
+#include "sol_lock.h"
+#endif
+
#include "bhyverun.h"
#include "pci_emul.h"
#include "virtio.h"