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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to