0001
0002
0003
0004
0005
0006
0007 #ifndef __ASM_TRAP_H
0008 #define __ASM_TRAP_H
0009
0010 #include <linux/list.h>
0011 #include <asm/esr.h>
0012 #include <asm/sections.h>
0013
0014 struct pt_regs;
0015
0016 struct undef_hook {
0017 struct list_head node;
0018 u32 instr_mask;
0019 u32 instr_val;
0020 u64 pstate_mask;
0021 u64 pstate_val;
0022 int (*fn)(struct pt_regs *regs, u32 instr);
0023 };
0024
0025 void register_undef_hook(struct undef_hook *hook);
0026 void unregister_undef_hook(struct undef_hook *hook);
0027 void force_signal_inject(int signal, int code, unsigned long address, unsigned long err);
0028 void arm64_notify_segfault(unsigned long addr);
0029 void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str);
0030 void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str);
0031 void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str);
0032
0033
0034
0035
0036
0037 void arm64_skip_faulting_instruction(struct pt_regs *regs, unsigned long size);
0038
0039 static inline int __in_irqentry_text(unsigned long ptr)
0040 {
0041 return ptr >= (unsigned long)&__irqentry_text_start &&
0042 ptr < (unsigned long)&__irqentry_text_end;
0043 }
0044
0045 static inline int in_entry_text(unsigned long ptr)
0046 {
0047 return ptr >= (unsigned long)&__entry_text_start &&
0048 ptr < (unsigned long)&__entry_text_end;
0049 }
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 static inline bool arm64_is_ras_serror(unsigned long esr)
0061 {
0062 WARN_ON(preemptible());
0063
0064 if (esr & ESR_ELx_IDS)
0065 return false;
0066
0067 if (this_cpu_has_cap(ARM64_HAS_RAS_EXTN))
0068 return true;
0069 else
0070 return false;
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080 static inline unsigned long arm64_ras_serror_get_severity(unsigned long esr)
0081 {
0082 unsigned long aet = esr & ESR_ELx_AET;
0083
0084 if (!arm64_is_ras_serror(esr)) {
0085
0086 return ESR_ELx_AET_UC;
0087 }
0088
0089
0090
0091
0092
0093 if ((esr & ESR_ELx_FSC) != ESR_ELx_FSC_SERROR) {
0094
0095 return ESR_ELx_AET_UC;
0096 }
0097
0098 return aet;
0099 }
0100
0101 bool arm64_is_fatal_ras_serror(struct pt_regs *regs, unsigned long esr);
0102 void __noreturn arm64_serror_panic(struct pt_regs *regs, unsigned long esr);
0103 #endif