Re: [PATCH v7 3.2-rc2 9/30] uprobes: Background page replacement.

From: Peter Zijlstra
Date: Fri Nov 25 2011 - 09:54:03 EST


On Fri, 2011-11-18 at 16:38 +0530, Srikar Dronamraju wrote:
> +static int read_opcode(struct mm_struct *mm, unsigned long vaddr,
> + uprobe_opcode_t *opcode)
> +{
> + struct page *page;
> + void *vaddr_new;
> + int ret;
> +
> + ret = get_user_pages(NULL, mm, vaddr, 1, 0, 0, &page, NULL);
> + if (ret <= 0)
> + return ret;
> +
> + lock_page(page);
> + vaddr_new = kmap_atomic(page);
> + vaddr &= ~PAGE_MASK;

BUG_ON(vaddr + uprobe_opcode_sz >= PAGE_SIZE);

> + memcpy(opcode, vaddr_new + vaddr, uprobe_opcode_sz);
> + kunmap_atomic(vaddr_new);
> + unlock_page(page);
> + put_page(page); /* we did a get_user_pages in the beginning */
> + return 0;
> +}

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