^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kdev_t.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/sched/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/arcregs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/irqflags.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define ARC_PATH_MAX 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static noinline void print_regs_scratch(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) pr_cont("BTA: 0x%08lx\n SP: 0x%08lx FP: 0x%08lx BLK: %pS\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) regs->bta, regs->sp, regs->fp, (void *)regs->blink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) pr_cont("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) regs->lp_start, regs->lp_end, regs->lp_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) pr_info("r00: 0x%08lx\tr01: 0x%08lx\tr02: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) "r03: 0x%08lx\tr04: 0x%08lx\tr05: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) "r06: 0x%08lx\tr07: 0x%08lx\tr08: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) "r09: 0x%08lx\tr10: 0x%08lx\tr11: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) "r12: 0x%08lx\t",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) regs->r0, regs->r1, regs->r2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) regs->r3, regs->r4, regs->r5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) regs->r6, regs->r7, regs->r8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) regs->r9, regs->r10, regs->r11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) regs->r12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static void print_regs_callee(struct callee_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) pr_cont("r13: 0x%08lx\tr14: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) "r15: 0x%08lx\tr16: 0x%08lx\tr17: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) "r18: 0x%08lx\tr19: 0x%08lx\tr20: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) "r21: 0x%08lx\tr22: 0x%08lx\tr23: 0x%08lx\n" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) "r24: 0x%08lx\tr25: 0x%08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) regs->r13, regs->r14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) regs->r15, regs->r16, regs->r17,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) regs->r18, regs->r19, regs->r20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) regs->r21, regs->r22, regs->r23,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) regs->r24, regs->r25);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static void print_task_path_n_nm(struct task_struct *tsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) char *path_nm = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct mm_struct *mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct file *exe_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) char buf[ARC_PATH_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) mm = get_task_mm(tsk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (!mm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) exe_file = get_mm_exe_file(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) mmput(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (exe_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) path_nm = file_path(exe_file, buf, ARC_PATH_MAX-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) fput(exe_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static void show_faulting_vma(unsigned long address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct vm_area_struct *vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct mm_struct *active_mm = current->active_mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /* can't use print_vma_addr() yet as it doesn't check for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * non-inclusive vma
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) mmap_read_lock(active_mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) vma = find_vma(active_mm, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* check against the find_vma( ) behaviour which returns the next VMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * if the container VMA is not found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (vma && (vma->vm_start <= address)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) char buf[ARC_PATH_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) char *nm = "?";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (vma->vm_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) nm = file_path(vma->vm_file, buf, ARC_PATH_MAX-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (IS_ERR(nm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) nm = "?";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) pr_info(" @off 0x%lx in [%s] VMA: 0x%08lx to 0x%08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) vma->vm_start < TASK_UNMAPPED_BASE ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) address : address - vma->vm_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) nm, vma->vm_start, vma->vm_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) pr_info(" @No matching VMA found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) mmap_read_unlock(active_mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static void show_ecr_verbose(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) unsigned int vec, cause_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) unsigned long address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* For Data fault, this is data address not instruction addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) address = current->thread.fault_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) vec = regs->ecr_vec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) cause_code = regs->ecr_cause;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* For DTLB Miss or ProtV, display the memory involved too */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (vec == ECR_V_DTLB_MISS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) pr_cont("Invalid %s @ 0x%08lx by insn @ %pS\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) (cause_code == 0x01) ? "Read" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) ((cause_code == 0x02) ? "Write" : "EX"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) address, (void *)regs->ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) } else if (vec == ECR_V_ITLB_MISS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) pr_cont("Insn could not be fetched\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) } else if (vec == ECR_V_MACH_CHK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) pr_cont("Machine Check (%s)\n", (cause_code == 0x0) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) "Double Fault" : "Other Fatal Err");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) } else if (vec == ECR_V_PROTV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (cause_code == ECR_C_PROTV_INST_FETCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) pr_cont("Execute from Non-exec Page\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) else if (cause_code == ECR_C_PROTV_MISALIG_DATA &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) IS_ENABLED(CONFIG_ISA_ARCOMPACT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) pr_cont("Misaligned r/w from 0x%08lx\n", address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) pr_cont("%s access not allowed on page\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) (cause_code == 0x01) ? "Read" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) ((cause_code == 0x02) ? "Write" : "EX"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) } else if (vec == ECR_V_INSN_ERR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) pr_cont("Illegal Insn\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #ifdef CONFIG_ISA_ARCV2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) } else if (vec == ECR_V_MEM_ERR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (cause_code == 0x00)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) pr_cont("Bus Error from Insn Mem\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) else if (cause_code == 0x10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) pr_cont("Bus Error from Data Mem\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) pr_cont("Bus Error, check PRM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) } else if (vec == ECR_V_MISALIGN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) pr_cont("Misaligned r/w from 0x%08lx\n", address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) } else if (vec == ECR_V_TRAP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (regs->ecr_param == 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) pr_cont("gcc generated __builtin_trap\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) pr_cont("Check Programmer's Manual\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * API called by rest of kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ***********************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) void show_regs(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct task_struct *tsk = current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct callee_regs *cregs = (struct callee_regs *)tsk->thread.callee_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * generic code calls us with preemption disabled, but some calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * here could sleep, so re-enable to avoid lockdep splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) preempt_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) print_task_path_n_nm(tsk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) show_regs_print_info(KERN_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) show_ecr_verbose(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (user_mode(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) show_faulting_vma(regs->ret); /* faulting code, not data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) pr_info("ECR: 0x%08lx EFA: 0x%08lx ERET: 0x%08lx\nSTAT: 0x%08lx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) regs->event, current->thread.fault_address, regs->ret,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) regs->status32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define STS_BIT(r, bit) r->status32 & STATUS_##bit##_MASK ? #bit" " : ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #ifdef CONFIG_ISA_ARCOMPACT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) pr_cont(" [%2s%2s%2s%2s%2s%2s%2s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) (regs->status32 & STATUS_U_MASK) ? "U " : "K ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) STS_BIT(regs, DE), STS_BIT(regs, AE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) STS_BIT(regs, A2), STS_BIT(regs, A1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) STS_BIT(regs, E2), STS_BIT(regs, E1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) pr_cont(" [%2s%2s%2s%2s] ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) STS_BIT(regs, IE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) (regs->status32 & STATUS_U_MASK) ? "U " : "K ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) STS_BIT(regs, DE), STS_BIT(regs, AE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) print_regs_scratch(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (cregs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) print_regs_callee(cregs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) preempt_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) unsigned long address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) current->thread.fault_address = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /* Show fault description */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) pr_info("\n%s\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /* Caller and Callee regs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) show_regs(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /* Show stack trace if this Fatality happened in kernel mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!user_mode(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) show_stacktrace(current, regs, KERN_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }