Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries: Limit machine check stack to 4GB

This allows rtas_args to be put on the machine check stack, which
avoids a lot of complications with re-entrancy deadlocks.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Link: https://lore.kernel.org/r/20200508043408.886394-10-npiggin@gmail.com

authored by

Nicholas Piggin and committed by
Michael Ellerman
d2cbbd45 d7b14c5c

+12 -3
+12 -3
arch/powerpc/kernel/setup_64.c
··· 709 709 */ 710 710 void __init emergency_stack_init(void) 711 711 { 712 - u64 limit; 712 + u64 limit, mce_limit; 713 713 unsigned int i; 714 714 715 715 /* ··· 726 726 * initialized in kernel/irq.c. These are initialized here in order 727 727 * to have emergency stacks available as early as possible. 728 728 */ 729 - limit = min(ppc64_bolted_size(), ppc64_rma_size); 729 + limit = mce_limit = min(ppc64_bolted_size(), ppc64_rma_size); 730 + 731 + /* 732 + * Machine check on pseries calls rtas, but can't use the static 733 + * rtas_args due to a machine check hitting while the lock is held. 734 + * rtas args have to be under 4GB, so the machine check stack is 735 + * limited to 4GB so args can be put on stack. 736 + */ 737 + if (firmware_has_feature(FW_FEATURE_LPAR) && mce_limit > SZ_4G) 738 + mce_limit = SZ_4G; 730 739 731 740 for_each_possible_cpu(i) { 732 741 paca_ptrs[i]->emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; ··· 745 736 paca_ptrs[i]->nmi_emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; 746 737 747 738 /* emergency stack for machine check exception handling. */ 748 - paca_ptrs[i]->mc_emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; 739 + paca_ptrs[i]->mc_emergency_sp = alloc_stack(mce_limit, i) + THREAD_SIZE; 749 740 #endif 750 741 } 751 742 }