~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/microblaze/kernel/exceptions.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * HW exception handling
  3  *
  4  * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
  5  * Copyright (C) 2008 PetaLogix
  6  *
  7  * This file is subject to the terms and conditions of the GNU General
  8  * Public License.  See the file COPYING in the main directory of this
  9  * archive for more details.
 10  */
 11 
 12 /*
 13  * This file handles the architecture-dependent parts of hardware exceptions
 14  */
 15 
 16 #include <linux/export.h>
 17 #include <linux/kernel.h>
 18 #include <linux/signal.h>
 19 #include <linux/sched.h>
 20 #include <linux/sched/debug.h>
 21 #include <linux/kallsyms.h>
 22 
 23 #include <asm/exceptions.h>
 24 #include <asm/entry.h>          /* For KM CPU var */
 25 #include <linux/uaccess.h>
 26 #include <linux/errno.h>
 27 #include <linux/ptrace.h>
 28 #include <asm/current.h>
 29 #include <asm/cacheflush.h>
 30 
 31 #define MICROBLAZE_ILL_OPCODE_EXCEPTION 0x02
 32 #define MICROBLAZE_IBUS_EXCEPTION       0x03
 33 #define MICROBLAZE_DBUS_EXCEPTION       0x04
 34 #define MICROBLAZE_DIV_ZERO_EXCEPTION   0x05
 35 #define MICROBLAZE_FPU_EXCEPTION        0x06
 36 #define MICROBLAZE_PRIVILEGED_EXCEPTION 0x07
 37 
 38 static DEFINE_SPINLOCK(die_lock);
 39 
 40 void die(const char *str, struct pt_regs *fp, long err)
 41 {
 42         console_verbose();
 43         spin_lock_irq(&die_lock);
 44         pr_warn("Oops: %s, sig: %ld\n", str, err);
 45         show_regs(fp);
 46         spin_unlock_irq(&die_lock);
 47         /* make_task_dead() should take care of panic'ing from an interrupt
 48          * context so we don't handle it here
 49          */
 50         make_task_dead(err);
 51 }
 52 
 53 /* for user application debugging */
 54 asmlinkage void sw_exception(struct pt_regs *regs)
 55 {
 56         _exception(SIGTRAP, regs, TRAP_BRKPT, regs->r16);
 57         flush_dcache_range(regs->r16, regs->r16 + 0x4);
 58         flush_icache_range(regs->r16, regs->r16 + 0x4);
 59 }
 60 
 61 void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
 62 {
 63         if (kernel_mode(regs))
 64                 die("Exception in kernel mode", regs, signr);
 65 
 66         force_sig_fault(signr, code, (void __user *)addr);
 67 }
 68 
 69 asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
 70                                                         int fsr, int addr)
 71 {
 72         addr = regs->pc;
 73 
 74 #if 0
 75         pr_warn("Exception %02x in %s mode, FSR=%08x PC=%08x ESR=%08x\n",
 76                         type, user_mode(regs) ? "user" : "kernel", fsr,
 77                         (unsigned int) regs->pc, (unsigned int) regs->esr);
 78 #endif
 79 
 80         switch (type & 0x1F) {
 81         case MICROBLAZE_ILL_OPCODE_EXCEPTION:
 82                 if (user_mode(regs)) {
 83                         pr_debug("Illegal opcode exception in user mode\n");
 84                         _exception(SIGILL, regs, ILL_ILLOPC, addr);
 85                         return;
 86                 }
 87                 pr_warn("Illegal opcode exception in kernel mode.\n");
 88                 die("opcode exception", regs, SIGBUS);
 89                 break;
 90         case MICROBLAZE_IBUS_EXCEPTION:
 91                 if (user_mode(regs)) {
 92                         pr_debug("Instruction bus error exception in user mode\n");
 93                         _exception(SIGBUS, regs, BUS_ADRERR, addr);
 94                         return;
 95                 }
 96                 pr_warn("Instruction bus error exception in kernel mode.\n");
 97                 die("bus exception", regs, SIGBUS);
 98                 break;
 99         case MICROBLAZE_DBUS_EXCEPTION:
100                 if (user_mode(regs)) {
101                         pr_debug("Data bus error exception in user mode\n");
102                         _exception(SIGBUS, regs, BUS_ADRERR, addr);
103                         return;
104                 }
105                 pr_warn("Data bus error exception in kernel mode.\n");
106                 die("bus exception", regs, SIGBUS);
107                 break;
108         case MICROBLAZE_DIV_ZERO_EXCEPTION:
109                 if (user_mode(regs)) {
110                         pr_debug("Divide by zero exception in user mode\n");
111                         _exception(SIGFPE, regs, FPE_INTDIV, addr);
112                         return;
113                 }
114                 pr_warn("Divide by zero exception in kernel mode.\n");
115                 die("Divide by zero exception", regs, SIGBUS);
116                 break;
117         case MICROBLAZE_FPU_EXCEPTION:
118                 pr_debug("FPU exception\n");
119                 /* IEEE FP exception */
120                 /* I removed fsr variable and use code var for storing fsr */
121                 if (fsr & FSR_IO)
122                         fsr = FPE_FLTINV;
123                 else if (fsr & FSR_OF)
124                         fsr = FPE_FLTOVF;
125                 else if (fsr & FSR_UF)
126                         fsr = FPE_FLTUND;
127                 else if (fsr & FSR_DZ)
128                         fsr = FPE_FLTDIV;
129                 else if (fsr & FSR_DO)
130                         fsr = FPE_FLTRES;
131                 _exception(SIGFPE, regs, fsr, addr);
132                 break;
133         case MICROBLAZE_PRIVILEGED_EXCEPTION:
134                 pr_debug("Privileged exception\n");
135                 _exception(SIGILL, regs, ILL_PRVOPC, addr);
136                 break;
137         default:
138         /* FIXME what to do in unexpected exception */
139                 pr_warn("Unexpected exception %02x PC=%08x in %s mode\n",
140                         type, (unsigned int) addr,
141                         kernel_mode(regs) ? "kernel" : "user");
142         }
143         return;
144 }
145 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php