Re: virtual address to vma address

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

 



On Sun, 2007-04-15 at 14:29 +0200, Thomas Christensen wrote:
> Hi kernelnewbies,
> 
> I have allocated some pages with multiple calls to __get_free_pages(),
> and added them to a vm area with calls to vm_insert_page().
> 
> The question is: given an arbitrary kernel address contained by one of
> the pages, does Linux expose an API to translate that address to the
> userland address (vm area address)?
> 

I Dont know if there is a direct api for this....
but you can get it using the following logic (very long search :)).

get the page frame no by --> kernel address >> PAGE_SHIFT 
get the struct page using   -> mem_map + page frame no

struct page->mapping->i_mmap will give you a linked list of
vm_area_struct

now for each vma

->mm->pdg will give you the pgd base

now for each pte entry in the page table

if (pte >> page_shift == kernel_address >> page_shift) {
get virtual address for that particular pgd and pte entry(address
translation logic).
}


can someone please verify this ?


OR 
a simpler solution would be to maintain the list of user address of that
page when you call vm_insert_page :).



ps: there are macros for some of the above steps. 

--
Vivek Kutal


--
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