Re: [PATCH 1/2] habanalabs: support vmalloc memory mapping

From: Christoph Hellwig
Date: Fri Oct 11 2019 - 04:11:01 EST


On Thu, Oct 10, 2019 at 07:54:07PM +0000, Omer Shpigelman wrote:
> The is_vmalloc_addr checks are for user pointers and for memory which was allocated by the driver with vmalloc_user.

This does not make any sense whatsoever. vmalloc_user returns a kernel
address, it just does a GFP_USER instead of GFP_KERNEL allocation, which
is just accounting differences.

> > > Mapping vmalloc memory is needed for Gaudi ASIC.
> >
> > How does that ASIC pass in the vmalloc memory? I don't fully understand
> > the code, but it seems like the addresses are fed from ioctl, which means
> > they only come from userspace.
>
> The user pointers are indeed fed from ioctl for DMA purpose, but as I wrote above the vmalloc memory is allocated by the driver with vmalloc_user which will be mmapped later on in order to create a shared buffer between the driver and the userspace process.

Again, you can't pass pointers obtained from vmalloc* to userspace. You
can map the underlying pages into user pagetables, but is_vmalloc_addr
won't know that. I think you guys need to read up on virtual memory 101
first and then come back and actually explain what you are trying to do.