diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD index a89ea74..cccac3d 100644 --- a/trunk/PKGBUILD +++ b/trunk/PKGBUILD @@ -78,7 +78,16 @@ source=("https://download.virtualbox.org/virtualbox/${pkgver}/VirtualBox-${pkgve '016-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch' '017-fix-narrowing-conversion.patch' '018-xclient.patch' - '020-gsoap.patch') + '020-gsoap.patch' + 'r85208.patch' + 'r85430.patch' + 'r85431.patch' + 'r85432.patch' + 'r85504.patch' + 'r85505.patch' + 'r85514.patch' + 'r85516.patch' + 'r85518.patch') sha256sums=('05eff0321daa72f6d00fb121a6b4211f39964778823806fa0b7b751667dec362' 'SKIP' '76d98ea062fcad9e5e3fa981d046a6eb12a3e718a296544a68b66f4b65cb56db' @@ -103,7 +112,16 @@ sha256sums=('05eff0321daa72f6d00fb121a6b4211f39964778823806fa0b7b751667dec362' '100c9e14e9cfb12ae65364e830153d2481cf272ceeb39d11c6b203bc6e35bf0c' '5aac692909a0a0ec56b08bdece9e42cf7463abdca9da2f990d441ff463be6a99' 'cac5a573e9ed5aafb2f469c2e6fffb8cd4f389bbadba5a968c9f65be7a72fee3' - 'c6892a3561a72a9b308cb33fa6647cc53e54a3bd40cb41780cad7f8e9d7df9f6') + 'c6892a3561a72a9b308cb33fa6647cc53e54a3bd40cb41780cad7f8e9d7df9f6' + 'ca10f233a61e907266b6a05da0186acdbe1442bcb2b94b87b5ba25f0f44be578' + 'ebf75486733153ae4934beca10f434e5d412e4f75e15bb1f76a0a0ea4a38391e' + 'a47953806847d74153e3272b18e14bcc76de5ce621130dd0e464dda549385390' + '40dc275f719c0cf256db5f653fa71881040b3b3a56fdc25043bd33db3bae5acc' + 'b1e64320f55d5d85bd5bcf0c8a1b93ca195c1e33a40ea3287d9f05748829ec9d' + '2b680f42f8ac32ca4aa5deb7e1f9cba320c91ca3a22e456eddb2a4ebf8bfe2e3' + '022b361d020e35c9ada5eec9e3f03a8856c19929ac3e191693c611506bdc894f' + 'eea5442bdef77d4a63fda250f82a7752c604cc5e19c278ab4cd98456f74efb6a' + '084075357bb5fcd0b7a73120886b2c4af99a85ef628e110373aad7765d67fe0b') prepare() { cd "VirtualBox-$pkgver" diff --git a/trunk/r85208.patch b/trunk/r85208.patch new file mode 100644 index 0000000..f07026c --- /dev/null +++ b/trunk/r85208.patch @@ -0,0 +1,50 @@ +Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c +--- a/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 85207) ++++ b/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 85208) +@@ -31,6 +31,12 @@ + #define LOG_GROUP RTLOGGROUP_TIME + #include "the-linux-kernel.h" + #include "internal/iprt.h" ++/* Make sure we have the setting functions we need for RTTimeNow: */ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) ++# define RTTIME_INCL_TIMEVAL ++#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) ++# define RTTIME_INCL_TIMESPEC ++#endif + #include + #include + +@@ -182,22 +188,19 @@ + RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime) + { + IPRT_LINUX_SAVE_EFL_AC(); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) +-/* On Linux 4.20, time.h includes time64.h and we have to use 64-bit times. */ +-# ifdef _LINUX_TIME64_H ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) + struct timespec64 Ts; +- ktime_get_real_ts64(&Ts); +-# else ++ ktime_get_real_ts64(&Ts); /* ktime_get_real_ts64 was added as a macro in 3.17, function since 4.18. */ ++ IPRT_LINUX_RESTORE_EFL_AC(); ++ return RTTimeSpecSetTimespec64(pTime, &Ts); ++ ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) + struct timespec Ts; +- ktime_get_real_ts(&Ts); +-# endif ++ ktime_get_real_ts(&Ts); /* ktime_get_real_ts was removed in Linux 4.20. */ + IPRT_LINUX_RESTORE_EFL_AC(); +-# ifdef _LINUX_TIME64_H +- return RTTimeSpecSetTimespec64(pTime, &Ts); +-# else + return RTTimeSpecSetTimespec(pTime, &Ts); +-# endif +-#else /* < 2.6.16 */ ++ ++#else /* < 2.6.16 */ + struct timeval Tv; + do_gettimeofday(&Tv); + IPRT_LINUX_RESTORE_EFL_AC(); diff --git a/trunk/r85430.patch b/trunk/r85430.patch new file mode 100644 index 0000000..592a3d7 --- /dev/null +++ b/trunk/r85430.patch @@ -0,0 +1,151 @@ +Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85429) ++++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85430) +@@ -72,7 +72,22 @@ + # define gfp_t unsigned + #endif + ++/* ++ * Wrappers around mmap_lock/mmap_sem difference. ++ */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++# define LNX_MM_DOWN_READ(a_pMm) down_read(&(a_pMm)->mmap_lock) ++# define LNX_MM_UP_READ(a_pMm) up_read(&(a_pMm)->mmap_lock) ++# define LNX_MM_DOWN_WRITE(a_pMm) down_write(&(a_pMm)->mmap_lock) ++# define LNX_MM_UP_WRITE(a_pMm) up_write(&(a_pMm)->mmap_lock) ++#else ++# define LNX_MM_DOWN_READ(a_pMm) down_read(&(a_pMm)->mmap_sem) ++# define LNX_MM_UP_READ(a_pMm) up_read(&(a_pMm)->mmap_sem) ++# define LNX_MM_DOWN_WRITE(a_pMm) down_write(&(a_pMm)->mmap_sem) ++# define LNX_MM_UP_WRITE(a_pMm) up_write(&(a_pMm)->mmap_sem) ++#endif + ++ + /********************************************************************************************************************************* + * Structures and Typedefs * + *********************************************************************************************************************************/ +@@ -182,7 +197,7 @@ + * Worker for rtR0MemObjNativeReserveUser and rtR0MemObjNativerMapUser that creates + * an empty user space mapping. + * +- * We acquire the mmap_sem of the task! ++ * We acquire the mmap_sem/mmap_lock of the task! + * + * @returns Pointer to the mapping. + * (void *)-1 on failure. +@@ -222,9 +237,9 @@ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) + ulAddr = vm_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0); + #else +- down_write(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_WRITE(pTask->mm); + ulAddr = do_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0); +- up_write(&pTask->mm->mmap_sem); ++ LNX_MM_UP_WRITE(pTask->mm); + #endif + } + else +@@ -232,9 +247,9 @@ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0) + ulAddr = vm_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0); + #else +- down_write(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_WRITE(pTask->mm); + ulAddr = do_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0); +- up_write(&pTask->mm->mmap_sem); ++ LNX_MM_UP_WRITE(pTask->mm); + #endif + if ( !(ulAddr & ~PAGE_MASK) + && (ulAddr & (uAlignment - 1))) +@@ -257,7 +272,7 @@ + * Worker that destroys a user space mapping. + * Undoes what rtR0MemObjLinuxDoMmap did. + * +- * We acquire the mmap_sem of the task! ++ * We acquire the mmap_sem/mmap_lock of the task! + * + * @param pv The ring-3 mapping. + * @param cb The size of the mapping. +@@ -269,13 +284,13 @@ + Assert(pTask == current); RT_NOREF_PV(pTask); + vm_munmap((unsigned long)pv, cb); + #elif defined(USE_RHEL4_MUNMAP) +- down_write(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_WRITE(pTask->mm); + do_munmap(pTask->mm, (unsigned long)pv, cb, 0); /* should it be 1 or 0? */ +- up_write(&pTask->mm->mmap_sem); ++ LNX_MM_UP_WRITE(pTask->mm); + #else +- down_write(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_WRITE(pTask->mm); + do_munmap(pTask->mm, (unsigned long)pv, cb); +- up_write(&pTask->mm->mmap_sem); ++ LNX_MM_UP_WRITE(pTask->mm); + #endif + } + +@@ -593,7 +608,7 @@ + size_t iPage; + Assert(pTask); + if (pTask && pTask->mm) +- down_read(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_READ(pTask->mm); + + iPage = pMemLnx->cPages; + while (iPage-- > 0) +@@ -608,7 +623,7 @@ + } + + if (pTask && pTask->mm) +- up_read(&pTask->mm->mmap_sem); ++ LNX_MM_UP_READ(pTask->mm); + } + /* else: kernel memory - nothing to do here. */ + break; +@@ -1076,7 +1091,7 @@ + papVMAs = (struct vm_area_struct **)RTMemAlloc(sizeof(*papVMAs) * cPages); + if (papVMAs) + { +- down_read(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_READ(pTask->mm); + + /* + * Get user pages. +@@ -1162,7 +1177,7 @@ + papVMAs[rc]->vm_flags |= VM_DONTCOPY | VM_LOCKED; + } + +- up_read(&pTask->mm->mmap_sem); ++ LNX_MM_UP_READ(pTask->mm); + + RTMemFree(papVMAs); + +@@ -1189,7 +1204,7 @@ + #endif + } + +- up_read(&pTask->mm->mmap_sem); ++ LNX_MM_UP_READ(pTask->mm); + + RTMemFree(papVMAs); + rc = VERR_LOCK_FAILED; +@@ -1604,7 +1619,7 @@ + const size_t cPages = (offSub + cbSub) >> PAGE_SHIFT; + size_t iPage; + +- down_write(&pTask->mm->mmap_sem); ++ LNX_MM_DOWN_WRITE(pTask->mm); + + rc = VINF_SUCCESS; + if (pMemLnxToMap->cPages) +@@ -1721,7 +1736,7 @@ + } + #endif /* CONFIG_NUMA_BALANCING */ + +- up_write(&pTask->mm->mmap_sem); ++ LNX_MM_UP_WRITE(pTask->mm); + + if (RT_SUCCESS(rc)) + { diff --git a/trunk/r85431.patch b/trunk/r85431.patch new file mode 100644 index 0000000..3f29212 --- /dev/null +++ b/trunk/r85431.patch @@ -0,0 +1,38 @@ +Index: src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c +=================================================================== +diff --git a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c +--- a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (revision 85430) ++++ b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (revision 85431) +@@ -756,20 +756,25 @@ + + RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask) + { +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0) +- RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4); +- RTCCUINTREG uNew = (uOld & fAndMask) | fOrMask; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++ RTCCUINTREG const uOld = __read_cr4(); ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0) ++ RTCCUINTREG const uOld = this_cpu_read(cpu_tlbstate.cr4); ++#else ++ RTCCUINTREG const uOld = ASMGetCR4(); ++#endif ++ RTCCUINTREG const uNew = (uOld & fAndMask) | fOrMask; + if (uNew != uOld) + { ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++ ASMSetCR4(uNew); ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0) + this_cpu_write(cpu_tlbstate.cr4, uNew); + __write_cr4(uNew); +- } + #else +- RTCCUINTREG uOld = ASMGetCR4(); +- RTCCUINTREG uNew = (uOld & fAndMask) | fOrMask; +- if (uNew != uOld) + ASMSetCR4(uNew); + #endif ++ } + return uOld; + } + diff --git a/trunk/r85432.patch b/trunk/r85432.patch new file mode 100644 index 0000000..83437bc --- /dev/null +++ b/trunk/r85432.patch @@ -0,0 +1,14 @@ +Index: src/VBox/Additions/linux/sharedfolders/vfsmod.c +=================================================================== +diff --git a/src/VBox/Additions/linux/sharedfolders/vfsmod.c b/src/VBox/Additions/linux/sharedfolders/vfsmod.c +--- a/src/VBox/Additions/linux/sharedfolders/vfsmod.c (revision 85431) ++++ b/src/VBox/Additions/linux/sharedfolders/vfsmod.c (revision 85432) +@@ -52,7 +52,7 @@ + #endif + #include + #include +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 62) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 62) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + # include + #endif + #include diff --git a/trunk/r85504.patch b/trunk/r85504.patch new file mode 100644 index 0000000..b14e1dd --- /dev/null +++ b/trunk/r85504.patch @@ -0,0 +1,230 @@ +Index: include/iprt/memobj.h +=================================================================== +diff --git a/include/iprt/memobj.h b/include/iprt/memobj.h +--- a/include/iprt/memobj.h (revision 85503) ++++ b/include/iprt/memobj.h (revision 85504) +@@ -127,7 +127,10 @@ + * @returns IPRT status code. + * @param pMemObj Where to store the ring-0 memory object handle. + * @param cb Number of bytes to allocate. This is rounded up to nearest page. +- * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object. ++ * @param fExecutable Flag indicating whether it should be permitted to ++ * executed code in the memory object. The user must ++ * use RTR0MemObjProtect after initialization the ++ * allocation to actually make it executable. + */ + #define RTR0MemObjAllocPage(pMemObj, cb, fExecutable) \ + RTR0MemObjAllocPageTag((pMemObj), (cb), (fExecutable), RTMEM_TAG) +@@ -140,7 +143,10 @@ + * @returns IPRT status code. + * @param pMemObj Where to store the ring-0 memory object handle. + * @param cb Number of bytes to allocate. This is rounded up to nearest page. +- * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object. ++ * @param fExecutable Flag indicating whether it should be permitted to ++ * executed code in the memory object. The user must ++ * use RTR0MemObjProtect after initialization the ++ * allocation to actually make it executable. + * @param pszTag Allocation tag used for statistics and such. + */ + RTR0DECL(int) RTR0MemObjAllocPageTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag); +@@ -154,7 +160,10 @@ + * @returns IPRT status code. + * @param pMemObj Where to store the ring-0 memory object handle. + * @param cb Number of bytes to allocate. This is rounded up to nearest page. +- * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object. ++ * @param fExecutable Flag indicating whether it should be permitted to ++ * executed code in the memory object. The user must ++ * use RTR0MemObjProtect after initialization the ++ * allocation to actually make it executable. + */ + #define RTR0MemObjAllocLow(pMemObj, cb, fExecutable) \ + RTR0MemObjAllocLowTag((pMemObj), (cb), (fExecutable), RTMEM_TAG) +@@ -168,7 +177,10 @@ + * @returns IPRT status code. + * @param pMemObj Where to store the ring-0 memory object handle. + * @param cb Number of bytes to allocate. This is rounded up to nearest page. +- * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object. ++ * @param fExecutable Flag indicating whether it should be permitted to ++ * executed code in the memory object. The user must ++ * use RTR0MemObjProtect after initialization the ++ * allocation to actually make it executable. + * @param pszTag Allocation tag used for statistics and such. + */ + RTR0DECL(int) RTR0MemObjAllocLowTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag); +@@ -182,7 +194,10 @@ + * @returns IPRT status code. + * @param pMemObj Where to store the ring-0 memory object handle. + * @param cb Number of bytes to allocate. This is rounded up to nearest page. +- * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object. ++ * @param fExecutable Flag indicating whether it should be permitted to ++ * executed code in the memory object. The user must ++ * use RTR0MemObjProtect after initialization the ++ * allocation to actually make it executable. + */ + #define RTR0MemObjAllocCont(pMemObj, cb, fExecutable) \ + RTR0MemObjAllocContTag((pMemObj), (cb), (fExecutable), RTMEM_TAG) +@@ -196,7 +211,10 @@ + * @returns IPRT status code. + * @param pMemObj Where to store the ring-0 memory object handle. + * @param cb Number of bytes to allocate. This is rounded up to nearest page. +- * @param fExecutable Flag indicating whether it should be permitted to executed code in the memory object. ++ * @param fExecutable Flag indicating whether it should be permitted to ++ * executed code in the memory object. The user must ++ * use RTR0MemObjProtect after initialization the ++ * allocation to actually make it executable. + * @param pszTag Allocation tag used for statistics and such. + */ + RTR0DECL(int) RTR0MemObjAllocContTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag); +Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85503) ++++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85504) +@@ -92,7 +92,7 @@ + * Structures and Typedefs * + *********************************************************************************************************************************/ + /** +- * The Darwin version of the memory object structure. ++ * The Linux version of the memory object structure. + */ + typedef struct RTR0MEMOBJLNX + { +@@ -105,11 +105,20 @@ + bool fExecutable; + /** Set if we've vmap'ed the memory into ring-0. */ + bool fMappedToRing0; ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++ /** Return from alloc_vm_area() that we now need to use for executable ++ * memory. */ ++ struct vm_struct *pArea; ++ /** PTE array that goes along with pArea (must be freed). */ ++ pte_t **papPtesForArea; ++#endif + /** The pages in the apPages array. */ + size_t cPages; + /** Array of struct page pointers. (variable size) */ + struct page *apPages[1]; +-} RTR0MEMOBJLNX, *PRTR0MEMOBJLNX; ++} RTR0MEMOBJLNX; ++/** Pointer to the linux memory object. */ ++typedef RTR0MEMOBJLNX *PRTR0MEMOBJLNX; + + + static void rtR0MemObjLinuxFreePages(PRTR0MEMOBJLNX pMemLnx); +@@ -535,15 +544,49 @@ + pgprot_val(fPg) |= _PAGE_NX; + # endif + ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++ if (fExecutable) ++ { ++ pte_t **papPtes = (pte_t **)kmalloc_array(pMemLnx->cPages, sizeof(papPtes[0]), GFP_KERNEL); ++ if (papPtes) ++ { ++ pMemLnx->pArea = alloc_vm_area(pMemLnx->Core.cb, papPtes); /* Note! pArea->nr_pages is not set. */ ++ if (pMemLnx->pArea) ++ { ++ size_t i; ++ Assert(pMemLnx->pArea->size >= pMemLnx->Core.cb); /* Note! includes guard page. */ ++ Assert(pMemLnx->pArea->addr); ++# ifdef _PAGE_NX ++ pgprot_val(fPg) |= _PAGE_NX; /* Uses RTR0MemObjProtect to clear NX when memory ready, W^X fashion. */ ++# endif ++ pMemLnx->papPtesForArea = papPtes; ++ for (i = 0; i < pMemLnx->cPages; i++) ++ *papPtes[i] = mk_pte(pMemLnx->apPages[i], fPg); ++ pMemLnx->Core.pv = pMemLnx->pArea->addr; ++ pMemLnx->fMappedToRing0 = true; ++ } ++ else ++ { ++ kfree(papPtes); ++ rc = VERR_MAP_FAILED; ++ } ++ } ++ else ++ rc = VERR_MAP_FAILED; ++ } ++ else ++# endif ++ { + # ifdef VM_MAP +- pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_MAP, fPg); ++ pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_MAP, fPg); + # else +- pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_ALLOC, fPg); ++ pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_ALLOC, fPg); + # endif +- if (pMemLnx->Core.pv) +- pMemLnx->fMappedToRing0 = true; +- else +- rc = VERR_MAP_FAILED; ++ if (pMemLnx->Core.pv) ++ pMemLnx->fMappedToRing0 = true; ++ else ++ rc = VERR_MAP_FAILED; ++ } + #else /* < 2.4.22 */ + rc = VERR_NOT_SUPPORTED; + #endif +@@ -569,6 +612,22 @@ + static void rtR0MemObjLinuxVUnmap(PRTR0MEMOBJLNX pMemLnx) + { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++ if (pMemLnx->pArea) ++ { ++# if 0 ++ pte_t **papPtes = pMemLnx->papPtesForArea; ++ size_t i; ++ for (i = 0; i < pMemLnx->cPages; i++) ++ *papPtes[i] = 0; ++# endif ++ free_vm_area(pMemLnx->pArea); ++ kfree(pMemLnx->papPtesForArea); ++ pMemLnx->pArea = NULL; ++ pMemLnx->papPtesForArea = NULL; ++ } ++ else ++# endif + if (pMemLnx->fMappedToRing0) + { + Assert(pMemLnx->Core.pv); +@@ -1437,6 +1496,7 @@ + * Use vmap - 2.4.22 and later. + */ + pgprot_t fPg = rtR0MemObjLinuxConvertProt(fProt, true /* kernel */); ++ /** @todo We don't really care too much for EXEC here... 5.8 always adds NX. */ + Assert(((offSub + cbSub) >> PAGE_SHIFT) <= pMemLnxToMap->cPages); + # ifdef VM_MAP + pMemLnx->Core.pv = vmap(&pMemLnxToMap->apPages[offSub >> PAGE_SHIFT], cbSub >> PAGE_SHIFT, VM_MAP, fPg); +@@ -1768,6 +1828,29 @@ + + DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINTERNAL pMem, size_t offSub, size_t cbSub, uint32_t fProt) + { ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++ /* ++ * Currently only supported when we've got addresses PTEs from the kernel. ++ */ ++ PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem; ++ if (pMemLnx->pArea && pMemLnx->papPtesForArea) ++ { ++ pgprot_t const fPg = rtR0MemObjLinuxConvertProt(fProt, true /*fKernel*/); ++ size_t const cPages = (offSub + cbSub) >> PAGE_SHIFT; ++ pte_t **papPtes = pMemLnx->papPtesForArea; ++ size_t i; ++ ++ for (i = offSub >> PAGE_SHIFT; i < cPages; i++) ++ { ++ set_pte(papPtes[i], mk_pte(pMemLnx->apPages[i], fPg)); ++ } ++ preempt_disable(); ++ __flush_tlb_all(); ++ preempt_enable(); ++ return VINF_SUCCESS; ++ } ++# endif ++ + NOREF(pMem); + NOREF(offSub); + NOREF(cbSub); diff --git a/trunk/r85505.patch b/trunk/r85505.patch new file mode 100644 index 0000000..591d808 --- /dev/null +++ b/trunk/r85505.patch @@ -0,0 +1,31 @@ +Index: src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c +--- a/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c (revision 85504) ++++ b/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c (revision 85505) +@@ -38,7 +38,7 @@ + + + #if (defined(RT_ARCH_AMD64) || defined(DOXYGEN_RUNNING)) && !defined(RTMEMALLOC_EXEC_HEAP) +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23) ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + /** + * Starting with 2.6.23 we can use __get_vm_area and map_vm_area to allocate + * memory in the moduel range. This is preferrable to the exec heap below. +Index: src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c +=================================================================== +diff --git a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c +--- a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (revision 85504) ++++ b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c (revision 85505) +@@ -144,9 +144,9 @@ + * Memory for the executable memory heap (in IPRT). + */ + # ifdef DEBUG ++# define EXEC_MEMORY_SIZE 10485760 /* 10 MB */ ++# else + # define EXEC_MEMORY_SIZE 8388608 /* 8 MB */ +-# else +-# define EXEC_MEMORY_SIZE 2097152 /* 2 MB */ + # endif + extern uint8_t g_abExecMemory[EXEC_MEMORY_SIZE]; + # ifndef VBOX_WITH_TEXT_MODMEM_HACK diff --git a/trunk/r85514.patch b/trunk/r85514.patch new file mode 100644 index 0000000..27f1efc --- /dev/null +++ b/trunk/r85514.patch @@ -0,0 +1,55 @@ +Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85513) ++++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85514) +@@ -52,6 +52,13 @@ + # define PAGE_READONLY_EXEC PAGE_READONLY + #endif + ++/** @def IPRT_USE_ALLOC_VM_AREA_FOR_EXEC ++ * Whether we use alloc_vm_area (3.2+) for executable memory. ++ * This is a must for 5.8+, but we'll enable it for earlier kernels later. */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) || defined(DOXYGEN_RUNNING) ++# define IPRT_USE_ALLOC_VM_AREA_FOR_EXEC ++#endif ++ + /* + * 2.6.29+ kernels don't work with remap_pfn_range() anymore because + * track_pfn_vma_new() is apparently not defined for non-RAM pages. +@@ -105,7 +112,7 @@ + bool fExecutable; + /** Set if we've vmap'ed the memory into ring-0. */ + bool fMappedToRing0; +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++#ifdef IPRT_USE_ALLOC_VM_AREA_FOR_EXEC + /** Return from alloc_vm_area() that we now need to use for executable + * memory. */ + struct vm_struct *pArea; +@@ -544,7 +551,7 @@ + pgprot_val(fPg) |= _PAGE_NX; + # endif + +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++# ifdef IPRT_USE_ALLOC_VM_AREA_FOR_EXEC + if (fExecutable) + { + pte_t **papPtes = (pte_t **)kmalloc_array(pMemLnx->cPages, sizeof(papPtes[0]), GFP_KERNEL); +@@ -612,7 +619,7 @@ + static void rtR0MemObjLinuxVUnmap(PRTR0MEMOBJLNX pMemLnx) + { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22) +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++# ifdef IPRT_USE_ALLOC_VM_AREA_FOR_EXEC + if (pMemLnx->pArea) + { + # if 0 +@@ -1828,7 +1835,7 @@ + + DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINTERNAL pMem, size_t offSub, size_t cbSub, uint32_t fProt) + { +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) ++# ifdef IPRT_USE_ALLOC_VM_AREA_FOR_EXEC + /* + * Currently only supported when we've got addresses PTEs from the kernel. + */ diff --git a/trunk/r85516.patch b/trunk/r85516.patch new file mode 100644 index 0000000..eaa90c9 --- /dev/null +++ b/trunk/r85516.patch @@ -0,0 +1,17 @@ +Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85515) ++++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 85516) +@@ -54,8 +54,9 @@ + + /** @def IPRT_USE_ALLOC_VM_AREA_FOR_EXEC + * Whether we use alloc_vm_area (3.2+) for executable memory. +- * This is a must for 5.8+, but we'll enable it for earlier kernels later. */ +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) || defined(DOXYGEN_RUNNING) ++ * This is a must for 5.8+, but we enable it all the way back to 3.2.x for ++ * better W^R compliance (fExecutable flag). */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) || defined(DOXYGEN_RUNNING) + # define IPRT_USE_ALLOC_VM_AREA_FOR_EXEC + #endif + diff --git a/trunk/r85518.patch b/trunk/r85518.patch new file mode 100644 index 0000000..a8013da --- /dev/null +++ b/trunk/r85518.patch @@ -0,0 +1,17 @@ +Index: src/VBox/Runtime/r0drv/linux/the-linux-kernel.h +=================================================================== +diff --git a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h +--- a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h (revision 85517) ++++ b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h (revision 85518) +@@ -176,6 +176,11 @@ + # include + #endif + ++/* for __flush_tlb_all() */ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)) ++# include ++#endif ++ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) + # include + #else