All of lore.kernel.org
 help / color / mirror / Atom feed
* Virtual and physical page address
@ 2016-02-07 21:24 Mohammad A Khasawneh
  2016-02-07 21:43 ` Mike Krinkin
  0 siblings, 1 reply; 4+ messages in thread
From: Mohammad A Khasawneh @ 2016-02-07 21:24 UTC (permalink / raw)
  To: kernelnewbies

Hello everyone,

I am attempting to dump the page table of a process in terms of virtual
addresses and the corresponding physical addresses. I am looking for
information whether the pointers I am using are correct for this purpose:

1. Can I say that pte_page(pte_t) returns the virtual address of the page
that the PTE points at?

2. can I say that page_to_phys(struct page) returns the physical address of
that same entry?

Thank you,
Mohammad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160207/97f36a47/attachment.html 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Virtual and physical page address
  2016-02-07 21:24 Virtual and physical page address Mohammad A Khasawneh
@ 2016-02-07 21:43 ` Mike Krinkin
  2016-02-08 13:57   ` Mohammad A Khasawneh
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Krinkin @ 2016-02-07 21:43 UTC (permalink / raw)
  To: kernelnewbies

On Sun, Feb 07, 2016 at 04:24:08PM -0500, Mohammad A Khasawneh wrote:
> Hello everyone,
> 
> I am attempting to dump the page table of a process in terms of virtual
> addresses and the corresponding physical addresses. I am looking for
> information whether the pointers I am using are correct for this purpose:
> 
> 1. Can I say that pte_page(pte_t) returns the virtual address of the page
> that the PTE points at?

pte_page returns struct page pointer (virtual address of the struct page, but
i suppose it's not the virtual address you need), it has nothing to do with a
virtual address the pte corresponds to.

> 
> 2. can I say that page_to_phys(struct page) returns the physical address of
> that same entry?

page_to_phys returns physical address the struct page corresponds to, so yes.

> 
> Thank you,
> Mohammad

> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Virtual and physical page address
  2016-02-07 21:43 ` Mike Krinkin
@ 2016-02-08 13:57   ` Mohammad A Khasawneh
  2016-02-08 14:10     ` Mike Krinkin
  0 siblings, 1 reply; 4+ messages in thread
From: Mohammad A Khasawneh @ 2016-02-08 13:57 UTC (permalink / raw)
  To: kernelnewbies

Thank you for your answer. Is there a way to get the virtual address by
traversing the pgd->pte->page hierarchy? I'm not sure I can use the
phys_to_virt() function.

Thanks,
Mohammad
On Feb 7, 2016 16:43, "Mike Krinkin" <krinkin.m.u@gmail.com> wrote:

> On Sun, Feb 07, 2016 at 04:24:08PM -0500, Mohammad A Khasawneh wrote:
> > Hello everyone,
> >
> > I am attempting to dump the page table of a process in terms of virtual
> > addresses and the corresponding physical addresses. I am looking for
> > information whether the pointers I am using are correct for this purpose:
> >
> > 1. Can I say that pte_page(pte_t) returns the virtual address of the page
> > that the PTE points at?
>
> pte_page returns struct page pointer (virtual address of the struct page,
> but
> i suppose it's not the virtual address you need), it has nothing to do
> with a
> virtual address the pte corresponds to.
>
> >
> > 2. can I say that page_to_phys(struct page) returns the physical address
> of
> > that same entry?
>
> page_to_phys returns physical address the struct page corresponds to, so
> yes.
>
> >
> > Thank you,
> > Mohammad
>
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160208/6ac720c6/attachment.html 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Virtual and physical page address
  2016-02-08 13:57   ` Mohammad A Khasawneh
@ 2016-02-08 14:10     ` Mike Krinkin
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Krinkin @ 2016-02-08 14:10 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Feb 08, 2016 at 08:57:01AM -0500, Mohammad A Khasawneh wrote:
> Thank you for your answer. Is there a way to get the virtual address by
> traversing the pgd->pte->page hierarchy?

Well, position of pte in the hierarchy defines the virtual address, so yes,
there is way. I'm not sure that a portable across different architetures way
exists though. You can look at this reference:

https://www.kernel.org/doc/gorman/html/understand/understand006.html

> I'm not sure I can use the phys_to_virt() function.

In general you can't.

> 
> Thanks,
> Mohammad
> On Feb 7, 2016 16:43, "Mike Krinkin" <krinkin.m.u@gmail.com> wrote:
> 
> > On Sun, Feb 07, 2016 at 04:24:08PM -0500, Mohammad A Khasawneh wrote:
> > > Hello everyone,
> > >
> > > I am attempting to dump the page table of a process in terms of virtual
> > > addresses and the corresponding physical addresses. I am looking for
> > > information whether the pointers I am using are correct for this purpose:
> > >
> > > 1. Can I say that pte_page(pte_t) returns the virtual address of the page
> > > that the PTE points at?
> >
> > pte_page returns struct page pointer (virtual address of the struct page,
> > but
> > i suppose it's not the virtual address you need), it has nothing to do
> > with a
> > virtual address the pte corresponds to.
> >
> > >
> > > 2. can I say that page_to_phys(struct page) returns the physical address
> > of
> > > that same entry?
> >
> > page_to_phys returns physical address the struct page corresponds to, so
> > yes.
> >
> > >
> > > Thank you,
> > > Mohammad
> >
> > > _______________________________________________
> > > Kernelnewbies mailing list
> > > Kernelnewbies at kernelnewbies.org
> > > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-08 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-07 21:24 Virtual and physical page address Mohammad A Khasawneh
2016-02-07 21:43 ` Mike Krinkin
2016-02-08 13:57   ` Mohammad A Khasawneh
2016-02-08 14:10     ` Mike Krinkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.