pgalloc_64.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef _X86_64_PGALLOC_H
  2. #define _X86_64_PGALLOC_H
  3. #include <asm/pda.h>
  4. static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
  5. {
  6. set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)));
  7. }
  8. static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
  9. {
  10. set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
  11. }
  12. static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
  13. {
  14. set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
  15. }
  16. #define pmd_pgtable(pmd) pmd_page(pmd)
  17. static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
  18. {
  19. set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT)));
  20. }
  21. static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
  22. {
  23. BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
  24. free_page((unsigned long)pmd);
  25. }
  26. static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
  27. {
  28. return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
  29. }
  30. static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
  31. {
  32. return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
  33. }
  34. static inline void pud_free(struct mm_struct *mm, pud_t *pud)
  35. {
  36. BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
  37. free_page((unsigned long)pud);
  38. }
  39. /* Should really implement gc for free page table pages. This could be
  40. done with a reference count in struct page. */
  41. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  42. {
  43. BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
  44. free_page((unsigned long)pte);
  45. }
  46. static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
  47. {
  48. pgtable_page_dtor(pte);
  49. __free_page(pte);
  50. }
  51. extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte);
  52. extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
  53. extern void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud);
  54. #endif /* _X86_64_PGALLOC_H */