|
@@ -56,6 +56,25 @@ MODULE_PARM_DESC(drm_fbdev_overalloc,
|
|
|
"Overallocation of the fbdev buffer (%) [default="
|
|
|
__MODULE_STRING(CONFIG_DRM_FBDEV_OVERALLOC) "]");
|
|
|
|
|
|
+/*
|
|
|
+ * In order to keep user-space compatibility, we want in certain use-cases
|
|
|
+ * to keep leaking the fbdev physical address to the user-space program
|
|
|
+ * handling the fbdev buffer.
|
|
|
+ * This is a bad habit essentially kept into closed source opengl driver
|
|
|
+ * that should really be moved into open-source upstream projects instead
|
|
|
+ * of using legacy physical addresses in user space to communicate with
|
|
|
+ * other out-of-tree kernel modules.
|
|
|
+ *
|
|
|
+ * This module_param *should* be removed as soon as possible and be
|
|
|
+ * considered as a broken and legacy behaviour from a modern fbdev device.
|
|
|
+ */
|
|
|
+#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
|
|
|
+static bool drm_leak_fbdev_smem = false;
|
|
|
+module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
|
|
|
+MODULE_PARM_DESC(fbdev_emulation,
|
|
|
+ "Allow unsafe leaking fbdev physical smem address [default=false]");
|
|
|
+#endif
|
|
|
+
|
|
|
static LIST_HEAD(kernel_fb_helper_list);
|
|
|
static DEFINE_MUTEX(kernel_fb_helper_lock);
|
|
|
|
|
@@ -2670,8 +2689,12 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper,
|
|
|
|
|
|
info = fb_helper->fbdev;
|
|
|
info->var.pixclock = 0;
|
|
|
- /* don't leak any physical addresses to userspace */
|
|
|
- info->flags |= FBINFO_HIDE_SMEM_START;
|
|
|
+ /* Shamelessly allow physical address leaking to userspace */
|
|
|
+#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
|
|
|
+ if (!drm_leak_fbdev_smem)
|
|
|
+#endif
|
|
|
+ /* don't leak any physical addresses to userspace */
|
|
|
+ info->flags |= FBINFO_HIDE_SMEM_START;
|
|
|
|
|
|
/* Need to drop locks to avoid recursive deadlock in
|
|
|
* register_framebuffer. This is ok because the only thing left to do is
|
|
@@ -3081,6 +3104,12 @@ int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
|
|
|
fbi->screen_size = fb->height * fb->pitches[0];
|
|
|
fbi->fix.smem_len = fbi->screen_size;
|
|
|
fbi->screen_buffer = buffer->vaddr;
|
|
|
+ /* Shamelessly leak the physical address to user-space */
|
|
|
+#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
|
|
|
+ if (drm_leak_fbdev_smem && fbi->fix.smem_start == 0)
|
|
|
+ fbi->fix.smem_start =
|
|
|
+ page_to_phys(virt_to_page(fbi->screen_buffer));
|
|
|
+#endif
|
|
|
strcpy(fbi->fix.id, "DRM emulated");
|
|
|
|
|
|
drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
|