summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2009-12-22 21:53:39 -0500
committerFrank Ch. Eigler <fche@elastic.org>2009-12-22 21:53:39 -0500
commit93c8419165a7c651989cc344364b86695e1f142c (patch)
tree55b8315ccdc53d935bf5720018fd93cc11151198
parentc0e4090df6dee5f6f15143f0c3ff6bacfa653c2a (diff)
downloadsystemtap-steved-93c8419165a7c651989cc344364b86695e1f142c.tar.gz
systemtap-steved-93c8419165a7c651989cc344364b86695e1f142c.tar.xz
systemtap-steved-93c8419165a7c651989cc344364b86695e1f142c.zip
sdt.h semaphore: use get_user / put_user instead of __access_process_vm.
* translate.cxx (translate_pass): Don't #include <access_blah.> * tapsets.cxx, tapset-utrace.cxx: Replace __access_process_vm() calls with get_user() / put_user() respectively.
-rw-r--r--tapset-utrace.cxx22
-rw-r--r--tapsets.cxx10
-rw-r--r--translate.cxx1
3 files changed, 14 insertions, 19 deletions
diff --git a/tapset-utrace.cxx b/tapset-utrace.cxx
index cc4f2806..e3a6fd5b 100644
--- a/tapset-utrace.cxx
+++ b/tapset-utrace.cxx
@@ -949,14 +949,14 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline(-1) << "}";
// Before writing to the semaphore, we need to check for VM_WRITE access.
- s.op->newline() << "if (p->sdt_sem_address != 0) {";
+ s.op->newline() << "if (p->sdt_sem_address) {";
s.op->newline(1) << "size_t sdt_semaphore;";
// XXX p could get registered to more than one task!
s.op->newline() << "p->tsk = tsk;";
- s.op->newline() << "if (__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 0) == sizeof (sdt_semaphore)) {";
+ s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {";
s.op->newline(1) << "sdt_semaphore ++;";
- s.op->newline() << "__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 1);";
+ s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
@@ -1043,18 +1043,14 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
- s.op->newline() << "if (p->sdt_sem_address) {";
+ s.op->newline() << "if (p->sdt_sem_address && (vm_flags & VM_WRITE)) {";
s.op->newline(1) << "unsigned short sdt_semaphore = 0;"; // NB: fixed size
- s.op->newline() << "if (__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 0) == sizeof (sdt_semaphore)) {";
-
- s.op->newline(1) << "if (vm_flags & VM_WRITE) {";
- s.op->indent(1);
- s.op->newline() << "sdt_semaphore ++;";
+ s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {";
+ s.op->newline(1) << "sdt_semaphore ++;";
s.op->newline() << "#ifdef DEBUG_UTRACE";
s.op->newline() << "_stp_dbug (__FUNCTION__,__LINE__, \"+semaphore %#x @ %#lx\\n\", sdt_semaphore, p->sdt_sem_address);";
s.op->newline() << "#endif";
- s.op->newline() << "__access_process_vm (tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 1);";
- s.op->newline(-1) << "}";
+ s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
s.op->newline() << "return 0;";
@@ -1134,9 +1130,9 @@ utrace_derived_probe_group::emit_module_exit (systemtap_session& s)
s.op->newline() << "if (p->sdt_sem_address) {";
s.op->newline(1) << "size_t sdt_semaphore;";
// XXX p could get registered to more than one task!
- s.op->newline() << "if (__access_process_vm (p->tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 0) == sizeof (sdt_semaphore)) {";
+ s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {";
s.op->newline(1) << "sdt_semaphore --;";
- s.op->newline() << "__access_process_vm (p->tsk, p->sdt_sem_address, &sdt_semaphore, sizeof (sdt_semaphore), 1);";
+ s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
diff --git a/tapsets.cxx b/tapsets.cxx
index e14cc496..bac47761 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -4869,11 +4869,11 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "if (sdt_sem_address[spec_index]) {";
s.op->newline(1) << "unsigned short sdt_semaphore = 0;"; // NB: fixed size
- s.op->newline() << "if ( __access_process_vm (tsk, sdt_sem_address[spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 0)) {";
+ s.op->newline() << "if (get_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[spec_index]) == 0) {";
// We have an executable or a writeable segment of a .so
s.op->newline(1) << "if (vm_flags == 0 || vm_flags & VM_WRITE) {";
s.op->newline(1) << "sdt_semaphore ++;";
- s.op->newline() << "__access_process_vm (tsk, sdt_sem_address[spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 1);";
+ s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[spec_index]);";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}"; // sdt_sem_address
// XXX: error handling in __access_process_vm!
@@ -5139,13 +5139,13 @@ 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 (__access_process_vm (tsk, sdt_sem_address[sup->spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 0)) {";
+ s.op->newline(1) << "if (get_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[sup->spec_index]) == 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, sdt_sem_address[sup->spec_index]);";
s.op->newline() << "#endif";
- s.op->newline() << "(void) __access_process_vm (tsk, sdt_sem_address[sup->spec_index], &sdt_semaphore, sizeof (sdt_semaphore), 1);";
- s.op->newline(-1) << "}"; // access_process_vm
+ s.op->newline() << "put_user (sdt_semaphore, (unsigned short __user*) sdt_sem_address[sup->spec_index]);";
+ s.op->newline(-1) << "}";
// XXX: error handling in __access_process_vm!
// XXX: need to analyze possibility of race condition
s.op->newline(-1) << "}";
diff --git a/translate.cxx b/translate.cxx
index 81b8bef5..88e69a66 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -5238,7 +5238,6 @@ 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.