Author: jkim
Date: Fri Aug  6 15:04:01 2010
New Revision: 210934
URL: http://svn.freebsd.org/changeset/base/210934

Log:
  Fix allocation of multiple pages, which forgot to increase page number.
  Particularly, it caused "vm86_addpage: overlap" panics under VirtualBox.
  Add a safety check before freeing memory while I am here.

Modified:
  head/sys/compat/x86bios/x86bios.c

Modified: head/sys/compat/x86bios/x86bios.c
==============================================================================
--- head/sys/compat/x86bios/x86bios.c   Fri Aug  6 14:33:42 2010        
(r210933)
+++ head/sys/compat/x86bios/x86bios.c   Fri Aug  6 15:04:01 2010        
(r210934)
@@ -121,7 +121,7 @@ x86bios_alloc(uint32_t *offset, size_t s
                *offset = vtophys(addr);
                mtx_lock(&x86bios_lock);
                for (i = 0; i < howmany(size, PAGE_SIZE); i++)
-                       vm86_addpage(&x86bios_vmc, atop(*offset),
+                       vm86_addpage(&x86bios_vmc, atop(*offset) + i,
                            addr + i * PAGE_SIZE);
                mtx_unlock(&x86bios_lock);
        }
@@ -142,6 +142,10 @@ x86bios_free(void *addr, size_t size)
                            sizeof(x86bios_vmc.pmap[i]));
                        last = i;
                }
+       if (last < 0) {
+               mtx_unlock(&x86bios_lock);
+               return;
+       }
        if (last == x86bios_vmc.npages - 1) {
                x86bios_vmc.npages -= howmany(size, PAGE_SIZE);
                for (i = x86bios_vmc.npages - 1;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to