diff options
author | Andy Fiddaman <andy@omniosce.org> | 2022-03-16 03:50:36 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2023-01-26 19:22:48 +0000 |
commit | b0e5369098077f08c1a1ff4bbf7d6235e74c005e (patch) | |
tree | 56e3fc1d2610aa5f67520d081d476db15fa5a345 /usr.sbin | |
parent | 62bed9d49e418a48ca9bc36f5f7bc513c547c92f (diff) |
bhyve: missing mutex initializations
Explicitly initialize the mutex that a PCI virtio module passes back to
virtio.
It so happens that these mutexes were being initialized regardless, no
functional change intended.
Reviewed by: chuck, jhb
Differential Revision: https://reviews.freebsd.org/D34372
(cherry picked from commit f6f357efb1067b79678d8f348333ffdfec66ad20)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/pci_nvme.c | 4 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_virtio_console.c | 2 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_virtio_rnd.c | 2 | ||||
-rw-r--r-- | usr.sbin/bhyve/pci_virtio_scsi.c | 2 |
4 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index d57014ae4f35..123f91158a21 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -485,7 +485,7 @@ pci_nvme_init_queues(struct pci_nvme_softc *sc, uint32_t nsq, uint32_t ncq) } else { struct nvme_submission_queue *sq = sc->submit_queues; - for (i = 0; i < sc->num_squeues; i++) + for (i = 0; i < sc->num_squeues + 1; i++) pthread_mutex_init(&sq[i].mtx, NULL); } @@ -508,7 +508,7 @@ pci_nvme_init_queues(struct pci_nvme_softc *sc, uint32_t nsq, uint32_t ncq) } else { struct nvme_completion_queue *cq = sc->compl_queues; - for (i = 0; i < sc->num_cqueues; i++) + for (i = 0; i < sc->num_cqueues + 1; i++) pthread_mutex_init(&cq[i].mtx, NULL); } } diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index ad46482749d3..d16668e6a2cb 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -698,6 +698,8 @@ pci_vtcon_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) sc->vsc_config->cols = 80; sc->vsc_config->rows = 25; + pthread_mutex_init(&sc->vsc_mtx, NULL); + vi_softc_linkup(&sc->vsc_vs, &vtcon_vi_consts, sc, pi, sc->vsc_queues); sc->vsc_vs.vs_mtx = &sc->vsc_mtx; diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c index ed51004416fe..db8dc143e0b2 100644 --- a/usr.sbin/bhyve/pci_virtio_rnd.c +++ b/usr.sbin/bhyve/pci_virtio_rnd.c @@ -179,6 +179,8 @@ pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) sc = calloc(1, sizeof(struct pci_vtrnd_softc)); + pthread_mutex_init(&sc->vrsc_mtx, NULL); + vi_softc_linkup(&sc->vrsc_vs, &vtrnd_vi_consts, sc, pi, &sc->vrsc_vq); sc->vrsc_vs.vs_mtx = &sc->vrsc_mtx; diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c index a1dd880c65b3..b33e6e432dea 100644 --- a/usr.sbin/bhyve/pci_virtio_scsi.c +++ b/usr.sbin/bhyve/pci_virtio_scsi.c @@ -720,6 +720,8 @@ pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) return (1); } + pthread_mutex_init(&sc->vss_mtx, NULL); + vi_softc_linkup(&sc->vss_vs, &vtscsi_vi_consts, sc, pi, sc->vss_vq); sc->vss_vs.vs_mtx = &sc->vss_mtx; |