pgtable-ppc64.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. #ifndef _ASM_POWERPC_PGTABLE_PPC64_H_
  2. #define _ASM_POWERPC_PGTABLE_PPC64_H_
  3. /*
  4. * This file contains the functions and defines necessary to modify and use
  5. * the ppc64 hashed page table.
  6. */
  7. #ifdef CONFIG_PPC_64K_PAGES
  8. #include <asm/pgtable-ppc64-64k.h>
  9. #else
  10. #include <asm/pgtable-ppc64-4k.h>
  11. #endif
  12. #include <asm/barrier.h>
  13. #define FIRST_USER_ADDRESS 0
  14. /*
  15. * Size of EA range mapped by our pagetables.
  16. */
  17. #define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
  18. PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT)
  19. #define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE)
  20. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  21. #define PMD_CACHE_INDEX (PMD_INDEX_SIZE + 1)
  22. #else
  23. #define PMD_CACHE_INDEX PMD_INDEX_SIZE
  24. #endif
  25. /*
  26. * Define the address range of the kernel non-linear virtual area
  27. */
  28. #ifdef CONFIG_PPC_BOOK3E
  29. #define KERN_VIRT_START ASM_CONST(0x8000000000000000)
  30. #else
  31. #define KERN_VIRT_START ASM_CONST(0xD000000000000000)
  32. #endif
  33. #define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000)
  34. /*
  35. * The vmalloc space starts at the beginning of that region, and
  36. * occupies half of it on hash CPUs and a quarter of it on Book3E
  37. * (we keep a quarter for the virtual memmap)
  38. */
  39. #define VMALLOC_START KERN_VIRT_START
  40. #ifdef CONFIG_PPC_BOOK3E
  41. #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 2)
  42. #else
  43. #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
  44. #endif
  45. #define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE)
  46. /*
  47. * The second half of the kernel virtual space is used for IO mappings,
  48. * it's itself carved into the PIO region (ISA and PHB IO space) and
  49. * the ioremap space
  50. *
  51. * ISA_IO_BASE = KERN_IO_START, 64K reserved area
  52. * PHB_IO_BASE = ISA_IO_BASE + 64K to ISA_IO_BASE + 2G, PHB IO spaces
  53. * IOREMAP_BASE = ISA_IO_BASE + 2G to VMALLOC_START + PGTABLE_RANGE
  54. */
  55. #define KERN_IO_START (KERN_VIRT_START + (KERN_VIRT_SIZE >> 1))
  56. #define FULL_IO_SIZE 0x80000000ul
  57. #define ISA_IO_BASE (KERN_IO_START)
  58. #define ISA_IO_END (KERN_IO_START + 0x10000ul)
  59. #define PHB_IO_BASE (ISA_IO_END)
  60. #define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE)
  61. #define IOREMAP_BASE (PHB_IO_END)
  62. #define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE)
  63. /*
  64. * Region IDs
  65. */
  66. #define REGION_SHIFT 60UL
  67. #define REGION_MASK (0xfUL << REGION_SHIFT)
  68. #define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT)
  69. #define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START))
  70. #define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET))
  71. #define VMEMMAP_REGION_ID (0xfUL) /* Server only */
  72. #define USER_REGION_ID (0UL)
  73. /*
  74. * Defines the address of the vmemap area, in its own region on
  75. * hash table CPUs and after the vmalloc space on Book3E
  76. */
  77. #ifdef CONFIG_PPC_BOOK3E
  78. #define VMEMMAP_BASE VMALLOC_END
  79. #define VMEMMAP_END KERN_IO_START
  80. #else
  81. #define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT)
  82. #endif
  83. #define vmemmap ((struct page *)VMEMMAP_BASE)
  84. /*
  85. * Include the PTE bits definitions
  86. */
  87. #ifdef CONFIG_PPC_BOOK3S
  88. #include <asm/pte-hash64.h>
  89. #else
  90. #include <asm/pte-book3e.h>
  91. #endif
  92. #include <asm/pte-common.h>
  93. #ifdef CONFIG_PPC_MM_SLICES
  94. #define HAVE_ARCH_UNMAPPED_AREA
  95. #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
  96. #endif /* CONFIG_PPC_MM_SLICES */
  97. #ifndef __ASSEMBLY__
  98. /*
  99. * This is the default implementation of various PTE accessors, it's
  100. * used in all cases except Book3S with 64K pages where we have a
  101. * concept of sub-pages
  102. */
  103. #ifndef __real_pte
  104. #ifdef STRICT_MM_TYPECHECKS
  105. #define __real_pte(e,p) ((real_pte_t){(e)})
  106. #define __rpte_to_pte(r) ((r).pte)
  107. #else
  108. #define __real_pte(e,p) (e)
  109. #define __rpte_to_pte(r) (__pte(r))
  110. #endif
  111. #define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> 12)
  112. #define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \
  113. do { \
  114. index = 0; \
  115. shift = mmu_psize_defs[psize].shift; \
  116. #define pte_iterate_hashed_end() } while(0)
  117. #ifdef CONFIG_PPC_HAS_HASH_64K
  118. #define pte_pagesize_index(mm, addr, pte) get_slice_psize(mm, addr)
  119. #else
  120. #define pte_pagesize_index(mm, addr, pte) MMU_PAGE_4K
  121. #endif
  122. #endif /* __real_pte */
  123. /* pte_clear moved to later in this file */
  124. #define PMD_BAD_BITS (PTE_TABLE_SIZE-1)
  125. #define PUD_BAD_BITS (PMD_TABLE_SIZE-1)
  126. #define pmd_set(pmdp, pmdval) (pmd_val(*(pmdp)) = (pmdval))
  127. #define pmd_none(pmd) (!pmd_val(pmd))
  128. #define pmd_bad(pmd) (!is_kernel_addr(pmd_val(pmd)) \
  129. || (pmd_val(pmd) & PMD_BAD_BITS))
  130. #define pmd_present(pmd) (pmd_val(pmd) != 0)
  131. #define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
  132. #define pmd_page_vaddr(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS)
  133. extern struct page *pmd_page(pmd_t pmd);
  134. #define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval))
  135. #define pud_none(pud) (!pud_val(pud))
  136. #define pud_bad(pud) (!is_kernel_addr(pud_val(pud)) \
  137. || (pud_val(pud) & PUD_BAD_BITS))
  138. #define pud_present(pud) (pud_val(pud) != 0)
  139. #define pud_clear(pudp) (pud_val(*(pudp)) = 0)
  140. #define pud_page_vaddr(pud) (pud_val(pud) & ~PUD_MASKED_BITS)
  141. #define pud_page(pud) virt_to_page(pud_page_vaddr(pud))
  142. #define pgd_set(pgdp, pudp) ({pgd_val(*(pgdp)) = (unsigned long)(pudp);})
  143. /*
  144. * Find an entry in a page-table-directory. We combine the address region
  145. * (the high order N bits) and the pgd portion of the address.
  146. */
  147. #define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
  148. #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
  149. #define pmd_offset(pudp,addr) \
  150. (((pmd_t *) pud_page_vaddr(*(pudp))) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
  151. #define pte_offset_kernel(dir,addr) \
  152. (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
  153. #define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
  154. #define pte_unmap(pte) do { } while(0)
  155. /* to find an entry in a kernel page-table-directory */
  156. /* This now only contains the vmalloc pages */
  157. #define pgd_offset_k(address) pgd_offset(&init_mm, address)
  158. extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
  159. pte_t *ptep, unsigned long pte, int huge);
  160. /* Atomic PTE updates */
  161. static inline unsigned long pte_update(struct mm_struct *mm,
  162. unsigned long addr,
  163. pte_t *ptep, unsigned long clr,
  164. unsigned long set,
  165. int huge)
  166. {
  167. #ifdef PTE_ATOMIC_UPDATES
  168. unsigned long old, tmp;
  169. __asm__ __volatile__(
  170. "1: ldarx %0,0,%3 # pte_update\n\
  171. andi. %1,%0,%6\n\
  172. bne- 1b \n\
  173. andc %1,%0,%4 \n\
  174. or %1,%1,%7\n\
  175. stdcx. %1,0,%3 \n\
  176. bne- 1b"
  177. : "=&r" (old), "=&r" (tmp), "=m" (*ptep)
  178. : "r" (ptep), "r" (clr), "m" (*ptep), "i" (_PAGE_BUSY), "r" (set)
  179. : "cc" );
  180. #else
  181. unsigned long old = pte_val(*ptep);
  182. *ptep = __pte((old & ~clr) | set);
  183. #endif
  184. /* huge pages use the old page table lock */
  185. if (!huge)
  186. assert_pte_locked(mm, addr);
  187. #ifdef CONFIG_PPC_STD_MMU_64
  188. if (old & _PAGE_HASHPTE)
  189. hpte_need_flush(mm, addr, ptep, old, huge);
  190. #endif
  191. return old;
  192. }
  193. static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
  194. unsigned long addr, pte_t *ptep)
  195. {
  196. unsigned long old;
  197. if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
  198. return 0;
  199. old = pte_update(mm, addr, ptep, _PAGE_ACCESSED, 0, 0);
  200. return (old & _PAGE_ACCESSED) != 0;
  201. }
  202. #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
  203. #define ptep_test_and_clear_young(__vma, __addr, __ptep) \
  204. ({ \
  205. int __r; \
  206. __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \
  207. __r; \
  208. })
  209. #define __HAVE_ARCH_PTEP_SET_WRPROTECT
  210. static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
  211. pte_t *ptep)
  212. {
  213. if ((pte_val(*ptep) & _PAGE_RW) == 0)
  214. return;
  215. pte_update(mm, addr, ptep, _PAGE_RW, 0, 0);
  216. }
  217. static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
  218. unsigned long addr, pte_t *ptep)
  219. {
  220. if ((pte_val(*ptep) & _PAGE_RW) == 0)
  221. return;
  222. pte_update(mm, addr, ptep, _PAGE_RW, 0, 1);
  223. }
  224. /*
  225. * We currently remove entries from the hashtable regardless of whether
  226. * the entry was young or dirty. The generic routines only flush if the
  227. * entry was young or dirty which is not good enough.
  228. *
  229. * We should be more intelligent about this but for the moment we override
  230. * these functions and force a tlb flush unconditionally
  231. */
  232. #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
  233. #define ptep_clear_flush_young(__vma, __address, __ptep) \
  234. ({ \
  235. int __young = __ptep_test_and_clear_young((__vma)->vm_mm, __address, \
  236. __ptep); \
  237. __young; \
  238. })
  239. #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
  240. static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
  241. unsigned long addr, pte_t *ptep)
  242. {
  243. unsigned long old = pte_update(mm, addr, ptep, ~0UL, 0, 0);
  244. return __pte(old);
  245. }
  246. static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
  247. pte_t * ptep)
  248. {
  249. pte_update(mm, addr, ptep, ~0UL, 0, 0);
  250. }
  251. /* Set the dirty and/or accessed bits atomically in a linux PTE, this
  252. * function doesn't need to flush the hash entry
  253. */
  254. static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
  255. {
  256. unsigned long bits = pte_val(entry) &
  257. (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
  258. #ifdef PTE_ATOMIC_UPDATES
  259. unsigned long old, tmp;
  260. __asm__ __volatile__(
  261. "1: ldarx %0,0,%4\n\
  262. andi. %1,%0,%6\n\
  263. bne- 1b \n\
  264. or %0,%3,%0\n\
  265. stdcx. %0,0,%4\n\
  266. bne- 1b"
  267. :"=&r" (old), "=&r" (tmp), "=m" (*ptep)
  268. :"r" (bits), "r" (ptep), "m" (*ptep), "i" (_PAGE_BUSY)
  269. :"cc");
  270. #else
  271. unsigned long old = pte_val(*ptep);
  272. *ptep = __pte(old | bits);
  273. #endif
  274. }
  275. #define __HAVE_ARCH_PTE_SAME
  276. #define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HPTEFLAGS) == 0)
  277. #define pte_ERROR(e) \
  278. pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
  279. #define pmd_ERROR(e) \
  280. pr_err("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
  281. #define pgd_ERROR(e) \
  282. pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
  283. /* Encode and de-code a swap entry */
  284. #define __swp_type(entry) (((entry).val >> 1) & 0x3f)
  285. #define __swp_offset(entry) ((entry).val >> 8)
  286. #define __swp_entry(type, offset) ((swp_entry_t){((type)<< 1)|((offset)<<8)})
  287. #define __pte_to_swp_entry(pte) ((swp_entry_t){pte_val(pte) >> PTE_RPN_SHIFT})
  288. #define __swp_entry_to_pte(x) ((pte_t) { (x).val << PTE_RPN_SHIFT })
  289. #define pte_to_pgoff(pte) (pte_val(pte) >> PTE_RPN_SHIFT)
  290. #define pgoff_to_pte(off) ((pte_t) {((off) << PTE_RPN_SHIFT)|_PAGE_FILE})
  291. #define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT)
  292. void pgtable_cache_add(unsigned shift, void (*ctor)(void *));
  293. void pgtable_cache_init(void);
  294. #endif /* __ASSEMBLY__ */
  295. /*
  296. * THP pages can't be special. So use the _PAGE_SPECIAL
  297. */
  298. #define _PAGE_SPLITTING _PAGE_SPECIAL
  299. /*
  300. * We need to differentiate between explicit huge page and THP huge
  301. * page, since THP huge page also need to track real subpage details
  302. */
  303. #define _PAGE_THP_HUGE _PAGE_4K_PFN
  304. /*
  305. * set of bits not changed in pmd_modify.
  306. */
  307. #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | \
  308. _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SPLITTING | \
  309. _PAGE_THP_HUGE)
  310. #ifndef __ASSEMBLY__
  311. /*
  312. * The linux hugepage PMD now include the pmd entries followed by the address
  313. * to the stashed pgtable_t. The stashed pgtable_t contains the hpte bits.
  314. * [ 1 bit secondary | 3 bit hidx | 1 bit valid | 000]. We use one byte per
  315. * each HPTE entry. With 16MB hugepage and 64K HPTE we need 256 entries and
  316. * with 4K HPTE we need 4096 entries. Both will fit in a 4K pgtable_t.
  317. *
  318. * The last three bits are intentionally left to zero. This memory location
  319. * are also used as normal page PTE pointers. So if we have any pointers
  320. * left around while we collapse a hugepage, we need to make sure
  321. * _PAGE_PRESENT and _PAGE_FILE bits of that are zero when we look at them
  322. */
  323. static inline unsigned int hpte_valid(unsigned char *hpte_slot_array, int index)
  324. {
  325. return (hpte_slot_array[index] >> 3) & 0x1;
  326. }
  327. static inline unsigned int hpte_hash_index(unsigned char *hpte_slot_array,
  328. int index)
  329. {
  330. return hpte_slot_array[index] >> 4;
  331. }
  332. static inline void mark_hpte_slot_valid(unsigned char *hpte_slot_array,
  333. unsigned int index, unsigned int hidx)
  334. {
  335. hpte_slot_array[index] = hidx << 4 | 0x1 << 3;
  336. }
  337. struct page *realmode_pfn_to_page(unsigned long pfn);
  338. static inline char *get_hpte_slot_array(pmd_t *pmdp)
  339. {
  340. /*
  341. * The hpte hindex is stored in the pgtable whose address is in the
  342. * second half of the PMD
  343. *
  344. * Order this load with the test for pmd_trans_huge in the caller
  345. */
  346. smp_rmb();
  347. return *(char **)(pmdp + PTRS_PER_PMD);
  348. }
  349. extern void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
  350. pmd_t *pmdp, unsigned long old_pmd);
  351. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  352. extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);
  353. extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot);
  354. extern pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot);
  355. extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
  356. pmd_t *pmdp, pmd_t pmd);
  357. extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
  358. pmd_t *pmd);
  359. static inline int pmd_trans_huge(pmd_t pmd)
  360. {
  361. /*
  362. * leaf pte for huge page, bottom two bits != 00
  363. */
  364. return (pmd_val(pmd) & 0x3) && (pmd_val(pmd) & _PAGE_THP_HUGE);
  365. }
  366. static inline int pmd_large(pmd_t pmd)
  367. {
  368. /*
  369. * leaf pte for huge page, bottom two bits != 00
  370. */
  371. if (pmd_trans_huge(pmd))
  372. return pmd_val(pmd) & _PAGE_PRESENT;
  373. return 0;
  374. }
  375. static inline int pmd_trans_splitting(pmd_t pmd)
  376. {
  377. if (pmd_trans_huge(pmd))
  378. return pmd_val(pmd) & _PAGE_SPLITTING;
  379. return 0;
  380. }
  381. extern int has_transparent_hugepage(void);
  382. #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
  383. static inline pte_t pmd_pte(pmd_t pmd)
  384. {
  385. return __pte(pmd_val(pmd));
  386. }
  387. static inline pmd_t pte_pmd(pte_t pte)
  388. {
  389. return __pmd(pte_val(pte));
  390. }
  391. static inline pte_t *pmdp_ptep(pmd_t *pmd)
  392. {
  393. return (pte_t *)pmd;
  394. }
  395. #define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd))
  396. #define pmd_young(pmd) pte_young(pmd_pte(pmd))
  397. #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd)))
  398. #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
  399. #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
  400. #define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd)))
  401. #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))
  402. #define __HAVE_ARCH_PMD_WRITE
  403. #define pmd_write(pmd) pte_write(pmd_pte(pmd))
  404. static inline pmd_t pmd_mkhuge(pmd_t pmd)
  405. {
  406. /* Do nothing, mk_pmd() does this part. */
  407. return pmd;
  408. }
  409. static inline pmd_t pmd_mknotpresent(pmd_t pmd)
  410. {
  411. pmd_val(pmd) &= ~_PAGE_PRESENT;
  412. return pmd;
  413. }
  414. static inline pmd_t pmd_mksplitting(pmd_t pmd)
  415. {
  416. pmd_val(pmd) |= _PAGE_SPLITTING;
  417. return pmd;
  418. }
  419. #define __HAVE_ARCH_PMD_SAME
  420. static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
  421. {
  422. return (((pmd_val(pmd_a) ^ pmd_val(pmd_b)) & ~_PAGE_HPTEFLAGS) == 0);
  423. }
  424. #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
  425. extern int pmdp_set_access_flags(struct vm_area_struct *vma,
  426. unsigned long address, pmd_t *pmdp,
  427. pmd_t entry, int dirty);
  428. extern unsigned long pmd_hugepage_update(struct mm_struct *mm,
  429. unsigned long addr,
  430. pmd_t *pmdp,
  431. unsigned long clr,
  432. unsigned long set);
  433. static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
  434. unsigned long addr, pmd_t *pmdp)
  435. {
  436. unsigned long old;
  437. if ((pmd_val(*pmdp) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
  438. return 0;
  439. old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED, 0);
  440. return ((old & _PAGE_ACCESSED) != 0);
  441. }
  442. #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
  443. extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,
  444. unsigned long address, pmd_t *pmdp);
  445. #define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
  446. extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
  447. unsigned long address, pmd_t *pmdp);
  448. #define __HAVE_ARCH_PMDP_GET_AND_CLEAR
  449. extern pmd_t pmdp_get_and_clear(struct mm_struct *mm,
  450. unsigned long addr, pmd_t *pmdp);
  451. #define __HAVE_ARCH_PMDP_CLEAR_FLUSH
  452. extern pmd_t pmdp_clear_flush(struct vm_area_struct *vma, unsigned long address,
  453. pmd_t *pmdp);
  454. #define __HAVE_ARCH_PMDP_SET_WRPROTECT
  455. static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
  456. pmd_t *pmdp)
  457. {
  458. if ((pmd_val(*pmdp) & _PAGE_RW) == 0)
  459. return;
  460. pmd_hugepage_update(mm, addr, pmdp, _PAGE_RW, 0);
  461. }
  462. #define __HAVE_ARCH_PMDP_SPLITTING_FLUSH
  463. extern void pmdp_splitting_flush(struct vm_area_struct *vma,
  464. unsigned long address, pmd_t *pmdp);
  465. #define __HAVE_ARCH_PGTABLE_DEPOSIT
  466. extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
  467. pgtable_t pgtable);
  468. #define __HAVE_ARCH_PGTABLE_WITHDRAW
  469. extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
  470. #define __HAVE_ARCH_PMDP_INVALIDATE
  471. extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
  472. pmd_t *pmdp);
  473. #define pmd_move_must_withdraw pmd_move_must_withdraw
  474. struct spinlock;
  475. static inline int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl,
  476. struct spinlock *old_pmd_ptl)
  477. {
  478. /*
  479. * Archs like ppc64 use pgtable to store per pmd
  480. * specific information. So when we switch the pmd,
  481. * we should also withdraw and deposit the pgtable
  482. */
  483. return true;
  484. }
  485. #endif /* __ASSEMBLY__ */
  486. #endif /* _ASM_POWERPC_PGTABLE_PPC64_H_ */