Commit 76f92201 authored by Thomas Zimmermann's avatar Thomas Zimmermann

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231127131655.4020-30-tzimmermann@suse.de
parent 23dad7b9
...@@ -51,6 +51,8 @@ static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -51,6 +51,8 @@ static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{ {
struct page *pages = virt_to_page(cfag12864b_buffer); struct page *pages = virt_to_page(cfag12864b_buffer);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return vm_map_pages_zero(vma, &pages, 1); return vm_map_pages_zero(vma, &pages, 1);
} }
......
...@@ -351,6 +351,8 @@ static int ht16k33_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -351,6 +351,8 @@ static int ht16k33_mmap(struct fb_info *info, struct vm_area_struct *vma)
struct ht16k33_priv *priv = info->par; struct ht16k33_priv *priv = info->par;
struct page *pages = virt_to_page(priv->fbdev.buffer); struct page *pages = virt_to_page(priv->fbdev.buffer);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return vm_map_pages_zero(vma, &pages, 1); return vm_map_pages_zero(vma, &pages, 1);
} }
......
...@@ -829,6 +829,8 @@ static int clcdfb_of_dma_setup(struct clcd_fb *fb) ...@@ -829,6 +829,8 @@ static int clcdfb_of_dma_setup(struct clcd_fb *fb)
static int clcdfb_of_dma_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) static int clcdfb_of_dma_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
{ {
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base, return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base,
fb->fb.fix.smem_start, fb->fb.fix.smem_len); fb->fb.fix.smem_start, fb->fb.fix.smem_len);
} }
......
...@@ -342,6 +342,8 @@ int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) ...@@ -342,6 +342,8 @@ int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
{ {
struct au1100fb_device *fbdev = to_au1100fb_device(fbi); struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
return dma_mmap_coherent(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys, return dma_mmap_coherent(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys,
......
...@@ -1236,6 +1236,8 @@ static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1236,6 +1236,8 @@ static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{ {
struct au1200fb_device *fbdev = info->par; struct au1200fb_device *fbdev = info->par;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return dma_mmap_coherent(fbdev->dev, vma, return dma_mmap_coherent(fbdev->dev, vma,
fbdev->fb_mem, fbdev->fb_phys, fbdev->fb_len); fbdev->fb_mem, fbdev->fb_phys, fbdev->fb_len);
} }
......
...@@ -325,11 +325,6 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -325,11 +325,6 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma)
if (info->fbops->fb_mmap) { if (info->fbops->fb_mmap) {
int res; int res;
/*
* The framebuffer needs to be accessed decrypted, be sure
* SME protection is removed ahead of the call
*/
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
res = info->fbops->fb_mmap(info, vma); res = info->fbops->fb_mmap(info, vma);
mutex_unlock(&info->mm_lock); mutex_unlock(&info->mm_lock);
return res; return res;
......
...@@ -227,6 +227,8 @@ static const struct address_space_operations fb_deferred_io_aops = { ...@@ -227,6 +227,8 @@ static const struct address_space_operations fb_deferred_io_aops = {
int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma)
{ {
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
vma->vm_ops = &fb_deferred_io_vm_ops; vma->vm_ops = &fb_deferred_io_vm_ops;
vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP); vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
if (!(info->flags & FBINFO_VIRTFB)) if (!(info->flags & FBINFO_VIRTFB))
......
...@@ -311,6 +311,8 @@ static int ep93xxfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -311,6 +311,8 @@ static int ep93xxfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{ {
unsigned int offset = vma->vm_pgoff << PAGE_SHIFT; unsigned int offset = vma->vm_pgoff << PAGE_SHIFT;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
if (offset < info->fix.smem_len) { if (offset < info->fix.smem_len) {
return dma_mmap_wc(info->device, vma, info->screen_base, return dma_mmap_wc(info->device, vma, info->screen_base,
info->fix.smem_start, info->fix.smem_len); info->fix.smem_start, info->fix.smem_len);
......
...@@ -1000,6 +1000,8 @@ static int gbefb_mmap(struct fb_info *info, ...@@ -1000,6 +1000,8 @@ static int gbefb_mmap(struct fb_info *info,
unsigned long phys_addr, phys_size; unsigned long phys_addr, phys_size;
u16 *tile; u16 *tile;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
/* check range */ /* check range */
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL; return -EINVAL;
......
...@@ -1203,6 +1203,8 @@ static int omapfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1203,6 +1203,8 @@ static int omapfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
struct omapfb_device *fbdev = plane->fbdev; struct omapfb_device *fbdev = plane->fbdev;
int r; int r;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
omapfb_rqueue_lock(fbdev); omapfb_rqueue_lock(fbdev);
r = fbdev->ctrl->mmap(info, vma); r = fbdev->ctrl->mmap(info, vma);
omapfb_rqueue_unlock(fbdev); omapfb_rqueue_unlock(fbdev);
......
...@@ -1095,6 +1095,8 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) ...@@ -1095,6 +1095,8 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
u32 len; u32 len;
int r; int r;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
rg = omapfb_get_mem_region(ofbi->region); rg = omapfb_get_mem_region(ofbi->region);
start = omapfb_get_region_paddr(ofbi); start = omapfb_get_region_paddr(ofbi);
......
...@@ -708,6 +708,8 @@ static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -708,6 +708,8 @@ static int ps3fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{ {
int r; int r;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
r = vm_iomap_memory(vma, info->fix.smem_start, info->fix.smem_len); r = vm_iomap_memory(vma, info->fix.smem_start, info->fix.smem_len);
dev_dbg(info->device, "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n", dev_dbg(info->device, "ps3fb: mmap framebuffer P(%lx)->V(%lx)\n",
......
...@@ -562,6 +562,8 @@ static int sa1100fb_mmap(struct fb_info *info, ...@@ -562,6 +562,8 @@ static int sa1100fb_mmap(struct fb_info *info,
container_of(info, struct sa1100fb_info, fb); container_of(info, struct sa1100fb_info, fb);
unsigned long off = vma->vm_pgoff << PAGE_SHIFT; unsigned long off = vma->vm_pgoff << PAGE_SHIFT;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
if (off < info->fix.smem_len) { if (off < info->fix.smem_len) {
vma->vm_pgoff += 1; /* skip over the palette */ vma->vm_pgoff += 1; /* skip over the palette */
return dma_mmap_wc(fbi->dev, vma, fbi->map_cpu, fbi->map_dma, return dma_mmap_wc(fbi->dev, vma, fbi->map_cpu, fbi->map_dma,
......
...@@ -60,6 +60,7 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map, ...@@ -60,6 +60,7 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,
/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ /* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
/* Each page, see which map applies */ /* Each page, see which map applies */
......
...@@ -1482,6 +1482,8 @@ sh_mobile_lcdc_overlay_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1482,6 +1482,8 @@ sh_mobile_lcdc_overlay_mmap(struct fb_info *info, struct vm_area_struct *vma)
if (info->fbdefio) if (info->fbdefio)
return fb_deferred_io_mmap(info, vma); return fb_deferred_io_mmap(info, vma);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return dma_mmap_coherent(ovl->channel->lcdc->dev, vma, ovl->fb_mem, return dma_mmap_coherent(ovl->channel->lcdc->dev, vma, ovl->fb_mem,
ovl->dma_handle, ovl->fb_size); ovl->dma_handle, ovl->fb_size);
} }
...@@ -1956,6 +1958,8 @@ sh_mobile_lcdc_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -1956,6 +1958,8 @@ sh_mobile_lcdc_mmap(struct fb_info *info, struct vm_area_struct *vma)
if (info->fbdefio) if (info->fbdefio)
return fb_deferred_io_mmap(info, vma); return fb_deferred_io_mmap(info, vma);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return dma_mmap_coherent(ch->lcdc->dev, vma, ch->fb_mem, return dma_mmap_coherent(ch->lcdc->dev, vma, ch->fb_mem,
ch->dma_handle, ch->fb_size); ch->dma_handle, ch->fb_size);
} }
......
...@@ -783,6 +783,8 @@ static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -783,6 +783,8 @@ static int ufx_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)
if (info->fbdefio) if (info->fbdefio)
return fb_deferred_io_mmap(info, vma); return fb_deferred_io_mmap(info, vma);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL; return -EINVAL;
if (size > info->fix.smem_len) if (size > info->fix.smem_len)
......
...@@ -331,6 +331,8 @@ static int dlfb_ops_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -331,6 +331,8 @@ static int dlfb_ops_mmap(struct fb_info *info, struct vm_area_struct *vma)
if (info->fbdefio) if (info->fbdefio)
return fb_deferred_io_mmap(info, vma); return fb_deferred_io_mmap(info, vma);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL; return -EINVAL;
if (size > info->fix.smem_len) if (size > info->fix.smem_len)
......
...@@ -998,6 +998,8 @@ static int vmlfb_mmap(struct fb_info *info, struct vm_area_struct *vma) ...@@ -998,6 +998,8 @@ static int vmlfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
int ret; int ret;
unsigned long prot; unsigned long prot;
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
ret = vmlfb_vram_offset(vinfo, offset); ret = vmlfb_vram_offset(vinfo, offset);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
......
...@@ -382,6 +382,8 @@ static int vfb_pan_display(struct fb_var_screeninfo *var, ...@@ -382,6 +382,8 @@ static int vfb_pan_display(struct fb_var_screeninfo *var,
static int vfb_mmap(struct fb_info *info, static int vfb_mmap(struct fb_info *info,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
return remap_vmalloc_range(vma, (void *)info->fix.smem_start, vma->vm_pgoff); return remap_vmalloc_range(vma, (void *)info->fix.smem_start, vma->vm_pgoff);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment