16 May, 2022

1 commit

  • [ Upstream commit b17c2baa305cccbd16bafa289fd743cc2db77966 ]

    Replace all ret/retq instructions with ASM_RET in preparation of
    making it more than a single instruction.

    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Borislav Petkov
    Link: https://lore.kernel.org/r/20211204134907.964635458@infradead.org
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     

11 Jan, 2022

1 commit

  • commit 0daf5cb217a9ca8ae91b8f966ddae322699fb71d upstream.

    There's another compilation fail (first here [1]) reported by kernel
    test robot for W=1 clang build:

    >> samples/ftrace/ftrace-direct-multi-modify.c:7:6: warning: no previous
    prototype for function 'my_direct_func1' [-Wmissing-prototypes]
    void my_direct_func1(unsigned long ip)

    Direct functions in ftrace direct sample modules need to have prototypes
    defined. They are already global in order to be visible for the inline
    assembly, so there's no problem.

    The kernel test robot reported just error for ftrace-direct-multi-modify,
    but I got same errors also for the rest of the modules touched by this patch.

    [1] 67d4f6e3bf5d ftrace/samples: Add missing prototype for my_direct_func

    Link: https://lkml.kernel.org/r/20211219135317.212430-1-jolsa@kernel.org

    Reported-by: kernel test robot
    Fixes: e1067a07cfbc ("ftrace/samples: Add module to test multi direct modify interface")
    Fixes: ae0cc3b7e7f5 ("ftrace/samples: Add a sample module that implements modify_ftrace_direct()")
    Fixes: 156473a0ff4f ("ftrace: Add another example of register_ftrace_direct() use case")
    Fixes: b06457c83af6 ("ftrace: Add sample module that uses register_ftrace_direct()")
    Signed-off-by: Jiri Olsa
    Signed-off-by: Steven Rostedt
    Signed-off-by: Greg Kroah-Hartman

    Jiri Olsa
     

01 Dec, 2020

1 commit

  • my_tramp[12]? are declared as global functions in C, but they are not
    marked global in the inline assembly definition. This mismatch confuses
    Clang's Control-Flow Integrity checking. Fix the definitions by adding
    .globl.

    Link: https://lkml.kernel.org/r/20201113183414.1446671-1-samitolvanen@google.com

    Fixes: 9d907f1ae80b8 ("ftrace/samples: Add a sample module that implements modify_ftrace_direct()")
    Reviewed-by: Kees Cook
    Signed-off-by: Sami Tolvanen
    Signed-off-by: Steven Rostedt (VMware)

    Sami Tolvanen
     

17 Jun, 2020

2 commits

  • Remove trace_array 'sample-instance' if kthread_run fails
    in sample_trace_array_init().

    Link: https://lkml.kernel.org/r/20200609135200.2206726-1-wangkefeng.wang@huawei.com

    Cc: stable@vger.kernel.org
    Fixes: 89ed42495ef4a ("tracing: Sample module to demonstrate kernel access to Ftrace instances.")
    Reviewed-by: Divya Indi
    Signed-off-by: Kefeng Wang
    Signed-off-by: Steven Rostedt (VMware)

    Kefeng Wang
     
  • BUG: sleeping function called from invalid context at kernel/locking/mutex.c:935
    in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/5
    1 lock held by swapper/5/0:
    #0: ffff80001002bd90 (samples/ftrace/sample-trace-array.c:38){+.-.}-{0:0}, at: call_timer_fn+0x8/0x3e0
    CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.7.0+ #8
    Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
    Call trace:
    dump_backtrace+0x0/0x1a0
    show_stack+0x20/0x30
    dump_stack+0xe4/0x150
    ___might_sleep+0x160/0x200
    __might_sleep+0x58/0x90
    __mutex_lock+0x64/0x948
    mutex_lock_nested+0x3c/0x58
    __ftrace_set_clr_event+0x44/0x88
    trace_array_set_clr_event+0x24/0x38
    mytimer_handler+0x34/0x40 [sample_trace_array]

    mutex_lock() will be called in interrupt context, using workqueue to fix it.

    Link: https://lkml.kernel.org/r/20200610011244.2209486-1-wangkefeng.wang@huawei.com

    Cc: stable@vger.kernel.org
    Fixes: 89ed42495ef4 ("tracing: Sample module to demonstrate kernel access to Ftrace instances.")
    Reviewed-by: Divya Indi
    Signed-off-by: Kefeng Wang
    Signed-off-by: Steven Rostedt (VMware)

    Kefeng Wang
     

20 May, 2020

1 commit

  • Enable objtool coverage for the sample ftrace modules by adding ELF
    annotations to the asm trampoline functions.

    samples/ftrace/ftrace-direct.o: warning: objtool: .text+0x0: unreachable instruction
    samples/ftrace/ftrace-direct-modify.o: warning: objtool: .text+0x0: unreachable instruction
    samples/ftrace/ftrace-direct-too.o: warning: objtool: .text+0x0: unreachable instruction

    Reported-by: Randy Dunlap
    Signed-off-by: Josh Poimboeuf

    Josh Poimboeuf
     

23 Nov, 2019

1 commit

  • This is a sample module to demonstrate the use of the newly introduced and
    exported APIs to access Ftrace instances from within the kernel.

    Newly introduced APIs used here -

    1. Create/Lookup a trace array with the given name.
    struct trace_array *trace_array_get_by_name(const char *name)

    2. Destroy/Remove a trace array.
    int trace_array_destroy(struct trace_array *tr)

    4. Enable/Disable trace events:
    int trace_array_set_clr_event(struct trace_array *tr, const char *system,
    const char *event, bool enable);

    Exported APIs -
    1. trace_printk equivalent for instances.
    int trace_array_printk(struct trace_array *tr,
    unsigned long ip, const char *fmt, ...);

    2. Helper function.
    void trace_printk_init_buffers(void);

    3. To decrement the reference counter.
    void trace_array_put(struct trace_array *tr)

    Sample output(contents of /sys/kernel/tracing/instances/sample-instance)
    NOTE: Tracing disabled after ~5 sec)

    _-----=> irqs-off
    / _----=> need-resched
    | / _---=> hardirq/softirq
    || / _--=> preempt-depth
    ||| / delay
    TASK-PID CPU# |||| TIMESTAMP FUNCTION
    | | | |||| | |
    sample-instance-1452 [002] .... 49.430948: simple_thread: trace_array_printk: count=0
    sample-instance-1452 [002] .... 49.430951: sample_event: count value=0 at jiffies=4294716608
    sample-instance-1452 [002] .... 50.454847: simple_thread: trace_array_printk: count=1
    sample-instance-1452 [002] .... 50.454849: sample_event: count value=1 at jiffies=4294717632
    sample-instance-1452 [002] .... 51.478748: simple_thread: trace_array_printk: count=2
    sample-instance-1452 [002] .... 51.478750: sample_event: count value=2 at jiffies=4294718656
    sample-instance-1452 [002] .... 52.502652: simple_thread: trace_array_printk: count=3
    sample-instance-1452 [002] .... 52.502655: sample_event: count value=3 at jiffies=4294719680
    sample-instance-1452 [002] .... 53.526533: simple_thread: trace_array_printk: count=4
    sample-instance-1452 [002] .... 53.526535: sample_event: count value=4 at jiffies=4294720704
    sample-instance-1452 [002] .... 54.550438: simple_thread: trace_array_printk: count=5
    sample-instance-1452 [002] .... 55.574336: simple_thread: trace_array_printk: count=6

    Link: http://lkml.kernel.org/r/1574276919-11119-3-git-send-email-divya.indi@oracle.com

    Reviewed-by: Aruna Ramakrishna
    Signed-off-by: Divya Indi
    [ Moved to samples/ftrace ]
    Signed-off-by: Steven Rostedt (VMware)

    Divya Indi
     

16 Nov, 2019

1 commit

  • There is a spelling mistake in a trace_printk message. As well as in
    the selftests that search for this string.

    Link: http://lkml.kernel.org/r/20191115085938.38947-1-colin.king@canonical.com
    Link: http://lkml.kernel.org/r/20191115090356.39572-1-colin.king@canonical.com

    Signed-off-by: Colin Ian King
    Signed-off-by: Steven Rostedt (VMware)

    Colin Ian King
     

15 Nov, 2019

1 commit


13 Nov, 2019

2 commits