Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Dec 2008 01:35:57 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r186553 - in projects/releng_6_xen/sys: conf dev/xen/blkfront dev/xen/console dev/xen/evtchn dev/xen/netfront i386/i386 i386/include/xen i386/isa i386/xen sys xen xen/evtchn xen/interfa...
Message-ID:  <200812290135.mBT1Zvn6035937@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Mon Dec 29 01:35:56 2008
New Revision: 186553
URL: http://svn.freebsd.org/changeset/base/186553

Log:
  Integrate 186535 from releng_7_xen
  
   - merge in latest xenbus from dfr's xenhvm
   - fix race condition in xs_read_reply by converting tsleep to mtx_sleep

Added:
  projects/releng_6_xen/sys/xen/evtchn.h   (contents, props changed)
  projects/releng_6_xen/sys/xen/hypervisor.h   (contents, props changed)
  projects/releng_6_xen/sys/xen/xen_intr.h   (contents, props changed)
Modified:
  projects/releng_6_xen/sys/conf/kern.pre.mk
  projects/releng_6_xen/sys/dev/xen/blkfront/blkfront.c
  projects/releng_6_xen/sys/dev/xen/console/console.c
  projects/releng_6_xen/sys/dev/xen/console/xencons_ring.c
  projects/releng_6_xen/sys/dev/xen/evtchn/evtchn_dev.c
  projects/releng_6_xen/sys/dev/xen/netfront/netfront.c
  projects/releng_6_xen/sys/i386/i386/genassym.c
  projects/releng_6_xen/sys/i386/i386/machdep.c
  projects/releng_6_xen/sys/i386/i386/vm_machdep.c
  projects/releng_6_xen/sys/i386/include/xen/xenfunc.h
  projects/releng_6_xen/sys/i386/isa/npx.c
  projects/releng_6_xen/sys/i386/xen/clock.c
  projects/releng_6_xen/sys/i386/xen/mp_machdep.c
  projects/releng_6_xen/sys/i386/xen/mptable.c
  projects/releng_6_xen/sys/i386/xen/pmap.c
  projects/releng_6_xen/sys/i386/xen/xen_bus.c
  projects/releng_6_xen/sys/i386/xen/xen_machdep.c
  projects/releng_6_xen/sys/sys/mutex.h
  projects/releng_6_xen/sys/xen/evtchn/evtchn.c
  projects/releng_6_xen/sys/xen/evtchn/evtchn_dev.c
  projects/releng_6_xen/sys/xen/features.c
  projects/releng_6_xen/sys/xen/gnttab.c
  projects/releng_6_xen/sys/xen/gnttab.h
  projects/releng_6_xen/sys/xen/interface/arch-x86/xen.h
  projects/releng_6_xen/sys/xen/xenbus/xenbus_client.c
  projects/releng_6_xen/sys/xen/xenbus/xenbus_comms.c
  projects/releng_6_xen/sys/xen/xenbus/xenbus_comms.h
  projects/releng_6_xen/sys/xen/xenbus/xenbus_dev.c
  projects/releng_6_xen/sys/xen/xenbus/xenbus_probe.c
  projects/releng_6_xen/sys/xen/xenbus/xenbus_probe_backend.c
  projects/releng_6_xen/sys/xen/xenbus/xenbus_xs.c
  projects/releng_6_xen/sys/xen/xenbus/xenbusvar.h

Modified: projects/releng_6_xen/sys/conf/kern.pre.mk
==============================================================================
--- projects/releng_6_xen/sys/conf/kern.pre.mk	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/conf/kern.pre.mk	Mon Dec 29 01:35:56 2008	(r186553)
@@ -70,7 +70,7 @@ INCLUDES+= -I$S/dev/twa
 # .. and the same for em
 INCLUDES+= -I$S/dev/em
 
-INCLUDES+= -I$S/xen/interface -I$S/xen/interface/io
+INCLUDES+= -I$S/xen/interface -I$S/xen/interface/io -I$S/xen/interface/hvm
 
 
 CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG}

Modified: projects/releng_6_xen/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- projects/releng_6_xen/sys/dev/xen/blkfront/blkfront.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/dev/xen/blkfront/blkfront.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -40,10 +40,10 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <machine/vmparam.h>
 
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/xen_intr.h>
-#include <machine/xen/evtchn.h>
+#include <xen/xen_intr.h>
+#include <xen/evtchn.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/protocols.h>
 #include <xen/xenbus/xenbusvar.h>
@@ -214,7 +214,7 @@ xlvbd_add(device_t dev, blkif_sector_t c
 	struct xb_softc	*sc;
 	int	unit, error = 0;
 	const char *name;
-	
+
 	blkfront_vdevice_to_unit(vdevice, &unit, &name);
 
 	sc = (struct xb_softc *)malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
@@ -227,12 +227,12 @@ xlvbd_add(device_t dev, blkif_sector_t c
 
 	memset(&sc->xb_disk, 0, sizeof(sc->xb_disk)); 
 	sc->xb_disk = disk_alloc();
-	sc->xb_disk->d_unit = unit;
+	sc->xb_disk->d_unit = sc->xb_unit;
 	sc->xb_disk->d_open = blkif_open;
 	sc->xb_disk->d_close = blkif_close;
 	sc->xb_disk->d_ioctl = blkif_ioctl;
 	sc->xb_disk->d_strategy = xb_strategy;
-	sc->xb_disk->d_name = "xbd";
+	sc->xb_disk->d_name = name;
 	sc->xb_disk->d_drv1 = sc;
 	sc->xb_disk->d_sectorsize = sector_size;
 
@@ -329,8 +329,8 @@ blkfront_attach(device_t dev)
 
 	/* FIXME: Use dynamic device id if this is not set. */
 	err = xenbus_scanf(XBT_NIL, xenbus_get_node(dev),
-			   "virtual-device", "%i", &vdevice);
-	if (err != 1) {
+	    "virtual-device", NULL, "%i", &vdevice);
+	if (err) {
 		xenbus_dev_fatal(dev, err, "reading virtual-device");
 		printf("couldn't find virtual device");
 		return (err);
@@ -363,9 +363,8 @@ blkfront_attach(device_t dev)
 	info->handle = strtoul(strrchr(xenbus_get_node(dev),'/')+1, NULL, 0);
 
 	err = talk_to_backend(dev, info);
-	if (err) {
-		return err;
-	}
+	if (err)
+		return (err);
 
 	return (0);
 }
@@ -381,7 +380,8 @@ blkfront_resume(device_t dev)
 	blkif_free(info, 1);
 
 	err = talk_to_backend(dev, info);
-	if (!err)
+
+	if (info->connected == BLKIF_STATE_SUSPENDED && !err)
 		blkif_recover(info);
 
 	return err;
@@ -427,7 +427,7 @@ talk_to_backend(device_t dev, struct blk
 	}
 	err = xenbus_transaction_end(xbt, 0);
 	if (err) {
-		if (err == -EAGAIN)
+		if (err == EAGAIN)
 			goto again;
 		xenbus_dev_fatal(dev, err, "completing transaction");
 		goto destroy_blkring;
@@ -450,7 +450,7 @@ static int 
 setup_blkring(device_t dev, struct blkfront_info *info)
 {
 	blkif_sring_t *sring;
-	int err;
+	int error;
 
 	info->ring_ref = GRANT_INVALID_REF;
 
@@ -462,28 +462,27 @@ setup_blkring(device_t dev, struct blkfr
 	SHARED_RING_INIT(sring);
 	FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, (vtomach(info->ring.sring) >> PAGE_SHIFT));
-	if (err < 0) {
+	error = xenbus_grant_ring(dev, (vtomach(info->ring.sring) >> PAGE_SHIFT),
+		&info->ring_ref);
+	if (error) {
 		free(sring, M_DEVBUF);
 		info->ring.sring = NULL;
 		goto fail;
 	}
-	info->ring_ref = err;
 	
-	err = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
+	error = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
 		"xbd", (driver_intr_t *)blkif_int, info,
-					INTR_TYPE_BIO | INTR_MPSAFE, NULL);
-	if (err <= 0) {
-		xenbus_dev_fatal(dev, err,
+					INTR_TYPE_BIO | INTR_MPSAFE, &info->irq);
+	if (error) {
+		xenbus_dev_fatal(dev, error,
 				 "bind_evtchn_to_irqhandler failed");
 		goto fail;
 	}
-	info->irq = err;
 
-	return 0;
+	return (0);
  fail:
 	blkif_free(info, 0);
-	return err;
+	return (error);
 }
 
 
@@ -999,7 +998,7 @@ blkif_free(struct blkfront_info *info, i
 		info->ring.sring = NULL;
 	}
 	if (info->irq)
-		unbind_from_irqhandler(info->irq, info); 
+		unbind_from_irqhandler(info->irq);
 	info->irq = 0;
 
 }

Modified: projects/releng_6_xen/sys/dev/xen/console/console.c
==============================================================================
--- projects/releng_6_xen/sys/dev/xen/console/console.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/dev/xen/console/console.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -15,8 +15,8 @@
 #include <sys/bus.h>
 #include <machine/stdarg.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
 #include <sys/cons.h>
 #include <sys/proc.h>
 
@@ -76,17 +76,17 @@ static unsigned int wc, wp; /* write_con
 #define	XCUNIT(x)	(minor(x))
 #define ISTTYOPEN(tp)	((tp) && ((tp)->t_state & TS_ISOPEN))
 #define CN_LOCK_INIT(x, _name) \
-        mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE)
+        mtx_init(&x, _name, NULL, MTX_DEF|MTX_RECURSE)
 
 #define CN_LOCK(l)        								\
 		do {											\
 				if (panicstr == NULL)					\
-                        mtx_lock_spin(&(l));			\
+                        mtx_lock(&(l));			\
 		} while (0)
 #define CN_UNLOCK(l)        							\
 		do {											\
 				if (panicstr == NULL)					\
-                        mtx_unlock_spin(&(l));			\
+                        mtx_unlock(&(l));			\
 		} while (0)
 #define CN_LOCK_ASSERT(x)    mtx_assert(&x, MA_OWNED)
 #define CN_LOCK_DESTROY(x)   mtx_destroy(&x)
@@ -233,6 +233,7 @@ xc_probe(device_t dev)
 static int
 xc_attach(device_t dev) 
 {
+	int error;
 	struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev);
 
 
@@ -259,13 +260,14 @@ xc_attach(device_t dev) 
 	callout_reset(&xc_callout, XC_POLLTIME, xc_timeout, xccons);
     
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
-		PANIC_IF(bind_virq_to_irqhandler(
+			error = bind_virq_to_irqhandler(
 				 VIRQ_CONSOLE,
 				 0,
 				 "console",
 				 xencons_priv_interrupt,
-				 INTR_TYPE_TTY) < 0);
+					 INTR_TYPE_TTY, NULL);
 		
+				KASSERT(error >= 0, ("can't register console interrupt"));
 	}
 
 

Modified: projects/releng_6_xen/sys/dev/xen/console/xencons_ring.c
==============================================================================
--- projects/releng_6_xen/sys/dev/xen/console/xencons_ring.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/dev/xen/console/xencons_ring.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -15,19 +15,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <machine/stdarg.h>
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
 #include <sys/cons.h>
 
 
 #include <dev/xen/console/xencons_ring.h>
-#include <machine/xen/evtchn.h>
+#include <xen/evtchn.h>
 #include <xen/interface/io/console.h>
 
 
 #define console_evtchn	console.domU.evtchn
 extern char *console_page;
- 
+extern struct mtx              cn_mtx;
+
 static inline struct xencons_interface *
 xencons_interface(void)
 {
@@ -82,6 +83,7 @@ xencons_handle_input(void *unused)
 	struct xencons_interface *intf;
 	XENCONS_RING_IDX cons, prod;
 
+	mtx_lock(&cn_mtx);
 	intf = xencons_interface();
 
 	cons = intf->in_cons;
@@ -99,6 +101,7 @@ xencons_handle_input(void *unused)
 	notify_remote_via_evtchn(xen_start_info->console_evtchn);
 
 	xencons_tx();
+	mtx_unlock(&cn_mtx);
 }
 
 void 

Modified: projects/releng_6_xen/sys/dev/xen/evtchn/evtchn_dev.c
==============================================================================
--- projects/releng_6_xen/sys/dev/xen/evtchn/evtchn_dev.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/dev/xen/evtchn/evtchn_dev.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -26,13 +26,13 @@ __FBSDID("$FreeBSD$");
 #include <machine/cpufunc.h>
 #include <machine/intr_machdep.h>
 #include <machine/xen-os.h>
-#include <machine/xen_intr.h>
+#include <xen/xen_intr.h>
 #include <machine/bus.h>
 #include <sys/rman.h>
 #include <machine/resource.h>
 #include <machine/synch_bitops.h>
 
-#include <machine/hypervisor.h>
+#include <xen/hypervisor.h>
 
 
 typedef struct evtchn_sotfc {

Modified: projects/releng_6_xen/sys/dev/xen/netfront/netfront.c
==============================================================================
--- projects/releng_6_xen/sys/dev/xen/netfront/netfront.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/dev/xen/netfront/netfront.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -63,9 +63,9 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
-#include <machine/xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
+#include <xen/evtchn.h>
 #include <xen/gnttab.h>
 #include <xen/interface/memory.h>
 #include <dev/xen/netfront/mbufq.h>
@@ -364,24 +364,25 @@ makembuf (struct mbuf *buf)
 static int 
 xen_net_read_mac(device_t dev, uint8_t mac[])
 {
-	char *s;
-	int i;
-	char *e;
-	char *macstr = xenbus_read(XBT_NIL, xenbus_get_node(dev), "mac", NULL);
-	if (IS_ERR(macstr)) {
-		return PTR_ERR(macstr);
-	}
+	int error, i;
+	char *s, *e, *macstr;
+
+	error = xenbus_read(XBT_NIL, xenbus_get_node(dev), "mac", NULL,
+	    (void **) &macstr);
+	if (error)
+		return (error);
+
 	s = macstr;
 	for (i = 0; i < ETHER_ADDR_LEN; i++) {
 		mac[i] = strtoul(s, &e, 16);
 		if (s == e || (e[0] != ':' && e[0] != 0)) {
 			free(macstr, M_DEVBUF);
-			return ENOENT;
+			return (ENOENT);
 		}
 		s = &e[1];
 	}
 	free(macstr, M_DEVBUF);
-	return 0;
+	return (0);
 }
 
 /**
@@ -423,13 +424,11 @@ netfront_attach(device_t dev)
  * leave the device-layer structures intact so that this is transparent to the
  * rest of the kernel.
  */
-static int 
+static int
 netfront_resume(device_t dev)
 {
 	struct netfront_info *info = device_get_softc(dev);
-	
-	DPRINTK("%s\n", xenbus_get_node(dev));
-	
+
 	netif_disconnect_backend(info);
 	return (0);
 }
@@ -533,7 +532,7 @@ setup_device(device_t dev, struct netfro
 {
 	netif_tx_sring_t *txs;
 	netif_rx_sring_t *rxs;
-	int err;
+	int error;
 	struct ifnet *ifp;
 	
 	ifp = info->xn_ifp;
@@ -546,51 +545,45 @@ setup_device(device_t dev, struct netfro
 
 	txs = (netif_tx_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (!txs) {
-		err = ENOMEM;
-		xenbus_dev_fatal(dev, err, "allocating tx ring page");
+		error = ENOMEM;
+		xenbus_dev_fatal(dev, error, "allocating tx ring page");
 		goto fail;
 	}
 	SHARED_RING_INIT(txs);
 	FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
-	err = xenbus_grant_ring(dev, virt_to_mfn(txs));
-	if (err < 0)
+	error = xenbus_grant_ring(dev, virt_to_mfn(txs), &info->tx_ring_ref);
+	if (error)
 		goto fail;
-	info->tx_ring_ref = err;
 
 	rxs = (netif_rx_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO);
 	if (!rxs) {
-		err = ENOMEM;
-		xenbus_dev_fatal(dev, err, "allocating rx ring page");
+		error = ENOMEM;
+		xenbus_dev_fatal(dev, error, "allocating rx ring page");
 		goto fail;
 	}
 	SHARED_RING_INIT(rxs);
 	FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
-	if (err < 0)
+	error = xenbus_grant_ring(dev, virt_to_mfn(rxs), &info->rx_ring_ref);
+	if (error)
 		goto fail;
-	info->rx_ring_ref = err;
 
-#if 0	
-	network_connect(info);
-#endif
-	err = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
-		"xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, NULL);
+	error = bind_listening_port_to_irqhandler(xenbus_get_otherend_id(dev),
+	         "xn", xn_intr, info, INTR_TYPE_NET | INTR_MPSAFE, &info->irq);
 
-	if (err <= 0) {
-		xenbus_dev_fatal(dev, err,
+	if (error) {
+		xenbus_dev_fatal(dev, error,
 				 "bind_evtchn_to_irqhandler failed");
 		goto fail;
 	}
-	info->irq = err;
-	
+
 	show_device(info);
 	
-	return 0;
+	return (0);
 	
  fail:
 	netif_free(info);
-	return err;
+	return (error);
 }
 
 /**
@@ -1224,7 +1217,7 @@ xennet_get_responses(struct netfront_inf
 				MULTI_update_va_mapping(mcl, (u_long)vaddr,
 				    (((vm_paddr_t)mfn) << PAGE_SHIFT) | PG_RW |
 				    PG_V | PG_M | PG_A, 0);
-				pfn = (uint32_t)m->m_ext.ext_args;
+				pfn = (uintptr_t)m->m_ext.ext_args;
 				mmu->ptr = ((vm_paddr_t)mfn << PAGE_SHIFT) |
 				    MMU_MACHPHYS_UPDATE;
 				mmu->val = pfn;
@@ -1449,9 +1442,11 @@ xn_ioctl(struct ifnet *ifp, u_long cmd, 
 			if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) 
 				xn_ifinit_locked(sc);
 			arp_ifinit(ifp, ifa);
-		} else
+			XN_UNLOCK(sc);	
+		} else {
+			XN_UNLOCK(sc);	
 			error = ether_ioctl(ifp, cmd, data);
-		XN_UNLOCK(sc);
+		}
 		break;
 	case SIOCSIFMTU:
 		/* XXX can we alter the MTU on a VN ?*/
@@ -1554,18 +1549,18 @@ xn_stop(struct netfront_info *sc)
 int
 network_connect(struct netfront_info *np)
 {
-	int i, requeue_idx, err;
+	int i, requeue_idx, error;
 	grant_ref_t ref;
 	netif_rx_request_t *req;
 	u_int feature_rx_copy, feature_rx_flip;
 
-	err = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
-			   "feature-rx-copy", "%u", &feature_rx_copy);
-	if (err != 1)
+	error = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
+	    "feature-rx-copy", NULL, "%u", &feature_rx_copy);
+	if (error)
 		feature_rx_copy = 0;
-	err = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
-			   "feature-rx-flip", "%u", &feature_rx_flip);
-	if (err != 1)
+	error = xenbus_scanf(XBT_NIL, xenbus_get_otherend_path(np->xbdev),
+	    "feature-rx-flip", NULL, "%u", &feature_rx_flip);
+	if (error)
 		feature_rx_flip = 1;
 
 	/*
@@ -1578,9 +1573,9 @@ network_connect(struct netfront_info *np
 
 	XN_LOCK(np);
 	/* Recovery procedure: */
-	err = talk_to_backend(np->xbdev, np);
-	if (err) 
-		return (err);
+	error = talk_to_backend(np->xbdev, np);
+	if (error) 
+		return (error);
 	
 	/* Step 1: Reinitialise variables. */
 	netif_release_tx_bufs(np);
@@ -1588,6 +1583,7 @@ network_connect(struct netfront_info *np
 	/* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */
 	for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) {
 		struct mbuf *m;
+		u_long pfn;
 
 		if (np->rx_mbufs[i] == NULL)
 			continue;
@@ -1595,15 +1591,16 @@ network_connect(struct netfront_info *np
 		m = np->rx_mbufs[requeue_idx] = xennet_get_rx_mbuf(np, i);
 		ref = np->grant_rx_ref[requeue_idx] = xennet_get_rx_ref(np, i);
 		req = RING_GET_REQUEST(&np->rx, requeue_idx);
+		pfn = vtophys(mtod(m, vm_offset_t)) >> PAGE_SHIFT;
 
 		if (!np->copying_receiver) {
 			gnttab_grant_foreign_transfer_ref(ref,
 			    xenbus_get_otherend_id(np->xbdev),
-			    vtophys(mtod(m, vm_offset_t)));
+			    pfn);
 		} else {
 			gnttab_grant_foreign_access_ref(ref,
 			    xenbus_get_otherend_id(np->xbdev),
-			    vtophys(mtod(m, vm_offset_t)), 0);
+			    PFNTOMFN(pfn), 0);
 		}
 		req->gref = ref;
 		req->id   = requeue_idx;
@@ -1704,7 +1701,7 @@ create_netdev(device_t dev)
 	ifp = np->xn_ifp = if_alloc(IFT_ETHER);
     	ifp->if_softc = np;
     	if_initname(ifp, "xn",  device_get_unit(dev));
-    	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
+    	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
     	ifp->if_ioctl = xn_ioctl;
     	ifp->if_output = ether_output;
     	ifp->if_start = xn_start;
@@ -1774,11 +1771,14 @@ static void netif_free(struct netfront_i
 #endif
 }
 
-
-
 static void netif_disconnect_backend(struct netfront_info *info)
 {
-	xn_stop(info);
+	XN_RX_LOCK(info);
+	XN_TX_LOCK(info);
+	netfront_carrier_off(info);
+	XN_TX_UNLOCK(info);
+	XN_RX_UNLOCK(info);
+
 	end_access(info->tx_ring_ref, info->tx.sring);
 	end_access(info->rx_ring_ref, info->rx.sring);
 	info->tx_ring_ref = GRANT_INVALID_REF;
@@ -1786,12 +1786,9 @@ static void netif_disconnect_backend(str
 	info->tx.sring = NULL;
 	info->rx.sring = NULL;
 
-#if 0
 	if (info->irq)
-		unbind_from_irqhandler(info->irq, info->netdev);
-#else 
-	panic("FIX ME");
-#endif
+		unbind_from_irqhandler(info->irq);
+
 	info->irq = 0;
 }
 

Modified: projects/releng_6_xen/sys/i386/i386/genassym.c
==============================================================================
--- projects/releng_6_xen/sys/i386/i386/genassym.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/i386/genassym.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -229,7 +229,7 @@ ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(str
 #endif
 
 #ifdef XEN
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3));
 ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START);
 #endif

Modified: projects/releng_6_xen/sys/i386/i386/machdep.c
==============================================================================
--- projects/releng_6_xen/sys/i386/i386/machdep.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/i386/machdep.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -143,11 +143,11 @@ uint32_t arch_i386_xbox_memsize = 0;
 
 #ifdef XEN
 /* XEN includes */
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
 
 void Xhypervisor_callback(void);
 void failsafe_callback(void);

Modified: projects/releng_6_xen/sys/i386/i386/vm_machdep.c
==============================================================================
--- projects/releng_6_xen/sys/i386/i386/vm_machdep.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/i386/vm_machdep.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_param.h>
 
 #ifdef XEN
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #endif
 #ifdef PC98
 #include <pc98/cbus/cbus.h>

Modified: projects/releng_6_xen/sys/i386/include/xen/xenfunc.h
==============================================================================
--- projects/releng_6_xen/sys/i386/include/xen/xenfunc.h	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/include/xen/xenfunc.h	Mon Dec 29 01:35:56 2008	(r186553)
@@ -31,7 +31,7 @@
 #define _XEN_XENFUNC_H_
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xenpmap.h>
 #include <machine/segments.h>
 #include <sys/pcpu.h>

Modified: projects/releng_6_xen/sys/i386/isa/npx.c
==============================================================================
--- projects/releng_6_xen/sys/i386/isa/npx.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/isa/npx.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -69,8 +69,9 @@ __FBSDID("$FreeBSD$");
 #include <machine/ucontext.h>
 
 #include <machine/intr_machdep.h>
+#include <machine/xen/xen-os.h>
 #ifdef XEN
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #endif
 #ifdef DEV_ISA
 #include <isa/isavar.h>

Modified: projects/releng_6_xen/sys/i386/xen/clock.c
==============================================================================
--- projects/releng_6_xen/sys/i386/xen/clock.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/xen/clock.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -78,11 +78,11 @@ __FBSDID("$FreeBSD$");
 #include <i386/isa/isa.h>
 #include <isa/rtc.h>
 
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <machine/pmap.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
 #include <machine/xen/xenfunc.h>
 #include <xen/interface/vcpu.h>
@@ -295,12 +295,13 @@ static struct timecounter xen_timecounte
 };
 
 static void 
-clkintr(struct clockframe *frame)
+clkintr(void *arg)
 {
 	int64_t delta_cpu, delta;
 	int cpu = smp_processor_id();
 	struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu);
-
+	struct clockframe *frame = (struct clockframe *)arg;
+	
 	do {
 		__get_time_values_from_xen();
 		
@@ -840,17 +841,20 @@ static struct vcpu_set_periodic_timer xe
 void
 cpu_initclocks(void)
 {
-	int time_irq;
-
+	unsigned int time_irq;
+	int error;
+	
 	xen_set_periodic_tick.period_ns = NS_PER_TICK;
 
 	HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0,
 			   &xen_set_periodic_tick);
-
-        if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", 
-		    (driver_intr_t *)clkintr, INTR_TYPE_CLK | INTR_FAST)) < 0) {
+	
+        error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", 
+		                                clkintr,
+	    INTR_TYPE_CLK | INTR_FAST, &time_irq);
+	if (error)
 		panic("failed to register clock interrupt\n");
-	}
+
 
 	/* should fast clock be enabled ? */
 }
@@ -859,18 +863,19 @@ cpu_initclocks(void)
 int
 ap_cpu_initclocks(int cpu)
 {
-	int time_irq;
+	unsigned int time_irq;
+	int error;
 
 	xen_set_periodic_tick.period_ns = NS_PER_TICK;
 
 	HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu,
 			   &xen_set_periodic_tick);
-
-        if ((time_irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, "clk", 
-		    (driver_intr_t *)clkintr, 
-						INTR_TYPE_CLK | INTR_FAST)) < 0) {
+        error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", 
+		                                clkintr, 
+	    INTR_TYPE_CLK | INTR_FAST, &time_irq);
+	if (error)
 		panic("failed to register clock interrupt\n");
-	}
+
 
 	return (0);
 }

Modified: projects/releng_6_xen/sys/i386/xen/mp_machdep.c
==============================================================================
--- projects/releng_6_xen/sys/i386/xen/mp_machdep.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/xen/mp_machdep.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -82,9 +82,11 @@ __FBSDID("$FreeBSD$");
 #include <machine/smptests.h>	/** COUNT_XINVLTLB_HITS */
 #include <machine/specialreg.h>
 
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
-#include <machine/xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
+#include <xen/evtchn.h>
+#include <xen/xen_intr.h>
+#include <xen/hypervisor.h>
 #include <xen/interface/vcpu.h>
 
 #define WARMBOOT_TARGET		0
@@ -556,7 +558,8 @@ static int
 xen_smp_intr_init(unsigned int cpu)
 {
 	int rc;
-
+	unsigned int irq;
+	
 	per_cpu(resched_irq, cpu) = per_cpu(callfunc_irq, cpu) = -1;
 
 	sprintf(resched_name[cpu], "resched%u", cpu);
@@ -564,22 +567,22 @@ xen_smp_intr_init(unsigned int cpu)
 				    cpu,
 				    resched_name[cpu],
 				    smp_reschedule_interrupt,
-				    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE);
+	    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq);
 
 	printf("cpu=%d irq=%d vector=%d\n",
 	    cpu, rc, RESCHEDULE_VECTOR);
 	
-	per_cpu(resched_irq, cpu) = rc;
+	per_cpu(resched_irq, cpu) = irq;
 
 	sprintf(callfunc_name[cpu], "callfunc%u", cpu);
 	rc = bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR,
 				    cpu,
 				    callfunc_name[cpu],
 				    smp_call_function_interrupt,
-				    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE);
+	    INTR_FAST|INTR_TYPE_TTY|INTR_MPSAFE, &irq);
 	if (rc < 0)
 		goto fail;
-	per_cpu(callfunc_irq, cpu) = rc;
+	per_cpu(callfunc_irq, cpu) = irq;
 
 	printf("cpu=%d irq=%d vector=%d\n",
 	    cpu, rc, CALL_FUNCTION_VECTOR);
@@ -592,9 +595,9 @@ xen_smp_intr_init(unsigned int cpu)
 
  fail:
 	if (per_cpu(resched_irq, cpu) >= 0)
-		unbind_from_irqhandler(per_cpu(resched_irq, cpu), NULL);
+		unbind_from_irqhandler(per_cpu(resched_irq, cpu));
 	if (per_cpu(callfunc_irq, cpu) >= 0)
-		unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL);
+		unbind_from_irqhandler(per_cpu(callfunc_irq, cpu));
 	return rc;
 }
 

Modified: projects/releng_6_xen/sys/i386/xen/mptable.c
==============================================================================
--- projects/releng_6_xen/sys/i386/xen/mptable.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/xen/mptable.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/mptable.h>
 #include <machine/specialreg.h>
 
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xen-os.h>
 #include <machine/smp.h>
 #include <xen/interface/vcpu.h>

Modified: projects/releng_6_xen/sys/i386/xen/pmap.c
==============================================================================
--- projects/releng_6_xen/sys/i386/xen/pmap.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/xen/pmap.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -144,7 +144,7 @@ __FBSDID("$FreeBSD$");
 
 #ifdef XEN
 #include <xen/interface/xen.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/hypercall.h>
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
@@ -159,6 +159,16 @@ __FBSDID("$FreeBSD$");
 #include <machine/smp.h>
 #endif
 
+#ifdef XBOX
+#include <machine/xbox.h>
+#endif
+
+#include <xen/interface/xen.h>
+#include <xen/hypervisor.h>
+#include <machine/xen/hypercall.h>
+#include <machine/xen/xenvar.h>
+#include <machine/xen/xenfunc.h>
+
 #if !defined(CPU_DISABLE_SSE) && defined(I686_CPU)
 #define CPU_ENABLE_SSE
 #endif

Modified: projects/releng_6_xen/sys/i386/xen/xen_bus.c
==============================================================================
--- projects/releng_6_xen/sys/i386/xen/xen_bus.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/xen/xen_bus.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -15,8 +15,8 @@
 #include <machine/resource.h>
 
 #include <machine/xen/xen-os.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/hypervisor.h>
+#include <xen/xen_intr.h>
 
 static MALLOC_DEFINE(M_XENDEV, "xenintrdrv", "xen system device");
 

Modified: projects/releng_6_xen/sys/i386/xen/xen_machdep.c
==============================================================================
--- projects/releng_6_xen/sys/i386/xen/xen_machdep.c	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/i386/xen/xen_machdep.c	Mon Dec 29 01:35:56 2008	(r186553)
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
 
 
 
-#include <machine/xen/hypervisor.h>
+#include <xen/hypervisor.h>
 #include <machine/xen/xenvar.h>
 #include <machine/xen/xenfunc.h>
 #include <machine/xen/xenpmap.h>

Modified: projects/releng_6_xen/sys/sys/mutex.h
==============================================================================
--- projects/releng_6_xen/sys/sys/mutex.h	Mon Dec 29 01:09:40 2008	(r186552)
+++ projects/releng_6_xen/sys/sys/mutex.h	Mon Dec 29 01:35:56 2008	(r186553)
@@ -325,6 +325,9 @@ extern struct mtx_pool *mtxpool_sleep;
 #define mtx_trylock_flags(m, opts)					\
 	_mtx_trylock((m), (opts), LOCK_FILE, LOCK_LINE)
 
+#define	mtx_sleep(chan, mtx, pri, wmesg, timo)				\
+	_sleep((chan), &(mtx)->mtx_object, (pri), (wmesg), (timo))
+
 #define	mtx_initialized(m)	lock_initalized(&(m)->mtx_object)
 
 #define mtx_owned(m)	(((m)->mtx_lock & MTX_FLAGMASK) == (uintptr_t)curthread)

Added: projects/releng_6_xen/sys/xen/evtchn.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/releng_6_xen/sys/xen/evtchn.h	Mon Dec 29 01:35:56 2008	(r186553)
@@ -0,0 +1,188 @@
+/******************************************************************************
+ * evtchn.h
+ * 
+ * Communication via Xen event channels.
+ * Also definitions for the device that demuxes notifications to userspace.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __ASM_EVTCHN_H__
+#define __ASM_EVTCHN_H__
+#include <machine/pcpu.h>
+#include <xen/hypervisor.h>
+#include <machine/xen/synch_bitops.h>
+#include <machine/frame.h>
+
+/*
+ * LOW-LEVEL DEFINITIONS
+ */
+
+/*
+ * Unlike notify_remote_via_evtchn(), this is safe to use across
+ * save/restore. Notifications on a broken connection are silently dropped.
+ */
+void notify_remote_via_irq(int irq);
+
+
+/* Entry point for notifications into Linux subsystems. */
+void evtchn_do_upcall(struct intrframe *frame);
+
+/* Entry point for notifications into the userland character device. */
+void evtchn_device_upcall(int port);
+
+void mask_evtchn(int port);
+
+void unmask_evtchn(int port);
+
+#ifdef SMP
+void rebind_evtchn_to_cpu(int port, unsigned int cpu);
+#else
+#define rebind_evtchn_to_cpu(port, cpu)	((void)0)
+#endif
+
+static inline
+int test_and_set_evtchn_mask(int port)
+{
+	shared_info_t *s = HYPERVISOR_shared_info;
+	return synch_test_and_set_bit(port, s->evtchn_mask);
+}
+
+static inline void 
+clear_evtchn(int port)
+{
+	shared_info_t *s = HYPERVISOR_shared_info;
+	synch_clear_bit(port, &s->evtchn_pending[0]);
+}
+
+static inline void 
+notify_remote_via_evtchn(int port)
+{
+        struct evtchn_send send = { .port = port };
+        (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
+}
+
+/*
+ * Use these to access the event channel underlying the IRQ handle returned
+ * by bind_*_to_irqhandler().
+ */
+int irq_to_evtchn_port(int irq);
+
+void ipi_pcpu(unsigned int cpu, int vector);
+
+/*
+ * CHARACTER-DEVICE DEFINITIONS
+ */
+
+#define PORT_NORMAL    0x0000
+#define PORT_EXCEPTION 0x8000
+#define PORTIDX_MASK   0x7fff
+
+/* /dev/xen/evtchn resides at device number major=10, minor=200 */
+#define EVTCHN_MINOR 200
+
+/* /dev/xen/evtchn ioctls: */
+/* EVTCHN_RESET: Clear and reinit the event buffer. Clear error condition. */
+#define EVTCHN_RESET  _IO('E', 1)
+/* EVTCHN_BIND: Bind to the specified event-channel port. */
+#define EVTCHN_BIND   _IO('E', 2)
+/* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
+#define EVTCHN_UNBIND _IO('E', 3)
+
+#endif /* __ASM_EVTCHN_H__ */
+/******************************************************************************
+ * evtchn.h
+ * 
+ * Communication via Xen event channels.
+ * Also definitions for the device that demuxes notifications to userspace.
+ * 
+ * Copyright (c) 2004, K A Fraser
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __ASM_EVTCHN_H__
+#define __ASM_EVTCHN_H__
+#include <machine/pcpu.h>
+#include <xen/hypervisor.h>
+#include <machine/xen/synch_bitops.h>
+#include <machine/frame.h>
+
+/*
+ * LOW-LEVEL DEFINITIONS
+ */
+
+/*
+ * Unlike notify_remote_via_evtchn(), this is safe to use across
+ * save/restore. Notifications on a broken connection are silently dropped.
+ */
+void notify_remote_via_irq(int irq);
+
+
+/* Entry point for notifications into Linux subsystems. */
+void evtchn_do_upcall(struct trapframe *frame);
+
+/* Entry point for notifications into the userland character device. */
+void evtchn_device_upcall(int port);
+
+void mask_evtchn(int port);
+
+void unmask_evtchn(int port);
+
+#ifdef SMP
+void rebind_evtchn_to_cpu(int port, unsigned int cpu);
+#else
+#define rebind_evtchn_to_cpu(port, cpu)	((void)0)
+#endif
+
+static inline
+int test_and_set_evtchn_mask(int port)
+{
+	shared_info_t *s = HYPERVISOR_shared_info;
+	return synch_test_and_set_bit(port, s->evtchn_mask);
+}
+
+static inline void 
+clear_evtchn(int port)
+{
+	shared_info_t *s = HYPERVISOR_shared_info;
+	synch_clear_bit(port, &s->evtchn_pending[0]);
+}
+
+static inline void 
+notify_remote_via_evtchn(int port)
+{
+        struct evtchn_send send = { .port = port };
+        (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
+}
+
+/*
+ * Use these to access the event channel underlying the IRQ handle returned
+ * by bind_*_to_irqhandler().
+ */
+int irq_to_evtchn_port(int irq);
+
+void ipi_pcpu(unsigned int cpu, int vector);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812290135.mBT1Zvn6035937>