Re: [PATCH v2 1/2] mm/vmalloc: drop VM_DMA_COHERENT from remap_vmalloc_range_partial

From: Ye Liu

Date: Mon Nov 30 2026 - 21:07:45 EST




在 2026/11/22 23:39, Uladzislau Rezki 写道:
> On Thu, Oct 29, 2026 at 05:19:07PM +0800, Ye Liu wrote:
>> From: Ye Liu <liuye@xxxxxxxxxx>
>>
>> No caller maps a VM_DMA_COHERENT area through this path: such areas
>> come from dma_alloc_coherent() internals and are freed via vunmap(),
>> never through remap_vmalloc_range[_partial](); all 13 callers pass
>> vmalloc_user()/vmalloc()-backed addresses.
>>
>> The flag was added in commit fe9041c245196 ("vmalloc: lift the arm
>> flag for coherent mappings to common code") as a mechanical
>> translation of ARM's VM_ARM_DMA_CONSISTENT.
>>
>> Drop it so DMA-coherent areas can never enter the path.
>>
>> Signed-off-by: Ye Liu <liuye@xxxxxxxxxx>
>> ---
>> mm/vmalloc.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
>> index db669103dc66..a888eca016a8 100644
>> --- a/mm/vmalloc.c
>> +++ b/mm/vmalloc.c
>> @@ -4894,7 +4894,7 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
>> if (!area)
>> return -EINVAL;
>>
>> - if (!(area->flags & (VM_USERMAP | VM_DMA_COHERENT)))
>> + if (!(area->flags & VM_USERMAP))
>> return -EINVAL;
>>
>> if (check_add_overflow(size, off, &end_index) ||
>>
>> --
>> 2.43.0
>>
> I think we should really clarify why а remap_vmalloc_range_partial() should
> no longer accept VM_DMA_COHERENT mappings, because this change explicitly
> disallows a previously supported behavior.
>
> Could you please clarify why we should disallow this now?
>
Hi Uladzislau,

Thanks for the review. Sorry for not making this explicit enough.

The key point is that "previously accepted by the check" is not the same
as "previously supported behavior". No in-tree caller passes a
VM_DMA_COHERENT area to remap_vmalloc_range[_partial](); all 13 callers
use vmalloc_user()/vmalloc() areas with VM_USERMAP.

VM_DMA_COHERENT areas come from dma_alloc_coherent() internals and are
freed via vunmap()/dma_free_coherent(), so they should not enter this
remapping path at all. The flag was introduced by fe9041c245196 as a
mechanical translation of ARM's VM_ARM_DMA_CONSISTENT, not as an API
requirement.

So this change removes an unused/accidental allowance rather than a
supported behavior. I can reword the changelog to make that clearer if
you think it would help.

> Thank you!
>
> --
> Uladzislau Rezki

--
Thanks,
Ye Liu