pan/kmod: Enforce PAN_KMOD_BO_FLAG_NO_MMAP
Fail early in pan_kmod_bo_mmap() if PAN_KMOD_BO_FLAG_NO_MMAP is set. This saves us a user -> kernel round-trip, but most importantly, it allows us to enforce NO_MMAP at the userspace level on BOs that the kernel would otherwise accept to mmap() (mapping of imported BOs requires extra DMA_BUF_IOCTL_SYNC calls we don't have). Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36385>
This commit is contained in:
@@ -648,6 +648,10 @@ pan_kmod_bo_mmap(struct pan_kmod_bo *bo, off_t bo_offset, size_t size, int prot,
|
||||
{
|
||||
off_t mmap_offset;
|
||||
|
||||
/* Don't bother trying an mmap() if it's not allowed. */
|
||||
if (bo->flags & PAN_KMOD_BO_FLAG_NO_MMAP)
|
||||
return MAP_FAILED;
|
||||
|
||||
if ((uint64_t)bo_offset + (uint64_t)size > bo->size)
|
||||
return MAP_FAILED;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user