Index: trunk/src/VBox/Additions/linux/drm/vbox_drv.h
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vbox_drv.h	(revision 87091)
+++ trunk/src/VBox/Additions/linux/drm/vbox_drv.h	(revision 87092)
@@ -176,4 +176,7 @@
 #include <drm/ttm/ttm_memory.h>
 #include <drm/ttm/ttm_module.h>
+#if RTLNX_VER_MIN(5,10,0)
+# include <drm/ttm/ttm_resource.h>
+#endif
 
 #include "vboxvideo_guest.h"
@@ -445,5 +448,8 @@
 		    u32 size, bool iskernel, struct drm_gem_object **obj);
 
-int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr);
+#define VBOX_MEM_TYPE_VRAM   0x1
+#define VBOX_MEM_TYPE_SYSTEM 0x2
+
+int vbox_bo_pin(struct vbox_bo *bo, u32 mem_type, u64 *gpu_addr);
 int vbox_bo_unpin(struct vbox_bo *bo);
 
@@ -470,5 +476,5 @@
 }
 
-void vbox_ttm_placement(struct vbox_bo *bo, int domain);
+void vbox_ttm_placement(struct vbox_bo *bo, u32 mem_type);
 int vbox_bo_push_sysram(struct vbox_bo *bo);
 int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
Index: trunk/src/VBox/Additions/linux/drm/vbox_fb.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vbox_fb.c	(revision 87091)
+++ trunk/src/VBox/Additions/linux/drm/vbox_fb.c	(revision 87092)
@@ -296,5 +296,5 @@
 		return ret;
 
-	ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	ret = vbox_bo_pin(bo, VBOX_MEM_TYPE_VRAM, NULL);
 	if (ret) {
 		vbox_bo_unreserve(bo);
Index: trunk/src/VBox/Additions/linux/drm/vbox_mode.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vbox_mode.c	(revision 87091)
+++ trunk/src/VBox/Additions/linux/drm/vbox_mode.c	(revision 87092)
@@ -228,5 +228,5 @@
 		return ret;
 
-	ret = vbox_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
+	ret = vbox_bo_pin(bo, VBOX_MEM_TYPE_VRAM, &gpu_addr);
 	vbox_bo_unreserve(bo);
 	if (ret)
Index: trunk/src/VBox/Additions/linux/drm/vbox_ttm.c
===================================================================
--- trunk/src/VBox/Additions/linux/drm/vbox_ttm.c	(revision 87091)
+++ trunk/src/VBox/Additions/linux/drm/vbox_ttm.c	(revision 87092)
@@ -42,4 +42,5 @@
 #endif
 
+
 static inline struct vbox_private *vbox_bdev(struct ttm_bo_device *bd)
 {
@@ -126,4 +127,5 @@
 }
 
+#if RTLNX_VER_MAX(5,10,0)
 static int
 vbox_bo_init_mem_type(struct ttm_bo_device *bdev, u32 type,
@@ -149,4 +151,5 @@
 	return 0;
 }
+#endif
 
 static void
@@ -158,5 +161,5 @@
 		return;
 
-	vbox_ttm_placement(vboxbo, TTM_PL_FLAG_SYSTEM);
+	vbox_ttm_placement(vboxbo, VBOX_MEM_TYPE_SYSTEM);
 	*pl = vboxbo->placement;
 }
@@ -168,9 +171,10 @@
 }
 
+#if RTLNX_VER_MAX(5,10,0)
 static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
 				   struct ttm_mem_reg *mem)
 {
+	struct vbox_private *vbox = vbox_bdev(bdev);
 	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
-	struct vbox_private *vbox = vbox_bdev(bdev);
 
 	mem->bus.addr = NULL;
@@ -195,10 +199,51 @@
 	return 0;
 }
-
+#else
+static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
+				   struct ttm_resource *mem)
+{
+	struct vbox_private *vbox = vbox_bdev(bdev);
+	mem->bus.addr = NULL;
+	mem->bus.offset = 0;
+	mem->size = mem->num_pages << PAGE_SHIFT;
+	mem->start = 0;
+	mem->bus.is_iomem = false;
+	switch (mem->mem_type) {
+	case TTM_PL_SYSTEM:
+		/* system memory */
+		return 0;
+	case TTM_PL_VRAM:
+		mem->bus.offset = mem->start << PAGE_SHIFT;
+		mem->start = pci_resource_start(vbox->dev->pdev, 0);
+		mem->bus.is_iomem = true;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+#endif
+
+
+
+#if RTLNX_VER_MIN(5,10,0)
+static void vbox_ttm_io_mem_free(struct ttm_bo_device *bdev,
+				 struct ttm_resource *mem)
+{
+}
+#else
 static void vbox_ttm_io_mem_free(struct ttm_bo_device *bdev,
 				 struct ttm_mem_reg *mem)
 {
 }
-
+#endif
+
+#if RTLNX_VER_MIN(5,10,0)
+static void vbox_ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *tt)
+{
+	ttm_tt_fini(tt);
+	kfree(tt);
+}
+#else
 static void vbox_ttm_backend_destroy(struct ttm_tt *tt)
 {
@@ -210,4 +255,5 @@
 	.destroy = &vbox_ttm_backend_destroy,
 };
+#endif
 
 #if RTLNX_VER_MAX(4,17,0) && !RTLNX_RHEL_MAJ_PREREQ(7,6) && !RTLNX_SUSE_MAJ_PREREQ(15,1) && !RTLNX_SUSE_MAJ_PREREQ(12,5)
@@ -227,5 +273,7 @@
 		return NULL;
 
+#if RTLNX_VER_MAX(5,10,0)
 	tt->func = &vbox_tt_backend_func;
+#endif
 #if RTLNX_VER_MAX(4,17,0) && !RTLNX_RHEL_MAJ_PREREQ(7,6) && !RTLNX_SUSE_MAJ_PREREQ(15,1) && !RTLNX_SUSE_MAJ_PREREQ(12,5)
 	if (ttm_tt_init(tt, bdev, size, page_flags, dummy_read_page)) {
@@ -262,9 +310,14 @@
 static struct ttm_bo_driver vbox_bo_driver = {
 	.ttm_tt_create = vbox_ttm_tt_create,
+#if RTLNX_VER_MIN(5,10,0)
+	.ttm_tt_destroy = vbox_ttm_tt_destroy,
+#endif
 #if RTLNX_VER_MAX(4,17,0)
 	.ttm_tt_populate = vbox_ttm_tt_populate,
 	.ttm_tt_unpopulate = vbox_ttm_tt_unpopulate,
 #endif
+#if RTLNX_VER_MAX(5,10,0)
 	.init_mem_type = vbox_bo_init_mem_type,
+#endif
 #if RTLNX_VER_MIN(4,10,0) || RTLNX_RHEL_MAJ_PREREQ(7,4)
 	.eviction_valuable = ttm_bo_eviction_valuable,
@@ -319,6 +372,11 @@
 	}
 
+#if RTLNX_VER_MIN(5,10,0)
+	ret = ttm_range_man_init(bdev, TTM_PL_VRAM, false,
+			     vbox->available_vram_size >> PAGE_SHIFT);
+#else
 	ret = ttm_bo_init_mm(bdev, TTM_PL_VRAM,
 			     vbox->available_vram_size >> PAGE_SHIFT);
+#endif
 	if (ret) {
 		DRM_ERROR("Failed ttm VRAM init: %d\n", ret);
@@ -360,5 +418,5 @@
 }
 
-void vbox_ttm_placement(struct vbox_bo *bo, int domain)
+void vbox_ttm_placement(struct vbox_bo *bo, u32 mem_type)
 {
 	u32 c = 0;
@@ -373,13 +431,34 @@
 	bo->placement.busy_placement = bo->placements;
 
-	if (domain & TTM_PL_FLAG_VRAM)
+	if (mem_type & VBOX_MEM_TYPE_VRAM) {
+#if RTLNX_VER_MIN(5,10,0)
+		bo->placements[c].mem_type = TTM_PL_VRAM;
+		PLACEMENT_FLAGS(bo->placements[c++]) =
+		    TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED;
+#else
 		PLACEMENT_FLAGS(bo->placements[c++]) =
 		    TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_VRAM;
-	if (domain & TTM_PL_FLAG_SYSTEM)
+#endif
+	}
+	if (mem_type & VBOX_MEM_TYPE_SYSTEM) {
+#if RTLNX_VER_MIN(5,10,0)
+		bo->placements[c].mem_type = TTM_PL_SYSTEM;
+		PLACEMENT_FLAGS(bo->placements[c++]) =
+		    TTM_PL_MASK_CACHING;
+#else
 		PLACEMENT_FLAGS(bo->placements[c++]) =
 		    TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
-	if (!c)
+#endif
+	}
+	if (!c) {
+#if RTLNX_VER_MIN(5,10,0)
+		bo->placements[c].mem_type = TTM_PL_SYSTEM;
+		PLACEMENT_FLAGS(bo->placements[c++]) =
+		    TTM_PL_MASK_CACHING;
+#else
 		PLACEMENT_FLAGS(bo->placements[c++]) =
 		    TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+#endif
+	}
 
 	bo->placement.num_placement = c;
@@ -415,5 +494,5 @@
 #endif
 
-	vbox_ttm_placement(vboxbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
+	vbox_ttm_placement(vboxbo, VBOX_MEM_TYPE_VRAM | VBOX_MEM_TYPE_SYSTEM);
 
 	acc_size = ttm_bo_dma_acc_size(&vbox->ttm.bdev, size,
@@ -453,5 +532,5 @@
 }
 
-int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr)
+int vbox_bo_pin(struct vbox_bo *bo, u32 mem_type, u64 *gpu_addr)
 {
 #if RTLNX_VER_MIN(4,16,0) || RTLNX_RHEL_MAJ_PREREQ(7,6) || RTLNX_SUSE_MAJ_PREREQ(15,1) || RTLNX_SUSE_MAJ_PREREQ(12,5)
@@ -468,5 +547,5 @@
 	}
 
-	vbox_ttm_placement(bo, pl_flag);
+	vbox_ttm_placement(bo, mem_type);
 
 	for (i = 0; i < bo->placement.num_placement; i++)
@@ -541,5 +620,5 @@
 		ttm_bo_kunmap(&bo->kmap);
 
-	vbox_ttm_placement(bo, TTM_PL_FLAG_SYSTEM);
+	vbox_ttm_placement(bo, VBOX_MEM_TYPE_SYSTEM);
 
 	for (i = 0; i < bo->placement.num_placement; i++)
