• David S. Miller's avatar
    [SPARC64]: Fix several kprobes bugs. · f0882589
    David S. Miller authored
    - relbranch_fixup(), for non-branches, would end up setting
      regs->tnpc incorrectly, in fact it would set it equal to
      regs->tpc which would cause that instruction to execute twice
    
      Also, if this is not a PC-relative branch, we should just
      leave regs->tnpc as-is.  This covers cases like 'jmpl' which
      branch to absolute values.
    
    - To be absolutely %100 safe, we need to flush the instruction
      cache for all assignments to kprobe->ainsn.insn[], including
      cases like add_aggr_kprobe()
    
    - prev_kprobe's status field needs to be 'unsigned long' to match
      the type of the value it is saving
    
    - jprobes were totally broken:
      = jprobe_return() can run in the stack frame of the jprobe handler,
        or in an even deeper stack frame, thus we'll be in the wrong
        register window than the one from the original probe state.
    
        So unwind using 'restore' instructions, if necessary, right
        before we do the jprobe_return() breakpoint trap.
    
      = There is no reason to save/restore the register window saved
        at %sp at jprobe trigger time.  Those registers cannot be
        modified by the jprobe handler.  Also, this code was saving
        and restoring "sizeof (struct sparc_stackf)" bytes.  Depending
        upon the caller, this could clobber unrelated stack frame
        pieces if there is only a basic 128-byte register window
        stored on the stack, without the argument save area.
    
        So just saving and restoring struct pt_regs is sufficient.
    
      = Kill the "jprobe_saved_esp", totally unused.
    
        Also, delete "jprobe_saved_regs_location", with the stack frame
        unwind now done explicitly by jprobe_return(), this check is
        superfluous.
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f0882589
kprobes.h 1.16 KB