Date: Sun, 01 Apr 2012 15:25:03 +0300 From: Mikolaj Golub <trociny@freebsd.org> To: Bernhard Froehlich <decke@FreeBSD.org> Cc: freebsd-emulation@freebsd.org, freebsd-virtualization@freebsd.org Subject: Re: [patch] VirtualBox-4.0.14 + FreeBSD/CURRENT + VIMAGE: crash on vm shutdown Message-ID: <86iphjiqqo.fsf@kopusha.home.net> In-Reply-To: <12f5de744d0ca920d3b204aa291b4084@bluelife.at> (Bernhard Froehlich's message of "Fri, 30 Mar 2012 10:13:57 %2B0200") References: <867gyg77h0.fsf@kopusha.home.net> <12f5de744d0ca920d3b204aa291b4084@bluelife.at>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-= Hi, On Fri, 30 Mar 2012 10:13:57 +0200 Bernhard Froehlich wrote: BF> Sorry for the late response and thanks for the patch. Is this patch BF> still required for 4.1.8? My guess is yes but it would be great if you BF> could confirm that with the latest port. Sorry, it required some time to check -- I upgraded my box to the latest current and had some instabilities to fix before testing vbox. So on the recent current and VirtualBox-4.1.10 (the latest version I have found in the ports) the VBoxNetFlt patch is still required but VBoxNetAdp also needs patching: I had a crash on vm start: #0 doadump (textdump=-2022600704) at pcpu.h:244 #1 0x8051af69 in db_fncall (dummy1=1, dummy2=0, dummy3=-2127583648, dummy4=0xdcb61838 "") at /home/golub/freebsd/base/head/sys/ddb/db_command.c:573 #2 0x8051b361 in db_command (last_cmdp=0x811221fc, cmd_table=0x0, dopager=1) at /home/golub/freebsd/base/head/sys/ddb/db_command.c:449 #3 0x8051b4ba in db_command_loop () at /home/golub/freebsd/base/head/sys/ddb/db_command.c:502 #4 0x8051d4ad in db_trap (type=12, code=0) at /home/golub/freebsd/base/head/sys/ddb/db_main.c:229 #5 0x80a81d96 in kdb_trap (type=12, code=0, tf=0xdcb61ad4) at /home/golub/freebsd/base/head/sys/kern/subr_kdb.c:629 #6 0x80dd22af in trap_fatal (frame=0xdcb61ad4, eva=24) at /home/golub/freebsd/base/head/sys/i386/i386/trap.c:1014 #7 0x80dd2387 in trap_pfault (frame=0xdcb61ad4, usermode=0, eva=24) at /home/golub/freebsd/base/head/sys/i386/i386/trap.c:835 #8 0x80dd3451 in trap (frame=0xdcb61ad4) at /home/golub/freebsd/base/head/sys/i386/i386/trap.c:547 #9 0x80dbccac in calltrap () at /home/golub/freebsd/base/head/sys/i386/i386/exception.s:169 #10 0x80b0633e in ifindex_alloc_locked (idxp=0xdcb61b56) at /home/golub/freebsd/base/head/sys/net/if.c:279 #11 0x80b09172 in if_alloc (type=6 '\006') at /home/golub/freebsd/base/head/sys/net/if.c:435 #12 0x8b01e8e7 in vboxNetAdpOsCreate () from /boot/modules/vboxnetadp.ko #13 0x8b01ef00 in vboxNetAdpCreate () from /boot/modules/vboxnetadp.ko #14 0x8b01ecd8 in VBoxNetAdpFreeBSDCtrlioctl () from /boot/modules/vboxnetadp.ko #15 0x8095c6bb in devfs_ioctl_f (fp=0x8b6f8118, com=3223352833, data=0x8b022360, cred=0x87759b00, td=0x89fdf2e0) at /home/golub/freebsd/base/head/sys/fs/devfs/devfs_vnops.c:757 #16 0x80a9b4ed in kern_ioctl (td=0x89fdf2e0, fd=3, com=3223352833, data=0x8b022360 "vboxnet0") at file.h:287 #17 0x80a9b674 in sys_ioctl (td=0x89fdf2e0, uap=0xdcb61cec) at /home/golub/freebsd/base/head/sys/kern/sys_generic.c:691 #18 0x80dd29ae in syscall (frame=0xdcb61d28) at subr_syscall.c:135 I am attaching two patches: the first one is for VBoxNetFlt (the same I sent to the list but against 4.1.10) and the second one for VBoxNetAdp (a fix for the panic above). BF> Do you aggree that this patch is under MIT License so that I can push BF> it upstream? Sure for both patches. Thanks for taking it! -- Mikolaj Golub --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=VirtualBox-4.1.10.VBoxNetFlt.freebsd.VIMAGE.patch diff -rpu VirtualBox-4.1.10.orig/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c VirtualBox-4.1.10/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c --- VirtualBox-4.1.10.orig/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c 2012-03-13 15:15:44.000000000 +0200 +++ VirtualBox-4.1.10/src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c 2012-04-01 13:43:02.000000000 +0300 @@ -651,13 +651,13 @@ bool vboxNetFltOsMaybeRediscovered(PVBOX ng_rmnode_self(pThis->u.s.node); pThis->u.s.node = NULL; } + VBOXCURVNET_RESTORE(); if (ifp0 != NULL) { vboxNetFltOsDeleteInstance(pThis); vboxNetFltOsInitInstance(pThis, NULL); } - VBOXCURVNET_RESTORE(); return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); } @@ -671,8 +671,10 @@ void vboxNetFltOsDeleteInstance(PVBOXNET mtx_destroy(&pThis->u.s.inq.ifq_mtx); mtx_destroy(&pThis->u.s.outq.ifq_mtx); + VBOXCURVNET_SET_FROM_UCRED(); if (pThis->u.s.node != NULL) ng_rmnode_self(pThis->u.s.node); + VBOXCURVNET_RESTORE(); pThis->u.s.node = NULL; } --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=VirtualBox-4.1.10.VBoxNetAdp.freebsd.VIMAGE.patch diff -rpu VirtualBox-4.1.10.orig/src/VBox/HostDrivers/VBoxNetAdp/freebsd/Makefile VirtualBox-4.1.10/src/VBox/HostDrivers/VBoxNetAdp/freebsd/Makefile --- VirtualBox-4.1.10.orig/src/VBox/HostDrivers/VBoxNetAdp/freebsd/Makefile 2012-03-13 15:15:44.000000000 +0200 +++ VirtualBox-4.1.10/src/VBox/HostDrivers/VBoxNetAdp/freebsd/Makefile 2012-04-01 13:27:16.000000000 +0300 @@ -18,7 +18,7 @@ KMOD = vboxnetadp -CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING +CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVIMAGE .if (${MACHINE_ARCH} == "i386") CFLAGS += -DRT_ARCH_X86 diff -rpu VirtualBox-4.1.10.orig/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c VirtualBox-4.1.10/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c --- VirtualBox-4.1.10.orig/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2012-03-13 15:15:44.000000000 +0200 +++ VirtualBox-4.1.10/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2012-04-01 13:23:58.000000000 +0300 @@ -68,6 +68,22 @@ #define VBOXNETADP_OS_SPECFIC 1 #include "../VBoxNetAdpInternal.h" +#if defined(__FreeBSD_version) && __FreeBSD_version >= 800500 +# include <sys/jail.h> +# include <net/vnet.h> + +# define VBOXCURVNET_SET(arg) CURVNET_SET_QUIET(arg) +# define VBOXCURVNET_SET_FROM_UCRED() VBOXCURVNET_SET(CRED_TO_VNET(curthread->td_ucred)) +# define VBOXCURVNET_RESTORE() CURVNET_RESTORE() + +#else /* !defined(__FreeBSD_version) || __FreeBSD_version < 800500 */ + +# define VBOXCURVNET_SET(arg) +# define VBOXCURVNET_SET_FROM_UCRED() +# define VBOXCURVNET_RESTORE() + +#endif /* !defined(__FreeBSD_version) || __FreeBSD_version < 800500 */ + static int VBoxNetAdpFreeBSDCtrlioctl(struct cdev *, u_long, caddr_t, int flags, struct thread *); static struct cdevsw vboxnetadp_cdevsw = @@ -260,6 +276,7 @@ int vboxNetAdpOsCreate(PVBOXNETADP pThis { struct ifnet *ifp; + VBOXCURVNET_SET_FROM_UCRED(); ifp = if_alloc(IFT_ETHER); if (ifp == NULL) return VERR_NO_MEMORY; @@ -279,6 +296,7 @@ int vboxNetAdpOsCreate(PVBOXNETADP pThis strncpy(pThis->szName, ifp->if_xname, VBOXNETADP_MAX_NAME_LEN); pThis->u.s.ifp = ifp; + VBOXCURVNET_RESTORE(); return 0; } @@ -286,7 +304,9 @@ void vboxNetAdpOsDestroy(PVBOXNETADP pTh { struct ifnet *ifp; + VBOXCURVNET_SET(ifp->if_vnet); ifp = pThis->u.s.ifp; ether_ifdetach(ifp); if_free(ifp); + VBOXCURVNET_RESTORE(); } --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86iphjiqqo.fsf>