CVS commit: [netbsd-8] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Mon Mar 16 12:22:03 UTC 2020 Modified Files: src/sys/arch/xen/xen [netbsd-8]: xennet_checksum.c Log Message: Pull up the following revisions(s) (requested by jdolecek in ticket #1521): sys/arch/xen/xen/xennet_checksum.c: revision 1.4 Make the packet length check less strict, allow the physical packet longer than IP payload. This fixes problem where checksum was not recomputed for short packets coming from Windows domU on same physical host as it seems Windows does some padding. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.98.1 src/sys/arch/xen/xen/xennet_checksum.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/arch/xen/xen/xennet_checksum.c diff -u src/sys/arch/xen/xen/xennet_checksum.c:1.3 src/sys/arch/xen/xen/xennet_checksum.c:1.3.98.1 --- src/sys/arch/xen/xen/xennet_checksum.c:1.3 Thu Nov 22 16:17:10 2007 +++ src/sys/arch/xen/xen/xennet_checksum.c Mon Mar 16 12:22:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xennet_checksum.c,v 1.3 2007/11/22 16:17:10 bouyer Exp $ */ +/* $NetBSD: xennet_checksum.c,v 1.3.98.1 2020/03/16 12:22:03 sborrill Exp $ */ /*- * Copyright (c)2006 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.3 2007/11/22 16:17:10 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xennet_checksum.c,v 1.3.98.1 2020/03/16 12:22:03 sborrill Exp $"); #include #include @@ -124,7 +124,7 @@ xennet_checksum_fill(struct mbuf **mp) nxt = iph->ip_p; iphlen = iph->ip_hl * 4; iplen = ntohs(iph->ip_len); - if (ehlen + iplen != m->m_pkthdr.len) { + if (ehlen + iplen > m->m_pkthdr.len) { return EINVAL; } if (nxt == IPPROTO_UDP) {
CVS commit: [netbsd-8] src/sys/arch/xen/xen
Module Name:src Committed By: martin Date: Mon Jan 21 20:12:15 UTC 2019 Modified Files: src/sys/arch/xen/xen [netbsd-8]: if_xennet_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1166): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.74 Don't call xennet_softstart from hard interrupt; schedule softint. Fixes panic in bpf_mtap which expects to be called only in softint. To generate a diff of this commit: cvs rdiff -u -r1.70.6.1 -r1.70.6.2 src/sys/arch/xen/xen/if_xennet_xenbus.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/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.70.6.1 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.70.6.2 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.70.6.1 Thu Jul 26 23:55:29 2018 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Mon Jan 21 20:12:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.70.6.1 2018/07/26 23:55:29 snj Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.70.6.2 2019/01/21 20:12:15 martin Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.70.6.1 2018/07/26 23:55:29 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.70.6.2 2019/01/21 20:12:15 martin Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -953,7 +953,7 @@ again: end: if (ifp->if_flags & IFF_OACTIVE) { ifp->if_flags &= ~IFF_OACTIVE; - xennet_softstart(sc); + softint_schedule(sc->sc_softintr); } }
CVS commit: [netbsd-8] src/sys/arch/xen/xen
Module Name:src Committed By: martin Date: Sun Sep 23 17:58:51 UTC 2018 Modified Files: src/sys/arch/xen/xen [netbsd-8]: xbdback_xenbus.c Log Message: Apply patch, requested by manu in ticket #1034: Avoid sleeping with a spin lock held (solved differently on HEAD). To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.63.8.1 src/sys/arch/xen/xen/xbdback_xenbus.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/arch/xen/xen/xbdback_xenbus.c diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.63 src/sys/arch/xen/xen/xbdback_xenbus.c:1.63.8.1 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.63 Mon Dec 26 08:16:28 2016 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Sun Sep 23 17:58:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.63 2016/12/26 08:16:28 skrll Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.63.8.1 2018/09/23 17:58:51 martin Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.63 2016/12/26 08:16:28 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.63.8.1 2018/09/23 17:58:51 martin Exp $"); #include #include @@ -674,15 +674,16 @@ err: static void xbdback_disconnect(struct xbdback_instance *xbdi) { - + + hypervisor_mask_event(xbdi->xbdi_evtchn); + event_remove_handler(xbdi->xbdi_evtchn, xbdback_evthandler, + xbdi); + mutex_enter(&xbdi->xbdi_lock); if (xbdi->xbdi_status == DISCONNECTED) { mutex_exit(&xbdi->xbdi_lock); return; } - hypervisor_mask_event(xbdi->xbdi_evtchn); - event_remove_handler(xbdi->xbdi_evtchn, xbdback_evthandler, - xbdi); /* signal thread that we want to disconnect, then wait for it */ xbdi->xbdi_status = DISCONNECTING;
CVS commit: [netbsd-8] src/sys/arch/xen/xen
Module Name:src Committed By: martin Date: Sat Aug 25 14:28:00 UTC 2018 Modified Files: src/sys/arch/xen/xen [netbsd-8]: xbd_xenbus.c Log Message: Pull up following revision(s) (requested by jdolecek in ticket #984): sys/arch/xen/xen/xbd_xenbus.c: revision 1.83 avoid race condition between I/O submission in xbd_diskstart() and interrupt handling in xbd_handler() - need to protect it with splbio() fixes PR port-xen/53506 by Emmanuel Dreyfus, and likely also port-xen/53074 by Brad Spencer To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.76.6.1 src/sys/arch/xen/xen/xbd_xenbus.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/arch/xen/xen/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.76 src/sys/arch/xen/xen/xbd_xenbus.c:1.76.6.1 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.76 Sun Mar 5 23:07:12 2017 +++ src/sys/arch/xen/xen/xbd_xenbus.c Sat Aug 25 14:28:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.76 2017/03/05 23:07:12 mlelstv Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.76.6.1 2018/08/25 14:28:00 martin Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.76 2017/03/05 23:07:12 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.76.6.1 2018/08/25 14:28:00 martin Exp $"); #include "opt_xen.h" @@ -916,6 +916,7 @@ xbd_diskstart(device_t self, struct buf vaddr_t va; int nsects, nbytes, seg; int notify, error = 0; + int s; DPRINTF(("xbd_diskstart(%p): b_bcount = %ld\n", bp, (long)bp->b_bcount)); @@ -931,6 +932,8 @@ xbd_diskstart(device_t self, struct buf goto err; } + s = splbio(); /* XXX SMP */ + if (__predict_false( sc->sc_backend_status == BLKIF_STATE_SUSPENDED)) { /* device is suspended, do not consume buffer */ @@ -1008,6 +1011,7 @@ out: RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&sc->sc_ring, notify); if (notify) hypervisor_notify_via_evtchn(sc->sc_evtchn); + splx(s); /* XXXSMP */ err: return error; }
CVS commit: [netbsd-8] src/sys/arch/xen/xen
Module Name:src Committed By: martin Date: Wed Aug 15 12:04:02 UTC 2018 Modified Files: src/sys/arch/xen/xen [netbsd-8]: xennetback_xenbus.c Log Message: Pull up following revision(s) (requested by dolecek in ticket #973): sys/arch/xen/xen/xennetback_xenbus.c: revision 1.68 (patch) disestablish interrupt handler regardless of the state whenever it was setup, i.e. also when the instance is DISCONNECTING already fixes PR port-xen/53487 by Bert Kiers; fix found and reported by Dennis Lindroos XXX pullup netbsd-8 To generate a diff of this commit: cvs rdiff -u -r1.58.8.2 -r1.58.8.3 src/sys/arch/xen/xen/xennetback_xenbus.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/arch/xen/xen/xennetback_xenbus.c diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.58.8.2 src/sys/arch/xen/xen/xennetback_xenbus.c:1.58.8.3 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.58.8.2 Thu Jul 26 23:55:29 2018 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Wed Aug 15 12:04:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.58.8.2 2018/07/26 23:55:29 snj Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.58.8.3 2018/08/15 12:04:02 martin Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.58.8.2 2018/07/26 23:55:29 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.58.8.3 2018/08/15 12:04:02 martin Exp $"); #include "opt_xen.h" @@ -386,10 +386,12 @@ xennetback_xenbus_destroy(void *arg) aprint_verbose_ifnet(&xneti->xni_if, "disconnecting\n"); - if (xneti->xni_status == CONNECTED) { + if (xneti->xni_evtchn != 0) { hypervisor_mask_event(xneti->xni_evtchn); event_remove_handler(xneti->xni_evtchn, xennetback_evthandler, xneti); + xneti->xni_evtchn = 0; + if (xneti->xni_softintr) { softint_disestablish(xneti->xni_softintr); xneti->xni_softintr = NULL;
CVS commit: [netbsd-8] src/sys/arch/xen/xen
Module Name:src Committed By: martin Date: Sun Jul 15 10:54:03 UTC 2018 Modified Files: src/sys/arch/xen/xen [netbsd-8]: xennetback_xenbus.c Log Message: Pull up following revision(s) (requested by jdolecek in ticket #909): sys/arch/xen/xen/xennetback_xenbus.c: revision 1.64 (patch) Fix panic of DOM0 in xennetback_xenbus_destroy() on xl destroy of DOMU with created, but non CONNECTED xennet (such as when DOMU panics during boot); only try to disestablish the intr if it was actually setup. While here protect xnetback_instances with mutex, and switch to use kmem_zalloc() + KM_SLEEP / kmem_free() like xbdback_xenbus.c; add XXXSMP to the other global variables, and at least mark them static To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.58.8.1 src/sys/arch/xen/xen/xennetback_xenbus.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/arch/xen/xen/xennetback_xenbus.c diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.58 src/sys/arch/xen/xen/xennetback_xenbus.c:1.58.8.1 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.58 Thu Dec 15 09:28:04 2016 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Sun Jul 15 10:54:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.58 2016/12/15 09:28:04 ozaki-r Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.58.8.1 2018/07/15 10:54:03 martin Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.58 2016/12/15 09:28:04 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.58.8.1 2018/07/15 10:54:03 martin Exp $"); #include "opt_xen.h" @@ -34,6 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: xennetback_x #include #include #include +#include #include #include #include @@ -140,9 +141,10 @@ static inline void xennetback_tx_respons int, int); static void xennetback_tx_free(struct mbuf * , void *, size_t, void *); -SLIST_HEAD(, xnetback_instance) xnetback_instances; +static SLIST_HEAD(, xnetback_instance) xnetback_instances; +static kmutex_t xnetback_lock; -static struct xnetback_instance *xnetif_lookup(domid_t, uint32_t); +static bool xnetif_lookup(domid_t, uint32_t); static int xennetback_evthandler(void *); static struct xenbus_backend_driver xvif_backend_driver = { @@ -176,12 +178,13 @@ pool_cache_t xmit_pages_cache; pool_cache_t xmit_pages_cachep; /* arrays used in xennetback_ifstart(), too large to allocate on stack */ +/* XXXSMP */ static mmu_update_t xstart_mmu[NB_XMIT_PAGES_BATCH]; static multicall_entry_t xstart_mcl[NB_XMIT_PAGES_BATCH + 1]; static gnttab_transfer_t xstart_gop_transfer[NB_XMIT_PAGES_BATCH]; static gnttab_copy_t xstart_gop_copy[NB_XMIT_PAGES_BATCH]; -struct mbuf *mbufs_sent[NB_XMIT_PAGES_BATCH]; -struct _pages_pool_free { +static struct mbuf *mbufs_sent[NB_XMIT_PAGES_BATCH]; +static struct _pages_pool_free { vaddr_t va; paddr_t pa; } pages_pool_free[NB_XMIT_PAGES_BATCH]; @@ -229,6 +232,8 @@ xvifattach(int n) #endif SLIST_INIT(&xnetback_instances); + mutex_init(&xnetback_lock, MUTEX_DEFAULT, IPL_NONE); + xenbus_backend_register(&xvif_backend_driver); } @@ -256,14 +261,10 @@ xennetback_xenbus_create(struct xenbus_d return err; } - if (xnetif_lookup(domid, handle) != NULL) { + if (xnetif_lookup(domid, handle)) { return EEXIST; } - xneti = malloc(sizeof(struct xnetback_instance), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (xneti == NULL) { - return ENOMEM; - } + xneti = kmem_zalloc(sizeof(*xneti), KM_SLEEP); xneti->xni_domid = domid; xneti->xni_handle = handle; xneti->xni_status = DISCONNECTED; @@ -317,7 +318,9 @@ xennetback_xenbus_create(struct xenbus_d if_attach(ifp); ether_ifattach(&xneti->xni_if, xneti->xni_enaddr); + mutex_enter(&xnetback_lock); SLIST_INSERT_HEAD(&xnetback_instances, xneti, next); + mutex_exit(&xnetback_lock); xbusd->xbusd_otherend_changed = xennetback_frontend_changed; @@ -371,7 +374,7 @@ xennetback_xenbus_create(struct xenbus_d abort_xbt: xenbus_transaction_end(xbt, 1); fail: - free(xneti, M_DEVBUF); + kmem_free(xneti, sizeof(*xneti)); return err; } @@ -382,21 +385,22 @@ xennetback_xenbus_destroy(void *arg) struct gnttab_unmap_grant_ref op; int err; -#if 0 - if (xneti->xni_status == CONNECTED) { - return EBUSY; - } -#endif aprint_verbose_ifnet(&xneti->xni_if, "disconnecting\n"); - hypervisor_mask_event(xneti->xni_evtchn); - event_remove_handler(xneti->xni_evtchn, xennetback_evthandler, xneti); - if (xneti->xni_softintr) { - softint_disestablish(xneti->xni_softintr); - xneti->xni_softintr = NULL; + + if (xneti->xni_status == CONNECTED) { + hypervisor_mask_event(xneti->xni_evtchn); + event_remove_handler(xneti->xni_evtchn, xennetback_evthandler, + xneti); + if (xneti->xni_softintr) { + softint_disestablish(xneti->xni_softintr); + xneti->xni_softintr = NULL; + } } +