Commit d1dfe21
accel/habanalabs: support mapping cb with vmalloc-backed coherent memory
[ Upstream commit 513024d ]
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 <[email protected]>
Reviewed-by: Koby Elbaz <[email protected]>
Signed-off-by: Koby Elbaz <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent 71b40ff commit d1dfe21
2 files changed
+26
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4168 | 4168 | | |
4169 | 4169 | | |
4170 | 4170 | | |
| 4171 | + | |
| 4172 | + | |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
| 4176 | + | |
| 4177 | + | |
| 4178 | + | |
| 4179 | + | |
4171 | 4180 | | |
4172 | 4181 | | |
4173 | 4182 | | |
4174 | 4183 | | |
| 4184 | + | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
| 4193 | + | |
4175 | 4194 | | |
4176 | 4195 | | |
4177 | 4196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6490 | 6490 | | |
6491 | 6491 | | |
6492 | 6492 | | |
| 6493 | + | |
| 6494 | + | |
| 6495 | + | |
| 6496 | + | |
| 6497 | + | |
| 6498 | + | |
| 6499 | + | |
6493 | 6500 | | |
6494 | 6501 | | |
6495 | 6502 | | |
| |||
0 commit comments