Skip to content

Commit 97806df

Browse files
author
Vasily Gorbik
committed
s390/unwind: make reuse_sp default when unwinding pt_regs
Currently unwinder yields 2 entries when pt_regs are met: sp="address of pt_regs itself" ip=pt_regs->psw sp=pt_regs->gprs[15] ip="r14 from stack frame pointed by pt_regs->gprs[15]" And neither of those 2 states (combination of sp and ip) ever happened. reuse_sp has been introduced by commit a1d863a ("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->gprs[15] ip=pt_regs->psw sp=pt_regs->gprs[15] ip="r14 from stack frame pointed by pt_regs->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 <heiko.carstens@de.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 67f5593 commit 97806df

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

‎arch/s390/include/asm/unwind.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ struct unwind_state {
3535
struct task_struct *task;
3636
struct pt_regs *regs;
3737
unsigned long sp, ip;
38-
bool reuse_sp;
3938
int graph_idx;
4039
bool reliable;
4140
bool error;

‎arch/s390/kernel/unwind_bc.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,7 @@ bool unwind_next_frame(struct unwind_state *state)
4646

4747
regs = state->regs;
4848
if (unlikely(regs)) {
49-
if (state->reuse_sp) {
50-
sp = state->sp;
51-
state->reuse_sp = false;
52-
} else {
53-
sp = READ_ONCE_NOCHECK(regs->gprs[15]);
54-
if (unlikely(outside_of_stack(state, sp))) {
55-
if (!update_stack_info(state, sp))
56-
goto out_err;
57-
}
58-
}
49+
sp = state->sp;
5950
sf = (struct stack_frame *) sp;
6051
ip = READ_ONCE_NOCHECK(sf->gprs[8]);
6152
reliable = false;
@@ -81,6 +72,11 @@ bool unwind_next_frame(struct unwind_state *state)
8172
if (READ_ONCE_NOCHECK(regs->psw.mask) & PSW_MASK_PSTATE)
8273
goto out_stop;
8374
ip = READ_ONCE_NOCHECK(regs->psw.addr);
75+
sp = READ_ONCE_NOCHECK(regs->gprs[15]);
76+
if (unlikely(outside_of_stack(state, sp))) {
77+
if (!update_stack_info(state, sp))
78+
goto out_err;
79+
}
8480
reliable = true;
8581
}
8682
}
@@ -107,7 +103,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
107103
{
108104
struct stack_info *info = &state->stack_info;
109105
unsigned long *mask = &state->stack_mask;
110-
bool reliable, reuse_sp;
106+
bool reliable;
111107
struct stack_frame *sf;
112108
unsigned long ip;
113109

@@ -134,12 +130,10 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
134130
if (regs) {
135131
ip = READ_ONCE_NOCHECK(regs->psw.addr);
136132
reliable = true;
137-
reuse_sp = true;
138133
} else {
139134
sf = (struct stack_frame *) sp;
140135
ip = READ_ONCE_NOCHECK(sf->gprs[8]);
141136
reliable = false;
142-
reuse_sp = false;
143137
}
144138

145139
ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, ip, NULL);
@@ -148,6 +142,5 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
148142
state->sp = sp;
149143
state->ip = ip;
150144
state->reliable = reliable;
151-
state->reuse_sp = reuse_sp;
152145
}
153146
EXPORT_SYMBOL_GPL(__unwind_start);

0 commit comments

Comments
 (0)