traps.c (d527353e4bceae6d59606ad21ad00916401d22ad) | traps.c (3db8aa10de9a478b3086db7894e0266def3d77af) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 4 * Copyright 2007-2010 Freescale Semiconductor, Inc. 5 * 6 * Modified by Cort Dougan (cort@cs.nmt.edu) 7 * and Paul Mackerras (paulus@samba.org) 8 */ --- 39 unchanged lines hidden (view full) --- 48#include <asm/pmc.h> 49#include <asm/reg.h> 50#ifdef CONFIG_PMAC_BACKLIGHT 51#include <asm/backlight.h> 52#endif 53#ifdef CONFIG_PPC64 54#include <asm/firmware.h> 55#include <asm/processor.h> | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 4 * Copyright 2007-2010 Freescale Semiconductor, Inc. 5 * 6 * Modified by Cort Dougan (cort@cs.nmt.edu) 7 * and Paul Mackerras (paulus@samba.org) 8 */ --- 39 unchanged lines hidden (view full) --- 48#include <asm/pmc.h> 49#include <asm/reg.h> 50#ifdef CONFIG_PMAC_BACKLIGHT 51#include <asm/backlight.h> 52#endif 53#ifdef CONFIG_PPC64 54#include <asm/firmware.h> 55#include <asm/processor.h> |
56#include <asm/tm.h> | |
57#endif 58#include <asm/kexec.h> 59#include <asm/ppc-opcode.h> 60#include <asm/rio.h> 61#include <asm/fadump.h> 62#include <asm/switch_to.h> 63#include <asm/tm.h> 64#include <asm/debug.h> --- 335 unchanged lines hidden (view full) --- 400 return; 401 if (regs->msr & MSR_PR) 402 return; 403 404 /* 405 * Now test if the interrupt has hit a range that may be using 406 * HSPRG1 without having RI=0 (i.e., an HSRR interrupt). The 407 * problem ranges all run un-relocated. Test real and virt modes | 56#endif 57#include <asm/kexec.h> 58#include <asm/ppc-opcode.h> 59#include <asm/rio.h> 60#include <asm/fadump.h> 61#include <asm/switch_to.h> 62#include <asm/tm.h> 63#include <asm/debug.h> --- 335 unchanged lines hidden (view full) --- 399 return; 400 if (regs->msr & MSR_PR) 401 return; 402 403 /* 404 * Now test if the interrupt has hit a range that may be using 405 * HSPRG1 without having RI=0 (i.e., an HSRR interrupt). The 406 * problem ranges all run un-relocated. Test real and virt modes |
408 * at the same time by droping the high bit of the nip (virt mode | 407 * at the same time by dropping the high bit of the nip (virt mode |
409 * entry points still have the +0x4000 offset). 410 */ 411 nip &= ~0xc000000000000000ULL; 412 if ((nip >= 0x500 && nip < 0x600) || (nip >= 0x4500 && nip < 0x4600)) 413 goto nonrecoverable; 414 if ((nip >= 0x980 && nip < 0xa00) || (nip >= 0x4980 && nip < 0x4a00)) 415 goto nonrecoverable; 416 if ((nip >= 0xe00 && nip < 0xec0) || (nip >= 0x4e00 && nip < 0x4ec0)) --- 442 unchanged lines hidden (view full) --- 859static void p9_hmi_special_emu(struct pt_regs *regs) 860{ 861 unsigned int ra, rb, t, i, sel, instr, rc; 862 const void __user *addr; 863 u8 vbuf[16] __aligned(16), *vdst; 864 unsigned long ea, msr, msr_mask; 865 bool swap; 866 | 408 * entry points still have the +0x4000 offset). 409 */ 410 nip &= ~0xc000000000000000ULL; 411 if ((nip >= 0x500 && nip < 0x600) || (nip >= 0x4500 && nip < 0x4600)) 412 goto nonrecoverable; 413 if ((nip >= 0x980 && nip < 0xa00) || (nip >= 0x4980 && nip < 0x4a00)) 414 goto nonrecoverable; 415 if ((nip >= 0xe00 && nip < 0xec0) || (nip >= 0x4e00 && nip < 0x4ec0)) --- 442 unchanged lines hidden (view full) --- 858static void p9_hmi_special_emu(struct pt_regs *regs) 859{ 860 unsigned int ra, rb, t, i, sel, instr, rc; 861 const void __user *addr; 862 u8 vbuf[16] __aligned(16), *vdst; 863 unsigned long ea, msr, msr_mask; 864 bool swap; 865 |
867 if (__get_user_inatomic(instr, (unsigned int __user *)regs->nip)) | 866 if (__get_user(instr, (unsigned int __user *)regs->nip)) |
868 return; 869 870 /* 871 * lxvb16x opcode: 0x7c0006d8 872 * lxvd2x opcode: 0x7c000698 873 * lxvh8x opcode: 0x7c000658 874 * lxvw4x opcode: 0x7c000618 875 */ --- 198 unchanged lines hidden (view full) --- 1074DEFINE_INTERRUPT_HANDLER_ASYNC(unknown_async_exception) 1075{ 1076 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 1077 regs->nip, regs->msr, regs->trap); 1078 1079 _exception(SIGTRAP, regs, TRAP_UNK, 0); 1080} 1081 | 867 return; 868 869 /* 870 * lxvb16x opcode: 0x7c0006d8 871 * lxvd2x opcode: 0x7c000698 872 * lxvh8x opcode: 0x7c000658 873 * lxvw4x opcode: 0x7c000618 874 */ --- 198 unchanged lines hidden (view full) --- 1073DEFINE_INTERRUPT_HANDLER_ASYNC(unknown_async_exception) 1074{ 1075 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 1076 regs->nip, regs->msr, regs->trap); 1077 1078 _exception(SIGTRAP, regs, TRAP_UNK, 0); 1079} 1080 |
1081DEFINE_INTERRUPT_HANDLER_NMI(unknown_nmi_exception) 1082{ 1083 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 1084 regs->nip, regs->msr, regs->trap); 1085 1086 _exception(SIGTRAP, regs, TRAP_UNK, 0); 1087 1088 return 0; 1089} 1090 |
|
1082DEFINE_INTERRUPT_HANDLER(instruction_breakpoint_exception) 1083{ 1084 if (notify_die(DIE_IABR_MATCH, "iabr_match", regs, 5, 1085 5, SIGTRAP) == NOTIFY_STOP) 1086 return; 1087 if (debugger_iabr_match(regs)) 1088 return; 1089 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); --- 311 unchanged lines hidden (view full) --- 1401{ 1402 return is_kernel_addr(addr); 1403} 1404 1405#ifdef CONFIG_MATH_EMULATION 1406static int emulate_math(struct pt_regs *regs) 1407{ 1408 int ret; | 1091DEFINE_INTERRUPT_HANDLER(instruction_breakpoint_exception) 1092{ 1093 if (notify_die(DIE_IABR_MATCH, "iabr_match", regs, 5, 1094 5, SIGTRAP) == NOTIFY_STOP) 1095 return; 1096 if (debugger_iabr_match(regs)) 1097 return; 1098 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); --- 311 unchanged lines hidden (view full) --- 1410{ 1411 return is_kernel_addr(addr); 1412} 1413 1414#ifdef CONFIG_MATH_EMULATION 1415static int emulate_math(struct pt_regs *regs) 1416{ 1417 int ret; |
1409 extern int do_mathemu(struct pt_regs *regs); | |
1410 1411 ret = do_mathemu(regs); 1412 if (ret >= 0) 1413 PPC_WARN_EMULATED(math, regs); 1414 1415 switch (ret) { 1416 case 0: 1417 emulate_single_step(regs); --- 183 unchanged lines hidden (view full) --- 1601 } 1602bad: 1603 if (user_mode(regs)) 1604 _exception(sig, regs, code, regs->dar); 1605 else 1606 bad_page_fault(regs, sig); 1607} 1608 | 1418 1419 ret = do_mathemu(regs); 1420 if (ret >= 0) 1421 PPC_WARN_EMULATED(math, regs); 1422 1423 switch (ret) { 1424 case 0: 1425 emulate_single_step(regs); --- 183 unchanged lines hidden (view full) --- 1609 } 1610bad: 1611 if (user_mode(regs)) 1612 _exception(sig, regs, code, regs->dar); 1613 else 1614 bad_page_fault(regs, sig); 1615} 1616 |
1609DEFINE_INTERRUPT_HANDLER(StackOverflow) 1610{ 1611 pr_crit("Kernel stack overflow in process %s[%d], r1=%lx\n", 1612 current->comm, task_pid_nr(current), regs->gpr[1]); 1613 debugger(regs); 1614 show_regs(regs); 1615 panic("kernel stack overflow"); 1616} 1617 | |
1618DEFINE_INTERRUPT_HANDLER(stack_overflow_exception) 1619{ 1620 die("Kernel stack overflow", regs, SIGSEGV); 1621} 1622 1623DEFINE_INTERRUPT_HANDLER(kernel_fp_unavailable_exception) 1624{ 1625 printk(KERN_EMERG "Unrecoverable FP Unavailable Exception " --- 539 unchanged lines hidden (view full) --- 2165#endif 2166 2167/* 2168 * We enter here if we get an unrecoverable exception, that is, one 2169 * that happened at a point where the RI (recoverable interrupt) bit 2170 * in the MSR is 0. This indicates that SRR0/1 are live, and that 2171 * we therefore lost state by taking this exception. 2172 */ | 1617DEFINE_INTERRUPT_HANDLER(stack_overflow_exception) 1618{ 1619 die("Kernel stack overflow", regs, SIGSEGV); 1620} 1621 1622DEFINE_INTERRUPT_HANDLER(kernel_fp_unavailable_exception) 1623{ 1624 printk(KERN_EMERG "Unrecoverable FP Unavailable Exception " --- 539 unchanged lines hidden (view full) --- 2164#endif 2165 2166/* 2167 * We enter here if we get an unrecoverable exception, that is, one 2168 * that happened at a point where the RI (recoverable interrupt) bit 2169 * in the MSR is 0. This indicates that SRR0/1 are live, and that 2170 * we therefore lost state by taking this exception. 2171 */ |
2173void unrecoverable_exception(struct pt_regs *regs) | 2172void __noreturn unrecoverable_exception(struct pt_regs *regs) |
2174{ 2175 pr_emerg("Unrecoverable exception %lx at %lx (msr=%lx)\n", 2176 regs->trap, regs->nip, regs->msr); 2177 die("Unrecoverable exception", regs, SIGABRT); | 2173{ 2174 pr_emerg("Unrecoverable exception %lx at %lx (msr=%lx)\n", 2175 regs->trap, regs->nip, regs->msr); 2176 die("Unrecoverable exception", regs, SIGABRT); |
2177 /* die() should not return */ 2178 for (;;) 2179 ; |
|
2178} 2179 2180#if defined(CONFIG_BOOKE_WDT) || defined(CONFIG_40x) 2181/* 2182 * Default handler for a Watchdog exception, 2183 * spins until a reboot occurs 2184 */ 2185void __attribute__ ((weak)) WatchdogHandler(struct pt_regs *regs) 2186{ 2187 /* Generic WatchdogHandler, implement your own */ 2188 mtspr(SPRN_TCR, mfspr(SPRN_TCR)&(~TCR_WIE)); 2189 return; 2190} 2191 | 2180} 2181 2182#if defined(CONFIG_BOOKE_WDT) || defined(CONFIG_40x) 2183/* 2184 * Default handler for a Watchdog exception, 2185 * spins until a reboot occurs 2186 */ 2187void __attribute__ ((weak)) WatchdogHandler(struct pt_regs *regs) 2188{ 2189 /* Generic WatchdogHandler, implement your own */ 2190 mtspr(SPRN_TCR, mfspr(SPRN_TCR)&(~TCR_WIE)); 2191 return; 2192} 2193 |
2192DEFINE_INTERRUPT_HANDLER(WatchdogException) /* XXX NMI? async? */ | 2194DEFINE_INTERRUPT_HANDLER_NMI(WatchdogException) |
2193{ 2194 printk (KERN_EMERG "PowerPC Book-E Watchdog Exception\n"); 2195 WatchdogHandler(regs); | 2195{ 2196 printk (KERN_EMERG "PowerPC Book-E Watchdog Exception\n"); 2197 WatchdogHandler(regs); |
2198 return 0; |
|
2196} 2197#endif 2198 2199/* 2200 * We enter here if we discover during exception entry that we are 2201 * running in supervisor mode with a userspace value in the stack pointer. 2202 */ 2203DEFINE_INTERRUPT_HANDLER(kernel_bad_stack) --- 77 unchanged lines hidden --- | 2199} 2200#endif 2201 2202/* 2203 * We enter here if we discover during exception entry that we are 2204 * running in supervisor mode with a userspace value in the stack pointer. 2205 */ 2206DEFINE_INTERRUPT_HANDLER(kernel_bad_stack) --- 77 unchanged lines hidden --- |