Kernel virtual addr to Physical page number.

From: Raj, Ashok (ashok.raj@intel.com)
Date: Thu Feb 10 2000 - 11:21:45 EST


Hello.

Iam trying to see if there is a common method i can obtain physical page
numbers for memory allocated by kmem_alloc,
__get_free_pages() and vmalloc().

vmalloc() seems to follow the same method i use to lock and obtain physical
page numbers for user space addr. This is what i do.

        pgd = pgd_offset(current->mm, addr);
            pmd = pmd_offset(pgd, addr);
            pte = pte_offset(pmd, addr);
            phys_addr = pte_page(*pte);
            phys_page_num = MAP_NR(phys_addr);

for kernel allocated memory, especially if its from kmem_alloc or
__get_free_pages, iam not able to use the above method. I need to use
__pa(addr)/PAGE_SIZE. Unfortunately if this is from a vmalloc, then
__pa(addr)/PAGE_SIZE does work.

1. Can someone suggest a common method to do this for all addr? both user
and kernel.

2. if not is there a method to distinguish if this is user, or kernel addr?
i thought i can use the PAGE_OFFSET
   present in the addr.

3. if 1 and 2 is not possible, then in kernel allocated addr, can we have
some way to find if this is vmalloc() or
the other s(kmem_alloc, or get_free_pages variety)?

thanks
ashokr

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:17 EST