04 Feb, 2010

1 commit

  • Disable kprobe booster when CONFIG_PREEMPT=y at this time,
    because it can't ensure that all kernel threads preempted on
    kprobe's boosted slot run out from the slot even using
    freeze_processes().

    The booster on preemptive kernel will be resumed if
    synchronize_tasks() or something like that is introduced.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Ananth N Mavinakayanahalli
    Cc: Frederic Weisbecker
    Cc: Jim Keniston
    Cc: Mathieu Desnoyers
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

17 Jan, 2009

1 commit

  • Check CONFIG_FREEZER instead of CONFIG_PM because kprobe booster
    depends on freeze_processes() and thaw_processes() when CONFIG_PREEMPT=y.

    This fixes a linkage error which occurs when CONFIG_PREEMPT=y, CONFIG_PM=y
    and CONFIG_FREEZER=n.

    Reported-by: Cheng Renquan
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Rafael J. Wysocki
    Acked-by: Ingo Molnar
    Signed-off-by: Len Brown

    Masami Hiramatsu
     

08 Jan, 2009

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (24 commits)
    trivial: chack -> check typo fix in main Makefile
    trivial: Add a space (and a comma) to a printk in 8250 driver
    trivial: Fix misspelling of "firmware" in docs for ncr53c8xx/sym53c8xx
    trivial: Fix misspelling of "firmware" in powerpc Makefile
    trivial: Fix misspelling of "firmware" in usb.c
    trivial: Fix misspelling of "firmware" in qla1280.c
    trivial: Fix misspelling of "firmware" in a100u2w.c
    trivial: Fix misspelling of "firmware" in megaraid.c
    trivial: Fix misspelling of "firmware" in ql4_mbx.c
    trivial: Fix misspelling of "firmware" in acpi_memhotplug.c
    trivial: Fix misspelling of "firmware" in ipw2100.c
    trivial: Fix misspelling of "firmware" in atmel.c
    trivial: Fix misspelled firmware in Kconfig
    trivial: fix an -> a typos in documentation and comments
    trivial: fix then -> than typos in comments and documentation
    trivial: update Jesper Juhl CREDITS entry with new email
    trivial: fix singal -> signal typo
    trivial: Fix incorrect use of "loose" in event.c
    trivial: printk: fix indentation of new_text_line declaration
    trivial: rtc-stk17ta8: fix sparse warning
    ...

    Linus Torvalds
     

07 Jan, 2009

1 commit

  • Add kprobe_insn_mutex for protecting kprobe_insn_pages hlist, and remove
    kprobe_mutex from architecture dependent code.

    This allows us to call arch_remove_kprobe() (and free_insn_slot) while
    holding kprobe_mutex.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: Russell King
    Cc: "Luck, Tony"
    Cc: Paul Mackerras
    Cc: Benjamin Herrenschmidt
    Cc: Martin Schwidefsky
    Cc: Heiko Carstens
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masami Hiramatsu
     

06 Jan, 2009

1 commit


26 Jul, 2008

1 commit

  • Currently list of kretprobe instances are stored in kretprobe object (as
    used_instances,free_instances) and in kretprobe hash table. We have one
    global kretprobe lock to serialise the access to these lists. This causes
    only one kretprobe handler to execute at a time. Hence affects system
    performance, particularly on SMP systems and when return probe is set on
    lot of functions (like on all systemcalls).

    Solution proposed here gives fine-grain locks that performs better on SMP
    system compared to present kretprobe implementation.

    Solution:

    1) Instead of having one global lock to protect kretprobe instances
    present in kretprobe object and kretprobe hash table. We will have
    two locks, one lock for protecting kretprobe hash table and another
    lock for kretporbe object.

    2) We hold lock present in kretprobe object while we modify kretprobe
    instance in kretprobe object and we hold per-hash-list lock while
    modifying kretprobe instances present in that hash list. To prevent
    deadlock, we never grab a per-hash-list lock while holding a kretprobe
    lock.

    3) We can remove used_instances from struct kretprobe, as we can
    track used instances of kretprobe instances using kretprobe hash
    table.

    Time duration for kernel compilation ("make -j 8") on a 8-way ppc64 system
    with return probes set on all systemcalls looks like this.

    cacheline non-cacheline Un-patched kernel
    aligned patch aligned patch
    ===============================================================================
    real 9m46.784s 9m54.412s 10m2.450s
    user 40m5.715s 40m7.142s 40m4.273s
    sys 2m57.754s 2m58.583s 3m17.430s
    ===========================================================

    Time duration for kernel compilation ("make -j 8) on the same system, when
    kernel is not probed.
    =========================
    real 9m26.389s
    user 40m8.775s
    sys 2m7.283s
    =========================

    Signed-off-by: Srinivasa DS
    Signed-off-by: Jim Keniston
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: David S. Miller
    Cc: Masami Hiramatsu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Srinivasa D S
     

10 Apr, 2008

1 commit

  • Add kprobe-booster support on ia64.

    Kprobe-booster improves the performance of kprobes by eliminating single-step,
    where possible. Currently, kprobe-booster is implemented on x86 and x86-64.
    This is an ia64 port.

    On ia64, kprobe-booster executes a copied bundle directly, instead of single
    stepping. Bundles which have B or X unit and which may cause an exception
    (including break) are not executed directly. And also, to prevent hitting
    break exceptions on the copied bundle, only the hindmost kprobe is executed
    directly if several kprobes share a bundle and are placed in different slots.
    Note: set_brl_inst() is used for preparing an instruction buffer(it does not
    modify any active code), so it does not need any atomic operation.

    Signed-off-by: Masami Hiramatsu
    Cc: Anil S Keshavamurthy
    Cc: Ananth N Mavinakayanahalli
    Cc: bibo,mao
    Cc: Rusty Lynch
    Cc: Prasanna S Panchamukhi
    Cc: Jim Keniston
    Cc: Shaohua Li
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Masami Hiramatsu
     

07 Mar, 2008

1 commit


05 Mar, 2008

1 commit

  • This patch fixes the following compile error with a recent gcc:
    CC kernel/kprobes.o
    /home/bunk/linux/kernel-2.6/git/linux-2.6/kernel/kprobes.c:1066: error: __ksymtab_jprobe_return causes a section type conflict

    Signed-off-by: Adrian Bunk
    Signed-off-by: Tony Luck

    Adrian Bunk
     

05 Feb, 2008

1 commit


08 Dec, 2007

2 commits


17 Oct, 2007

1 commit

  • Introduce architecture dependent kretprobe blacklists to prohibit users
    from inserting return probes on the function in which kprobes can be
    inserted but kretprobes can not.

    This patch also removes "__kprobes" mark from "__switch_to" on x86_64 and
    registers "__switch_to" to the blacklist on x86-64, because that mark is to
    prohibit user from inserting only kretprobe.

    Signed-off-by: Masami Hiramatsu
    Cc: Prasanna S Panchamukhi
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masami Hiramatsu
     

20 Jul, 2007

1 commit

  • I realise jprobes are a razor-blades-included type of interface, but that
    doesn't mean we can't try and make them safer to use. This guy I know once
    wrote code like this:

    struct jprobe jp = { .kp.symbol_name = "foo", .entry = "jprobe_foo" };

    And then his kernel exploded. Oops.

    This patch adds an arch hook, arch_deref_entry_point() (I don't like it
    either) which takes the void * in a struct jprobe, and gives back the text
    address that it represents.

    We can then use that in register_jprobe() to check that the entry point we're
    passed is actually in the kernel text, rather than just some random value.

    Signed-off-by: Michael Ellerman
    Cc: Prasanna S Panchamukhi
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Cc: David S. Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Ellerman
     

17 May, 2007

1 commit


12 May, 2007

2 commits

  • Spelling and apostrophe fixes in arch/ia64/.

    Signed-off-by: Simon Arlott
    Signed-off-by: Tony Luck

    Simon Arlott
     
  • In case of reentrance i.e when a probe handler calls a functions which
    inturn has a probe, we save a previous kprobe information and just single
    step the reentrant probe without calling the actual probe handler. During
    this reentracy period, if an interrupt occurs and if probe happens to
    trigger in the inturrupt path, then we were corrupting the previous kprobe(
    as we were overriding the previous kprobe info) info their by crashing the
    system. This patch fixes this issues by having a an array of previous
    kprobe info struct(with the array size of 2).

    This similar technique is not needed on i386 and x86_64 because by default
    interrupts are turn off in the break/int3 exception handler.

    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Anil S Keshavamurthy
     

09 May, 2007

4 commits

  • This patch provides a debugfs knob to turn kprobes on/off

    o A new file /debug/kprobes/enabled indicates if kprobes is enabled or
    not (default enabled)
    o Echoing 0 to this file will disarm all installed probes
    o Any new probe registration when disabled will register the probe but
    not arm it. A message will be printed out in such a case.
    o When a value 1 is echoed to the file, all probes (including ones
    registered in the intervening period) will be enabled
    o Unregistration will happen irrespective of whether probes are globally
    enabled or not.
    o Update Documentation/kprobes.txt to reflect these changes. While there
    also update the doc to make it current.

    We are also looking at providing sysrq key support to tie to the disabling
    feature provided by this patch.

    [akpm@linux-foundation.org: Use bool like a bool!]
    [akpm@linux-foundation.org: add printk facility levels]
    [cornelia.huck@de.ibm.com: Add the missing arch_trampoline_kprobe() for s390]
    Signed-off-by: Ananth N Mavinakayanahalli
    Signed-off-by: Srinivasa DS
    Signed-off-by: Cornelia Huck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ananth N Mavinakayanahalli
     
  • - consolidate duplicate code in all arch_prepare_kretprobe instances
    into common code
    - replace various odd helpers that use hlist_for_each_entry to get
    the first elemenet of a list with either a hlist_for_each_entry_save
    or an opencoded access to the first element in the caller
    - inline add_rp_inst into it's only remaining caller
    - use kretprobe_inst_table_head instead of opencoding it

    Signed-off-by: Christoph Hellwig
    Cc: Prasanna S Panchamukhi
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     
  • In certain cases like when the real return address can't be found or when
    the number of tracked calls to a kretprobed function is less than the
    number of returns, we may not be able to find the correct return address
    after processing a kretprobe. Currently we just do a BUG_ON, but no
    information is provided about the actual failing kretprobe.

    Print out details of the kretprobe before calling BUG().

    Signed-off-by: Ananth N Mavinakayanahalli
    Cc: Prasanna S Panchamukhi
    Cc: Jim Keniston
    Cc: Anil S Keshavamurthy
    Cc: Maneesh Soni
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ananth N Mavinakayanahalli
     
  • This patch moves the die notifier handling to common code. Previous
    various architectures had exactly the same code for it. Note that the new
    code is compiled unconditionally, this should be understood as an appel to
    the other architecture maintainer to implement support for it aswell (aka
    sprinkling a notify_die or two in the proper place)

    arm had a notifiy_die that did something totally different, I renamed it to
    arm_notify_die as part of the patch and made it static to the file it's
    declared and used at. avr32 used to pass slightly less information through
    this interface and I brought it into line with the other architectures.

    [akpm@linux-foundation.org: build fix]
    [akpm@linux-foundation.org: fix vmalloc_sync_all bustage]
    [bryan.wu@analog.com: fix vmalloc_sync_all in nommu]
    Signed-off-by: Christoph Hellwig
    Cc:
    Cc: Russell King
    Signed-off-by: Bryan Wu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

13 Dec, 2006

2 commits

  • On IA64 there exists some special instructions which
    always need to be executed regradless of qp bits, such
    as com.crel.unc, tbit.trel.unc etc.
    This patch clears qp bits when inserting kprobe trap code
    and disables probepoint on slot 1 for these special
    instructions.

    Signed-off-by: bibo,mao
    Signed-off-by: Tony Luck

    bibo,mao
     
  • Because slot 1 of one instr bundle crosses border of two consecutive
    8-bytes, kprobe on slot 1 is disabled. This patch enables kprobe on
    slot1, it only replaces higher 8-bytes of the instruction bundle and
    changes the exception code to ignore the low 12 bits of the break
    number (which is across the border in the lower 8-bytes of the bundle).

    For those instructions which must execute regardless qp bits,
    kprobe on slot 1 is still disabled.

    Signed-off-by: bibo,mao
    Signed-off-by: Tony Luck

    Tony Luck
     

08 Dec, 2006

3 commits

  • * 'release' of master.kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6:
    [IA64] replace kmalloc+memset with kzalloc
    [IA64] resolve name clash by renaming is_available_memory()
    [IA64] Need export for csum_ipv6_magic
    [IA64] Fix DISCONTIGMEM without VIRTUAL_MEM_MAP
    [PATCH] Add support for type argument in PAL_GET_PSTATE
    [IA64] tidy up return value of ip_fast_csum
    [IA64] implement csum_ipv6_magic for ia64.
    [IA64] More Itanium PAL spec updates
    [IA64] Update processor_info features
    [IA64] Add se bit to Processor State Parameter structure
    [IA64] Add dp bit to cache and bus check structs
    [IA64] SN: Correctly update smp_affinty mask
    [IA64] sparse cleanups
    [IA64] IA64 Kexec/kdump

    Linus Torvalds
     
  • 0/NULL confusion and some missing UL on constants.

    Signed-off-by: Matthew Wilcox
    Signed-off-by: Tony Luck

    Matthew Wilcox
     
  • When we are unregistering a kprobe-booster, we can't release its
    instruction buffer immediately on the preemptive kernel, because some
    processes might be preempted on the buffer. The freeze_processes() and
    thaw_processes() functions can clean most of processes up from the buffer.
    There are still some non-frozen threads who have the PF_NOFREEZE flag. If
    those threads are sleeping (not preempted) at the known place outside the
    buffer, we can ensure safety of freeing.

    However, the processing of this check routine takes a long time. So, this
    patch introduces the garbage collection mechanism of insn_slot. It also
    introduces the "dirty" flag to free_insn_slot because of efficiency.

    The "clean" instruction slots (dirty flag is cleared) are released
    immediately. But the "dirty" slots which are used by boosted kprobes, are
    marked as garbages. collect_garbage_slots() will be invoked to release
    "dirty" slots if there are more than INSNS_PER_PAGE garbage slots or if
    there are no unused slots.

    Cc: "Keshavamurthy, Anil S"
    Cc: Ananth N Mavinakayanahalli
    Cc: "bibo,mao"
    Cc: Prasanna S Panchamukhi
    Cc: Yumiko Sugita
    Cc: Satoshi Oshima
    Cc: Hideo Aoki
    Signed-off-by: Masami Hiramatsu
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masami Hiramatsu
     

02 Oct, 2006

2 commits

  • kprobe_flush_task() possibly calls kfree function during holding
    kretprobe_lock spinlock, if kfree function is probed by kretprobe that will
    incur spinlock deadlock. This patch moves kfree function out scope of
    kretprobe_lock.

    Signed-off-by: bibo, mao
    Signed-off-by: Ananth N Mavinakayanahalli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    bibo,mao
     
  • Whitespace is used to indent, this patch cleans up these sentences by
    kernel coding style.

    Signed-off-by: bibo, mao
    Signed-off-by: Ananth N Mavinakayanahalli
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    bibo,mao
     

27 Sep, 2006

2 commits

  • If the user-specified kprobe handler causes the page fault when accessing
    user space address, fixup this fault since do_page_fault() should not
    continue as the kprobe handler are run with preemption disabled.

    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Tony Luck

    Keshavamurthy Anil S
     
  • On IA64 instruction opcode must be 16 bytes alignment, in kprobe structure
    there is one element to save original instruction, currently saved opcode
    is not statically allocated in kprobe structure, that can not assure
    16 bytes alignment. This patch dynamically allocated kprobe instruction
    opcode to assure 16 bytes alignment.

    Signed-off-by: bibo mao
    Acked-by: Anil S Keshavamurthy
    Signed-off-by: Tony Luck

    bibo mao
     

01 Aug, 2006

1 commit

  • Kprobe inserts breakpoint instruction in probepoint and then jumps to
    instruction slot when breakpoint is hit, the instruction slot icache must
    be consistent with dcache. Here is the patch which invalidates instruction
    slot icache area.

    Without this patch, in some machines there will be fault when executing
    instruction slot where icache content is inconsistent with dcache.

    Signed-off-by: bibo,mao
    Acked-by: "Luck, Tony"
    Acked-by: Keshavamurthy Anil S
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    bibo, mao
     

01 Jul, 2006

1 commit


20 Apr, 2006

1 commit

  • Andrew Morton pointed out that compiler might not inline the functions
    marked for inline in kprobes. There-by allowing the insertion of probes
    on these kprobes routines, which might cause recursion.

    This patch removes all such inline and adds them to kprobes section
    there by disallowing probes on all such routines. Some of the routines
    can even still be inlined, since these routines gets executed after the
    kprobes had done necessay setup for reentrancy.

    Signed-off-by: Prasanna S Panchamukhi
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Prasanna S Panchamukhi
     

27 Mar, 2006

2 commits

  • Provide proper kprobes fault handling, if a user-specified pre/post handlers
    tries to access user address space, through copy_from_user(), get_user() etc.

    The user-specified fault handler gets called only if the fault occurs while
    executing user-specified handlers. In such a case user-specified handler is
    allowed to fix it first, later if the user-specifed fault handler does not fix
    it, we try to fix it by calling fix_exception().

    The user-specified handler will not be called if the fault happens when single
    stepping the original instruction, instead we reset the current probe and
    allow the system page fault handler to fix it up.

    Signed-off-by: Prasanna S Panchamukhi
    Acked-by: Anil S Keshavamurthy
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Prasanna S Panchamukhi
     
  • Currently kprobe handler traps only happen in kernel space, so function
    kprobe_exceptions_notify should skip traps which happen in user space.
    This patch modifies this, and it is based on 2.6.16-rc4.

    Signed-off-by: bibo mao
    Cc: Ananth N Mavinakayanahalli
    Cc: "Keshavamurthy, Anil S"
    Cc:
    Signed-off-by: Prasanna S Panchamukhi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    bibo,mao
     

14 Jan, 2006

1 commit

  • When jprobe is hit, the function parameters of the original function
    should be saved before jprobe handler is executed, and restored it after
    jprobe handler is executed, because jprobe handler might change the
    register values due to tail call optimization by the gcc.

    Signed-off-by: Zhang Yanmin
    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Tony Luck

    Zhang Yanmin
     

12 Jan, 2006

1 commit

  • There is a window where a probe gets removed right after the probe is hit
    on some different cpu. In this case probe handlers can't find a matching
    probe instance related to break address. In this case we need to read the
    original instruction at break address to see if that is not a break/int3
    instruction and recover safely.

    Previous code had a bug where we were not checking for the above race in
    case of reentrant probes and the below patch fixes this race.

    Tested on IA64, Powerpc, x86_64.

    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Keshavamurthy Anil S
     

11 Jan, 2006

1 commit

  • Currently arch_remove_kprobes() is only implemented/required for x86_64 and
    powerpc. All other architecture like IA64, i386 and sparc64 implementes a
    dummy function which is being called from arch independent kprobes.c file.

    This patch removes the dummy functions and replaces it with
    #define arch_remove_kprobe(p, s) do { } while(0)

    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anil S Keshavamurthy
     

13 Dec, 2005

1 commit

  • When multiple probes are registered at the same address and if due to some
    recursion (probe getting triggered within a probe handler), we skip calling
    pre_handlers and just increment nmissed field.

    The below patch make sure it walks the list for multiple probes case.
    Without the below patch we get incorrect results of nmissed count for
    multiple probe case.

    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Keshavamurthy Anil S
     

30 Nov, 2005

1 commit

  • break.b always sets cr.iim to 0 and the current code tries to
    get the break_num by decoding instruction. However, their
    seems to be a race condition while reading the regs->cr_iip,
    as on other cpu the break.b at regs->cr_iip might have been
    replaced with the original instruction as a result of
    unregister_kprobe() and hence decoding instruction to
    obtain break_num will result in wrong value in this case.

    Also includes changes to kprobes.c which now has to handle
    break number zero.

    Signed-off-by: Anil S Keshavamurthy
    Signed-off-by: Tony Luck

    Keshavamurthy Anil S