vtnet IFF_NEEDSEPOCH?

Kristof Provost kp at FreeBSD.org
Thu Feb 20 11:16:10 UTC 2020


On 19 Feb 2020, at 23:48, Gleb Smirnoff wrote:
> On Tue, Feb 18, 2020 at 10:08:50PM +0100, Kristof Provost wrote:
> K> So I suspect our call stack is something like virtqueue_intr() ->
> K> vtnet_rx_vq_intr() -> vtnet_rxq_eof() -> vtnet_rxq_input() ->
> K> ether_input().
> K> I don’t see anything entering epoch in that path, which 
> presumably explains
> K> the panic, but I still don’t understand why my bhyve current vm 
> doesn’t
> K> panic in the same way.
>
> On bhyve we enter it through interrupt handler, and this is where we
> enter the epoch. Does RISC-V has interrupt handling by the MI code
> in sys/kern/kern_intr.c as other platforms?
>
It does, yes, but that was the hint I needed. I didn’t know that we 
entered net_epoch automagically based on the interrupt type.

The difference between the two is that Bhyve uses virtio_pci, and in my 
qemu case we run through the virtio_mmio path. In that path we always 
set INTR_TYPE_MISC, so we never set INTR_TYPE_NET, even for if_vtnet, so 
we never entered epoch.

This is the correct fix:

	diff --git a/sys/dev/virtio/mmio/virtio_mmio.c 
b/sys/dev/virtio/mmio/virtio_mmio.c
	index 95eb8647052..ccafe326868 100644
	--- a/sys/dev/virtio/mmio/virtio_mmio.c
	+++ b/sys/dev/virtio/mmio/virtio_mmio.c
	@@ -196,7 +196,7 @@ vtmmio_setup_intr(device_t dev, enum intr_type 
type)
	                return (ENXIO);
	        }

	-       if (bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | 
INTR_MPSAFE,
	+       if (bus_setup_intr(dev, sc->res[1], type | INTR_MPSAFE,
	                NULL, vtmmio_vq_intr, sc, &sc->ih)) {
	                device_printf(dev, "Can't setup the interrupt\n");
	                return (ENXIO);

Thanks for the help!

Regards,
Kristof


More information about the freebsd-net mailing list