hugetlbpage.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * arch/sh/mm/hugetlbpage.c
  3. *
  4. * SuperH HugeTLB page support.
  5. *
  6. * Cloned from sparc64 by Paul Mundt.
  7. *
  8. * Copyright (C) 2002, 2003 David S. Miller (davem@redhat.com)
  9. */
  10. #include <linux/config.h>
  11. #include <linux/init.h>
  12. #include <linux/fs.h>
  13. #include <linux/mm.h>
  14. #include <linux/hugetlb.h>
  15. #include <linux/pagemap.h>
  16. #include <linux/smp_lock.h>
  17. #include <linux/slab.h>
  18. #include <linux/sysctl.h>
  19. #include <asm/mman.h>
  20. #include <asm/pgalloc.h>
  21. #include <asm/tlb.h>
  22. #include <asm/tlbflush.h>
  23. #include <asm/cacheflush.h>
  24. pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
  25. {
  26. pgd_t *pgd;
  27. pmd_t *pmd;
  28. pte_t *pte = NULL;
  29. pgd = pgd_offset(mm, addr);
  30. if (pgd) {
  31. pmd = pmd_alloc(mm, pgd, addr);
  32. if (pmd)
  33. pte = pte_alloc_map(mm, pmd, addr);
  34. }
  35. return pte;
  36. }
  37. pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
  38. {
  39. pgd_t *pgd;
  40. pmd_t *pmd;
  41. pte_t *pte = NULL;
  42. pgd = pgd_offset(mm, addr);
  43. if (pgd) {
  44. pmd = pmd_offset(pgd, addr);
  45. if (pmd)
  46. pte = pte_offset_map(pmd, addr);
  47. }
  48. return pte;
  49. }
  50. #define mk_pte_huge(entry) do { pte_val(entry) |= _PAGE_SZHUGE; } while (0)
  51. void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
  52. pte_t *ptep, pte_t entry)
  53. {
  54. int i;
  55. for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
  56. set_pte_at(mm, addr, ptep, entry);
  57. ptep++;
  58. addr += PAGE_SIZE;
  59. pte_val(entry) += PAGE_SIZE;
  60. }
  61. }
  62. pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
  63. pte_t *ptep)
  64. {
  65. pte_t entry;
  66. int i;
  67. entry = *ptep;
  68. for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
  69. pte_clear(mm, addr, ptep);
  70. addr += PAGE_SIZE;
  71. ptep++;
  72. }
  73. return entry;
  74. }
  75. /*
  76. * This function checks for proper alignment of input addr and len parameters.
  77. */
  78. int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
  79. {
  80. if (len & ~HPAGE_MASK)
  81. return -EINVAL;
  82. if (addr & ~HPAGE_MASK)
  83. return -EINVAL;
  84. return 0;
  85. }
  86. struct page *follow_huge_addr(struct mm_struct *mm,
  87. unsigned long address, int write)
  88. {
  89. return ERR_PTR(-EINVAL);
  90. }
  91. int pmd_huge(pmd_t pmd)
  92. {
  93. return 0;
  94. }
  95. struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
  96. pmd_t *pmd, int write)
  97. {
  98. return NULL;
  99. }