pte-common.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* Included from asm/pgtable-*.h only ! */
  2. /*
  3. * Some bits are only used on some cpu families... Make sure that all
  4. * the undefined gets a sensible default
  5. */
  6. #ifndef _PAGE_HASHPTE
  7. #define _PAGE_HASHPTE 0
  8. #endif
  9. #ifndef _PAGE_SHARED
  10. #define _PAGE_SHARED 0
  11. #endif
  12. #ifndef _PAGE_HWWRITE
  13. #define _PAGE_HWWRITE 0
  14. #endif
  15. #ifndef _PAGE_HWEXEC
  16. #define _PAGE_HWEXEC 0
  17. #endif
  18. #ifndef _PAGE_EXEC
  19. #define _PAGE_EXEC 0
  20. #endif
  21. #ifndef _PAGE_ENDIAN
  22. #define _PAGE_ENDIAN 0
  23. #endif
  24. #ifndef _PAGE_COHERENT
  25. #define _PAGE_COHERENT 0
  26. #endif
  27. #ifndef _PAGE_WRITETHRU
  28. #define _PAGE_WRITETHRU 0
  29. #endif
  30. #ifndef _PAGE_SPECIAL
  31. #define _PAGE_SPECIAL 0
  32. #endif
  33. #ifndef _PAGE_4K_PFN
  34. #define _PAGE_4K_PFN 0
  35. #endif
  36. #ifndef _PAGE_PSIZE
  37. #define _PAGE_PSIZE 0
  38. #endif
  39. #ifndef _PMD_PRESENT_MASK
  40. #define _PMD_PRESENT_MASK _PMD_PRESENT
  41. #endif
  42. #ifndef _PMD_SIZE
  43. #define _PMD_SIZE 0
  44. #define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
  45. #endif
  46. #ifndef _PAGE_KERNEL_RO
  47. #define _PAGE_KERNEL_RO 0
  48. #endif
  49. #ifndef _PAGE_KERNEL_RW
  50. #define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
  51. #endif
  52. #ifndef _PAGE_HPTEFLAGS
  53. #define _PAGE_HPTEFLAGS _PAGE_HASHPTE
  54. #endif
  55. #ifndef _PTE_NONE_MASK
  56. #define _PTE_NONE_MASK _PAGE_HPTEFLAGS
  57. #endif
  58. /* Make sure we get a link error if PMD_PAGE_SIZE is ever called on a
  59. * kernel without large page PMD support
  60. */
  61. #ifndef __ASSEMBLY__
  62. extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
  63. #endif /* __ASSEMBLY__ */
  64. /* Location of the PFN in the PTE. Most 32-bit platforms use the same
  65. * as _PAGE_SHIFT here (ie, naturally aligned).
  66. * Platform who don't just pre-define the value so we don't override it here
  67. */
  68. #ifndef PTE_RPN_SHIFT
  69. #define PTE_RPN_SHIFT (PAGE_SHIFT)
  70. #endif
  71. /* The mask convered by the RPN must be a ULL on 32-bit platforms with
  72. * 64-bit PTEs
  73. */
  74. #if defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT)
  75. #define PTE_RPN_MAX (1ULL << (64 - PTE_RPN_SHIFT))
  76. #define PTE_RPN_MASK (~((1ULL<<PTE_RPN_SHIFT)-1))
  77. #else
  78. #define PTE_RPN_MAX (1UL << (32 - PTE_RPN_SHIFT))
  79. #define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1))
  80. #endif
  81. /* _PAGE_CHG_MASK masks of bits that are to be preserved accross
  82. * pgprot changes
  83. */
  84. #define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
  85. _PAGE_ACCESSED | _PAGE_SPECIAL)
  86. /* Mask of bits returned by pte_pgprot() */
  87. #define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
  88. _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \
  89. _PAGE_USER | _PAGE_ACCESSED | \
  90. _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \
  91. _PAGE_EXEC | _PAGE_HWEXEC)
  92. /*
  93. * We define 2 sets of base prot bits, one for basic pages (ie,
  94. * cacheable kernel and user pages) and one for non cacheable
  95. * pages. We always set _PAGE_COHERENT when SMP is enabled or
  96. * the processor might need it for DMA coherency.
  97. */
  98. #define _PAGE_BASE_NC (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE)
  99. #if defined(CONFIG_SMP) || defined(CONFIG_PPC_STD_MMU)
  100. #define _PAGE_BASE (_PAGE_BASE_NC | _PAGE_COHERENT)
  101. #else
  102. #define _PAGE_BASE (_PAGE_BASE_NC)
  103. #endif
  104. /* Permission masks used to generate the __P and __S table,
  105. *
  106. * Note:__pgprot is defined in arch/powerpc/include/asm/page.h
  107. *
  108. * Write permissions imply read permissions for now (we could make write-only
  109. * pages on BookE but we don't bother for now). Execute permission control is
  110. * possible on platforms that define _PAGE_EXEC
  111. *
  112. * Note due to the way vm flags are laid out, the bits are XWR
  113. */
  114. #define PAGE_NONE __pgprot(_PAGE_BASE)
  115. #define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
  116. #define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
  117. #define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER)
  118. #define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
  119. #define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER)
  120. #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
  121. #define __P000 PAGE_NONE
  122. #define __P001 PAGE_READONLY
  123. #define __P010 PAGE_COPY
  124. #define __P011 PAGE_COPY
  125. #define __P100 PAGE_READONLY_X
  126. #define __P101 PAGE_READONLY_X
  127. #define __P110 PAGE_COPY_X
  128. #define __P111 PAGE_COPY_X
  129. #define __S000 PAGE_NONE
  130. #define __S001 PAGE_READONLY
  131. #define __S010 PAGE_SHARED
  132. #define __S011 PAGE_SHARED
  133. #define __S100 PAGE_READONLY_X
  134. #define __S101 PAGE_READONLY_X
  135. #define __S110 PAGE_SHARED_X
  136. #define __S111 PAGE_SHARED_X
  137. /* Permission masks used for kernel mappings */
  138. #define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
  139. #define PAGE_KERNEL_NC __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
  140. _PAGE_NO_CACHE)
  141. #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
  142. _PAGE_NO_CACHE | _PAGE_GUARDED)
  143. #define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC | \
  144. _PAGE_HWEXEC)
  145. #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
  146. #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC | \
  147. _PAGE_HWEXEC)
  148. /* Protection used for kernel text. We want the debuggers to be able to
  149. * set breakpoints anywhere, so don't write protect the kernel text
  150. * on platforms where such control is possible.
  151. */
  152. #if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
  153. defined(CONFIG_KPROBES)
  154. #define PAGE_KERNEL_TEXT PAGE_KERNEL_X
  155. #else
  156. #define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX
  157. #endif
  158. /* Make modules code happy. We don't set RO yet */
  159. #define PAGE_KERNEL_EXEC PAGE_KERNEL_X
  160. /* Advertise special mapping type for AGP */
  161. #define PAGE_AGP (PAGE_KERNEL_NC)
  162. #define HAVE_PAGE_AGP
  163. /* Advertise support for _PAGE_SPECIAL */
  164. #ifdef _PAGE_SPECIAL
  165. #define __HAVE_ARCH_PTE_SPECIAL
  166. #endif