}
}
+static inline unsigned long *
+scratch_reg(struct arch_uprobe *auprobe, struct pt_regs *regs)
+{
+ return (auprobe->def.fixups & UPROBE_FIX_RIP_AX) ? ®s->ax : ®s->cx;
+}
+
/*
* If we're emulating a rip-relative instruction, save the contents
* of the scratch register and store the target address in that register.
*/
static void riprel_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
{
- struct uprobe_task *utask = current->utask;
+ if (auprobe->def.fixups & (UPROBE_FIX_RIP_AX | UPROBE_FIX_RIP_CX)) {
+ struct uprobe_task *utask = current->utask;
+ unsigned long *sr = scratch_reg(auprobe, regs);
- if (auprobe->def.fixups & UPROBE_FIX_RIP_AX) {
- utask->autask.saved_scratch_register = regs->ax;
- regs->ax = utask->vaddr;
- regs->ax += auprobe->def.riprel_target;
- } else if (auprobe->def.fixups & UPROBE_FIX_RIP_CX) {
- utask->autask.saved_scratch_register = regs->cx;
- regs->cx = utask->vaddr;
- regs->cx += auprobe->def.riprel_target;
+ utask->autask.saved_scratch_register = *sr;
+ *sr = utask->vaddr + auprobe->def.riprel_target;
}
}
long *correction)
{
if (auprobe->def.fixups & (UPROBE_FIX_RIP_AX | UPROBE_FIX_RIP_CX)) {
- struct arch_uprobe_task *autask;
-
- autask = ¤t->utask->autask;
- if (auprobe->def.fixups & UPROBE_FIX_RIP_AX)
- regs->ax = autask->saved_scratch_register;
- else
- regs->cx = autask->saved_scratch_register;
+ struct uprobe_task *utask = current->utask;
+ unsigned long *sr = scratch_reg(auprobe, regs);
+ *sr = utask->autask.saved_scratch_register;
/*
* The original instruction includes a displacement, and so
* is 4 bytes longer than what we've just single-stepped.