• Nicholas Piggin's avatar
    powerpc/64s: make HPTE lock and native_tlbie_lock irq-safe · 35159b57
    Nicholas Piggin authored
    With kfence enabled, there are several cases where HPTE and TLBIE locks
    are called from softirq context, for example:
    
      WARNING: inconsistent lock state
      6.0.0-11845-g0cbbc95b12ac #1 Tainted: G                 N
      --------------------------------
      inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
      swapper/0/1 [HC0[0]:SC0[0]:HE1:SE1] takes:
      c000000002734de8 (native_tlbie_lock){+.?.}-{2:2}, at: .native_hpte_updateboltedpp+0x1a4/0x600
      {IN-SOFTIRQ-W} state was registered at:
        .lock_acquire+0x20c/0x520
        ._raw_spin_lock+0x4c/0x70
        .native_hpte_invalidate+0x62c/0x840
        .hash__kernel_map_pages+0x450/0x640
        .kfence_protect+0x58/0xc0
        .kfence_guarded_free+0x374/0x5a0
        .__slab_free+0x3d0/0x630
        .put_cred_rcu+0xcc/0x120
        .rcu_core+0x3c4/0x14e0
        .__do_softirq+0x1dc/0x7dc
        .do_softirq_own_stack+0x40/0x60
    
    Fix this by consistently disabling irqs while taking either of these
    locks. Don't just disable bh because several of the more common cases
    already disable irqs, so this just makes the locks always irq-safe.
    Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
    Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20221013230710.1987253-2-npiggin@gmail.com
    35159b57
hash_native.c 22.4 KB