Messages in this thread | | | Date | Sat, 22 Dec 2012 17:02:28 +0100 | From | Oleg Nesterov <> | Subject | Re: [RFC PATCH 2/6] uretprobes: trampoline implementation |
| |
On 12/21, Anton Arapov wrote: > > +static unsigned long xol_get_trampoline_slot(void) > +{ > + struct xol_area *area; > + unsigned long offset; > + void *vaddr; > + uprobe_opcode_t bp_insn = UPROBE_SWBP_INSN; > + > + area = get_xol_area(current->mm); > + if (!area) { > + area = xol_alloc_area(); > + if (!area) > + return 0; > + } > + > + if (!area->rp_trampoline_vaddr) > + area->rp_trampoline_vaddr = xol_take_insn_slot(area); > + > + /* > + * Initialize the slot if rp_trampoline_vaddr points to valid > + * instruction slot. > + */ > + if (unlikely(!area->rp_trampoline_vaddr)) > + return 0; > + > + offset = area->rp_trampoline_vaddr & ~PAGE_MASK; > + vaddr = kmap_atomic(area->page); > + memcpy(vaddr + offset, &bp_insn, UPROBE_SWBP_INSN_SIZE); > + kunmap_atomic(vaddr); > + > + return area->rp_trampoline_vaddr; > +}
Oh, this should be unified with xol_get_insn_slot(), we certainly do not want to copy-and-paste it.
Or. Perhaps even better, do not add this helper at all. xol_alloc_area() could reserve the first slot/bit for trampoline. And note that in this case we do not need xol_area->rp_trampoline_vaddr, it is always equal to xol_area->vaddr.
Oleg.
| |