From d3d9ac4a567fbbc9a3cf19f13260cdee113293c1 Mon Sep 17 00:00:00 2001 From: riastradh Date: Wed, 23 Mar 2022 23:23:25 +0000 Subject: [PATCH] viornd(4): Process host entropy in softint context. Samples added to the entropy pool in hard interrupt context are only buffered, never processed directly, and if they fill the buffer, the sample is dropped -- this serves to encourage taking timing samples in hard interrupt context because it's cheap, and we have no idea how many samples we really need for full entropy so it's safer to err on the side of `as many as we can get'. But for viornd(4), we assume the host has full entropy so we only need a single 32-byte sample, and we want to avoid dropping it so we get full entropy ASAP. Entering the sample in a soft interrupt rather than hard interrupt achieves this. --- sys/dev/pci/viornd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/viornd.c b/sys/dev/pci/viornd.c index e4266f597604..57c78ae2c247 100644 --- a/sys/dev/pci/viornd.c +++ b/sys/dev/pci/viornd.c @@ -1,4 +1,4 @@ -/* $NetBSD: viornd.c,v 1.16 2022/03/19 16:20:45 riastradh Exp $ */ +/* $NetBSD: viornd.c,v 1.17 2022/03/23 23:23:25 riastradh Exp $ */ /* $OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $ */ /* @@ -139,7 +139,7 @@ viornd_attach(device_t parent, device_t self, void *aux) sc->sc_dev = self; sc->sc_virtio = vsc; - mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_VM); + mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_SOFTSERIAL); error = bus_dmamem_alloc(virtio_dmat(vsc), VIRTIO_PAGE_SIZE, 0, 0, segs, 1, &nsegs, @@ -177,7 +177,7 @@ viornd_attach(device_t parent, device_t self, void *aux) } virtio_child_attach_start(vsc, self, IPL_NET, &sc->sc_vq, - NULL, virtio_vq_intr, 0, + NULL, virtio_vq_intr, VIRTIO_F_INTR_MPSAFE|VIRTIO_F_INTR_SOFTINT, 0, VIRTIO_COMMON_FLAG_BITS); error = virtio_alloc_vq(vsc, &sc->sc_vq, 0, VIORND_BUFSIZE, 1,