Commit e7c5c29a authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/fb-helper: Set flag in struct drm_fb_helper for leaking physical addresses



Uncouple the parameter drm_leak_fbdev_smem from the implementation by
setting a flag in struct drm_fb_helper. This will help to move the
generic fbdev emulation into its own source file, while keeping the
parameter in drm_fb_helper.c. No functional changes.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221103151446.2638-21-tzimmermann@suse.de
parent 7ce19535
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ MODULE_PARM_DESC(drm_fbdev_overalloc,
 * 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;
static bool drm_leak_fbdev_smem;
module_param_unsafe(drm_leak_fbdev_smem, bool, 0600);
MODULE_PARM_DESC(drm_leak_fbdev_smem,
		 "Allow unsafe leaking fbdev physical smem address [default=false]");
@@ -1968,6 +1968,10 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
		sizes.surface_height = config->max_height;
	}

#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
	fb_helper->hint_leak_smem_start = drm_leak_fbdev_smem;
#endif

	/* push down into drivers */
	ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
	if (ret < 0)
@@ -2165,7 +2169,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper,
	info->var.pixclock = 0;
	/* Shamelessly allow physical address leaking to userspace */
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
	if (!drm_leak_fbdev_smem)
	if (!fb_helper->hint_leak_smem_start)
#endif
		/* don't leak any physical addresses to userspace */
		info->flags |= FBINFO_HIDE_SMEM_START;
@@ -2564,7 +2568,7 @@ static int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
		 * case.
		 */
#if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM)
		if (drm_leak_fbdev_smem && fbi->fix.smem_start == 0 &&
		if (fb_helper->hint_leak_smem_start && fbi->fix.smem_start == 0 &&
		    !drm_WARN_ON_ONCE(dev, map.is_iomem))
			fbi->fix.smem_start =
				page_to_phys(virt_to_page(fbi->screen_buffer));
+2 −0
Original line number Diff line number Diff line
@@ -199,6 +199,8 @@ struct drm_fb_helper {
	 * See also: @deferred_setup
	 */
	int preferred_bpp;

	bool hint_leak_smem_start;
};

static inline struct drm_fb_helper *