Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    mapping struct pages to physical address

    #define virt_to_page(kaddr) (mem_map + (__pa(KADDR) >> PAGE_SHIFT))
    1) why do we need it at te first point ?
    2) why does it only talk bout kernel virtual addresses, what about processes virtual addresses ?
    how processe's virtual addresses can have access to "struct pages" using mem_map array ?

  2. #2
    Linux Newbie
    Join Date
    Mar 2008
    1. It is used to convert from kernel logical addresses to Physical struct page pointer.

    There is a one to one mapping for kernel logical address and physical address. So what this macro does is
    __pa(kaddr) returns the physical address of the kaddr,
    then __pa(kaddr) >> PAGE_SHIFT shifts the physical address by PAGE_SHIFT bits to get the physical PAGE FRAME NUMBER
    mem_map stores struct pages for whole physical memory in the system, as it is an array so
    mem_map + (__pa(kaddr) >> PAGE_SHIFT)
    gives the correct struct page pointer corresponding to the PAGE FRAME NUMBER.

    Your second question is too confusing clearify a little more.

  3. #3
    what you told about mem_map array storing of styruct pages is understood.
    but I would like to ask questions little further.

    1) how does user's virtual address can have access to struct pages ?
    2) if mem_mao is storing entire map if the physical memory then only kernel virtual addresses use it.. how does user space address use it ?

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts