Bug 187580 - emulators/virtualbox-ose panic when starting virtual machine on 9.2-STABLE
Summary: emulators/virtualbox-ose panic when starting virtual machine on 9.2-STABLE
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Virtualbox Team (Nobody)
URL:
Keywords:
: 190184 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-14 16:10 UTC by Arrigo Marchiori
Modified: 2014-12-18 16:42 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arrigo Marchiori 2014-03-14 16:10:00 UTC
Panic when trying to start a virtual machine under the latest VirtualBox, on up-to-date world and up-to-date ports.

kgdb session follows.


# kgdb kernel.debug /var/crash/vmcore.1

GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...

Unread portion of the kernel message buffer:
panic: vm_page_insert: page already inserted
cpuid = 3
KDB: stack backtrace:
#0 0xc0adbaaf at kdb_backtrace+0x4f
#1 0xc0aa1e9f at panic+0x16f
#2 0xc0d38cca at vm_page_insert+0x2a
#3 0xc1668bf8 at rtR0MemObjFreeBSDContigPhysAllocHelper+0xe8
#4 0xc1668d5d at rtR0MemObjFreeBSDPhysAllocHelper+0x10d
#5 0xc166904a at rtR0MemObjFreeBSDAllocHelper+0xca
#6 0xc1669131 at rtR0MemObjNativeAllocCont+0x61
#7 0xc91d2e5b at _end+0xc98a43
#8 0xc91c26bb at _end+0xc882a3
#9 0xc91d84fc at _end+0xc9e0e4
#10 0xc165157d at supdrvIOCtl+0x29ad
#11 0xc16565fe at VBoxDrvFreeBSDIOCtl+0x1fe
#12 0xc0978eea at devfs_ioctl_f+0x10a
#13 0xc0aee6a0 at kern_ioctl+0x2a0
#14 0xc0aee7ff at sys_ioctl+0x12f
#15 0xc0f66ce3 at syscall+0x443
#16 0xc0f50771 at Xint0x80_syscall+0x21
Uptime: 4m11s
Physical memory: 3051 MB
Dumping 189 MB: (CTRL-C to abort)  174 158 142 126 110 94 78 62 46 30 14

Reading symbols from /boot/modules/vboxdrv.ko...done.
Loaded symbols for /boot/modules/vboxdrv.ko
Reading symbols from /boot/kernel/fdescfs.ko...Reading symbols from /boot/kernel/fdescfs.ko.symbols...done.
done.
Loaded symbols for /boot/kernel/fdescfs.ko
Reading symbols from /boot/modules/vboxnetflt.ko...done.
Loaded symbols for /boot/modules/vboxnetflt.ko
Reading symbols from /boot/kernel/netgraph.ko...Reading symbols from /boot/kernel/netgraph.ko.symbols...done.
done.
Loaded symbols for /boot/kernel/netgraph.ko
Reading symbols from /boot/kernel/ng_ether.ko...Reading symbols from /boot/kernel/ng_ether.ko.symbols...done.
done.
Loaded symbols for /boot/kernel/ng_ether.ko
Reading symbols from /boot/modules/vboxnetadp.ko...done.
Loaded symbols for /boot/modules/vboxnetadp.ko
Reading symbols from /boot/kernel/linux.ko...Reading symbols from /boot/kernel/linux.ko.symbols...done.
done.
Loaded symbols for /boot/kernel/linux.ko
Reading symbols from /usr/local/modules/fuse.ko...done.
Loaded symbols for /usr/local/modules/fuse.ko
Reading symbols from /boot/kernel/radeon.ko...Reading symbols from /boot/kernel/radeon.ko.symbols...done.
done.
Loaded symbols for /boot/kernel/radeon.ko
Reading symbols from /boot/kernel/drm.ko...Reading symbols from /boot/kernel/drm.ko.symbols...done.
done.
Loaded symbols for /boot/kernel/drm.ko
#0  doadump (textdump=1) at pcpu.h:249
249		__asm("movl %%fs:%1,%0" : "=r" (td)
(kgdb) bt
#0  doadump (textdump=1) at pcpu.h:249
#1  0xc0aa1bee in kern_reboot (howto=260)
    at /usr/src/sys/kern/kern_shutdown.c:454
#2  0xc0aa1ee5 in panic (fmt=<value optimized out>)
    at /usr/src/sys/kern/kern_shutdown.c:642
#3  0xc0d38cca in vm_page_insert (m=0xc435b598, object=0xc91b1818, pindex=Unhandled dwarf expression opcode 0x93
)
    at /usr/src/sys/vm/vm_page.c:915
#4  0xc1668bf8 in rtR0MemObjFreeBSDContigPhysAllocHelper ()
   from /boot/modules/vboxdrv.ko
#5  0xc1668d5d in rtR0MemObjFreeBSDPhysAllocHelper ()
   from /boot/modules/vboxdrv.ko
#6  0xc166904a in rtR0MemObjFreeBSDAllocHelper () from /boot/modules/vboxdrv.ko
#7  0xc1669131 in rtR0MemObjNativeAllocCont () from /boot/modules/vboxdrv.ko
#8  0xc91d2e5b in ?? ()
#9  0xc92a5ae0 in ?? ()
#10 0x00003000 in ?? ()
#11 0x00000000 in ?? ()

How-To-Repeat: Launch VirtualBox and try to start a virtual machine. System hangs immediately.

The above panic was caused outside of X, by trying to start a headless VM using VBoxManage.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2014-03-14 16:10:12 UTC
Responsible Changed
From-To: freebsd-ports-bugs->vbox

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Jung-uk Kim freebsd_committer freebsd_triage 2014-03-14 19:17:32 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Please download the following file:

https://svn.redports.org/virtualbox/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c

Then, replace the existing file in emulators/virtualbox-ose/files
directory with it, rebuild emulators/virtualbox-ose-kmod, and try
again.  Please note the patch directory is NOT
emulators/virtualbox-ose-kmod/files.

BTW, you must update your kernel first to test this patch, i.e.,
r263171 or later because __FreeBSD_version was bumped little late.

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQEcBAEBAgAGBQJTI1XMAAoJEHyflib82/FGU9AH/Rir0KvxP5iG8POoE/lNGVrA
EIjblk4PBRFIAozmeJbjuNlLDfwv1bgGZ5D6ZBkcrPd4fbaLKEtlG9KT1QzFdMk7
W1vYbQ8k9t3prXHc2YDXyy8STXRaH/fyFnrCvxxbdR8AVO4cOi6WnQBxpVAuv3xo
ZGyom00Rq9Ymcxo3oA1agoNAiyrPNGCP2Uz1tWWAAYsa09G2MbpT+QP+ADc8zZxj
ZB3gOw3FVCUcNeYfofxdd+6ofG3Jp/H7iomueyPsS5c88WG/YZRop+lXIX7fhKOX
JY0l2AdCBV6a31mKDlRWRO2wfwN4RyV/kj7RPh5DzEyfnaTtO0QAy5MBAlgS5xU=
=bccj
-----END PGP SIGNATURE-----
Comment 3 Leon Kos 2014-03-15 17:36:59 UTC
Same problem here. When trying with replaced patch as suggested I am getting

Mar 15 17:02:47 cad kernel: FreeBSD 9.2-STABLE #33 r263203: Sat Mar 15 11:56:03 CET 2014
Mar 15 17:02:47 cad kernel: root@cad.lecad.fs.uni-lj.si:/usr/obj/usr/src/sys/CAD amd64
Mar 15 17:02:47 cad kernel: gcc version 4.2.1 20070831 patched [FreeBSD]
Mar 15 17:02:47 cad kernel: link_elf_obj: symbol vm_pageout_grow_cache undefined
Mar 15 17:02:47 cad kernel: KLD file vboxdrv.ko - could not finalize loading
...

Best regards,
Leon Kos
Comment 4 olgeni 2014-03-15 19:47:37 UTC
Hi,

On Fri, 14 Mar 2014, Jung-uk Kim wrote:

> Then, replace the existing file in emulators/virtualbox-ose/files
> directory with it, rebuild emulators/virtualbox-ose-kmod, and try
> again.  Please note the patch directory is NOT
> emulators/virtualbox-ose-kmod/files.

I tried on r263205 and I have been able to start an i386 FreeBSD VM only
once; I usually get this:

Tracing pid 2489 tid 101003 td 0xfffffe01eb862920
kdb_enter() at kdb_enter+0x3b/frame 0xffffff8495797630
panic() at panic+0x1c7/frame 0xffffff8495797730
vm_page_insert() at vm_page_insert+0x177/frame 0xffffff8495797760
rtR0MemObjFreeBSDContigPhysAllocHelper() at rtR0MemObjFreeBSDContigPhysAllocHelper+0xc1/frame 0xffffff84957977b0
rtR0MemObjFreeBSDPhysAllocHelper() at rtR0MemObjFreeBSDPhysAllocHelper+0x67/frame 0xffffff8495797800
rtR0MemObjFreeBSDAllocPhysPages() at rtR0MemObjFreeBSDAllocPhysPages+0x81/frame 0xffffff8495797850
rtR0MemObjNativeAllocPhysNC() at rtR0MemObjNativeAllocPhysNC+0x28/frame 0xffffff8495797870
SUPR0PageAllocEx() at SUPR0PageAllocEx+0x253/frame 0xffffff84957978f0
supdrvIOCtl() at supdrvIOCtl+0x1bd7/frame 0xffffff8495797980
VBoxDrvFreeBSDIOCtl() at VBoxDrvFreeBSDIOCtl+0x1e3/frame 0xffffff84957979f0
devfs_ioctl_f() at devfs_ioctl_f+0x7b/frame 0xffffff8495797a60
kern_ioctl() at kern_ioctl+0x106/frame 0xffffff8495797ab0
sys_ioctl() at sys_ioctl+0xfd/frame 0xffffff8495797b10
amd64_syscall() at amd64_syscall+0x5ea/frame 0xffffff8495797c30
Xfast_syscall() at Xfast_syscall+0xf7/frame 0xffffff8495797c30
--- syscall (54, FreeBSD ELF64, sys_ioctl), rip = 0x801282d9c, rsp = 0x7fffff9a5868, rbp = 0x7fffff9a5870 ---

I¢m not sure if the one time success is related to the patch or to
mere luck. If you need any test just drop me a line.

--
jimmy
Comment 5 Arrigo Marchiori 2014-03-17 09:02:51 UTC
Hello Jung-uk,

On Fri, Mar 14, 2014 at 03:17:32PM -0400, Jung-uk Kim wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Please download the following file:
> 
> https://svn.redports.org/virtualbox/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c
> 
> Then, replace the existing file in emulators/virtualbox-ose/files
> directory with it, rebuild emulators/virtualbox-ose-kmod, and try
> again.  Please note the patch directory is NOT
> emulators/virtualbox-ose-kmod/files.
> 
> BTW, you must update your kernel first to test this patch, i.e.,
> r263171 or later because __FreeBSD_version was bumped little late.

I updated this morning and rebuilt world.

# uname -a
FreeBSD myhost 9.2-STABLE FreeBSD 9.2-STABLE #66 r263261: Mon Mar
17 08:50:31 CET 2014     root@myhost:/usr/obj/usr/src/sys/GENERIC
i386

I have now the same problem as Leon Kos: 

# dmesg
Copyright (c) 1992-2014 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993,
1994
        The Regents of the University of California. All rights
	reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.2-STABLE #66 r263261: Mon Mar 17 08:50:31 CET 2014
    root@myhost:/usr/obj/usr/src/sys/GENERIC i386
gcc version 4.2.1 20070831 patched [FreeBSD]
link_elf: symbol vm_pageout_grow_cache undefined
KLD file vboxdrv.ko - could not finalize loading
[...]

Thank you for your support!

Best regards,
-- 
rigo

http://rigo.altervista.org
Comment 6 Jung-uk Kim freebsd_committer freebsd_triage 2014-03-17 18:33:59 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I just updated the patch.  Please re-download the patch and try again.

https://svn.redports.org/virtualbox/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c

The prerequisite is still the same, i. e., your kernel and kernel
source must be up-to-date, at least r263171.

Sorry about the mess.

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQEcBAEBAgAGBQJTJ0AXAAoJEHyflib82/FGDZEH/RGbpQt00VopcueJfYJNDZJI
SqZppTsFEdChP7zA97k1Ksay3kl1CMU1d37A7lLtygoRLhlnlACiX0a2L0bFNuZj
MDYYCRvlTzkGqUzoGopiNLphT29U2hFo1TGsISjaNd/AT5MyIClMAy9A+Q062kSd
LVrnpGlN4j3QIBwVwCDyCCER6EXJSJuuUmz7zOlbg67W/1wZdH0zetW9XvFEtCDP
3gttRuPR03N61ySh8xJfYr3ePj4Yvpgx/CG+xufhPv9oA8bBRS5MIqhL2UJBMd/W
wWeMuEbqfJ5+/GufOs9SR164QE6bTNcaYkmDtdLxe/17MdMo6kU748LRajKSdMk=
=UP+M
-----END PGP SIGNATURE-----
Comment 7 Arrigo Marchiori 2014-03-18 12:23:39 UTC
Hello Jung-uk,

On Mon, Mar 17, 2014 at 02:33:59PM -0400, Jung-uk Kim wrote:

[...]
> I just updated the patch.  Please re-download the patch and try again.
> 
> https://svn.redports.org/virtualbox/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c
> 
> The prerequisite is still the same, i. e., your kernel and kernel
> source must be up-to-date, at least r263171.

This time, it seems to work fine! I have been running a Linux VM for
some time with no problems. Can you think of any tests I can do to
make sure that the problem is solved? (I only have Linux VM's)

> Sorry about the mess.

Thank you for your support!

Best regards,
-- 
rigo

http://rigo.altervista.org
Comment 8 dfilter service freebsd_committer freebsd_triage 2014-03-20 18:11:16 UTC
Author: jkim
Date: Thu Mar 20 18:11:11 2014
New Revision: 348711
URL: http://svnweb.freebsd.org/changeset/ports/348711
QAT: https://qat.redports.org/buildarchive/r348711/

Log:
  Fix panic for stable/9.  Use vm_page_alloc_contig() as it is now available.
  
  Tested by:	Douglas Berry (doug at bitnix dot ca)
  PR:		ports/187580

Added:
  head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_PAGEOUT_GROW_CACHE.c   (contents, props changed)
Modified:
  head/emulators/virtualbox-ose-additions/Makefile
  head/emulators/virtualbox-ose-kmod-legacy/Makefile
  head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c
  head/emulators/virtualbox-ose-kmod/Makefile
  head/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c

Modified: head/emulators/virtualbox-ose-additions/Makefile
==============================================================================
--- head/emulators/virtualbox-ose-additions/Makefile	Thu Mar 20 18:01:39 2014	(r348710)
+++ head/emulators/virtualbox-ose-additions/Makefile	Thu Mar 20 18:11:11 2014	(r348711)
@@ -3,6 +3,7 @@
 
 PORTNAME=	virtualbox-ose
 DISTVERSION=	4.3.8
+PORTREVISION=	1
 CATEGORIES=	emulators
 MASTER_SITES=	http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \
 		http://tmp.chruetertee.ch/ \

Modified: head/emulators/virtualbox-ose-kmod-legacy/Makefile
==============================================================================
--- head/emulators/virtualbox-ose-kmod-legacy/Makefile	Thu Mar 20 18:01:39 2014	(r348710)
+++ head/emulators/virtualbox-ose-kmod-legacy/Makefile	Thu Mar 20 18:11:11 2014	(r348711)
@@ -3,6 +3,7 @@
 
 PORTNAME=	virtualbox-ose
 DISTVERSION=	4.2.22
+PORTREVISION=	1
 CATEGORIES=	emulators
 MASTER_SITES=	http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \
 		http://tmp.chruetertee.ch/ \

Modified: head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c
==============================================================================
--- head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c	Thu Mar 20 18:01:39 2014	(r348710)
+++ head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_OBJECT_RENAME.c	Thu Mar 20 18:11:11 2014	(r348711)
@@ -1,7 +1,7 @@
 $FreeBSD$
 
---- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2013-03-20 19:19:36.795745576 -0700
-+++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2013-03-20 19:15:35.164791970 -0700
+--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig	2014-03-14 17:25:46.000000000 -0400
++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2014-03-14 17:34:35.000000000 -0400
 @@ -162,7 +162,11 @@
          case RTR0MEMOBJTYPE_PHYS:
          case RTR0MEMOBJTYPE_PHYS_NC:
@@ -14,7 +14,7 @@ $FreeBSD$
              vm_page_t pPage = vm_page_find_least(pMemFreeBSD->pObject, 0);
  #if __FreeBSD_version < 900000
              /* See http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html */
-@@ -177,7 +181,12 @@
+@@ -177,7 +181,11 @@
  #if __FreeBSD_version < 900000
              vm_page_unlock_queues();
  #endif
@@ -23,11 +23,18 @@ $FreeBSD$
 +#else
              VM_OBJECT_UNLOCK(pMemFreeBSD->pObject);
 +#endif
-+
              vm_object_deallocate(pMemFreeBSD->pObject);
              break;
          }
-@@ -205,10 +214,18 @@
+@@ -198,17 +206,25 @@
+     vm_page_t pPages;
+     int cTries = 0;
+ 
+-#if __FreeBSD_version > 1000000
++#if __FreeBSD_version >= 902508
+     int fFlags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY;
+     if (fWire)
+         fFlags |= VM_ALLOC_WIRED;
  
      while (cTries <= 1)
      {
@@ -46,31 +53,7 @@ $FreeBSD$
          if (pPages)
              break;
          vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
-@@ -228,7 +245,11 @@
- 
-     if (!pPages)
-         return pPages;
-+#if __FreeBSD_version >= 1000030
-+    VM_OBJECT_WLOCK(pObject);
-+#else
-     VM_OBJECT_LOCK(pObject);
-+#endif
-     for (vm_pindex_t iPage = 0; iPage < cPages; iPage++)
-     {
-         vm_page_t pPage = pPages + iPage;
-@@ -240,7 +261,11 @@
-             atomic_add_int(&cnt.v_wire_count, 1);
-         }
-     }
-+#if __FreeBSD_version >= 1000030
-+    VM_OBJECT_WUNLOCK(pObject);
-+#else
-     VM_OBJECT_UNLOCK(pObject);
-+#endif
-     return pPages;
- #endif
- }
-@@ -264,7 +289,11 @@
+@@ -264,7 +280,11 @@
          if (!pPage)
          {
              /* Free all allocated pages */
@@ -82,7 +65,7 @@ $FreeBSD$
              while (iPage-- > 0)
              {
                  pPage = vm_page_lookup(pObject, iPage);
-@@ -278,7 +307,11 @@
+@@ -278,7 +298,11 @@
                  vm_page_unlock_queues();
  #endif
              }
@@ -94,7 +77,7 @@ $FreeBSD$
              return rcNoMem;
          }
      }
-@@ -411,9 +444,17 @@
+@@ -417,9 +441,17 @@
          if (fContiguous)
          {
              Assert(enmType == RTR0MEMOBJTYPE_PHYS);
@@ -112,7 +95,7 @@ $FreeBSD$
              pMemFreeBSD->Core.u.Phys.fAllocated = true;
          }
  
-@@ -823,9 +864,17 @@
+@@ -838,9 +870,17 @@
          case RTR0MEMOBJTYPE_PHYS_NC:
          {
              RTHCPHYS addr;

Added: head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_PAGEOUT_GROW_CACHE.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd_VM_PAGEOUT_GROW_CACHE.c	Thu Mar 20 18:11:11 2014	(r348711)
@@ -0,0 +1,37 @@
+--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig	2014-03-17 14:08:04.000000000 -0400
++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2014-03-17 14:09:34.000000000 -0400
+@@ -211,7 +211,7 @@
+     if (fWire)
+         fFlags |= VM_ALLOC_WIRED;
+ 
+-    while (cTries <= 1)
++    while (1)
+     {
+ #if __FreeBSD_version >= 1000030
+         VM_OBJECT_WLOCK(pObject);
+@@ -225,18 +225,22 @@
+ #else
+         VM_OBJECT_UNLOCK(pObject);
+ #endif
+-        if (pPages)
++        if (pPages || cTries >= 1)
+             break;
++#if __FreeBSD_version >= 1000015
+         vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
++#else
++        vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
++#endif
+         cTries++;
+     }
+ 
+     return pPages;
+ #else
+-    while (cTries <= 1)
++    while (1)
+     {
+         pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
+-        if (pPages)
++        if (pPages || cTries >= 1)
+             break;
+         vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
+         cTries++;

Modified: head/emulators/virtualbox-ose-kmod/Makefile
==============================================================================
--- head/emulators/virtualbox-ose-kmod/Makefile	Thu Mar 20 18:01:39 2014	(r348710)
+++ head/emulators/virtualbox-ose-kmod/Makefile	Thu Mar 20 18:11:11 2014	(r348711)
@@ -3,6 +3,7 @@
 
 PORTNAME=	virtualbox-ose
 DISTVERSION=	4.3.8
+PORTREVISION=	1
 CATEGORIES=	emulators
 MASTER_SITES=	http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \
 		http://tmp.chruetertee.ch/ \

Modified: head/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c
==============================================================================
--- head/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c	Thu Mar 20 18:01:39 2014	(r348710)
+++ head/emulators/virtualbox-ose/files/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c	Thu Mar 20 18:11:11 2014	(r348711)
@@ -7,8 +7,8 @@ From Alan L. Cox on FreeBSD-current:
     answer that question.
 
 [1] http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html
---- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig	2013-11-29 12:04:53.000000000 +0100
-+++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2013-11-29 12:37:29.000000000 +0100
+--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig	2014-02-25 12:09:32.000000000 -0500
++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2014-03-17 13:57:00.000000000 -0400
 @@ -168,14 +168,19 @@
              VM_OBJECT_LOCK(pMemFreeBSD->pObject);
  #endif
@@ -29,7 +29,75 @@ From Alan L. Cox on FreeBSD-current:
  #if __FreeBSD_version >= 1000030
              VM_OBJECT_WUNLOCK(pMemFreeBSD->pObject);
  #else
-@@ -291,11 +296,15 @@
+@@ -201,12 +206,12 @@
+     vm_page_t pPages;
+     int cTries = 0;
+ 
+-#if __FreeBSD_version > 1000000
++#if __FreeBSD_version >= 902508
+     int fFlags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY;
+     if (fWire)
+         fFlags |= VM_ALLOC_WIRED;
+ 
+-    while (cTries <= 1)
++    while (1)
+     {
+ #if __FreeBSD_version >= 1000030
+         VM_OBJECT_WLOCK(pObject);
+@@ -220,18 +225,20 @@
+ #else
+         VM_OBJECT_UNLOCK(pObject);
+ #endif
+-        if (pPages)
++        if (pPages || cTries >= 1)
+             break;
++#if __FreeBSD_version >= 1000015
+         vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
++#else
++        vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
++#endif
+         cTries++;
+     }
+-
+-    return pPages;
+ #else
+-    while (cTries <= 1)
++    while (1)
+     {
+         pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
+-        if (pPages)
++        if (pPages || cTries >= 1)
+             break;
+         vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
+         cTries++;
+@@ -239,11 +246,8 @@
+ 
+     if (!pPages)
+         return pPages;
+-#if __FreeBSD_version >= 1000030
+-    VM_OBJECT_WLOCK(pObject);
+-#else
++
+     VM_OBJECT_LOCK(pObject);
+-#endif
+     for (vm_pindex_t iPage = 0; iPage < cPages; iPage++)
+     {
+         vm_page_t pPage = pPages + iPage;
+@@ -255,13 +259,9 @@
+             atomic_add_int(&cnt.v_wire_count, 1);
+         }
+     }
+-#if __FreeBSD_version >= 1000030
+-    VM_OBJECT_WUNLOCK(pObject);
+-#else
+     VM_OBJECT_UNLOCK(pObject);
+ #endif
+     return pPages;
+-#endif
+ }
+ 
+ static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
+@@ -291,11 +291,15 @@
              while (iPage-- > 0)
              {
                  pPage = vm_page_lookup(pObject, iPage);
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 9 Jung-uk Kim freebsd_committer freebsd_triage 2014-03-20 18:20:15 UTC
State Changed
From-To: open->closed

It should be fixed with r348711.  Thanks!
Comment 10 Bryan Drewery freebsd_committer freebsd_triage 2014-12-18 16:08:19 UTC
*** Bug 190184 has been marked as a duplicate of this bug. ***
Comment 11 Bryan Drewery freebsd_committer freebsd_triage 2014-12-18 16:42:14 UTC
Note that while this fixes the panic when you build virtualbox-ose on the target system, the fix is not ABI compatible and still panics on 9.3.

Packages are built on the cluster for the oldest supported release on a branch. So currently they are built for 9.1. The package does not use the new vm_page_alloc_contig(). So when using the official package on 9.3 you will still run into the panic.

This is not a big issue at this point as 9.1 and 9.2 both are EOL in 2 weeks. At that time package building will be switched to 9.3 and a proper package will be created.