page_64.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 lines, line_size;
  40. line_size = ppc64_caches.dline_size;
  41. lines = ppc64_caches.dlines_per_page;
  42. __asm__ __volatile__(
  43. "mtctr %1 # clear_page\n\
  44. 1: dcbz 0,%0\n\
  45. add %0,%0,%3\n\
  46. bdnz+ 1b"
  47. : "=r" (addr)
  48. : "r" (lines), "0" (addr), "r" (line_size)
  49. : "ctr", "memory");
  50. }
  51. extern void copy_4K_page(void *to, void *from);
  52. #ifdef CONFIG_PPC_64K_PAGES
  53. static inline void copy_page(void *to, void *from)
  54. {
  55. unsigned int i;
  56. for (i=0; i < (1 << (PAGE_SHIFT - 12)); i++) {
  57. copy_4K_page(to, from);
  58. to += 4096;
  59. from += 4096;
  60. }
  61. }
  62. #else /* CONFIG_PPC_64K_PAGES */
  63. static inline void copy_page(void *to, void *from)
  64. {
  65. copy_4K_page(to, from);
  66. }
  67. #endif /* CONFIG_PPC_64K_PAGES */
  68. /* Log 2 of page table size */
  69. extern u64 ppc64_pft_size;
  70. /* Large pages size */
  71. #ifdef CONFIG_HUGETLB_PAGE
  72. extern unsigned int HPAGE_SHIFT;
  73. #else
  74. #define HPAGE_SHIFT PAGE_SHIFT
  75. #endif
  76. #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
  77. #define HPAGE_MASK (~(HPAGE_SIZE - 1))
  78. #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
  79. #define HUGE_MAX_HSTATE 3
  80. #endif /* __ASSEMBLY__ */
  81. #ifdef CONFIG_PPC_MM_SLICES
  82. #define SLICE_LOW_SHIFT 28
  83. #define SLICE_HIGH_SHIFT 40
  84. #define SLICE_LOW_TOP (0x100000000ul)
  85. #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT)
  86. #define SLICE_NUM_HIGH (PGTABLE_RANGE >> SLICE_HIGH_SHIFT)
  87. #define GET_LOW_SLICE_INDEX(addr) ((addr) >> SLICE_LOW_SHIFT)
  88. #define GET_HIGH_SLICE_INDEX(addr) ((addr) >> SLICE_HIGH_SHIFT)
  89. #ifndef __ASSEMBLY__
  90. struct slice_mask {
  91. u16 low_slices;
  92. u16 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. int use_cache);
  101. extern unsigned int get_slice_psize(struct mm_struct *mm,
  102. unsigned long addr);
  103. extern void slice_init_context(struct mm_struct *mm, unsigned int psize);
  104. extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
  105. extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
  106. unsigned long len, unsigned int psize);
  107. #define slice_mm_new_context(mm) ((mm)->context.id == 0)
  108. #endif /* __ASSEMBLY__ */
  109. #else
  110. #define slice_init()
  111. #define get_slice_psize(mm, addr) ((mm)->context.user_psize)
  112. #define slice_set_user_psize(mm, psize) \
  113. do { \
  114. (mm)->context.user_psize = (psize); \
  115. (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \
  116. } while (0)
  117. #define slice_set_range_psize(mm, start, len, psize) \
  118. slice_set_user_psize((mm), (psize))
  119. #define slice_mm_new_context(mm) 1
  120. #endif /* CONFIG_PPC_MM_SLICES */
  121. #ifdef CONFIG_HUGETLB_PAGE
  122. #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
  123. #endif /* !CONFIG_HUGETLB_PAGE */
  124. #ifdef MODULE
  125. #define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
  126. #else
  127. #define __page_aligned \
  128. __attribute__((__aligned__(PAGE_SIZE), \
  129. __section__(".data.page_aligned")))
  130. #endif
  131. #define VM_DATA_DEFAULT_FLAGS \
  132. (test_thread_flag(TIF_32BIT) ? \
  133. VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
  134. /*
  135. * This is the default if a program doesn't have a PT_GNU_STACK
  136. * program header entry. The PPC64 ELF ABI has a non executable stack
  137. * stack by default, so in the absense of a PT_GNU_STACK program header
  138. * we turn execute permission off.
  139. */
  140. #define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
  141. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  142. #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
  143. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  144. #define VM_STACK_DEFAULT_FLAGS \
  145. (test_thread_flag(TIF_32BIT) ? \
  146. VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
  147. #include <asm-generic/page.h>
  148. #endif /* _ASM_POWERPC_PAGE_64_H */