VirtualBox

Changeset 22355 in vbox for trunk/src


Ignore:
Timestamp:
Aug 19, 2009 8:09:45 PM (15 years ago)
Author:
vboxsync
Message:

Runtime/Linux: don't allow to pass pages above 4GB to remap_page_range(); some remarks about GFP_USER

Location:
trunk/src/VBox/Runtime/r0drv/linux
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c

    r21337 r22355  
    239239    cPages = cb >> PAGE_SHIFT;
    240240    cOrder = CalcPowerOf2Order(cPages);
    241 #ifdef RT_ARCH_AMD64 /** @todo check out if there is a correct way of getting memory below 4GB (physically). */
     241#ifdef RT_ARCH_AMD64
     242    /** @todo check out if there is a correct way of getting memory below 4GB (physically).
     243     * GFP_DMA32 is available since Linux 2.6.15 */
    242244    paPages = alloc_pages(GFP_DMA, cOrder);
    243245#else
     246    /** XXX Wrong: GFP_USER can return page frames above 4GB! */
    244247    paPages = alloc_pages(GFP_USER, cOrder);
    245248#endif
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r21497 r22355  
    531531        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_DMA, false /* non-contiguous */);
    532532#else
     533    /** XXX Wrong: GFP_USER can return page frames above 4GB! */
    533534    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_USER, false /* non-contiguous */);
    534535#endif
     
    11741175                for (iPage = 0; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE)
    11751176                {
     1177#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11)
     1178                    uint64_t u64Phys = page_to_phys(pMemLnxToMap->apPages[iPage]);
     1179#endif
    11761180#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    11771181                    struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */
    11781182                    AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR);
     1183#endif
     1184#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11) && defined(RT_ARCH_X86)
     1185                    /* remap_page_range() limitation on x86 */
     1186                    AssertBreakStmt(u64Phys < _4G, rc = VERR_NO_MEMORY);
    11791187#endif
    11801188
     
    11851193                    rc = remap_pfn_range(vma, ulAddrCur, page_to_pfn(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
    11861194#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    1187                     rc = remap_page_range(vma, ulAddrCur, page_to_phys(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
     1195                    rc = remap_page_range(vma, ulAddrCur, u64Phys, PAGE_SIZE, fPg);
    11881196#else /* 2.4 */
    1189                     rc = remap_page_range(ulAddrCur, page_to_phys(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
     1197                    rc = remap_page_range(ulAddrCur, u64Phys, PAGE_SIZE, fPg);
    11901198#endif
    11911199                    if (rc)
     
    12131221                        AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR);
    12141222#endif
     1223#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11) && defined(RT_ARCH_X86)
     1224                        /* remap_page_range() limitation on x86 */
     1225                        AssertBreakStmt(Phys < _4G, rc = VERR_NO_MEMORY);
     1226#endif
    12151227
    12161228#if   LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette