lkml.org 
[lkml]   [2012]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.



\
 
 \ /
  Last update: 2012-12-22 17:41    [W:0.103 / U:1.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site