Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/fb-helper: Consolidate CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM

Consolidate all handling of CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM by
making the module parameter optional in drm_fb_helper.c.

Without the config option, modules can set smem_start in struct
fb_info for internal usage, but not export if to userspace. The
address can only be exported by enabling the option and setting
the module parameter. Also update the comment.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Acked-by: Zack Rusin <zackr@vmware.com>
Tested-by: Sui Jingfeng<suijingfeng@loongson.cn>
Link: https://patchwork.freedesktop.org/patch/msgid/20230320150751.20399-8-tzimmermann@suse.de

+9 -31
+8 -14
drivers/gpu/drm/drm_fb_helper.c
··· 60 60 * In order to keep user-space compatibility, we want in certain use-cases 61 61 * to keep leaking the fbdev physical address to the user-space program 62 62 * handling the fbdev buffer. 63 - * This is a bad habit essentially kept into closed source opengl driver 64 - * that should really be moved into open-source upstream projects instead 65 - * of using legacy physical addresses in user space to communicate with 66 - * other out-of-tree kernel modules. 63 + * 64 + * This is a bad habit, essentially kept to support closed-source OpenGL 65 + * drivers that should really be moved into open-source upstream projects 66 + * instead of using legacy physical addresses in user space to communicate 67 + * with other out-of-tree kernel modules. 67 68 * 68 69 * This module_param *should* be removed as soon as possible and be 69 70 * considered as a broken and legacy behaviour from a modern fbdev device. 70 71 */ 71 - #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) 72 72 static bool drm_leak_fbdev_smem; 73 + #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) 73 74 module_param_unsafe(drm_leak_fbdev_smem, bool, 0600); 74 75 MODULE_PARM_DESC(drm_leak_fbdev_smem, 75 76 "Allow unsafe leaking fbdev physical smem address [default=false]"); ··· 1984 1983 return ret; 1985 1984 } 1986 1985 1987 - #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) 1988 - fb_helper->hint_leak_smem_start = drm_leak_fbdev_smem; 1989 - #endif 1990 - 1991 1986 /* push down into drivers */ 1992 1987 ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes); 1993 1988 if (ret < 0) ··· 2182 2185 2183 2186 info = fb_helper->info; 2184 2187 info->var.pixclock = 0; 2185 - /* Shamelessly allow physical address leaking to userspace */ 2186 - #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) 2187 - if (!fb_helper->hint_leak_smem_start) 2188 - #endif 2189 - /* don't leak any physical addresses to userspace */ 2188 + 2189 + if (!drm_leak_fbdev_smem) 2190 2190 info->flags |= FBINFO_HIDE_SMEM_START; 2191 2191 2192 2192 /* Need to drop locks to avoid recursive deadlock in
+1 -8
drivers/gpu/drm/drm_fbdev_dma.c
··· 136 136 info->flags |= FBINFO_READS_FAST; /* signal caching */ 137 137 info->screen_size = sizes->surface_height * fb->pitches[0]; 138 138 info->screen_buffer = map.vaddr; 139 + info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer)); 139 140 info->fix.smem_len = info->screen_size; 140 - 141 - #if IS_ENABLED(CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM) 142 - /* 143 - * Shamelessly leak the physical address to user-space. 144 - */ 145 - if (fb_helper->hint_leak_smem_start && !info->fix.smem_start) 146 - info->fix.smem_start = page_to_phys(virt_to_page(info->screen_buffer)); 147 - #endif 148 141 149 142 return 0; 150 143
-9
include/drm/drm_fb_helper.h
··· 195 195 */ 196 196 int preferred_bpp; 197 197 198 - /** 199 - * @hint_leak_smem_start: 200 - * 201 - * Hint to the fbdev emulation to store the framebuffer's physical 202 - * address in struct &fb_info.fix.smem_start. If the hint is unset, 203 - * the smem_start field should always be cleared to zero. 204 - */ 205 - bool hint_leak_smem_start; 206 - 207 198 #ifdef CONFIG_FB_DEFERRED_IO 208 199 /** 209 200 * @fbdefio: