Rebased from upstream / out of band repository.
[librecmc/librecmc.git] / target / linux / generic / pending-4.19 / 102-MIPS-only-process-negative-stack-offsets-on-stack-tr.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 18 Apr 2018 10:50:05 +0200
3 Subject: [PATCH] MIPS: only process negative stack offsets on stack traces
4
5 Fixes endless back traces in cases where the compiler emits a stack
6 pointer increase in a branch delay slot (probably for some form of
7 function return).
8
9 [    3.475442] BUG: MAX_STACK_TRACE_ENTRIES too low!
10 [    3.480070] turning off the locking correctness validator.
11 [    3.485521] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.34 #0
12 [    3.491475] Stack : 00000000 00000000 00000000 00000000 80e0fce2 00000034 00000000 00000000
13 [    3.499764]         87c3838c 80696377 8061047c 00000000 00000001 00000001 87c2d850 6534689f
14 [    3.508059]         00000000 00000000 80e10000 00000000 00000000 000000cf 0000000f 00000000
15 [    3.516353]         00000000 806a0000 00076891 00000000 00000000 00000000 ffffffff 00000000
16 [    3.524648]         806c0000 00000004 80e10000 806a0000 00000003 80690000 00000000 80700000
17 [    3.532942]         ...
18 [    3.535362] Call Trace:
19 [    3.537818] [<80010a48>] show_stack+0x58/0x100
20 [    3.542207] [<804c2f78>] dump_stack+0xe8/0x170
21 [    3.546613] [<80079f90>] save_trace+0xf0/0x110
22 [    3.551010] [<8007b1ec>] mark_lock+0x33c/0x78c
23 [    3.555413] [<8007bf48>] __lock_acquire+0x2ac/0x1a08
24 [    3.560337] [<8007de60>] lock_acquire+0x64/0x8c
25 [    3.564846] [<804e1570>] _raw_spin_lock_irqsave+0x54/0x78
26 [    3.570186] [<801b618c>] kernfs_notify+0x94/0xac
27 [    3.574770] [<801b7b10>] sysfs_notify+0x74/0xa0
28 [    3.579257] [<801b618c>] kernfs_notify+0x94/0xac
29 [    3.583839] [<801b7b10>] sysfs_notify+0x74/0xa0
30 [    3.588329] [<801b618c>] kernfs_notify+0x94/0xac
31 [    3.592911] [<801b7b10>] sysfs_notify+0x74/0xa0
32 [    3.597401] [<801b618c>] kernfs_notify+0x94/0xac
33 [    3.601983] [<801b7b10>] sysfs_notify+0x74/0xa0
34 [    3.606473] [<801b618c>] kernfs_notify+0x94/0xac
35 [    3.611055] [<801b7b10>] sysfs_notify+0x74/0xa0
36 [    3.615545] [<801b618c>] kernfs_notify+0x94/0xac
37 [    3.620125] [<801b7b10>] sysfs_notify+0x74/0xa0
38 [    3.624619] [<801b618c>] kernfs_notify+0x94/0xac
39 [    3.629197] [<801b7b10>] sysfs_notify+0x74/0xa0
40 [    3.633691] [<801b618c>] kernfs_notify+0x94/0xac
41 [    3.638269] [<801b7b10>] sysfs_notify+0x74/0xa0
42 [    3.642763] [<801b618c>] kernfs_notify+0x94/0xac
43
44 Signed-off-by: Felix Fietkau <nbd@nbd.name>
45 ---
46
47 --- a/arch/mips/kernel/process.c
48 +++ b/arch/mips/kernel/process.c
49 @@ -361,6 +361,8 @@ static inline int is_sp_move_ins(union m
50  
51         if (ip->i_format.opcode == addiu_op ||
52             ip->i_format.opcode == daddiu_op) {
53 +               if (ip->i_format.simmediate > 0)
54 +                       return 0;
55                 *frame_size = -ip->i_format.simmediate;
56                 return 1;
57         }