1 Index: b/src/VBox/Additions/linux/sharedfolders/regops.c
2 ===================================================================
3 --- a/src/VBox/Additions/linux/sharedfolders/regops.c
4 +++ b/src/VBox/Additions/linux/sharedfolders/regops.c
5 @@ -1401,7 +1401,10 @@ static int vbsf_lock_user_pages_failed_c
7 * Check that this is valid user memory that is actually in the kernel range.
9 -#if RTLNX_VER_MIN(5,0,0) || RTLNX_RHEL_MIN(8,1)
10 +#if RTLNX_VER_MIN(5,10,0)
11 + if ( access_ok((void *)uPtrFrom, cPages << PAGE_SHIFT)
12 + && uPtrFrom >= TASK_SIZE_MAX)
13 +#elif RTLNX_VER_MIN(5,0,0) || RTLNX_RHEL_MIN(8,1)
14 if ( access_ok((void *)uPtrFrom, cPages << PAGE_SHIFT)
15 && uPtrFrom >= USER_DS.seg)
17 Index: b/src/VBox/Additions/linux/drm/vbox_drv.h
18 ===================================================================
19 --- a/src/VBox/Additions/linux/drm/vbox_drv.h
20 +++ b/src/VBox/Additions/linux/drm/vbox_drv.h
21 @@ -205,6 +205,13 @@ static inline void drm_gem_object_put(st
25 +#ifndef TTM_PL_FLAG_SYSTEM
26 +#define TTM_PL_FLAG_SYSTEM (1 << TTM_PL_SYSTEM)
28 +#ifndef TTM_PL_FLAG_VRAM
29 +#define TTM_PL_FLAG_VRAM (1 << TTM_PL_VRAM)
32 #define DRIVER_AUTHOR VBOX_VENDOR
34 #define DRIVER_NAME "vboxvideo"
35 Index: b/src/VBox/Additions/linux/drm/vbox_ttm.c
36 ===================================================================
37 --- a/src/VBox/Additions/linux/drm/vbox_ttm.c
38 +++ b/src/VBox/Additions/linux/drm/vbox_ttm.c
39 @@ -373,11 +373,23 @@ void vbox_ttm_placement(struct vbox_bo *
40 bo->placement.busy_placement = bo->placements;
42 if (domain & TTM_PL_FLAG_VRAM)
43 +#if RTLNX_VER_MIN(5,10,0)
44 + bo->placements[c].mem_type = TTM_PL_VRAM;
45 + PLACEMENT_FLAGS(bo->placements[c++]) =
46 + TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED;
48 PLACEMENT_FLAGS(bo->placements[c++]) =
49 TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_VRAM;
51 if (domain & TTM_PL_FLAG_SYSTEM)
52 +#if RTLNX_VER_MIN(5,10,0)
53 + bo->placements[c].mem_type = TTM_PL_SYSTEM;
54 + PLACEMENT_FLAGS(bo->placements[c++]) =
55 + TTM_PL_MASK_CACHING;
57 PLACEMENT_FLAGS(bo->placements[c++]) =
58 TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
61 PLACEMENT_FLAGS(bo->placements[c++]) =
62 TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
63 Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
64 ===================================================================
65 --- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (Revision 141658)
66 +++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (Arbeitskopie)
68 * Whether we use alloc_vm_area (3.2+) for executable memory.
69 * This is a must for 5.8+, but we enable it all the way back to 3.2.x for
70 * better W^R compliance (fExecutable flag). */
71 -#if RTLNX_VER_MIN(3,2,0) || defined(DOXYGEN_RUNNING)
72 +#if RTLNX_VER_RANGE(3,2,0, 5,10,0) || defined(DOXYGEN_RUNNING)
73 # define IPRT_USE_ALLOC_VM_AREA_FOR_EXEC
75 +#if RTLNX_VER_MIN(5,10,0) || defined(DOXYGEN_RUNNING)
76 +# define IPRT_USE_APPLY_TO_PAGE_RANGE_FOR_EXEC
80 * 2.6.29+ kernels don't work with remap_pfn_range() anymore because
85 +#ifdef IPRT_USE_APPLY_TO_PAGE_RANGE_FOR_EXEC
87 + * User data passed to the apply_to_page_range() callback.
89 +typedef struct LNXAPPLYPGRANGE
91 + /** Pointer to the memory object. */
92 + PRTR0MEMOBJLNX pMemLnx;
93 + /** The page protection flags to apply. */
96 +/** Pointer to the user data. */
97 +typedef LNXAPPLYPGRANGE *PLNXAPPLYPGRANGE;
98 +/** Pointer to the const user data. */
99 +typedef const LNXAPPLYPGRANGE *PCLNXAPPLYPGRANGE;
102 + * Callback called in apply_to_page_range().
104 + * @returns Linux status code.
105 + * @param pPte Pointer to the page table entry for the given address.
106 + * @param uAddr The address to apply the new protection to.
107 + * @param pvUser The opaque user data.
109 +static int rtR0MemObjLinuxApplyPageRange(pte_t *pPte, unsigned long uAddr, void *pvUser)
111 + PCLNXAPPLYPGRANGE pArgs = (PCLNXAPPLYPGRANGE)pvUser;
112 + PRTR0MEMOBJLNX pMemLnx = pArgs->pMemLnx;
113 + uint32_t idxPg = (uAddr - (unsigned long)pMemLnx->Core.pv) >> PAGE_SHIFT;
115 + set_pte(pPte, mk_pte(pMemLnx->apPages[idxPg], pArgs->fPg));
122 * Maps the allocation into ring-0.
124 * This will update the RTR0MEMOBJLNX::Core.pv and RTR0MEMOBJ::fMappedToRing0 members.
129 +# if defined(IPRT_USE_APPLY_TO_PAGE_RANGE_FOR_EXEC)
131 + pgprot_val(fPg) |= _PAGE_NX; /* Uses RTR0MemObjProtect to clear NX when memory ready, W^X fashion. */
135 pMemLnx->Core.pv = vmap(&pMemLnx->apPages[0], pMemLnx->cPages, VM_MAP, fPg);
137 @@ -1851,6 +1895,21 @@
141 +# elif defined(IPRT_USE_APPLY_TO_PAGE_RANGE_FOR_EXEC)
142 + PRTR0MEMOBJLNX pMemLnx = (PRTR0MEMOBJLNX)pMem;
143 + if ( pMemLnx->fExecutable
144 + && pMemLnx->fMappedToRing0)
146 + LNXAPPLYPGRANGE Args;
147 + Args.pMemLnx = pMemLnx;
148 + Args.fPg = rtR0MemObjLinuxConvertProt(fProt, true /*fKernel*/);
149 + int rcLnx = apply_to_page_range(current->active_mm, (unsigned long)pMemLnx->Core.pv + offSub, cbSub,
150 + rtR0MemObjLinuxApplyPageRange, (void *)&Args);
152 + return VERR_NOT_SUPPORTED;
154 + return VINF_SUCCESS;