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

fbdev: Push pgprot_decrypted() into mmap implementations

If a driver sets struct fb_ops.fb_mmap, the fbdev core automatically
calls pgprot_decrypted(). But the default fb_mmap code doesn't handle
pgprot_decrypted().

Move the call to pgprot_decrypted() into each drivers' fb_mmap function.
This only concerns fb_mmap functions for system and DMA memory. For
I/O memory, which is the default case, nothing changes. The fb_mmap
for I/O-memory can later be moved into a helper as well.

DRM's fbdev emulation handles pgprot_decrypted() internally via the
Prime helpers. Fbdev doesn't have to do anything in this case. In
cases where DRM uses deferred I/O, this patch updates fb_mmap correctly.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231127131655.4020-30-tzimmermann@suse.de

+37 -5
+2
drivers/auxdisplay/cfag12864bfb.c
··· 51 51 { 52 52 struct page *pages = virt_to_page(cfag12864b_buffer); 53 53 54 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 55 + 54 56 return vm_map_pages_zero(vma, &pages, 1); 55 57 } 56 58
+2
drivers/auxdisplay/ht16k33.c
··· 351 351 struct ht16k33_priv *priv = info->par; 352 352 struct page *pages = virt_to_page(priv->fbdev.buffer); 353 353 354 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 355 + 354 356 return vm_map_pages_zero(vma, &pages, 1); 355 357 } 356 358
+2
drivers/video/fbdev/amba-clcd.c
··· 829 829 830 830 static int clcdfb_of_dma_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) 831 831 { 832 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 833 + 832 834 return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base, 833 835 fb->fb.fix.smem_start, fb->fb.fix.smem_len); 834 836 }
+2
drivers/video/fbdev/au1100fb.c
··· 342 342 { 343 343 struct au1100fb_device *fbdev = to_au1100fb_device(fbi); 344 344 345 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 346 + 345 347 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6 346 348 347 349 return dma_mmap_coherent(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys,
+2
drivers/video/fbdev/au1200fb.c
··· 1236 1236 { 1237 1237 struct au1200fb_device *fbdev = info->par; 1238 1238 1239 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1240 + 1239 1241 return dma_mmap_coherent(fbdev->dev, vma, 1240 1242 fbdev->fb_mem, fbdev->fb_phys, fbdev->fb_len); 1241 1243 }
-5
drivers/video/fbdev/core/fb_chrdev.c
··· 325 325 if (info->fbops->fb_mmap) { 326 326 int res; 327 327 328 - /* 329 - * The framebuffer needs to be accessed decrypted, be sure 330 - * SME protection is removed ahead of the call 331 - */ 332 - vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 333 328 res = info->fbops->fb_mmap(info, vma); 334 329 mutex_unlock(&info->mm_lock); 335 330 return res;
+2
drivers/video/fbdev/core/fb_defio.c
··· 227 227 228 228 int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) 229 229 { 230 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 231 + 230 232 vma->vm_ops = &fb_deferred_io_vm_ops; 231 233 vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP); 232 234 if (!(info->flags & FBINFO_VIRTFB))
+2
drivers/video/fbdev/ep93xx-fb.c
··· 311 311 { 312 312 unsigned int offset = vma->vm_pgoff << PAGE_SHIFT; 313 313 314 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 315 + 314 316 if (offset < info->fix.smem_len) { 315 317 return dma_mmap_wc(info->device, vma, info->screen_base, 316 318 info->fix.smem_start, info->fix.smem_len);
+2
drivers/video/fbdev/gbefb.c
··· 1000 1000 unsigned long phys_addr, phys_size; 1001 1001 u16 *tile; 1002 1002 1003 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1004 + 1003 1005 /* check range */ 1004 1006 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 1005 1007 return -EINVAL;
+2
drivers/video/fbdev/omap/omapfb_main.c
··· 1203 1203 struct omapfb_device *fbdev = plane->fbdev; 1204 1204 int r; 1205 1205 1206 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1207 + 1206 1208 omapfb_rqueue_lock(fbdev); 1207 1209 r = fbdev->ctrl->mmap(info, vma); 1208 1210 omapfb_rqueue_unlock(fbdev);
+2
drivers/video/fbdev/omap2/omapfb/omapfb-main.c
··· 1095 1095 u32 len; 1096 1096 int r; 1097 1097 1098 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1099 + 1098 1100 rg = omapfb_get_mem_region(ofbi->region); 1099 1101 1100 1102 start = omapfb_get_region_paddr(ofbi);
+2
drivers/video/fbdev/ps3fb.c
··· 708 708 { 709 709 int r; 710 710 711 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 712 + 711 713 r = vm_iomap_memory(vma, info->fix.smem_start, info->fix.smem_len); 712 714 713 715 dev_dbg(info->device, "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n",
+2
drivers/video/fbdev/sa1100fb.c
··· 562 562 container_of(info, struct sa1100fb_info, fb); 563 563 unsigned long off = vma->vm_pgoff << PAGE_SHIFT; 564 564 565 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 566 + 565 567 if (off < info->fix.smem_len) { 566 568 vma->vm_pgoff += 1; /* skip over the palette */ 567 569 return dma_mmap_wc(fbi->dev, vma, fbi->map_cpu, fbi->map_dma,
+1
drivers/video/fbdev/sbuslib.c
··· 60 60 61 61 /* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ 62 62 63 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 63 64 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 64 65 65 66 /* Each page, see which map applies */
+4
drivers/video/fbdev/sh_mobile_lcdcfb.c
··· 1482 1482 if (info->fbdefio) 1483 1483 return fb_deferred_io_mmap(info, vma); 1484 1484 1485 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1486 + 1485 1487 return dma_mmap_coherent(ovl->channel->lcdc->dev, vma, ovl->fb_mem, 1486 1488 ovl->dma_handle, ovl->fb_size); 1487 1489 } ··· 1957 1955 1958 1956 if (info->fbdefio) 1959 1957 return fb_deferred_io_mmap(info, vma); 1958 + 1959 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1960 1960 1961 1961 return dma_mmap_coherent(ch->lcdc->dev, vma, ch->fb_mem, 1962 1962 ch->dma_handle, ch->fb_size);
+2
drivers/video/fbdev/smscufx.c
··· 783 783 if (info->fbdefio) 784 784 return fb_deferred_io_mmap(info, vma); 785 785 786 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 787 + 786 788 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 787 789 return -EINVAL; 788 790 if (size > info->fix.smem_len)
+2
drivers/video/fbdev/udlfb.c
··· 331 331 if (info->fbdefio) 332 332 return fb_deferred_io_mmap(info, vma); 333 333 334 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 335 + 334 336 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 335 337 return -EINVAL; 336 338 if (size > info->fix.smem_len)
+2
drivers/video/fbdev/vermilion/vermilion.c
··· 998 998 int ret; 999 999 unsigned long prot; 1000 1000 1001 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 1002 + 1001 1003 ret = vmlfb_vram_offset(vinfo, offset); 1002 1004 if (ret) 1003 1005 return -EINVAL;
+2
drivers/video/fbdev/vfb.c
··· 382 382 static int vfb_mmap(struct fb_info *info, 383 383 struct vm_area_struct *vma) 384 384 { 385 + vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); 386 + 385 387 return remap_vmalloc_range(vma, (void *)info->fix.smem_start, vma->vm_pgoff); 386 388 } 387 389