powerpc/mm/book3s: Rename hash specific PTE bits to carry H_ prefix
[cascardo/linux.git] / arch / powerpc / include / asm / book3s / 64 / hash.h
1 #ifndef _ASM_POWERPC_BOOK3S_64_HASH_H
2 #define _ASM_POWERPC_BOOK3S_64_HASH_H
3 #ifdef __KERNEL__
4
5 /*
6  * Common bits between 4K and 64K pages in a linux-style PTE.
7  * Additional bits may be defined in pgtable-hash64-*.h
8  *
9  * Note: We only support user read/write permissions. Supervisor always
10  * have full read/write to pages above PAGE_OFFSET (pages below that
11  * always use the user access permissions).
12  *
13  * We could create separate kernel read-only if we used the 3 PP bits
14  * combinations that newer processors provide but we currently don't.
15  */
16 #define _PAGE_BIT_SWAP_TYPE     0
17
18 #define _PAGE_EXEC              0x00001 /* execute permission */
19 #define _PAGE_WRITE             0x00002 /* write access allowed */
20 #define _PAGE_READ              0x00004 /* read access allowed */
21 #define _PAGE_RW                (_PAGE_READ | _PAGE_WRITE)
22 #define _PAGE_RWX               (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
23 #define _PAGE_PRIVILEGED        0x00008 /* kernel access only */
24 #define _PAGE_SAO               0x00010 /* Strong access order */
25 #define _PAGE_NON_IDEMPOTENT    0x00020 /* non idempotent memory */
26 #define _PAGE_TOLERANT          0x00030 /* tolerant memory, cache inhibited */
27 #define _PAGE_DIRTY             0x00080 /* C: page changed */
28 #define _PAGE_ACCESSED          0x00100 /* R: page referenced */
29 /*
30  * Software bits
31  */
32 #ifdef CONFIG_MEM_SOFT_DIRTY
33 #define _PAGE_SOFT_DIRTY        0x00200 /* software: software dirty tracking */
34 #else
35 #define _PAGE_SOFT_DIRTY        0x00000
36 #endif
37 #define _PAGE_SPECIAL           0x00400 /* software: special page */
38 #define H_PAGE_BUSY             0x00800 /* software: PTE & hash are busy */
39
40
41 #define H_PAGE_F_GIX_SHIFT      57
42 #define H_PAGE_F_GIX            (7ul << 57)     /* HPTE index within HPTEG */
43 #define H_PAGE_F_SECOND         (1ul << 60)     /* HPTE is in 2ndary HPTEG */
44 #define H_PAGE_HASHPTE          (1ul << 61)     /* PTE has associated HPTE */
45 #define _PAGE_PTE               (1ul << 62)     /* distinguishes PTEs from pointers */
46 #define _PAGE_PRESENT           (1ul << 63)     /* pte contains a translation */
47 /*
48  * Drivers request for cache inhibited pte mapping using _PAGE_NO_CACHE
49  * Instead of fixing all of them, add an alternate define which
50  * maps CI pte mapping.
51  */
52 #define _PAGE_NO_CACHE          _PAGE_TOLERANT
53 /*
54  * We support 57 bit real address in pte. Clear everything above 57, and
55  * every thing below PAGE_SHIFT;
56  */
57 #define PTE_RPN_MASK    (((1UL << 57) - 1) & (PAGE_MASK))
58 /*
59  * set of bits not changed in pmd_modify.
60  */
61 #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
62                          _PAGE_ACCESSED | H_PAGE_THP_HUGE | _PAGE_PTE | \
63                          _PAGE_SOFT_DIRTY)
64
65
66 #ifdef CONFIG_PPC_64K_PAGES
67 #include <asm/book3s/64/hash-64k.h>
68 #else
69 #include <asm/book3s/64/hash-4k.h>
70 #endif
71
72 /*
73  * Size of EA range mapped by our pagetables.
74  */
75 #define PGTABLE_EADDR_SIZE      (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
76                                  PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT)
77 #define PGTABLE_RANGE           (ASM_CONST(1) << PGTABLE_EADDR_SIZE)
78
79 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
80 #define PMD_CACHE_INDEX (PMD_INDEX_SIZE + 1)
81 #else
82 #define PMD_CACHE_INDEX PMD_INDEX_SIZE
83 #endif
84 /*
85  * Define the address range of the kernel non-linear virtual area
86  */
87 #define KERN_VIRT_START ASM_CONST(0xD000000000000000)
88 #define KERN_VIRT_SIZE  ASM_CONST(0x0000100000000000)
89
90 /*
91  * The vmalloc space starts at the beginning of that region, and
92  * occupies half of it on hash CPUs and a quarter of it on Book3E
93  * (we keep a quarter for the virtual memmap)
94  */
95 #define VMALLOC_START   KERN_VIRT_START
96 #define VMALLOC_SIZE    (KERN_VIRT_SIZE >> 1)
97 #define VMALLOC_END     (VMALLOC_START + VMALLOC_SIZE)
98
99 /*
100  * Region IDs
101  */
102 #define REGION_SHIFT            60UL
103 #define REGION_MASK             (0xfUL << REGION_SHIFT)
104 #define REGION_ID(ea)           (((unsigned long)(ea)) >> REGION_SHIFT)
105
106 #define VMALLOC_REGION_ID       (REGION_ID(VMALLOC_START))
107 #define KERNEL_REGION_ID        (REGION_ID(PAGE_OFFSET))
108 #define VMEMMAP_REGION_ID       (0xfUL) /* Server only */
109 #define USER_REGION_ID          (0UL)
110
111 /*
112  * Defines the address of the vmemap area, in its own region on
113  * hash table CPUs.
114  */
115 #define VMEMMAP_BASE            (VMEMMAP_REGION_ID << REGION_SHIFT)
116
117 #ifdef CONFIG_PPC_MM_SLICES
118 #define HAVE_ARCH_UNMAPPED_AREA
119 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
120 #endif /* CONFIG_PPC_MM_SLICES */
121
122 /*
123  * user access blocked by key
124  */
125 #define _PAGE_KERNEL_RW         (_PAGE_PRIVILEGED | _PAGE_RW | _PAGE_DIRTY)
126 #define _PAGE_KERNEL_RO          (_PAGE_PRIVILEGED | _PAGE_READ)
127 #define _PAGE_KERNEL_RWX        (_PAGE_PRIVILEGED | _PAGE_DIRTY | \
128                                  _PAGE_RW | _PAGE_EXEC)
129
130 /* No page size encoding in the linux PTE */
131 #define _PAGE_PSIZE             0
132
133 /* PTEIDX nibble */
134 #define _PTEIDX_SECONDARY       0x8
135 #define _PTEIDX_GROUP_IX        0x7
136
137 #define _PTE_NONE_MASK  _PAGE_HPTEFLAGS
138 /*
139  * _PAGE_CHG_MASK masks of bits that are to be preserved across
140  * pgprot changes
141  */
142 #define _PAGE_CHG_MASK  (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
143                          _PAGE_ACCESSED | _PAGE_SPECIAL | _PAGE_PTE | \
144                          _PAGE_SOFT_DIRTY)
145 /*
146  * Mask of bits returned by pte_pgprot()
147  */
148 #define PAGE_PROT_BITS  (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT | \
149                          H_PAGE_4K_PFN | _PAGE_PRIVILEGED | _PAGE_ACCESSED | \
150                          _PAGE_READ | _PAGE_WRITE |  _PAGE_DIRTY | _PAGE_EXEC | \
151                          _PAGE_SOFT_DIRTY)
152 /*
153  * We define 2 sets of base prot bits, one for basic pages (ie,
154  * cacheable kernel and user pages) and one for non cacheable
155  * pages. We always set _PAGE_COHERENT when SMP is enabled or
156  * the processor might need it for DMA coherency.
157  */
158 #define _PAGE_BASE_NC   (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE)
159 #define _PAGE_BASE      (_PAGE_BASE_NC)
160
161 /* Permission masks used to generate the __P and __S table,
162  *
163  * Note:__pgprot is defined in arch/powerpc/include/asm/page.h
164  *
165  * Write permissions imply read permissions for now (we could make write-only
166  * pages on BookE but we don't bother for now). Execute permission control is
167  * possible on platforms that define _PAGE_EXEC
168  *
169  * Note due to the way vm flags are laid out, the bits are XWR
170  */
171 #define PAGE_NONE       __pgprot(_PAGE_BASE | _PAGE_PRIVILEGED)
172 #define PAGE_SHARED     __pgprot(_PAGE_BASE | _PAGE_RW)
173 #define PAGE_SHARED_X   __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_EXEC)
174 #define PAGE_COPY       __pgprot(_PAGE_BASE | _PAGE_READ)
175 #define PAGE_COPY_X     __pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_EXEC)
176 #define PAGE_READONLY   __pgprot(_PAGE_BASE | _PAGE_READ)
177 #define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_EXEC)
178
179 #define __P000  PAGE_NONE
180 #define __P001  PAGE_READONLY
181 #define __P010  PAGE_COPY
182 #define __P011  PAGE_COPY
183 #define __P100  PAGE_READONLY_X
184 #define __P101  PAGE_READONLY_X
185 #define __P110  PAGE_COPY_X
186 #define __P111  PAGE_COPY_X
187
188 #define __S000  PAGE_NONE
189 #define __S001  PAGE_READONLY
190 #define __S010  PAGE_SHARED
191 #define __S011  PAGE_SHARED
192 #define __S100  PAGE_READONLY_X
193 #define __S101  PAGE_READONLY_X
194 #define __S110  PAGE_SHARED_X
195 #define __S111  PAGE_SHARED_X
196
197 /* Permission masks used for kernel mappings */
198 #define PAGE_KERNEL     __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
199 #define PAGE_KERNEL_NC  __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
200                                  _PAGE_TOLERANT)
201 #define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
202                                  _PAGE_NON_IDEMPOTENT)
203 #define PAGE_KERNEL_X   __pgprot(_PAGE_BASE | _PAGE_KERNEL_RWX)
204 #define PAGE_KERNEL_RO  __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
205 #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_ROX)
206
207 /* Protection used for kernel text. We want the debuggers to be able to
208  * set breakpoints anywhere, so don't write protect the kernel text
209  * on platforms where such control is possible.
210  */
211 #if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
212         defined(CONFIG_KPROBES) || defined(CONFIG_DYNAMIC_FTRACE)
213 #define PAGE_KERNEL_TEXT        PAGE_KERNEL_X
214 #else
215 #define PAGE_KERNEL_TEXT        PAGE_KERNEL_ROX
216 #endif
217
218 /* Make modules code happy. We don't set RO yet */
219 #define PAGE_KERNEL_EXEC        PAGE_KERNEL_X
220 #define PAGE_AGP                (PAGE_KERNEL_NC)
221
222 #define PMD_BAD_BITS            (PTE_TABLE_SIZE-1)
223 #define PUD_BAD_BITS            (PMD_TABLE_SIZE-1)
224
225 #ifndef __ASSEMBLY__
226 #define pmd_bad(pmd)            (pmd_val(pmd) & PMD_BAD_BITS)
227 #define pmd_page_vaddr(pmd)     __va(pmd_val(pmd) & ~PMD_MASKED_BITS)
228
229 #define pud_bad(pud)            (pud_val(pud) & PUD_BAD_BITS)
230 #define pud_page_vaddr(pud)     __va(pud_val(pud) & ~PUD_MASKED_BITS)
231
232 /* Pointers in the page table tree are physical addresses */
233 #define __pgtable_ptr_val(ptr)  __pa(ptr)
234
235 #define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
236 #define pud_index(address) (((address) >> (PUD_SHIFT)) & (PTRS_PER_PUD - 1))
237 #define pmd_index(address) (((address) >> (PMD_SHIFT)) & (PTRS_PER_PMD - 1))
238 #define pte_index(address) (((address) >> (PAGE_SHIFT)) & (PTRS_PER_PTE - 1))
239
240 extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
241                             pte_t *ptep, unsigned long pte, int huge);
242 extern unsigned long htab_convert_pte_flags(unsigned long pteflags);
243 /* Atomic PTE updates */
244 static inline unsigned long pte_update(struct mm_struct *mm,
245                                        unsigned long addr,
246                                        pte_t *ptep, unsigned long clr,
247                                        unsigned long set,
248                                        int huge)
249 {
250         __be64 old_be, tmp_be;
251         unsigned long old;
252
253         __asm__ __volatile__(
254         "1:     ldarx   %0,0,%3         # pte_update\n\
255         and.    %1,%0,%6\n\
256         bne-    1b \n\
257         andc    %1,%0,%4 \n\
258         or      %1,%1,%7\n\
259         stdcx.  %1,0,%3 \n\
260         bne-    1b"
261         : "=&r" (old_be), "=&r" (tmp_be), "=m" (*ptep)
262         : "r" (ptep), "r" (cpu_to_be64(clr)), "m" (*ptep),
263           "r" (cpu_to_be64(H_PAGE_BUSY)), "r" (cpu_to_be64(set))
264         : "cc" );
265         /* huge pages use the old page table lock */
266         if (!huge)
267                 assert_pte_locked(mm, addr);
268
269         old = be64_to_cpu(old_be);
270         if (old & H_PAGE_HASHPTE)
271                 hpte_need_flush(mm, addr, ptep, old, huge);
272
273         return old;
274 }
275
276 /*
277  * We currently remove entries from the hashtable regardless of whether
278  * the entry was young or dirty.
279  *
280  * We should be more intelligent about this but for the moment we override
281  * these functions and force a tlb flush unconditionally
282  */
283 static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
284                                               unsigned long addr, pte_t *ptep)
285 {
286         unsigned long old;
287
288         if ((pte_val(*ptep) & (_PAGE_ACCESSED | H_PAGE_HASHPTE)) == 0)
289                 return 0;
290         old = pte_update(mm, addr, ptep, _PAGE_ACCESSED, 0, 0);
291         return (old & _PAGE_ACCESSED) != 0;
292 }
293 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
294 #define ptep_test_and_clear_young(__vma, __addr, __ptep)                   \
295 ({                                                                         \
296         int __r;                                                           \
297         __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \
298         __r;                                                               \
299 })
300
301 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
302 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
303                                       pte_t *ptep)
304 {
305
306         if ((pte_val(*ptep) & _PAGE_WRITE) == 0)
307                 return;
308
309         pte_update(mm, addr, ptep, _PAGE_WRITE, 0, 0);
310 }
311
312 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
313                                            unsigned long addr, pte_t *ptep)
314 {
315         if ((pte_val(*ptep) & _PAGE_WRITE) == 0)
316                 return;
317
318         pte_update(mm, addr, ptep, _PAGE_WRITE, 0, 1);
319 }
320
321 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
322 static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
323                                        unsigned long addr, pte_t *ptep)
324 {
325         unsigned long old = pte_update(mm, addr, ptep, ~0UL, 0, 0);
326         return __pte(old);
327 }
328
329 static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
330                              pte_t * ptep)
331 {
332         pte_update(mm, addr, ptep, ~0UL, 0, 0);
333 }
334
335
336 /* Set the dirty and/or accessed bits atomically in a linux PTE, this
337  * function doesn't need to flush the hash entry
338  */
339 static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
340 {
341         __be64 old, tmp, val, mask;
342
343         mask = cpu_to_be64(_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_READ | _PAGE_WRITE |
344                            _PAGE_EXEC | _PAGE_SOFT_DIRTY);
345
346         val = pte_raw(entry) & mask;
347
348         __asm__ __volatile__(
349         "1:     ldarx   %0,0,%4\n\
350                 and.    %1,%0,%6\n\
351                 bne-    1b \n\
352                 or      %0,%3,%0\n\
353                 stdcx.  %0,0,%4\n\
354                 bne-    1b"
355         :"=&r" (old), "=&r" (tmp), "=m" (*ptep)
356         :"r" (val), "r" (ptep), "m" (*ptep), "r" (cpu_to_be64(H_PAGE_BUSY))
357         :"cc");
358 }
359
360 static inline int pgd_bad(pgd_t pgd)
361 {
362         return (pgd_val(pgd) == 0);
363 }
364
365 #define __HAVE_ARCH_PTE_SAME
366 static inline int pte_same(pte_t pte_a, pte_t pte_b)
367 {
368         return (((pte_raw(pte_a) ^ pte_raw(pte_b)) & ~cpu_to_be64(_PAGE_HPTEFLAGS)) == 0);
369 }
370
371 static inline unsigned long pgd_page_vaddr(pgd_t pgd)
372 {
373         return (unsigned long)__va(pgd_val(pgd) & ~PGD_MASKED_BITS);
374 }
375
376
377 /* Generic accessors to PTE bits */
378 static inline int pte_write(pte_t pte)          { return !!(pte_val(pte) & _PAGE_WRITE);}
379 static inline int pte_dirty(pte_t pte)          { return !!(pte_val(pte) & _PAGE_DIRTY); }
380 static inline int pte_young(pte_t pte)          { return !!(pte_val(pte) & _PAGE_ACCESSED); }
381 static inline int pte_special(pte_t pte)        { return !!(pte_val(pte) & _PAGE_SPECIAL); }
382 static inline int pte_none(pte_t pte)           { return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; }
383 static inline pgprot_t pte_pgprot(pte_t pte)    { return __pgprot(pte_val(pte) & PAGE_PROT_BITS); }
384
385 #ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
386 static inline bool pte_soft_dirty(pte_t pte)
387 {
388         return !!(pte_val(pte) & _PAGE_SOFT_DIRTY);
389 }
390 static inline pte_t pte_mksoft_dirty(pte_t pte)
391 {
392         return __pte(pte_val(pte) | _PAGE_SOFT_DIRTY);
393 }
394
395 static inline pte_t pte_clear_soft_dirty(pte_t pte)
396 {
397         return __pte(pte_val(pte) & ~_PAGE_SOFT_DIRTY);
398 }
399 #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
400
401 #ifdef CONFIG_NUMA_BALANCING
402 /*
403  * These work without NUMA balancing but the kernel does not care. See the
404  * comment in include/asm-generic/pgtable.h . On powerpc, this will only
405  * work for user pages and always return true for kernel pages.
406  */
407 static inline int pte_protnone(pte_t pte)
408 {
409         return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PRIVILEGED)) ==
410                 (_PAGE_PRESENT | _PAGE_PRIVILEGED);
411 }
412 #endif /* CONFIG_NUMA_BALANCING */
413
414 static inline int pte_present(pte_t pte)
415 {
416         return !!(pte_val(pte) & _PAGE_PRESENT);
417 }
418
419 /* Conversion functions: convert a page and protection to a page entry,
420  * and a page entry and page directory to the page they refer to.
421  *
422  * Even if PTEs can be unsigned long long, a PFN is always an unsigned
423  * long for now.
424  */
425 static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
426 {
427         return __pte((((pte_basic_t)(pfn) << PAGE_SHIFT) & PTE_RPN_MASK) |
428                      pgprot_val(pgprot));
429 }
430
431 static inline unsigned long pte_pfn(pte_t pte)
432 {
433         return (pte_val(pte) & PTE_RPN_MASK) >> PAGE_SHIFT;
434 }
435
436 /* Generic modifiers for PTE bits */
437 static inline pte_t pte_wrprotect(pte_t pte)
438 {
439         return __pte(pte_val(pte) & ~_PAGE_WRITE);
440 }
441
442 static inline pte_t pte_mkclean(pte_t pte)
443 {
444         return __pte(pte_val(pte) & ~_PAGE_DIRTY);
445 }
446
447 static inline pte_t pte_mkold(pte_t pte)
448 {
449         return __pte(pte_val(pte) & ~_PAGE_ACCESSED);
450 }
451
452 static inline pte_t pte_mkwrite(pte_t pte)
453 {
454         /*
455          * write implies read, hence set both
456          */
457         return __pte(pte_val(pte) | _PAGE_RW);
458 }
459
460 static inline pte_t pte_mkdirty(pte_t pte)
461 {
462         return __pte(pte_val(pte) | _PAGE_DIRTY | _PAGE_SOFT_DIRTY);
463 }
464
465 static inline pte_t pte_mkyoung(pte_t pte)
466 {
467         return __pte(pte_val(pte) | _PAGE_ACCESSED);
468 }
469
470 static inline pte_t pte_mkspecial(pte_t pte)
471 {
472         return __pte(pte_val(pte) | _PAGE_SPECIAL);
473 }
474
475 static inline pte_t pte_mkhuge(pte_t pte)
476 {
477         return pte;
478 }
479
480 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
481 {
482         return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
483 }
484
485 /* This low level function performs the actual PTE insertion
486  * Setting the PTE depends on the MMU type and other factors. It's
487  * an horrible mess that I'm not going to try to clean up now but
488  * I'm keeping it in one place rather than spread around
489  */
490 static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
491                                 pte_t *ptep, pte_t pte, int percpu)
492 {
493         /*
494          * Anything else just stores the PTE normally. That covers all 64-bit
495          * cases, and 32-bit non-hash with 32-bit PTEs.
496          */
497         *ptep = pte;
498 }
499
500 #define _PAGE_CACHE_CTL (_PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
501
502 #define pgprot_noncached pgprot_noncached
503 static inline pgprot_t pgprot_noncached(pgprot_t prot)
504 {
505         return __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) |
506                         _PAGE_NON_IDEMPOTENT);
507 }
508
509 #define pgprot_noncached_wc pgprot_noncached_wc
510 static inline pgprot_t pgprot_noncached_wc(pgprot_t prot)
511 {
512         return __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) |
513                         _PAGE_TOLERANT);
514 }
515
516 #define pgprot_cached pgprot_cached
517 static inline pgprot_t pgprot_cached(pgprot_t prot)
518 {
519         return __pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL));
520 }
521
522 #define pgprot_writecombine pgprot_writecombine
523 static inline pgprot_t pgprot_writecombine(pgprot_t prot)
524 {
525         return pgprot_noncached_wc(prot);
526 }
527 /*
528  * check a pte mapping have cache inhibited property
529  */
530 static inline bool pte_ci(pte_t pte)
531 {
532         unsigned long pte_v = pte_val(pte);
533
534         if (((pte_v & _PAGE_CACHE_CTL) == _PAGE_TOLERANT) ||
535             ((pte_v & _PAGE_CACHE_CTL) == _PAGE_NON_IDEMPOTENT))
536                 return true;
537         return false;
538 }
539
540 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
541 extern void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
542                                    pmd_t *pmdp, unsigned long old_pmd);
543 #else
544 static inline void hpte_do_hugepage_flush(struct mm_struct *mm,
545                                           unsigned long addr, pmd_t *pmdp,
546                                           unsigned long old_pmd)
547 {
548         WARN(1, "%s called with THP disabled\n", __func__);
549 }
550 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
551
552 #endif /* !__ASSEMBLY__ */
553 #endif /* __KERNEL__ */
554 #endif /* _ASM_POWERPC_BOOK3S_64_HASH_H */