Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: In order to enable lockdep support, we need a compelte TRACE_IRQFLAGS support. While enabled previously, there no trace_hardirqs support leading to various errors when enabling PROVE_LOCKING. This patch adds necessary calls to trace_hardirqs_on/off in assembly to correctly track irqs state when entering exceptions. During testing, a problem arose when calling trace_hardirqs_off indirectly from module: ``` ------------[ cut here ]------------ WARNING: CPU: 0 PID: 59 at kernel/locking/lockdep.c:4329 check_flags.part.23+0x23c/0x240 DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled) Modules linked in: crc32c_generic(+) loop ext4 crc16 mbcache jbd2 crypto_hash crypto_algapi crypto m) CPU: 0 PID: 59 Comm: modprobe Tainted: G O 5.3.0 torvalds#135 Hardware name: Kalray HAPS prototyping (LS) (DT) ... Call Trace: [<ffffff80007816e8>] dump_stack+0x30/0x50 [<ffffff8000216c98>] __warn+0x138/0x158 [<ffffff8000216d10>] warn_slowpath_fmt+0x58/0x78 [<ffffff800026224c>] check_flags.part.23+0x23c/0x240 [<ffffff800026649c>] lock_is_held_type+0x1a4/0x1b0 [<ffffff8000282dd0>] rcu_read_lock_sched_held+0x88/0x90 [<ffffff80002a2fac>] module_assert_mutex_or_preempt+0x2c/0x98 [<ffffff80002a3988>] __module_address+0x48/0x150 [<ffffff80002a3ab0>] __module_text_address+0x20/0xb0 [<ffffff80002a7900>] is_module_text_address+0x18/0x38 [<ffffff800023be04>] kernel_text_address+0x8c/0xb8 [<ffffff800023be50>] __kernel_text_address+0x20/0x90 [<ffffff800020ded8>] walk_stackframe+0x78/0xe0 [<ffffff800020e5e8>] return_address+0x58/0x90 [<ffffff80002c3650>] trace_hardirqs_off+0x68/0x1b8 [<ffffff800036912c>] kfree+0xe4/0x328 [<ffffff8040087c3c>] crypto_larval_destroy+0x54/0x78 [crypto] [<ffffff8040087464>] crypto_larval_kill+0xd4/0xf8 [crypto] [<ffffff804008080c>] crypto_wait_for_test+0x9c/0x108 [crypto_algapi] [<ffffff8040080e24>] crypto_register_alg+0xdc/0xe8 [crypto_algapi] [<ffffff804008d308>] crypto_register_shash+0x48/0x70 [crypto_hash] [<ffffff8040096030>] crc32c_mod_init+0x30/0x4c [crc32c_generic] [<ffffff80002099d8>] do_one_initcall+0x70/0x2b0 [<ffffff80002a7ed4>] do_init_module+0x74/0x270 [<ffffff80002a6a04>] load_module+0x223c/0x26f0 [<ffffff80002a70c8>] sys_finit_module+0xb0/0x118 irq event stamp: 1989 hardirqs last enabled at (1989): [<ffffff80007a8854>] _raw_spin_unlock_irqrestore+0x8c/0xa0 hardirqs last disabled at (1988): [<ffffff80007a861c>] _raw_spin_lock_irqsave+0x34/0x88 softirqs last enabled at (1940): [<ffffff80007ab04c>] _etext+0x38c/0x2340 softirqs last disabled at (1935): [<ffffff800021c754>] irq_exit+0xa4/0xa8 ---[ end trace f667df957dc78eed ]--- possible reason: unannotated irqs-off. ``` Problem is due to the fact trace_hardirqs_off used CALLER_ADDR0 and CALLER_ADDR1. These macros indirectly uses return_addr. Then in walk_stackframe, address of frame pointer ra is checked to be a kernel address using __kernel_text_address. In this function, __module_address take a lock which trigger a hardirqs check that fails. However, since we are calling it to report that trace_hardirqs are off, this is triggering a check before even tracking that irqs are off. Remove the call to __kernel_text_address as it is also not done on arm64. Ref T10401 Test Plan: Executed both smp & valid images on FPGA and verified that there are no signaled lockdep errors. Note that this can't run on debug image since the overhead to call trace_hardirqs_on in exception does not leave any time for normal code to execute. Reviewers: O51 Linux Coolidge, gthouvenin Reviewed By: O51 Linux Coolidge, gthouvenin Subscribers: gthouvenin, jcpince, alfred, #linux_coolidge_cc Maniphest Tasks: T10401 Differential Revision: https://phab.kalray.eu/D2034
- Loading branch information