From pete@f10master.secroom.net  Wed Feb 27 08:30:43 2013
Return-Path: <pete@f10master.secroom.net>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 87C152B7
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Feb 2013 08:30:43 +0000 (UTC)
	(envelope-from pete@f10master.secroom.net)
Received: from f10master.secroom.net (unknown [IPv6:2001:67c:164:40:216:3eff:fe00:84])
	by mx1.freebsd.org (Postfix) with ESMTP id F090C107
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Feb 2013 08:30:42 +0000 (UTC)
Received: from f10master.secroom.net (localhost [127.0.0.1])
	by f10master.secroom.net (8.14.6/8.14.5) with ESMTP id r1Q88FJd001443
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Feb 2013 10:08:15 +0200 (EET)
	(envelope-from pete@f10master.secroom.net)
Received: (from root@localhost)
	by f10master.secroom.net (8.14.6/8.14.5/Submit) id r1Q88Frr001442;
	Tue, 26 Feb 2013 10:08:15 +0200 (EET)
	(envelope-from pete)
Message-Id: <201302260808.r1Q88Frr001442@f10master.secroom.net>
Date: Tue, 26 Feb 2013 10:08:15 +0200 (EET)
From: pete@helenius.fi
Reply-To: pete@helenius.fi
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: xn driver crash on detach
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         176471
>Category:       kern
>Synopsis:       [xen] xn driver crash on detach
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-xen
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 27 08:40:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Tue Jun 18 23:20:01 UTC 2013
>Originator:     Charlie Root
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
System: FreeBSD f10master.secroom.net 10.0-CURRENT FreeBSD 10.0-CURRENT #3: Tue Feb 26 00:23:53 EET 2013 root@zfsmaster.secroom.net:/usr/obj/usr/src/sys/XENSR amd64


>Description:
	Using XenServer, detaching or changing configuration of xn network interface will lead to kernel panic in 9-STABLE and 10-CURRENT
>How-To-Repeat:
	Detach the interface when the VM is running
>Fix:
	Workaround is to shutdown the VM


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-xen 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Feb 27 14:54:25 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=176471 

From: =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= <roger.pau@citrix.com>
To: <bug-followup@FreeBSD.org>, <pete@helenius.fi>
Cc:  
Subject: Re: kern/176471: [xen] xn driver crash on detach
Date: Thu, 28 Feb 2013 18:00:12 +0100

 Hello,
 
 I've been able to reproduce this bug with Xen unstable, here is a fix 
 for it.
 
 ---
 From 6206137f80cbe5812294b1733a86f28e5cdc01bd Mon Sep 17 00:00:00 2001
 From: Roger Pau Monne <roger.pau@citrix.com>
 Date: Thu, 28 Feb 2013 17:43:34 +0100
 Subject: [PATCH] xen-netfront: fix detach of network interfaces
 
 Remove all the media and the interface when detaching it. Prevents the
 following panic when detaching an interface (xl network-detach freebsd
 1)
 
 xn1: detached
 
 Fatal trap 12: page fault while in kernel mode
 cpuid = 3; apic id = 06
 fault virtual address	= 0xffffff80028ff2a0
 fault code		= supervisor read data, page not present
 instruction pointer	= 0x20:0xffffffff809653af
 stack pointer	        = 0x28:0xffffff8117cb4940
 frame pointer	        = 0x28:0xffffff8117cb4980
 code segment		= base 0x0, limit 0xfffff, type 0x1b
 			= DPL 0, pres 1, long 1, def32 0, gran 1
 processor eflags	= interrupt enabled, resume, IOPL = 0
 current process		= 699 (devd)
 [ thread pid 699 tid 100107 ]
 Stopped at      ifmedia_ioctl+0x3f:     movq    0x8(%r12),%rcx
 db> trace
 Tracing pid 706 tid 100059 td 0xfffffe0006b69480
 ifmedia_ioctl() at ifmedia_ioctl+0x3f/frame 0xffffff80f774c980
 ifioctl() at ifioctl+0xeb7/frame 0xffffff80f774ca40
 kern_ioctl() at kern_ioctl+0x1ce/frame 0xffffff80f774ca90
 sys_ioctl() at sys_ioctl+0x11f/frame 0xffffff80f774cae0
 amd64_syscall() at amd64_syscall+0x265/frame 0xffffff80f774cbf0
 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xffffff80f774cbf0
 --- syscall (54, FreeBSD ELF64, sys_ioctl), rip = 0x44c60a, rsp = 0x7fffffffd678, rbp = 0x7fffffffd750 ---
 
 PR: 176471
 ---
  sys/dev/xen/netfront/netfront.c |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
 
 diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
 index 88641e3..167fd12 100644
 --- a/sys/dev/xen/netfront/netfront.c
 +++ b/sys/dev/xen/netfront/netfront.c
 @@ -2172,6 +2172,9 @@ static void
  netif_free(struct netfront_info *info)
  {
  	netif_disconnect_backend(info);
 +	ifmedia_removeall(&info->sc_media);
 +	ether_ifdetach(info->xn_ifp);
 +	if_free(info->xn_ifp);
  #if 0
  	close_netdev(info);
  #endif
 -- 
 1.7.7.5 (Apple Git-26)

From: =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= <roger.pau@citrix.com>
To: <bug-followup@FreeBSD.org>, <pete@helenius.fi>
Cc:  
Subject: Re: kern/176471: [xen] xn driver crash on detach
Date: Thu, 28 Feb 2013 18:58:44 +0100

 Hi (again),
 
 I've just realized the previous patch also crashed when trying to 
 detach an interface that's up and running, the following patch allows 
 to detach the interface while running without crashing the FreeBSD 
 kernel.
 
 Also, what do you mean by "changing configuration of xn network"?
 
 ---
 From 9c0097ed4775c68769049c61e474ddb62cc11d1f Mon Sep 17 00:00:00 2001
 From: Roger Pau Monne <roger.pau@citrix.com>
 Date: Thu, 28 Feb 2013 17:43:34 +0100
 Subject: [PATCH] xen-netfront: fix detach of network interfaces
 
 Remove all the media and the interface when detaching it. Prevents the
 following panic when detaching an interface (xl network-detach freebsd
 1)
 
 xn1: detached
 
 Fatal trap 12: page fault while in kernel mode
 cpuid = 3; apic id = 06
 fault virtual address	= 0xffffff80028ff2a0
 fault code		= supervisor read data, page not present
 instruction pointer	= 0x20:0xffffffff809653af
 stack pointer	        = 0x28:0xffffff8117cb4940
 frame pointer	        = 0x28:0xffffff8117cb4980
 code segment		= base 0x0, limit 0xfffff, type 0x1b
 			= DPL 0, pres 1, long 1, def32 0, gran 1
 processor eflags	= interrupt enabled, resume, IOPL = 0
 current process		= 699 (devd)
 [ thread pid 699 tid 100107 ]
 Stopped at      ifmedia_ioctl+0x3f:     movq    0x8(%r12),%rcx
 db> trace
 Tracing pid 706 tid 100059 td 0xfffffe0006b69480
 ifmedia_ioctl() at ifmedia_ioctl+0x3f/frame 0xffffff80f774c980
 ifioctl() at ifioctl+0xeb7/frame 0xffffff80f774ca40
 kern_ioctl() at kern_ioctl+0x1ce/frame 0xffffff80f774ca90
 sys_ioctl() at sys_ioctl+0x11f/frame 0xffffff80f774cae0
 amd64_syscall() at amd64_syscall+0x265/frame 0xffffff80f774cbf0
 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xffffff80f774cbf0
 --- syscall (54, FreeBSD ELF64, sys_ioctl), rip = 0x44c60a, rsp = 0x7fffffffd678, rbp = 0x7fffffffd750 ---
 
 PR: 176471
 ---
  sys/dev/xen/netfront/netfront.c |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)
 
 diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
 index 88641e3..3a8b8ea 100644
 --- a/sys/dev/xen/netfront/netfront.c
 +++ b/sys/dev/xen/netfront/netfront.c
 @@ -2171,7 +2171,14 @@ netfront_detach(device_t dev)
  static void
  netif_free(struct netfront_info *info)
  {
 +	XN_LOCK(info);
 +	xn_stop(info);
 +	XN_UNLOCK(info);
 +	callout_drain(&info->xn_stat_ch);
  	netif_disconnect_backend(info);
 +	ifmedia_removeall(&info->sc_media);
 +	ether_ifdetach(info->xn_ifp);
 +	if_free(info->xn_ifp);
  #if 0
  	close_netdev(info);
  #endif
 -- 
 1.7.7.5 (Apple Git-26)

From: Petri Helenius <petri@helenius.fi>
To: =?iso-8859-1?Q?Roger_Pau_Monn=E9?= <roger.pau@citrix.com>
Cc: <bug-followup@FreeBSD.org>,
 <pete@helenius.fi>
Subject: Re: kern/176471: [xen] xn driver crash on detach
Date: Fri, 1 Mar 2013 12:19:34 +0200

 On Feb 28, 2013, at 19:58 , Roger Pau Monn=E9 <roger.pau@citrix.com> =
 wrote:
 
 > Hi (again),
 >=20
 > I've just realized the previous patch also crashed when trying to=20
 > detach an interface that's up and running, the following patch allows=20=
 
 > to detach the interface while running without crashing the FreeBSD=20
 > kernel.
 >=20
 > Also, what do you mean by "changing configuration of xn network"?
 
 Using the management console, I think it just does detach / attach.=20
 
 The second patch works in 10-CURRENT, will try 9-STABLE.=20
 
 Pete
 
 >=20
 > ---
 > =46rom 9c0097ed4775c68769049c61e474ddb62cc11d1f Mon Sep 17 00:00:00 =
 2001
 > From: Roger Pau Monne <roger.pau@citrix.com>
 > Date: Thu, 28 Feb 2013 17:43:34 +0100
 > Subject: [PATCH] xen-netfront: fix detach of network interfaces
 >=20
 > Remove all the media and the interface when detaching it. Prevents the
 > following panic when detaching an interface (xl network-detach freebsd
 > 1)
 >=20
 > xn1: detached
 >=20
 > Fatal trap 12: page fault while in kernel mode
 > cpuid =3D 3; apic id =3D 06
 > fault virtual address	=3D 0xffffff80028ff2a0
 > fault code		=3D supervisor read data, page not present
 > instruction pointer	=3D 0x20:0xffffffff809653af
 > stack pointer	        =3D 0x28:0xffffff8117cb4940
 > frame pointer	        =3D 0x28:0xffffff8117cb4980
 > code segment		=3D base 0x0, limit 0xfffff, type 0x1b
 > 			=3D DPL 0, pres 1, long 1, def32 0, gran 1
 > processor eflags	=3D interrupt enabled, resume, IOPL =3D 0
 > current process		=3D 699 (devd)
 > [ thread pid 699 tid 100107 ]
 > Stopped at      ifmedia_ioctl+0x3f:     movq    0x8(%r12),%rcx
 > db> trace
 > Tracing pid 706 tid 100059 td 0xfffffe0006b69480
 > ifmedia_ioctl() at ifmedia_ioctl+0x3f/frame 0xffffff80f774c980
 > ifioctl() at ifioctl+0xeb7/frame 0xffffff80f774ca40
 > kern_ioctl() at kern_ioctl+0x1ce/frame 0xffffff80f774ca90
 > sys_ioctl() at sys_ioctl+0x11f/frame 0xffffff80f774cae0
 > amd64_syscall() at amd64_syscall+0x265/frame 0xffffff80f774cbf0
 > Xfast_syscall() at Xfast_syscall+0xfb/frame 0xffffff80f774cbf0
 > --- syscall (54, FreeBSD ELF64, sys_ioctl), rip =3D 0x44c60a, rsp =3D =
 0x7fffffffd678, rbp =3D 0x7fffffffd750 ---
 >=20
 > PR: 176471
 > ---
 > sys/dev/xen/netfront/netfront.c |    7 +++++++
 > 1 files changed, 7 insertions(+), 0 deletions(-)
 >=20
 > diff --git a/sys/dev/xen/netfront/netfront.c =
 b/sys/dev/xen/netfront/netfront.c
 > index 88641e3..3a8b8ea 100644
 > --- a/sys/dev/xen/netfront/netfront.c
 > +++ b/sys/dev/xen/netfront/netfront.c
 > @@ -2171,7 +2171,14 @@ netfront_detach(device_t dev)
 > static void
 > netif_free(struct netfront_info *info)
 > {
 > +	XN_LOCK(info);
 > +	xn_stop(info);
 > +	XN_UNLOCK(info);
 > +	callout_drain(&info->xn_stat_ch);
 > 	netif_disconnect_backend(info);
 > +	ifmedia_removeall(&info->sc_media);
 > +	ether_ifdetach(info->xn_ifp);
 > +	if_free(info->xn_ifp);
 > #if 0
 > 	close_netdev(info);
 > #endif
 > --=20
 > 1.7.7.5 (Apple Git-26)
 

From: Mark Felder <feld@feld.me>
To: bug-followup@freebsd.org, pete@helenius.fi
Cc:  
Subject: Re: kern/176471: [xen] xn driver crash on detach
Date: Fri, 1 Mar 2013 08:37:40 -0600

 ------------ZKr8kQLgp1eZBwnNXnyCtT
 Content-Type: text/plain; format=flowed; delsp=yes
 
 I had to reformat the patch (the one in this PR didn't come through well)  
 but I've tested this on FreeBSD 9.0 and our Xen environment and I can  
 successfully add/remove network interfaces and change their properties  
 without crashes.
 
 I still have to attempt this on the FreeBSD 9.1 VMs but I don't expect  
 different results.
 
 
 Thank you very much Roger!
 
 ------------ZKr8kQLgp1eZBwnNXnyCtT
 Content-Disposition: attachment; filename=xen-netfront.patch
 Content-Type: application/octet-stream; name=xen-netfront.patch
 Content-Transfer-Encoding: base64
 
 LS0tIHN5cy9kZXYveGVuL25ldGZyb250L25ldGZyb250LmMub3JpZwkyMDEzLTAzLTAxIDA2
 OjUyOjQ2LjAwMDAwMDAwMCAtMDYwMAorKysgc3lzL2Rldi94ZW4vbmV0ZnJvbnQvbmV0ZnJv
 bnQuYwkyMDEzLTAzLTAxIDA2OjU0OjE5LjAwMDAwMDAwMCAtMDYwMApAQCAtMjE5OSw3ICsy
 MTk5LDE0IEBACiBzdGF0aWMgdm9pZAogbmV0aWZfZnJlZShzdHJ1Y3QgbmV0ZnJvbnRfaW5m
 byAqaW5mbykKIHsKKwlYTl9MT0NLKGluZm8pOworCXhuX3N0b3AoaW5mbyk7CisJWE5fVU5M
 T0NLKGluZm8pOworCWNhbGxvdXRfZHJhaW4oJmluZm8tPnhuX3N0YXRfY2gpOwogCW5ldGlm
 X2Rpc2Nvbm5lY3RfYmFja2VuZChpbmZvKTsKKwlpZm1lZGlhX3JlbW92ZWFsbCgmaW5mby0+
 c2NfbWVkaWEpOworCWV0aGVyX2lmZGV0YWNoKGluZm8tPnhuX2lmcCk7CisJaWZfZnJlZShp
 bmZvLT54bl9pZnApOwogI2lmIDAKIAljbG9zZV9uZXRkZXYoaW5mbyk7CiAjZW5kaWYK
 
 ------------ZKr8kQLgp1eZBwnNXnyCtT--

From: Adam McDougall <mcdouga9@egr.msu.edu>
To: bug-followup@FreeBSD.org, pete@helenius.fi
Cc:  
Subject: Re: kern/176471: [xen] xn driver crash on detach
Date: Tue, 21 May 2013 09:57:06 -0400

 This patch is working well for me as well, using it on 9.1-stable.  Can
 we get it committed?  Thanks.

From: "Mark Felder" <feld@feld.me>
To: bug-followup@freebsd.org, pete@helenius.fi
Cc:  
Subject: Re: kern/176471: [xen] xn driver crash on detach
Date: Tue, 21 May 2013 09:52:28 -0500

 I've been running this in production since March 1st with no problems. I  
 also would like to see this committed ASAP.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/176471: commit references a PR
Date: Wed, 22 May 2013 17:13:21 +0000 (UTC)

 Author: gibbs
 Date: Wed May 22 17:13:03 2013
 New Revision: 250913
 URL: http://svnweb.freebsd.org/changeset/base/250913
 
 Log:
   Correct panic on detach of Xen PV network interfaces.
   
   dev/xen/netfront:
       In netif_free(), properly stop the interface and drain any pending
       timers prior to disconnecting from the backend device.
   
       Remove all media and detach our interface object from the system
       prior to deleting it.
   
   PR:		kern/176471
   Submitted by:	Roger Pau Monne <roger.pau@citrix.com>
   Reviewed by:	gibbs
   MFC after:	1 week
 
 Modified:
   head/sys/dev/xen/netfront/netfront.c
 
 Modified: head/sys/dev/xen/netfront/netfront.c
 ==============================================================================
 --- head/sys/dev/xen/netfront/netfront.c	Wed May 22 16:33:28 2013	(r250912)
 +++ head/sys/dev/xen/netfront/netfront.c	Wed May 22 17:13:03 2013	(r250913)
 @@ -2171,10 +2171,14 @@ netfront_detach(device_t dev)
  static void
  netif_free(struct netfront_info *info)
  {
 +	XN_LOCK(info);
 +	xn_stop(info);
 +	XN_UNLOCK(info);
 +	callout_drain(&info->xn_stat_ch);
  	netif_disconnect_backend(info);
 -#if 0
 -	close_netdev(info);
 -#endif
 +	ifmedia_removeall(&info->sc_media);
 +	ether_ifdetach(info->xn_ifp);
 +	if_free(info->xn_ifp);
  }
  
  static void
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/176471: commit references a PR
Date: Tue, 18 Jun 2013 23:14:35 +0000 (UTC)

 Author: gibbs
 Date: Tue Jun 18 23:14:21 2013
 New Revision: 251973
 URL: http://svnweb.freebsd.org/changeset/base/251973
 
 Log:
   MFC Xen fixes:
   
   svn rev 250081 Author:gibbs Date:2013-04-29T23:08:13.552620Z
   ==============
   xenstore/xenstore.c:
       Prevent access to invalid memory region when listing an empty
       directory in the XenStore.
   
   Reported by:	Bei Guan
   
   svn rev 250913 Author:gibbs Date:2013-05-22T17:13:03.545339Z
   ==============
   Correct panic on detach of Xen PV network interfaces.
   
   dev/xen/netfront:
       In netif_free(), properly stop the interface and drain any pending
       timers prior to disconnecting from the backend device.
   
       Remove all media and detach our interface object from the system
       prior to deleting it.
   
   PR:		kern/176471
   Submitted by:	Roger Pau Monne <roger.pau@citrix.com>
   Reviewed by:	gibbs
   
   svn rev 250917 Author:gibbs Date:2013-05-22T19:22:44.923351Z
   ==============
   Fix loss of the emulated keyboard on Xen PV HVM domains.
   
   xen/xenbus/xenbusb.c:
       In xenbusb_probe_children(), do not modify the XenBus state of
       devices for which we have no PV driver support. An emulated device
       we do support may share this backend.  Hide the node from XenBus
       instead.
   
       This prevents closing the vkbd device, which Qemu's emulated keyboard
       device is using as the source for keyboard events.
   
       Tested with qemu-xen-traditional, qemu-xen and qemu stubdomains, all
       working as expected.
   
   Submitted by:	Roger Pau Monne <roger.pau@citrix.com>
   Reviewed by:	gibbs
   MFC after:	1 week
   
   svn rev 251175 Author:gibbs Date:2013-05-31T04:43:19.944993Z
   ==============
   Apply the ad* => ada* IDE device name transition to the Xen block
   front driver.
   
   Submitted by:	Bei Guan <gbtju85@gmail.com>
   Reviewed by:	gibbs
   MFC after:	1 week
   
   svn rev 251176 Author:gibbs Date:2013-05-31T04:45:59.563195Z
   ==============
   Make netif_free() safe to call on a partially initialized softc.
   
   Sponsored by:	Spectra Logic Corporation
   MFC after:	1 week
   
   svn rev 251729 Author:gibbs Date:2013-06-14T03:31:11.033200Z
   ==============
   sys/dev/xen/netfront/netfront.c:
       In netif_free(), call ifmedia_removeall() after ether_ifdetach()
       so that bpf listeners are detached, any link state processing
       is completed, and there is no chance for external reference to media
       information.
   
   Suggested by:	yongari
 
 Modified:
   stable/9/sys/dev/xen/blkfront/blkfront.c
   stable/9/sys/dev/xen/netfront/netfront.c
   stable/9/sys/xen/xenbus/xenbusb.c
   stable/9/sys/xen/xenstore/xenstore.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/dev/   (props changed)
 
 Modified: stable/9/sys/dev/xen/blkfront/blkfront.c
 ==============================================================================
 --- stable/9/sys/dev/xen/blkfront/blkfront.c	Tue Jun 18 23:11:36 2013	(r251972)
 +++ stable/9/sys/dev/xen/blkfront/blkfront.c	Tue Jun 18 23:14:21 2013	(r251973)
 @@ -148,16 +148,16 @@ blkfront_vdevice_to_unit(uint32_t vdevic
  		int base;
  		const char *name;
  	} info[] = {
 -		{3,	6,	0,	"ad"},	/* ide0 */
 -		{22,	6,	2,	"ad"},	/* ide1 */
 -		{33,	6,	4,	"ad"},	/* ide2 */
 -		{34,	6,	6,	"ad"},	/* ide3 */
 -		{56,	6,	8,	"ad"},	/* ide4 */
 -		{57,	6,	10,	"ad"},	/* ide5 */
 -		{88,	6,	12,	"ad"},	/* ide6 */
 -		{89,	6,	14,	"ad"},	/* ide7 */
 -		{90,	6,	16,	"ad"},	/* ide8 */
 -		{91,	6,	18,	"ad"},	/* ide9 */
 +		{3,	6,	0,	"ada"},	/* ide0 */
 +		{22,	6,	2,	"ada"},	/* ide1 */
 +		{33,	6,	4,	"ada"},	/* ide2 */
 +		{34,	6,	6,	"ada"},	/* ide3 */
 +		{56,	6,	8,	"ada"},	/* ide4 */
 +		{57,	6,	10,	"ada"},	/* ide5 */
 +		{88,	6,	12,	"ada"},	/* ide6 */
 +		{89,	6,	14,	"ada"},	/* ide7 */
 +		{90,	6,	16,	"ada"},	/* ide8 */
 +		{91,	6,	18,	"ada"},	/* ide9 */
  
  		{8,	4,	0,	"da"},	/* scsi disk0 */
  		{65,	4,	16,	"da"},	/* scsi disk1 */
 
 Modified: stable/9/sys/dev/xen/netfront/netfront.c
 ==============================================================================
 --- stable/9/sys/dev/xen/netfront/netfront.c	Tue Jun 18 23:11:36 2013	(r251972)
 +++ stable/9/sys/dev/xen/netfront/netfront.c	Tue Jun 18 23:14:21 2013	(r251973)
 @@ -2172,10 +2172,17 @@ netfront_detach(device_t dev)
  static void
  netif_free(struct netfront_info *info)
  {
 +	XN_LOCK(info);
 +	xn_stop(info);
 +	XN_UNLOCK(info);
 +	callout_drain(&info->xn_stat_ch);
  	netif_disconnect_backend(info);
 -#if 0
 -	close_netdev(info);
 -#endif
 +	if (info->xn_ifp != NULL) {
 +		ether_ifdetach(info->xn_ifp);
 +		if_free(info->xn_ifp);
 +		info->xn_ifp = NULL;
 +	}
 +	ifmedia_removeall(&info->sc_media);
  }
  
  static void
 
 Modified: stable/9/sys/xen/xenbus/xenbusb.c
 ==============================================================================
 --- stable/9/sys/xen/xenbus/xenbusb.c	Tue Jun 18 23:11:36 2013	(r251972)
 +++ stable/9/sys/xen/xenbus/xenbusb.c	Tue Jun 18 23:14:21 2013	(r251973)
 @@ -404,6 +404,31 @@ xenbusb_device_sysctl_init(device_t dev)
  }
  
  /**
 + * \brief Decrement the number of XenBus child devices in the
 + *        connecting state by one and release the xbs_attch_ch
 + *        interrupt configuration hook if the connecting count
 + *        drops to zero.
 + *
 + * \param xbs  XenBus Bus device softc of the owner of the bus to enumerate.
 + */
 +static void
 +xenbusb_release_confighook(struct xenbusb_softc *xbs)
 +{
 +	mtx_lock(&xbs->xbs_lock);
 +	KASSERT(xbs->xbs_connecting_children > 0,
 +		("Connecting device count error\n"));
 +	xbs->xbs_connecting_children--;
 +	if (xbs->xbs_connecting_children == 0
 +	 && (xbs->xbs_flags & XBS_ATTACH_CH_ACTIVE) != 0) {
 +		xbs->xbs_flags &= ~XBS_ATTACH_CH_ACTIVE;
 +		mtx_unlock(&xbs->xbs_lock);
 +		config_intrhook_disestablish(&xbs->xbs_attach_ch);
 +	} else {
 +		mtx_unlock(&xbs->xbs_lock);
 +	}
 +}
 +
 +/**
   * \brief Verify the existance of attached device instances and perform
   *        probe/attach processing for newly arrived devices.
   *
 @@ -417,7 +442,7 @@ xenbusb_probe_children(device_t dev)
  {
  	device_t *kids;
  	struct xenbus_device_ivars *ivars;
 -	int i, count;
 +	int i, count, error;
  
  	if (device_get_children(dev, &kids, &count) == 0) {
  		for (i = 0; i < count; i++) {
 @@ -430,7 +455,30 @@ xenbusb_probe_children(device_t dev)
  				continue;
  			}
  
 -			if (device_probe_and_attach(kids[i])) {
 +			error = device_probe_and_attach(kids[i]);
 +			if (error == ENXIO) {
 +				struct xenbusb_softc *xbs;
 +
 +				/*
 +				 * We don't have a PV driver for this device.
 +				 * However, an emulated device we do support
 +				 * may share this backend.  Hide the node from
 +				 * XenBus until the next rescan, but leave it's
 +				 * state unchanged so we don't inadvertently
 +				 * prevent attachment of any emulated device.
 +				 */
 +				xenbusb_delete_child(dev, kids[i]);
 +
 +				/*
 +				 * Since the XenStore state of this device
 +				 * still indicates a pending attach, manually
 +				 * release it's hold on the boot process.
 +				 */
 +				xbs = device_get_softc(dev);
 +				xenbusb_release_confighook(xbs);
 +
 +				continue;
 +			} else if (error) {
  				/*
  				 * Transition device to the closed state
  				 * so the world knows that attachment will
 @@ -579,31 +627,6 @@ xenbusb_nop_confighook_cb(void *arg __un
  {
  }
  
 -/**
 - * \brief Decrement the number of XenBus child devices in the
 - *        connecting state by one and release the xbs_attch_ch
 - *        interrupt configuration hook if the connecting count
 - *        drops to zero.
 - *
 - * \param xbs  XenBus Bus device softc of the owner of the bus to enumerate.
 - */
 -static void
 -xenbusb_release_confighook(struct xenbusb_softc *xbs)
 -{
 -	mtx_lock(&xbs->xbs_lock);
 -	KASSERT(xbs->xbs_connecting_children > 0,
 -		("Connecting device count error\n"));
 -	xbs->xbs_connecting_children--;
 -	if (xbs->xbs_connecting_children == 0
 -	 && (xbs->xbs_flags & XBS_ATTACH_CH_ACTIVE) != 0) {
 -		xbs->xbs_flags &= ~XBS_ATTACH_CH_ACTIVE;
 -		mtx_unlock(&xbs->xbs_lock);
 -		config_intrhook_disestablish(&xbs->xbs_attach_ch);
 -	} else {
 -		mtx_unlock(&xbs->xbs_lock);
 -	}
 -}
 -
  /*--------------------------- Public Functions -------------------------------*/
  /*--------- API comments for these methods can be found in xenbusb.h ---------*/
  void
 
 Modified: stable/9/sys/xen/xenstore/xenstore.c
 ==============================================================================
 --- stable/9/sys/xen/xenstore/xenstore.c	Tue Jun 18 23:11:36 2013	(r251972)
 +++ stable/9/sys/xen/xenstore/xenstore.c	Tue Jun 18 23:14:21 2013	(r251973)
 @@ -307,7 +307,8 @@ split(char *strings, u_int len, u_int *n
  	const char **ret;
  
  	/* Protect against unterminated buffers. */
 -	strings[len - 1] = '\0';
 +	if (len > 0)
 +		strings[len - 1] = '\0';
  
  	/* Count the strings. */
  	*num = extract_strings(strings, /*dest*/NULL, len);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
