⬢ DragonFlyBSD Kernel Audit
DF-5581 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/i915/i915_module.c b/sys/dev/drm/i915/i915_module.c
index 8dd3bcf..4d56e36 100644
--- a/sys/dev/drm/i915/i915_module.c
+++ b/sys/dev/drm/i915/i915_module.c
@@ -17,13 +17,26 @@ struct linux_resource intel_graphics_stolen_res;
 
 static int __init i915_init(void)
 {
-#if 0
+	/*
+	 * XXX: DragonFly never reserves the Intel graphics stolen range
+	 * out of the kernel physical memory map: the reservation KPI the
+	 * early quirk (sys/bus/pci/x86_64/pci_early_quirks.c) was written
+	 * for does not exist yet, so the call is commented out there and
+	 * nothing else carves the range out of phys_avail.
+	 *
+	 * On BIOSes that fail to hide stolen memory from the OS memory map
+	 * (the exact case the early quirk exists for), the kernel page
+	 * allocator still owns these pages; advertising the range here
+	 * makes i915 allocate GPU objects over live kernel memory, and the
+	 * devm_request_mem_region() conflict check is a DragonFly stub
+	 * that cannot detect the overlap (i915_gem_stolen.c).
+	 *
+	 * Keep stolen memory disabled (zero-sized resource) until a real
+	 * reservation exists.  i915_gem_init_stolen() treats a zero size
+	 * as "stolen unavailable" and falls back safely.
+	 */
 	intel_graphics_stolen_res = (struct linux_resource)
 		DEFINE_RES_MEM(0, 0);
-#endif
-	intel_graphics_stolen_res = (struct linux_resource)
-		DEFINE_RES_MEM(intel_graphics_stolen_base,
-		    intel_graphics_stolen_size);
 	DRM_INFO("Got Intel graphics stolen memory base 0x%lx, size 0x%lx\n",
 	    intel_graphics_stolen_res.start,
 	    resource_size(&intel_graphics_stolen_res));