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:
Boris Brezillon
2025-10-28 10:49:51 +01:00
parent 0f4f556229
commit af14c37bf1

View File

@@ -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;