RE: User mode Virt -> Phys

Kai Harrekilde-Petersen (KHP@olicom.dk)
Wed, 13 Jan 1999 10:19:54 +0100


> From: Mike A. Harris [mailto:mharris@ican.net]
> Sent: 13. januar 1999 09:56
> To: Jamie Lokier
> Cc: Alan Cox; linux-kernel@vger.rutgers.edu; Terence Murphy
> Subject: Re: User mode Virt -> Phys
>
> On Tue, 12 Jan 1999, Jamie Lokier wrote:
>
> >> > The linux kernel is full of calls to virt_to_phys. This
> function seems
> >> > only to work in kernel mode. Is there a way to convert a
> physical address
> >> > to a virtual address in user mode (from a regular program)?
> >>
> >> No. Nor should there ever need to be.
> >
> >Yes, for user level I/O stuff doing PCI DMA. Not normal
> applications by
> >any means, and you'd better know what you're doing.
> >
> >I have code which implements this quite cleanly (as this
> sort of thing
> >goes), but I haven't released it yet and won't until I am ready.
>
> Gee. DMA from userland? Might as well have userland run in ring
> 0 then... unless this is a special case, and not a general
> kernel option suggestion. If someone is going to compromize
> their system like that, they might as well use MSDOS IMHO.

Userlevel DMA is the only way to go as the IO devices increase the
bandwidth (say, Clustering, Gigabit Ethernet, System Area networking),
and you want to keep the overheads down (ie: avoid going into the
kernel every so often).

The idea is to have the user process register the dma areas it needs
in the kernel (in a table that the dma engine has a pointer to)
and then have the peripheral do a check (in hard/firmware) that the
actual dma block it got is 'within bounds'.

On a PCI-SCI clustering adapter I used to work on in a previous (work)
life, you needed to have ~1-2Kbyte DMA blocks before the DMA engine
was worth using; otherwise just moving the data with the CPU was far
superior.

Regards,

Kai

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/