1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2017 Arm Ltd.
3 #ifndef __ASM_SDEI_H
4 #define __ASM_SDEI_H
5 
6 /* Values for sdei_exit_mode */
7 #define SDEI_EXIT_HVC  0
8 #define SDEI_EXIT_SMC  1
9 
10 #define SDEI_STACK_SIZE		IRQ_STACK_SIZE
11 
12 #ifndef __ASSEMBLY__
13 
14 #include <linux/linkage.h>
15 #include <linux/preempt.h>
16 #include <linux/types.h>
17 
18 #include <asm/virt.h>
19 
20 extern unsigned long sdei_exit_mode;
21 
22 /* Software Delegated Exception entry point from firmware*/
23 asmlinkage void __sdei_asm_handler(unsigned long event_num, unsigned long arg,
24 				   unsigned long pc, unsigned long pstate);
25 
26 /* and its CONFIG_UNMAP_KERNEL_AT_EL0 trampoline */
27 asmlinkage void __sdei_asm_entry_trampoline(unsigned long event_num,
28 						   unsigned long arg,
29 						   unsigned long pc,
30 						   unsigned long pstate);
31 
32 /*
33  * The above entry point does the minimum to call C code. This function does
34  * anything else, before calling the driver.
35  */
36 struct sdei_registered_event;
37 asmlinkage unsigned long __sdei_handler(struct pt_regs *regs,
38 					struct sdei_registered_event *arg);
39 
40 unsigned long do_sdei_event(struct pt_regs *regs,
41 			    struct sdei_registered_event *arg);
42 
43 unsigned long sdei_arch_get_entry_point(int conduit);
44 #define sdei_arch_get_entry_point(x)	sdei_arch_get_entry_point(x)
45 
46 struct stack_info;
47 
48 bool _on_sdei_stack(unsigned long sp, unsigned long size,
49 		    struct stack_info *info);
on_sdei_stack(unsigned long sp,unsigned long size,struct stack_info * info)50 static inline bool on_sdei_stack(unsigned long sp, unsigned long size,
51 				struct stack_info *info)
52 {
53 	if (!IS_ENABLED(CONFIG_VMAP_STACK))
54 		return false;
55 	if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE))
56 		return false;
57 	if (in_nmi())
58 		return _on_sdei_stack(sp, size, info);
59 
60 	return false;
61 }
62 
63 #endif /* __ASSEMBLY__ */
64 #endif	/* __ASM_SDEI_H */
65