static int cch_seq_show(struct seq_file *file, void *data) { long gid = *(long *)data; int i; struct gru_state *gru = GID_TO_GRU(gid); struct gru_thread_state *ts; const char *mode[] = { "??", "UPM", "INTR", "OS_POLL" }; if (gid == 0) seq_printf(file, "#%5s%5s%6s%7s%9s%6s%8s%8s\n", "gid", "bid", "ctx#", "asid", "pid", "cbrs", "dsbytes", "mode"); if (gru) for (i = 0; i < GRU_NUM_CCH; i++) { ts = gru->gs_gts[i]; if (!ts) continue; seq_printf(file, " %5d%5d%6d%7d%9d%6d%8d%8s\n", gru->gs_gid, gru->gs_blade_id, i, is_kernel_context(ts) ? 0 : ts->ts_gms->ms_asids[gid].mt_asid, is_kernel_context(ts) ? 0 : ts->ts_tgid_owner, ts->ts_cbr_au_count * GRU_CBR_AU_SIZE, ts->ts_cbr_au_count * GRU_DSR_AU_BYTES, mode[ts->ts_user_options & GRU_OPT_MISS_MASK]); } return 0; }
static void dump_context(struct ucontext *cx) { kprintf("iret_eip = 0x%lx\n", cx->iret_eip); kprintf("iret_cs = 0x%lx\n", cx->iret_cs); kprintf("iret_elfags = 0x%lx\n", cx->eflags); if (!is_kernel_context(cx)) { kprintf("iret_esp = 0x%lx\n", cx->iret_esp); kprintf("iret_ss = 0x%lx\n", cx->iret_ss); } dump_registers(&cx->reg); }
static void segfault(int code, unsigned long error, void *addr) { kprintf("Segmentation fault: %s mode %s at 0x%p%s\n", (error & PGF_USER) ? "user" : "kernel", (error & PGF_WRITE) ? "write" : "read", addr, (error & PGF_PERM) ? "" : " (page not present)"); dump_context(current->esp); if (is_kernel_context(current->esp)) panic("Segfault in kernel"); __kill(current, SIGSEGV, code); }
static unsigned long get_error_code(struct ucontext *cx) { unsigned long error = cx->reg.stack[0]; cx->reg.stack[0] = cx->reg.stack[1]; cx->reg.stack[1] = cx->reg.stack[2]; cx->reg.stack[2] = cx->reg.stack[3]; if (!is_kernel_context(cx)) { cx->reg.stack[3] = cx->reg.stack[4]; cx->reg.stack[4] = cx->reg.stack[5]; } return error; }