Mailing List Archive

User mode Virt -> Phys
Hi All,
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)?
Thanks,
Terry Murphy
-
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/
Re: User mode Virt -> Phys [ In reply to ]
> 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.
Alan
-
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/
Re: User mode Virt -> Phys [ In reply to ]
On Mon, Jan 11, 1999 at 12:18:57PM -0800, Terence Murphy 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 -- I don't think there presently is.
I think Richard Gooch posted a patch so that this could be done ages
ago (via ioctl or something).
Userland doesn't (or shouldn't) need to know physical addresses
normally -- can you explain why you might need this?
(I'm not saying you don't, I've tested drivers from userland before,
so its conceivable there are uses for this)
-cw
-
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/
Re: User mode Virt -> Phys [ In reply to ]
On Tue, Jan 12, 1999 at 12:54:45AM +0000, Alan Cox 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.
Wouldn't that just be a mmap() of /dev/mem ?
Philipp Rumpf
-
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/
Re: User mode Virt -> Phys [ In reply to ]
On Tue, Jan 12, 1999 at 12:54:45AM +0000, Alan Cox 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.
-- Jamie
-
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/
Re: User mode Virt -> Phys [ In reply to ]
On Tue, 12 Jan 1999, Chris Wedgwood wrote:
> On Mon, Jan 11, 1999 at 12:18:57PM -0800, Terence Murphy 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 -- I don't think there presently is.
>
> I think Richard Gooch posted a patch so that this could be done ages
> ago (via ioctl or something).
Any idea on where I can find it? This sounds like it would be very
useful.
> Userland doesn't (or shouldn't) need to know physical addresses
> normally -- can you explain why you might need this?
Mainly because I want to set up cache types for different memory objects
in memory. I want a certain region to be WB, some to be WC, some to be
USWC, etc. To set the cache types (with MTRR's), I need the physical
address. (Note: this is for a highly specialized testing tool, not a
regular application).
-- Terry
-
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/
Re: User mode Virt -> Phys [ In reply to ]
> On Tue, Jan 12, 1999 at 12:54:45AM +0000, Alan Cox 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.
You still don't need to do that translation for user space. Have a look
at Stephen Tweedie <sct@redhat.com>'s raw-io patches and DMA hooks in
kernel space for handling this stuff
Alan
-
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/
Re: User mode Virt -> Phys [ In reply to ]
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.
--
Mike A. Harris - Computer Consultant - Linux advocate
Linux software galore: http://freshmeat.net
-
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/
RE: User mode Virt -> Phys [ In reply to ]
> 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/
Re: User mode Virt -> Phys [ In reply to ]
On Wed, Jan 13, 1999 at 03:56:21AM -0500, Mike A. Harris wrote:
> 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.
We'd happily use MSDOS if it provided all the services Linux provides...
Like being able to run Linux applications at the same time as the ring 0
stuff, for example. Linux is much more than a mere protection mechanism.
Actually, we do have a specialist network & data processing application
that is far too slow when the network I/O is partitioned between kernel
and user space. At the same time, we use Linux itself to provide a good
ddevelopment/management environment.
Hard to believe, I know, but even handling interrupts is _way_ too slow
(latency) - so we are building special hardware to modify user space
thread scheduling lists directly through bus mastering DMA.
My userdma driver is that, a device driver. So it is not a general
kernel thing and security for normal users will not be compromised.
-- Jamie
-
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/
Re: User mode Virt -> Phys [ In reply to ]
On Tue, Jan 12, 1999 at 05:23:21PM +0000, Alan Cox wrote:
> You still don't need to do that translation for user space. Have a look
> at Stephen Tweedie <sct@redhat.com>'s raw-io patches and DMA hooks in
> kernel space for handling this stuff
Yes, that sounds interesting and I will look at it as soon as I can.
Though I suspect the I/O setup for page locking/unlocking/translation
will be too slow if it has to be done for each read/write operation.
My approach is for when you want to set these things up in advance, then
use them repeatedly.
-- Jamie
-
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/
Re: User mode Virt -> Phys [ In reply to ]
> Yes, that sounds interesting and I will look at it as soon as I can.
> Though I suspect the I/O setup for page locking/unlocking/translation
> will be too slow if it has to be done for each read/write operation.
>
> My approach is for when you want to set these things up in advance, then
> use them repeatedly.
You can do that too - obviously you have questions about tying a lot
of memory down, but thats policy not code
Alan
-
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/
Re: User mode Virt -> Phys [ In reply to ]
> 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).
Beg to differ, and differ big time.
You want to avoid the kernel for _Latency_ reasons. Bandwidth isnt the
issue since a syscall doing DMA to user space is the sme data copy rate.
Its when you get tons of small messages you want user mode hooks - things
like U-Net.
> 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.
You are priming the cache. I can well believe it. In networking I saw
bizzare artifacts like that - like where a 1500 byte packet copy into
an sk_buff if you avoided it and went direct to user space was no
different in cost.
Alan
-
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/
Re: User mode Virt -> Phys [ In reply to ]
> You want to avoid the kernel for _Latency_ reasons. Bandwidth isnt the
> issue since a syscall doing DMA to user space is the sme data copy rate.
Yes indeed, latency latency latency.
Now if someone could actually make handling interrupts _fast_, that'd be
great. Meanwhile...
-- Jamie
-
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/