Lines Matching +full:len +full:- +full:or +full:- +full:limit
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2007-2008 Paul Mackerras, IBM Corp.
24 struct subpage_prot_table *spt = mm_ctx_subpage_prot(&mm->context); in subpage_prot_free()
32 if (spt->low_prot[i]) { in subpage_prot_free()
33 free_page((unsigned long)spt->low_prot[i]); in subpage_prot_free()
34 spt->low_prot[i] = NULL; in subpage_prot_free()
39 p = spt->protptrs[i]; in subpage_prot_free()
42 spt->protptrs[i] = NULL; in subpage_prot_free()
43 for (j = 0; j < SBP_L2_COUNT && addr < spt->maxaddr; in subpage_prot_free()
49 spt->maxaddr = 0; in subpage_prot_free()
77 for (; npages > 0; --npages) { in hpte_flush_range()
83 pte_unmap_unlock(pte - 1, ptl); in hpte_flush_range()
90 static void subpage_prot_clear(unsigned long addr, unsigned long len) in subpage_prot_clear() argument
92 struct mm_struct *mm = current->mm; in subpage_prot_clear()
97 unsigned long next, limit; in subpage_prot_clear() local
101 spt = mm_ctx_subpage_prot(&mm->context); in subpage_prot_clear()
105 limit = addr + len; in subpage_prot_clear()
106 if (limit > spt->maxaddr) in subpage_prot_clear()
107 limit = spt->maxaddr; in subpage_prot_clear()
108 for (; addr < limit; addr = next) { in subpage_prot_clear()
109 next = pmd_addr_end(addr, limit); in subpage_prot_clear()
111 spm = spt->low_prot; in subpage_prot_clear()
113 spm = spt->protptrs[addr >> SBP_L3_SHIFT]; in subpage_prot_clear()
117 spp = spm[(addr >> SBP_L2_SHIFT) & (SBP_L2_COUNT - 1)]; in subpage_prot_clear()
120 spp += (addr >> PAGE_SHIFT) & (SBP_L1_COUNT - 1); in subpage_prot_clear()
122 i = (addr >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); in subpage_prot_clear()
123 nw = PTRS_PER_PTE - i; in subpage_prot_clear()
125 nw = (next - addr) >> PAGE_SHIFT; in subpage_prot_clear()
141 struct vm_area_struct *vma = walk->vma; in subpage_walk_pmd_entry()
152 unsigned long len) in subpage_mark_vma_nohuge() argument
161 for_each_vma_range(vmi, vma, addr + len) { in subpage_mark_vma_nohuge()
168 unsigned long len) in subpage_mark_vma_nohuge() argument
177 * Each 2-bit field is 0 to allow any access, 1 to prevent writes,
178 * 2 or 3 to prevent all accesses.
181 * in a 2-bit field won't allow writes to a page that is otherwise
182 * write-protected.
185 unsigned long, len, u32 __user *, map) in SYSCALL_DEFINE3() argument
187 struct mm_struct *mm = current->mm; in SYSCALL_DEFINE3()
192 unsigned long next, limit; in SYSCALL_DEFINE3() local
196 return -ENOENT; in SYSCALL_DEFINE3()
199 if ((addr & ~PAGE_MASK) || (len & ~PAGE_MASK) || in SYSCALL_DEFINE3()
200 addr >= mm->task_size || len >= mm->task_size || in SYSCALL_DEFINE3()
201 addr + len > mm->task_size) in SYSCALL_DEFINE3()
202 return -EINVAL; in SYSCALL_DEFINE3()
204 if (is_hugepage_only_range(mm, addr, len)) in SYSCALL_DEFINE3()
205 return -EINVAL; in SYSCALL_DEFINE3()
209 subpage_prot_clear(addr, len); in SYSCALL_DEFINE3()
213 if (!access_ok(map, (len >> PAGE_SHIFT) * sizeof(u32))) in SYSCALL_DEFINE3()
214 return -EFAULT; in SYSCALL_DEFINE3()
218 spt = mm_ctx_subpage_prot(&mm->context); in SYSCALL_DEFINE3()
226 err = -ENOMEM; in SYSCALL_DEFINE3()
229 mm->context.hash_context->spt = spt; in SYSCALL_DEFINE3()
232 subpage_mark_vma_nohuge(mm, addr, len); in SYSCALL_DEFINE3()
233 for (limit = addr + len; addr < limit; addr = next) { in SYSCALL_DEFINE3()
234 next = pmd_addr_end(addr, limit); in SYSCALL_DEFINE3()
235 err = -ENOMEM; in SYSCALL_DEFINE3()
237 spm = spt->low_prot; in SYSCALL_DEFINE3()
239 spm = spt->protptrs[addr >> SBP_L3_SHIFT]; in SYSCALL_DEFINE3()
244 spt->protptrs[addr >> SBP_L3_SHIFT] = spm; in SYSCALL_DEFINE3()
247 spm += (addr >> SBP_L2_SHIFT) & (SBP_L2_COUNT - 1); in SYSCALL_DEFINE3()
255 spp += (addr >> PAGE_SHIFT) & (SBP_L1_COUNT - 1); in SYSCALL_DEFINE3()
261 i = (addr >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); in SYSCALL_DEFINE3()
262 nw = PTRS_PER_PTE - i; in SYSCALL_DEFINE3()
264 nw = (next - addr) >> PAGE_SHIFT; in SYSCALL_DEFINE3()
268 return -EFAULT; in SYSCALL_DEFINE3()
275 if (limit > spt->maxaddr) in SYSCALL_DEFINE3()
276 spt->maxaddr = limit; in SYSCALL_DEFINE3()