GNU Linux-libre 4.9.337-gnu1
[releases.git] / arch / powerpc / include / asm / nohash / 64 / pgtable-64k.h
1 #ifndef _ASM_POWERPC_NOHASH_64_PGTABLE_64K_H
2 #define _ASM_POWERPC_NOHASH_64_PGTABLE_64K_H
3
4 #include <asm-generic/pgtable-nopud.h>
5
6
7 #define PTE_INDEX_SIZE  8
8 #define PMD_INDEX_SIZE  10
9 #define PUD_INDEX_SIZE  0
10 #define PGD_INDEX_SIZE  12
11
12 /*
13  * we support 32 fragments per PTE page of 64K size
14  */
15 #define PTE_FRAG_NR     32
16 /*
17  * We use a 2K PTE page fragment and another 2K for storing
18  * real_pte_t hash index
19  */
20 #define PTE_FRAG_SIZE_SHIFT  11
21 #define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)
22
23 #ifndef __ASSEMBLY__
24 #define PTE_TABLE_SIZE  PTE_FRAG_SIZE
25 #define PMD_TABLE_SIZE  (sizeof(pmd_t) << PMD_INDEX_SIZE)
26 #define PUD_TABLE_SIZE  (0)
27 #define PGD_TABLE_SIZE  (sizeof(pgd_t) << PGD_INDEX_SIZE)
28 #endif  /* __ASSEMBLY__ */
29
30 #define PTRS_PER_PTE    (1 << PTE_INDEX_SIZE)
31 #define PTRS_PER_PMD    (1 << PMD_INDEX_SIZE)
32 #define PTRS_PER_PGD    (1 << PGD_INDEX_SIZE)
33
34 /* With 4k base page size, hugepage PTEs go at the PMD level */
35 #define MIN_HUGEPTE_SHIFT       PAGE_SHIFT
36
37 /* PMD_SHIFT determines what a second-level page table entry can map */
38 #define PMD_SHIFT       (PAGE_SHIFT + PTE_INDEX_SIZE)
39 #define PMD_SIZE        (1UL << PMD_SHIFT)
40 #define PMD_MASK        (~(PMD_SIZE-1))
41
42 /* PGDIR_SHIFT determines what a third-level page table entry can map */
43 #define PGDIR_SHIFT     (PMD_SHIFT + PMD_INDEX_SIZE)
44 #define PGDIR_SIZE      (1UL << PGDIR_SHIFT)
45 #define PGDIR_MASK      (~(PGDIR_SIZE-1))
46
47 /*
48  * Bits to mask out from a PMD to get to the PTE page
49  * PMDs point to PTE table fragments which are PTE_FRAG_SIZE aligned.
50  */
51 #define PMD_MASKED_BITS         (PTE_FRAG_SIZE - 1)
52 /* Bits to mask out from a PGD/PUD to get to the PMD page */
53 #define PUD_MASKED_BITS         0x1ff
54
55 #define pgd_pte(pgd)    (pud_pte(((pud_t){ pgd })))
56 #define pte_pgd(pte)    ((pgd_t)pte_pud(pte))
57
58 #endif /* _ASM_POWERPC_NOHASH_64_PGTABLE_64K_H */