Re: [RFC] [PATCH 2/6] Kprobes: Get one pagetable entry

From: Prasanna S Panchamukhi
Date: Tue May 09 2006 - 03:01:02 EST


This patch provide a wrapper routine to allocate one page
table entry for a given virtual address address. Kprobe's
user-space probe mechanism uses this routine to get one
page table entry. As Nick Piggin suggested, this generic
routine can be used by routines like get_user_pages,
find_*_page, and other standard APIs.

Signed-off-by: Prasanna S Panchamukhi <prasanna@xxxxxxxxxx>


mm/memory.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+)

diff -puN mm/memory.c~kprobes_userspace_probes-get-one-pagetable-entry mm/memory.c
--- linux-2.6.17-rc3-mm1/mm/memory.c~kprobes_userspace_probes-get-one-pagetable-entry 2006-05-09 10:08:44.000000000 +0530
+++ linux-2.6.17-rc3-mm1-prasanna/mm/memory.c 2006-05-09 10:08:44.000000000 +0530
@@ -48,6 +48,7 @@
#include <linux/rmap.h>
#include <linux/module.h>
#include <linux/init.h>
+#include <linux/kprobes.h>

#include <asm/pgalloc.h>
#include <asm/uaccess.h>
@@ -417,6 +418,34 @@ struct page *vm_normal_page(struct vm_ar
}

/*
+ * This routines get the pte of the page containing the specified address.
+ */
+pte_t __kprobes *get_one_pte(unsigned long address)
+{
+ pgd_t *pgd;
+ pud_t *pud;
+ pmd_t *pmd;
+ pte_t *pte = NULL;
+
+ pgd = pgd_offset(current->mm, address);
+ if (!pgd)
+ goto out;
+
+ pud = pud_offset(pgd, address);
+ if (!pud)
+ goto out;
+
+ pmd = pmd_offset(pud, address);
+ if (!pmd)
+ goto out;
+
+ pte = pte_alloc_map(current->mm, pmd, address);
+
+out:
+ return pte;
+}
+
+/*
* copy one vm_area from one task to the other. Assumes the page tables
* already present in the new task to be cleared in the whole range
* covered by this vma.

_
--
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Email: prasanna@xxxxxxxxxx
Ph: 91-80-41776329
-
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/