qemu/hw/net
Yajun Wu 4c54f5bc8e hw/net/virtio-net: fix qemu set used ring flag even vhost started
When vhost-user or vhost-kernel is handling virtio net datapath,
QEMU should not touch used ring.

But with vhost-user socket reconnect scenario, in a very rare case
(has pending kick event). VRING_USED_F_NO_NOTIFY is set by QEMU in
following code path:

	#0  virtio_queue_split_set_notification (vq=0x7ff5f4c920a8, enable=0) at ../hw/virtio/virtio.c:511
	#1  0x0000559d6dbf033b in virtio_queue_set_notification (vq=0x7ff5f4c920a8, enable=0) at ../hw/virtio/virtio.c:576
	#2  0x0000559d6dbbbdbc in virtio_net_handle_tx_bh (vdev=0x559d703a6aa0, vq=0x7ff5f4c920a8) at ../hw/net/virtio-net.c:2801
	#3  0x0000559d6dbf4791 in virtio_queue_notify_vq (vq=0x7ff5f4c920a8) at ../hw/virtio/virtio.c:2248
	#4  0x0000559d6dbf79da in virtio_queue_host_notifier_read (n=0x7ff5f4c9211c) at ../hw/virtio/virtio.c:3525
	#5  0x0000559d6d9a5814 in virtio_bus_cleanup_host_notifier (bus=0x559d703a6a20, n=1) at ../hw/virtio/virtio-bus.c:321
	#6  0x0000559d6dbf83c9 in virtio_device_stop_ioeventfd_impl (vdev=0x559d703a6aa0) at ../hw/virtio/virtio.c:3774
	#7  0x0000559d6d9a55c8 in virtio_bus_stop_ioeventfd (bus=0x559d703a6a20) at ../hw/virtio/virtio-bus.c:259
	#8  0x0000559d6d9a53e8 in virtio_bus_grab_ioeventfd (bus=0x559d703a6a20) at ../hw/virtio/virtio-bus.c:199
	#9  0x0000559d6dbf841c in virtio_device_grab_ioeventfd (vdev=0x559d703a6aa0) at ../hw/virtio/virtio.c:3783
	#10 0x0000559d6d9bde18 in vhost_dev_enable_notifiers (hdev=0x559d707edd70, vdev=0x559d703a6aa0) at ../hw/virtio/vhost.c:1592
	#11 0x0000559d6d89a0b8 in vhost_net_start_one (net=0x559d707edd70, dev=0x559d703a6aa0) at ../hw/net/vhost_net.c:266
	#12 0x0000559d6d89a6df in vhost_net_start (dev=0x559d703a6aa0, ncs=0x559d7048d890, data_queue_pairs=31, cvq=0) at ../hw/net/vhost_net.c:412
	#13 0x0000559d6dbb5b89 in virtio_net_vhost_status (n=0x559d703a6aa0, status=15 '\017') at ../hw/net/virtio-net.c:311
	#14 0x0000559d6dbb5e34 in virtio_net_set_status (vdev=0x559d703a6aa0, status=15 '\017') at ../hw/net/virtio-net.c:392
	#15 0x0000559d6dbb60d8 in virtio_net_set_link_status (nc=0x559d7048d890) at ../hw/net/virtio-net.c:455
	#16 0x0000559d6da64863 in qmp_set_link (name=0x559d6f0b83d0 "hostnet1", up=true, errp=0x7ffdd76569f0) at ../net/net.c:1459
	#17 0x0000559d6da7226e in net_vhost_user_event (opaque=0x559d6f0b83d0, event=CHR_EVENT_OPENED) at ../net/vhost-user.c:301
	#18 0x0000559d6ddc7f63 in chr_be_event (s=0x559d6f2ffea0, event=CHR_EVENT_OPENED) at ../chardev/char.c:62
	#19 0x0000559d6ddc7fdc in qemu_chr_be_event (s=0x559d6f2ffea0, event=CHR_EVENT_OPENED) at ../chardev/char.c:82

This issue causes guest kernel stop kicking device and traffic stop.

Add vhost_started check in virtio_net_handle_tx_bh to fix this wrong
VRING_USED_F_NO_NOTIFY set.

Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20240402045109.97729-1-yajunw@nvidia.com>
[PMD: Use unlikely()]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2024-04-02 16:15:07 +02:00
..
can hw/net/can/sja1000: fix bug for single acceptance filter and standard frame 2024-01-05 16:20:15 +01:00
fsl_etsec net: Provide MemReentrancyGuard * to qemu_new_nic() 2023-11-21 15:42:34 +08:00
rocker net: Provide MemReentrancyGuard * to qemu_new_nic() 2023-11-21 15:42:34 +08:00
allwinner_emac.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
allwinner-sun8i-emac.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
cadence_gem.c hw/net: cadence_gem: Fix MDIO_OP_xxx values 2024-01-05 22:28:54 +03:00
dp8393x.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
e1000_common.h e1000: Split header files 2023-03-10 15:35:38 +08:00
e1000_regs.h hw/net: spelling fixes 2023-09-20 07:54:34 +03:00
e1000.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
e1000e_core.c e1000e: fix link state on resume 2024-03-12 19:28:32 +08:00
e1000e_core.h e1000e: fix link state on resume 2024-03-12 19:28:32 +08:00
e1000e.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
e1000x_common.c e1000x: Take CRC into consideration for size check 2023-05-23 15:20:15 +08:00
e1000x_common.h e1000x: Share more Rx filtering logic 2023-05-23 15:20:15 +08:00
e1000x_regs.h hw/net: spelling fixes 2023-09-20 07:54:34 +03:00
eepro100.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
etraxfs_eth.c hw/net/etraxfs-eth: use qemu_configure_nic_device() 2024-02-02 16:23:47 +00:00
ftgmac100.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
i82596.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
i82596.h
igb_common.h igb: Add a VF reset handler 2023-11-13 15:33:37 +08:00
igb_core.c igb: fix link state on resume 2024-03-12 19:28:31 +08:00
igb_core.h igb: fix link state on resume 2024-03-12 19:28:31 +08:00
igb_regs.h hw/net: spelling fixes 2023-09-20 07:54:34 +03:00
igb.c hw/pci: Always call pcie_sriov_pf_reset() 2024-03-12 17:56:55 -04:00
igbvf.c igb: Add Function Level Reset to PF and VF 2023-11-13 15:33:37 +08:00
imx_fec.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
Kconfig kconfig: Add PCIe devices to s390x machines 2023-07-14 11:10:57 +02:00
lan9118.c hw/net/lan9118: use qemu_configure_nic_device() 2024-02-02 16:23:47 +00:00
lance.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
lasi_i82596.c hw/net/lasi_i82596: use qemu_create_nic_device() 2024-02-02 16:23:47 +00:00
mcf_fec.c net: Provide MemReentrancyGuard * to qemu_new_nic() 2023-11-21 15:42:34 +08:00
meson.build target/arm: fix exception syndrome for AArch32 bkpt insn 2024-02-02 18:56:32 +00:00
mipsnet.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
msf2-emac.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
mv88w8618_eth.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
ne2000-isa.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
ne2000-pci.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
ne2000.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
ne2000.h
net_rx_pkt.c igb: Strip the second VLAN tag for extended VLAN 2023-05-23 15:20:15 +08:00
net_rx_pkt.h igb: Strip the second VLAN tag for extended VLAN 2023-05-23 15:20:15 +08:00
net_tx_pkt.c hw/net/net_tx_pkt: Fix virtio header without checksum offloading 2024-03-29 14:59:07 +08:00
net_tx_pkt.h igb: Implement Tx SCTP CSO 2023-05-23 15:20:15 +08:00
npcm7xx_emc.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
npcm_gmac.c hw/net: GMAC Tx Implementation 2024-02-02 13:51:59 +00:00
opencores_eth.c net: Provide MemReentrancyGuard * to qemu_new_nic() 2023-11-21 15:42:34 +08:00
pcnet-pci.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
pcnet.c Avoid unaligned fetch in ladr_match() 2024-03-12 19:28:32 +08:00
pcnet.h net: Replace TAB indentations with spaces 2022-11-11 09:39:03 +01:00
rtl8139.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
smc91c111.c hw/net/smc91c111: use qemu_configure_nic_device() 2024-02-02 16:23:47 +00:00
spapr_llan.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
stellaris_enet.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
sungem.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
sunhme.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
trace-events hw/net: GMAC Tx Implementation 2024-02-02 13:51:59 +00:00
trace.h
tulip.c hw/net/tulip: add chip status register values 2024-02-11 13:20:23 +01:00
tulip.h
vhost_net-stub.c virtio-net: add support for configure interrupt 2023-01-08 01:54:22 -05:00
vhost_net.c vdpa-dev: Fix initialisation order to restore VDUSE compatibility 2024-03-26 14:21:26 +01:00
virtio-net.c hw/net/virtio-net: fix qemu set used ring flag even vhost started 2024-04-02 16:15:07 +02:00
vmware_utils.h
vmxnet3_defs.h include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
vmxnet3.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
vmxnet3.h hw/net: spelling fixes 2023-09-20 07:54:34 +03:00
vmxnet_debug.h
xen_nic.c hw/net/xen_nic: Fix missing ERRP_GUARD() for error_prepend() 2024-03-09 18:51:45 +01:00
xgmac.c hw/net: Constify VMState 2023-12-30 07:38:06 +11:00
xilinx_axienet.c net: Provide MemReentrancyGuard * to qemu_new_nic() 2023-11-21 15:42:34 +08:00
xilinx_ethlite.c net: Provide MemReentrancyGuard * to qemu_new_nic() 2023-11-21 15:42:34 +08:00