Getting the physical page for a kernel virtual address

1 view
Skip to first unread message

Katelyn Rowlands

unread,
May 2, 2007, 8:40:07 AM5/2/07
to kernel...@nl.linux.org
Hi,

I have a question regarding the page tables which map kernel virtual
addresses to physical pages.

Given a kernel virtual address in the range 0xC0000000 - 0xFFFFFFFF, is
it possible to walk the page tables to get the physical page
corresponding to that address? For example, I tried the following:

unsigned long addr = PAGE_OFFSET|0x00100000;

pgd = pgd_offset(&init_mm, addr);
if(pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
return NULL;

pud = pud_offset(pgd, addr);
if(pud_none(*pud) || unlikely(pud_bad(*pud)))
return NULL;

pmd = pmd_offset(pud, addr);
if(pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
return NULL;

ptep = pte_offset_map_lock(mm, pmd, addr, &ptl);
if(!ptep)
return NULL;

However, this code returns NULL instead of returning the physical page
where the start of the kernel image resides.

Am I going about this in a completely wrong way?

Thanks,

Katelyn

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to eca...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply all
Reply to author
Forward
0 new messages