Re: [PATCH] mm/vmalloc: fix mischeck pfn valid in vmap_pfns
From: Bingbu Cao
Date: Tue Mar 25 2025 - 02:51:01 EST
Vivek,
On 3/25/25 2:32 PM, Kasireddy, Vivek wrote:
> Hi Huan,
>
>> Subject: Re: [PATCH] mm/vmalloc: fix mischeck pfn valid in vmap_pfns
>>
>> HI Hillf,
>>
>> Thanks fo your suggestion.
>>
>> 在 2025/3/19 19:26, Hillf Danton 写道:
>>> On Wed, 19 Mar 2025 09:08:51 +0100 Christoph Hellwig wrote:
>>>> On Wed, Mar 19, 2025 at 01:03:55PM +0800, Hillf Danton wrote:
>>>>> A quick fix is to add a vmap_pfn variant to walk around the pfn
>>>>> check in question, like the following diff (just for idea show).
>>>> No.
>>>>
>>> Patient to see your fix, given no low hanging peach left for Mr Folio
>>> in case of HVO, (feel free to ignore, who is likely about 2.6-mile
>>> less tough than you could be).
>>
>> I now believe there are two way to resolve the HVO folio can't vmap in
>> udmabuf.
>>
>> 1. simple copy vmap_pfn code, don't bother common vmap_pfn, use by itself
>> and remove pfn_valid check.
>>
>> 2. implement folio array based vmap(vmap_folios), which can given a range of
>> each folio(offset, nr_pages), so can suit HVO folio's vmap.
>>
>> 1 is simple and can fast fix this issue, but may not too good. I need discuss with
>> bot Christoph and udmabuf's maintainer.
>>
>> 2 is hard, but may worth to research, which I also will try to do. :)
> Another option is to just limit udmabuf's vmap() to only shmem folios but I guess
> it may not work as expected if THP is also enabled.
> Bingbu, what exactly is your use-case? Could you please describe the scenario that
> requires you to use udmabuf's vmap()?
I guess my case is a very simple one.
Userspace create the udmabuf and mmap:
dmabuf_fd = ioctl(udma_fd, UDMABUF_CREATE, &create);
userptr = mmap(NULL, len, PROT_READ | PROT_WRITE,
MAP_SHARED, dmafd, 0);
And driver side call dma_buf_vmap() on the dmabuf to get a virtual
address.
>
> Thanks,
> Vivek
>
>>
>
--
Best regards,
Bingbu Cao