<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/arch/s390/include/asm/unwind.h, branch linux-5.14.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.14.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.14.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2021-09-26T12:10:22Z</updated>
<entry>
<title>s390/unwind: use current_frame_address() to unwind current task</title>
<updated>2021-09-26T12:10:22Z</updated>
<author>
<name>Vasily Gorbik</name>
<email>gor@linux.ibm.com</email>
</author>
<published>2021-09-01T14:05:59Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e0f8639c87e1aacf46f542f98c271010a96130e3'/>
<id>urn:sha1:e0f8639c87e1aacf46f542f98c271010a96130e3</id>
<content type='text'>
[ Upstream commit 88b604263f3d6eedae0b1c2c3bbd602d1e2e8775 ]

current_stack_pointer() simply returns current value of %r15. If
current_stack_pointer() caller allocates stack (which is the case in
unwind code) %r15 points to a stack frame allocated for callees, meaning
current_stack_pointer() caller (e.g. stack_trace_save) will end up in
the stacktrace. This is not expected by stack_trace_save*() callers and
causes problems.

current_frame_address() on the other hand returns function stack frame
address, which matches %r15 upon function invocation. Using it in
get_stack_pointer() makes it more aligned with x86 implementation
(according to BACKTRACE_SELF_TEST output) and meets stack_trace_save*()
caller's expectations, notably KCSAN.

Also make sure unwind_start is always inlined.

Reported-by: Nathan Chancellor &lt;nathan@kernel.org&gt;
Suggested-by: Marco Elver &lt;elver@google.com&gt;
Signed-off-by: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
Tested-by: Marco Elver &lt;elver@google.com&gt;
Tested-by: Nathan Chancellor &lt;nathan@kernel.org&gt;
Link: https://lore.kernel.org/r/patch.git-04dd26be3043.your-ad-here.call-01630504868-ext-6188@work.hours
Signed-off-by: Heiko Carstens &lt;hca@linux.ibm.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>s390/unwind: start unwinding from reliable state</title>
<updated>2019-11-30T09:52:48Z</updated>
<author>
<name>Vasily Gorbik</name>
<email>gor@linux.ibm.com</email>
</author>
<published>2019-11-27T16:37:51Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=222ee9087a730b1df08d09baed0d03626e67600f'/>
<id>urn:sha1:222ee9087a730b1df08d09baed0d03626e67600f</id>
<content type='text'>
A comment in arch/s390/include/asm/unwind.h says:
&gt; If 'first_frame' is not zero unwind_start skips unwind frames until it
&gt; reaches the specified stack pointer.
&gt; The end of the unwinding is indicated with unwind_done, this can be true
&gt; right after unwind_start, e.g. with first_frame!=0 that can not be found.
&gt; unwind_next_frame skips to the next frame.
&gt; Once the unwind is completed unwind_error() can be used to check if there
&gt; has been a situation where the unwinder could not correctly understand
&gt; the tasks call chain.

With this change backchain unwinder now comply with behaviour
described. As well as matches orc unwinder implementation.  Now unwinder
starts from reliable state, i.e. __unwind_start own stack frame is
taken or stack frame generated by __switch_to (ksp) - both known to be
valid. In case of pt_regs %r15 is better match for pt_regs psw, than
sometimes random "sp" caller passed.

Reviewed-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Signed-off-by: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>s390/unwind: make reuse_sp default when unwinding pt_regs</title>
<updated>2019-11-30T09:52:45Z</updated>
<author>
<name>Vasily Gorbik</name>
<email>gor@linux.ibm.com</email>
</author>
<published>2019-11-22T14:58:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=97806dfb6f3838ee4b7bc69e6f160d83eadbc74a'/>
<id>urn:sha1:97806dfb6f3838ee4b7bc69e6f160d83eadbc74a</id>
<content type='text'>
Currently unwinder yields 2 entries when pt_regs are met:
sp="address of pt_regs itself" ip=pt_regs-&gt;psw
sp=pt_regs-&gt;gprs[15] ip="r14 from stack frame pointed by pt_regs-&gt;gprs[15]"

And neither of those 2 states (combination of sp and ip) ever happened.

reuse_sp has been introduced by commit a1d863ac3e10 ("s390/unwind: fix
mixing regs and sp"). reuse_sp=true makes unwinder keen to produce the
following result, when pt_regs are given (as an arg to unwind_start):
sp=pt_regs-&gt;gprs[15] ip=pt_regs-&gt;psw
sp=pt_regs-&gt;gprs[15] ip="r14 from stack frame pointed by pt_regs-&gt;gprs[15]"

The first state is an actual state in which a task was when pt_regs were
collected. The second state is marked unreliable and is for debugging
purposes to cover the case when a task has been interrupted in between
stack frame allocation and writing back_chain - in this case r14 might
show an actual caller.

Make unwinder behaviour enabled via reuse_sp=true default and drop the
special case handling.

Reviewed-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Signed-off-by: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>s390/unwind: unify task is current checks</title>
<updated>2019-11-30T09:52:45Z</updated>
<author>
<name>Vasily Gorbik</name>
<email>gor@linux.ibm.com</email>
</author>
<published>2019-11-22T11:35:34Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=103b4cca60d2c8c51f1290cc984b7046ccb8b46d'/>
<id>urn:sha1:103b4cca60d2c8c51f1290cc984b7046ccb8b46d</id>
<content type='text'>
Avoid mixture of task == NULL and task == current meaning the same
thing and simply always initialize task with current in unwind_start.

Reviewed-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Signed-off-by: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>s390/unwind: fix mixing regs and sp</title>
<updated>2019-10-31T16:26:48Z</updated>
<author>
<name>Ilya Leoshkevich</name>
<email>iii@linux.ibm.com</email>
</author>
<published>2019-10-02T11:29:57Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=a1d863ac3e1085e1fea9caafd87252d08731de2e'/>
<id>urn:sha1:a1d863ac3e1085e1fea9caafd87252d08731de2e</id>
<content type='text'>
unwind_for_each_frame stops after the first frame if regs-&gt;gprs[15] &lt;=
sp.

The reason is that in case regs are specified, the first frame should be
regs-&gt;psw.addr and the second frame should be sp-&gt;gprs[8]. However,
currently the second frame is regs-&gt;gprs[15], which confuses
outside_of_stack().

Fix by introducing a flag to distinguish this special case from
unwinding the interrupt handler, for which the current behavior is
appropriate.

Fixes: 78c98f907413 ("s390/unwind: introduce stack unwind API")
Signed-off-by: Ilya Leoshkevich &lt;iii@linux.ibm.com&gt;
Cc: stable@vger.kernel.org # v5.2+
Reviewed-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Signed-off-by: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>s390/unwind: cleanup unused READ_ONCE_TASK_STACK</title>
<updated>2019-07-02T14:00:27Z</updated>
<author>
<name>Vasily Gorbik</name>
<email>gor@linux.ibm.com</email>
</author>
<published>2019-06-20T08:18:35Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=da1776733617c4a92319eddb4e765ce60426b20a'/>
<id>urn:sha1:da1776733617c4a92319eddb4e765ce60426b20a</id>
<content type='text'>
Kasan instrumentation of backchain unwinder stack reads is disabled
completely and simply uses READ_ONCE_NOCHECK now.
READ_ONCE_TASK_STACK macro is unused and could be removed.

Signed-off-by: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>s390/unwind: introduce stack unwind API</title>
<updated>2019-05-02T11:54:11Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2019-01-28T07:33:08Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=78c98f9074135d3dab4e39544e0a537f92388fce'/>
<id>urn:sha1:78c98f9074135d3dab4e39544e0a537f92388fce</id>
<content type='text'>
Rework the dump_trace() stack unwinder interface to support different
unwinding algorithms. The new interface looks like this:

	struct unwind_state state;
	unwind_for_each_frame(&amp;state, task, regs, start_stack)
		do_something(state.sp, state.ip, state.reliable);

The unwind_bc.c file contains the implementation for the classic
back-chain unwinder.

One positive side effect of the new code is it now handles ftraced
functions gracefully. It prints the real name of the return function
instead of 'return_to_handler'.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
</content>
</entry>
</feed>
