Changbin Du
1851b9a467
riscv: fix oops caused by irqsoff latency tracer
...
commit 22e2100b1b07d6f5acc71cc1acb53f680c677d77 upstream.
The trace_hardirqs_{on,off}() require the caller to setup frame pointer
properly. This because these two functions use macro 'CALLER_ADDR1' (aka.
__builtin_return_address(1)) to acquire caller info. If the $fp is used
for other purpose, the code generated this macro (as below) could trigger
memory access fault.
0xffffffff8011510e <+80>: ld a1,-16(s0)
0xffffffff80115112 <+84>: ld s2,-8(a1) # <-- paging fault here
The oops message during booting if compiled with 'irqoff' tracer enabled:
[ 0.039615][ T0] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000f8
[ 0.041925][ T0] Oops [#1 ]
[ 0.042063][ T0] Modules linked in:
[ 0.042864][ T0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.17.0-rc1-00233-g9a20c48d1ed2 #29
[ 0.043568][ T0] Hardware name: riscv-virtio,qemu (DT)
[ 0.044343][ T0] epc : trace_hardirqs_on+0x56/0xe2
[ 0.044601][ T0] ra : restore_all+0x12/0x6e
[ 0.044721][ T0] epc : ffffffff80126a5c ra : ffffffff80003b94 sp : ffffffff81403db0
[ 0.044801][ T0] gp : ffffffff8163acd8 tp : ffffffff81414880 t0 : 0000000000000020
[ 0.044882][ T0] t1 : 0098968000000000 t2 : 0000000000000000 s0 : ffffffff81403de0
[ 0.044967][ T0] s1 : 0000000000000000 a0 : 0000000000000001 a1 : 0000000000000100
[ 0.045046][ T0] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000
[ 0.045124][ T0] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000054494d45
[ 0.045210][ T0] s2 : ffffffff80003b94 s3 : ffffffff81a8f1b0 s4 : ffffffff80e27b50
[ 0.045289][ T0] s5 : ffffffff81414880 s6 : ffffffff8160fa00 s7 : 00000000800120e8
[ 0.045389][ T0] s8 : 0000000080013100 s9 : 000000000000007f s10: 0000000000000000
[ 0.045474][ T0] s11: 0000000000000000 t3 : 7fffffffffffffff t4 : 0000000000000000
[ 0.045548][ T0] t5 : 0000000000000000 t6 : ffffffff814aa368
[ 0.045620][ T0] status: 0000000200000100 badaddr: 00000000000000f8 cause: 000000000000000d
[ 0.046402][ T0] [<ffffffff80003b94>] restore_all+0x12/0x6e
This because the $fp(aka. $s0) register is not used as frame pointer in the
assembly entry code.
resume_kernel:
REG_L s0, TASK_TI_PREEMPT_COUNT(tp)
bnez s0, restore_all
REG_L s0, TASK_TI_FLAGS(tp)
andi s0, s0, _TIF_NEED_RESCHED
beqz s0, restore_all
call preempt_schedule_irq
j restore_all
To fix above issue, here we add one extra level wrapper for function
trace_hardirqs_{on,off}() so they can be safely called by low level entry
code.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Fixes: 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-02 11:48:08 +01:00
..
2021-07-21 23:22:34 -07:00
2021-10-02 13:42:25 -07:00
2020-03-25 11:50:48 +01:00
2021-07-05 18:04:00 -07:00
2021-09-01 10:29:10 +02:00
2020-03-31 11:28:30 -07:00
2020-03-31 11:25:56 -07:00
2020-10-25 14:51:49 -07:00
2022-02-16 12:56:18 +01:00
2020-06-09 19:11:20 -07:00
2021-05-29 13:39:27 -07:00
2021-04-26 08:25:24 -07:00
2021-04-26 08:25:23 -07:00
2020-10-02 14:31:16 -07:00
2020-10-02 14:31:28 -07:00
2022-03-02 11:48:08 +01:00
2019-11-05 09:20:42 -08:00
2021-01-14 15:09:05 -08:00
2021-04-26 08:31:28 -07:00
2021-10-27 13:08:01 -07:00
2021-02-18 23:18:00 -08:00
2020-06-09 19:11:24 -07:00
2020-07-30 11:37:43 -07:00
2022-01-27 11:02:50 +01:00
2020-07-09 20:09:30 -07:00
2022-01-27 11:02:50 +01:00
2022-03-02 11:48:08 +01:00
2021-01-14 15:09:05 -08:00
2021-04-26 08:25:01 -07:00
2019-10-28 00:46:01 -07:00
2021-04-26 08:25:15 -07:00
2021-01-14 15:09:01 -08:00
2022-01-20 09:13:14 +01:00
2020-05-11 13:48:19 -07:00
2020-11-09 18:12:34 +01:00
2021-05-25 22:56:57 -07:00
2021-08-24 20:54:10 -07:00
2019-11-13 13:22:52 -08:00
2020-12-10 17:27:54 -08:00
2021-05-06 09:24:18 -07:00
2022-01-27 11:02:50 +01:00
2021-05-25 22:56:57 -07:00
2022-01-27 11:02:50 +01:00
2021-05-12 13:01:45 +02:00
2021-01-07 19:00:50 -08:00
2022-02-16 12:56:18 +01:00
2020-06-18 17:28:53 -07:00
2021-10-02 13:42:23 -07:00
2021-05-06 09:24:18 -07:00
2022-03-02 11:48:08 +01:00
2022-03-02 11:48:08 +01:00
2020-04-03 10:45:33 -07:00
2021-09-08 11:50:27 -07:00
2021-10-02 13:42:26 -07:00
2021-09-10 23:59:48 -07:00
2021-09-10 23:59:48 -07:00