aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/include/asm
diff options
context:
space:
mode:
authorDavid Woods <dwoods@ezchip.com>2015-12-17 14:31:26 -0500
committerWill Deacon <will.deacon@arm.com>2015-12-21 12:26:00 -0500
commit66b3923a1a0f77a563b43f43f6ad091354abbfe9 (patch)
treeb380eb7da866452ff697dfb588309184b86f1ef1 /arch/arm64/include/asm
parent0a28714c53fd4f7aea709be7577dfbe0095c8c3e (diff)
arm64: hugetlb: add support for PTE contiguous bit
The arm64 MMU supports a Contiguous bit which is a hint that the TTE is one of a set of contiguous entries which can be cached in a single TLB entry. Supporting this bit adds new intermediate huge page sizes. The set of huge page sizes available depends on the base page size. Without using contiguous pages the huge page sizes are as follows. 4KB: 2MB 1GB 64KB: 512MB With a 4KB granule, the contiguous bit groups together sets of 16 pages and with a 64KB granule it groups sets of 32 pages. This enables two new huge page sizes in each case, so that the full set of available sizes is as follows. 4KB: 64KB 2MB 32MB 1GB 64KB: 2MB 512MB 16GB If a 16KB granule is used then the contiguous bit groups 128 pages at the PTE level and 32 pages at the PMD level. If the base page size is set to 64KB then 2MB pages are enabled by default. It is possible in the future to make 2MB the default huge page size for both 4KB and 64KB granules. Reviewed-by: Chris Metcalf <cmetcalf@ezchip.com> Reviewed-by: Steve Capper <steve.capper@linaro.org> Signed-off-by: David Woods <dwoods@ezchip.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/include/asm')
-rw-r--r--arch/arm64/include/asm/hugetlb.h44
-rw-r--r--arch/arm64/include/asm/pgtable-hwdef.h18
-rw-r--r--arch/arm64/include/asm/pgtable.h10
3 files changed, 40 insertions, 32 deletions
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index bb4052e85dba..bbc1e35aa601 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -26,36 +26,7 @@ static inline pte_t huge_ptep_get(pte_t *ptep)
26 return *ptep; 26 return *ptep;
27} 27}
28 28
29static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
30 pte_t *ptep, pte_t pte)
31{
32 set_pte_at(mm, addr, ptep, pte);
33}
34
35static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
36 unsigned long addr, pte_t *ptep)
37{
38 ptep_clear_flush(vma, addr, ptep);
39}
40
41static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
42 unsigned long addr, pte_t *ptep)
43{
44 ptep_set_wrprotect(mm, addr, ptep);
45}
46 29
47static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
48 unsigned long addr, pte_t *ptep)
49{
50 return ptep_get_and_clear(mm, addr, ptep);
51}
52
53static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
54 unsigned long addr, pte_t *ptep,
55 pte_t pte, int dirty)
56{
57 return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
58}
59 30
60static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb, 31static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
61 unsigned long addr, unsigned long end, 32 unsigned long addr, unsigned long end,
@@ -97,4 +68,19 @@ static inline void arch_clear_hugepage_flags(struct page *page)
97 clear_bit(PG_dcache_clean, &page->flags); 68 clear_bit(PG_dcache_clean, &page->flags);
98} 69}
99 70
71extern pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
72 struct page *page, int writable);
73#define arch_make_huge_pte arch_make_huge_pte
74extern void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
75 pte_t *ptep, pte_t pte);
76extern int huge_ptep_set_access_flags(struct vm_area_struct *vma,
77 unsigned long addr, pte_t *ptep,
78 pte_t pte, int dirty);
79extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
80 unsigned long addr, pte_t *ptep);
81extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
82 unsigned long addr, pte_t *ptep);
83extern void huge_ptep_clear_flush(struct vm_area_struct *vma,
84 unsigned long addr, pte_t *ptep);
85
100#endif /* __ASM_HUGETLB_H */ 86#endif /* __ASM_HUGETLB_H */
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index d6739e836f7b..5c25b831273d 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -90,7 +90,23 @@
90/* 90/*
91 * Contiguous page definitions. 91 * Contiguous page definitions.
92 */ 92 */
93#define CONT_PTES (_AC(1, UL) << CONT_SHIFT) 93#ifdef CONFIG_ARM64_64K_PAGES
94#define CONT_PTE_SHIFT 5
95#define CONT_PMD_SHIFT 5
96#elif defined(CONFIG_ARM64_16K_PAGES)
97#define CONT_PTE_SHIFT 7
98#define CONT_PMD_SHIFT 5
99#else
100#define CONT_PTE_SHIFT 4
101#define CONT_PMD_SHIFT 4
102#endif
103
104#define CONT_PTES (1 << CONT_PTE_SHIFT)
105#define CONT_PTE_SIZE (CONT_PTES * PAGE_SIZE)
106#define CONT_PTE_MASK (~(CONT_PTE_SIZE - 1))
107#define CONT_PMDS (1 << CONT_PMD_SHIFT)
108#define CONT_PMD_SIZE (CONT_PMDS * PMD_SIZE)
109#define CONT_PMD_MASK (~(CONT_PMD_SIZE - 1))
94/* the the numerical offset of the PTE within a range of CONT_PTES */ 110/* the the numerical offset of the PTE within a range of CONT_PTES */
95#define CONT_RANGE_OFFSET(addr) (((addr)>>PAGE_SHIFT)&(CONT_PTES-1)) 111#define CONT_RANGE_OFFSET(addr) (((addr)>>PAGE_SHIFT)&(CONT_PTES-1))
96 112
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 450b355f3f49..35a318c2fd87 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -227,7 +227,8 @@ static inline pte_t pte_mkspecial(pte_t pte)
227 227
228static inline pte_t pte_mkcont(pte_t pte) 228static inline pte_t pte_mkcont(pte_t pte)
229{ 229{
230 return set_pte_bit(pte, __pgprot(PTE_CONT)); 230 pte = set_pte_bit(pte, __pgprot(PTE_CONT));
231 return set_pte_bit(pte, __pgprot(PTE_TYPE_PAGE));
231} 232}
232 233
233static inline pte_t pte_mknoncont(pte_t pte) 234static inline pte_t pte_mknoncont(pte_t pte)
@@ -235,6 +236,11 @@ static inline pte_t pte_mknoncont(pte_t pte)
235 return clear_pte_bit(pte, __pgprot(PTE_CONT)); 236 return clear_pte_bit(pte, __pgprot(PTE_CONT));
236} 237}
237 238
239static inline pmd_t pmd_mkcont(pmd_t pmd)
240{
241 return __pmd(pmd_val(pmd) | PMD_SECT_CONT);
242}
243
238static inline void set_pte(pte_t *ptep, pte_t pte) 244static inline void set_pte(pte_t *ptep, pte_t pte)
239{ 245{
240 *ptep = pte; 246 *ptep = pte;
@@ -304,7 +310,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
304/* 310/*
305 * Hugetlb definitions. 311 * Hugetlb definitions.
306 */ 312 */
307#define HUGE_MAX_HSTATE 2 313#define HUGE_MAX_HSTATE 4
308#define HPAGE_SHIFT PMD_SHIFT 314#define HPAGE_SHIFT PMD_SHIFT
309#define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT) 315#define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT)
310#define HPAGE_MASK (~(HPAGE_SIZE - 1)) 316#define HPAGE_MASK (~(HPAGE_SIZE - 1))