From: David S. Miller Date: Wed, 25 May 2016 19:51:20 +0000 (-0700) Subject: sparc64: Take ctx_alloc_lock properly in hugetlb_setup(). X-Git-Tag: v4.1.12-92~74^2~12 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f7b5bfd45edab6d99bb1bb36187b7ce979e241f8;p=users%2Fjedix%2Flinux-maple.git sparc64: Take ctx_alloc_lock properly in hugetlb_setup(). On cheetahplus chips we take the ctx_alloc_lock in order to modify the TLB lookup parameters for the indexed TLBs, which are stored in the context register. This is called with interrupts disabled, however ctx_alloc_lock is an IRQ safe lock, therefore we must take acquire/release it properly with spin_{lock,unlock}_irq(). Orabug: 24671126 Reported-by: Meelis Roos Tested-by: Meelis Roos Signed-off-by: David S. Miller Signed-off-by: Allen Pais --- diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 012132d71e1c..086aa0901391 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -3254,9 +3254,10 @@ void hugetlb_setup(struct pt_regs *regs, unsigned int tsb_index) * the Data-TLB for huge pages. */ if (tlb_type == cheetah_plus) { + bool need_context_reload = false; unsigned long ctx; - spin_lock(&ctx_alloc_lock); + spin_lock_irq(&ctx_alloc_lock); ctx = mm->context.sparc64_ctx_val; ctx &= ~CTX_PGSZ_MASK; ctx |= CTX_PGSZ_BASE << CTX_PGSZ0_SHIFT; @@ -3275,9 +3276,12 @@ void hugetlb_setup(struct pt_regs *regs, unsigned int tsb_index) * also executing in this address space. */ mm->context.sparc64_ctx_val = ctx; - on_each_cpu(context_reload, mm, 0); + need_context_reload = true; } - spin_unlock(&ctx_alloc_lock); + spin_unlock_irq(&ctx_alloc_lock); + + if (need_context_reload) + on_each_cpu(context_reload, mm, 0); } } #endif