vtnet IFF_NEEDSEPOCH?

Kristof Provost kp at FreeBSD.org
Tue Feb 18 09:52:12 UTC 2020


Hi,

I’ve been playing around with a risc-v qemu image, and run into this 
panic with vtnet:

	DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 5
	panic: Assertion in_epoch(net_epoch_preempt) failed at 
/usr/src/sys/net/netisr.c:1093
	cpuid = 0
	time = 1581981733
	KDB: stack backtrace:
	db_trace_self() at db_trace_self
	db_fetch_ksymtab() at db_fetch_ksymtab+0x12a
	kdb_backtrace() at kdb_backtrace+0x2c
	vpanic() at vpanic+0x144
	panic() at panic+0x26
	netisr_dispatch_src() at netisr_dispatch_src+0x3c0
	netisr_dispatch() at netisr_dispatch+0x10
	ether_ifattach() at ether_ifattach+0x2fa
	vtmmio_attach() at vtmmio_attach+0x490c
	vtmmio_attach() at vtmmio_attach+0x4624
	vtmmio_attach() at vtmmio_attach+0x544a
	virtqueue_intr() at virtqueue_intr+0xc
	vtmmio_attach() at vtmmio_attach+0x2008
	db_dump_intr_event() at db_dump_intr_event+0x730
	fork_exit() at fork_exit+0x68
	fork_trampoline() at fork_trampoline+0xa
	KDB: enter: panic
	[ thread pid 12 tid 100023 ]
	Stopped at      kdb_enter+0x44: sd      zero,0(a0)
	db>

It seems pretty clear that the vtmmio path doesn’t enter epoch before 
it runs the vtnet_attach() code.
On the other hand, I run vtnet CURRENT guests in bhyve, and don’t see 
this panic. In that case it lives on top of PCI rather than mmio, but I 
don’t see why/where that’d enter epoch.

The following does fix the panic for me, but I’m not sure if I’m 
fixing the correct problem:

	commit 4e388ab164c0d746875501d403a1c7052f1ed633 (HEAD -> kp-hardfloat)
	Author: Kristof Provost <kristof at codepro.be>
	Date:   Mon Feb 17 10:05:14 2020 +0100

	    vtnet: Needs epoch

	diff --git a/sys/dev/virtio/network/if_vtnet.c 
b/sys/dev/virtio/network/if_vtnet.c
	index ceb3ffaaf2b..8c776b27f21 100644
	--- a/sys/dev/virtio/network/if_vtnet.c
	+++ b/sys/dev/virtio/network/if_vtnet.c
	@@ -950,7 +950,7 @@ vtnet_setup_interface(struct vtnet_softc *sc)
	        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
	        ifp->if_baudrate = IF_Gbps(10); /* Approx. */
	        ifp->if_softc = sc;
	-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
	+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | 
IFF_NEEDSEPOCH;
	        ifp->if_init = vtnet_init;
	        ifp->if_ioctl = vtnet_ioctl;
	        ifp->if_get_counter = vtnet_get_counter;

Best regards,
Kristof


More information about the freebsd-net mailing list