VirtualBox

Changeset 81621 in vbox for trunk


Ignore:
Timestamp:
Nov 1, 2019 2:39:35 PM (5 years ago)
Author:
vboxsync
Message:

IPRT/memobj-r0drv-linux.cpp: Implemented sub-mappings in kernel space. (untested) bugref:9218

File:
1 edited

Legend:

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

    r81587 r81621  
    14121412     * Create the IPRT memory object.
    14131413     */
    1414     pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_MAPPING, NULL, pMemLnxToMap->Core.cb);
     1414    if (!cbSub)
     1415        cbSub = pMemLnxToMap->Core.cb - offSub;
     1416    pMemLnx = (PRTR0MEMOBJLNX)rtR0MemObjNew(sizeof(*pMemLnx), RTR0MEMOBJTYPE_MAPPING, NULL, cbSub);
    14151417    if (pMemLnx)
    14161418    {
     
    14221424             */
    14231425            pgprot_t fPg = rtR0MemObjLinuxConvertProt(fProt, true /* kernel */);
     1426            Assert(((offSub + cbSub) >> PAGE_SHIFT) <= pMemLnxToMap->cPages);
    14241427# ifdef VM_MAP
    1425             pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[0], pMemLnxToMap->cPages, VM_MAP, fPg);
     1428            pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[offSub >> PAGE_SHIFT], cbSub >> PAGE_SHIFT, VM_MAP, fPg);
    14261429# else
    1427             pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[0], pMemLnxToMap->cPages, VM_ALLOC, fPg);
     1430            pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[offSub >> PAGE_SHIFT], cbSub >> PAGE_SHIFT, VM_ALLOC, fPg);
    14281431# endif
    14291432            if (pMemLnx->Core.pv)
     
    14491452                {
    14501453                    Assert(pMemLnxToMap->Core.pv);
    1451                     pMemLnx->Core.pv = pMemLnxToMap->Core.pv;
     1454                    pMemLnx->Core.pv = (uint8_t *)pMemLnxToMap->Core.pv + offSub;
    14521455                }
    14531456            }
     
    14611464            Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
    14621465            pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
    1463                              ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb)
    1464                              : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase, pMemLnxToMap->Core.cb);
     1466                             ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
     1467                             : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
    14651468            if (pMemLnx->Core.pv)
    14661469            {
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