page_64.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_page(void *to, void *from);
  52. /* Log 2 of page table size */
  53. extern u64 ppc64_pft_size;
  54. #endif /* __ASSEMBLY__ */
  55. #ifdef CONFIG_PPC_MM_SLICES
  56. #define SLICE_LOW_SHIFT 28
  57. #define SLICE_HIGH_SHIFT 40
  58. #define SLICE_LOW_TOP (0x100000000ul)
  59. #define SLICE_NUM_LOW (SLICE_LOW_TOP >> SLICE_LOW_SHIFT)
  60. #define SLICE_NUM_HIGH (PGTABLE_RANGE >> SLICE_HIGH_SHIFT)
  61. #define GET_LOW_SLICE_INDEX(addr) ((addr) >> SLICE_LOW_SHIFT)
  62. #define GET_HIGH_SLICE_INDEX(addr) ((addr) >> SLICE_HIGH_SHIFT)
  63. #ifndef __ASSEMBLY__
  64. struct slice_mask {
  65. u16 low_slices;
  66. u16 high_slices;
  67. };
  68. struct mm_struct;
  69. extern unsigned long slice_get_unmapped_area(unsigned long addr,
  70. unsigned long len,
  71. unsigned long flags,
  72. unsigned int psize,
  73. int topdown,
  74. int use_cache);
  75. extern unsigned int get_slice_psize(struct mm_struct *mm,
  76. unsigned long addr);
  77. extern void slice_init_context(struct mm_struct *mm, unsigned int psize);
  78. extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
  79. extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
  80. unsigned long len, unsigned int psize);
  81. #define slice_mm_new_context(mm) ((mm)->context.id == MMU_NO_CONTEXT)
  82. #endif /* __ASSEMBLY__ */
  83. #else
  84. #define slice_init()
  85. #ifdef CONFIG_PPC_STD_MMU_64
  86. #define get_slice_psize(mm, addr) ((mm)->context.user_psize)
  87. #define slice_set_user_psize(mm, psize) \
  88. do { \
  89. (mm)->context.user_psize = (psize); \
  90. (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \
  91. } while (0)
  92. #else /* CONFIG_PPC_STD_MMU_64 */
  93. #ifdef CONFIG_PPC_64K_PAGES
  94. #define get_slice_psize(mm, addr) MMU_PAGE_64K
  95. #else /* CONFIG_PPC_64K_PAGES */
  96. #define get_slice_psize(mm, addr) MMU_PAGE_4K
  97. #endif /* !CONFIG_PPC_64K_PAGES */
  98. #define slice_set_user_psize(mm, psize) do { BUG(); } while(0)
  99. #endif /* !CONFIG_PPC_STD_MMU_64 */
  100. #define slice_set_range_psize(mm, start, len, psize) \
  101. slice_set_user_psize((mm), (psize))
  102. #define slice_mm_new_context(mm) 1
  103. #endif /* CONFIG_PPC_MM_SLICES */
  104. #ifdef CONFIG_HUGETLB_PAGE
  105. #ifdef CONFIG_PPC_MM_SLICES
  106. #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
  107. #endif
  108. #endif /* !CONFIG_HUGETLB_PAGE */
  109. #define VM_DATA_DEFAULT_FLAGS \
  110. (is_32bit_task() ? \
  111. VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
  112. /*
  113. * This is the default if a program doesn't have a PT_GNU_STACK
  114. * program header entry. The PPC64 ELF ABI has a non executable stack
  115. * stack by default, so in the absence of a PT_GNU_STACK program header
  116. * we turn execute permission off.
  117. */
  118. #define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
  119. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  120. #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
  121. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  122. #define VM_STACK_DEFAULT_FLAGS \
  123. (is_32bit_task() ? \
  124. VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
  125. #include <asm-generic/getorder.h>
  126. #endif /* _ASM_POWERPC_PAGE_64_H */