1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
210b663aeSCatalin Marinas /*
310b663aeSCatalin Marinas * Based on arch/arm/include/asm/exception.h
410b663aeSCatalin Marinas *
510b663aeSCatalin Marinas * Copyright (C) 2012 ARM Ltd.
610b663aeSCatalin Marinas */
710b663aeSCatalin Marinas #ifndef __ASM_EXCEPTION_H
810b663aeSCatalin Marinas #define __ASM_EXCEPTION_H
910b663aeSCatalin Marinas
1068ddbf09SJames Morse #include <asm/esr.h>
11e540e0a7SJames Morse #include <asm/ptrace.h>
1268ddbf09SJames Morse
13be7635e7SAlexander Potapenko #include <linux/interrupt.h>
149a5ad7d0SJungseok Lee
159a5ad7d0SJungseok Lee #define __exception_irq_entry __irq_entry
1610b663aeSCatalin Marinas
disr_to_esr(u64 disr)178d56e5c5SAlexandru Elisei static inline unsigned long disr_to_esr(u64 disr)
1868ddbf09SJames Morse {
198d56e5c5SAlexandru Elisei unsigned long esr = ESR_ELx_EC_SERROR << ESR_ELx_EC_SHIFT;
2068ddbf09SJames Morse
2168ddbf09SJames Morse if ((disr & DISR_EL1_IDS) == 0)
2268ddbf09SJames Morse esr |= (disr & DISR_EL1_ESR_MASK);
2368ddbf09SJames Morse else
2468ddbf09SJames Morse esr |= (disr & ESR_ELx_ISS_MASK);
2568ddbf09SJames Morse
2668ddbf09SJames Morse return esr;
2768ddbf09SJames Morse }
2868ddbf09SJames Morse
295ab6876cSJosh Poimboeuf asmlinkage void __noreturn handle_bad_stack(struct pt_regs *regs);
308168f098SMark Rutland
31ec841aabSMark Rutland asmlinkage void el1t_64_sync_handler(struct pt_regs *regs);
32ec841aabSMark Rutland asmlinkage void el1t_64_irq_handler(struct pt_regs *regs);
33ec841aabSMark Rutland asmlinkage void el1t_64_fiq_handler(struct pt_regs *regs);
34ec841aabSMark Rutland asmlinkage void el1t_64_error_handler(struct pt_regs *regs);
35ec841aabSMark Rutland
36ec841aabSMark Rutland asmlinkage void el1h_64_sync_handler(struct pt_regs *regs);
37ec841aabSMark Rutland asmlinkage void el1h_64_irq_handler(struct pt_regs *regs);
38ec841aabSMark Rutland asmlinkage void el1h_64_fiq_handler(struct pt_regs *regs);
39ec841aabSMark Rutland asmlinkage void el1h_64_error_handler(struct pt_regs *regs);
40ec841aabSMark Rutland
41ec841aabSMark Rutland asmlinkage void el0t_64_sync_handler(struct pt_regs *regs);
42ec841aabSMark Rutland asmlinkage void el0t_64_irq_handler(struct pt_regs *regs);
43ec841aabSMark Rutland asmlinkage void el0t_64_fiq_handler(struct pt_regs *regs);
44ec841aabSMark Rutland asmlinkage void el0t_64_error_handler(struct pt_regs *regs);
45ec841aabSMark Rutland
46ec841aabSMark Rutland asmlinkage void el0t_32_sync_handler(struct pt_regs *regs);
47ec841aabSMark Rutland asmlinkage void el0t_32_irq_handler(struct pt_regs *regs);
48ec841aabSMark Rutland asmlinkage void el0t_32_fiq_handler(struct pt_regs *regs);
49ec841aabSMark Rutland asmlinkage void el0t_32_error_handler(struct pt_regs *regs);
50bf023e76SMark Rutland
51f8049488SMark Rutland asmlinkage void call_on_irq_stack(struct pt_regs *regs,
52f8049488SMark Rutland void (*func)(struct pt_regs *));
534d1c2ee2SMark Rutland asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs);
544d1c2ee2SMark Rutland
558d56e5c5SAlexandru Elisei void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs);
5661d64a37SMark Rutland void do_el0_undef(struct pt_regs *regs, unsigned long esr);
5761d64a37SMark Rutland void do_el1_undef(struct pt_regs *regs, unsigned long esr);
58830a2a4dSMark Rutland void do_el0_bti(struct pt_regs *regs);
59830a2a4dSMark Rutland void do_el1_bti(struct pt_regs *regs, unsigned long esr);
608d56e5c5SAlexandru Elisei void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
61e540e0a7SJames Morse struct pt_regs *regs);
628d56e5c5SAlexandru Elisei void do_fpsimd_acc(unsigned long esr, struct pt_regs *regs);
638d56e5c5SAlexandru Elisei void do_sve_acc(unsigned long esr, struct pt_regs *regs);
640616ea3fSCatalin Marinas void do_sme_acc(unsigned long esr, struct pt_regs *regs);
658d56e5c5SAlexandru Elisei void do_fpsimd_exc(unsigned long esr, struct pt_regs *regs);
66b3a0c010SMark Rutland void do_el0_sys(unsigned long esr, struct pt_regs *regs);
678d56e5c5SAlexandru Elisei void do_sp_pc_abort(unsigned long addr, unsigned long esr, struct pt_regs *regs);
688d56e5c5SAlexandru Elisei void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr);
69b3a0c010SMark Rutland void do_el0_cp15(unsigned long esr, struct pt_regs *regs);
703fc24ef3SArd Biesheuvel int do_compat_alignment_fixup(unsigned long addr, struct pt_regs *regs);
717a2c0944SMark Rutland void do_el0_svc(struct pt_regs *regs);
727a2c0944SMark Rutland void do_el0_svc_compat(struct pt_regs *regs);
73a1fafa3bSMark Rutland void do_el0_fpac(struct pt_regs *regs, unsigned long esr);
74a1fafa3bSMark Rutland void do_el1_fpac(struct pt_regs *regs, unsigned long esr);
758536ceaaSKristina Martsenko void do_el0_mops(struct pt_regs *regs, unsigned long esr);
768d56e5c5SAlexandru Elisei void do_serror(struct pt_regs *regs, unsigned long esr);
77*997d79ebSMark Rutland void do_signal(struct pt_regs *regs);
788168f098SMark Rutland
795ab6876cSJosh Poimboeuf void __noreturn panic_bad_stack(struct pt_regs *regs, unsigned long esr, unsigned long far);
8010b663aeSCatalin Marinas #endif /* __ASM_EXCEPTION_H */
81