VirtualBox

Changeset 22508 in vbox


Ignore:
Timestamp:
Aug 27, 2009 11:38:33 AM (15 years ago)
Author:
vboxsync
Message:

use GFP_DMA32 first on 32-bit PAE systems (like on 64-bit hosts) when allocating memory below 4GB

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

Legend:

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

    r22355 r22508  
    239239    cPages = cb >> PAGE_SHIFT;
    240240    cOrder = CalcPowerOf2Order(cPages);
     241#if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
     242    paPages = alloc_pages(GFP_DMA32, cOrder);
     243    if (!paPages)
     244#endif
    241245#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 */
    244     paPages = alloc_pages(GFP_DMA, cOrder);
     246        paPages = alloc_pages(GFP_DMA, cOrder);
    245247#else
    246     /** XXX Wrong: GFP_USER can return page frames above 4GB! */
    247     paPages = alloc_pages(GFP_USER, cOrder);
     248# if defined(CONFIG_X86_PAE)
     249    /** GFP_USER can return page frames above 4GB on PAE systems => GFP_DMA? */
     250# endif
     251        paPages = alloc_pages(GFP_USER, cOrder);
    248252#endif
    249253    if (paPages)
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r22355 r22508  
    524524    int rc;
    525525
    526 #ifdef RT_ARCH_AMD64
    527 # ifdef GFP_DMA32
     526    /* Try to avoid GFP_DMA. GFM_DMA32 was introduced with Linux 2.6.15. */
     527#if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
    528528    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_DMA32, false /* non-contiguous */);
    529529    if (RT_FAILURE(rc))
    530 # endif
     530#endif
     531#ifdef RT_ARCH_AMD64
    531532        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_DMA, false /* non-contiguous */);
    532533#else
    533     /** XXX Wrong: GFP_USER can return page frames above 4GB! */
    534     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_USER, false /* non-contiguous */);
     534# ifdef CONFIG_X86_PAE
     535        /** XXX GFP_USER can return page frames above 4GB on PAE systems => GFP_DMA? */
     536# endif
     537        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, GFP_USER, false /* non-contiguous */);
    535538#endif
    536539    if (RT_SUCCESS(rc))
     
    556559    int rc;
    557560
    558 #ifdef RT_ARCH_AMD64
    559 # ifdef GFP_DMA32
     561#if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
    560562    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_DMA32, true /* contiguous */);
    561563    if (RT_FAILURE(rc))
    562 # endif
     564#endif
     565#ifdef RT_ARCH_AMD64
    563566        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_DMA, true /* contiguous */);
    564567#else
    565     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_USER, true /* contiguous */);
     568# if defined(CONFIG_X86_PAE)
     569        /** XXX GFP_USER can return page frames above 4GB on PAE systems => GFP_DMA? */
     570# endif
     571        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, GFP_USER, true /* contiguous */);
    566572#endif
    567573    if (RT_SUCCESS(rc))
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