RE: [rpmsg PATCH v2 1/1] rpmsg: virtio_rpmsg_bus: fix unexpected huge vmap mappings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christoph Hellwig <hch@xxxxxxxxxxxxx> Sent: 2018年12月26日 22:51
> On Wed, Dec 26, 2018 at 01:27:25PM +0100, Ard Biesheuvel wrote:
> > If there are legal uses for vmalloc_to_page() even if the region is
> > not mapped down to pages [which appears to be the case here], I'd
> > prefer to fix vmalloc_to_page() instead of adding this hack. Or
> > perhaps we need a sg_xxx helper that translates any virtual address
> > (vmalloc or otherwise) into a scatterlist entry?
> 
> What rpmsg does is completely bogus and needs to be fixed ASAP.  The
> virtual address returned from dma_alloc_coherent must not be passed to
> virt_to_page or vmalloc_to_page, but only use as a kernel virtual address.  It
> might not be backed by pages, or might create aliases that must not be used
> with VIVT caches.
> 
> rpmsg needs to either stop trying to extract pages from dma_alloc_coherent,
> or just replace its use of dma_alloc_coherent with the normal page allocator
> and the streaming DMA API.

Rpmsg is used to communicate with remote cpu like M4, the allocated memory is shared by Linux and M4 side.
In general, Linux side reserved the static memory region like per-device DMA pool as coherent memory for the RPMSG receive/transmit buffers.
For the static memory region, normal page allocator cannot match the requirement unless there have protocol to tell M4 the dynamic RPMSG receive/transmit buffers.

To stop to extract pages from dma_alloc_coherent, the rpmsg bus implementation base on virtio that already use the scatterlist mechanism for vring memory. So for virtio driver like RPMSG bus, we have to extract pages from dma_alloc_coherent.

I don't think the patch is one hack,  as we already know the physical address for the coherent memory,  just want to get pages, the interface "pfn_to_page(PHYS_PFN(x))" is very reasonable to the related pages.  

If you stick to use normal page allocator and streaming DMA API in RPMSG,  then we have to:
- add new quirk feature for virtio like the same function as "VIRTIO_F_IOMMU_PLATFORM", register the new feature for RPMSG virto driver.  Then RPMSG virtio bus driver only need to allocate the continuous pages.
- the static memory region for M4 is not supported.

Any idea ?

Regards,
Andy Duan




[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux