]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
accel/habanalabs: support mapping cb with vmalloc-backed coherent memory
authorMoti Haimovski <moti.haimovski@intel.com>
Sun, 8 Sep 2024 12:01:26 +0000 (15:01 +0300)
committerKoby Elbaz <koby.elbaz@intel.com>
Thu, 25 Sep 2025 06:09:30 +0000 (09:09 +0300)
commit513024d5a0e34fd34247043f1876b6138ca52847
tree836ffcc97ea983df3a7a2d8656e28b613ad455ef
parent0668db41b5d8a834a04be3b281fa9452dcf3dc18
accel/habanalabs: support mapping cb with vmalloc-backed coherent memory

When IOMMU is enabled, dma_alloc_coherent() with GFP_USER may return
addresses from the vmalloc range. If such an address is mapped without
VM_MIXEDMAP, vm_insert_page() will trigger a BUG_ON due to the
VM_PFNMAP restriction.

Fix this by checking for vmalloc addresses and setting VM_MIXEDMAP
in the VMA before mapping. This ensures safe mapping and avoids kernel
crashes. The memory is still driver-allocated and cannot be accessed
directly by userspace.

Signed-off-by: Moti Haimovski <moti.haimovski@intel.com>
Reviewed-by: Koby Elbaz <koby.elbaz@intel.com>
Signed-off-by: Koby Elbaz <koby.elbaz@intel.com>
drivers/accel/habanalabs/gaudi/gaudi.c
drivers/accel/habanalabs/gaudi2/gaudi2.c