1. 28 Jun, 2005 33 commits
  2. 27 Jun, 2005 7 commits
    • Keshavamurthy Anil S's avatar
      [PATCH] kprobes/ia64: refuse kprobe on ivt code · c7b645f9
      Keshavamurthy Anil S authored
      Not safe to insert kprobes on IVT code.
      
      This patch checks to see if the address on which Kprobes is being inserted is
      in ivt code and if it is in ivt code then refuse to register kprobe.
      Signed-off-by: default avatarAnil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Acked-by: default avatarDavid Mosberger <davidm@napali.hpl.hp.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      c7b645f9
    • Rusty Lynch's avatar
      [PATCH] kprobes/ia64: refuse inserting kprobe on slot 1 · a528e21c
      Rusty Lynch authored
      Without the ability to atomically write 16 bytes, we can not update the
      middle slot of a bundle, slot 1, unless we stop the machine first.  This
      patch will ensure the ability to robustly insert and remove a kprobe by
      refusing to insert a kprobe on slot 1 until a mechanism is in place to
      safely handle this case.
      Signed-off-by: default avatarRusty Lynch <rusty.lynch@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      a528e21c
    • Rusty Lynch's avatar
      [PATCH] Return probe redesign: ppc64 specific implementation · 97f7943d
      Rusty Lynch authored
      The following is a patch provided by Ananth Mavinakayanahalli that implements
      the new PPC64 specific parts of the new function return probe design.
      
      NOTE: Since getting Ananth's patch, I changed trampoline_probe_handler()
            to consume each of the outstanding return probem instances (feedback
            on my original RFC after Ananth cut a patch), and also added the
            arch_init() function (adding arch specific initialization.) I have
            cross compiled but have not testing this on a PPC64 machine.
      
      Changes include:
       * Addition of kretprobe_trampoline to act as a dummy function for instrumented
         functions to return to, and for the return probe infrastructure to place
         a kprobe on on, gaining control so that the return probe handler
         can be called, and so that the instruction pointer can be moved back
         to the original return address.
       * Addition of arch_init(), allowing a kprobe to be registered on
         kretprobe_trampoline
       * Addition of trampoline_probe_handler() which is used as the pre_handler
         for the kprobe inserted on kretprobe_implementation.  This is the function
         that handles the details for calling the return probe handler function
         and returning control back at the original return address
       * Addition of arch_prepare_kretprobe() which is setup as the pre_handler
         for a kprobe registered at the beginning of the target function by
         kernel/kprobes.c so that a return probe instance can be setup when
         a caller enters the target function.  (A return probe instance contains
         all the needed information for trampoline_probe_handler to do it's job.)
       * Hooks added to the exit path of a task so that we can cleanup any left-over
         return probe instances (i.e. if a task dies while inside a targeted function
         then the return probe instance was reserved at the beginning of the function
         but the function never returns so we need to mark the instance as unused.)
      Signed-off-by: default avatarRusty Lynch <rusty.lynch@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      97f7943d
    • Rusty Lynch's avatar
      [PATCH] Return probe redesign: ia64 specific implementation · 9508dbfe
      Rusty Lynch authored
      The following patch implements function return probes for ia64 using
      the revised design.  With this new design we no longer need to do some
      of the odd hacks previous required on the last ia64 return probe port
      that I sent out for comments.
      
      Note that this new implementation still does not resolve the problem noted
      by Keith Owens where backtrace data is lost after a return probe is hit.
      
      Changes include:
       * Addition of kretprobe_trampoline to act as a dummy function for instrumented
         functions to return to, and for the return probe infrastructure to place
         a kprobe on on, gaining control so that the return probe handler
         can be called, and so that the instruction pointer can be moved back
         to the original return address.
       * Addition of arch_init(), allowing a kprobe to be registered on
         kretprobe_trampoline
       * Addition of trampoline_probe_handler() which is used as the pre_handler
         for the kprobe inserted on kretprobe_implementation.  This is the function
         that handles the details for calling the return probe handler function
         and returning control back at the original return address
       * Addition of arch_prepare_kretprobe() which is setup as the pre_handler
         for a kprobe registered at the beginning of the target function by
         kernel/kprobes.c so that a return probe instance can be setup when
         a caller enters the target function.  (A return probe instance contains
         all the needed information for trampoline_probe_handler to do it's job.)
       * Hooks added to the exit path of a task so that we can cleanup any left-over
         return probe instances (i.e. if a task dies while inside a targeted function
         then the return probe instance was reserved at the beginning of the function
         but the function never returns so we need to mark the instance as unused.)
      Signed-off-by: default avatarRusty Lynch <rusty.lynch@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      9508dbfe
    • Rusty Lynch's avatar
      [PATCH] Return probe redesign: x86_64 specific changes · ba8af12f
      Rusty Lynch authored
      The following patch contains the x86_64 specific changes for the new
      return probe design.  Changes include:
       * Removing the architecture specific functions for querying a return probe
         instance off a stack address
       * Complete rework onf arch_prepare_kretprobe() and trampoline_probe_handler()
       * Removing trampoline_post_handler()
       * Adding arch_init() so that now we handle registering the return probe
         trampoline instead of kernel/kprobes.c doing it
      
      NOTE:
      Note that with this new design, the dependency on calculating a pointer to
      the task off the stack pointer no longer exist (resolving the problem of
      interruption stacks as pointed out in the original feedback to this port.)
      Signed-off-by: default avatarRusty Lynch <rusty.lynch@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      ba8af12f
    • Rusty Lynch's avatar
      [PATCH] Return probe redesign: i386 specific changes · 4bdbd37f
      Rusty Lynch authored
      The following patch contains the i386 specific changes for the new
      return probe design.  Changes include:
      
       * Removing the architecture specific functions for querying a return probe
         instance off a stack address
       * Complete rework onf arch_prepare_kretprobe() and trampoline_probe_handler()
       * Removing trampoline_post_handler()
       * Adding arch_init() so that now we handle registering the return probe
         trampoline instead of kernel/kprobes.c doing it
      Signed-off-by: default avatarRusty Lynch <rusty.lynch@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      4bdbd37f
    • Rusty Lynch's avatar
      [PATCH] Return probe redesign: architecture independent changes · 802eae7c
      Rusty Lynch authored
      The following is the second version of the function return probe patches
      I sent out earlier this week.  Changes since my last submission include:
      
      * Fix in ppc64 code removing an unneeded call to re-enable preemption
      * Fix a build problem in ia64 when kprobes was turned off
      * Added another BUG_ON check to each of the architecture trampoline
        handlers
      
      My initial patch description ==>
      
       From my experiences with adding return probes to x86_64 and ia64, and the
      feedback on LKML to those patches, I think we can simplify the design
      for return probes.
      
      The following patch tweaks the original design such that:
      
      * Instead of storing the stack address in the return probe instance, the
        task pointer is stored.  This gives us all we need in order to:
          - find the correct return probe instance when we enter the trampoline
            (even if we are recursing)
          - find all left-over return probe instances when the task is going away
      
        This has the side effect of simplifying the implementation since more
        work can be done in kernel/kprobes.c since architecture specific knowledge
        of the stack layout is no longer required.  Specifically, we no longer have:
      	- arch_get_kprobe_task()
      	- arch_kprobe_flush_task()
      	- get_rp_inst_tsk()
      	- get_rp_inst()
      	- trampoline_post_handler() <see next bullet>
      
      * Instead of splitting the return probe handling and cleanup logic across
        the pre and post trampoline handlers, all the work is pushed into the
        pre function (trampoline_probe_handler), and then we skip single stepping
        the original function.  In this case the original instruction to be single
        stepped was just a NOP, and we can do without the extra interruption.
      
      The new flow of events to having a return probe handler execute when a target
      function exits is:
      
      * At system initialization time, a kprobe is inserted at the beginning of
        kretprobe_trampoline.  kernel/kprobes.c use to handle this on it's own,
        but ia64 needed to do this a little differently (i.e. a function pointer
        is really a pointer to a structure containing the instruction pointer and
        a global pointer), so I added the notion of arch_init(), so that
        kernel/kprobes.c:init_kprobes() now allows architecture specific
        initialization by calling arch_init() before exiting.  Each architecture
        now registers a kprobe on it's own trampoline function.
      
      * register_kretprobe() will insert a kprobe at the beginning of the targeted
        function with the kprobe pre_handler set to arch_prepare_kretprobe
        (still no change)
      
      * When the target function is entered, the kprobe is fired, calling
        arch_prepare_kretprobe (still no change)
      
      * In arch_prepare_kretprobe() we try to get a free instance and if one is
        available then we fill out the instance with a pointer to the return probe,
        the original return address, and a pointer to the task structure (instead
        of the stack address.)  Just like before we change the return address
        to the trampoline function and mark the instance as used.
      
        If multiple return probes are registered for a given target function,
        then arch_prepare_kretprobe() will get called multiple times for the same
        task (since our kprobe implementation is able to handle multiple kprobes
        at the same address.)  Past the first call to arch_prepare_kretprobe,
        we end up with the original address stored in the return probe instance
        pointing to our trampoline function. (This is a significant difference
        from the original arch_prepare_kretprobe design.)
      
      * Target function executes like normal and then returns to kretprobe_trampoline.
      
      * kprobe inserted on the first instruction of kretprobe_trampoline is fired
        and calls trampoline_probe_handler() (no change here)
      
      * trampoline_probe_handler() consumes each of the instances associated with
        the current task by calling the registered handler function and marking
        the instance as unused until an instance is found that has a return address
        different then the trampoline function.
      
        (change similar to my previous ia64 RFC)
      
      * If the task is killed with some left-over return probe instances (meaning
        that a target function was entered, but never returned), then we just
        free any instances associated with the task.  (Not much different other
        then we can handle this without calling architecture specific functions.)
      
        There is a known problem that this patch does not yet solve where
        registering a return probe flush_old_exec or flush_thread will put us
        in a bad state.  Most likely the best way to handle this is to not allow
        registering return probes on these two functions.
      
        (Significant change)
      
      This patch series applies to the 2.6.12-rc6-mm1 kernel, and provides:
        * kernel/kprobes.c changes
        * i386 patch of existing return probes implementation
        * x86_64 patch of existing return probe implementation
        * ia64 implementation
        * ppc64 implementation (provided by Ananth)
      
      This patch implements the architecture independant changes for a reworking
      of the kprobes based function return probes design. Changes include:
      
        * Removing functions for querying a return probe instance off a stack address
        * Removing the stack_addr field from the kretprobe_instance definition,
          and adding a task pointer
        * Adding architecture specific initialization via arch_init()
        * Removing extern definitions for the architecture trampoline functions
          (this isn't needed anymore since the architecture handles the
           initialization of the kprobe in the return probe trampoline function.)
      Signed-off-by: default avatarRusty Lynch <rusty.lynch@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      802eae7c