2019-05-27 09:55:01 +03:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2016-07-05 08:07:51 +03:00
/*
* Prototypes for functions that are shared between setup_ ( 32 | 64 | common ) . c
*
* Copyright 2016 Michael Ellerman , IBM Corporation .
*/
# ifndef __ARCH_POWERPC_KERNEL_SETUP_H
# define __ARCH_POWERPC_KERNEL_SETUP_H
void initialize_cache_info ( void ) ;
void irqstack_early_init ( void ) ;
# ifdef CONFIG_PPC32
void setup_power_save ( void ) ;
# else
2021-01-25 12:53:38 +03:00
static inline void setup_power_save ( void ) { }
2016-07-05 08:07:51 +03:00
# endif
# if defined(CONFIG_PPC64) && defined(CONFIG_SMP)
void check_smt_enabled ( void ) ;
# else
2021-01-25 12:53:38 +03:00
static inline void check_smt_enabled ( void ) { }
2016-07-05 08:07:51 +03:00
# endif
2022-09-19 20:01:33 +03:00
# if defined(CONFIG_PPC_BOOK3E_64) && defined(CONFIG_SMP)
2016-07-05 08:07:51 +03:00
void setup_tlb_core_data ( void ) ;
# else
2021-01-25 12:53:38 +03:00
static inline void setup_tlb_core_data ( void ) { }
2016-07-05 08:07:51 +03:00
# endif
2021-10-19 10:29:25 +03:00
# ifdef CONFIG_BOOKE_OR_40x
2016-07-05 08:07:51 +03:00
void exc_lvl_early_init ( void ) ;
# else
2021-01-25 12:53:38 +03:00
static inline void exc_lvl_early_init ( void ) { }
2016-07-05 08:07:51 +03:00
# endif
powerpc/32: Add early stack overflow detection with VMAP stack.
To avoid recursive faults, stack overflow detection has to be
performed before writing in the stack in exception prologs.
Do it by checking the alignment. If the stack pointer alignment is
wrong, it means it is pointing to the following or preceding page.
Without VMAP stack, a stack overflow is catastrophic. With VMAP
stack, a stack overflow isn't destructive, so don't panic. Kill
the task with SIGSEGV instead.
A dedicated overflow stack is set up for each CPU.
lkdtm: Performing direct entry EXHAUST_STACK
lkdtm: Calling function with 512 frame size to depth 32 ...
lkdtm: loop 32/32 ...
lkdtm: loop 31/32 ...
lkdtm: loop 30/32 ...
lkdtm: loop 29/32 ...
lkdtm: loop 28/32 ...
lkdtm: loop 27/32 ...
lkdtm: loop 26/32 ...
lkdtm: loop 25/32 ...
lkdtm: loop 24/32 ...
lkdtm: loop 23/32 ...
lkdtm: loop 22/32 ...
lkdtm: loop 21/32 ...
lkdtm: loop 20/32 ...
Kernel stack overflow in process test[359], r1=c900c008
Oops: Kernel stack overflow, sig: 6 [#1]
BE PAGE_SIZE=4K MMU=Hash PowerMac
Modules linked in:
CPU: 0 PID: 359 Comm: test Not tainted 5.3.0-rc7+ #2225
NIP: c0622060 LR: c0626710 CTR: 00000000
REGS: c0895f48 TRAP: 0000 Not tainted (5.3.0-rc7+)
MSR: 00001032 <ME,IR,DR,RI> CR: 28004224 XER: 00000000
GPR00: c0626ca4 c900c008 c783c000 c07335cc c900c010 c07335cc c900c0f0 c07335cc
GPR08: c900c0f0 00000001 00000000 00000000 28008222 00000000 00000000 00000000
GPR16: 00000000 00000000 10010128 10010000 b799c245 10010158 c07335cc 00000025
GPR24: c0690000 c08b91d4 c068f688 00000020 c900c0f0 c068f668 c08b95b4 c08b91d4
NIP [c0622060] format_decode+0x0/0x4d4
LR [c0626710] vsnprintf+0x80/0x5fc
Call Trace:
[c900c068] [c0626ca4] vscnprintf+0x18/0x48
[c900c078] [c007b944] vprintk_store+0x40/0x214
[c900c0b8] [c007bf50] vprintk_emit+0x90/0x1dc
[c900c0e8] [c007c5cc] printk+0x50/0x60
[c900c128] [c03da5b0] recursive_loop+0x44/0x6c
[c900c338] [c03da5c4] recursive_loop+0x58/0x6c
[c900c548] [c03da5c4] recursive_loop+0x58/0x6c
[c900c758] [c03da5c4] recursive_loop+0x58/0x6c
[c900c968] [c03da5c4] recursive_loop+0x58/0x6c
[c900cb78] [c03da5c4] recursive_loop+0x58/0x6c
[c900cd88] [c03da5c4] recursive_loop+0x58/0x6c
[c900cf98] [c03da5c4] recursive_loop+0x58/0x6c
[c900d1a8] [c03da5c4] recursive_loop+0x58/0x6c
[c900d3b8] [c03da5c4] recursive_loop+0x58/0x6c
[c900d5c8] [c03da5c4] recursive_loop+0x58/0x6c
[c900d7d8] [c03da5c4] recursive_loop+0x58/0x6c
[c900d9e8] [c03da5c4] recursive_loop+0x58/0x6c
[c900dbf8] [c03da5c4] recursive_loop+0x58/0x6c
[c900de08] [c03da67c] lkdtm_EXHAUST_STACK+0x30/0x4c
[c900de18] [c03da3e8] direct_entry+0xc8/0x140
[c900de48] [c029fb40] full_proxy_write+0x64/0xcc
[c900de68] [c01500f8] __vfs_write+0x30/0x1d0
[c900dee8] [c0152cb8] vfs_write+0xb8/0x1d4
[c900df08] [c0152f7c] ksys_write+0x58/0xe8
[c900df38] [c0014208] ret_from_syscall+0x0/0x34
--- interrupt: c01 at 0xf806664
LR = 0x1000c868
Instruction dump:
4bffff91 80010014 7c832378 7c0803a6 38210010 4e800020 3d20c08a 3ca0c089
8089a0cc 38a58f0c 38600001 4ba2d494 <9421ffe0> 7c0802a6 bfc10018 7c9f2378
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1b89c121b4070c7ee99e4f22cc178f15a736b07b.1576916812.git.christophe.leroy@c-s.fr
2019-12-21 11:32:29 +03:00
# if defined(CONFIG_PPC64) || defined(CONFIG_VMAP_STACK)
2016-07-05 08:07:51 +03:00
void emergency_stack_init ( void ) ;
# else
2021-01-25 12:53:38 +03:00
static inline void emergency_stack_init ( void ) { }
2016-07-05 08:07:51 +03:00
# endif
2017-12-22 14:17:13 +03:00
# ifdef CONFIG_PPC64
u64 ppc64_bolted_size ( void ) ;
2018-02-13 18:08:17 +03:00
/* Default SPR values from firmware/kexec */
extern unsigned long spr_default_dscr ;
2017-12-22 14:17:13 +03:00
# endif
2016-07-05 08:07:51 +03:00
/*
* Having this in kvm_ppc . h makes include dependencies too
* tricky to solve for setup - common . c so have it here .
*/
# ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
void kvm_cma_reserve ( void ) ;
# else
2021-01-25 12:53:38 +03:00
static inline void kvm_cma_reserve ( void ) { }
2016-07-05 08:07:51 +03:00
# endif
2018-04-04 23:10:28 +03:00
# ifdef CONFIG_TAU
u32 cpu_temp ( unsigned long cpu ) ;
u32 cpu_temp_both ( unsigned long cpu ) ;
u32 tau_interrupts ( unsigned long cpu ) ;
# endif /* CONFIG_TAU */
2016-07-05 08:07:51 +03:00
# endif /* __ARCH_POWERPC_KERNEL_SETUP_H */