--- sys/dev/virtio/scsi/virtio_scsi.c 2019/06/22 01:06:41 349284 +++ sys/dev/virtio/scsi/virtio_scsi.c 2019/06/22 01:20:45 @@ -81,6 +81,7 @@ struct virtio_scsi_config *); static int vtscsi_maximum_segments(struct vtscsi_softc *, int); static int vtscsi_alloc_virtqueues(struct vtscsi_softc *); +static void vtscsi_check_sizes(struct vtscsi_softc *); static void vtscsi_write_device_config(struct vtscsi_softc *); static int vtscsi_reinit(struct vtscsi_softc *); @@ -311,6 +312,8 @@ goto fail; } + vtscsi_check_sizes(sc); + error = vtscsi_init_event_vq(sc); if (error) { device_printf(dev, "cannot populate the eventvq\n"); @@ -478,6 +481,26 @@ } static void +vtscsi_check_sizes(struct vtscsi_softc *sc) +{ + int rqsize; + + if ((sc->vtscsi_flags & VTSCSI_FLAG_INDIRECT) == 0) { + /* + * Ensure the assertions in virtqueue_enqueue(), + * even if the hypervisor reports a bad seg_max. + */ + rqsize = virtqueue_size(sc->vtscsi_request_vq); + if (sc->vtscsi_max_nsegs > rqsize) { + device_printf(sc->vtscsi_dev, + "clamping seg_max (%d %d)\n", sc->vtscsi_max_nsegs, + rqsize); + sc->vtscsi_max_nsegs = rqsize; + } + } +} + +static void vtscsi_write_device_config(struct vtscsi_softc *sc) { --- sys/dev/virtio/network/if_vtnet.c 2020-01-13 14:53:41.011784000 -0800 +++ sys/dev/virtio/network/if_vtnet.c 2020-01-13 15:00:39.712042026 -0800 @@ -70,7 +70,6 @@ #include #include #include -#include #include #include @@ -1816,9 +1815,6 @@ case IPPROTO_UDP: m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xFFFF; - break; - case IPPROTO_SCTP: - m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; break; default: /*