Index: trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c
===================================================================
--- trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c	(revision 26847)
+++ trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/os/vbi.c	(revision 27003)
@@ -314,5 +314,5 @@
 
 static void *
-vbi_internal_alloc(uint64_t *phys, size_t size, int contig)
+vbi_internal_alloc(uint64_t *phys, size_t size, uint64_t alignment, int contig)
 {
 	ddi_dma_attr_t attr;
@@ -323,5 +323,5 @@
 	if ((size & PAGEOFFSET) != 0)
 		return (NULL);
-	npages = size >> PAGESHIFT;
+	npages = (size + PAGESIZE - 1) >> PAGESHIFT;
 	if (npages == 0)
 		return (NULL);
@@ -329,4 +329,5 @@
 	attr = base_attr;
 	attr.dma_attr_addr_hi = *phys;
+    attr.dma_attr_align   = alignment;
 	if (!contig)
 		attr.dma_attr_sgllen = npages;
@@ -348,5 +349,6 @@
 vbi_contig_alloc(uint64_t *phys, size_t size)
 {
-	return (vbi_internal_alloc(phys, size, 1));
+    /* Obsolete */
+	return (vbi_internal_alloc(phys, size, PAGESIZE /* alignment */, 1 /* contiguous */));
 }
 
@@ -354,4 +356,5 @@
 vbi_contig_free(void *va, size_t size)
 {
+    /* Obsolete */
 	p_contig_free(va, size);
 }
@@ -746,5 +749,5 @@
 	 */
 	va = seg->s_base;
-	pgcnt = seg->s_size >> PAGESHIFT;
+	pgcnt = (seg->s_size + PAGESIZE - 1) >> PAGESHIFT;
 	for (p = 0; p < pgcnt; ++p, va += PAGESIZE) {
 		hat_devload(as->a_hat, va,
@@ -865,4 +868,5 @@
 segvbi_getoffset(struct seg *seg, caddr_t addr)
 {
+    cmn_err(CE_NOTE, "segvbi_getoffset\n");
 	return ((uintptr_t)addr - (uintptr_t)seg->s_base);
 }
@@ -968,5 +972,7 @@
 	map_addr(va, len, 0, 0, MAP_SHARED);
 	if (*va != NULL)
+	{
 		error = as_map(as, *va, len, segvbi_create, &args);
+	}
 	else
 		error = ENOMEM;
@@ -1203,10 +1209,10 @@
  * increased. Also change vbi_modlmisc at the top of the file.
  */
-uint_t vbi_revision_level = 6;
+uint_t vbi_revision_level = 7;
 
 void *
 vbi_lowmem_alloc(uint64_t phys, size_t size)
 {
-	return (vbi_internal_alloc(&phys, size, 0));
+	return (vbi_internal_alloc(&phys, size, PAGESIZE /* alignment */, 0 /* non-contiguous */));
 }
 
@@ -1229,2 +1235,17 @@
 }
 
+/*
+ * This is revision 7 of the interface.
+ */
+
+void *
+vbi_phys_alloc(uint64_t *phys, size_t size, uint64_t alignment, int contig)
+{
+	return (vbi_internal_alloc(phys, size, alignment, contig));
+}
+
+void
+vbi_phys_free(void *va, size_t size)
+{
+	p_contig_free(va, size);
+}
Index: trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h
===================================================================
--- trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h	(revision 26847)
+++ trunk/src/VBox/Runtime/r0drv/solaris/vbi/i86pc/sys/vbi.h	(revision 27003)
@@ -336,4 +336,19 @@
 /* end of interfaces defined for version 6 */
 
+/* begin interfaces defined for version 7 */
+/*
+ * Allocate and free physically limited, aligned as specified continuous or non-continuous memory. 
+ *
+ * return value is a) NULL if memory below "phys" not available or
+ * b) virtual address of memory in kernel heap
+ *
+ * phys on input is set to the upper boundary of acceptable memory
+ *
+ * size is the amount to allocate and must be a multiple of PAGESIZE
+ */
+extern void *vbi_phys_alloc(uint64_t *phys, size_t size, uint64_t alignment, int contig);
+extern void vbi_phys_free(void *va, size_t size);
+/* end of interfaces defined for version 7 */
+
 #ifdef	__cplusplus
 }
Index: trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c
===================================================================
--- trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c	(revision 26847)
+++ trunk/src/VBox/Runtime/r0drv/solaris/vbi/memobj-r0drv-solaris.c	(revision 27003)
@@ -77,5 +77,10 @@
 
         case RTR0MEMOBJTYPE_CONT:
+        case RTR0MEMOBJTYPE_PHYS:
             vbi_contig_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
+            break;
+
+        case RTR0MEMOBJTYPE_PHYS_NC:
+            vbi_phys_free(pMemSolaris->Core.pv, pMemSolaris->Core.cb);
             break;
 
@@ -101,6 +106,4 @@
         }
 
-        /* unused */
-        case RTR0MEMOBJTYPE_PHYS:
         default:
             AssertMsgFailed(("enmType=%d\n", pMemSolaris->Core.enmType));
@@ -161,32 +164,38 @@
 {
     NOREF(fExecutable);
-
-    /* Create the object */
-    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb);
-    if (!pMemSolaris)
-        return VERR_NO_MEMORY;
-
-    /* Allocate physically contiguous page-aligned memory. */
+    return rtR0MemObjNativeAllocPhys(ppMem, cb, (uint64_t)0xffffffff /* highest address */, PAGE_SIZE /* alignment */);
+}
+
+
+int rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
+{
+#if HC_ARCH_BITS == 64
+    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_PHYS_NC, NULL, cb);
+    if (!pMemSolaris)
+        return VERR_NO_MEMORY;
+
+    if (PhysHighest == NIL_RTHCPHYS)
+        PhysHighest = (uint64_t)0xffffffff;
+
+    /* Allocate physically non-contiguous page-aligned memory. */
     caddr_t virtAddr;
-    uint64_t phys = (unsigned)0xffffffff;
-    virtAddr = vbi_contig_alloc(&phys, cb);
+    uint64_t phys = PhysHighest;
+    virtAddr = vbi_phys_alloc(&phys, cb, PAGE_SIZE, 0 /* non-contiguous */);
     if (virtAddr == NULL)
     {
         rtR0MemObjDelete(&pMemSolaris->Core);
-        return VERR_NO_CONT_MEMORY;
+        return VERR_NO_MEMORY;
     }
     Assert(phys < (uint64_t)1 << 32);
     pMemSolaris->Core.pv = virtAddr;
-    pMemSolaris->Core.u.Cont.Phys = phys;
+    pMemSolaris->Core.u.Phys.PhysBase = phys;
+    pMemSolaris->Core.u.Phys.fAllocated = true;
     pMemSolaris->pvHandle = NULL;
     *ppMem = &pMemSolaris->Core;
     return VINF_SUCCESS;
-}
-
-
-int rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
-{
+#else
     /** @todo rtR0MemObjNativeAllocPhysNC / solaris */
     return VERR_NOT_SUPPORTED; /* see the RTR0MemObjAllocPhysNC specs */
+#endif
 }
 
@@ -196,9 +205,30 @@
     AssertMsgReturn(PhysHighest >= 16 *_1M, ("PhysHigest=%RHp\n", PhysHighest), VERR_NOT_IMPLEMENTED);
 
-    /** @todo alignment */
+    /** @todo alignment, vbi currently assumes PAGE_SIZE not even less than PAGE_SIZE */
     if (uAlignment != PAGE_SIZE)
         return VERR_NOT_SUPPORTED;
 
-    return rtR0MemObjNativeAllocCont(ppMem, cb, false);
+    if (PhysHighest == NIL_RTHCPHYS)
+        PhysHighest = (uint64_t)0xffffffff;
+
+     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_CONT, NULL, cb);
+     if (!pMemSolaris)
+         return VERR_NO_MEMORY;
+
+     /* Allocate physically contiguous memory aligned as specified. */
+     caddr_t virtAddr;
+     uint64_t phys = PhysHighest;
+     virtAddr = vbi_phys_alloc(&phys, cb, uAlignment, 1 /* contiguous */);
+     if (virtAddr == NULL)
+     {
+         rtR0MemObjDelete(&pMemSolaris->Core);
+         return VERR_NO_CONT_MEMORY;
+     }
+     Assert(phys < (uint64_t)1 << 32);
+     pMemSolaris->Core.pv = virtAddr;
+     pMemSolaris->Core.u.Cont.Phys = phys;
+     pMemSolaris->pvHandle = NULL;
+     *ppMem = &pMemSolaris->Core;
+     return VINF_SUCCESS;
 }
 
@@ -240,5 +270,5 @@
     if (rc != 0)
     {
-        cmn_err(CE_NOTE,"rtR0MemObjNativeLockUser: vbi_lock_va failed rc=%d\n", rc);
+        LogRel(("rtR0MemObjNativeLockUser: vbi_lock_va failed rc=%d\n", rc));
         rtR0MemObjDelete(&pMemSolaris->Core);
         return VERR_LOCK_FAILED;
@@ -270,5 +300,5 @@
     if (rc != 0)
     {
-        cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: vbi_lock_va failed rc=%d\n", rc);
+        LogRel(("rtR0MemObjNativeLockKernel: vbi_lock_va failed rc=%d\n", rc));
         rtR0MemObjDelete(&pMemSolaris->Core);
         return VERR_LOCK_FAILED;
@@ -325,5 +355,5 @@
     AssertMsgReturn(R3PtrFixed == (RTR3PTR)-1, ("%p\n", R3PtrFixed), VERR_NOT_SUPPORTED);
     AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
-    if (uAlignment > PAGE_SIZE)
+    if (uAlignment != PAGE_SIZE)
         return VERR_NOT_SUPPORTED;
 
@@ -348,7 +378,8 @@
         if (paddrs[iPage] == -(uint64_t)1)
         {
-            cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: no page to map.\n");
-            rc = VERR_MAP_FAILED;
-            goto l_done;
+            LogRel(("rtR0MemObjNativeMapUser: no page to map.\n"));
+            kmem_free(paddrs, sizeof(uint64_t) * cPages);
+            rtR0MemObjDelete(&pMemSolaris->Core);
+            return VERR_MAP_FAILED;
         }
         pv = (void *)((uintptr_t)pv + PAGE_SIZE);
@@ -358,8 +389,8 @@
     if (rc != 0)
     {
-        cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: vbi failure.\n");
-        rc = VERR_MAP_FAILED;
-        rtR0MemObjDelete(&pMemSolaris->Core);
-        goto l_done;
+        LogRel(("rtR0MemObjNativeMapUser: vbi mapping failure.\n"));
+        kmem_free(paddrs, sizeof(uint64_t) * cPages);
+        rtR0MemObjDelete(&pMemSolaris->Core);
+        return VERR_MAP_FAILED;
     }
     else
@@ -369,5 +400,4 @@
     pMemSolaris->Core.pv = addr;
     *ppMem = &pMemSolaris->Core;
-l_done:
     kmem_free(paddrs, sizeof(uint64_t) * cPages);
     return rc;
@@ -393,5 +423,4 @@
         case RTR0MEMOBJTYPE_PAGE:
         case RTR0MEMOBJTYPE_LOW:
-        case RTR0MEMOBJTYPE_MAPPING:
         case RTR0MEMOBJTYPE_LOCK:
         {
@@ -400,12 +429,23 @@
         }
 
+        /*
+         * Although mapping can be handled by vbi_va_to_pa(offset) like the above case,
+         * request it from the parent so that we have a clear distinction between CONT/PHYS_NC.
+         */
+        case RTR0MEMOBJTYPE_MAPPING:
+            return rtR0MemObjNativeGetPagePhysAddr(pMemSolaris->Core.uRel.Child.pParent, iPage);
+
         case RTR0MEMOBJTYPE_CONT:
+        case RTR0MEMOBJTYPE_PHYS:
             return pMemSolaris->Core.u.Cont.Phys + (iPage << PAGE_SHIFT);
 
-        case RTR0MEMOBJTYPE_PHYS:
+        case RTR0MEMOBJTYPE_PHYS_NC:
+            if (pMemSolaris->Core.u.Phys.fAllocated == true)
+            {
+                uint8_t *pb = (uint8_t *)pMemSolaris->Core.pv + ((size_t)iPage << PAGE_SHIFT);
+                return vbi_va_to_pa(pb);
+            }
             return pMemSolaris->Core.u.Phys.PhysBase + (iPage << PAGE_SHIFT);
 
-        case RTR0MEMOBJTYPE_PHYS_NC:
-            AssertFailed(/* not implemented */);
         case RTR0MEMOBJTYPE_RES_VIRT:
         default:
