[PATCH] riscv: Fix TRACE_IRQFLAGS call points in entry.S

Guo Ren guoren at kernel.org
Tue Sep 13 06:45:30 PDT 2022


On Tue, Sep 13, 2022 at 7:21 PM Yipeng Zou <zouyipeng at huawei.com> wrote:
>
>
> 在 2022/9/11 8:45, Guo Ren 写道:
> > I think it would be fixed by GENERIC_ENTRY. You could have a try.
> >
> > https://lore.kernel.org/linux-riscv/20220908022506.1275799-1-guoren@kernel.org/
>
> I test your patch and yes the WARNING was gone.
Thx, could you give me a Tested-by?

>
> But I'm just wondering about the other stable branches, will your patch
> be merged into these branches?
No, your patch is still worth for stable branches.

>
> > On Fri, Sep 9, 2022 at 5:46 PM Yipeng Zou<zouyipeng at huawei.com>  wrote:
> >> TRACE_IRQFLAGS need trace all {Enable,Disable} hard interrupts points
> >> in entry.S.
> >> We miss a path(work_notifysig) that cause an WARN as shown below.
> >>
> >> [   50.362431] ------------[ cut here ]------------
> >> [   50.363607] DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled())
> >> [   50.367229] WARNING: CPU: 3 PID: 74 at kernel/locking/lockdep.c:5510 check_flags+0x10a/0x1e0
> >> [   50.368905] Modules linked in:
> >> [   50.369440] CPU: 3 PID: 74 Comm: rcS Tainted: G
> >> [   50.370225] Hardware name: riscv-virtio,qemu (DT)
> >> [   50.370632] epc : check_flags+0x10a/0x1e0
> >> [   50.371015]  ra : check_flags+0x10a/0x1e0
> >> [   50.371751] epc : ffffffff808e2670 ra : ffffffff808e2670 sp : ff20000000c3bca0
> >> [   50.372721]  gp : ffffffff817e2188 tp : ff60000002fe1800 t0 : ffffffff8162a2a8
> >> [   50.373321]  t1 : 0000000000000001 t2 : 2d2d2d2d2d2d2d2d s0 : ff20000000c3bcc0
> >> [   50.373903]  s1 : ffffffff817e3340 a0 : 0000000000000030 a1 : ffffffff81693fa8
> >> [   50.374476]  a2 : 0000000000000010 a3 : fffffffffffffffe a4 : 083151a422b8df00
> >> [   50.375039]  a5 : 083151a422b8df00 a6 : ffffffff8006891e a7 : 083151a422b8df00
> >> [   50.376028]  s2 : ffffffff817e54e0 s3 : ffffffff81695070 s4 : ff600000027d7800
> >> [   50.376978]  s5 : ffffffff80c22770 s6 : 0000000200000022 s7 : ffffffffffffffff
> >> [   50.377779]  s8 : ffffffff82301ed0 s9 : 0000000000001000 s10: 00000000001a9905
> >> [   50.378335]  s11: 000000000014f3e8 t3 : ffffffff822d714f t4 : ffffffff822d714f
> >> [   50.378955]  t5 : ffffffff822d7150 t6 : ff20000000c3ba98
> >> [   50.379783] status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003
> >> [   50.380810] [<ffffffff808e27be>] lock_is_held_type+0x78/0x14e
> >> [   50.381477] [<ffffffff8003e850>] __might_resched+0x26/0x22c
> >> [   50.382006] [<ffffffff8003ea92>] __might_sleep+0x3c/0x66
> >> [   50.382477] [<ffffffff8002324e>] get_signal+0xaa/0x912
> >> [   50.382947] [<ffffffff80005368>] do_notify_resume+0x82/0x434
> >> [   50.383839] [<ffffffff80003bec>] ret_from_exception+0x0/0x10
> >>
> >> Fixes: 3c4697982982 ("riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")
> >> Signed-off-by: Yipeng Zou<zouyipeng at huawei.com>
> >> ---
> >>   arch/riscv/kernel/entry.S | 6 +++++-
> >>   1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
> >> index b9eda3fcbd6d..f4d23995a4f1 100644
> >> --- a/arch/riscv/kernel/entry.S
> >> +++ b/arch/riscv/kernel/entry.S
> >> @@ -370,16 +370,20 @@ resume_kernel:
> >>
> >>   work_pending:
> >>          /* Enter slow path for supplementary processing */
> >> -       la ra, ret_from_exception
> >>          andi s1, s0, _TIF_NEED_RESCHED
> >>          bnez s1, work_resched
> >>   work_notifysig:
> >> +#ifdef CONFIG_TRACE_IRQFLAGS
> >> +       call __trace_hardirqs_on
> >> +#endif
> >> +       la ra, ret_from_exception
> >>          /* Handle pending signals and notify-resume requests */
> >>          csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */
> >>          move a0, sp /* pt_regs */
> >>          move a1, s0 /* current_thread_info->flags */
> >>          tail do_notify_resume
> >>   work_resched:
> >> +       la ra, ret_from_exception
> >>          tail schedule
> >>
> >>   /* Slow paths for ptrace. */
> >> --
> >> 2.17.1
> >>
> --
> Regards,
> Yipeng Zou
>


-- 
Best Regards
 Guo Ren



More information about the linux-riscv mailing list