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.
This commit is contained in:
riastradh 2022-03-23 23:23:25 +00:00
parent 2b8e15f8fa
commit d3d9ac4a56
1 changed files with 3 additions and 3 deletions

View File

@ -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,