Release 4.14 arch/s390/kernel/traps.c
// SPDX-License-Identifier: GPL-2.0
/*
* S390 version
* Copyright IBM Corp. 1999, 2000
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
* Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
*
* Derived from "arch/i386/kernel/traps.c"
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/*
* 'Traps.c' handles hardware traps and faults after we have saved some
* state in 'asm.s'.
*/
#include <linux/kprobes.h>
#include <linux/kdebug.h>
#include <linux/extable.h>
#include <linux/ptrace.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/cpu.h>
#include <asm/fpu/api.h>
#include "entry.h"
static inline void __user *get_trap_ip(struct pt_regs *regs)
{
unsigned long address;
if (regs->int_code & 0x200)
address = *(unsigned long *)(current->thread.trap_tdb + 24);
else
address = regs->psw.addr;
return (void __user *) (address - (regs->int_code >> 16));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 71 | 100.00% | 1 | 100.00% |
Total | 71 | 100.00% | 1 | 100.00% |
int is_valid_bugaddr(unsigned long addr)
{
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Heiko Carstens | 12 | 100.00% | 1 | 100.00% |
Total | 12 | 100.00% | 1 | 100.00% |
void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str)
{
siginfo_t info;
if (user_mode(regs)) {
info.si_signo = si_signo;
info.si_errno = 0;
info.si_code = si_code;
info.si_addr = get_trap_ip(regs);
force_sig_info(si_signo, &info, current);
report_user_fault(regs, si_signo, 0);
} else {
const struct exception_table_entry *fixup;
fixup = search_exception_tables(regs->psw.addr);
if (fixup)
regs->psw.addr = extable_fixup(fixup);
else {
enum bug_trap_type btt;
btt = report_bug(regs->psw.addr, regs);
if (btt == BUG_TRAP_TYPE_WARN)
return;
die(regs, str);
}
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 51 | 34.69% | 4 | 30.77% |
Heiko Carstens | 36 | 24.49% | 6 | 46.15% |
Linus Torvalds (pre-git) | 34 | 23.13% | 1 | 7.69% |
Linus Torvalds | 25 | 17.01% | 1 | 7.69% |
Jan Willeke | 1 | 0.68% | 1 | 7.69% |
Total | 147 | 100.00% | 13 | 100.00% |
static void do_trap(struct pt_regs *regs, int si_signo, int si_code, char *str)
{
if (notify_die(DIE_TRAP, str, regs, 0,
regs->int_code, si_signo) == NOTIFY_STOP)
return;
do_report_trap(regs, si_signo, si_code, str);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jan Willeke | 54 | 100.00% | 1 | 100.00% |
Total | 54 | 100.00% | 1 | 100.00% |
NOKPROBE_SYMBOL(do_trap);
void do_per_trap(struct pt_regs *regs)
{
siginfo_t info;
if (notify_die(DIE_SSTEP, "sstep", regs, 0, 0, SIGTRAP) == NOTIFY_STOP)
return;
if (!current->ptrace)
return;
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_HWBKPT;
info.si_addr =
(void __force __user *) current->thread.per_event.address;
force_sig_info(SIGTRAP, &info, current);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 48 | 55.17% | 5 | 62.50% |
Michael Grundy | 20 | 22.99% | 1 | 12.50% |
Linus Torvalds (pre-git) | 17 | 19.54% | 1 | 12.50% |
Tejun Heo | 2 | 2.30% | 1 | 12.50% |
Total | 87 | 100.00% | 8 | 100.00% |
NOKPROBE_SYMBOL(do_per_trap);
void default_trap_handler(struct pt_regs *regs)
{
if (user_mode(regs)) {
report_user_fault(regs, SIGSEGV, 0);
do_exit(SIGSEGV);
} else
die(regs, "Unknown program exception");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 27 | 65.85% | 3 | 37.50% |
Heiko Carstens | 14 | 34.15% | 5 | 62.50% |
Total | 41 | 100.00% | 8 | 100.00% |
#define DO_ERROR_INFO(name, signr, sicode, str) \
void name(struct pt_regs *regs) \
{ \
do_trap(regs, signr, sicode, str); \
}
DO_ERROR_INFO(addressing_exception, SIGILL, ILL_ILLADR,
"addressing exception")
DO_ERROR_INFO(execute_exception, SIGILL, ILL_ILLOPN,
"execute exception")
DO_ERROR_INFO(divide_exception, SIGFPE, FPE_INTDIV,
"fixpoint divide exception")
DO_ERROR_INFO(overflow_exception, SIGFPE, FPE_INTOVF,
"fixpoint overflow exception")
DO_ERROR_INFO(hfp_overflow_exception, SIGFPE, FPE_FLTOVF,
"HFP overflow exception")
DO_ERROR_INFO(hfp_underflow_exception, SIGFPE, FPE_FLTUND,
"HFP underflow exception")
DO_ERROR_INFO(hfp_significance_exception, SIGFPE, FPE_FLTRES,
"HFP significance exception")
DO_ERROR_INFO(hfp_divide_exception, SIGFPE, FPE_FLTDIV,
"HFP divide exception")
DO_ERROR_INFO(hfp_sqrt_exception, SIGFPE, FPE_FLTINV,
"HFP square root exception")
DO_ERROR_INFO(operand_exception, SIGILL, ILL_ILLOPN,
"operand exception")
DO_ERROR_INFO(privileged_op, SIGILL, ILL_PRVOPC,
"privileged operation")
DO_ERROR_INFO(special_op_exception, SIGILL, ILL_ILLOPN,
"special operation exception")
DO_ERROR_INFO(transaction_exception, SIGILL, ILL_ILLOPN,
"transaction constraint exception")
static inline void do_fp_trap(struct pt_regs *regs, __u32 fpc)
{
int si_code = 0;
/* FPC[2] is Data Exception Code */
if ((fpc & 0x00000300) == 0) {
/* bits 6 and 7 of DXC are 0 iff IEEE exception */
if (fpc & 0x8000) /* invalid fp operation */
si_code = FPE_FLTINV;
else if (fpc & 0x4000) /* div by 0 */
si_code = FPE_FLTDIV;
else if (fpc & 0x2000) /* overflow */
si_code = FPE_FLTOVF;
else if (fpc & 0x1000) /* underflow */
si_code = FPE_FLTUND;
else if (fpc & 0x0800) /* inexact */
si_code = FPE_FLTRES;
}
do_trap(regs, SIGFPE, si_code, "floating point exception");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 98 | 94.23% | 2 | 50.00% |
Linus Torvalds (pre-git) | 5 | 4.81% | 1 | 25.00% |
Hendrik Brueckner | 1 | 0.96% | 1 | 25.00% |
Total | 104 | 100.00% | 4 | 100.00% |
void translation_exception(struct pt_regs *regs)
{
/* May never happen. */
panic("Translation exception");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Heiko Carstens | 16 | 100.00% | 2 | 100.00% |
Total | 16 | 100.00% | 2 | 100.00% |
void illegal_op(struct pt_regs *regs)
{
siginfo_t info;
__u8 opcode[6];
__u16 __user *location;
int is_uprobe_insn = 0;
int signal = 0;
location = get_trap_ip(regs);
if (user_mode(regs)) {
if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
return;
if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
if (current->ptrace) {
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_BRKPT;
info.si_addr = location;
force_sig_info(SIGTRAP, &info, current);
} else
signal = SIGILL;
#ifdef CONFIG_UPROBES
} else if (*((__u16 *) opcode) == UPROBE_SWBP_INSN) {
is_uprobe_insn = 1;
#endif
} else
signal = SIGILL;
}
/*
* We got either an illegal op in kernel mode, or user space trapped
* on a uprobes illegal instruction. See if kprobes or uprobes picks
* it up. If not, SIGILL.
*/
if (is_uprobe_insn || !user_mode(regs)) {
if (notify_die(DIE_BPT, "bpt", regs, 0,
3, SIGTRAP) != NOTIFY_STOP)
signal = SIGILL;
}
if (signal)
do_trap(regs, signal, ILL_ILLOPC, "illegal operation");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 80 | 37.21% | 1 | 6.25% |
Heiko Carstens | 45 | 20.93% | 4 | 25.00% |
Martin Schwidefsky | 45 | 20.93% | 5 | 31.25% |
Jan Willeke | 28 | 13.02% | 1 | 6.25% |
Linus Torvalds | 10 | 4.65% | 3 | 18.75% |
Andrew Morton | 5 | 2.33% | 1 | 6.25% |
Tejun Heo | 2 | 0.93% | 1 | 6.25% |
Total | 215 | 100.00% | 16 | 100.00% |
NOKPROBE_SYMBOL(illegal_op);
DO_ERROR_INFO(specification_exception, SIGILL, ILL_ILLOPN,
"specification exception");
void vector_exception(struct pt_regs *regs)
{
int si_code, vic;
if (!MACHINE_HAS_VX) {
do_trap(regs, SIGILL, ILL_ILLOPN, "illegal operation");
return;
}
/* get vector interrupt code from fpc */
save_fpu_regs();
vic = (current->thread.fpu.fpc & 0xf00) >> 8;
switch (vic) {
case 1: /* invalid vector operation */
si_code = FPE_FLTINV;
break;
case 2: /* division by zero */
si_code = FPE_FLTDIV;
break;
case 3: /* overflow */
si_code = FPE_FLTOVF;
break;
case 4: /* underflow */
si_code = FPE_FLTUND;
break;
case 5: /* inexact */
si_code = FPE_FLTRES;
break;
default: /* unknown cause */
si_code = 0;
}
do_trap(regs, SIGFPE, si_code, "vector exception");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Heiko Carstens | 58 | 47.54% | 1 | 10.00% |
Linus Torvalds (pre-git) | 47 | 38.52% | 1 | 10.00% |
Martin Schwidefsky | 8 | 6.56% | 3 | 30.00% |
Linus Torvalds | 5 | 4.10% | 2 | 20.00% |
Hendrik Brueckner | 4 | 3.28% | 3 | 30.00% |
Total | 122 | 100.00% | 10 | 100.00% |
void data_exception(struct pt_regs *regs)
{
int signal = 0;
save_fpu_regs();
if (current->thread.fpu.fpc & FPC_DXC_MASK)
signal = SIGFPE;
else
signal = SIGILL;
if (signal == SIGFPE)
do_fp_trap(regs, current->thread.fpu.fpc);
else if (signal)
do_trap(regs, signal, ILL_ILLOPN, "data exception");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds | 36 | 48.65% | 2 | 22.22% |
Heiko Carstens | 12 | 16.22% | 1 | 11.11% |
Linus Torvalds (pre-git) | 12 | 16.22% | 1 | 11.11% |
Martin Schwidefsky | 9 | 12.16% | 2 | 22.22% |
Hendrik Brueckner | 5 | 6.76% | 3 | 33.33% |
Total | 74 | 100.00% | 9 | 100.00% |
void space_switch_exception(struct pt_regs *regs)
{
/* Set user psw back to home space mode. */
if (user_mode(regs))
regs->psw.mask |= PSW_ASC_HOME;
/* Send SIGILL. */
do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 35 | 92.11% | 2 | 66.67% |
Heiko Carstens | 3 | 7.89% | 1 | 33.33% |
Total | 38 | 100.00% | 3 | 100.00% |
void kernel_stack_overflow(struct pt_regs *regs)
{
bust_spinlocks(1);
printk("Kernel stack overflow.\n");
show_regs(regs);
bust_spinlocks(0);
panic("Corrupt kernel stack, can't continue.");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 20 | 57.14% | 1 | 50.00% |
Heiko Carstens | 15 | 42.86% | 1 | 50.00% |
Total | 35 | 100.00% | 2 | 100.00% |
NOKPROBE_SYMBOL(kernel_stack_overflow);
void __init trap_init(void)
{
local_mcck_enable();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 7 | 63.64% | 1 | 33.33% |
Heiko Carstens | 3 | 27.27% | 1 | 33.33% |
Martin Schwidefsky | 1 | 9.09% | 1 | 33.33% |
Total | 11 | 100.00% | 3 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Martin Schwidefsky | 553 | 44.56% | 15 | 28.85% |
Heiko Carstens | 251 | 20.23% | 21 | 40.38% |
Linus Torvalds (pre-git) | 230 | 18.53% | 1 | 1.92% |
Jan Willeke | 83 | 6.69% | 1 | 1.92% |
Linus Torvalds | 77 | 6.20% | 4 | 7.69% |
Michael Grundy | 20 | 1.61% | 1 | 1.92% |
Hendrik Brueckner | 11 | 0.89% | 4 | 7.69% |
Andrew Morton | 5 | 0.40% | 1 | 1.92% |
Tejun Heo | 4 | 0.32% | 1 | 1.92% |
Ingo Molnar | 3 | 0.24% | 1 | 1.92% |
Paul Gortmaker | 3 | 0.24% | 1 | 1.92% |
Greg Kroah-Hartman | 1 | 0.08% | 1 | 1.92% |
Total | 1241 | 100.00% | 52 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.