page_64.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #ifndef _ASM_POWERPC_PAGE_64_H
  2. #define _ASM_POWERPC_PAGE_64_H
  3. /*
  4. * Copyright (C) 2001 PPC64 Team, IBM Corp
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. /*
  12. * We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux
  13. * specific, every notion of page number shared with the firmware, TCEs,
  14. * iommu, etc... still uses a page size of 4K.
  15. */
  16. #define HW_PAGE_SHIFT 12
  17. #define HW_PAGE_SIZE (ASM_CONST(1) << HW_PAGE_SHIFT)
  18. #define HW_PAGE_MASK (~(HW_PAGE_SIZE-1))
  19. /*
  20. * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and
  21. * HW_PAGE_SHIFT, that is 4K pages.
  22. */
  23. #define PAGE_FACTOR (PAGE_SHIFT - HW_PAGE_SHIFT)
  24. /* Segment size; normal 256M segments */
  25. #define SID_SHIFT 28
  26. #define SID_MASK ASM_CONST(0xfffffffff)
  27. #define ESID_MASK 0xfffffffff0000000UL
  28. #define GET_ESID(x) (((x) >> SID_SHIFT) & SID_MASK)
  29. /* 1T segments */
  30. #define SID_SHIFT_1T 40
  31. #define SID_MASK_1T 0xffffffUL
  32. #define ESID_MASK_1T 0xffffff0000000000UL
  33. #define GET_ESID_1T(x) (((x) >> SID_SHIFT_1T) & SID_MASK_1T)
  34. #ifndef __ASSEMBLY__
  35. #include <asm/cache.h>
  36. typedef unsigned long pte_basic_t;
  37. static inline void clear_page(void *addr)
  38. {
  39. unsigned long iterations;
  40. unsigned long onex, twox, fourx, eightx;
  41. iterations = ppc64_caches.dlines_per_page / 8;
  42. /*
  43. * Some verisions of gcc use multiply instructions to
  44. * calculate the offsets so lets give it a hand to
  45. * do better.
  46. */
  47. onex = ppc64_caches.dline_size;
  48. twox = onex << 1;
  49. fourx = onex << 2;
  50. eightx = onex << 3;
  51. asm volatile(
  52. "mtctr %1 # clear_page\n\
  53. .balign 16\n\
  54. 1: dcbz 0,%0\n\
  55. dcbz %3,%0\n\
  56. dcbz %4,%0\n\
  57. dcbz %5,%0\n\
  58. dcbz %6,%0\n\
  59. dcbz %7,%0\n\
  60. dcbz %8,%0\n\
  61. dcbz %9,%0\n\
  62. add %0,%0,%10\n\
  63. bdnz+ 1b"
  64. : "=&r" (addr)
  65. : "r" (iterations), "0" (addr), "b" (onex), "b" (twox),
  66. "b" (twox+onex), "b" (fourx), "b" (fourx+onex),
  67. "b" (twox+fourx), "b" (eightx-onex), "r" (eightx)
  68. : "ctr", "memory");
  69. }
  70. extern void copy_page(void *to, void *from);
  71. /* Log 2 of page table size */
  72. extern u64 ppc64_pft_size;
  73. #endif /* __ASSEMBLY__ */
  74. #ifdef CONFIG_PPC_MM_SLICES
  75. #define SLICE_LOW_SHIFT 28
  76. #define SLICE_HIGH_SHIFT 40
  77. #define SLICE_LOW_TOP (0x100000000ul)
  78. #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT)
  79. #define SLICE_NUM_HIGH (PGTABLE_RANGE >> SLICE_HIGH_SHIFT)
  80. #define GET_LOW_SLICE_INDEX(addr) ((addr) >> SLICE_LOW_SHIFT)
  81. #define GET_HIGH_SLICE_INDEX(addr) ((addr) >> SLICE_HIGH_SHIFT)
  82. /*
  83. * 1 bit per slice and we have one slice per 1TB
  84. * Right now we support only 64TB.
  85. * IF we change this we will have to change the type
  86. * of high_slices
  87. */
  88. #define SLICE_MASK_SIZE 8
  89. #ifndef __ASSEMBLY__
  90. struct slice_mask {
  91. u16 low_slices;
  92. u64 high_slices;
  93. };
  94. struct mm_struct;
  95. extern unsigned long slice_get_unmapped_area(unsigned long addr,
  96. unsigned long len,
  97. unsigned long flags,
  98. unsigned int psize,
  99. int topdown);
  100. extern unsigned int get_slice_psize(struct mm_struct *mm,
  101. unsigned long addr);
  102. extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
  103. extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
  104. unsigned long len, unsigned int psize);
  105. #define slice_mm_new_context(mm) ((mm)->context.id == MMU_NO_CONTEXT)
  106. #endif /* __ASSEMBLY__ */
  107. #else
  108. #define slice_init()
  109. #ifdef CONFIG_PPC_STD_MMU_64
  110. #define get_slice_psize(mm, addr) ((mm)->context.user_psize)
  111. #define slice_set_user_psize(mm, psize) \
  112. do { \
  113. (mm)->context.user_psize = (psize); \
  114. (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \
  115. } while (0)
  116. #else /* CONFIG_PPC_STD_MMU_64 */
  117. #ifdef CONFIG_PPC_64K_PAGES
  118. #define get_slice_psize(mm, addr) MMU_PAGE_64K
  119. #else /* CONFIG_PPC_64K_PAGES */
  120. #define get_slice_psize(mm, addr) MMU_PAGE_4K
  121. #endif /* !CONFIG_PPC_64K_PAGES */
  122. #define slice_set_user_psize(mm, psize) do { BUG(); } while(0)
  123. #endif /* !CONFIG_PPC_STD_MMU_64 */
  124. #define slice_set_range_psize(mm, start, len, psize) \
  125. slice_set_user_psize((mm), (psize))
  126. #define slice_mm_new_context(mm) 1
  127. #endif /* CONFIG_PPC_MM_SLICES */
  128. #ifdef CONFIG_HUGETLB_PAGE
  129. #ifdef CONFIG_PPC_MM_SLICES
  130. #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
  131. #endif
  132. #endif /* !CONFIG_HUGETLB_PAGE */
  133. #define VM_DATA_DEFAULT_FLAGS \
  134. (is_32bit_task() ? \
  135. VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
  136. /*
  137. * This is the default if a program doesn't have a PT_GNU_STACK
  138. * program header entry. The PPC64 ELF ABI has a non executable stack
  139. * stack by default, so in the absence of a PT_GNU_STACK program header
  140. * we turn execute permission off.
  141. */
  142. #define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
  143. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  144. #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
  145. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  146. #define VM_STACK_DEFAULT_FLAGS \
  147. (is_32bit_task() ? \
  148. VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
  149. #include <asm-generic/getorder.h>
  150. #endif /* _ASM_POWERPC_PAGE_64_H */