October 2017
Intermediate to advanced
586 pages
14h 8m
English
The page_to_virt() function is used to convert the struct page (as returned by alloc_pages(), for example) into the kernel address. virt_to_page() takes a kernel virtual address and returns its associated struct page instance (as if it was allocated using the alloc_pages() function). Both virt_to_page() and page_to_virt() are defined in <asm/page.h>:
struct page *virt_to_page(void *kaddr); void *page_to_virt(struct page *pg)
The page_address() macro can be used to return the virtual address that corresponds to the beginning address (the logical address of course) of a struct page instance:
void *page_address(const struct page *page)
We can see how it is used in the get_zeroed_page() function:
unsigned long get_zeroed_page(unsigned ...