aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Capper <steve.capper@arm.com>2017-08-22 06:42:42 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2017-08-22 10:51:55 -0400
commitb5b0be86d7181ed82cee9d8ac5073a48f038a305 (patch)
tree8c4e1cd449242c7689199c7997764f78b82565d2
parentd3ea79527757ba65b3ee08e10c59a3c84f34e4bf (diff)
arm64: hugetlb: Introduce pte_pgprot helper
Rather than xor pte bits in various places, use this helper function. Cc: David Woods <dwoods@mellanox.com> Signed-off-by: Steve Capper <steve.capper@arm.com> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/mm/hugetlbpage.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 7b61e4833432..cb84ca33bc6b 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -41,6 +41,16 @@ int pud_huge(pud_t pud)
41#endif 41#endif
42} 42}
43 43
44/*
45 * Select all bits except the pfn
46 */
47static inline pgprot_t pte_pgprot(pte_t pte)
48{
49 unsigned long pfn = pte_pfn(pte);
50
51 return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
52}
53
44static int find_num_contig(struct mm_struct *mm, unsigned long addr, 54static int find_num_contig(struct mm_struct *mm, unsigned long addr,
45 pte_t *ptep, size_t *pgsize) 55 pte_t *ptep, size_t *pgsize)
46{ 56{
@@ -80,7 +90,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
80 90
81 ncontig = find_num_contig(mm, addr, ptep, &pgsize); 91 ncontig = find_num_contig(mm, addr, ptep, &pgsize);
82 pfn = pte_pfn(pte); 92 pfn = pte_pfn(pte);
83 hugeprot = __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte)); 93 hugeprot = pte_pgprot(pte);
84 for (i = 0; i < ncontig; i++) { 94 for (i = 0; i < ncontig; i++) {
85 pr_debug("%s: set pte %p to 0x%llx\n", __func__, ptep, 95 pr_debug("%s: set pte %p to 0x%llx\n", __func__, ptep,
86 pte_val(pfn_pte(pfn, hugeprot))); 96 pte_val(pfn_pte(pfn, hugeprot)));
@@ -223,9 +233,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
223 size_t pgsize = 0; 233 size_t pgsize = 0;
224 unsigned long pfn = pte_pfn(pte); 234 unsigned long pfn = pte_pfn(pte);
225 /* Select all bits except the pfn */ 235 /* Select all bits except the pfn */
226 pgprot_t hugeprot = 236 pgprot_t hugeprot = pte_pgprot(pte);
227 __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^
228 pte_val(pte));
229 237
230 pfn = pte_pfn(pte); 238 pfn = pte_pfn(pte);
231 ncontig = find_num_contig(vma->vm_mm, addr, ptep, 239 ncontig = find_num_contig(vma->vm_mm, addr, ptep,