Re: CMA enhancement - non-default areas in x86

From: gregkh@xxxxxxxxxxxxxxxxxxx
Date: Wed May 13 2020 - 06:04:54 EST


On Wed, May 13, 2020 at 09:43:45AM +0000, Ravich, Leonid wrote:
> > On Wed, May 13, 2020 at 08:29:16AM +0000, Ravich, Leonid wrote:
> > > PCIe NTB
> > > Documentation/driver-api/ntb.rst
> >
> > > 1) Basically PCI bridge between to root complex / PCI switches
> > > 2) using out of OS memory is one solution but then this memory is
> > > Limited for usage by other stack, ex: get_user_pages on this memory
> > > will fail, Therefore attempting to use it for block layer with (o_direct) will
> > fail.
> > >
> > > Acutely any generic stack which attempts to "pin" this memory will fail.
> >
> > So why isn't the BIOS/UEFI properly reserving this from the general operating
> > system's pages so that the driver knows to use them instead?
> >
> > Is UEFI wrong here about these being valid memory ranges for general use?
> > If so, why not fix that? If not, how in the world is the OS supposed to know
> > these memory ranges are _not_ for general use? I feel like there is
> > something missing here...
> >
> Maybe I am miss understanding something here , but if BIOS/UEFI will reserve this pages
> They will be "out of kernel" which will work for propriety driver but this memory will not
> be useable for generic driver which will attempt to pin this memory with get_user_pages() .
> so we can go and try to fix that (not sure this is the right way) .

What do you mean by "propriety" driver vs. "generic" driver?

Shouldn't there be some "generic" way that UEFI tells any driver where
these memory locations are that can not be used as general memory? If
not, try fixing up UEFI for that.

> another option here is to use some kernel infrastructure which from one side reserve the memory from general use
> on the other hand kernel will be aware of this pages so get_user_pages() will work on this memory .
>
> from what we saw CMA infrastructure can support such requirements.

CMA needs to be told where to reserve the memory at boot time. If you
want to use that, great, but something has to tell it, so perhaps just
get that info from UEFI as that is the "equilivant" to a device tree,
right?

Try it all out and see, all of this is pointless without real patches,
which is why we almost never have these kinds of discussions without
working code.

thanks,

greg k-h