* how to translate virtual memory addresss into physical address ?
@ 2000-09-20 7:44 BenHanokh Gabriel
2000-09-20 9:53 ` Stephen C. Tweedie
0 siblings, 1 reply; 5+ messages in thread
From: BenHanokh Gabriel @ 2000-09-20 7:44 UTC (permalink / raw)
To: Linux-MM mailing list
hi
how do i get in a kernel module the physical address from a virtual memory
addreess ( where the virual address can be either main-memory address or mmaped
pci memory) ?
please CC me for any answer
regards
Benhanokh Gabriel
-----------------------------------------------------------------------------
"If you think C++ is not overly complicated, just what is a
protected abstract virtual base class with a pure virtual private destructor,
and when was the last time you needed one?"
-- Tom Cargil, C++ Journal, Fall 1990. --
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to translate virtual memory addresss into physical address ?
2000-09-20 7:44 how to translate virtual memory addresss into physical address ? BenHanokh Gabriel
@ 2000-09-20 9:53 ` Stephen C. Tweedie
2000-09-20 10:26 ` BenHanokh Gabriel
0 siblings, 1 reply; 5+ messages in thread
From: Stephen C. Tweedie @ 2000-09-20 9:53 UTC (permalink / raw)
To: BenHanokh Gabriel; +Cc: Linux-MM mailing list
Hi,
On Wed, Sep 20, 2000 at 10:44:54AM +0300, BenHanokh Gabriel wrote:
>
> how do i get in a kernel module the physical address from a virtual memory
> addreess ( where the virual address can be either main-memory address or mmaped
> pci memory) ?
When you say "main memory", do you mean user space virtual addresses
or just kernel space?
For kernel-space main memory, you just use virt_to_phys().
For pci memory, you usually don't do anything --- you *start* with the
physical address and work from there, creating a virtual address with
ioremap(). You can do the translation backwards, but only by walking
page tables.
You might want to use map_user_kiobuf() for user-space addresses if
you are running on 2.4 (or 2.2 with the raw IO patches). I've got
diffs for a map_kernel_kiobuf() too, for 2.4 only. Those will also
deal properly with things like locking user pages in memory and
dealing with high memory on Intel boxes.
Cheers,
Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to translate virtual memory addresss into physical address ?
2000-09-20 9:53 ` Stephen C. Tweedie
@ 2000-09-20 10:26 ` BenHanokh Gabriel
2000-09-20 11:20 ` Stephen C. Tweedie
0 siblings, 1 reply; 5+ messages in thread
From: BenHanokh Gabriel @ 2000-09-20 10:26 UTC (permalink / raw)
To: Stephen C. Tweedie; +Cc: Linux-MM mailing list
Stephen C. Tweedie wrote:
> Hi,
>
> On Wed, Sep 20, 2000 at 10:44:54AM +0300, BenHanokh Gabriel wrote:
> >
> > how do i get in a kernel module the physical address from a virtual memory
> > addreess ( where the virual address can be either main-memory address or mmaped
> > pci memory) ?
>
> When you say "main memory", do you mean user space virtual addresses
> or just kernel space?
>
my module will have to deal with user space virtual addresses which are mapped
either to the computer "main-memory" or to a pci-device memory.
> For pci memory, you usually don't do anything --- you *start* with the
> physical address and work from there, creating a virtual address with
> ioremap().
this is only possible when my module is the pci-device driver, which is not the
case here
> You can do the translation backwards, but only by walking
> page tables.
how do i do this ? i tought that pci-memory is not pageable
>
> You might want to use map_user_kiobuf() for user-space addresses if
> you are running on 2.4 (or 2.2 with the raw IO patches). I've got
> diffs for a map_kernel_kiobuf() too, for 2.4 only. Those will also
> deal properly with things like locking user pages in memory and
> dealing with high memory on Intel boxes.
will the map_user_kiobuf handle pci-device memory correctly (AFAIK locking pci
memory is meaningless and that its memory is not split into pages ) ?
regards
Benhanokh Gabriel
-----------------------------------------------------------------------------
"If you think C++ is not overly complicated, just what is a
protected abstract virtual base class with a pure virtual private destructor,
and when was the last time you needed one?"
-- Tom Cargil, C++ Journal, Fall 1990. --
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to translate virtual memory addresss into physical address ?
2000-09-20 10:26 ` BenHanokh Gabriel
@ 2000-09-20 11:20 ` Stephen C. Tweedie
2000-09-20 12:16 ` BenHanokh Gabriel
0 siblings, 1 reply; 5+ messages in thread
From: Stephen C. Tweedie @ 2000-09-20 11:20 UTC (permalink / raw)
To: BenHanokh Gabriel; +Cc: Stephen C. Tweedie, Linux-MM mailing list
Hi,
On Wed, Sep 20, 2000 at 01:26:04PM +0300, BenHanokh Gabriel wrote:
> my module will have to deal with user space virtual addresses which are mapped
> either to the computer "main-memory" or to a pci-device memory.
User space virtual addresses aren't necessarily mapped anywhere. They
can be swapped out, or for mmap they might not yet be faulted in at
all. You have to deal with all the complications of faulting the page
and pinning it in memory if you want to deal with user virtual
addresses. I'd definitely use map_user_kiobuf for this, but that
cannot yet deal with pci device memory.
> > You can do the translation backwards, but only by walking
> > page tables.
> how do i do this ? i tought that pci-memory is not pageable
It's not pageable, but the virtual-to-physical address translation
still uses page tables. "Non-pageable" just means that the page table
entries cannot get paged out, not that they don't exist.
> will the map_user_kiobuf handle pci-device memory correctly (AFAIK locking pci
> memory is meaningless and that its memory is not split into pages ) ?
Not yet, no. It can (and does) on the 2.2 version, but 2.4 encodes
the kiobuf pages as "struct page *" pointers and we need to teach it
how to generate such structs for dynamically-allocated memory regions
such as PCI.
Cheers,
Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to translate virtual memory addresss into physical address ?
2000-09-20 11:20 ` Stephen C. Tweedie
@ 2000-09-20 12:16 ` BenHanokh Gabriel
0 siblings, 0 replies; 5+ messages in thread
From: BenHanokh Gabriel @ 2000-09-20 12:16 UTC (permalink / raw)
To: Stephen C. Tweedie; +Cc: Linux-MM mailing list
Stephen C. Tweedie wrote:
>
> User space virtual addresses aren't necessarily mapped anywhere. They
> can be swapped out, or for mmap they might not yet be faulted in at
> all. You have to deal with all the complications of faulting the page
> and pinning it in memory if you want to deal with user virtual
> addresses. I'd definitely use map_user_kiobuf for this, but that
> cannot yet deal with pci device memory.
how can i tell given a user-space virtual address, if that address is a "normal"
main-memory address( which i can pass to map_user_kiobuf ) or that it is a pci
mmaped address( which i have to deal with it myself ) ?
> > > You can do the translation backwards, but only by walking
> > > page tables.
> > how do i do this ? i tought that pci-memory is not pageable
>
> It's not pageable, but the virtual-to-physical address translation
> still uses page tables.
can you explain please with more details how to translate from virtual
user-space pci mmaped address to a physical address?
>"Non-pageable" just means that the page table
> entries cannot get paged out, not that they don't exist.
does the kernel have a page emulation for pci-memory ?
>> will the map_user_kiobuf handle pci-device memory correctly (AFAIK locking pci
>> memory is meaningless and that its memory is not split into pages ) ?
> Not yet, no. It can (and does) on the 2.2 version, but 2.4 encodes
>the kiobuf pages as "struct page *" pointers and we need to teach it
>how to generate such structs for dynamically-allocated memory regions
>such as PCI.
when do you think we are going to see implemenation of the map_user_kiobuf supporting pci-memory ?
will this be done for kernel 2.4 or only for the 2.5
regards
Benhanokh Gabriel
-----------------------------------------------------------------------------
"If you think C++ is not overly complicated, just what is a
protected abstract virtual base class with a pure virtual private destructor,
and when was the last time you needed one?"
-- Tom Cargil, C++ Journal, Fall 1990. --
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-09-20 12:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-20 7:44 how to translate virtual memory addresss into physical address ? BenHanokh Gabriel
2000-09-20 9:53 ` Stephen C. Tweedie
2000-09-20 10:26 ` BenHanokh Gabriel
2000-09-20 11:20 ` Stephen C. Tweedie
2000-09-20 12:16 ` BenHanokh Gabriel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox