Lines Matching +full:pre +full:- +full:processing
1 // SPDX-License-Identifier: GPL-2.0+
24 #include <asm/text-patching.h>
53 len = insn_length(*p->addr >> 8); in copy_instruction()
54 memcpy(&insn, p->addr, len); in copy_instruction()
55 p->opcode = insn[0]; in copy_instruction()
58 * For pc-relative instructions in RIL-b or RIL-c format patch in copy_instruction()
65 addr = (u64)(unsigned long)p->addr; in copy_instruction()
66 new_addr = (u64)(unsigned long)p->ainsn.insn; in copy_instruction()
67 new_disp = ((addr + (disp * 2)) - new_addr) / 2; in copy_instruction()
70 s390_kernel_write(p->ainsn.insn, &insn, len); in copy_instruction()
88 addr = paddr - offset; in can_probe()
113 insn = kp->opcode; in can_probe()
122 if (!can_probe((unsigned long)p->addr)) in arch_prepare_kprobe()
123 return -EINVAL; in arch_prepare_kprobe()
125 if (probe_is_prohibited_opcode(p->addr)) in arch_prepare_kprobe()
126 return -EINVAL; in arch_prepare_kprobe()
127 p->ainsn.insn = get_insn_slot(); in arch_prepare_kprobe()
128 if (!p->ainsn.insn) in arch_prepare_kprobe()
129 return -ENOMEM; in arch_prepare_kprobe()
143 struct kprobe *p = args->p; in swap_instruction()
146 opc = args->arm_kprobe ? BREAKPOINT_INSTRUCTION : p->opcode; in swap_instruction()
147 s390_kernel_write(p->addr, &opc, sizeof(opc)); in swap_instruction()
180 if (!p->ainsn.insn) in arch_remove_kprobe()
182 free_insn_slot(p->ainsn.insn, 0); in arch_remove_kprobe()
183 p->ainsn.insn = NULL; in arch_remove_kprobe()
200 /* Set up the PER control registers %cr9-%cr11 */ in enable_singlestep()
206 __local_ctl_store(9, 11, kcb->kprobe_saved_ctl); in enable_singlestep()
207 kcb->kprobe_saved_imask = regs->psw.mask & in enable_singlestep()
212 regs->psw.mask |= PSW_MASK_PER; in enable_singlestep()
213 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT); in enable_singlestep()
214 regs->psw.addr = ip; in enable_singlestep()
223 __local_ctl_load(9, 11, kcb->kprobe_saved_ctl); in disable_singlestep()
224 regs->psw.mask &= ~PSW_MASK_PER; in disable_singlestep()
225 regs->psw.mask |= kcb->kprobe_saved_imask; in disable_singlestep()
226 regs->psw.addr = ip; in disable_singlestep()
232 * previous kprobe is stored in kcb->prev_kprobe. A stack of up to
237 kcb->prev_kprobe.kp = __this_cpu_read(current_kprobe); in push_kprobe()
238 kcb->prev_kprobe.status = kcb->kprobe_status; in push_kprobe()
245 * current state is KPROBE_REENTER prev_kprobe.kp will be non-NULL,
250 __this_cpu_write(current_kprobe, kcb->prev_kprobe.kp); in pop_kprobe()
251 kcb->kprobe_status = kcb->prev_kprobe.status; in pop_kprobe()
252 kcb->prev_kprobe.kp = NULL; in pop_kprobe()
258 switch (kcb->kprobe_status) { in kprobe_reenter_check()
285 * processing. That includes the calls to the pre/post handlers in kprobe_handler()
290 p = get_kprobe((void *)(regs->psw.addr - 2)); in kprobe_handler()
296 * active. This can happen in the pre and post in kprobe_handler()
305 kcb->kprobe_status = KPROBE_REENTER; in kprobe_handler()
308 * If we have no pre-handler or it returned 0, we in kprobe_handler()
310 * pre-handler and it returned non-zero, it prepped in kprobe_handler()
315 kcb->kprobe_status = KPROBE_HIT_ACTIVE; in kprobe_handler()
316 if (p->pre_handler && p->pre_handler(p, regs)) { in kprobe_handler()
321 kcb->kprobe_status = KPROBE_HIT_SS; in kprobe_handler()
323 enable_singlestep(kcb, regs, (unsigned long) p->ainsn.insn); in kprobe_handler()
337 * Called after single-stepping. p->addr is the address of the
340 * temporarily put back the original opcode to single-step, we
341 * single-stepped a copy of the instruction. The address of this
342 * copy is p->ainsn.insn.
347 unsigned long ip = regs->psw.addr; in resume_execution()
348 int fixup = probe_get_fixup_type(p->ainsn.insn); in resume_execution()
351 ip += (unsigned long) p->addr - (unsigned long) p->ainsn.insn; in resume_execution()
354 int ilen = insn_length(p->ainsn.insn[0] >> 8); in resume_execution()
355 if (ip - (unsigned long) p->ainsn.insn == ilen) in resume_execution()
356 ip = (unsigned long) p->addr + ilen; in resume_execution()
360 int reg = (p->ainsn.insn[0] & 0xf0) >> 4; in resume_execution()
361 regs->gprs[reg] += (unsigned long) p->addr - in resume_execution()
362 (unsigned long) p->ainsn.insn; in resume_execution()
378 if (kcb->kprobe_status != KPROBE_REENTER && p->post_handler) { in post_kprobe_handler()
379 kcb->kprobe_status = KPROBE_HIT_SSDONE; in post_kprobe_handler()
380 p->post_handler(p, regs, 0); in post_kprobe_handler()
387 * will have PER set, in which case, continue the remaining processing in post_kprobe_handler()
390 if (regs->psw.mask & PSW_MASK_PER) in post_kprobe_handler()
402 switch(kcb->kprobe_status) { in kprobe_trap_handler()
412 disable_singlestep(kcb, regs, (unsigned long) p->addr); in kprobe_trap_handler()
419 * In case the user-specified fault handler returned in kprobe_trap_handler()
440 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT)) in kprobe_fault_handler()
443 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT)) in kprobe_fault_handler()
444 local_irq_restore(regs->psw.mask & ~PSW_MASK_PER); in kprobe_fault_handler()
456 struct pt_regs *regs = args->regs; in kprobe_exceptions_notify()
459 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT)) in kprobe_exceptions_notify()
473 kprobe_trap_handler(regs, args->trapnr)) in kprobe_exceptions_notify()
480 if (regs->psw.mask & (PSW_MASK_IO | PSW_MASK_EXT)) in kprobe_exceptions_notify()
481 local_irq_restore(regs->psw.mask & ~PSW_MASK_PER); in kprobe_exceptions_notify()