summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/access_process_vm.h57
-rw-r--r--tapsets.cxx4
-rw-r--r--translate.cxx1
3 files changed, 57 insertions, 5 deletions
diff --git a/runtime/access_process_vm.h b/runtime/access_process_vm.h
index 70489d48..eda160e9 100644
--- a/runtime/access_process_vm.h
+++ b/runtime/access_process_vm.h
@@ -5,7 +5,17 @@
*/
#include <linux/pagemap.h>
#include <asm/cacheflush.h>
-static int __access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
+
+static int
+__access_process_vm_(struct task_struct *tsk, unsigned long addr, void *buf,
+ int len, int write,
+ void (*writer)(struct vm_area_struct *vma,
+ struct page *page, unsigned long vaddr,
+ void *dst, void *src, int len),
+ void (*reader)(struct vm_area_struct *vma,
+ struct page *page, unsigned long vaddr,
+ void *dst, void *src, int len)
+)
{
struct mm_struct *mm;
struct vm_area_struct *vma;
@@ -34,11 +44,11 @@ static int __access_process_vm(struct task_struct *tsk, unsigned long addr, void
maddr = kmap(page);
if (write) {
- copy_to_user_page(vma, page, addr,
+ writer(vma, page, addr,
maddr + offset, buf, bytes);
set_page_dirty_lock(page);
} else {
- copy_from_user_page(vma, page, addr,
+ reader(vma, page, addr,
buf, maddr + offset, bytes);
}
kunmap(page);
@@ -52,3 +62,44 @@ static int __access_process_vm(struct task_struct *tsk, unsigned long addr, void
return buf - old_buf;
}
+
+static void
+copy_to_user_page_ (struct vm_area_struct *vma, struct page *page, unsigned long vaddr,
+ void *dst, void *src, int len)
+{
+ copy_to_user_page (vma, page, vaddr, dst, src, len);
+}
+
+static void
+copy_from_user_page_ (struct vm_area_struct *vma, struct page *page, unsigned long vaddr,
+ void *dst, void *src, int len)
+{
+ copy_from_user_page (vma, page, vaddr, dst, src, len);
+}
+
+static int __access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
+{
+ return __access_process_vm_(tsk, addr, buf, len, write, copy_to_user_page_, copy_from_user_page_);
+}
+
+/* This simpler version does not flush the caches. */
+
+static void
+copy_to_user_page_noflush (struct vm_area_struct *vma, struct page *page, unsigned long vaddr,
+ void *dst, void *src, int len)
+{
+ memcpy (dst, src, len);
+}
+
+static void
+copy_from_user_page_noflush (struct vm_area_struct *vma, struct page *page, unsigned long vaddr,
+ void *dst, void *src, int len)
+{
+ memcpy (dst, src, len);
+}
+
+static int __access_process_vm_noflush(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
+{
+ return __access_process_vm_(tsk, addr, buf, len, write, copy_to_user_page_noflush, copy_from_user_page_noflush);
+}
+
diff --git a/tapsets.cxx b/tapsets.cxx
index 4b6305b2..83c626df 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -5146,12 +5146,12 @@ uprobe_derived_probe_group::emit_module_exit (systemtap_session& s)
s.op->newline() << "#endif /* 2.6.31 */";
s.op->newline() << "if (tsk) {"; // just in case the thing exited while we weren't watching
- s.op->newline(1) << "if (get_user (sdt_semaphore, (unsigned short __user*) sup->sdt_sem_address) == 0) {";
+ s.op->newline(1) << "if (__access_process_vm_noflush(tsk, sup->sdt_sem_address, &sdt_semaphore, sizeof(sdt_semaphore), 0)) {";
s.op->newline(1) << "sdt_semaphore --;";
s.op->newline() << "#ifdef DEBUG_UPROBES";
s.op->newline() << "_stp_dbug (__FUNCTION__,__LINE__, \"-semaphore %#x @ %#lx\\n\", sdt_semaphore, sup->sdt_sem_address);";
s.op->newline() << "#endif";
- s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user*) sup->sdt_sem_address);";
+ s.op->newline() << "__access_process_vm_noflush(tsk, sup->sdt_sem_address, &sdt_semaphore, sizeof(sdt_semaphore), 1);";
s.op->newline(-1) << "}";
// XXX: need to analyze possibility of race condition
s.op->newline(-1) << "}";
diff --git a/translate.cxx b/translate.cxx
index 88e69a66..81b8bef5 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -5238,6 +5238,7 @@ translate_pass (systemtap_session& s)
s.op->newline() << "#include <linux/version.h>";
// s.op->newline() << "#include <linux/compile.h>";
s.op->newline() << "#include \"loc2c-runtime.h\" ";
+ s.op->newline() << "#include \"access_process_vm.h\" ";
s.up->emit_common_header (); // context etc.