• James Morse's avatar
    arm64: entry: Move ct_user_exit before any other exception · 2671828c
    James Morse authored
    When taking an SError or Debug exception from EL0, we run the C
    handler for these exceptions before updating the context tracking
    code and unmasking lower priority interrupts.
    
    When booting with nohz_full lockdep tells us we got this wrong:
    | =============================
    | WARNING: suspicious RCU usage
    | 5.3.0-rc2-00010-gb4b5e9dcb11b-dirty #11271 Not tainted
    | -----------------------------
    | include/linux/rcupdate.h:643 rcu_read_unlock() used illegally wh!
    |
    | other info that might help us debug this:
    |
    |
    | RCU used illegally from idle CPU!
    | rcu_scheduler_active = 2, debug_locks = 1
    | RCU used illegally from extended quiescent state!
    | 1 lock held by a.out/432:
    |  #0: 00000000c7a79515 (rcu_read_lock){....}, at: brk_handler+0x00
    |
    | stack backtrace:
    | CPU: 1 PID: 432 Comm: a.out Not tainted 5.3.0-rc2-00010-gb4b5e9d1
    | Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno De8
    | Call trace:
    |  dump_backtrace+0x0/0x140
    |  show_stack+0x14/0x20
    |  dump_stack+0xbc/0x104
    |  lockdep_rcu_suspicious+0xf8/0x108
    |  brk_handler+0x164/0x1b0
    |  do_debug_exception+0x11c/0x278
    |  el0_dbg+0x14/0x20
    
    Moving the ct_user_exit calls to be before do_debug_exception() means
    they are also before trace_hardirqs_off() has been updated. Add a new
    ct_user_exit_irqoff macro to avoid the context-tracking code using
    irqsave/restore before we've updated trace_hardirqs_off(). To be
    consistent, do this everywhere.
    
    The C helper is called enter_from_user_mode() to match x86 in the hope
    we can merge them into kernel/context_tracking.c later.
    
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Fixes: 6c81fe79 ("arm64: enable context tracking")
    Signed-off-by: default avatarJames Morse <james.morse@arm.com>
    Signed-off-by: default avatarWill Deacon <will@kernel.org>
    2671828c
exception.h 740 Bytes