VirtualBox

Ignore:
Timestamp:
Sep 1, 2009 3:13:42 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51780
Message:

memobj-r0drv-linux.c: polish.

File:
1 edited

Legend:

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

    r22617 r22679  
    11541154#ifdef VBOX_USE_PAE_HACK
    11551155/**
    1156  * Replace the PFN of a PTE entry of a reserved page. This hack is required for older Linux
    1157  * kernels which don't provide remap_pfn_range().
     1156 * Replace the PFN of a PTE with the address of the actual page.
     1157 *
     1158 * The caller maps a reserved dummy page at the address with the desired access
     1159 * and flags.
     1160 *
     1161 * This hack is required for older Linux kernels which don't provide
     1162 * remap_pfn_range().
     1163 *
     1164 * @returns 0 on success, -ENOMEM on failure.
     1165 * @param   mm          The memory context.
     1166 * @param   ulAddr      The mapping address.
     1167 * @param   Phys        The physical address of the page to map.
    11581168 */
    1159 static int fixPte(struct mm_struct *mm, unsigned long ulAddr, unsigned long long u64Phys)
     1169static int rtR0MemObjLinuxFixPte(struct mm_struct *mm, unsigned long ulAddr, RTHCPHYS Phys)
    11601170{
    11611171    int rc = -ENOMEM;
     
    11751185                pte_t pte = *ptep;
    11761186                pte.pte_high &= 0xfff00000;
    1177                 pte.pte_high |= ((u64Phys >> 32) & 0x000fffff);
     1187                pte.pte_high |= ((Phys >> 32) & 0x000fffff);
    11781188                pte.pte_low  &= 0x00000fff;
    1179                 pte.pte_low  |= (u64Phys & 0xfffff000);
     1189                pte.pte_low  |= (Phys & 0xfffff000);
    11801190                set_pte(ptep, pte);
    11811191                pte_unmap(ptep);
     
    12291239            size_t          iPage;
    12301240#ifdef VBOX_USE_PAE_HACK
    1231             struct page     *pDummyPage = alloc_page(GFP_USER);
     1241            struct page    *pDummyPage = alloc_page(GFP_USER);
    12321242            RTHCPHYS        DummyPhys;
    12331243
    12341244            if (!pDummyPage)
    1235                 goto error;
    1236 
     1245                goto l_error;
    12371246            SetPageReserved(pDummyPage);
    12381247            DummyPhys = page_to_phys(pDummyPage);
    12391248#endif
     1249
    12401250            rc = 0;
    12411251            if (pMemLnxToMap->cPages)
     
    12621272#elif defined(VBOX_USE_PAE_HACK)
    12631273                    rc = remap_page_range(vma, ulAddrCur, DummyPhys, PAGE_SIZE, fPg);
    1264                     if (rc)
    1265                     {
    1266                         rc = VERR_NO_MEMORY;
    1267                         break;
    1268                     }
    1269                     rc = fixPte(pTask->mm, ulAddrCur, Phys);
     1274                    if (!rc)
     1275                        rc = rtR0MemObjLinuxFixPte(pTask->mm, ulAddrCur, Phys);
    12701276#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    12711277                    rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
     
    13091315#elif defined(VBOX_USE_PAE_HACK)
    13101316                        rc = remap_page_range(vma, ulAddrCur, DummyPhys, PAGE_SIZE, fPg);
    1311                         if (rc)
    1312                         {
    1313                             rc = VERR_NO_MEMORY;
    1314                             break;
    1315                         }
    1316                         rc = fixPte(pTask->mm, ulAddrCur, Phys);
     1317                        if (!rc)
     1318                            rc = rtR0MemObjLinuxFixPte(pTask->mm, ulAddrCur, Phys);
    13171319#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    13181320                        rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
     
    13281330                }
    13291331            }
    1330 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11) && defined(CONFIG_X86_PAE)
     1332#ifdef VBOX_USE_PAE_HACK
    13311333            __free_page(pDummyPage);
    13321334#endif
     
    13451347             */
    13461348            MY_DO_MUNMAP(pTask->mm, (unsigned long)pv, pMemLnxToMap->Core.cb);
    1347             if (rc != VERR_INTERNAL_ERROR)
    1348                 rc = VERR_NO_MEMORY;
    13491349        }
    13501350
    13511351#ifdef VBOX_USE_PAE_HACK
    1352 error:
     1352l_error:
    13531353#endif
    13541354        up_write(&pTask->mm->mmap_sem);
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