Module Name: src Committed By: martin Date: Wed Aug 7 09:58:20 UTC 2024
Modified Files: src/sys/dev/pci [netbsd-10]: if_vioif.c Log Message: Pull up following revision(s) (requested by isaki in ticket #772): sys/dev/pci/if_vioif.c: revision 1.111 Ensure that the number of bus_dma segments doesn't exceed VirtIO queue size. This fixes reproducible panics when the host's VirtIO queue size is too small, less than or equal to VIRTIO_NET_TX_MAXNSEGS(=16). PR kern/58049. To generate a diff of this commit: cvs rdiff -u -r1.82.4.4 -r1.82.4.5 src/sys/dev/pci/if_vioif.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_vioif.c diff -u src/sys/dev/pci/if_vioif.c:1.82.4.4 src/sys/dev/pci/if_vioif.c:1.82.4.5 --- src/sys/dev/pci/if_vioif.c:1.82.4.4 Wed Aug 7 09:12:55 2024 +++ src/sys/dev/pci/if_vioif.c Wed Aug 7 09:58:20 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vioif.c,v 1.82.4.4 2024/08/07 09:12:55 martin Exp $ */ +/* $NetBSD: if_vioif.c,v 1.82.4.5 2024/08/07 09:58:20 martin Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.82.4.4 2024/08/07 09:12:55 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.82.4.5 2024/08/07 09:58:20 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -1280,12 +1280,14 @@ vioif_alloc_mems(struct vioif_softc *sc) struct virtio_net_hdr *hdrs; int dir; + int nsegs; dir = VIOIF_NETQ_DIR(qid); netq = &sc->sc_netqs[qid]; vq_num = netq->netq_vq->vq_num; maps = netq->netq_maps; hdrs = netq->netq_maps_kva; + nsegs = uimin(dmaparams[dir].dma_nsegs, vq_num - 1/*hdr*/); for (i = 0; i < vq_num; i++) { maps[i].vnm_hdr = &hdrs[i]; @@ -1297,7 +1299,7 @@ vioif_alloc_mems(struct vioif_softc *sc) goto err_reqs; r = vioif_dmamap_create(sc, &maps[i].vnm_mbuf_map, - dmaparams[dir].dma_size, dmaparams[dir].dma_nsegs, + dmaparams[dir].dma_size, nsegs, dmaparams[dir].msg_payload); if (r != 0) goto err_reqs;