Lines Matching +full:write +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 * Copyright (C) 1995 - 2000 by Ralf Baechle
13 #include <linux/entry-common.h>
34 static int __kprobes spurious_fault(unsigned long write, unsigned long address) in spurious_fault() argument
43 return 0; in spurious_fault()
47 return 0; in spurious_fault()
51 return 0; in spurious_fault()
55 return 0; in spurious_fault()
59 return 0; in spurious_fault()
62 return write ? pmd_write(pmdp_get(pmd)) : 1; in spurious_fault()
66 return 0; in spurious_fault()
68 return write ? pte_write(ptep_get(pte)) : 1; in spurious_fault()
73 unsigned long write, unsigned long address) in no_context() argument
77 if (spurious_fault(write, address)) in no_context()
84 if (kfence_handle_page_fault(address, write, regs)) in no_context()
94 "virtual address %0*lx, era == %0*lx, ra == %0*lx\n", in no_context()
95 raw_smp_processor_id(), field, address, field, regs->csr_era, in no_context()
96 field, regs->regs[1]); in no_context()
101 unsigned long write, unsigned long address) in do_out_of_memory() argument
105 * (which will retry the fault, or kill us if we got oom-killed). in do_out_of_memory()
108 no_context(regs, write, address); in do_out_of_memory()
115 unsigned long write, unsigned long address, int si_code) in do_sigbus() argument
119 no_context(regs, write, address); in do_sigbus()
127 current->thread.csr_badvaddr = address; in do_sigbus()
128 current->thread.trap_nr = read_csr_excode(); in do_sigbus()
133 unsigned long write, unsigned long address, int si_code) in do_sigsegv() argument
140 no_context(regs, write, address); in do_sigsegv()
145 current->thread.csr_badvaddr = address; in do_sigsegv()
146 if (!write) in do_sigsegv()
147 current->thread.error_code = 1; in do_sigsegv()
149 current->thread.error_code = 2; in do_sigsegv()
150 current->thread.trap_nr = read_csr_excode(); in do_sigsegv()
154 pr_info("do_page_fault(): sending SIGSEGV to %s for invalid %s %0*lx\n", in do_sigsegv()
155 current->comm, in do_sigsegv()
156 write ? "write access to" : "read access from", in do_sigsegv()
158 pr_info("era = %0*lx in", field, in do_sigsegv()
159 (unsigned long) regs->csr_era); in do_sigsegv()
160 print_vma_addr(KERN_CONT " ", regs->csr_era); in do_sigsegv()
162 pr_info("ra = %0*lx in", field, in do_sigsegv()
163 (unsigned long) regs->regs[1]); in do_sigsegv()
164 print_vma_addr(KERN_CONT " ", regs->regs[1]); in do_sigsegv()
176 unsigned long write, unsigned long address) in __do_page_fault() argument
181 struct mm_struct *mm = tsk->mm; in __do_page_fault()
185 if (kprobe_page_fault(regs, current->thread.trap_nr)) in __do_page_fault()
189 * We fault-in kernel-space virtual memory on-demand. The in __do_page_fault()
199 no_context(regs, write, address); in __do_page_fault()
201 do_sigsegv(regs, write, address, si_code); in __do_page_fault()
210 do_sigsegv(regs, write, address, si_code); in __do_page_fault()
231 do_sigsegv(regs, write, address, si_code); in __do_page_fault()
241 if (write) { in __do_page_fault()
243 if (!(vma->vm_flags & VM_WRITE)) in __do_page_fault()
246 if (!(vma->vm_flags & VM_EXEC) && address == exception_era(regs)) in __do_page_fault()
248 if (!(vma->vm_flags & (VM_READ | VM_WRITE)) && address != exception_era(regs)) in __do_page_fault()
261 no_context(regs, write, address); in __do_page_fault()
282 do_out_of_memory(regs, write, address); in __do_page_fault()
285 do_sigsegv(regs, write, address, si_code); in __do_page_fault()
288 do_sigbus(regs, write, address, si_code); in __do_page_fault()
298 unsigned long write, unsigned long address) in do_page_fault() argument
303 if (likely(regs->csr_prmd & CSR_PRMD_PIE)) in do_page_fault()
306 __do_page_fault(regs, write, address); in do_page_fault()