Getting the physical page for a kernel virtual address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux