* pte_page
@ 2001-05-30 8:01 mdaljeet
2001-05-30 12:26 ` pte_page Brian Gerst
2001-05-30 14:09 ` pte_page Ingo Molnar
0 siblings, 2 replies; 7+ messages in thread
From: mdaljeet @ 2001-05-30 8:01 UTC (permalink / raw)
To: linux-kernel
I use the 'pgt_offset', 'pmd_offset', 'pte_offset' and 'pte_page' inside a
module to get the physical address of a user space virtual address. The
physical address returned by 'pte_page' is not page aligned whereas the
virtual address was page aligned. Can somebody tell me the reason?
Also, can i use these functions to get the physical address of a kernel
virtual address using init_mm?
regards,
Daljeet.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pte_page
2001-05-30 8:01 pte_page mdaljeet
@ 2001-05-30 12:26 ` Brian Gerst
2001-05-30 12:38 ` pte_page Brian Gerst
2001-05-30 14:09 ` pte_page Ingo Molnar
1 sibling, 1 reply; 7+ messages in thread
From: Brian Gerst @ 2001-05-30 12:26 UTC (permalink / raw)
To: mdaljeet; +Cc: linux-kernel
mdaljeet@in.ibm.com wrote:
>
> I use the 'pgt_offset', 'pmd_offset', 'pte_offset' and 'pte_page' inside a
> module to get the physical address of a user space virtual address. The
> physical address returned by 'pte_page' is not page aligned whereas the
> virtual address was page aligned. Can somebody tell me the reason?
>
> Also, can i use these functions to get the physical address of a kernel
> virtual address using init_mm?
pte_page() returns the struct page * for the page, not the page
address. To get the physical address of a page use __pa(virtaddr), but
this works if and only if the page is not highmem and not vmalloced.
--
Brian Gerst
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pte_page
2001-05-30 12:26 ` pte_page Brian Gerst
@ 2001-05-30 12:38 ` Brian Gerst
0 siblings, 0 replies; 7+ messages in thread
From: Brian Gerst @ 2001-05-30 12:38 UTC (permalink / raw)
To: mdaljeet, linux-kernel
Brian Gerst wrote:
>
> mdaljeet@in.ibm.com wrote:
> >
> > I use the 'pgt_offset', 'pmd_offset', 'pte_offset' and 'pte_page' inside a
> > module to get the physical address of a user space virtual address. The
> > physical address returned by 'pte_page' is not page aligned whereas the
> > virtual address was page aligned. Can somebody tell me the reason?
> >
> > Also, can i use these functions to get the physical address of a kernel
> > virtual address using init_mm?
>
> pte_page() returns the struct page * for the page, not the page
> address. To get the physical address of a page use __pa(virtaddr), but
> this works if and only if the page is not highmem and not vmalloced.
Oops, I forgot that you said user page... __pa() only works for kernel
addresses. I don't see any other macros that can help you. Maybe one
of the VM gurus can add something here?
--
Brian Gerst
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pte_page
2001-05-30 8:01 pte_page mdaljeet
2001-05-30 12:26 ` pte_page Brian Gerst
@ 2001-05-30 14:09 ` Ingo Molnar
2001-05-30 17:08 ` pte_page Pete Wyckoff
1 sibling, 1 reply; 7+ messages in thread
From: Ingo Molnar @ 2001-05-30 14:09 UTC (permalink / raw)
To: mdaljeet; +Cc: linux-kernel
On Wed, 30 May 2001 mdaljeet@in.ibm.com wrote:
> I use the 'pgt_offset', 'pmd_offset', 'pte_offset' and 'pte_page'
> inside a module to get the physical address of a user space virtual
> address. The physical address returned by 'pte_page' is not page
> aligned whereas the virtual address was page aligned. Can somebody
> tell me the reason?
__pa(page_address(pte_page(pte))) is the address you want. [or
pte_val(*pte) & (PAGE_SIZE-1) on x86 but this is platform-dependent.]
> Also, can i use these functions to get the physical address of a
> kernel virtual address using init_mm?
nope. Eg. on x86 these functions only walk normal 4K page pagetables, they
do not walk 4MB pages correctly. (which are set up on pentiums and better
CPUs, unless mem=nopentium is specified.)
a kernel virtual address can be decoded by simply doing __pa(kaddr). If
the page is a highmem page [and you have the struct page pointer] then you
can do [(page-mem_map) << PAGE_SHIFT] to get the physical address, but
only on systems where mem_map[] starts at physical address 0.
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pte_page
2001-05-30 14:09 ` pte_page Ingo Molnar
@ 2001-05-30 17:08 ` Pete Wyckoff
2001-05-30 17:39 ` pte_page Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: Pete Wyckoff @ 2001-05-30 17:08 UTC (permalink / raw)
To: Ingo Molnar; +Cc: mdaljeet, linux-kernel
mingo@elte.hu said:
> On Wed, 30 May 2001 mdaljeet@in.ibm.com wrote:
> > I use the 'pgt_offset', 'pmd_offset', 'pte_offset' and 'pte_page'
> > inside a module to get the physical address of a user space virtual
> > address. The physical address returned by 'pte_page' is not page
> > aligned whereas the virtual address was page aligned. Can somebody
> > tell me the reason?
>
> __pa(page_address(pte_page(pte))) is the address you want. [or
> pte_val(*pte) & (PAGE_SIZE-1) on x86 but this is platform-dependent.]
Does this work on x86 non-kmapped highmem user pages too? (i.e. is
page->virtual valid for every potential user page.)
-- Pete
> > Also, can i use these functions to get the physical address of a
> > kernel virtual address using init_mm?
>
> nope. Eg. on x86 these functions only walk normal 4K page pagetables, they
> do not walk 4MB pages correctly. (which are set up on pentiums and better
> CPUs, unless mem=nopentium is specified.)
>
> a kernel virtual address can be decoded by simply doing __pa(kaddr). If
> the page is a highmem page [and you have the struct page pointer] then you
> can do [(page-mem_map) << PAGE_SHIFT] to get the physical address, but
> only on systems where mem_map[] starts at physical address 0.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pte_page
2001-05-30 17:08 ` pte_page Pete Wyckoff
@ 2001-05-30 17:39 ` Ingo Molnar
0 siblings, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2001-05-30 17:39 UTC (permalink / raw)
To: Pete Wyckoff; +Cc: mdaljeet, linux-kernel
On Wed, 30 May 2001, Pete Wyckoff wrote:
> > __pa(page_address(pte_page(pte))) is the address you want. [or
> > pte_val(*pte) & (PAGE_SIZE-1) on x86 but this is platform-dependent.]
>
> Does this work on x86 non-kmapped highmem user pages too? (i.e. is
> page->virtual valid for every potential user page.)
you are right, the highmem-compatible solution is to use page-mem_map as
the physical page index.
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pte_page
@ 2001-05-31 9:57 mdaljeet
0 siblings, 0 replies; 7+ messages in thread
From: mdaljeet @ 2001-05-31 9:57 UTC (permalink / raw)
To: mingo; +Cc: linux-kernel, Pete Wyckoff
I am doing a DMA from a card to system memory. The system memory "physical
address" is '0x104000'. I am doing this on x86 with kernel version 2.4.2.
Can this address be the address of a user space buffer?
Regards,
Daljeet.
|--------+----------------------->
| | Ingo Molnar |
| | <mingo@elte.h|
| | u> |
| | |
| | 05/30/01 |
| | 11:09 PM |
| | Please |
| | respond to |
| | mingo |
| | |
|--------+----------------------->
>--------------------------------------------------------|
| |
| To: Pete Wyckoff <pw@osc.edu> |
| cc: Daljeet Maini/India/IBM@IBMIN, |
| linux-kernel@vger.kernel.org |
| Subject: Re: pte_page |
>--------------------------------------------------------|
On Wed, 30 May 2001, Pete Wyckoff wrote:
> > __pa(page_address(pte_page(pte))) is the address you want. [or
> > pte_val(*pte) & (PAGE_SIZE-1) on x86 but this is platform-dependent.]
>
> Does this work on x86 non-kmapped highmem user pages too? (i.e. is
> page->virtual valid for every potential user page.)
you are right, the highmem-compatible solution is to use page-mem_map as
the physical page index.
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-05-31 10:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-30 8:01 pte_page mdaljeet
2001-05-30 12:26 ` pte_page Brian Gerst
2001-05-30 12:38 ` pte_page Brian Gerst
2001-05-30 14:09 ` pte_page Ingo Molnar
2001-05-30 17:08 ` pte_page Pete Wyckoff
2001-05-30 17:39 ` pte_page Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2001-05-31 9:57 pte_page mdaljeet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox