pgtable-64.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1999, 2000 by Silicon Graphics
  7. * Copyright (C) 2003 by Ralf Baechle
  8. */
  9. #include <linux/init.h>
  10. #include <linux/mm.h>
  11. #include <asm/fixmap.h>
  12. #include <asm/pgtable.h>
  13. #include <asm/pgalloc.h>
  14. #include <asm/tlbflush.h>
  15. void pgd_init(unsigned long page)
  16. {
  17. unsigned long *p, *end;
  18. unsigned long entry;
  19. #ifdef __PAGETABLE_PMD_FOLDED
  20. entry = (unsigned long)invalid_pte_table;
  21. #else
  22. entry = (unsigned long)invalid_pmd_table;
  23. #endif
  24. p = (unsigned long *) page;
  25. end = p + PTRS_PER_PGD;
  26. do {
  27. p[0] = entry;
  28. p[1] = entry;
  29. p[2] = entry;
  30. p[3] = entry;
  31. p[4] = entry;
  32. p += 8;
  33. p[-3] = entry;
  34. p[-2] = entry;
  35. p[-1] = entry;
  36. } while (p != end);
  37. }
  38. #ifndef __PAGETABLE_PMD_FOLDED
  39. void pmd_init(unsigned long addr, unsigned long pagetable)
  40. {
  41. unsigned long *p, *end;
  42. p = (unsigned long *) addr;
  43. end = p + PTRS_PER_PMD;
  44. do {
  45. p[0] = pagetable;
  46. p[1] = pagetable;
  47. p[2] = pagetable;
  48. p[3] = pagetable;
  49. p[4] = pagetable;
  50. p += 8;
  51. p[-3] = pagetable;
  52. p[-2] = pagetable;
  53. p[-1] = pagetable;
  54. } while (p != end);
  55. }
  56. #endif
  57. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  58. void pmdp_splitting_flush(struct vm_area_struct *vma,
  59. unsigned long address,
  60. pmd_t *pmdp)
  61. {
  62. if (!pmd_trans_splitting(*pmdp)) {
  63. pmd_t pmd = pmd_mksplitting(*pmdp);
  64. set_pmd_at(vma->vm_mm, address, pmdp, pmd);
  65. }
  66. }
  67. #endif
  68. pmd_t mk_pmd(struct page *page, pgprot_t prot)
  69. {
  70. pmd_t pmd;
  71. pmd_val(pmd) = (page_to_pfn(page) << _PFN_SHIFT) | pgprot_val(prot);
  72. return pmd;
  73. }
  74. void set_pmd_at(struct mm_struct *mm, unsigned long addr,
  75. pmd_t *pmdp, pmd_t pmd)
  76. {
  77. *pmdp = pmd;
  78. flush_tlb_all();
  79. }
  80. void __init pagetable_init(void)
  81. {
  82. unsigned long vaddr;
  83. pgd_t *pgd_base;
  84. /* Initialize the entire pgd. */
  85. pgd_init((unsigned long)swapper_pg_dir);
  86. #ifndef __PAGETABLE_PMD_FOLDED
  87. pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
  88. #endif
  89. pgd_base = swapper_pg_dir;
  90. /*
  91. * Fixed mappings:
  92. */
  93. vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
  94. fixrange_init(vaddr, vaddr + FIXADDR_SIZE, pgd_base);
  95. }