Results 1 to 3 of 3
#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 ...
- 05-28-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 55
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 ?
- 05-29-2008 #2Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
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.
- 05-29-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 55
Hi,
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 ?


Reply With Quote
