blob: ffe47d766c2593601573f748a18c84645bec79ad [file] [log] [blame]
James Morsead6eb312018-01-08 15:38:09 +00001// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2017 Arm Ltd.
3#ifndef __ASM_SDEI_H
4#define __ASM_SDEI_H
5
James Morsef5df2692018-01-08 15:38:12 +00006/* Values for sdei_exit_mode */
7#define SDEI_EXIT_HVC 0
8#define SDEI_EXIT_SMC 1
James Morsead6eb312018-01-08 15:38:09 +00009
James Morsef5df2692018-01-08 15:38:12 +000010#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
20extern unsigned long sdei_exit_mode;
21
22/* Software Delegated Exception entry point from firmware*/
23asmlinkage void __sdei_asm_handler(unsigned long event_num, unsigned long arg,
24 unsigned long pc, unsigned long pstate);
25
James Morse79e9aa52018-01-08 15:38:18 +000026/* and its CONFIG_UNMAP_KERNEL_AT_EL0 trampoline */
27asmlinkage void __sdei_asm_entry_trampoline(unsigned long event_num,
28 unsigned long arg,
29 unsigned long pc,
30 unsigned long pstate);
31
James Morsef5df2692018-01-08 15:38:12 +000032/*
33 * The above entry point does the minimum to call C code. This function does
34 * anything else, before calling the driver.
35 */
36struct sdei_registered_event;
37asmlinkage unsigned long __sdei_handler(struct pt_regs *regs,
38 struct sdei_registered_event *arg);
39
40unsigned long sdei_arch_get_entry_point(int conduit);
41#define sdei_arch_get_entry_point(x) sdei_arch_get_entry_point(x)
42
Laura Abbott8a1ccfb2018-07-20 14:41:53 -070043struct stack_info;
44
45bool _on_sdei_stack(unsigned long sp, struct stack_info *info);
46static inline bool on_sdei_stack(unsigned long sp,
47 struct stack_info *info)
James Morsef5df2692018-01-08 15:38:12 +000048{
49 if (!IS_ENABLED(CONFIG_VMAP_STACK))
50 return false;
51 if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE))
52 return false;
53 if (in_nmi())
Laura Abbott8a1ccfb2018-07-20 14:41:53 -070054 return _on_sdei_stack(sp, info);
James Morsef5df2692018-01-08 15:38:12 +000055
56 return false;
57}
58
59#endif /* __ASSEMBLY__ */
60#endif /* __ASM_SDEI_H */