traps.c (b3bbcc5d1da1b654091dad15980b3d58fdae0fc6) | traps.c (b26e484b8bb3a992ef30e851d771973a3dd2336b) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Based on arch/arm/kernel/traps.c 4 * 5 * Copyright (C) 1995-2009 Russell King 6 * Copyright (C) 2012 ARM Ltd. 7 */ 8 --- 12 unchanged lines hidden (view full) --- 21#include <linux/init.h> 22#include <linux/sched/signal.h> 23#include <linux/sched/debug.h> 24#include <linux/sched/task_stack.h> 25#include <linux/sizes.h> 26#include <linux/syscalls.h> 27#include <linux/mm_types.h> 28#include <linux/kasan.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Based on arch/arm/kernel/traps.c 4 * 5 * Copyright (C) 1995-2009 Russell King 6 * Copyright (C) 2012 ARM Ltd. 7 */ 8 --- 12 unchanged lines hidden (view full) --- 21#include <linux/init.h> 22#include <linux/sched/signal.h> 23#include <linux/sched/debug.h> 24#include <linux/sched/task_stack.h> 25#include <linux/sizes.h> 26#include <linux/syscalls.h> 27#include <linux/mm_types.h> 28#include <linux/kasan.h> |
29#include <linux/cfi.h> |
|
29 30#include <asm/atomic.h> 31#include <asm/bug.h> 32#include <asm/cpufeature.h> 33#include <asm/daifflags.h> 34#include <asm/debug-monitors.h> 35#include <asm/esr.h> 36#include <asm/exception.h> --- 949 unchanged lines hidden (view full) --- 986 return DBG_HOOK_HANDLED; 987} 988 989static struct break_hook bug_break_hook = { 990 .fn = bug_handler, 991 .imm = BUG_BRK_IMM, 992}; 993 | 30 31#include <asm/atomic.h> 32#include <asm/bug.h> 33#include <asm/cpufeature.h> 34#include <asm/daifflags.h> 35#include <asm/debug-monitors.h> 36#include <asm/esr.h> 37#include <asm/exception.h> --- 949 unchanged lines hidden (view full) --- 987 return DBG_HOOK_HANDLED; 988} 989 990static struct break_hook bug_break_hook = { 991 .fn = bug_handler, 992 .imm = BUG_BRK_IMM, 993}; 994 |
995#ifdef CONFIG_CFI_CLANG 996static int cfi_handler(struct pt_regs *regs, unsigned long esr) 997{ 998 unsigned long target; 999 u32 type; 1000 1001 target = pt_regs_read_reg(regs, FIELD_GET(CFI_BRK_IMM_TARGET, esr)); 1002 type = (u32)pt_regs_read_reg(regs, FIELD_GET(CFI_BRK_IMM_TYPE, esr)); 1003 1004 switch (report_cfi_failure(regs, regs->pc, &target, type)) { 1005 case BUG_TRAP_TYPE_BUG: 1006 die("Oops - CFI", regs, 0); 1007 break; 1008 1009 case BUG_TRAP_TYPE_WARN: 1010 break; 1011 1012 default: 1013 return DBG_HOOK_ERROR; 1014 } 1015 1016 arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE); 1017 return DBG_HOOK_HANDLED; 1018} 1019 1020static struct break_hook cfi_break_hook = { 1021 .fn = cfi_handler, 1022 .imm = CFI_BRK_IMM_BASE, 1023 .mask = CFI_BRK_IMM_MASK, 1024}; 1025#endif /* CONFIG_CFI_CLANG */ 1026 |
|
994static int reserved_fault_handler(struct pt_regs *regs, unsigned long esr) 995{ 996 pr_err("%s generated an invalid instruction at %pS!\n", 997 "Kernel text patching", 998 (void *)instruction_pointer(regs)); 999 1000 /* We cannot handle this */ 1001 return DBG_HOOK_ERROR; --- 45 unchanged lines hidden (view full) --- 1047 1048static struct break_hook kasan_break_hook = { 1049 .fn = kasan_handler, 1050 .imm = KASAN_BRK_IMM, 1051 .mask = KASAN_BRK_MASK, 1052}; 1053#endif 1054 | 1027static int reserved_fault_handler(struct pt_regs *regs, unsigned long esr) 1028{ 1029 pr_err("%s generated an invalid instruction at %pS!\n", 1030 "Kernel text patching", 1031 (void *)instruction_pointer(regs)); 1032 1033 /* We cannot handle this */ 1034 return DBG_HOOK_ERROR; --- 45 unchanged lines hidden (view full) --- 1080 1081static struct break_hook kasan_break_hook = { 1082 .fn = kasan_handler, 1083 .imm = KASAN_BRK_IMM, 1084 .mask = KASAN_BRK_MASK, 1085}; 1086#endif 1087 |
1088 1089#define esr_comment(esr) ((esr) & ESR_ELx_BRK64_ISS_COMMENT_MASK) 1090 |
|
1055/* 1056 * Initial handler for AArch64 BRK exceptions 1057 * This handler only used until debug_traps_init(). 1058 */ 1059int __init early_brk64(unsigned long addr, unsigned long esr, 1060 struct pt_regs *regs) 1061{ | 1091/* 1092 * Initial handler for AArch64 BRK exceptions 1093 * This handler only used until debug_traps_init(). 1094 */ 1095int __init early_brk64(unsigned long addr, unsigned long esr, 1096 struct pt_regs *regs) 1097{ |
1098#ifdef CONFIG_CFI_CLANG 1099 if ((esr_comment(esr) & ~CFI_BRK_IMM_MASK) == CFI_BRK_IMM_BASE) 1100 return cfi_handler(regs, esr) != DBG_HOOK_HANDLED; 1101#endif |
|
1062#ifdef CONFIG_KASAN_SW_TAGS | 1102#ifdef CONFIG_KASAN_SW_TAGS |
1063 unsigned long comment = esr & ESR_ELx_BRK64_ISS_COMMENT_MASK; 1064 1065 if ((comment & ~KASAN_BRK_MASK) == KASAN_BRK_IMM) | 1103 if ((esr_comment(esr) & ~KASAN_BRK_MASK) == KASAN_BRK_IMM) |
1066 return kasan_handler(regs, esr) != DBG_HOOK_HANDLED; 1067#endif 1068 return bug_handler(regs, esr) != DBG_HOOK_HANDLED; 1069} 1070 1071void __init trap_init(void) 1072{ 1073 register_kernel_break_hook(&bug_break_hook); | 1104 return kasan_handler(regs, esr) != DBG_HOOK_HANDLED; 1105#endif 1106 return bug_handler(regs, esr) != DBG_HOOK_HANDLED; 1107} 1108 1109void __init trap_init(void) 1110{ 1111 register_kernel_break_hook(&bug_break_hook); |
1112#ifdef CONFIG_CFI_CLANG 1113 register_kernel_break_hook(&cfi_break_hook); 1114#endif |
|
1074 register_kernel_break_hook(&fault_break_hook); 1075#ifdef CONFIG_KASAN_SW_TAGS 1076 register_kernel_break_hook(&kasan_break_hook); 1077#endif 1078 debug_traps_init(); 1079} | 1115 register_kernel_break_hook(&fault_break_hook); 1116#ifdef CONFIG_KASAN_SW_TAGS 1117 register_kernel_break_hook(&kasan_break_hook); 1118#endif 1119 debug_traps_init(); 1120} |