<feed xmlns='http://www.w3.org/2005/Atom'>
<title>android_kernel_zuk_msm8996.git/arch/arm64/include/asm/stacktrace.h, branch master</title>
<subtitle>null
</subtitle>
<link rel='alternate' type='text/html' href='http://git.compromyse.xyz/android/android_kernel_zuk_msm8996.git/'/>
<entry>
<title>UPSTREAM: arm64: fix unwind_frame() for filtered out fn for function graph tracing</title>
<updated>2020-11-15T14:49:07+00:00</updated>
<author>
<name>Pratyush Anand</name>
<email>panand@redhat.com</email>
</author>
<published>2018-02-05T13:28:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.compromyse.xyz/android/android_kernel_zuk_msm8996.git/commit/?id=788d872548c2db2a09ce7e658397385ca3834eed'/>
<id>788d872548c2db2a09ce7e658397385ca3834eed</id>
<content type='text'>
do_task_stat() calls get_wchan(), which further does unwind_frame().
unwind_frame() restores frame-&gt;pc to original value in case function
graph tracer has modified a return address (LR) in a stack frame to hook
a function return. However, if function graph tracer has hit a filtered
function, then we can't unwind it as ftrace_push_return_trace() has
biased the index(frame-&gt;graph) with a 'huge negative'
offset(-FTRACE_NOTRACE_DEPTH).

Moreover, arm64 stack walker defines index(frame-&gt;graph) as unsigned
int, which can not compare a -ve number.

Similar problem we can have with calling of walk_stackframe() from
save_stack_trace_tsk() or dump_backtrace().

This patch fixes unwind_frame() to test the index for -ve value and
restore index accordingly before we can restore frame-&gt;pc.

Reproducer:

cd /sys/kernel/debug/tracing/
echo schedule &gt; set_graph_notrace
echo 1 &gt; options/display-graph
echo wakeup &gt; current_tracer
ps -ef | grep -i agent

Above commands result in:
Unable to handle kernel paging request at virtual address ffff801bd3d1e000
pgd = ffff8003cbe97c00
[ffff801bd3d1e000] *pgd=0000000000000000, *pud=0000000000000000
Internal error: Oops: 96000006 [#1] SMP
[...]
CPU: 5 PID: 11696 Comm: ps Not tainted 4.11.0+ #33
[...]
task: ffff8003c21ba000 task.stack: ffff8003cc6c0000
PC is at unwind_frame+0x12c/0x180
LR is at get_wchan+0xd4/0x134
pc : [&lt;ffff00000808892c&gt;] lr : [&lt;ffff0000080860b8&gt;] pstate: 60000145
sp : ffff8003cc6c3ab0
x29: ffff8003cc6c3ab0 x28: 0000000000000001
x27: 0000000000000026 x26: 0000000000000026
x25: 00000000000012d8 x24: 0000000000000000
x23: ffff8003c1c04000 x22: ffff000008c83000
x21: ffff8003c1c00000 x20: 000000000000000f
x19: ffff8003c1bc0000 x18: 0000fffffc593690
x17: 0000000000000000 x16: 0000000000000001
x15: 0000b855670e2b60 x14: 0003e97f22cf1d0f
x13: 0000000000000001 x12: 0000000000000000
x11: 00000000e8f4883e x10: 0000000154f47ec8
x9 : 0000000070f367c0 x8 : 0000000000000000
x7 : 00008003f7290000 x6 : 0000000000000018
x5 : 0000000000000000 x4 : ffff8003c1c03cb0
x3 : ffff8003c1c03ca0 x2 : 00000017ffe80000
x1 : ffff8003cc6c3af8 x0 : ffff8003d3e9e000

Process ps (pid: 11696, stack limit = 0xffff8003cc6c0000)
Stack: (0xffff8003cc6c3ab0 to 0xffff8003cc6c4000)
[...]
[&lt;ffff00000808892c&gt;] unwind_frame+0x12c/0x180
[&lt;ffff000008305008&gt;] do_task_stat+0x864/0x870
[&lt;ffff000008305c44&gt;] proc_tgid_stat+0x3c/0x48
[&lt;ffff0000082fde0c&gt;] proc_single_show+0x5c/0xb8
[&lt;ffff0000082b27e0&gt;] seq_read+0x160/0x414
[&lt;ffff000008289e6c&gt;] __vfs_read+0x58/0x164
[&lt;ffff00000828b164&gt;] vfs_read+0x88/0x144
[&lt;ffff00000828c2e8&gt;] SyS_read+0x60/0xc0
[&lt;ffff0000080834a0&gt;] __sys_trace_return+0x0/0x4

Fixes: 20380bb390a4 (arm64: ftrace: fix a stack tracer's output under function graph tracer)
Signed-off-by: Pratyush Anand &lt;panand@redhat.com&gt;
Signed-off-by: Jerome Marchand &lt;jmarchan@redhat.com&gt;
[catalin.marinas@arm.com: replace WARN_ON with WARN_ON_ONCE]
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
(cherry picked from commit 9f416319f40cd857d2bb517630e5855a905ef3fb)
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@google.com&gt;
Change-Id: I9cbc564cf7e1808a05e1e45e9196a8d138bae4a5
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
do_task_stat() calls get_wchan(), which further does unwind_frame().
unwind_frame() restores frame-&gt;pc to original value in case function
graph tracer has modified a return address (LR) in a stack frame to hook
a function return. However, if function graph tracer has hit a filtered
function, then we can't unwind it as ftrace_push_return_trace() has
biased the index(frame-&gt;graph) with a 'huge negative'
offset(-FTRACE_NOTRACE_DEPTH).

Moreover, arm64 stack walker defines index(frame-&gt;graph) as unsigned
int, which can not compare a -ve number.

Similar problem we can have with calling of walk_stackframe() from
save_stack_trace_tsk() or dump_backtrace().

This patch fixes unwind_frame() to test the index for -ve value and
restore index accordingly before we can restore frame-&gt;pc.

Reproducer:

cd /sys/kernel/debug/tracing/
echo schedule &gt; set_graph_notrace
echo 1 &gt; options/display-graph
echo wakeup &gt; current_tracer
ps -ef | grep -i agent

Above commands result in:
Unable to handle kernel paging request at virtual address ffff801bd3d1e000
pgd = ffff8003cbe97c00
[ffff801bd3d1e000] *pgd=0000000000000000, *pud=0000000000000000
Internal error: Oops: 96000006 [#1] SMP
[...]
CPU: 5 PID: 11696 Comm: ps Not tainted 4.11.0+ #33
[...]
task: ffff8003c21ba000 task.stack: ffff8003cc6c0000
PC is at unwind_frame+0x12c/0x180
LR is at get_wchan+0xd4/0x134
pc : [&lt;ffff00000808892c&gt;] lr : [&lt;ffff0000080860b8&gt;] pstate: 60000145
sp : ffff8003cc6c3ab0
x29: ffff8003cc6c3ab0 x28: 0000000000000001
x27: 0000000000000026 x26: 0000000000000026
x25: 00000000000012d8 x24: 0000000000000000
x23: ffff8003c1c04000 x22: ffff000008c83000
x21: ffff8003c1c00000 x20: 000000000000000f
x19: ffff8003c1bc0000 x18: 0000fffffc593690
x17: 0000000000000000 x16: 0000000000000001
x15: 0000b855670e2b60 x14: 0003e97f22cf1d0f
x13: 0000000000000001 x12: 0000000000000000
x11: 00000000e8f4883e x10: 0000000154f47ec8
x9 : 0000000070f367c0 x8 : 0000000000000000
x7 : 00008003f7290000 x6 : 0000000000000018
x5 : 0000000000000000 x4 : ffff8003c1c03cb0
x3 : ffff8003c1c03ca0 x2 : 00000017ffe80000
x1 : ffff8003cc6c3af8 x0 : ffff8003d3e9e000

Process ps (pid: 11696, stack limit = 0xffff8003cc6c0000)
Stack: (0xffff8003cc6c3ab0 to 0xffff8003cc6c4000)
[...]
[&lt;ffff00000808892c&gt;] unwind_frame+0x12c/0x180
[&lt;ffff000008305008&gt;] do_task_stat+0x864/0x870
[&lt;ffff000008305c44&gt;] proc_tgid_stat+0x3c/0x48
[&lt;ffff0000082fde0c&gt;] proc_single_show+0x5c/0xb8
[&lt;ffff0000082b27e0&gt;] seq_read+0x160/0x414
[&lt;ffff000008289e6c&gt;] __vfs_read+0x58/0x164
[&lt;ffff00000828b164&gt;] vfs_read+0x88/0x144
[&lt;ffff00000828c2e8&gt;] SyS_read+0x60/0xc0
[&lt;ffff0000080834a0&gt;] __sys_trace_return+0x0/0x4

Fixes: 20380bb390a4 (arm64: ftrace: fix a stack tracer's output under function graph tracer)
Signed-off-by: Pratyush Anand &lt;panand@redhat.com&gt;
Signed-off-by: Jerome Marchand &lt;jmarchan@redhat.com&gt;
[catalin.marinas@arm.com: replace WARN_ON with WARN_ON_ONCE]
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
(cherry picked from commit 9f416319f40cd857d2bb517630e5855a905ef3fb)
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@google.com&gt;
Change-Id: I9cbc564cf7e1808a05e1e45e9196a8d138bae4a5
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>UPSTREAM: arm64: ftrace: fix a stack tracer's output under function graph tracer</title>
<updated>2016-09-18T21:13:26+00:00</updated>
<author>
<name>AKASHI Takahiro</name>
<email>takahiro.akashi@linaro.org</email>
</author>
<published>2015-12-15T08:33:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.compromyse.xyz/android/android_kernel_zuk_msm8996.git/commit/?id=0c078f6a47bb3de392e16788a119d575441c1fb2'/>
<id>0c078f6a47bb3de392e16788a119d575441c1fb2</id>
<content type='text'>
Function graph tracer modifies a return address (LR) in a stack frame
to hook a function return. This will result in many useless entries
(return_to_handler) showing up in
 a) a stack tracer's output
 b) perf call graph (with perf record -g)
 c) dump_backtrace (at panic et al.)

For example, in case of a),
  $ echo function_graph &gt; /sys/kernel/debug/tracing/current_tracer
  $ echo 1 &gt; /proc/sys/kernel/stack_trace_enabled
  $ cat /sys/kernel/debug/tracing/stack_trace
        Depth    Size   Location    (54 entries)
        -----    ----   --------
  0)     4504      16   gic_raise_softirq+0x28/0x150
  1)     4488      80   smp_cross_call+0x38/0xb8
  2)     4408      48   return_to_handler+0x0/0x40
  3)     4360      32   return_to_handler+0x0/0x40
  ...

In case of b),
  $ echo function_graph &gt; /sys/kernel/debug/tracing/current_tracer
  $ perf record -e mem:XXX:x -ag -- sleep 10
  $ perf report
                  ...
                  |          |          |--0.22%-- 0x550f8
                  |          |          |          0x10888
                  |          |          |          el0_svc_naked
                  |          |          |          sys_openat
                  |          |          |          return_to_handler
                  |          |          |          return_to_handler
                  ...

In case of c),
  $ echo function_graph &gt; /sys/kernel/debug/tracing/current_tracer
  $ echo c &gt; /proc/sysrq-trigger
  ...
  Call trace:
  [&lt;ffffffc00044d3ac&gt;] sysrq_handle_crash+0x24/0x30
  [&lt;ffffffc000092250&gt;] return_to_handler+0x0/0x40
  [&lt;ffffffc000092250&gt;] return_to_handler+0x0/0x40
  ...

This patch replaces such entries with real addresses preserved in
current-&gt;ret_stack[] at unwind_frame(). This way, we can cover all
the cases.

Reviewed-by: Jungseok Lee &lt;jungseoklee85@gmail.com&gt;
Signed-off-by: AKASHI Takahiro &lt;takahiro.akashi@linaro.org&gt;
[will: fixed minor context changes conflicting with irq stack bits]
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;

Bug: 30369029
Patchset: rework-pagetable

(cherry picked from commit 20380bb390a443b2c5c8800cec59743faf8151b4)
Signed-off-by: Jeff Vander Stoep &lt;jeffv@google.com&gt;
Change-Id: I6360182f8d04fdd2e31c0cb6054aefa2adb216e7
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Function graph tracer modifies a return address (LR) in a stack frame
to hook a function return. This will result in many useless entries
(return_to_handler) showing up in
 a) a stack tracer's output
 b) perf call graph (with perf record -g)
 c) dump_backtrace (at panic et al.)

For example, in case of a),
  $ echo function_graph &gt; /sys/kernel/debug/tracing/current_tracer
  $ echo 1 &gt; /proc/sys/kernel/stack_trace_enabled
  $ cat /sys/kernel/debug/tracing/stack_trace
        Depth    Size   Location    (54 entries)
        -----    ----   --------
  0)     4504      16   gic_raise_softirq+0x28/0x150
  1)     4488      80   smp_cross_call+0x38/0xb8
  2)     4408      48   return_to_handler+0x0/0x40
  3)     4360      32   return_to_handler+0x0/0x40
  ...

In case of b),
  $ echo function_graph &gt; /sys/kernel/debug/tracing/current_tracer
  $ perf record -e mem:XXX:x -ag -- sleep 10
  $ perf report
                  ...
                  |          |          |--0.22%-- 0x550f8
                  |          |          |          0x10888
                  |          |          |          el0_svc_naked
                  |          |          |          sys_openat
                  |          |          |          return_to_handler
                  |          |          |          return_to_handler
                  ...

In case of c),
  $ echo function_graph &gt; /sys/kernel/debug/tracing/current_tracer
  $ echo c &gt; /proc/sysrq-trigger
  ...
  Call trace:
  [&lt;ffffffc00044d3ac&gt;] sysrq_handle_crash+0x24/0x30
  [&lt;ffffffc000092250&gt;] return_to_handler+0x0/0x40
  [&lt;ffffffc000092250&gt;] return_to_handler+0x0/0x40
  ...

This patch replaces such entries with real addresses preserved in
current-&gt;ret_stack[] at unwind_frame(). This way, we can cover all
the cases.

Reviewed-by: Jungseok Lee &lt;jungseoklee85@gmail.com&gt;
Signed-off-by: AKASHI Takahiro &lt;takahiro.akashi@linaro.org&gt;
[will: fixed minor context changes conflicting with irq stack bits]
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;

Bug: 30369029
Patchset: rework-pagetable

(cherry picked from commit 20380bb390a443b2c5c8800cec59743faf8151b4)
Signed-off-by: Jeff Vander Stoep &lt;jeffv@google.com&gt;
Change-Id: I6360182f8d04fdd2e31c0cb6054aefa2adb216e7
</pre>
</div>
</content>
</entry>
<entry>
<title>UPSTREAM: arm64: pass a task parameter to unwind_frame()</title>
<updated>2016-09-18T21:12:02+00:00</updated>
<author>
<name>AKASHI Takahiro</name>
<email>takahiro.akashi@linaro.org</email>
</author>
<published>2015-12-15T08:33:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.compromyse.xyz/android/android_kernel_zuk_msm8996.git/commit/?id=6adbc95c63d8b5a2873865ee8b6a4092ac95a0e9'/>
<id>6adbc95c63d8b5a2873865ee8b6a4092ac95a0e9</id>
<content type='text'>
Function graph tracer modifies a return address (LR) in a stack frame
to hook a function's return. This will result in many useless entries
(return_to_handler) showing up in a call stack list.
We will fix this problem in a later patch ("arm64: ftrace: fix a stack
tracer's output under function graph tracer"). But since real return
addresses are saved in ret_stack[] array in struct task_struct,
unwind functions need to be notified of, in addition to a stack pointer
address, which task is being traced in order to find out real return
addresses.

This patch extends unwind functions' interfaces by adding an extra
argument of a pointer to task_struct.

Signed-off-by: AKASHI Takahiro &lt;takahiro.akashi@linaro.org&gt;
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;

Bug: 30369029
Patchset: rework-pagetable

(cherry picked from commit fe13f95b720075327a761fe6ddb45b0c90cab504)
Signed-off-by: Jeff Vander Stoep &lt;jeffv@google.com&gt;
Change-Id: I92a9a07468c182d5abbacaa73a90984ab11ad535
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Function graph tracer modifies a return address (LR) in a stack frame
to hook a function's return. This will result in many useless entries
(return_to_handler) showing up in a call stack list.
We will fix this problem in a later patch ("arm64: ftrace: fix a stack
tracer's output under function graph tracer"). But since real return
addresses are saved in ret_stack[] array in struct task_struct,
unwind functions need to be notified of, in addition to a stack pointer
address, which task is being traced in order to find out real return
addresses.

This patch extends unwind functions' interfaces by adding an extra
argument of a pointer to task_struct.

Signed-off-by: AKASHI Takahiro &lt;takahiro.akashi@linaro.org&gt;
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;

Bug: 30369029
Patchset: rework-pagetable

(cherry picked from commit fe13f95b720075327a761fe6ddb45b0c90cab504)
Signed-off-by: Jeff Vander Stoep &lt;jeffv@google.com&gt;
Change-Id: I92a9a07468c182d5abbacaa73a90984ab11ad535
</pre>
</div>
</content>
</entry>
<entry>
<title>arm64: Exception handling</title>
<updated>2012-09-17T09:24:46+00:00</updated>
<author>
<name>Catalin Marinas</name>
<email>catalin.marinas@arm.com</email>
</author>
<published>2012-03-05T11:49:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.compromyse.xyz/android/android_kernel_zuk_msm8996.git/commit/?id=60ffc30d5652810dd34ea2eec41504222f5d5791'/>
<id>60ffc30d5652810dd34ea2eec41504222f5d5791</id>
<content type='text'>
The patch contains the exception entry code (kernel/entry.S), pt_regs
structure and related accessors, undefined instruction trapping and
stack tracing.

AArch64 Linux kernel (including kernel threads) runs in EL1 mode using
the SP1 stack. The vectors don't have a fixed address, only alignment
(2^11) requirements.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Acked-by: Tony Lindgren &lt;tony@atomide.com&gt;
Acked-by: Nicolas Pitre &lt;nico@linaro.org&gt;
Acked-by: Olof Johansson &lt;olof@lixom.net&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@ti.com&gt;
Acked-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The patch contains the exception entry code (kernel/entry.S), pt_regs
structure and related accessors, undefined instruction trapping and
stack tracing.

AArch64 Linux kernel (including kernel threads) runs in EL1 mode using
the SP1 stack. The vectors don't have a fixed address, only alignment
(2^11) requirements.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Acked-by: Tony Lindgren &lt;tony@atomide.com&gt;
Acked-by: Nicolas Pitre &lt;nico@linaro.org&gt;
Acked-by: Olof Johansson &lt;olof@lixom.net&gt;
Acked-by: Santosh Shilimkar &lt;santosh.shilimkar@ti.com&gt;
Acked-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
</pre>
</div>
</content>
</entry>
</feed>
