CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Fri Feb 24 17:45:29 UTC 2012 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c Log Message: Pull up the following revisions(s) (requested by bouyer in ticket #1730): sys/arch/xen/xen/if_xennet_xenbus.c:revision 1.59 via patch Fix receive stall on the domU side when buffers stay a long time in the network stack or socket buffers. To generate a diff of this commit: cvs rdiff -u -r1.29.2.6 -r1.29.2.7 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.29.2.6 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.7 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.6 Thu May 19 21:13:07 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Fri Feb 24 17:45:29 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.6 2011/05/19 21:13:07 bouyer Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.7 2012/02/24 17:45:29 sborrill Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.6 2011/05/19 21:13:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.7 2012/02/24 17:45:29 sborrill Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -130,7 +130,6 @@ int xennet_debug = 0xff; #endif #define GRANT_INVALID_REF -1 /* entry is free */ -#define GRANT_STACK_REF -2 /* entry owned by the network stack */ #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE) #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE) @@ -192,6 +191,9 @@ struct xennet_xenbus_softc { static multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1]; static u_long xennet_pages[NET_RX_RING_SIZE]; +static pool_cache_t if_xennetrxbuf_cache; +static int if_xennetrxbuf_cache_inited=0; + static int xennet_xenbus_match(device_t, cfdata_t, void *); static void xennet_xenbus_attach(device_t, device_t, void *); static int xennet_xenbus_detach(device_t, int); @@ -202,6 +204,7 @@ static void xennet_alloc_rx_buffer(struc static void xennet_free_rx_buffer(struct xennet_xenbus_softc *); static void xennet_tx_complete(struct xennet_xenbus_softc *); static void xennet_rx_mbuf_free(struct mbuf *, void *, size_t, void *); +static void xennet_rx_free_req(struct xennet_rxreq *); static int xennet_handler(void *); static int xennet_talk_to_backend(struct xennet_xenbus_softc *); #ifdef XENNET_DEBUG_DUMP @@ -278,6 +281,14 @@ xennet_xenbus_attach(device_t parent, de sc->sc_xbusd = xa->xa_xbusd; sc->sc_xbusd->xbusd_otherend_changed = xennet_backend_changed; + /* xenbus ensure 2 devices can't be probed at the same time */ + if (if_xennetrxbuf_cache_inited == 0) { + if_xennetrxbuf_cache = pool_cache_init(PAGE_SIZE, 0, 0, 0, + "xnfrx", NULL, IPL_VM, NULL, NULL, NULL); + if_xennetrxbuf_cache_inited = 1; + } + + /* initialize free RX and RX request lists */ SLIST_INIT(&sc->sc_txreq_head); for (i = 0; i < NET_TX_RING_SIZE; i++) { @@ -291,13 +302,10 @@ xennet_xenbus_attach(device_t parent, de struct xennet_rxreq *rxreq = &sc->sc_rxreqs[i]; rxreq->rxreq_id = i; rxreq->rxreq_sc = sc; - rxreq->rxreq_va = uvm_km_alloc(kernel_map, - PAGE_SIZE, PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_ZERO); + rxreq->rxreq_va = (vaddr_t)pool_cache_get_paddr( + if_xennetrxbuf_cache, PR_WAITOK, &rxreq->rxreq_pa); if (rxreq->rxreq_va == 0) break; - if (!pmap_extract(pmap_kernel(), rxreq->rxreq_va, - &rxreq->rxreq_pa)) - panic("%s: no pa for mapped va ?", device_xname(self)); rxreq->rxreq_gntref = GRANT_INVALID_REF; SLIST_INSERT_HEAD(&sc->sc_rxreq_head, rxreq, rxreq_next); } @@ -560,7 +568,7 @@ xennet_alloc_rx_buffer(struct xennet_xen RING_IDX i; struct xennet_rxreq *req; struct xen_memory_reservation reservation; - int s1, s2, otherend_id; + int s1, s2, otherend_id, notify; paddr_t pfn; otherend_id = sc->sc_xbusd->xbusd_otherend_id; @@ -647,9 +655,10 @@ out_loop: } sc->sc_rx_ring.req_prod_pvt = req_prod + i; - RING_PUSH_REQUESTS(&sc->sc_rx_ring); - + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&sc->sc_rx_ring, notify); splx(s1); + if (notify) + hypervisor_notify_via_evtchn(sc->sc_evtchn); return; } @@ -669,14 +678,6 @@ xennet_free_rx_buffer(struct xennet_xenb for (i = 0; i < NET_RX_RING_SIZE; i++) { struct xennet_rxreq *rxreq = &sc->sc_rxreqs[i]; - /* - * if the buffer is in transit in the network stack, wait for - * the network stack to free it. - */ - while ((volatile grant_ref_t)rxreq->rxreq_gntref == - GRANT_STACK_REF) - tsleep(xennet_xenbus_detach, PRIBIO, "xnet_free", hz/2); - if (rxreq->rxreq_gntref != GRANT_INVALID_REF) { /* * this req is still granted. Get back the page or @@ -746,7 +747,20 @@ xen
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Tue May 8 12:11:46 UTC 2012 Modified Files: src/sys/arch/xen/xen [netbsd-5]: hypervisor.c Log Message: Pull up the following revisions(s) (requested by riz in ticket #1748): sys/arch/xen/xen/hypervisor.c: revision 1.62 via patch Retrieve and print the hypervisor "extra" (teeny) version. To generate a diff of this commit: cvs rdiff -u -r1.42.4.5 -r1.42.4.6 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.5 src/sys/arch/xen/xen/hypervisor.c:1.42.4.6 --- src/sys/arch/xen/xen/hypervisor.c:1.42.4.5 Mon Sep 26 09:56:54 2011 +++ src/sys/arch/xen/xen/hypervisor.c Tue May 8 12:11:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $ */ +/* $NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -63,7 +63,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $"); #include #include @@ -239,13 +239,17 @@ hypervisor_attach(device_t parent, devic #endif /* NPCI */ union hypervisor_attach_cookie hac; + char xen_extra_version[XEN_EXTRAVERSION_LEN]; xenkernfs_init(); #ifdef XEN3 xen_version = HYPERVISOR_xen_version(XENVER_version, NULL); - aprint_normal(": Xen version %d.%d\n", (xen_version & 0x) >> 16, - xen_version & 0x); + memset(xen_extra_version, 0, sizeof(xen_extra_version)); + HYPERVISOR_xen_version(XENVER_extraversion, xen_extra_version); + aprint_normal(": Xen version %d.%d%s\n", + (xen_version & 0x) >> 16, xen_version & 0x, + xen_extra_version); xengnt_init();
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Tue May 8 15:51:14 UTC 2012 Modified Files: src/sys/arch/xen/xen [netbsd-5]: hypervisor.c Log Message: Fix XEN2 build after last pullup To generate a diff of this commit: cvs rdiff -u -r1.42.4.6 -r1.42.4.7 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.6 src/sys/arch/xen/xen/hypervisor.c:1.42.4.7 --- src/sys/arch/xen/xen/hypervisor.c:1.42.4.6 Tue May 8 12:11:45 2012 +++ src/sys/arch/xen/xen/hypervisor.c Tue May 8 15:51:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $ */ +/* $NetBSD: hypervisor.c,v 1.42.4.7 2012/05/08 15:51:13 sborrill Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -63,7 +63,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.7 2012/05/08 15:51:13 sborrill Exp $"); #include #include @@ -230,6 +230,7 @@ hypervisor_attach(device_t parent, devic { #ifdef XEN3 int xen_version; + char xen_extra_version[XEN_EXTRAVERSION_LEN]; #endif #if NPCI >0 #ifndef XEN3 @@ -239,7 +240,6 @@ hypervisor_attach(device_t parent, devic #endif /* NPCI */ union hypervisor_attach_cookie hac; - char xen_extra_version[XEN_EXTRAVERSION_LEN]; xenkernfs_init();
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Fri Oct 26 11:31:50 UTC 2012 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xengnt.c Log Message: Pull up the following revisions(s) (requested by royger in ticket #1805): sys/arch/xen/xen/xengnt.c: revision 1.25 via patch Prevents a memory corruption issue that freezes a Xen DomU and can also cause fs corruption. Addresses PR port-xen/47057 and port-xen/47056 To generate a diff of this commit: cvs rdiff -u -r1.10.4.1 -r1.10.4.2 src/sys/arch/xen/xen/xengnt.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/xengnt.c diff -u src/sys/arch/xen/xen/xengnt.c:1.10.4.1 src/sys/arch/xen/xen/xengnt.c:1.10.4.2 --- src/sys/arch/xen/xen/xengnt.c:1.10.4.1 Sat Jan 30 19:14:20 2010 +++ src/sys/arch/xen/xen/xengnt.c Fri Oct 26 11:31:50 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: xengnt.c,v 1.10.4.1 2010/01/30 19:14:20 snj Exp $ */ +/* $NetBSD: xengnt.c,v 1.10.4.2 2012/10/26 11:31:50 sborrill Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.10.4.1 2010/01/30 19:14:20 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.10.4.2 2012/10/26 11:31:50 sborrill Exp $"); #include #include @@ -55,6 +55,9 @@ __KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1 #define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_t)) +/* External tools reserve first few grant table entries. */ +#define NR_RESERVED_ENTRIES 8 + int gnt_nr_grant_frames; int gnt_max_grant_frames; @@ -127,7 +130,7 @@ xengnt_more_entries() gnttab_setup_table_t setup; u_long *pages; int nframes_new = gnt_nr_grant_frames + 1; - int i; + int i, start_gnt; if (gnt_nr_grant_frames == gnt_max_grant_frames) return ENOMEM; @@ -167,9 +170,14 @@ xengnt_more_entries() /* * add the grant entries associated to the last grant table frame - * and mark them as free + * and mark them as free. Prevent using the first grants (from 0 to 8) + * since they are used by the tools. */ - for (i = gnt_nr_grant_frames * NR_GRANT_ENTRIES_PER_PAGE; + start_gnt = (gnt_nr_grant_frames * NR_GRANT_ENTRIES_PER_PAGE) < + (NR_RESERVED_ENTRIES + 1) ? + (NR_RESERVED_ENTRIES + 1) : + (gnt_nr_grant_frames * NR_GRANT_ENTRIES_PER_PAGE); + for (i = start_gnt; i < nframes_new * NR_GRANT_ENTRIES_PER_PAGE; i++) { KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY); @@ -206,7 +214,7 @@ xengnt_get_entry() entry = gnt_entries[last_gnt_entry]; gnt_entries[last_gnt_entry] = XENGNT_NO_ENTRY; splx(s); - KASSERT(entry != XENGNT_NO_ENTRY); + KASSERT(entry != XENGNT_NO_ENTRY && entry > NR_RESERVED_ENTRIES); KASSERT(last_gnt_entry >= 0 && last_gnt_entry <= gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE); return entry; } @@ -218,6 +226,7 @@ static void xengnt_free_entry(grant_ref_t entry) { int s = splvm(); + KASSERT(entry > NR_RESERVED_ENTRIES); KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY); KASSERT(last_gnt_entry >= 0 && last_gnt_entry <= gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE); gnt_entries[last_gnt_entry] = entry;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Wed Dec 11 16:00:46 UTC 2013 Modified Files: src/sys/arch/xen/xen [netbsd-5]: evtchn.c Log Message: Pull up the following revisions(s) (requested by bouyer in ticket #1890): sys/arch/xen/xen/evtchn.c: revision 1.70 Remove the "evtchn_do_event: handler %p didn't lower ipl %d %d\n" printf as analysis shows it actually isn't a bug in the handler, but related to spin mutexes. Fixes port-xen/46313 To generate a diff of this commit: cvs rdiff -u -r1.39.4.2 -r1.39.4.3 src/sys/arch/xen/xen/evtchn.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/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.39.4.2 src/sys/arch/xen/xen/evtchn.c:1.39.4.3 --- src/sys/arch/xen/xen/evtchn.c:1.39.4.2 Fri Nov 14 02:59:39 2008 +++ src/sys/arch/xen/xen/evtchn.c Wed Dec 11 16:00:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.39.4.2 2008/11/14 02:59:39 snj Exp $ */ +/* $NetBSD: evtchn.c,v 1.39.4.3 2013/12/11 16:00:46 sborrill Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -64,7 +64,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.39.4.2 2008/11/14 02:59:39 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.39.4.3 2013/12/11 16:00:46 sborrill Exp $"); #include "opt_xen.h" #include "isa.h" @@ -301,13 +301,6 @@ splx: ih_fun = (void *)ih->ih_fun; ih_fun(ih->ih_arg, regs); cli(); - if (ci->ci_ilevel != i) { - printf("evtchn_do_event: " - "handler %p didn't lower " - "ipl %d %d\n", - ih_fun, ci->ci_ilevel, i); - ci->ci_ilevel = i; - } } hypervisor_enable_ipl(i); /* more pending IPLs may have been registered */
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Mon Sep 28 00:42:34 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbd_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1025): sys/arch/xen/xen/xbd_xenbus.c: revision 1.40 Implement DIOCGDISKINFO for xbd disk driver. To generate a diff of this commit: cvs rdiff -u -r1.34.2.1 -r1.34.2.2 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.34.2.1 src/sys/arch/xen/xen/xbd_xenbus.c:1.34.2.2 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.34.2.1 Sun Mar 8 03:12:50 2009 +++ src/sys/arch/xen/xen/xbd_xenbus.c Mon Sep 28 00:42:34 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.34.2.1 2009/03/08 03:12:50 snj Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.34.2.2 2009/09/28 00:42:34 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.34.2.1 2009/03/08 03:12:50 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.34.2.2 2009/09/28 00:42:34 snj Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -395,6 +395,8 @@ { struct xbd_xenbus_softc *sc = device_private((device_t)arg); struct dk_geom *pdg; + prop_dictionary_t disk_info, odisk_info, geom; + char buf[9]; int s; DPRINTF(("%s: new backend state %d\n", device_xname(sc->sc_dev), new_state)); @@ -454,6 +456,31 @@ /* Discover wedges on this disk. */ dkwedge_discover(&sc->sc_dksc.sc_dkdev); + disk_info = prop_dictionary_create(); + geom = prop_dictionary_create(); + prop_dictionary_set_uint64(geom, "sectors-per-unit", + sc->sc_dksc.sc_size); + prop_dictionary_set_uint32(geom, "sector-size", + pdg->pdg_secsize); + prop_dictionary_set_uint16(geom, "sectors-per-track", + pdg->pdg_nsectors); + prop_dictionary_set_uint16(geom, "tracks-per-cylinder", + pdg->pdg_ntracks); + prop_dictionary_set_uint64(geom, "cylinders-per-unit", + pdg->pdg_ncylinders); + prop_dictionary_set(disk_info, "geometry", geom); + prop_object_release(geom); + prop_dictionary_set(device_properties(sc->sc_dev), + "disk-info", disk_info); + /* + * Don't release disk_info here; we keep a reference to it. + * disk_detach() will release it when we go away. + */ + odisk_info = sc->sc_dksc.sc_dkdev.dk_info; + sc->sc_dksc.sc_dkdev.dk_info = disk_info; + if (odisk_info) + prop_object_release(odisk_info); + /* the disk should be working now */ config_pending_decr(); break; @@ -669,6 +696,10 @@ dksc = &sc->sc_dksc; dk = &dksc->sc_dkdev; + error = disk_ioctl(&sc->sc_dksc.sc_dkdev, cmd, data, flag, l); + if (error != EPASSTHROUGH) + return (error); + switch (cmd) { case DIOCSSTRATEGY: error = EOPNOTSUPP;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Mon Sep 28 01:25:22 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbd_xenbus.c xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1026): sys/arch/xen/xen/xbd_xenbus.c: revision 1.43 via patch sys/arch/xen/xen/xbdback_xenbus.c: revision 1.25 xbdback: implement and publish "feature-flush-cache". xbd: if feature-flush-cache is present, use it for DIOCCACHESYNC. If not present, make DIOCCACHESYNC return EOPNOTSUPP and warn on first call. Should improve WAPBL reliability of Xen guests on a NetBSD dom0. Unfortunably not all linux guests seems to support this feature, and using feature-write-barrier would require a B_BARRIER flag in the buffer. To generate a diff of this commit: cvs rdiff -u -r1.34.2.2 -r1.34.2.3 src/sys/arch/xen/xen/xbd_xenbus.c cvs rdiff -u -r1.20 -r1.20.4.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/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.34.2.2 src/sys/arch/xen/xen/xbd_xenbus.c:1.34.2.3 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.34.2.2 Mon Sep 28 00:42:34 2009 +++ src/sys/arch/xen/xen/xbd_xenbus.c Mon Sep 28 01:25:22 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.34.2.2 2009/09/28 00:42:34 snj Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.34.2.3 2009/09/28 01:25:22 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.34.2.2 2009/09/28 00:42:34 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.34.2.3 2009/09/28 01:25:22 snj Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -85,11 +85,24 @@ struct xbd_req { SLIST_ENTRY(xbd_req) req_next; uint16_t req_id; /* ID passed to backend */ - grant_ref_t req_gntref[BLKIF_MAX_SEGMENTS_PER_REQUEST]; - int req_nr_segments; /* number of segments in this request */ - struct buf *req_bp; /* buffer associated with this request */ - void *req_data; /* pointer to the data buffer */ + union { + struct { + grant_ref_t req_gntref[BLKIF_MAX_SEGMENTS_PER_REQUEST]; + int req_nr_segments; /* number of segments in this request */ + struct buf *req_bp; /* buffer associated with this request */ + void *req_data; /* pointer to the data buffer */ + } req_rw; + struct { + int s_error; + volatile int s_done; + } req_sync; + } u; }; +#define req_gntref u.req_rw.req_gntref +#define req_nr_segments u.req_rw.req_nr_segments +#define req_bp u.req_rw.req_bp +#define req_data u.req_rw.req_data +#define req_sync u.req_sync struct xbd_xenbus_softc { device_t sc_dev; @@ -105,6 +118,7 @@ struct xbd_req sc_reqs[XBD_RING_SIZE]; SLIST_HEAD(,xbd_req) sc_xbdreq_head; /* list of free requests */ + bool sc_xbdreq_wait; /* special waiting on xbd_req */ int sc_backend_status; /* our status with backend */ #define BLKIF_STATE_DISCONNECTED 0 @@ -117,6 +131,7 @@ uint64_t sc_xbdsize; /* size of disk in DEV_BSIZE */ u_long sc_info; /* VDISK_* */ u_long sc_handle; /* from backend */ + int sc_cache_flush; /* backend supports BLKIF_OP_FLUSH_DISKCACHE */ #if NRND > 0 rndsource_element_t sc_rnd_source; #endif @@ -494,6 +509,7 @@ { int err; unsigned long long sectors; + u_long cache_flush; err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_path, "virtual-device", &sc->sc_handle, 10); @@ -517,6 +533,14 @@ if (err) panic("%s: can't read number from %s/sector-size\n", device_xname(sc->sc_dev), sc->sc_xbusd->xbusd_otherend); + err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend, + "feature-flush-cache", &cache_flush, 10); + if (err) + cache_flush = 0; + if (cache_flush > 0) + sc->sc_cache_flush = 1; + else + sc->sc_cache_flush = 0; xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected); } @@ -540,9 +564,16 @@ for (i = sc->sc_ring.rsp_cons; i != resp_prod; i++) { blkif_response_t *rep = RING_GET_RESPONSE(&sc->sc_ring, i); struct xbd_req *xbdreq = &sc->sc_reqs[rep->id]; - bp = xbdreq->req_bp; DPRINTF(("xbd_handler(%p): b_bcount = %ld\n", - bp, (long)bp->b_bcount)); + xbdreq->req_bp, (long)bp->b_bcount)); + bp = xbdreq->req_bp; + if (rep->operation == BLKIF_OP_FLUSH_DISKCACHE) { + xbdreq->req_sync.s_error = rep->status; + xbdreq->req_sync.s_done = 1; + wakeup(xbdreq); + /* caller will free the req */ + continue; + } for (seg = xbdreq->req_nr_segments - 1; seg >= 0; seg--) { if (__predict_false( xengnt_status(xbdreq->req_gntref[seg]))) { @@ -584,13 +615,15 @@ biodone(bp); SLIST_INSERT_HEAD(&sc->sc_xbdreq_head, xbdreq, req_next); } +done: x86_lfence(); sc->sc_ring.rsp_cons = i; RING_FINAL_CHECK_FOR_RESPONSES(&sc->sc_ring, more_to_do); if (more_to_do) goto again; -done: dk_iodone(sc->sc_di, &sc->sc_dksc); + if (sc->sc_xbd
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Mon Sep 28 01:31:46 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1027): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.36 Patch from Brian Marcotte on port-xen@: write a "feature-rx-notify" to the xenstore, which is used by recent linux dom0 kernels. This reduce packet loss when using a NetBSD domU on such linux dom0. This entry is ignored by NetBSD and older linux domUs. To generate a diff of this commit: cvs rdiff -u -r1.29.2.2 -r1.29.2.3 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.29.2.2 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.3 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.2 Wed May 13 01:05:20 2009 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Mon Sep 28 01:31:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.2 2009/05/13 01:05:20 snj Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.3 2009/09/28 01:31:46 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.2 2009/05/13 01:05:20 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.3 2009/09/28 01:31:46 snj Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -467,6 +467,12 @@ goto abort_transaction; } error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path, + "feature-rx-notify", "%u", 1); + if (error) { + errmsg = "writing feature-rx-notify"; + goto abort_transaction; + } + error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path, "event-channel", "%u", sc->sc_evtchn); if (error) { errmsg = "writing event channel";
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Mon Sep 28 01:46:48 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xennetback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1030): sys/arch/xen/xen/xennetback_xenbus.c: revision 1.29 via patch Announce feature-rx-copy and feature-rx-flip. Add support for request-rx-copy. Tested with a Debian lenny install. Should fix PR port-xen/40650 To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.24.4.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.24 src/sys/arch/xen/xen/xennetback_xenbus.c:1.24.4.1 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.24 Fri Oct 24 18:02:58 2008 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Mon Sep 28 01:46:48 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.24 2008/10/24 18:02:58 jym Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.24.4.1 2009/09/28 01:46:48 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -131,7 +131,8 @@ void xvifattach(int); static int xennetback_ifioctl(struct ifnet *, u_long, void *); static void xennetback_ifstart(struct ifnet *); -static void xennetback_ifsoftstart(void *); +static void xennetback_ifsoftstart_transfer(void *); +static void xennetback_ifsoftstart_copy(void *); static void xennetback_ifwatchdog(struct ifnet *); static int xennetback_ifinit(struct ifnet *); static void xennetback_ifstop(struct ifnet *, int); @@ -182,7 +183,8 @@ /* arrays used in xennetback_ifstart(), too large to allocate on stack */ 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[NB_XMIT_PAGES_BATCH]; +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 { vaddr_t va; @@ -244,6 +246,7 @@ extern int ifqmaxlen; /* XXX */ char *val, *e, *p; int i, err; + struct xenbus_transaction *xbt; if ((err = xenbus_read_ul(NULL, xbusd->xbusd_path, "frontend-id", &domid, 10)) != 0) { @@ -274,13 +277,6 @@ xbusd->xbusd_u.b.b_detach = xennetback_xenbus_destroy; xneti->xni_xbusd = xbusd; - xneti->xni_softintr = softint_establish(SOFTINT_NET, - xennetback_ifsoftstart, xneti); - if (xneti->xni_softintr == NULL) { - err = ENOMEM; - goto fail; - } - ifp = &xneti->xni_if; ifp->if_softc = xneti; @@ -328,6 +324,33 @@ xbusd->xbusd_otherend_changed = xennetback_frontend_changed; + do { + xbt = xenbus_transaction_start(); + if (xbt == NULL) { + printf("xbdback %s: can't start transaction\n", + xbusd->xbusd_path); + goto fail; + } + err = xenbus_printf(xbt, xbusd->xbusd_path, + "feature-rx-copy", "%d", 1); + if (err) { + printf("xbdback: failed to write %s/feature-rx-copy: " + "%d\n", xbusd->xbusd_path, err); + goto abort_xbt; + } + err = xenbus_printf(xbt, xbusd->xbusd_path, + "feature-rx-flip", "%d", 1); + if (err) { + printf("xbdback: failed to write %s/feature-rx-flip: " + "%d\n", xbusd->xbusd_path, err); + goto abort_xbt; + } + } while ((err = xenbus_transaction_end(xbt, 0)) == EAGAIN); + if (err) { + printf("xbdback %s: can't end transaction: %d\n", + xbusd->xbusd_path, err); + } + err = xenbus_switch_state(xbusd, NULL, XenbusStateInitWait); if (err) { printf("failed to switch state on %s: %d\n", @@ -340,6 +363,8 @@ goto fail; } return 0; +abort_xbt: + xenbus_transaction_end(xbt, 1); fail: free(xneti, M_DEVBUF); return err; @@ -407,7 +432,7 @@ struct gnttab_map_grant_ref op; evtchn_op_t evop; u_long tx_ring_ref, rx_ring_ref; - u_long revtchn; + u_long revtchn, rx_copy; XENPRINTF(("%s: new state %d\n", xneti->xni_if.if_xname, new_state)); switch(new_state) { @@ -438,6 +463,29 @@ xbusd->xbusd_otherend); break; } + err = xenbus_read_ul(NULL, xbusd->xbusd_otherend, + "request-rx-copy", &rx_copy, 10); + if (err == ENOENT) + rx_copy = 0; + else if (err) { + xenbus_dev_fatal(xbusd, err, "reading %s/request-rx-copy", + xbusd->xbusd_otherend); + break; + } + + if (rx_copy) + xneti->xni_softintr = softint_establish(SOFTINT_NET, + xennetback_ifsoftstart_copy, xneti); + else + xneti->xni_softintr = softint_establish(SOFTINT_NET, + xennetback_ifsoftstart_transfer, xneti); + if (xneti->xni_softintr == NULL) { + err = ENOMEM; + xenbus_dev_fatal(xbusd, ENOMEM, + "can't allocate softint", xbusd->xbusd_otherend); + break; + } + /* allocate VA space and map rings */ xneti->xni_tx_ring_va = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY); @@ -830,13 +878,13 @@
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Mon Sep 28 01:47:49 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xennetback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1030): sys/arch/xen/xen/xennetback_xenbus.c: revision 1.30 Don't disestablish a soft interrupt which has not been established. To generate a diff of this commit: cvs rdiff -u -r1.24.4.1 -r1.24.4.2 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.24.4.1 src/sys/arch/xen/xen/xennetback_xenbus.c:1.24.4.2 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.24.4.1 Mon Sep 28 01:46:48 2009 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Mon Sep 28 01:47:49 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.24.4.1 2009/09/28 01:46:48 snj Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.24.4.2 2009/09/28 01:47:49 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -385,7 +385,10 @@ aprint_verbose_ifnet(&xneti->xni_if, "disconnecting\n"); hypervisor_mask_event(xneti->xni_evtchn); event_remove_handler(xneti->xni_evtchn, xennetback_evthandler, xneti); - softint_disestablish(xneti->xni_softintr); + if (xneti->xni_softintr) { + softint_disestablish(xneti->xni_softintr); + xneti->xni_softintr = NULL; + } SLIST_REMOVE(&xnetback_instances, xneti, xnetback_instance, next);
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sat Oct 3 23:56:43 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: pciback.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1054): sys/arch/xen/xen/pciback.c: revision 1.2 - xentools also use pci vendor/product id and subsystem id; export them via the kernfs file - EVTCHNOP_bind_pirq wants the legacy IRQ number; so always set the legacy IRQ number in the PCI_INTERRUPT_REG. To generate a diff of this commit: cvs rdiff -u -r1.4.6.2 -r1.4.6.3 src/sys/arch/xen/xen/pciback.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/pciback.c diff -u src/sys/arch/xen/xen/pciback.c:1.4.6.2 src/sys/arch/xen/xen/pciback.c:1.4.6.3 --- src/sys/arch/xen/xen/pciback.c:1.4.6.2 Sat Oct 3 23:54:05 2009 +++ src/sys/arch/xen/xen/pciback.c Sat Oct 3 23:56:43 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pciback.c,v 1.4.6.2 2009/10/03 23:54:05 snj Exp $ */ +/* $NetBSD: pciback.c,v 1.4.6.3 2009/10/03 23:56:43 snj Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.4.6.2 2009/10/03 23:54:05 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.4.6.3 2009/10/03 23:56:43 snj Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -105,6 +105,8 @@ } sc_bars[PCI_NBARS]; pci_intr_handle_t sc_intrhandle; int sc_irq; + pcireg_t sc_id; + pcireg_t sc_subid; char sc_kernfsname[16]; }; @@ -187,7 +189,7 @@ SLIST_ENTRY(pb_xenbus_instance) pbx_next; /* list of backend instances*/ struct xenbus_device *pbx_xbusd; domid_t pbx_domid; - struct pciback_pci_devlist pbx_pb_pci_dev; /* list of exported PCi devices */ + struct pciback_pci_devlist pbx_pb_pci_dev; /* list of exported PCI devices */ /* communication with the domU */ unsigned int pbx_evtchn; /* our even channel */ struct xen_pci_sharedinfo *pbx_sh_info; @@ -237,6 +239,9 @@ sc->sc_pb->pb_pc = pa->pa_pc; sc->sc_pb->pb_tag = pa->pa_tag; + sc->sc_id = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_ID_REG); + sc->sc_subid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG); + for (i = 0; i < PCI_NBARS;) { sc->sc_bars[i].b_type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START + i * 4); @@ -267,11 +272,7 @@ aprint_normal_dev(self, "interrupting at %s\n", intrstr ? intrstr : "unknown interrupt"); } - if (sc->sc_intrhandle.pirq & APIC_INT_VIA_APIC) { - sc->sc_irq = APIC_IRQ_PIN(sc->sc_intrhandle.pirq); - } else { - sc->sc_irq = APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle.pirq); - } + sc->sc_irq = APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle.pirq); /* XXX should be done elsewhere ? */ reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_INTERRUPT_REG); reg &= ~ (PCI_INTERRUPT_LINE_MASK << PCI_INTERRUPT_LINE_SHIFT); @@ -314,6 +315,12 @@ off = uio->uio_offset; len = 0; + len += snprintf(&buf[len], PCIBACK_KERNFS_SIZE - len, + "vendor: 0x%04x\nproduct: 0x%04x\n", + PCI_VENDOR(sc->sc_id), PCI_PRODUCT(sc->sc_id)); + len += snprintf(&buf[len], PCIBACK_KERNFS_SIZE - len, + "subsys_vendor: 0x%04x\nsubsys_product: 0x%04x\n", + PCI_VENDOR(sc->sc_subid), PCI_PRODUCT(sc->sc_subid)); for(i = 0; i < PCI_NBARS; i++) { if (sc->sc_bars[i].b_valid) { len += snprintf(&buf[len], PCIBACK_KERNFS_SIZE - len, @@ -776,6 +783,7 @@ op->err = XEN_PCI_ERR_invalid_offset; break; } + break; default: aprint_error("pciback: unknown cmd %d\n", op->cmd); op->err = XEN_PCI_ERR_not_implemented;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sat Oct 3 23:58:47 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: pciback.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1054): sys/arch/xen/xen/pciback.c: revision 1.3 Unbind the event channel after mapping the interrupt. Otherwise domain0 will share the interrupt with the domU and xen will wait for domain0 to ack the interrupt too. Now devices that don't share an interrupt with a device in domain0 works too. Make sure the same PCI bus isn't published multiple times. To generate a diff of this commit: cvs rdiff -u -r1.4.6.3 -r1.4.6.4 src/sys/arch/xen/xen/pciback.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/pciback.c diff -u src/sys/arch/xen/xen/pciback.c:1.4.6.3 src/sys/arch/xen/xen/pciback.c:1.4.6.4 --- src/sys/arch/xen/xen/pciback.c:1.4.6.3 Sat Oct 3 23:56:43 2009 +++ src/sys/arch/xen/xen/pciback.c Sat Oct 3 23:58:47 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pciback.c,v 1.4.6.3 2009/10/03 23:56:43 snj Exp $ */ +/* $NetBSD: pciback.c,v 1.4.6.4 2009/10/03 23:58:47 snj Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.4.6.3 2009/10/03 23:56:43 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.4.6.4 2009/10/03 23:58:47 snj Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -272,6 +272,7 @@ aprint_normal_dev(self, "interrupting at %s\n", intrstr ? intrstr : "unknown interrupt"); } + unbind_pirq_from_evtch(APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle.pirq)); sc->sc_irq = APIC_IRQ_LEGACY_IRQ(sc->sc_intrhandle.pirq); /* XXX should be done elsewhere ? */ reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_INTERRUPT_REG); @@ -700,6 +701,7 @@ err); } num_roots++; + bus[pbd->pb_bus]++; } } err = xenbus_printf(NULL, pbxi->pbx_xbusd->xbusd_path, "root_num",
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sat Oct 3 23:59:33 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: pciback.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1054): sys/arch/xen/xen/pciback.c: revision 1.4 Move a message to debug To generate a diff of this commit: cvs rdiff -u -r1.4.6.4 -r1.4.6.5 src/sys/arch/xen/xen/pciback.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/pciback.c diff -u src/sys/arch/xen/xen/pciback.c:1.4.6.4 src/sys/arch/xen/xen/pciback.c:1.4.6.5 --- src/sys/arch/xen/xen/pciback.c:1.4.6.4 Sat Oct 3 23:58:47 2009 +++ src/sys/arch/xen/xen/pciback.c Sat Oct 3 23:59:32 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pciback.c,v 1.4.6.4 2009/10/03 23:58:47 snj Exp $ */ +/* $NetBSD: pciback.c,v 1.4.6.5 2009/10/03 23:59:32 snj Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.4.6.4 2009/10/03 23:58:47 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.4.6.5 2009/10/03 23:59:32 snj Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -739,7 +739,7 @@ break; } if (pbd == NULL) { - aprint_error("pciback: %02x:%02x.%x not found\n", + aprint_debug("pciback: %02x:%02x.%x not found\n", bus, dev, func); op->err = XEN_PCI_ERR_dev_not_found; goto end;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sun Oct 4 00:00:14 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xpci_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1054): sys/arch/xen/xen/xpci_xenbus.c: revision 1.2 Don't emulate a cold boot here, this breaks drivers using config_interrupt(). To generate a diff of this commit: cvs rdiff -u -r1.2.6.2 -r1.2.6.3 src/sys/arch/xen/xen/xpci_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/xpci_xenbus.c diff -u src/sys/arch/xen/xen/xpci_xenbus.c:1.2.6.2 src/sys/arch/xen/xen/xpci_xenbus.c:1.2.6.3 --- src/sys/arch/xen/xen/xpci_xenbus.c:1.2.6.2 Sat Oct 3 23:54:05 2009 +++ src/sys/arch/xen/xen/xpci_xenbus.c Sun Oct 4 00:00:14 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xpci_xenbus.c,v 1.2.6.2 2009/10/03 23:54:05 snj Exp $ */ +/* $NetBSD: xpci_xenbus.c,v 1.2.6.3 2009/10/04 00:00:14 snj Exp $ */ /* * Copyright (c) 2009 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xpci_xenbus.c,v 1.2.6.2 2009/10/03 23:54:05 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xpci_xenbus.c,v 1.2.6.3 2009/10/04 00:00:14 snj Exp $"); #include "opt_xen.h" #include "rnd.h" @@ -336,7 +336,7 @@ char node[10]; u_long busn; int i; - int s, oldcold; + int s; err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend, "root_num", &num_roots, 10); @@ -372,10 +372,7 @@ "%s is not a number\n", bus); else { s = splhigh(); -oldcold = cold; -cold = 1; xpci_attach_pcibus(0, busn); -cold = oldcold; splx(s); } }
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sun Oct 4 00:04:08 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: pci_intr_machdep.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1054): sys/arch/xen/xen/pci_intr_machdep.c: revision 1.10 Keep the BIOS-configured interrupt number if intr_find_mpmapping() doesn't return a APIC_INT_VIA_APIC pirq. Problem debugged and patch tested by jym@ To generate a diff of this commit: cvs rdiff -u -r1.7.6.2 -r1.7.6.3 src/sys/arch/xen/xen/pci_intr_machdep.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/pci_intr_machdep.c diff -u src/sys/arch/xen/xen/pci_intr_machdep.c:1.7.6.2 src/sys/arch/xen/xen/pci_intr_machdep.c:1.7.6.3 --- src/sys/arch/xen/xen/pci_intr_machdep.c:1.7.6.2 Sun Oct 4 00:03:20 2009 +++ src/sys/arch/xen/xen/pci_intr_machdep.c Sun Oct 4 00:04:08 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.7.6.2 2009/10/04 00:03:20 snj Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.7.6.3 2009/10/04 00:04:08 snj Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.7.6.2 2009/10/04 00:03:20 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.7.6.3 2009/10/04 00:04:08 snj Exp $"); #include #include @@ -109,8 +109,12 @@ pci_decompose_tag(pc, pa->pa_tag, &bus, &dev, &func); if (mp_busses != NULL) { if (intr_find_mpmapping(bus, (dev<<2)|(rawpin-1), ihp) == 0) { - /* make sure a new IRQ will be allocated */ - ihp->pirq &= ~0xff; + if (ihp->pirq & APIC_INT_VIA_APIC) { +/* make sure a new IRQ will be allocated */ +ihp->pirq &= ~0xff; + } else { +ihp->pirq |= line; + } goto end; } /*
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sun Oct 4 00:02:00 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: hypervisor.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1054): sys/arch/xen/xen/hypervisor.c: revision 1.45 Make sure xenkernfs_init() is called for XEN2 too. To generate a diff of this commit: cvs rdiff -u -r1.42.4.2 -r1.42.4.3 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.2 src/sys/arch/xen/xen/hypervisor.c:1.42.4.3 --- src/sys/arch/xen/xen/hypervisor.c:1.42.4.2 Sat Oct 3 23:54:05 2009 +++ src/sys/arch/xen/xen/hypervisor.c Sun Oct 4 00:02:00 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.42.4.2 2009/10/03 23:54:05 snj Exp $ */ +/* $NetBSD: hypervisor.c,v 1.42.4.3 2009/10/04 00:02:00 snj Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -63,7 +63,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.2 2009/10/03 23:54:05 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.3 2009/10/04 00:02:00 snj Exp $"); #include #include @@ -240,17 +240,17 @@ #endif /* NPCI */ union hypervisor_attach_cookie hac; +#ifdef DOM0OPS + if (xendomain_is_privileged()) { + xenkernfs_init(); + } +#endif #ifdef XEN3 xen_version = HYPERVISOR_xen_version(XENVER_version, NULL); aprint_normal(": Xen version %d.%d\n", (xen_version & 0x) >> 16, xen_version & 0x); xengnt_init(); -#ifdef DOM0OPS - if (xendomain_is_privileged()) { - xenkernfs_init(); - } -#endif memset(&hac.hac_vcaa, 0, sizeof(hac.hac_vcaa)); hac.hac_vcaa.vcaa_name = "vcpu";
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Fri Oct 16 07:04:37 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1093): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.26 Don't pass a NULL arg to DIOCCACHESYNC, sd(4) dereferences it. Pass a pointer to a int initialized to 1, so that a DIOCCACHESYNC will be forced on sd(4). Should fix dom0 panic reported by Sarton O'Brien. To generate a diff of this commit: cvs rdiff -u -r1.20.4.1 -r1.20.4.2 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.20.4.1 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.2 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.1 Mon Sep 28 01:25:22 2009 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Fri Oct 16 07:04:37 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.1 2009/09/28 01:25:22 snj Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.2 2009/10/16 07:04:37 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.1 2009/09/28 01:25:22 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.2 2009/10/16 07:04:37 snj Exp $"); #include #include @@ -1313,9 +1313,10 @@ if (xbd_io->xio_operation == BLKIF_OP_FLUSH_DISKCACHE) { int error; + int force = 1; struct xbdback_instance *xbdi = xbd_io->xio_xbdi; - error = VOP_IOCTL(xbdi->xbdi_vp, DIOCCACHESYNC, NULL, FWRITE, + error = VOP_IOCTL(xbdi->xbdi_vp, DIOCCACHESYNC, &force, FWRITE, kauth_cred_get()); if (error) { aprint_error("xbdback %s: DIOCCACHESYNC returned %d\n",
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Sat Oct 31 12:53:22 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up the following revisions(s) (requested by bouyer in ticket #1117): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.28 Fix stalled xbdback detach that would stall the whole xenbus thread, preventing new domU from be created. To generate a diff of this commit: cvs rdiff -u -r1.20.4.2 -r1.20.4.3 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.20.4.2 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.3 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.2 Fri Oct 16 07:04:37 2009 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Sat Oct 31 12:53:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.2 2009/10/16 07:04:37 snj Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.3 2009/10/31 12:53:21 sborrill Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.2 2009/10/16 07:04:37 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.3 2009/10/31 12:53:21 sborrill Exp $"); #include #include @@ -989,6 +989,7 @@ if (xbdi->xbdi_pendingreqs > 0) { /* event or iodone will restart processing */ xbdi->xbdi_cont = NULL; + xbdi_put(xbdi); return NULL; } xbdi->xbdi_cont = xbdback_co_cache_doflush;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Wed May 13 01:05:21 UTC 2009 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c Log Message: Pull up following revision(s) (requested by jym in ticket #754): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.35 Do not forget to detach rnd(4) device when removing a xennet device. Ok by bouyer@ in private mail. To generate a diff of this commit: cvs rdiff -u -r1.29.2.1 -r1.29.2.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.29.2.1 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.2 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.1 Sun Mar 8 03:12:50 2009 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Wed May 13 01:05:20 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.1 2009/03/08 03:12:50 snj Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.2 2009/05/13 01:05:20 snj Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.1 2009/03/08 03:12:50 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.2 2009/05/13 01:05:20 snj Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -381,6 +381,12 @@ ether_ifdetach(ifp); if_detach(ifp); + +#if NRND > 0 + /* Unhook the entropy source. */ + rnd_detach_source(&sc->sc_rnd_source); +#endif + while (xengnt_status(sc->sc_tx_ring_gntref)) { tsleep(xennet_xenbus_detach, PRIBIO, "xnet_txref", hz/2); }
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sat Jun 18 16:38:27 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by jym in ticket #1630): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.37 In xbdback(4), move the code that copies segments after the bound checks of the ``nr_segments'' variable. In cases where we are running domUs with an architecture different from the dom0 one (for example: 32 bits domUs on 64 bits dom0), copying segments with an invalid nr_segments value will lead to the corruption of the xbdback instance structure and quickly crash the dom0 backend. Tested under 64 bits dom0 with 32 bits domUs. No regression observed. ok bouyer@. Will be pulled up to -4 and -5. To generate a diff of this commit: cvs rdiff -u -r1.20.4.4 -r1.20.4.5 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.20.4.4 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.5 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.4 Mon Mar 7 04:19:13 2011 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Sat Jun 18 16:38:26 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.4 2011/03/07 04:19:13 riz Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.5 2011/06/18 16:38:26 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.4 2011/03/07 04:19:13 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.5 2011/06/18 16:38:26 bouyer Exp $"); #include #include @@ -869,7 +869,6 @@ blkif_request_t *req = &xbdi->xbdi_xen_req; blkif_x86_32_request_t *req32; blkif_x86_64_request_t *req64; - int i; (void)obj; if (xbdi->xbdi_ring.ring_n.req_cons != xbdi->xbdi_req_prod) { @@ -887,8 +886,6 @@ req->handle = req32->handle; req->id = req32->id; req->sector_number = req32->sector_number; - for (i = 0; i < req->nr_segments; i++) -req->seg[i] = req32->seg[i]; break; case XBDIP_64: @@ -899,8 +896,6 @@ req->handle = req64->handle; req->id = req64->id; req->sector_number = req64->sector_number; - for (i = 0; i < req->nr_segments; i++) -req->seg[i] = req64->seg[i]; break; } XENPRINTF(("xbdback op %d req_cons 0x%x req_prod 0x%x " @@ -1015,16 +1010,23 @@ static void * xbdback_co_io(struct xbdback_instance *xbdi, void *obj) { - int error; + int i, error; + blkif_request_t *req; + blkif_x86_32_request_t *req32; + blkif_x86_64_request_t *req64; (void)obj; - if (xbdi->xbdi_xen_req.nr_segments < 1 || - xbdi->xbdi_xen_req.nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST ) { + + /* some sanity checks */ + req = &xbdi->xbdi_xen_req; + if (req->nr_segments < 1 || + req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST) { printf("xbdback_io domain %d: %d segments\n", xbdi->xbdi_domid, xbdi->xbdi_xen_req.nr_segments); error = EINVAL; goto end; } + if (xbdi->xbdi_xen_req.operation == BLKIF_OP_WRITE) { if (xbdi->xbdi_ro) { error = EROFS; @@ -1034,6 +1036,25 @@ xbdi->xbdi_segno = 0; + /* copy request segments */ + switch(xbdi->xbdi_proto) { + case XBDIP_NATIVE: + /* already copied in xbdback_co_main_loop */ + break; + case XBDIP_32: + req32 = RING_GET_REQUEST(&xbdi->xbdi_ring.ring_32, + xbdi->xbdi_ring.ring_n.req_cons); + for (i = 0; i < req->nr_segments; i++) + req->seg[i] = req32->seg[i]; + break; + case XBDIP_64: + req64 = RING_GET_REQUEST(&xbdi->xbdi_ring.ring_64, + xbdi->xbdi_ring.ring_n.req_cons); + for (i = 0; i < req->nr_segments; i++) + req->seg[i] = req64->seg[i]; + break; + } + xbdi->xbdi_cont = xbdback_co_io_gotreq; return xbdback_pool_get(&xbdback_request_pool, xbdi); end:
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: riz Date: Mon Mar 7 04:19:14 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1573): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.33 Test and set xbdi->xbdi_cont at splbio(). Otherwise we could overwrite xbdi->xbdi_cont and process the same request twice. To generate a diff of this commit: cvs rdiff -u -r1.20.4.3 -r1.20.4.4 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.20.4.3 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.4 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.3 Sat Oct 31 12:53:21 2009 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Mon Mar 7 04:19:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.3 2009/10/31 12:53:21 sborrill Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.4 2011/03/07 04:19:13 riz Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.3 2009/10/31 12:53:21 sborrill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.4 2011/03/07 04:19:13 riz Exp $"); #include #include @@ -1376,6 +1376,7 @@ struct xbdback_io *xbd_io; struct xbdback_instance *xbdi; int errp; + int s; xbd_io = bp->b_private; xbdi = xbd_io->xio_xbdi; @@ -1430,11 +1431,13 @@ atomic_dec_uint(&xbdi->xbdi_pendingreqs); buf_destroy(&xbd_io->xio_buf); xbdback_pool_put(&xbdback_io_pool, xbd_io); + s = splbio(); if (xbdi->xbdi_cont == NULL) { /* check if there is more work to do */ xbdi->xbdi_cont = xbdback_co_main; xbdback_trampoline(xbdi, xbdi); } + splx(s); } /*
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu May 19 21:11:15 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c Log Message: Pull up following revision(s) (requested by jym in ticket #1608): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.49 Separate xennet(4) backend initialization code ("resume") from the part that talks with Xenstore to query backend's information. Resuming is now performed just after xennet(4) attachment instead of waiting for backend to announce its features in Xenstore and change it state. This fixes the race observed by Urban Boquist when the domU boots with root on NFS. FWIW, the boot code (when root is NFS-backed) can innit() the xennet(4) interface very early: it tried to access ifnet structures that were not yet allocated. Will ask for a pullup. Thanks to Urban for reporting the issue and investigate it. Confirmed fixed. No regression observed by me for dynamic attach/detach of xvif(4) and xennet(4) interfaces. See also http://mail-index.netbsd.org/port-xen/2011/04/18/msg006647.html To generate a diff of this commit: cvs rdiff -u -r1.29.2.4 -r1.29.2.5 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.29.2.4 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.5 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.4 Sun Nov 21 23:55:58 2010 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Thu May 19 21:11:15 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.4 2010/11/21 23:55:58 riz Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.5 2011/05/19 21:11:15 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.4 2010/11/21 23:55:58 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.5 2011/05/19 21:11:15 bouyer Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -203,6 +203,7 @@ static void xennet_tx_complete(struct xennet_xenbus_softc *); static void xennet_rx_mbuf_free(struct mbuf *, void *, size_t, void *); static int xennet_handler(void *); +static int xennet_talk_to_backend(struct xennet_xenbus_softc *); #ifdef XENNET_DEBUG_DUMP static void xennet_hex_dump(const unsigned char *, size_t, const char *, int); #endif @@ -350,6 +351,9 @@ rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev), RND_TYPE_NET, 0); #endif + + /* resume shared structures and tell backend that we are ready */ + xennet_xenbus_resume(sc); } static int @@ -410,13 +414,10 @@ xennet_xenbus_resume(void *p) { struct xennet_xenbus_softc *sc = p; - struct xenbus_transaction *xbt; - unsigned long rx_copy; int error; netif_tx_sring_t *tx_ring; netif_rx_sring_t *rx_ring; paddr_t ma; - const char *errmsg; sc->sc_tx_ring_gntref = GRANT_INVALID_REF; sc->sc_rx_ring_gntref = GRANT_INVALID_REF; @@ -450,6 +451,17 @@ event_set_handler(sc->sc_evtchn, &xennet_handler, sc, IPL_NET, device_xname(sc->sc_dev)); + return 0; +} + +static int +xennet_talk_to_backend(struct xennet_xenbus_softc *sc) +{ + int error; + unsigned long rx_copy; + struct xenbus_transaction *xbt; + const char *errmsg; + error = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend, "feature-rx-copy", &rx_copy, 10); if (error) @@ -529,7 +541,7 @@ xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateClosed); break; case XenbusStateInitWait: - if (xennet_xenbus_resume(sc) == 0) + if (xennet_talk_to_backend(sc) == 0) xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected); break;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu May 19 21:13:07 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c xennetback_xenbus.c Log Message: Pull up following revision(s) (requested by jym in ticket #1609): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.50 sys/arch/xen/xen/xennetback_xenbus.c: revision 1.43 Check that xvif(4) is not already connected before proceeding in the XenbusStateConnected mode. Under rare occasions, the xenbus watcher can fire multiple times, overwriting the I/O ring memory mappings with invalid values. This will lead sooner or later to dom0 panic(). Will ask for pullup. FWIW, xbdback(4) is not affected. Check status before proceeding further. Avoids spurious watch calls. To generate a diff of this commit: cvs rdiff -u -r1.29.2.5 -r1.29.2.6 src/sys/arch/xen/xen/if_xennet_xenbus.c cvs rdiff -u -r1.24.4.3 -r1.24.4.4 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/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.5 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.6 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.5 Thu May 19 21:11:15 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Thu May 19 21:13:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.5 2011/05/19 21:11:15 bouyer Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.6 2011/05/19 21:13:07 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.5 2011/05/19 21:11:15 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.6 2011/05/19 21:13:07 bouyer Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -541,6 +541,8 @@ xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateClosed); break; case XenbusStateInitWait: + if (sc->sc_backend_status == BEST_CONNECTED) + break; if (xennet_talk_to_backend(sc) == 0) xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected); Index: src/sys/arch/xen/xen/xennetback_xenbus.c diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.24.4.3 src/sys/arch/xen/xen/xennetback_xenbus.c:1.24.4.4 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.24.4.3 Sat Jan 30 19:14:20 2010 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Thu May 19 21:13:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.24.4.3 2010/01/30 19:14:20 snj Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.24.4.4 2011/05/19 21:13:07 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -444,6 +444,8 @@ break; case XenbusStateConnected: + if (xneti->xni_status == CONNECTED) + break; /* read comunication informations */ err = xenbus_read_ul(NULL, xbusd->xbusd_otherend, "tx-ring-ref", &tx_ring_ref, 10);
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Mon Sep 26 09:56:55 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: hypervisor.c Log Message: Patch to fix build on Xen 2 (fallout from pullup #1672) To generate a diff of this commit: cvs rdiff -u -r1.42.4.4 -r1.42.4.5 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.4 src/sys/arch/xen/xen/hypervisor.c:1.42.4.5 --- src/sys/arch/xen/xen/hypervisor.c:1.42.4.4 Fri Sep 23 12:44:51 2011 +++ src/sys/arch/xen/xen/hypervisor.c Mon Sep 26 09:56:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.42.4.4 2011/09/23 12:44:51 sborrill Exp $ */ +/* $NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -63,7 +63,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.4 2011/09/23 12:44:51 sborrill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $"); #include #include @@ -100,7 +100,6 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c #include #endif -#if defined(DOM0OPS) || defined(XEN3) #include #include #include @@ -108,6 +107,7 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c #include #include #include +#if defined(DOM0OPS) || defined(XEN3) #include #endif /* DOM0OPS || XEN3 */ #ifdef XEN3
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: riz Date: Wed Nov 2 20:30:41 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1682): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.45 Guard against spurious xbdback_backend_changed() calls which would result in the block device being opened twice. Fixes port-xen/45158, although the underlying cause (multiple open of the same device not properly handled any more) is not fixed. To generate a diff of this commit: cvs rdiff -u -r1.20.4.6 -r1.20.4.7 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.20.4.6 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.7 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.6 Fri Aug 12 20:48:47 2011 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Wed Nov 2 20:30:41 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.7 2011/11/02 20:30:41 riz Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.7 2011/11/02 20:30:41 riz Exp $"); #include #include @@ -674,10 +674,16 @@ xbdback_backend_changed(struct xenbus_wa */ if (err) return; - if (xbdi->xbdi_status == CONNECTED && xbdi->xbdi_dev != dev) { - printf("xbdback %s: changing physical device from 0x%x to " - "0x%lx not supported\n", xbusd->xbusd_path, xbdi->xbdi_dev, - dev); + /* + * we can also fire up after having opened the device, don't try + * to do it twice. + */ + if (xbdi->xbdi_vp != NULL) { + if (xbdi->xbdi_status == CONNECTED && xbdi->xbdi_dev != dev) { + printf("xbdback %s: changing physical device from " + "0x%x to 0x%lx not supported\n", + xbusd->xbusd_path, xbdi->xbdi_dev, dev); + } return; } xbdi->xbdi_dev = dev;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: riz Date: Wed Nov 2 20:34:52 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1685): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.48 Fix bogus KASSERT: if there is a xbdi_io, xbdi_pendingreqs must *NOT* be 0. Not sure why it has stayed unoticed for so long ... To generate a diff of this commit: cvs rdiff -u -r1.20.4.7 -r1.20.4.8 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.20.4.7 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.8 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.7 Wed Nov 2 20:30:41 2011 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Wed Nov 2 20:34:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.7 2011/11/02 20:30:41 riz Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.8 2011/11/02 20:34:52 riz Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.7 2011/11/02 20:30:41 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.8 2011/11/02 20:34:52 riz Exp $"); #include #include @@ -981,7 +981,7 @@ xbdback_co_cache_flush(struct xbdback_in /* Some I/Os are required for this instance. Process them. */ KASSERT(xbdi->xbdi_io->xio_operation == BLKIF_OP_READ || xbdi->xbdi_io->xio_operation == BLKIF_OP_WRITE); - KASSERT(xbdi->xbdi_pendingreqs == 0); + KASSERT(xbdi->xbdi_pendingreqs > 0); xbdi->xbdi_cont = xbdback_co_flush; xbdi->xbdi_cont_aux = xbdback_co_cache_flush2; } else {
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sat Jan 30 19:12:26 UTC 2010 Modified Files: src/sys/arch/xen/xen [netbsd-5]: privcmd.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1271): sys/arch/xen/xen/privcmd.c: revision 1.40 Use paddr_t to store physical address and cast mfn values to paddr_t before shift. Fix overflow issue preventing xend from working as reported by Mark Davies on port-xen@ To generate a diff of this commit: cvs rdiff -u -r1.33.4.1 -r1.33.4.2 src/sys/arch/xen/xen/privcmd.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/privcmd.c diff -u src/sys/arch/xen/xen/privcmd.c:1.33.4.1 src/sys/arch/xen/xen/privcmd.c:1.33.4.2 --- src/sys/arch/xen/xen/privcmd.c:1.33.4.1 Sun Mar 8 03:19:50 2009 +++ src/sys/arch/xen/xen/privcmd.c Sat Jan 30 19:12:26 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: privcmd.c,v 1.33.4.1 2009/03/08 03:19:50 snj Exp $ */ +/* $NetBSD: privcmd.c,v 1.33.4.2 2010/01/30 19:12:26 snj Exp $ */ /*- * Copyright (c) 2004 Christian Limpach. @@ -32,7 +32,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.33.4.1 2009/03/08 03:19:50 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.33.4.2 2010/01/30 19:12:26 snj Exp $"); #include "opt_compat_netbsd.h" @@ -362,7 +362,7 @@ privcmd_mmap_t *mcmd = ap->a_data; privcmd_mmap_entry_t mentry; vaddr_t va; - u_long ma; + paddr_t ma; struct vm_map *vmm = &curlwp->l_proc->p_vmspace->vm_map; for (i = 0; i < mcmd->num; i++) { @@ -383,7 +383,7 @@ if (maddr == NULL) return ENOMEM; va = mentry.va & ~PAGE_MASK; - ma = mentry.mfn << PGSHIFT; /* XXX ??? */ + ma = ((paddr_t)mentry.mfn) << PGSHIFT; /* XXX ??? */ for (j = 0; j < mentry.npages; j++) { maddr[j] = ma; ma += PAGE_SIZE; @@ -400,7 +400,8 @@ int i; privcmd_mmapbatch_t* pmb = ap->a_data; vaddr_t va0, va; - u_long mfn, ma; + u_long mfn; + paddr_t ma; struct vm_map *vmm; struct vm_map_entry *entry; vm_prot_t prot; @@ -446,7 +447,7 @@ UVM_KMF_VAONLY); return error; } - ma = mfn << PGSHIFT; + ma = ((paddr_t)mfn) << PGSHIFT; if (pmap_enter_ma(pmap_kernel(), trymap, ma, 0, prot, PMAP_CANFAIL, pmb->dom)) { mfn |= 0xF000;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: snj Date: Sun Mar 28 17:07:26 UTC 2010 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet.c Log Message: Apply patch (requested by bad in ticket #1347): Make it possible to use netbsd-5 domUs running on a Xen2 hypervisor. This changes two panics to printfs. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.60.2.1 src/sys/arch/xen/xen/if_xennet.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.c diff -u src/sys/arch/xen/xen/if_xennet.c:1.60 src/sys/arch/xen/xen/if_xennet.c:1.60.2.1 --- src/sys/arch/xen/xen/if_xennet.c:1.60 Mon Oct 27 10:58:22 2008 +++ src/sys/arch/xen/xen/if_xennet.c Sun Mar 28 17:07:26 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet.c,v 1.60 2008/10/27 10:58:22 cegger Exp $ */ +/* $NetBSD: if_xennet.c,v 1.60.2.1 2010/03/28 17:07:26 snj Exp $ */ /* * @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.60 2008/10/27 10:58:22 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.60.2.1 2010/03/28 17:07:26 snj Exp $"); #include "opt_inet.h" #include "opt_nfs_boot.h" @@ -657,8 +657,10 @@ (void)HYPERVISOR_multicall(rx_mcl, nr_pfns+1); /* Check return status of HYPERVISOR_dom_mem_op(). */ - if ( rx_mcl[nr_pfns].args[5] != nr_pfns ) - panic("Unable to reduce memory reservation\n"); + if ( rx_mcl[nr_pfns].args[5] != nr_pfns ) { + printf("xennet_rx_push_buffer: unable to reduce memory " + "reservation (%lu != %d)\n", rx_mcl[nr_pfns].args[5], nr_pfns); + } /* Above is a suitable barrier to ensure backend will see requests. */ sc->sc_rx->req_prod = ringidx; @@ -994,8 +996,10 @@ (void)HYPERVISOR_multicall(rx_mcl, nr_pfns+1); /* Check return status of HYPERVISOR_dom_mem_op(). */ - if (rx_mcl[nr_pfns].args[5] != nr_pfns) - panic("Unable to reduce memory reservation\n"); + if (rx_mcl[nr_pfns].args[5] != nr_pfns) { + printf("xennet_alloc_rx_buffers: unable to reduce memory " + "reservation (%lu != %d)\n", rx_mcl[nr_pfns].args[5], nr_pfns); + } /* Above is a suitable barrier to ensure backend will see requests. */ sc->sc_rx->req_prod = ringidx;
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: riz Date: Fri Aug 12 20:48:48 UTC 2011 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xbdback_xenbus.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1654): sys/arch/xen/xen/xbdback_xenbus.c: revision 1.42 sys/arch/xen/xen/xbdback_xenbus.c: revision 1.43 sys/arch/xen/xen/xbdback_xenbus.c: revision 1.44 Make sure to call xbdback_trampoline() at splbio() Several fixes to the continuation engine: - make sure to enter the continuation loop at splbio(), and add some KASSERT() for this. - When a flush operation is enqueued to the workqueue, make sure the continuation loop can't be restarted by a previous workqueue completion or an event. We can't restart it at this point because the flush even is still recorded as the current I/O. For this add a xbdback_co_cache_doflush_wait() which acts as a noop; the workqueue callback will restart the loop once the flush is complete. Should fix "kernel diagnostic assertion xbd_io->xio_mapped == 0" panics reported by Jeff Rizzo on port-xen@. Add a comment explaing why a flush workqueue is handled differently from read/write workqueue requests. To generate a diff of this commit: cvs rdiff -u -r1.20.4.5 -r1.20.4.6 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.20.4.5 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.6 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.5 Sat Jun 18 16:38:26 2011 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Fri Aug 12 20:48:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.20.4.5 2011/06/18 16:38:26 bouyer Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.5 2011/06/18 16:38:26 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $"); #include #include @@ -283,6 +283,7 @@ static void *xbdback_co_cache_flush(struct xbdback_instance *, void *); static void *xbdback_co_cache_flush2(struct xbdback_instance *, void *); static void *xbdback_co_cache_doflush(struct xbdback_instance *, void *); +static void *xbdback_co_cache_doflush_wait(struct xbdback_instance *, void *); static void *xbdback_co_io(struct xbdback_instance *, void *); static void *xbdback_co_io_gotreq(struct xbdback_instance *, void *); @@ -941,6 +942,8 @@ { (void)obj; if (xbdi->xbdi_io != NULL) { + KASSERT(xbdi->xbdi_io->xio_operation == BLKIF_OP_READ || + xbdi->xbdi_io->xio_operation == BLKIF_OP_WRITE); xbdi->xbdi_cont = xbdback_co_flush; xbdi->xbdi_cont_aux = xbdback_co_main_done2; } else { @@ -966,8 +969,13 @@ xbdback_co_cache_flush(struct xbdback_instance *xbdi, void *obj) { (void)obj; + KASSERT(curcpu()->ci_ilevel >= IPL_BIO); XENPRINTF(("xbdback_co_cache_flush %p %p\n", xbdi, obj)); if (xbdi->xbdi_io != NULL) { + /* Some I/Os are required for this instance. Process them. */ + KASSERT(xbdi->xbdi_io->xio_operation == BLKIF_OP_READ || + xbdi->xbdi_io->xio_operation == BLKIF_OP_WRITE); + KASSERT(xbdi->xbdi_pendingreqs == 0); xbdi->xbdi_cont = xbdback_co_flush; xbdi->xbdi_cont_aux = xbdback_co_cache_flush2; } else { @@ -982,7 +990,10 @@ (void)obj; XENPRINTF(("xbdback_co_cache_flush2 %p %p\n", xbdi, obj)); if (xbdi->xbdi_pendingreqs > 0) { - /* event or iodone will restart processing */ + /* + * There are pending requests. + * Event or iodone() will restart processing + */ xbdi->xbdi_cont = NULL; xbdi_put(xbdi); return NULL; @@ -1002,8 +1013,23 @@ xbd_io->xio_operation = xbdi->xbdi_xen_req.operation; xbd_io->xio_flush_id = xbdi->xbdi_xen_req.id; workqueue_enqueue(xbdback_workqueue, &xbdi->xbdi_io->xio_work, NULL); - /* xbdback_do_io() will advance req pointer and restart processing */ - xbdi->xbdi_cont = xbdback_co_cache_doflush; + /* + * xbdback_do_io() will advance req pointer and restart processing. + * Note that we could probably set xbdi->xbdi_io to NULL and + * let the processing continue, but we really want to wait + * for the flush to complete before doing any more work. + */ + xbdi->xbdi_cont = xbdback_co_cache_doflush_wait; + return NULL; +} + +/* wait for the flush work to complete */ +static void * +xbdback_co_cache_doflush_wait(struct xbdback_instance *xbdi, void *obj) +{ + (void)obj; + /* abort the continuation loop; xbdback_do_io() will restart it */ + xbdi->xbdi_cont = xbdback_co_cache_doflush_wait; return NULL; } @@ -1027,7 +1053,9 @@ goto end; } - if (xbdi->xbdi_xen_req.operation == BLKIF_OP_WRITE) { + KASSERT(req->operation == BLKIF_OP_READ || + req->operation == BLKIF_OP_WRITE); + if (req->operation == B
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: riz Date: Sun Nov 21 23:55:58 UTC 2010 Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c Log Message: Pull up following revision(s) (requested by jym in ticket #1473): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.42 sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.43 sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.45 Features (like feature-rx-copy) are set during XenbusStateInitWait in backend. So delay xennet_xenbus_resume() up to notification of backend state change. This avoids a race that happens during dynamic attach/detach of network interfaces with xm(1), where frontend queries xenstore for features not yet reported by backend. This does not happen during normal domU boot, as the backend has enough time to fill in these entries before frontend asks for them. Issue was reported by sborrill@: detaching xennet interfaces with RX copy mode enabled turns them back during attach to RX flip mode due to the race. feature-rx-copy support is part of another patch. Handle error case (avoid changing to XenbusStateConnected when resume failed) Implement feature-rx-copy support in xennet (domU network frontend). Instead of flipping pages back and forth between dom0 and domU for the network RX queue, feature-rx-copy tells frontend to use content copy instead. This is the only mode supported by the dom0 Linux pv_ops backend. NetBSD domU and dom0 can still fall back to flipping, when needed. Copy is supposed to be faster than flipping, as it does not require MMU manipulation and TLB shootdowns. Based on patch provided by Hideki ONO. Thanks! See also http://mail-index.netbsd.org/port-xen/2010/09/24/msg006265.html and http://mail-index.netbsd.org/port-xen/2010/10/16/msg006312.html ok bou...@. XXX will ask for a pull-up after 5.1 is branched. To generate a diff of this commit: cvs rdiff -u -r1.29.2.3 -r1.29.2.4 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.29.2.3 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.4 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.3 Mon Sep 28 01:31:46 2009 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Sun Nov 21 23:55:58 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.3 2009/09/28 01:31:46 snj Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.4 2010/11/21 23:55:58 riz Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.3 2009/09/28 01:31:46 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.4 2010/11/21 23:55:58 riz Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -178,6 +178,9 @@ #define BEST_DISCONNECTED 1 #define BEST_CONNECTED 2 #define BEST_SUSPENDED 3 + unsigned long sc_rx_feature; +#define FEATURE_RX_FLIP 0 +#define FEATURE_RX_COPY 1 #if NRND > 0 rndsource_element_t sc_rnd_source; #endif @@ -347,9 +350,6 @@ rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev), RND_TYPE_NET, 0); #endif - - /* initialise shared structures and tell backend that we are ready */ - xennet_xenbus_resume(sc); } static int @@ -411,6 +411,7 @@ { struct xennet_xenbus_softc *sc = p; struct xenbus_transaction *xbt; + unsigned long rx_copy; int error; netif_tx_sring_t *tx_ring; netif_rx_sring_t *rx_ring; @@ -420,7 +421,6 @@ sc->sc_tx_ring_gntref = GRANT_INVALID_REF; sc->sc_rx_ring_gntref = GRANT_INVALID_REF; - /* setup device: alloc event channel and shared rings */ tx_ring = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED | UVM_KMF_ZERO); @@ -450,6 +450,19 @@ event_set_handler(sc->sc_evtchn, &xennet_handler, sc, IPL_NET, device_xname(sc->sc_dev)); + error = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend, + "feature-rx-copy", &rx_copy, 10); + if (error) + rx_copy = 0; /* default value if key is absent */ + + if (rx_copy == 1) { + aprint_normal_dev(sc->sc_dev, "using RX copy mode\n"); + sc->sc_rx_feature = FEATURE_RX_COPY; + } else { + aprint_normal_dev(sc->sc_dev, "using RX flip mode\n"); + sc->sc_rx_feature = FEATURE_RX_FLIP; + } + again: xbt = xenbus_transaction_start(); if (xbt == NULL) @@ -467,21 +480,21 @@ goto abort_transaction; } error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path, - "feature-rx-notify", "%u", 1); + "request-rx-copy", "%lu", rx_copy); if (error) { - errmsg = "writing feature-rx-notify"; + errmsg = "writing request-rx-copy"; goto abort_transaction; } error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path, - "event-channel", "%u", sc->sc_evtchn); + "feature-rx-notify", "%u", 1); if (error) { - errmsg = "writing event channel"; + errmsg = "writing feature-rx-notify"; goto abor
CVS commit: [netbsd-5] src/sys/arch/xen/xen
Module Name:src Committed By: sborrill Date: Fri May 22 11:04:28 UTC 2015 Modified Files: src/sys/arch/xen/xen [netbsd-5]: xenevt.c Log Message: Pull up the following revisions(s) (requested by bouyer in ticket #1965): sys/arch/xen/xen/xenevt.c: revision 1.42 Fix off by one error, addresses port-xen/49919. To generate a diff of this commit: cvs rdiff -u -r1.29.4.2 -r1.29.4.3 src/sys/arch/xen/xen/xenevt.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/xenevt.c diff -u src/sys/arch/xen/xen/xenevt.c:1.29.4.2 src/sys/arch/xen/xen/xenevt.c:1.29.4.3 --- src/sys/arch/xen/xen/xenevt.c:1.29.4.2 Wed Sep 30 00:08:03 2009 +++ src/sys/arch/xen/xen/xenevt.c Fri May 22 11:04:28 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xenevt.c,v 1.29.4.2 2009/09/30 00:08:03 snj Exp $ */ +/* $NetBSD: xenevt.c,v 1.29.4.3 2015/05/22 11:04:28 sborrill Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.29.4.2 2009/09/30 00:08:03 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.29.4.3 2015/05/22 11:04:28 sborrill Exp $"); #include "opt_xen.h" #include @@ -496,7 +496,7 @@ xenevt_fwrite(struct file *fp, off_t *of if (uio->uio_resid == 0) return (0); nentries = uio->uio_resid / sizeof(uint16_t); - if (nentries > NR_EVENT_CHANNELS) + if (nentries >= NR_EVENT_CHANNELS) return EMSGSIZE; chans = kmem_alloc(nentries * sizeof(uint16_t), KM_SLEEP); if (chans == NULL) @@ -580,7 +580,7 @@ xenevt_fioctl(struct file *fp, u_long cm { struct ioctl_evtchn_unbind *unbind = addr; - if (unbind->port > NR_EVENT_CHANNELS) + if (unbind->port >= NR_EVENT_CHANNELS) return EINVAL; if (devevent[unbind->port] != d) return ENOTCONN; @@ -596,7 +596,7 @@ xenevt_fioctl(struct file *fp, u_long cm { struct ioctl_evtchn_notify *notify = addr; - if (notify->port > NR_EVENT_CHANNELS) + if (notify->port >= NR_EVENT_CHANNELS) return EINVAL; if (devevent[notify->port] != d) return ENOTCONN;