Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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)  *  Port on Texas Instruments TMS320C6x architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 2004, 2006, 2009, 2010, 2011 Texas Instruments Incorporated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/sched/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/special_insns.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) int (*c6x_nmi_handler)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) void __init trap_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	ack_exception(EXCEPT_TYPE_NXF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	ack_exception(EXCEPT_TYPE_EXC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	ack_exception(EXCEPT_TYPE_IXF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	ack_exception(EXCEPT_TYPE_SXF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	enable_exception();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) void show_regs(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	pr_err("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	show_regs_print_info(KERN_ERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	pr_err("PC: %08lx SP: %08lx\n", regs->pc, regs->sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	pr_err("Status: %08lx ORIG_A4: %08lx\n", regs->csr, regs->orig_a4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	pr_err("A0: %08lx  B0: %08lx\n", regs->a0, regs->b0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	pr_err("A1: %08lx  B1: %08lx\n", regs->a1, regs->b1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	pr_err("A2: %08lx  B2: %08lx\n", regs->a2, regs->b2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	pr_err("A3: %08lx  B3: %08lx\n", regs->a3, regs->b3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	pr_err("A4: %08lx  B4: %08lx\n", regs->a4, regs->b4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	pr_err("A5: %08lx  B5: %08lx\n", regs->a5, regs->b5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	pr_err("A6: %08lx  B6: %08lx\n", regs->a6, regs->b6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	pr_err("A7: %08lx  B7: %08lx\n", regs->a7, regs->b7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	pr_err("A8: %08lx  B8: %08lx\n", regs->a8, regs->b8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	pr_err("A9: %08lx  B9: %08lx\n", regs->a9, regs->b9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	pr_err("A10: %08lx  B10: %08lx\n", regs->a10, regs->b10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	pr_err("A11: %08lx  B11: %08lx\n", regs->a11, regs->b11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	pr_err("A12: %08lx  B12: %08lx\n", regs->a12, regs->b12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	pr_err("A13: %08lx  B13: %08lx\n", regs->a13, regs->b13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	pr_err("A14: %08lx  B14: %08lx\n", regs->a14, regs->dp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	pr_err("A15: %08lx  B15: %08lx\n", regs->a15, regs->sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	pr_err("A16: %08lx  B16: %08lx\n", regs->a16, regs->b16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	pr_err("A17: %08lx  B17: %08lx\n", regs->a17, regs->b17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	pr_err("A18: %08lx  B18: %08lx\n", regs->a18, regs->b18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	pr_err("A19: %08lx  B19: %08lx\n", regs->a19, regs->b19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	pr_err("A20: %08lx  B20: %08lx\n", regs->a20, regs->b20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	pr_err("A21: %08lx  B21: %08lx\n", regs->a21, regs->b21);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	pr_err("A22: %08lx  B22: %08lx\n", regs->a22, regs->b22);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	pr_err("A23: %08lx  B23: %08lx\n", regs->a23, regs->b23);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	pr_err("A24: %08lx  B24: %08lx\n", regs->a24, regs->b24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	pr_err("A25: %08lx  B25: %08lx\n", regs->a25, regs->b25);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	pr_err("A26: %08lx  B26: %08lx\n", regs->a26, regs->b26);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	pr_err("A27: %08lx  B27: %08lx\n", regs->a27, regs->b27);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	pr_err("A28: %08lx  B28: %08lx\n", regs->a28, regs->b28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	pr_err("A29: %08lx  B29: %08lx\n", regs->a29, regs->b29);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	pr_err("A30: %08lx  B30: %08lx\n", regs->a30, regs->b30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	pr_err("A31: %08lx  B31: %08lx\n", regs->a31, regs->b31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) void die(char *str, struct pt_regs *fp, int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	console_verbose();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	pr_err("%s: %08x\n", str, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	show_regs(fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	pr_err("Process %s (pid: %d, stackpage=%08lx)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	       current->comm, current->pid, (PAGE_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 					     (unsigned long) current));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	dump_stack();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	while (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static void die_if_kernel(char *str, struct pt_regs *fp, int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	if (user_mode(fp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	die(str, fp, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) /* Internal exceptions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static struct exception_info iexcept_table[10] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	{ "Oops - instruction fetch", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	{ "Oops - fetch packet", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	{ "Oops - execute packet", SIGILL, ILL_ILLOPC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	{ "Oops - undefined instruction", SIGILL, ILL_ILLOPC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	{ "Oops - resource conflict", SIGILL, ILL_ILLOPC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	{ "Oops - resource access", SIGILL, ILL_PRVREG },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	{ "Oops - privilege", SIGILL, ILL_PRVOPC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	{ "Oops - loops buffer", SIGILL, ILL_ILLOPC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	{ "Oops - software exception", SIGILL, ILL_ILLTRP },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	{ "Oops - unknown exception", SIGILL, ILL_ILLOPC }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* External exceptions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static struct exception_info eexcept_table[128] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	{ "Oops - external exception", SIGBUS, BUS_ADRERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	{ "Oops - CPU memory protection fault", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	{ "Oops - CPU memory protection fault in L1P", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	{ "Oops - DMA memory protection fault in L1P", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	{ "Oops - CPU memory protection fault in L1D", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	{ "Oops - DMA memory protection fault in L1D", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	{ "Oops - CPU memory protection fault in L2", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	{ "Oops - DMA memory protection fault in L2", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	{ "Oops - EMC CPU memory protection fault", SIGSEGV, SEGV_ACCERR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	{ "Oops - EMC bus error", SIGBUS, BUS_ADRERR }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static void do_trap(struct exception_info *except_info, struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	unsigned long addr = instruction_pointer(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (except_info->code != TRAP_BRKPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		pr_err("TRAP: %s PC[0x%lx] signo[%d] code[%d]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		       except_info->kernel_str, regs->pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		       except_info->signo, except_info->code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	die_if_kernel(except_info->kernel_str, regs, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	force_sig_fault(except_info->signo, except_info->code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			(void __user *)addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  * Process an internal exception (non maskable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static int process_iexcept(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	unsigned int iexcept_report = get_iexcept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	unsigned int iexcept_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	ack_exception(EXCEPT_TYPE_IXF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	pr_err("IEXCEPT: PC[0x%lx]\n", regs->pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	while (iexcept_report) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		iexcept_num = __ffs(iexcept_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		iexcept_report &= ~(1 << iexcept_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		set_iexcept(iexcept_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		if (*(unsigned int *)regs->pc == BKPT_OPCODE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			/* This is a breakpoint */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			struct exception_info bkpt_exception = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 				"Oops - undefined instruction",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 				  SIGTRAP, TRAP_BRKPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			do_trap(&bkpt_exception, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			iexcept_report &= ~(0xFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			set_iexcept(iexcept_report);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		do_trap(&iexcept_table[iexcept_num], regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)  * Process an external exception (maskable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static void process_eexcept(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	int evt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	pr_err("EEXCEPT: PC[0x%lx]\n", regs->pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	while ((evt = soc_get_exception()) >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		do_trap(&eexcept_table[evt], regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	ack_exception(EXCEPT_TYPE_EXC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)  * Main exception processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) asmlinkage int process_exception(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	unsigned int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	unsigned int type_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	unsigned int ie_num = 9; /* default is unknown exception */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	while ((type = get_except_type()) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		type_num = fls(type) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		switch (type_num) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		case EXCEPT_TYPE_NXF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			ack_exception(EXCEPT_TYPE_NXF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			if (c6x_nmi_handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 				(c6x_nmi_handler)(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 				pr_alert("NMI interrupt!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		case EXCEPT_TYPE_IXF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			if (process_iexcept(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 				return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		case EXCEPT_TYPE_EXC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 			process_eexcept(regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		case EXCEPT_TYPE_SXF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 			ie_num = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			ack_exception(type_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 			do_trap(&iexcept_table[ie_num], regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static int kstack_depth_to_print = 48;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static void show_trace(unsigned long *stack, unsigned long *endstack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		       const char *loglvl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	unsigned long addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	printk("%sCall trace:", loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	while (stack + 1 <= endstack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		addr = *stack++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		 * If the address is either in the text segment of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		 * kernel, or in the region which contains vmalloc'ed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		 * memory, it *may* be the address of a calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		 * routine; if so, print it so that someone tracing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		 * down the cause of the crash will be able to figure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		 * out the call path that was taken.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		if (__kernel_text_address(addr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) #ifndef CONFIG_KALLSYMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			if (i % 5 == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 				printk("%s\n	    ", loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 			printk("%s [<%08lx>] %pS\n", loglvl, addr, (void *)addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 			i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	printk("%s\n", loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) void show_stack(struct task_struct *task, unsigned long *stack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		const char *loglvl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	unsigned long *p, *endstack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	if (!stack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		if (task && task != current)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			/* We know this is a kernel stack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			   so this is the start/end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			stack = (unsigned long *)thread_saved_ksp(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			stack = (unsigned long *)&stack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 				     & -THREAD_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	pr_debug("Stack from %08lx:", (unsigned long)stack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	for (i = 0, p = stack; i < kstack_depth_to_print; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		if (p + 1 > endstack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		if (i % 8 == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			pr_cont("\n	    ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		pr_cont(" %08lx", *p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	show_trace(stack, endstack, loglvl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) int is_valid_bugaddr(unsigned long addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	return __kernel_text_address(addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }