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 DECLARE_PER_CPU(struct sdei_registered_event *, sdei_active_normal_event);
21 DECLARE_PER_CPU(struct sdei_registered_event *, sdei_active_critical_event);
22
23 extern unsigned long sdei_exit_mode;
24
25 /* Software Delegated Exception entry point from firmware*/
26 asmlinkage void __sdei_asm_handler(unsigned long event_num, unsigned long arg,
27 unsigned long pc, unsigned long pstate);
28
29 /* and its CONFIG_UNMAP_KERNEL_AT_EL0 trampoline */
30 asmlinkage void __sdei_asm_entry_trampoline(unsigned long event_num,
31 unsigned long arg,
32 unsigned long pc,
33 unsigned long pstate);
34
35 /* Abort a running handler. Context is discarded. */
36 void __sdei_handler_abort(void);
37
38 /*
39 * The above entry point does the minimum to call C code. This function does
40 * anything else, before calling the driver.
41 */
42 struct sdei_registered_event;
43 asmlinkage unsigned long __sdei_handler(struct pt_regs *regs,
44 struct sdei_registered_event *arg);
45
46 unsigned long do_sdei_event(struct pt_regs *regs,
47 struct sdei_registered_event *arg);
48
49 unsigned long sdei_arch_get_entry_point(int conduit);
50 #define sdei_arch_get_entry_point(x) sdei_arch_get_entry_point(x)
51
52 struct stack_info;
53
54 bool _on_sdei_stack(unsigned long sp, unsigned long size,
55 struct stack_info *info);
on_sdei_stack(unsigned long sp,unsigned long size,struct stack_info * info)56 static inline bool on_sdei_stack(unsigned long sp, unsigned long size,
57 struct stack_info *info)
58 {
59 if (!IS_ENABLED(CONFIG_VMAP_STACK))
60 return false;
61 if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE))
62 return false;
63 if (in_nmi())
64 return _on_sdei_stack(sp, size, info);
65
66 return false;
67 }
68
69 #endif /* __ASSEMBLY__ */
70 #endif /* __ASM_SDEI_H */
71