powerpc/64s: make linear_map_hash_lock a raw spinlock
authorNicholas Piggin <npiggin@gmail.com>
Thu, 13 Oct 2022 23:07:10 +0000 (09:07 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 18 Oct 2022 11:46:18 +0000 (22:46 +1100)
This lock is taken while the raw kfence_freelist_lock is held, so it
must also be a raw spinlock, as reported by lockdep when raw lock
nesting checking is enabled.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221013230710.1987253-3-npiggin@gmail.com
arch/powerpc/mm/book3s64/hash_utils.c

index df008ed..6df4c6d 100644 (file)
@@ -1981,7 +1981,7 @@ repeat:
 }
 
 #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KFENCE)
-static DEFINE_SPINLOCK(linear_map_hash_lock);
+static DEFINE_RAW_SPINLOCK(linear_map_hash_lock);
 
 static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
 {
@@ -2005,10 +2005,10 @@ static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
                                    mmu_linear_psize, mmu_kernel_ssize);
 
        BUG_ON (ret < 0);
-       spin_lock(&linear_map_hash_lock);
+       raw_spin_lock(&linear_map_hash_lock);
        BUG_ON(linear_map_hash_slots[lmi] & 0x80);
        linear_map_hash_slots[lmi] = ret | 0x80;
-       spin_unlock(&linear_map_hash_lock);
+       raw_spin_unlock(&linear_map_hash_lock);
 }
 
 static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
@@ -2018,14 +2018,14 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
        unsigned long vpn = hpt_vpn(vaddr, vsid, mmu_kernel_ssize);
 
        hash = hpt_hash(vpn, PAGE_SHIFT, mmu_kernel_ssize);
-       spin_lock(&linear_map_hash_lock);
+       raw_spin_lock(&linear_map_hash_lock);
        if (!(linear_map_hash_slots[lmi] & 0x80)) {
-               spin_unlock(&linear_map_hash_lock);
+               raw_spin_unlock(&linear_map_hash_lock);
                return;
        }
        hidx = linear_map_hash_slots[lmi] & 0x7f;
        linear_map_hash_slots[lmi] = 0;
-       spin_unlock(&linear_map_hash_lock);
+       raw_spin_unlock(&linear_map_hash_lock);
        if (hidx & _PTEIDX_SECONDARY)
                hash = ~hash;
        slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;