diff options
-rw-r--r-- | include/linux/mm.h | 6 | ||||
-rw-r--r-- | mm/memory.c | 40 | ||||
-rw-r--r-- | mm/vmalloc.c | 38 |
3 files changed, 42 insertions, 42 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 1bba6789a50a..1961056b1af7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -231,6 +231,10 @@ static inline int get_page_unless_zero(struct page *page) | |||
231 | return atomic_inc_not_zero(&page->_count); | 231 | return atomic_inc_not_zero(&page->_count); |
232 | } | 232 | } |
233 | 233 | ||
234 | /* Support for virtually mapped pages */ | ||
235 | struct page *vmalloc_to_page(void *addr); | ||
236 | unsigned long vmalloc_to_pfn(void *addr); | ||
237 | |||
234 | static inline struct page *compound_head(struct page *page) | 238 | static inline struct page *compound_head(struct page *page) |
235 | { | 239 | { |
236 | if (unlikely(PageTail(page))) | 240 | if (unlikely(PageTail(page))) |
@@ -1089,8 +1093,6 @@ static inline unsigned long vma_pages(struct vm_area_struct *vma) | |||
1089 | 1093 | ||
1090 | pgprot_t vm_get_page_prot(unsigned long vm_flags); | 1094 | pgprot_t vm_get_page_prot(unsigned long vm_flags); |
1091 | struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); | 1095 | struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); |
1092 | struct page *vmalloc_to_page(void *addr); | ||
1093 | unsigned long vmalloc_to_pfn(void *addr); | ||
1094 | int remap_pfn_range(struct vm_area_struct *, unsigned long addr, | 1096 | int remap_pfn_range(struct vm_area_struct *, unsigned long addr, |
1095 | unsigned long pfn, unsigned long size, pgprot_t); | 1097 | unsigned long pfn, unsigned long size, pgprot_t); |
1096 | int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); | 1098 | int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); |
diff --git a/mm/memory.c b/mm/memory.c index d902d0e25edc..1b8ca160f1d0 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2618,46 +2618,6 @@ int make_pages_present(unsigned long addr, unsigned long end) | |||
2618 | return ret == len ? 0 : -1; | 2618 | return ret == len ? 0 : -1; |
2619 | } | 2619 | } |
2620 | 2620 | ||
2621 | /* | ||
2622 | * Map a vmalloc()-space virtual address to the physical page. | ||
2623 | */ | ||
2624 | struct page * vmalloc_to_page(void * vmalloc_addr) | ||
2625 | { | ||
2626 | unsigned long addr = (unsigned long) vmalloc_addr; | ||
2627 | struct page *page = NULL; | ||
2628 | pgd_t *pgd = pgd_offset_k(addr); | ||
2629 | pud_t *pud; | ||
2630 | pmd_t *pmd; | ||
2631 | pte_t *ptep, pte; | ||
2632 | |||
2633 | if (!pgd_none(*pgd)) { | ||
2634 | pud = pud_offset(pgd, addr); | ||
2635 | if (!pud_none(*pud)) { | ||
2636 | pmd = pmd_offset(pud, addr); | ||
2637 | if (!pmd_none(*pmd)) { | ||
2638 | ptep = pte_offset_map(pmd, addr); | ||
2639 | pte = *ptep; | ||
2640 | if (pte_present(pte)) | ||
2641 | page = pte_page(pte); | ||
2642 | pte_unmap(ptep); | ||
2643 | } | ||
2644 | } | ||
2645 | } | ||
2646 | return page; | ||
2647 | } | ||
2648 | |||
2649 | EXPORT_SYMBOL(vmalloc_to_page); | ||
2650 | |||
2651 | /* | ||
2652 | * Map a vmalloc()-space virtual address to the physical page frame number. | ||
2653 | */ | ||
2654 | unsigned long vmalloc_to_pfn(void * vmalloc_addr) | ||
2655 | { | ||
2656 | return page_to_pfn(vmalloc_to_page(vmalloc_addr)); | ||
2657 | } | ||
2658 | |||
2659 | EXPORT_SYMBOL(vmalloc_to_pfn); | ||
2660 | |||
2661 | #if !defined(__HAVE_ARCH_GATE_AREA) | 2621 | #if !defined(__HAVE_ARCH_GATE_AREA) |
2662 | 2622 | ||
2663 | #if defined(AT_SYSINFO_EHDR) | 2623 | #if defined(AT_SYSINFO_EHDR) |
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index af77e171e339..e4c59a30835b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c | |||
@@ -166,6 +166,44 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages) | |||
166 | } | 166 | } |
167 | EXPORT_SYMBOL_GPL(map_vm_area); | 167 | EXPORT_SYMBOL_GPL(map_vm_area); |
168 | 168 | ||
169 | /* | ||
170 | * Map a vmalloc()-space virtual address to the physical page. | ||
171 | */ | ||
172 | struct page *vmalloc_to_page(void *vmalloc_addr) | ||
173 | { | ||
174 | unsigned long addr = (unsigned long) vmalloc_addr; | ||
175 | struct page *page = NULL; | ||
176 | pgd_t *pgd = pgd_offset_k(addr); | ||
177 | pud_t *pud; | ||
178 | pmd_t *pmd; | ||
179 | pte_t *ptep, pte; | ||
180 | |||
181 | if (!pgd_none(*pgd)) { | ||
182 | pud = pud_offset(pgd, addr); | ||
183 | if (!pud_none(*pud)) { | ||
184 | pmd = pmd_offset(pud, addr); | ||
185 | if (!pmd_none(*pmd)) { | ||
186 | ptep = pte_offset_map(pmd, addr); | ||
187 | pte = *ptep; | ||
188 | if (pte_present(pte)) | ||
189 | page = pte_page(pte); | ||
190 | pte_unmap(ptep); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | return page; | ||
195 | } | ||
196 | EXPORT_SYMBOL(vmalloc_to_page); | ||
197 | |||
198 | /* | ||
199 | * Map a vmalloc()-space virtual address to the physical page frame number. | ||
200 | */ | ||
201 | unsigned long vmalloc_to_pfn(void *vmalloc_addr) | ||
202 | { | ||
203 | return page_to_pfn(vmalloc_to_page(vmalloc_addr)); | ||
204 | } | ||
205 | EXPORT_SYMBOL(vmalloc_to_pfn); | ||
206 | |||
169 | static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags, | 207 | static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags, |
170 | unsigned long start, unsigned long end, | 208 | unsigned long start, unsigned long end, |
171 | int node, gfp_t gfp_mask) | 209 | int node, gfp_t gfp_mask) |