VirtualBox

Ignore:
Timestamp:
Jul 23, 2020 11:57:35 AM (4 years ago)
Author:
vboxsync
Message:

IPRT/memobj-r0drv-linux.c: Wrap mmap_sem operations as it was renamed to mmap_lock in 5.8. bugref:9801

File:
1 edited

Legend:

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

    r83471 r85430  
    7171#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
    7272# define gfp_t  unsigned
     73#endif
     74
     75/*
     76 * Wrappers around mmap_lock/mmap_sem difference.
     77 */
     78#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     79# define LNX_MM_DOWN_READ(a_pMm)    down_read(&(a_pMm)->mmap_lock)
     80# define LNX_MM_UP_READ(a_pMm)        up_read(&(a_pMm)->mmap_lock)
     81# define LNX_MM_DOWN_WRITE(a_pMm)   down_write(&(a_pMm)->mmap_lock)
     82# define LNX_MM_UP_WRITE(a_pMm)       up_write(&(a_pMm)->mmap_lock)
     83#else
     84# define LNX_MM_DOWN_READ(a_pMm)    down_read(&(a_pMm)->mmap_sem)
     85# define LNX_MM_UP_READ(a_pMm)        up_read(&(a_pMm)->mmap_sem)
     86# define LNX_MM_DOWN_WRITE(a_pMm)   down_write(&(a_pMm)->mmap_sem)
     87# define LNX_MM_UP_WRITE(a_pMm)       up_write(&(a_pMm)->mmap_sem)
    7388#endif
    7489
     
    183198 * an empty user space mapping.
    184199 *
    185  * We acquire the mmap_sem of the task!
     200 * We acquire the mmap_sem/mmap_lock of the task!
    186201 *
    187202 * @returns Pointer to the mapping.
     
    223238        ulAddr = vm_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
    224239#else
    225         down_write(&pTask->mm->mmap_sem);
     240        LNX_MM_DOWN_WRITE(pTask->mm);
    226241        ulAddr = do_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
    227         up_write(&pTask->mm->mmap_sem);
     242        LNX_MM_UP_WRITE(pTask->mm);
    228243#endif
    229244    }
     
    233248        ulAddr = vm_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
    234249#else
    235         down_write(&pTask->mm->mmap_sem);
     250        LNX_MM_DOWN_WRITE(pTask->mm);
    236251        ulAddr = do_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
    237         up_write(&pTask->mm->mmap_sem);
     252        LNX_MM_UP_WRITE(pTask->mm);
    238253#endif
    239254        if (    !(ulAddr & ~PAGE_MASK)
     
    258273 * Undoes what rtR0MemObjLinuxDoMmap did.
    259274 *
    260  * We acquire the mmap_sem of the task!
     275 * We acquire the mmap_sem/mmap_lock of the task!
    261276 *
    262277 * @param   pv          The ring-3 mapping.
     
    270285    vm_munmap((unsigned long)pv, cb);
    271286#elif defined(USE_RHEL4_MUNMAP)
    272     down_write(&pTask->mm->mmap_sem);
     287    LNX_MM_DOWN_WRITE(pTask->mm);
    273288    do_munmap(pTask->mm, (unsigned long)pv, cb, 0); /* should it be 1 or 0? */
    274     up_write(&pTask->mm->mmap_sem);
     289    LNX_MM_UP_WRITE(pTask->mm);
    275290#else
    276     down_write(&pTask->mm->mmap_sem);
     291    LNX_MM_DOWN_WRITE(pTask->mm);
    277292    do_munmap(pTask->mm, (unsigned long)pv, cb);
    278     up_write(&pTask->mm->mmap_sem);
     293    LNX_MM_UP_WRITE(pTask->mm);
    279294#endif
    280295}
     
    594609                Assert(pTask);
    595610                if (pTask && pTask->mm)
    596                     down_read(&pTask->mm->mmap_sem);
     611                    LNX_MM_DOWN_READ(pTask->mm);
    597612
    598613                iPage = pMemLnx->cPages;
     
    609624
    610625                if (pTask && pTask->mm)
    611                     up_read(&pTask->mm->mmap_sem);
     626                    LNX_MM_UP_READ(pTask->mm);
    612627            }
    613628            /* else: kernel memory - nothing to do here. */
     
    10771092    if (papVMAs)
    10781093    {
    1079         down_read(&pTask->mm->mmap_sem);
     1094        LNX_MM_DOWN_READ(pTask->mm);
    10801095
    10811096        /*
     
    11631178            }
    11641179
    1165             up_read(&pTask->mm->mmap_sem);
     1180            LNX_MM_UP_READ(pTask->mm);
    11661181
    11671182            RTMemFree(papVMAs);
     
    11901205        }
    11911206
    1192         up_read(&pTask->mm->mmap_sem);
     1207        LNX_MM_UP_READ(pTask->mm);
    11931208
    11941209        RTMemFree(papVMAs);
     
    16051620            size_t          iPage;
    16061621
    1607             down_write(&pTask->mm->mmap_sem);
     1622            LNX_MM_DOWN_WRITE(pTask->mm);
    16081623
    16091624            rc = VINF_SUCCESS;
     
    17221737#endif /* CONFIG_NUMA_BALANCING */
    17231738
    1724             up_write(&pTask->mm->mmap_sem);
     1739            LNX_MM_UP_WRITE(pTask->mm);
    17251740
    17261741            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