diff options
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r-- | arch/powerpc/mm/book3s64/iommu_api.c | 41 | ||||
-rw-r--r-- | arch/powerpc/mm/book3s64/radix_pgtable.c | 5 | ||||
-rw-r--r-- | arch/powerpc/mm/fault.c | 23 |
3 files changed, 11 insertions, 58 deletions
diff --git a/arch/powerpc/mm/book3s64/iommu_api.c b/arch/powerpc/mm/book3s64/iommu_api.c index 90ee3a89722c..b056cae3388b 100644 --- a/arch/powerpc/mm/book3s64/iommu_api.c +++ b/arch/powerpc/mm/book3s64/iommu_api.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/hugetlb.h> | 14 | #include <linux/hugetlb.h> |
15 | #include <linux/swap.h> | 15 | #include <linux/swap.h> |
16 | #include <linux/sizes.h> | 16 | #include <linux/sizes.h> |
17 | #include <linux/mm.h> | ||
17 | #include <asm/mmu_context.h> | 18 | #include <asm/mmu_context.h> |
18 | #include <asm/pte-walk.h> | 19 | #include <asm/pte-walk.h> |
19 | #include <linux/mm_inline.h> | 20 | #include <linux/mm_inline.h> |
@@ -46,40 +47,6 @@ struct mm_iommu_table_group_mem_t { | |||
46 | u64 dev_hpa; /* Device memory base address */ | 47 | u64 dev_hpa; /* Device memory base address */ |
47 | }; | 48 | }; |
48 | 49 | ||
49 | static long mm_iommu_adjust_locked_vm(struct mm_struct *mm, | ||
50 | unsigned long npages, bool incr) | ||
51 | { | ||
52 | long ret = 0, locked, lock_limit; | ||
53 | |||
54 | if (!npages) | ||
55 | return 0; | ||
56 | |||
57 | down_write(&mm->mmap_sem); | ||
58 | |||
59 | if (incr) { | ||
60 | locked = mm->locked_vm + npages; | ||
61 | lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; | ||
62 | if (locked > lock_limit && !capable(CAP_IPC_LOCK)) | ||
63 | ret = -ENOMEM; | ||
64 | else | ||
65 | mm->locked_vm += npages; | ||
66 | } else { | ||
67 | if (WARN_ON_ONCE(npages > mm->locked_vm)) | ||
68 | npages = mm->locked_vm; | ||
69 | mm->locked_vm -= npages; | ||
70 | } | ||
71 | |||
72 | pr_debug("[%d] RLIMIT_MEMLOCK HASH64 %c%ld %ld/%ld\n", | ||
73 | current ? current->pid : 0, | ||
74 | incr ? '+' : '-', | ||
75 | npages << PAGE_SHIFT, | ||
76 | mm->locked_vm << PAGE_SHIFT, | ||
77 | rlimit(RLIMIT_MEMLOCK)); | ||
78 | up_write(&mm->mmap_sem); | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | bool mm_iommu_preregistered(struct mm_struct *mm) | 50 | bool mm_iommu_preregistered(struct mm_struct *mm) |
84 | { | 51 | { |
85 | return !list_empty(&mm->context.iommu_group_mem_list); | 52 | return !list_empty(&mm->context.iommu_group_mem_list); |
@@ -96,7 +63,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, unsigned long ua, | |||
96 | unsigned long entry, chunk; | 63 | unsigned long entry, chunk; |
97 | 64 | ||
98 | if (dev_hpa == MM_IOMMU_TABLE_INVALID_HPA) { | 65 | if (dev_hpa == MM_IOMMU_TABLE_INVALID_HPA) { |
99 | ret = mm_iommu_adjust_locked_vm(mm, entries, true); | 66 | ret = account_locked_vm(mm, entries, true); |
100 | if (ret) | 67 | if (ret) |
101 | return ret; | 68 | return ret; |
102 | 69 | ||
@@ -211,7 +178,7 @@ free_exit: | |||
211 | kfree(mem); | 178 | kfree(mem); |
212 | 179 | ||
213 | unlock_exit: | 180 | unlock_exit: |
214 | mm_iommu_adjust_locked_vm(mm, locked_entries, false); | 181 | account_locked_vm(mm, locked_entries, false); |
215 | 182 | ||
216 | return ret; | 183 | return ret; |
217 | } | 184 | } |
@@ -311,7 +278,7 @@ long mm_iommu_put(struct mm_struct *mm, struct mm_iommu_table_group_mem_t *mem) | |||
311 | unlock_exit: | 278 | unlock_exit: |
312 | mutex_unlock(&mem_list_mutex); | 279 | mutex_unlock(&mem_list_mutex); |
313 | 280 | ||
314 | mm_iommu_adjust_locked_vm(mm, unlock_entries, false); | 281 | account_locked_vm(mm, unlock_entries, false); |
315 | 282 | ||
316 | return ret; | 283 | return ret; |
317 | } | 284 | } |
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index 65c2ba1e1783..b4ca9e95e678 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c | |||
@@ -1237,3 +1237,8 @@ int radix__ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, | |||
1237 | return 0; | 1237 | return 0; |
1238 | } | 1238 | } |
1239 | } | 1239 | } |
1240 | |||
1241 | int __init arch_ioremap_p4d_supported(void) | ||
1242 | { | ||
1243 | return 0; | ||
1244 | } | ||
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index d989592b6fc8..8432c281de92 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c | |||
@@ -42,26 +42,6 @@ | |||
42 | #include <asm/debug.h> | 42 | #include <asm/debug.h> |
43 | #include <asm/kup.h> | 43 | #include <asm/kup.h> |
44 | 44 | ||
45 | static inline bool notify_page_fault(struct pt_regs *regs) | ||
46 | { | ||
47 | bool ret = false; | ||
48 | |||
49 | #ifdef CONFIG_KPROBES | ||
50 | /* kprobe_running() needs smp_processor_id() */ | ||
51 | if (!user_mode(regs)) { | ||
52 | preempt_disable(); | ||
53 | if (kprobe_running() && kprobe_fault_handler(regs, 11)) | ||
54 | ret = true; | ||
55 | preempt_enable(); | ||
56 | } | ||
57 | #endif /* CONFIG_KPROBES */ | ||
58 | |||
59 | if (unlikely(debugger_fault_handler(regs))) | ||
60 | ret = true; | ||
61 | |||
62 | return ret; | ||
63 | } | ||
64 | |||
65 | /* | 45 | /* |
66 | * Check whether the instruction inst is a store using | 46 | * Check whether the instruction inst is a store using |
67 | * an update addressing form which will update r1. | 47 | * an update addressing form which will update r1. |
@@ -461,8 +441,9 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, | |||
461 | int is_write = page_fault_is_write(error_code); | 441 | int is_write = page_fault_is_write(error_code); |
462 | vm_fault_t fault, major = 0; | 442 | vm_fault_t fault, major = 0; |
463 | bool must_retry = false; | 443 | bool must_retry = false; |
444 | bool kprobe_fault = kprobe_page_fault(regs, 11); | ||
464 | 445 | ||
465 | if (notify_page_fault(regs)) | 446 | if (unlikely(debugger_fault_handler(regs) || kprobe_fault)) |
466 | return 0; | 447 | return 0; |
467 | 448 | ||
468 | if (unlikely(page_fault_is_bad(error_code))) { | 449 | if (unlikely(page_fault_is_bad(error_code))) { |