Ejemplo n.º 1
0
void
kmdb_dpi_process_work_queue(void)
{
	work_results_t res;

	(void) mdb_nv_create(&res.res_loads, UM_SLEEP);
	(void) mdb_nv_create(&res.res_unloads, UM_SLEEP);

	mdb_dprintf(MDB_DBG_DPI, "processing work queue\n");
	(void) kmdb_wr_debugger_process(kmdb_dbgnotify_cb, &res);

	if (mdb_nv_size(&res.res_loads)) {
		mdb_printf("Loaded modules: [");
		print_modules(&res.res_loads);
		mdb_printf(" ]\n");
	}

	if (mdb_nv_size(&res.res_unloads)) {
		mdb_printf("Unloaded modules: [");
		print_modules(&res.res_unloads);
		mdb_printf(" ]\n");
	}

	mdb_nv_destroy(&res.res_loads);
	mdb_nv_destroy(&res.res_unloads);
}
Ejemplo n.º 2
0
static void
print_usage(void)
{
	fprintf(stderr, "Usage: dnet <command> <args> ...\n\n");

	print_modules(MOD_TYPE_DATA, "Payload generation");
	print_modules(MOD_TYPE_ENCAP, "Packet encapsulation");
	print_modules(MOD_TYPE_XMIT, "Packet transmission");
	print_modules(MOD_TYPE_KERN, "Kernel interface");
}
Ejemplo n.º 3
0
void die(struct pt_regs *regs, const char *str)
{
	static int die_counter;

	oops_enter();
	lgr_info_log();
	debug_stop_all();
	console_verbose();
	spin_lock_irq(&die_lock);
	bust_spinlocks(1);
	printk("%s: %04x [#%d] ", str, regs->int_code & 0xffff, ++die_counter);
#ifdef CONFIG_PREEMPT
	printk("PREEMPT ");
#endif
#ifdef CONFIG_SMP
	printk("SMP ");
#endif
#ifdef CONFIG_DEBUG_PAGEALLOC
	printk("DEBUG_PAGEALLOC");
#endif
	printk("\n");
	notify_die(DIE_OOPS, str, regs, 0, regs->int_code & 0xffff, SIGSEGV);
	print_modules();
	show_regs(regs);
	bust_spinlocks(0);
	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
	spin_unlock_irq(&die_lock);
	if (in_interrupt())
		panic("Fatal exception in interrupt");
	if (panic_on_oops)
		panic("Fatal exception: panic_on_oops");
	oops_exit();
	do_exit(SIGSEGV);
}
Ejemplo n.º 4
0
void __noreturn die(const char *str, struct pt_regs *regs,
		    long err, unsigned long addr)
{
	static int die_counter;

	oops_enter();

	spin_lock_irq(&die_lock);
	console_verbose();
	bust_spinlocks(1);
	pr_err("%s: err %04lx (%s) addr %08lx [#%d]\n", str, err & 0xffff,
	       trap_name(err & 0xffff), addr, ++die_counter);

	print_modules();
	show_regs(regs);

	pr_err("Process: %s (pid: %d, stack limit = %p)\n", current->comm,
	       task_pid_nr(current), task_stack_page(current) + THREAD_SIZE);

	bust_spinlocks(0);
	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
	if (kexec_should_crash(current))
		crash_kexec(regs);

	if (in_interrupt())
		panic("Fatal exception in interrupt");

	if (panic_on_oops)
		panic("Fatal exception");

	spin_unlock_irq(&die_lock);
	oops_exit();
	do_exit(SIGSEGV);
}
Ejemplo n.º 5
0
static int __die(const char *str, int err, struct thread_info *thread,
		 struct pt_regs *regs)
{
	struct task_struct *tsk = thread->task;
	static int die_counter;
	int ret;

	pr_emerg("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n",
		 str, err, ++die_counter);

	/* trap and error numbers are mostly meaningless on ARM */
	ret = notify_die(DIE_OOPS, str, regs, err, 0, SIGSEGV);
	if (ret == NOTIFY_STOP)
		return ret;

	print_modules();
	__show_regs(regs);
	pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n",
		 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);

	if (!user_mode(regs) || in_interrupt()) {
		dump_mem(KERN_EMERG, "Stack: ", regs->sp,
			 THREAD_SIZE + (unsigned long)task_stack_page(tsk));
		dump_backtrace(regs, tsk);
		dump_instr(KERN_EMERG, regs);
	}

	return ret;
}
Ejemplo n.º 6
0
static int __die(const char *str, int err, struct pt_regs *regs)
{
	struct task_struct *tsk = current;
	static int die_counter;
	int ret;

	pr_emerg("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n",
		 str, err, ++die_counter);

	/* trap and error numbers are mostly meaningless on ARM */
	ret = notify_die(DIE_OOPS, str, regs, err, 0, SIGSEGV);
	if (ret == NOTIFY_STOP)
		return ret;

	print_modules();
	__show_regs(regs);
	pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n",
		 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk),
		 end_of_stack(tsk));

	if (!user_mode(regs)) {
		dump_backtrace(regs, tsk);
		dump_instr(KERN_EMERG, regs);
	}

	return ret;
}
Ejemplo n.º 7
0
void warn_on_slowpath(const char *file, int line)
{
	char function[KSYM_SYMBOL_LEN];
	unsigned long caller = (unsigned long) __builtin_return_address(0);
	sprint_symbol(function, caller);

	printk(KERN_WARNING "------------[ cut here ]------------\n");
	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
		line, function);
	print_modules();
	dump_stack();
	print_oops_end_marker();
}
Ejemplo n.º 8
0
/* Callback function for perf event subsystem */
static void watchdog_overflow_callback(struct perf_event *event,
		 struct perf_sample_data *data,
		 struct pt_regs *regs)
{
	/* Ensure the watchdog never gets throttled */
	event->hw.interrupts = 0;

	if (__this_cpu_read(watchdog_nmi_touch) == true) {
		__this_cpu_write(watchdog_nmi_touch, false);
		return;
	}

	/* check for a hardlockup
	 * This is done by making sure our timer interrupt
	 * is incrementing.  The timer interrupt should have
	 * fired multiple times before we overflow'd.  If it hasn't
	 * then this is a good indication the cpu is stuck
	 */
	if (is_hardlockup()) {
		int this_cpu = smp_processor_id();

		/* only print hardlockups once */
		if (__this_cpu_read(hard_watchdog_warn) == true)
			return;

		pr_emerg("Watchdog detected hard LOCKUP on cpu %d", this_cpu);
		print_modules();
		print_irqtrace_events(current);
		if (regs)
			show_regs(regs);
		else
			dump_stack();

		/*
		 * Perform all-CPU dump only once to avoid multiple hardlockups
		 * generating interleaving traces
		 */
		if (sysctl_hardlockup_all_cpu_backtrace &&
				!test_and_set_bit(0, &hardlockup_allcpu_dumped))
			trigger_allbutself_cpu_backtrace();

		if (hardlockup_panic)
			nmi_panic(regs, "Hard LOCKUP");

		__this_cpu_write(hard_watchdog_warn, true);
		return;
	}

	__this_cpu_write(hard_watchdog_warn, false);
	return;
}
void show_registers(struct pt_regs *regs)
{
	int i;
	unsigned long sp;
	const int cpu = smp_processor_id();
	struct task_struct *cur = current;

	sp = regs->sp;
	printk("CPU %d ", cpu);
	print_modules();
	__show_regs(regs, 1);
	printk("Process %s (pid: %d, veid: %d, threadinfo %p, task %p)\n",
		cur->comm, cur->pid, task_veid(cur),
		task_thread_info(cur), cur);

	/*
	 * When in-kernel, we also print out the stack and code at the
	 * time of the fault..
	 */
	if (!user_mode(regs)) {
		unsigned int code_prologue = code_bytes * 43 / 64;
		unsigned int code_len = code_bytes;
		unsigned char c;
		u8 *ip;

		printk(KERN_DEFAULT "Stack:\n");
		show_stack_log_lvl(NULL, regs, (unsigned long *)sp,
				KERN_DEFAULT);

		printk(KERN_DEFAULT "Code: ");

		ip = (u8 *)regs->ip - code_prologue;
		if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
			/* try starting at IP */
			ip = (u8 *)regs->ip;
			code_len = code_len - code_prologue + 1;
		}
		for (i = 0; i < code_len; i++, ip++) {
			if (ip < (u8 *)PAGE_OFFSET ||
					probe_kernel_address(ip, c)) {
				printk(" Bad RIP value.");
				break;
			}
			if (ip == (u8 *)regs->ip)
				printk("<%02x> ", c);
			else
				printk("%02x ", c);
		}
	}
	printk("\n");
}
Ejemplo n.º 10
0
int __die(const char *str, struct pt_regs *regs, long err)
{
#ifdef CONFIG_X86_32
	unsigned short ss;
	unsigned long sp;
#endif
	printk(KERN_DEFAULT
	       "%s: %04lx [#%d] ", str, err & 0xffff, ++die_counter);
#ifdef CONFIG_PREEMPT
	printk("PREEMPT ");
#endif
#ifdef CONFIG_SMP
	printk("SMP ");
#endif
#ifdef CONFIG_DEBUG_PAGEALLOC
	printk("DEBUG_PAGEALLOC ");
#endif
#ifdef CONFIG_KASAN
	printk("KASAN");
#endif
	printk("\n");
	if (notify_die(DIE_OOPS, str, regs, err,
			current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
		return 1;

	/* FIXME this should probably also need to print into buffer */
	print_modules();
	show_regs(regs);
#ifdef CONFIG_X86_32
	if (user_mode(regs)) {
		sp = regs->sp;
		ss = regs->ss & 0xffff;
	} else {
		sp = kernel_stack_pointer(regs);
		savesegment(ss, ss);
	}
	printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
	print_symbol("%s", regs->ip);
	printk(" SS:ESP %04x:%08lx\n", ss, sp);
#else
	/* Executive summary in case the oops scrolled away */
	printk(KERN_ALERT "RIP ");
	/* FIXME */
	printk_address(regs->ip);
	printk(" RSP <%016lx>\n", regs->sp);
#endif
	return 0;
}
Ejemplo n.º 11
0
/* Spanws a new process and use verilog parser to parse
 * the specified verilog file. After that serialize the
 * structrures */
void parse_file(GObject *object) {
    gtk_tree_store_clear(parser.treestore);
    gchar *filename;
    // get filename of opened file
    filename = g_list_nth_data(opened_files, notebook_current_file_number());

    // Delete old text in text_view
    GtkTextBuffer *buffer;
    GtkTextIter iter_start, iter_end;
    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(parser.parser_output));
    gtk_text_buffer_get_start_iter(buffer, &iter_start);
    gtk_text_buffer_get_end_iter(buffer, &iter_end);
    gtk_text_buffer_delete(buffer, &iter_start, &iter_end);

    if (filename != NULL) {
        // spawn new process for parsing
        if (fork() == 0) {
            Shared *shmem;
            // attach shared memory segment to the address space
            shmem = (Shared *)shmat(shmid, NULL, 0);
            //Redirect fds[1] to be writed with the standard output.
            dup2 (fds[1], 1);
            printf("\n*****\n");
            printf("Parsing %s", filename);
            printf("\n*****\n");
            fflush(stdout);
            fprintf(stderr, "%s\n", filename);
            // open given file
            yyin = fopen(filename, "r");
            // parse file
            yyparse();
            // close file
            fclose(yyin);
            print_modules();
            printf("\n*****\n");
            printf("Parsing Complete");
            printf("\n*****\n");
            fflush(stdout);
            store_structures();
            // copy structures to the shared segment
            shmem->rdy = 1;
            // detache from shared segment
            shmdt(shmem);
            // exit child process
            exit(0);
        }
    }
}
Ejemplo n.º 12
0
void show_registers(struct pt_regs *regs)
{
	int i;

	print_modules();
	__show_regs(regs, 0);

	printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
		TASK_COMM_LEN, current->comm, task_pid_nr(current),
		current_thread_info(), current, task_thread_info(current));
	/*
	 * When in-kernel, we also print out the stack and code at the
	 * time of the fault..
	 */
	if (!user_mode_vm(regs)) {
		unsigned int code_prologue = code_bytes * 43 / 64;
		unsigned int code_len = code_bytes;
		unsigned char c;
		u8 *ip;

		printk(KERN_EMERG "Stack:\n");
		show_stack_log_lvl(NULL, regs, &regs->sp,
				0, KERN_EMERG);

		printk(KERN_EMERG "Code: ");

		ip = (u8 *)regs->ip - code_prologue;
		if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
			/* try starting at IP */
			ip = (u8 *)regs->ip;
			code_len = code_len - code_prologue + 1;
		}
		for (i = 0; i < code_len; i++, ip++) {
			if (ip < (u8 *)PAGE_OFFSET ||
					probe_kernel_address(ip, c)) {
				printk(" Bad EIP value.");
				break;
			}
			if (ip == (u8 *)regs->ip)
				printk("<%02x> ", c);
			else
				printk("%02x ", c);
		}
	}
	printk("\n");
}
Ejemplo n.º 13
0
void __warn(const char *file, int line, void *caller, unsigned taint,
	    struct pt_regs *regs, struct warn_args *args)
{
	disable_trace_on_warning();

	if (args)
		pr_warn(CUT_HERE);

	if (file)
		pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n",
			raw_smp_processor_id(), current->pid, file, line,
			caller);
	else
		pr_warn("WARNING: CPU: %d PID: %d at %pS\n",
			raw_smp_processor_id(), current->pid, caller);

	if (args)
		vprintk(args->fmt, args->args);

	if (panic_on_warn) {
		/*
		 * This thread may hit another WARN() in the panic path.
		 * Resetting this prevents additional WARN() from panicking the
		 * system on this thread.  Other threads are blocked by the
		 * panic_mutex in panic().
		 */
		panic_on_warn = 0;
		panic("panic_on_warn set ...\n");
	}

	print_modules();

	if (regs)
		show_regs(regs);
	else
		dump_stack();

	print_irqtrace_events(current);

	print_oops_end_marker();

	/* Just a warning, don't kill lockdep. */
	add_taint(taint, LOCKDEP_STILL_OK);
}
Ejemplo n.º 14
0
void warn_slowpath(const char *file, int line, const char *fmt, ...)
{
	va_list args;
	char function[KSYM_SYMBOL_LEN];
	unsigned long caller = (unsigned long)__builtin_return_address(0);
	sprint_symbol(function, caller);

	printk(KERN_WARNING "------------[ cut here ]------------\n");
	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
		line, function);
	va_start(args, fmt);
	vprintk(fmt, args);
	va_end(args);

	print_modules();
	dump_stack();
	print_oops_end_marker();
	add_taint(TAINT_WARN);
}
Ejemplo n.º 15
0
void __show_regs(struct pt_regs *regs)
{
	printk("\n");
	print_modules();
	printk(KERN_INFO "Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current),
		current->comm, print_tainted(), init_utsname()->release);
	printk(KERN_INFO "RIP: %04lx:[<%016lx>]\n", PT_REGS_CS(regs) & 0xffff,
	       PT_REGS_IP(regs));
	printk(KERN_INFO "RSP: %016lx  EFLAGS: %08lx\n", PT_REGS_SP(regs),
	       PT_REGS_EFLAGS(regs));
	printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n",
	       PT_REGS_AX(regs), PT_REGS_BX(regs), PT_REGS_CX(regs));
	printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n",
	       PT_REGS_DX(regs), PT_REGS_SI(regs), PT_REGS_DI(regs));
	printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n",
	       PT_REGS_BP(regs), PT_REGS_R8(regs), PT_REGS_R9(regs));
	printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n",
	       PT_REGS_R10(regs), PT_REGS_R11(regs), PT_REGS_R12(regs));
	printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n",
	       PT_REGS_R13(regs), PT_REGS_R14(regs), PT_REGS_R15(regs));
}
Ejemplo n.º 16
0
void die(const char *str, struct pt_regs *regs, long err)
{
	static int die_counter;

	oops_enter();

	spin_lock_irq(&die_lock);
	console_verbose();
	bust_spinlocks(1);

	printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
	print_modules();
	show_regs(regs);

	printk("Process: %s (pid: %d, stack limit = %p)\n", current->comm,
			task_pid_nr(current), task_stack_page(current) + 1);

	if (!user_mode(regs) || in_interrupt())
		dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
			 (unsigned long)task_stack_page(current));

	notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV);

	bust_spinlocks(0);
	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
	spin_unlock_irq(&die_lock);
	oops_exit();

	if (kexec_should_crash(current))
		crash_kexec(regs);

	if (in_interrupt())
		panic("Fatal exception in interrupt");

	if (panic_on_oops)
		panic("Fatal exception");

	do_exit(SIGSEGV);
}
Ejemplo n.º 17
0
int __die(const char *str, struct pt_regs *regs, long err)
{
#ifdef CONFIG_X86_32
    unsigned short ss;
    unsigned long sp;
#endif
    printk(KERN_DEFAULT
           "%s: %04lx [#%d]%s%s%s%s\n", str, err & 0xffff, ++die_counter,
           IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT"         : "",
           IS_ENABLED(CONFIG_SMP)     ? " SMP"             : "",
           debug_pagealloc_enabled()  ? " DEBUG_PAGEALLOC" : "",
           IS_ENABLED(CONFIG_KASAN)   ? " KASAN"           : "");

    if (notify_die(DIE_OOPS, str, regs, err,
                   current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
        return 1;

    print_modules();
    show_regs(regs);
#ifdef CONFIG_X86_32
    if (user_mode(regs)) {
        sp = regs->sp;
        ss = regs->ss & 0xffff;
    } else {
        sp = kernel_stack_pointer(regs);
        savesegment(ss, ss);
    }
    printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
    print_symbol("%s", regs->ip);
    printk(" SS:ESP %04x:%08lx\n", ss, sp);
#else
    /* Executive summary in case the oops scrolled away */
    printk(KERN_ALERT "RIP ");
    printk_address(regs->ip);
    printk(" RSP <%016lx>\n", regs->sp);
#endif
    return 0;
}
Ejemplo n.º 18
0
asmlinkage void trap_c(struct pt_regs *fp)
{
#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
    int j;
#endif
    int sig = 0;
    siginfo_t info;
    unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;

    trace_buffer_save(j);

    /* Important - be very careful dereferncing pointers - will lead to
     * double faults if the stack has become corrupt
     */

    /* If the fault was caused by a kernel thread, or interrupt handler
     * we will kernel panic, so the system reboots.
     * If KGDB is enabled, don't set this for kernel breakpoints
    */

    /* TODO: check to see if we are in some sort of deferred HWERR
     * that we should be able to recover from, not kernel panic
     */
    if ((bfin_read_IPEND() & 0xFFC0) && (trapnr != VEC_STEP)
#ifdef CONFIG_KGDB
            && (trapnr != VEC_EXCPT02)
#endif
       ) {
        console_verbose();
        oops_in_progress = 1;
    } else if (current) {
        if (current->mm == NULL) {
            console_verbose();
            oops_in_progress = 1;
        }
    }

    /* trap_c() will be called for exceptions. During exceptions
     * processing, the pc value should be set with retx value.
     * With this change we can cleanup some code in signal.c- TODO
     */
    fp->orig_pc = fp->retx;
    /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
    	trapnr, fp->ipend, fp->pc, fp->retx); */

    /* send the appropriate signal to the user program */
    switch (trapnr) {

    /* This table works in conjuction with the one in ./mach-common/entry.S
     * Some exceptions are handled there (in assembly, in exception space)
     * Some are handled here, (in C, in interrupt space)
     * Some, like CPLB, are handled in both, where the normal path is
     * handled in assembly/exception space, and the error path is handled
     * here
     */

    /* 0x00 - Linux Syscall, getting here is an error */
    /* 0x01 - userspace gdb breakpoint, handled here */
    case VEC_EXCPT01:
        info.si_code = TRAP_ILLTRAP;
        sig = SIGTRAP;
        CHK_DEBUGGER_TRAP_MAYBE();
        /* Check if this is a breakpoint in kernel space */
        if (fp->ipend & 0xffc0)
            return;
        else
            break;
#ifdef CONFIG_KGDB
    case VEC_EXCPT02 :		 /* gdb connection */
        info.si_code = TRAP_ILLTRAP;
        sig = SIGTRAP;
        CHK_DEBUGGER_TRAP();
        return;
#else
        /* 0x02 - User Defined, Caught by default */
#endif
    /* 0x03 - User Defined, userspace stack overflow */
    case VEC_EXCPT03:
        info.si_code = SEGV_STACKFLOW;
        sig = SIGSEGV;
        printk(KERN_NOTICE EXC_0x03(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x04 - User Defined, Caught by default */
    /* 0x05 - User Defined, Caught by default */
    /* 0x06 - User Defined, Caught by default */
    /* 0x07 - User Defined, Caught by default */
    /* 0x08 - User Defined, Caught by default */
    /* 0x09 - User Defined, Caught by default */
    /* 0x0A - User Defined, Caught by default */
    /* 0x0B - User Defined, Caught by default */
    /* 0x0C - User Defined, Caught by default */
    /* 0x0D - User Defined, Caught by default */
    /* 0x0E - User Defined, Caught by default */
    /* 0x0F - User Defined, Caught by default */
    /* 0x10 HW Single step, handled here */
    case VEC_STEP:
        info.si_code = TRAP_STEP;
        sig = SIGTRAP;
        CHK_DEBUGGER_TRAP_MAYBE();
        /* Check if this is a single step in kernel space */
        if (fp->ipend & 0xffc0)
            return;
        else
            break;
    /* 0x11 - Trace Buffer Full, handled here */
    case VEC_OVFLOW:
        info.si_code = TRAP_TRACEFLOW;
        sig = SIGTRAP;
        printk(KERN_NOTICE EXC_0x11(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x12 - Reserved, Caught by default */
    /* 0x13 - Reserved, Caught by default */
    /* 0x14 - Reserved, Caught by default */
    /* 0x15 - Reserved, Caught by default */
    /* 0x16 - Reserved, Caught by default */
    /* 0x17 - Reserved, Caught by default */
    /* 0x18 - Reserved, Caught by default */
    /* 0x19 - Reserved, Caught by default */
    /* 0x1A - Reserved, Caught by default */
    /* 0x1B - Reserved, Caught by default */
    /* 0x1C - Reserved, Caught by default */
    /* 0x1D - Reserved, Caught by default */
    /* 0x1E - Reserved, Caught by default */
    /* 0x1F - Reserved, Caught by default */
    /* 0x20 - Reserved, Caught by default */
    /* 0x21 - Undefined Instruction, handled here */
    case VEC_UNDEF_I:
        info.si_code = ILL_ILLOPC;
        sig = SIGILL;
        printk(KERN_NOTICE EXC_0x21(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x22 - Illegal Instruction Combination, handled here */
    case VEC_ILGAL_I:
        info.si_code = ILL_ILLPARAOP;
        sig = SIGILL;
        printk(KERN_NOTICE EXC_0x22(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x23 - Data CPLB protection violation, handled here */
    case VEC_CPLB_VL:
        info.si_code = ILL_CPLB_VI;
        sig = SIGBUS;
        printk(KERN_NOTICE EXC_0x23(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x24 - Data access misaligned, handled here */
    case VEC_MISALI_D:
        info.si_code = BUS_ADRALN;
        sig = SIGBUS;
        printk(KERN_NOTICE EXC_0x24(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x25 - Unrecoverable Event, handled here */
    case VEC_UNCOV:
        info.si_code = ILL_ILLEXCPT;
        sig = SIGILL;
        printk(KERN_NOTICE EXC_0x25(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
    	error case is handled here */
    case VEC_CPLB_M:
        info.si_code = BUS_ADRALN;
        sig = SIGBUS;
        printk(KERN_NOTICE EXC_0x26(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
    case VEC_CPLB_MHIT:
        info.si_code = ILL_CPLB_MULHIT;
        sig = SIGSEGV;
#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
        if (saved_dcplb_fault_addr < FIXED_CODE_START)
            printk(KERN_NOTICE "NULL pointer access\n");
        else
#endif
            printk(KERN_NOTICE EXC_0x27(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x28 - Emulation Watchpoint, handled here */
    case VEC_WATCH:
        info.si_code = TRAP_WATCHPT;
        sig = SIGTRAP;
        pr_debug(EXC_0x28(KERN_DEBUG));
        CHK_DEBUGGER_TRAP_MAYBE();
        /* Check if this is a watchpoint in kernel space */
        if (fp->ipend & 0xffc0)
            return;
        else
            break;
#ifdef CONFIG_BF535
    /* 0x29 - Instruction fetch access error (535 only) */
    case VEC_ISTRU_VL:      /* ADSP-BF535 only (MH) */
        info.si_code = BUS_OPFETCH;
        sig = SIGBUS;
        printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n");
        CHK_DEBUGGER_TRAP();
        break;
#else
        /* 0x29 - Reserved, Caught by default */
#endif
    /* 0x2A - Instruction fetch misaligned, handled here */
    case VEC_MISALI_I:
        info.si_code = BUS_ADRALN;
        sig = SIGBUS;
        printk(KERN_NOTICE EXC_0x2A(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x2B - Instruction CPLB protection violation, handled here */
    case VEC_CPLB_I_VL:
        info.si_code = ILL_CPLB_VI;
        sig = SIGBUS;
        printk(KERN_NOTICE EXC_0x2B(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
    case VEC_CPLB_I_M:
        info.si_code = ILL_CPLB_MISS;
        sig = SIGBUS;
        printk(KERN_NOTICE EXC_0x2C(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x2D - Instruction CPLB Multiple Hits, handled here */
    case VEC_CPLB_I_MHIT:
        info.si_code = ILL_CPLB_MULHIT;
        sig = SIGSEGV;
#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
        if (saved_icplb_fault_addr < FIXED_CODE_START)
            printk(KERN_NOTICE "Jump to NULL address\n");
        else
#endif
            printk(KERN_NOTICE EXC_0x2D(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x2E - Illegal use of Supervisor Resource, handled here */
    case VEC_ILL_RES:
        info.si_code = ILL_PRVOPC;
        sig = SIGILL;
        printk(KERN_NOTICE EXC_0x2E(KERN_NOTICE));
        CHK_DEBUGGER_TRAP();
        break;
    /* 0x2F - Reserved, Caught by default */
    /* 0x30 - Reserved, Caught by default */
    /* 0x31 - Reserved, Caught by default */
    /* 0x32 - Reserved, Caught by default */
    /* 0x33 - Reserved, Caught by default */
    /* 0x34 - Reserved, Caught by default */
    /* 0x35 - Reserved, Caught by default */
    /* 0x36 - Reserved, Caught by default */
    /* 0x37 - Reserved, Caught by default */
    /* 0x38 - Reserved, Caught by default */
    /* 0x39 - Reserved, Caught by default */
    /* 0x3A - Reserved, Caught by default */
    /* 0x3B - Reserved, Caught by default */
    /* 0x3C - Reserved, Caught by default */
    /* 0x3D - Reserved, Caught by default */
    /* 0x3E - Reserved, Caught by default */
    /* 0x3F - Reserved, Caught by default */
    case VEC_HWERR:
        info.si_code = BUS_ADRALN;
        sig = SIGBUS;
        switch (fp->seqstat & SEQSTAT_HWERRCAUSE) {
        /* System MMR Error */
        case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR):
            info.si_code = BUS_ADRALN;
            sig = SIGBUS;
            printk(KERN_NOTICE HWC_x2(KERN_NOTICE));
            break;
        /* External Memory Addressing Error */
        case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR):
            info.si_code = BUS_ADRERR;
            sig = SIGBUS;
            printk(KERN_NOTICE HWC_x3(KERN_NOTICE));
            break;
        /* Performance Monitor Overflow */
        case (SEQSTAT_HWERRCAUSE_PERF_FLOW):
            printk(KERN_NOTICE HWC_x12(KERN_NOTICE));
            break;
        /* RAISE 5 instruction */
        case (SEQSTAT_HWERRCAUSE_RAISE_5):
            printk(KERN_NOTICE HWC_x18(KERN_NOTICE));
            break;
        default:        /* Reserved */
            printk(KERN_NOTICE HWC_default(KERN_NOTICE));
            break;
        }
        CHK_DEBUGGER_TRAP();
        break;
    default:
        info.si_code = TRAP_ILLTRAP;
        sig = SIGTRAP;
        printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
               (fp->seqstat & SEQSTAT_EXCAUSE));
        CHK_DEBUGGER_TRAP();
        break;
    }

    BUG_ON(sig == 0);

    if (sig != SIGTRAP) {
        unsigned long *stack;
        dump_bfin_process(fp);
        dump_bfin_mem(fp);
        show_regs(fp);

        /* Print out the trace buffer if it makes sense */
#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
        if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M)
            printk(KERN_NOTICE "No trace since you do not have "
                   "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n"
                   KERN_NOTICE "\n");
        else
#endif
            dump_bfin_trace_buffer();

        if (oops_in_progress) {
            /* Dump the current kernel stack */
            printk(KERN_NOTICE "\n" KERN_NOTICE "Kernel Stack\n");
            show_stack(current, NULL);

            print_modules();
#ifndef CONFIG_ACCESS_CHECK
            printk(KERN_EMERG "Please turn on "
                   "CONFIG_ACCESS_CHECK\n");
#endif
            panic("Kernel exception");
        } else {
            /* Dump the user space stack */
            stack = (unsigned long *)rdusp();
            printk(KERN_NOTICE "Userspace Stack\n");
            show_stack(NULL, stack);
        }
    }

    info.si_signo = sig;
    info.si_errno = 0;
    info.si_addr = (void __user *)fp->pc;
    force_sig_info(sig, &info, current);

    trace_buffer_restore(j);
    return;
}
Ejemplo n.º 19
0
int main (int argc, char *argv[]) {
	char input_file[MAX_DIR] = MATRIX_DIR; 
	char input_index_file[MAX_DIR] = MATRIX_DIR; 
	char input_matrix_file[MAX_DIR] = MATRIX_DIR; 
	char input_matrix_name[MAX_DIR];
	char tmp_module_file[MAX_DIR] = MATRIX_DIR; 
	char final_module_file[MAX_DIR] = MATRIX_DIR; 
	char output_file[MAX_DIR] = MATRIX_DIR;
	char log_file[MAX_DIR] = MATRIX_DIR;
	char answer_file[MAX_DIR] = MATRIX_DIR;
	char prog[MAX_DIR]=BIN_DIR; 
	char mode, prog_option; 
	int i,j, k, l, num_edges, *pnum_edges, num_modules, *pnum_modules, num_answer_modules, *pnum_answer_modules; 
	ModulePtr modules, module, answer_modules, answer_module; 
	char tmp_file[MAX_DIR] = MATRIX_DIR; 
	double M, final_M; 
	int num_vertices, *pnum_vertices, num_lines; 
	int *degrees, total_edges; 
	int rand_num; 
	FILE *fp, *log; 
	time_t t_0, t_1, t, t_last;
	clock_t clo_0, clo_1, clo_last; 
	int elapTicks; 
	double elapMilli, elapSeconds, elapMinutes;  
	char answer_option; 
	double acc_0, acc_1; 
	double th1_up, th1_low, th2_up, th2_low; 
	char suffix[MAX_ATTR_NAME]; 
	char rand_graph_option; 

	if (argc < 3) { 
		fprintf(stderr, "Too few arguments!\n");
		fprintf(stderr, "Usage:\n");
		fprintf(stderr, "<Program Name> input_matrix (tab delimitted (string or index)) program_option (1: MSG.out; 2: SCNewman; 3: testQcut) answer_option (0: no answer; 1: answer) answer_file\n"); 
		exit(EXIT_FAILURE);
	}

	strcat(input_file, argv[1]); 
	strcpy (input_matrix_name, argv[1]); 
	prog_option = atoi(argv[2]); 
	answer_option = atoi(argv[3]); 
	if (answer_option) { 
		if (argc < 4) { 
			fprintf(stderr, "Missing answer file\n"); 
			fprintf(stderr, "Usage:\n");
			fprintf(stderr, "<Program Name> input_matrix (tab delimitted (string or index)) program_option (1: MSG.out; 2: SCNewman; 3: testQcut) answer_option (0: no answer; 1: answer) answer_file\n");
			exit(EXIT_FAILURE);
		}
		strcat(answer_file, argv[4]); 
	}

	strcat(input_index_file, argv[1]); 
	strcat(input_index_file, ".index"); 
	strcat(input_matrix_file, argv[1]); 
	strcat(input_matrix_file, ".matrix"); 

	strcat(output_file, argv[1]); 
	strcat(output_file, "_result_"); 
	strcat(log_file, argv[1]); 
	strcat(log_file, "_"); 

	strcat(final_module_file, argv[1]); 
	strcat(final_module_file, "_result_"); 

	if (prog_option == 1) { 
		strcat (prog, "MSG.out"); 
		strcat (input_matrix_name, "_MSG.out"); 
		strcat(final_module_file, "iNP_MSG"); 
		strcat(output_file, "MSG"); 
		strcat(log_file, "iNP_MSG.log"); 
	} else if (prog_option == 2) { 
		strcat (prog, "do_SCNewman"); 
		strcat (input_matrix_name, "_SCNewman");
		strcat(final_module_file, "iNP_SCNewman"); 
		strcat(output_file, "SCNewman"); 
		strcat(log_file, "iNP_SCNewman.log"); 
	} else if (prog_option == 3) { 
		strcat (prog, "qcut.pl");
		strcat (input_matrix_name, "_qcut"); 
		strcat(final_module_file, "iNP_Qcut"); 
		strcat(output_file, "Qcut"); 
		strcat(log_file, "iNP_Qcut.log"); 
	} else { 
		fprintf(stderr, "<Program Name> input_matrix (tab delimitted (string or index)) mode (0, 1, 2) program_option (1: MSG.out)\n"); 
		fprintf(stderr, "program_option currently allows only 1 - 3 (1: MSG, 2: SC, 3: Qcut)\n"); 
		exit(EXIT_FAILURE); 
	}
	if ((log = fopen(log_file, "w")) == NULL) {
		fprintf(stderr, "\nFailure to write file %s in read mode\n", log_file);
		fflush(NULL);
		return(-1);
	}

	num_vertices = 0; 
	pnum_vertices = &num_vertices;
	num_lines =	process_input(input_file, input_index_file, input_matrix_file, pnum_vertices); 
	degrees = (int *) calloc(num_vertices, sizeof(int))-1;
	total_edges = read_input_matrix(input_matrix_file, num_vertices, degrees); 

	num_modules = 0; 
	pnum_modules = &num_modules; 
	modules = (ModulePtr) malloc(num_vertices * sizeof(ModuleStr)) - 1; 

	time (&t_0); 
	M = partition_network(input_matrix_file, pnum_modules, modules, prog, prog_option); 
	time (&t_1); 

	if ((fp = fopen(output_file, "w")) == NULL) {
		fprintf(stderr, "\nFailure to write file %s in read mode\n", output_file);
		fflush(NULL);
		return(-1);
	}

/* print networks partitioned without iterations */ 
	for (i = 1; i <= num_modules; i ++) { 
		module = modules + i; 
		for (j = 1; j <= module->num_nodes; j ++) { 
			fprintf(fp, "%s\t", (vertices + module->nodes[j])->name); 
		}
		fprintf(fp, "\n");
	}
	fprintf(fp, "%f\n", M); 
	fclose (fp); 

	final_modules = (ModulePtr) malloc(num_vertices * sizeof(ModuleStr)) - 1; 
	num_final_modules = 0; 
	pnum_final_modules = &num_final_modules; 

	//printf ("%s %f\n", output_file, M); 
	rand_num = (int) rand(); 
	for (i = 1; i <= num_modules; i ++) { 
		module = modules + i; 
		iRun(module, num_vertices, prog, input_matrix_name, prog_option); 
	}
	if (num_final_modules) { 
		final_M = calculate_modularity(num_final_modules, final_modules, degrees, total_edges); 
		/* print networks partitioned with iterations */ 
		print_modules(final_module_file, final_M); 
	}
	time (&t_last); 

	fprintf (log, "NP\tnum_modules\t%d\tmodularity\t%f\ttime\t%f\t", num_modules, M, difftime(t_1, t_0)); 
	if (answer_option) { 
		acc_0 = jaccard(answer_file, output_file); 
		fprintf (log, "acc\t%f\n", acc_0); 
	} else { 
		fprintf (log, "\n"); 
	}
	fprintf (log, "iNP\tnum_modules\t%d\tmodularity\t%f\ttime\t%f\t", num_final_modules, final_M, difftime(t_last, t_0)); 
	if (answer_option) { 
		acc_1 = jaccard(answer_file, final_module_file); 
		fprintf (log, "acc\t%f\n", acc_1); 
	} else { 
		fprintf (log, "\n"); 
	}
	fclose (log); 
	
	remove(input_matrix_file); 
	remove(input_index_file); 

	return 0;
}
Ejemplo n.º 20
0
static int do_cli(int argc, char **argv) /* {{{ */
{
	int c;
	zend_file_handle file_handle;
	int behavior = PHP_MODE_STANDARD;
	char *reflection_what = NULL;
	volatile int request_started = 0;
	volatile int exit_status = 0;
	char *php_optarg = NULL, *orig_optarg = NULL;
	int php_optind = 1, orig_optind = 1;
	char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
	char *arg_free=NULL, **arg_excp=&arg_free;
	char *script_file=NULL, *translated_path = NULL;
	int interactive=0;
	int lineno = 0;
	const char *param_error=NULL;
	int hide_argv = 0;

	zend_try {

		CG(in_compilation) = 0; /* not initialized but needed for several options */

		while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
			switch (c) {

			case 'i': /* php info & quit */
				if (php_request_startup()==FAILURE) {
					goto err;
				}
				request_started = 1;
				php_print_info(0xFFFFFFFF);
				php_output_end_all();
				exit_status = (c == '?' && argc > 1 && !strchr(argv[1],  c));
				goto out;

			case 'v': /* show php version & quit */
				php_printf("PHP %s (%s) (built: %s %s) ( %s)\nCopyright (c) 1997-2016 The PHP Group\n%s",
					PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__,
#if ZTS
					"ZTS "
#else
					"NTS "
#endif
#if ZEND_DEBUG
					"DEBUG "
#endif
#ifdef HAVE_GCOV
					"GCOV "
#endif
					,
					get_zend_version()
				);
				sapi_deactivate();
				goto out;

			case 'm': /* list compiled in modules */
				if (php_request_startup()==FAILURE) {
					goto err;
				}
				request_started = 1;
				php_printf("[PHP Modules]\n");
				print_modules();
				php_printf("\n[Zend Modules]\n");
				print_extensions();
				php_printf("\n");
				php_output_end_all();
				exit_status=0;
				goto out;

			default:
				break;
			}
		}

		/* Set some CLI defaults */
		SG(options) |= SAPI_OPTION_NO_CHDIR;

		php_optind = orig_optind;
		php_optarg = orig_optarg;
		while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) {
			switch (c) {

			case 'a':	/* interactive mode */
				if (!interactive) {
					if (behavior != PHP_MODE_STANDARD) {
						param_error = param_mode_conflict;
						break;
					}

					interactive=1;
				}
				break;

			case 'C': /* don't chdir to the script directory */
				/* This is default so NOP */
				break;

			case 'F':
				if (behavior == PHP_MODE_PROCESS_STDIN) {
					if (exec_run || script_file) {
						param_error = "You can use -R or -F only once.\n";
						break;
					}
				} else if (behavior != PHP_MODE_STANDARD) {
					param_error = param_mode_conflict;
					break;
				}
				behavior=PHP_MODE_PROCESS_STDIN;
				script_file = php_optarg;
				break;

			case 'f': /* parse file */
				if (behavior == PHP_MODE_CLI_DIRECT || behavior == PHP_MODE_PROCESS_STDIN) {
					param_error = param_mode_conflict;
					break;
				} else if (script_file) {
					param_error = "You can use -f only once.\n";
					break;
				}
				script_file = php_optarg;
				break;

			case 'l': /* syntax check mode */
				if (behavior != PHP_MODE_STANDARD) {
					break;
				}
				behavior=PHP_MODE_LINT;
				break;

			case 'q': /* do not generate HTTP headers */
				/* This is default so NOP */
				break;

			case 'r': /* run code from command line */
				if (behavior == PHP_MODE_CLI_DIRECT) {
					if (exec_direct || script_file) {
						param_error = "You can use -r only once.\n";
						break;
					}
				} else if (behavior != PHP_MODE_STANDARD || interactive) {
					param_error = param_mode_conflict;
					break;
				}
				behavior=PHP_MODE_CLI_DIRECT;
				exec_direct=php_optarg;
				break;

			case 'R':
				if (behavior == PHP_MODE_PROCESS_STDIN) {
					if (exec_run || script_file) {
						param_error = "You can use -R or -F only once.\n";
						break;
					}
				} else if (behavior != PHP_MODE_STANDARD) {
					param_error = param_mode_conflict;
					break;
				}
				behavior=PHP_MODE_PROCESS_STDIN;
				exec_run=php_optarg;
				break;

			case 'B':
				if (behavior == PHP_MODE_PROCESS_STDIN) {
					if (exec_begin) {
						param_error = "You can use -B only once.\n";
						break;
					}
				} else if (behavior != PHP_MODE_STANDARD || interactive) {
					param_error = param_mode_conflict;
					break;
				}
				behavior=PHP_MODE_PROCESS_STDIN;
				exec_begin=php_optarg;
				break;

			case 'E':
				if (behavior == PHP_MODE_PROCESS_STDIN) {
					if (exec_end) {
						param_error = "You can use -E only once.\n";
						break;
					}
				} else if (behavior != PHP_MODE_STANDARD || interactive) {
					param_error = param_mode_conflict;
					break;
				}
				behavior=PHP_MODE_PROCESS_STDIN;
				exec_end=php_optarg;
				break;

			case 's': /* generate highlighted HTML from source */
				if (behavior == PHP_MODE_CLI_DIRECT || behavior == PHP_MODE_PROCESS_STDIN) {
					param_error = "Source highlighting only works for files.\n";
					break;
				}
				behavior=PHP_MODE_HIGHLIGHT;
				break;

			case 'w':
				if (behavior == PHP_MODE_CLI_DIRECT || behavior == PHP_MODE_PROCESS_STDIN) {
					param_error = "Source stripping only works for files.\n";
					break;
				}
				behavior=PHP_MODE_STRIP;
				break;

			case 'z': /* load extension file */
				zend_load_extension(php_optarg);
				break;
			case 'H':
				hide_argv = 1;
				break;
			case 10:
				behavior=PHP_MODE_REFLECTION_FUNCTION;
				reflection_what = php_optarg;
				break;
			case 11:
				behavior=PHP_MODE_REFLECTION_CLASS;
				reflection_what = php_optarg;
				break;
			case 12:
				behavior=PHP_MODE_REFLECTION_EXTENSION;
				reflection_what = php_optarg;
				break;
			case 13:
				behavior=PHP_MODE_REFLECTION_ZEND_EXTENSION;
				reflection_what = php_optarg;
				break;
			case 14:
				behavior=PHP_MODE_REFLECTION_EXT_INFO;
				reflection_what = php_optarg;
				break;
			case 15:
				behavior = PHP_MODE_SHOW_INI_CONFIG;
				break;
			default:
				break;
			}
		}

		if (param_error) {
			PUTS(param_error);
			exit_status=1;
			goto err;
		}

		if (interactive) {
#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
			printf("Interactive shell\n\n");
#else
			printf("Interactive mode enabled\n\n");
#endif
			fflush(stdout);
		}

		/* only set script_file if not set already and not in direct mode and not at end of parameter list */
		if (argc > php_optind
		  && !script_file
		  && behavior!=PHP_MODE_CLI_DIRECT
		  && behavior!=PHP_MODE_PROCESS_STDIN
		  && strcmp(argv[php_optind-1],"--"))
		{
			script_file=argv[php_optind];
			php_optind++;
		}
		if (script_file) {
			if (cli_seek_file_begin(&file_handle, script_file, &lineno) != SUCCESS) {
				goto err;
			} else {
				char real_path[MAXPATHLEN];
				if (VCWD_REALPATH(script_file, real_path)) {
					translated_path = strdup(real_path);
				}
				script_filename = script_file;
			}
		} else {
			/* We could handle PHP_MODE_PROCESS_STDIN in a different manner  */
			/* here but this would make things only more complicated. And it */
			/* is consitent with the way -R works where the stdin file handle*/
			/* is also accessible. */
			file_handle.filename = "-";
			file_handle.handle.fp = stdin;
		}
		file_handle.type = ZEND_HANDLE_FP;
		file_handle.opened_path = NULL;
		file_handle.free_filename = 0;
		php_self = (char*)file_handle.filename;

		/* before registering argv to module exchange the *new* argv[0] */
		/* we can achieve this without allocating more memory */
		SG(request_info).argc=argc-php_optind+1;
		arg_excp = argv+php_optind-1;
		arg_free = argv[php_optind-1];
		SG(request_info).path_translated = translated_path? translated_path: (char*)file_handle.filename;
		argv[php_optind-1] = (char*)file_handle.filename;
		SG(request_info).argv=argv+php_optind-1;

		if (php_request_startup()==FAILURE) {
			*arg_excp = arg_free;
			fclose(file_handle.handle.fp);
			PUTS("Could not startup.\n");
			goto err;
		}
		request_started = 1;
		CG(start_lineno) = lineno;
		*arg_excp = arg_free; /* reconstuct argv */

		if (hide_argv) {
			int i;
			for (i = 1; i < argc; i++) {
				memset(argv[i], 0, strlen(argv[i]));
			}
		}

		zend_is_auto_global_str(ZEND_STRL("_SERVER"));

		PG(during_request_startup) = 0;
		switch (behavior) {
		case PHP_MODE_STANDARD:
			if (strcmp(file_handle.filename, "-")) {
				cli_register_file_handles();
			}

			if (interactive && cli_shell_callbacks.cli_shell_run) {
				exit_status = cli_shell_callbacks.cli_shell_run();
			} else {
				php_execute_script(&file_handle);
				exit_status = EG(exit_status);
			}
			break;
		case PHP_MODE_LINT:
			exit_status = php_lint_script(&file_handle);
			if (exit_status==SUCCESS) {
				zend_printf("No syntax errors detected in %s\n", file_handle.filename);
			} else {
				zend_printf("Errors parsing %s\n", file_handle.filename);
			}
			break;
		case PHP_MODE_STRIP:
			if (open_file_for_scanning(&file_handle)==SUCCESS) {
				zend_strip();
			}
			goto out;
			break;
		case PHP_MODE_HIGHLIGHT:
			{
				zend_syntax_highlighter_ini syntax_highlighter_ini;

				if (open_file_for_scanning(&file_handle)==SUCCESS) {
					php_get_highlight_struct(&syntax_highlighter_ini);
					zend_highlight(&syntax_highlighter_ini);
				}
				goto out;
			}
			break;
		case PHP_MODE_CLI_DIRECT:
			cli_register_file_handles();
			if (zend_eval_string_ex(exec_direct, NULL, "Command line code", 1) == FAILURE) {
				exit_status=254;
			}
			break;

		case PHP_MODE_PROCESS_STDIN:
			{
				char *input;
				size_t len, index = 0;
				zval argn, argi;

				cli_register_file_handles();

				if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1) == FAILURE) {
					exit_status=254;
				}
				while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) {
					len = strlen(input);
					while (len > 0 && len-- && (input[len]=='\n' || input[len]=='\r')) {
						input[len] = '\0';
					}
					ZVAL_STRINGL(&argn, input, len + 1);
					zend_hash_str_update(&EG(symbol_table), "argn", sizeof("argn")-1, &argn);
					ZVAL_LONG(&argi, ++index);
					zend_hash_str_update(&EG(symbol_table), "argi", sizeof("argi")-1, &argi);
					if (exec_run) {
						if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1) == FAILURE) {
							exit_status=254;
						}
					} else {
						if (script_file) {
							if (cli_seek_file_begin(&file_handle, script_file, &lineno) != SUCCESS) {
								exit_status = 1;
							} else {
								CG(start_lineno) = lineno;
								php_execute_script(&file_handle);
								exit_status = EG(exit_status);
							}
						}
					}
					efree(input);
				}
				if (exec_end && zend_eval_string_ex(exec_end, NULL, "Command line end code", 1) == FAILURE) {
					exit_status=254;
				}

				break;
			}

			case PHP_MODE_REFLECTION_FUNCTION:
			case PHP_MODE_REFLECTION_CLASS:
			case PHP_MODE_REFLECTION_EXTENSION:
			case PHP_MODE_REFLECTION_ZEND_EXTENSION:
				{
					zend_class_entry *pce = NULL;
					zval arg, ref;
					zend_execute_data execute_data;

					switch (behavior) {
						default:
							break;
						case PHP_MODE_REFLECTION_FUNCTION:
							if (strstr(reflection_what, "::")) {
								pce = reflection_method_ptr;
							} else {
								pce = reflection_function_ptr;
							}
							break;
						case PHP_MODE_REFLECTION_CLASS:
							pce = reflection_class_ptr;
							break;
						case PHP_MODE_REFLECTION_EXTENSION:
							pce = reflection_extension_ptr;
							break;
						case PHP_MODE_REFLECTION_ZEND_EXTENSION:
							pce = reflection_zend_extension_ptr;
							break;
					}

					ZVAL_STRING(&arg, reflection_what);
					object_init_ex(&ref, pce);

					memset(&execute_data, 0, sizeof(zend_execute_data));
					EG(current_execute_data) = &execute_data;
					zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg);

					if (EG(exception)) {
						zval tmp, *msg, rv;

						ZVAL_OBJ(&tmp, EG(exception));
						msg = zend_read_property(zend_ce_exception, &tmp, "message", sizeof("message")-1, 0, &rv);
						zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
						zval_ptr_dtor(&tmp);
						EG(exception) = NULL;
					} else {
						zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref);
					}
					zval_ptr_dtor(&ref);
					zval_ptr_dtor(&arg);

					break;
				}
			case PHP_MODE_REFLECTION_EXT_INFO:
				{
					int len = (int)strlen(reflection_what);
					char *lcname = zend_str_tolower_dup(reflection_what, len);
					zend_module_entry *module;

					if ((module = zend_hash_str_find_ptr(&module_registry, lcname, len)) == NULL) {
						if (!strcmp(reflection_what, "main")) {
							display_ini_entries(NULL);
						} else {
							zend_printf("Extension '%s' not present.\n", reflection_what);
							exit_status = 1;
						}
					} else {
						php_info_print_module(module);
					}

					efree(lcname);
					break;
				}

			case PHP_MODE_SHOW_INI_CONFIG:
				{
					zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH);
					zend_printf("Loaded Configuration File:         %s\n", php_ini_opened_path ? php_ini_opened_path : "(none)");
					zend_printf("Scan for additional .ini files in: %s\n", php_ini_scanned_path  ? php_ini_scanned_path : "(none)");
					zend_printf("Additional .ini files parsed:      %s\n", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
					break;
				}
		}
	} zend_end_try();

out:
	if (request_started) {
		php_request_shutdown((void *) 0);
	}
	if (translated_path) {
		free(translated_path);
	}
	if (exit_status == 0) {
		exit_status = EG(exit_status);
	}
	return exit_status;
err:
	sapi_deactivate();
	zend_ini_deactivate();
	exit_status = 1;
	goto out;
}
Ejemplo n.º 21
0
/* watchdog kicker functions */
static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
{
	unsigned long touch_ts = __this_cpu_read(watchdog_touch_ts);
	struct pt_regs *regs = get_irq_regs();
	int duration;

	/* kick the hardlockup detector */
	watchdog_interrupt_count();

	/* kick the softlockup detector */
	wake_up_process(__this_cpu_read(softlockup_watchdog));

	/* .. and repeat */
	hrtimer_forward_now(hrtimer, ns_to_ktime(get_sample_period()));

	if (touch_ts == 0) {
		if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
			/*
			 * If the time stamp was touched atomically
			 * make sure the scheduler tick is up to date.
			 */
			__this_cpu_write(softlockup_touch_sync, false);
			sched_clock_tick();
		}

		/* Clear the guest paused flag on watchdog reset */
		kvm_check_and_clear_guest_paused();
		__touch_watchdog();
		return HRTIMER_RESTART;
	}

	/* check for a softlockup
	 * This is done by making sure a high priority task is
	 * being scheduled.  The task touches the watchdog to
	 * indicate it is getting cpu time.  If it hasn't then
	 * this is a good indication some task is hogging the cpu
	 */
	duration = is_softlockup(touch_ts);
	if (unlikely(duration)) {
		/*
		 * If a virtual machine is stopped by the host it can look to
		 * the watchdog like a soft lockup, check to see if the host
		 * stopped the vm before we issue the warning
		 */
		if (kvm_check_and_clear_guest_paused())
			return HRTIMER_RESTART;

		/* only warn once */
		if (__this_cpu_read(soft_watchdog_warn) == true)
			return HRTIMER_RESTART;

		printk(KERN_EMERG "BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
			smp_processor_id(), duration,
			current->comm, task_pid_nr(current));
		print_modules();
		print_irqtrace_events(current);
		if (regs)
			show_regs(regs);
		else
			dump_stack();

		if (softlockup_panic)
			panic("softlockup: hung tasks");
		__this_cpu_write(soft_watchdog_warn, true);
	} else
		__this_cpu_write(soft_watchdog_warn, false);

	return HRTIMER_RESTART;
}
Ejemplo n.º 22
0
asmlinkage notrace void trap_c(struct pt_regs *fp)
{
#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
	int j;
#endif
#ifdef CONFIG_BFIN_PSEUDODBG_INSNS
	int opcode;
#endif
	unsigned int cpu = raw_smp_processor_id();
	const char *strerror = NULL;
	int sig = 0;
	siginfo_t info;
	unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;

	trace_buffer_save(j);
#if defined(CONFIG_DEBUG_MMRS) || defined(CONFIG_DEBUG_MMRS_MODULE)
	last_seqstat = (u32)fp->seqstat;
#endif


	fp->orig_pc = fp->retx;

	
	switch (trapnr) {


	
	
	case VEC_EXCPT01:
		info.si_code = TRAP_ILLTRAP;
		sig = SIGTRAP;
		CHK_DEBUGGER_TRAP_MAYBE();
		
		if (kernel_mode_regs(fp))
			goto traps_done;
		else
			break;
	
	case VEC_EXCPT03:
		info.si_code = SEGV_STACKFLOW;
		sig = SIGSEGV;
		strerror = KERN_NOTICE EXC_0x03(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_EXCPT02:
#ifdef CONFIG_KGDB
		info.si_code = TRAP_ILLTRAP;
		sig = SIGTRAP;
		CHK_DEBUGGER_TRAP();
		goto traps_done;
#endif
	
	
	
	
	
	
	
	
	
	
	
	
	case VEC_EXCPT04 ... VEC_EXCPT15:
		info.si_code = ILL_ILLPARAOP;
		sig = SIGILL;
		strerror = KERN_NOTICE EXC_0x04(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_STEP:
		info.si_code = TRAP_STEP;
		sig = SIGTRAP;
		CHK_DEBUGGER_TRAP_MAYBE();
		
		if (kernel_mode_regs(fp))
			goto traps_done;
		else
			break;
	
	case VEC_OVFLOW:
		info.si_code = TRAP_TRACEFLOW;
		sig = SIGTRAP;
		strerror = KERN_NOTICE EXC_0x11(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	case VEC_UNDEF_I:
#ifdef CONFIG_BUG
		if (kernel_mode_regs(fp)) {
			switch (report_bug(fp->pc, fp)) {
			case BUG_TRAP_TYPE_NONE:
				break;
			case BUG_TRAP_TYPE_WARN:
				dump_bfin_trace_buffer();
				fp->pc += 2;
				goto traps_done;
			case BUG_TRAP_TYPE_BUG:
				panic("BUG()");
			}
		}
#endif
#ifdef CONFIG_BFIN_PSEUDODBG_INSNS
		if (!kernel_mode_regs(fp) && get_instruction(&opcode, (unsigned short *)fp->pc)) {
			if (execute_pseudodbg_assert(fp, opcode))
				goto traps_done;
			if (execute_pseudodbg(fp, opcode))
				goto traps_done;
		}
#endif
		info.si_code = ILL_ILLOPC;
		sig = SIGILL;
		strerror = KERN_NOTICE EXC_0x21(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_ILGAL_I:
		info.si_code = ILL_ILLPARAOP;
		sig = SIGILL;
		strerror = KERN_NOTICE EXC_0x22(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_CPLB_VL:
		info.si_code = ILL_CPLB_VI;
		sig = SIGSEGV;
		strerror = KERN_NOTICE EXC_0x23(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_MISALI_D:
		info.si_code = BUS_ADRALN;
		sig = SIGBUS;
		strerror = KERN_NOTICE EXC_0x24(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_UNCOV:
		info.si_code = ILL_ILLEXCPT;
		sig = SIGILL;
		strerror = KERN_NOTICE EXC_0x25(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	case VEC_CPLB_M:
		info.si_code = BUS_ADRALN;
		sig = SIGBUS;
		strerror = KERN_NOTICE EXC_0x26(KERN_NOTICE);
		break;
	
	case VEC_CPLB_MHIT:
		info.si_code = ILL_CPLB_MULHIT;
		sig = SIGSEGV;
#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
		if (cpu_pda[cpu].dcplb_fault_addr < FIXED_CODE_START)
			strerror = KERN_NOTICE "NULL pointer access\n";
		else
#endif
			strerror = KERN_NOTICE EXC_0x27(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_WATCH:
		info.si_code = TRAP_WATCHPT;
		sig = SIGTRAP;
		pr_debug(EXC_0x28(KERN_DEBUG));
		CHK_DEBUGGER_TRAP_MAYBE();
		
		if (kernel_mode_regs(fp))
			goto traps_done;
		else
			break;
#ifdef CONFIG_BF535
	
	case VEC_ISTRU_VL:      
		info.si_code = BUS_OPFETCH;
		sig = SIGBUS;
		strerror = KERN_NOTICE "BF535: VEC_ISTRU_VL\n";
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
#else
	
#endif
	
	case VEC_MISALI_I:
		info.si_code = BUS_ADRALN;
		sig = SIGBUS;
		strerror = KERN_NOTICE EXC_0x2A(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_CPLB_I_VL:
		info.si_code = ILL_CPLB_VI;
		sig = SIGBUS;
		strerror = KERN_NOTICE EXC_0x2B(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_CPLB_I_M:
		info.si_code = ILL_CPLB_MISS;
		sig = SIGBUS;
		strerror = KERN_NOTICE EXC_0x2C(KERN_NOTICE);
		break;
	
	case VEC_CPLB_I_MHIT:
		info.si_code = ILL_CPLB_MULHIT;
		sig = SIGSEGV;
#ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
		if (cpu_pda[cpu].icplb_fault_addr < FIXED_CODE_START)
			strerror = KERN_NOTICE "Jump to NULL address\n";
		else
#endif
			strerror = KERN_NOTICE EXC_0x2D(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	case VEC_ILL_RES:
		info.si_code = ILL_PRVOPC;
		sig = SIGILL;
		strerror = KERN_NOTICE EXC_0x2E(KERN_NOTICE);
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	case VEC_HWERR:
		info.si_code = BUS_ADRALN;
		sig = SIGBUS;
		switch (fp->seqstat & SEQSTAT_HWERRCAUSE) {
		
		case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR):
			info.si_code = BUS_ADRALN;
			sig = SIGBUS;
			strerror = KERN_NOTICE HWC_x2(KERN_NOTICE);
			break;
		
		case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR):
			if (ANOMALY_05000310) {
				static unsigned long anomaly_rets;

				if ((fp->pc >= (L1_CODE_START + L1_CODE_LENGTH - 512)) &&
				    (fp->pc < (L1_CODE_START + L1_CODE_LENGTH))) {
					anomaly_rets = fp->rets;
					goto traps_done;
				} else if (fp->rets == anomaly_rets) {
					goto traps_done;
				} else if ((fp->rets >= (L1_CODE_START + L1_CODE_LENGTH - 512)) &&
				           (fp->rets < (L1_CODE_START + L1_CODE_LENGTH))) {
					goto traps_done;
				} else
					anomaly_rets = 0;
			}

			info.si_code = BUS_ADRERR;
			sig = SIGBUS;
			strerror = KERN_NOTICE HWC_x3(KERN_NOTICE);
			break;
		
		case (SEQSTAT_HWERRCAUSE_PERF_FLOW):
			strerror = KERN_NOTICE HWC_x12(KERN_NOTICE);
			break;
		
		case (SEQSTAT_HWERRCAUSE_RAISE_5):
			printk(KERN_NOTICE HWC_x18(KERN_NOTICE));
			break;
		default:        
			printk(KERN_NOTICE HWC_default(KERN_NOTICE));
			break;
		}
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	default:
		info.si_code = ILL_ILLPARAOP;
		sig = SIGILL;
		verbose_printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
			(fp->seqstat & SEQSTAT_EXCAUSE));
		CHK_DEBUGGER_TRAP_MAYBE();
		break;
	}

	BUG_ON(sig == 0);

	if (kernel_mode_regs(fp) || (current && !current->mm)) {
		console_verbose();
		oops_in_progress = 1;
	}

	if (sig != SIGTRAP) {
		if (strerror)
			verbose_printk(strerror);

		dump_bfin_process(fp);
		dump_bfin_mem(fp);
		show_regs(fp);

		
#ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
		if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M)
			verbose_printk(KERN_NOTICE "No trace since you do not have "
			       "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n\n");
		else
#endif
			dump_bfin_trace_buffer();

		if (oops_in_progress) {
			
			verbose_printk(KERN_NOTICE "Kernel Stack\n");
			show_stack(current, NULL);
			print_modules();
#ifndef CONFIG_ACCESS_CHECK
			verbose_printk(KERN_EMERG "Please turn on "
			       "CONFIG_ACCESS_CHECK\n");
#endif
			panic("Kernel exception");
		} else {
#ifdef CONFIG_DEBUG_VERBOSE
			unsigned long *stack;
			
			stack = (unsigned long *)rdusp();
			verbose_printk(KERN_NOTICE "Userspace Stack\n");
			show_stack(NULL, stack);
#endif
		}
	}

#ifdef CONFIG_IPIPE
	if (!ipipe_trap_notify(fp->seqstat & 0x3f, fp))
#endif
	{
		info.si_signo = sig;
		info.si_errno = 0;
		switch (trapnr) {
		case VEC_CPLB_VL:
		case VEC_MISALI_D:
		case VEC_CPLB_M:
		case VEC_CPLB_MHIT:
			info.si_addr = (void __user *)cpu_pda[cpu].dcplb_fault_addr;
			break;
		default:
			info.si_addr = (void __user *)fp->pc;
			break;
		}
		force_sig_info(sig, &info, current);
	}

	if ((ANOMALY_05000461 && trapnr == VEC_HWERR && !access_ok(VERIFY_READ, fp->pc, 8)) ||
	    (ANOMALY_05000281 && trapnr == VEC_HWERR) ||
	    (ANOMALY_05000189 && (trapnr == VEC_CPLB_I_VL || trapnr == VEC_CPLB_VL)))
		fp->pc = SAFE_USER_INSTRUCTION;

 traps_done:
	trace_buffer_restore(j);
}
Ejemplo n.º 23
0
static uint32_t sys_list_module(uint32_t arg[])
{
	print_modules();
	return 0;
}
Ejemplo n.º 24
0
/* watchdog kicker functions */
static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
{
	unsigned long touch_ts = __this_cpu_read(watchdog_touch_ts);
	struct pt_regs *regs = get_irq_regs();
	int duration;
	int softlockup_all_cpu_backtrace = sysctl_softlockup_all_cpu_backtrace;

	if (!watchdog_enabled)
		return HRTIMER_NORESTART;

	/* kick the hardlockup detector */
	watchdog_interrupt_count();

	/* kick the softlockup detector */
	wake_up_process(__this_cpu_read(softlockup_watchdog));

	/* .. and repeat */
	hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));

	if (touch_ts == 0) {
		if (unlikely(__this_cpu_read(softlockup_touch_sync))) {
			/*
			 * If the time stamp was touched atomically
			 * make sure the scheduler tick is up to date.
			 */
			__this_cpu_write(softlockup_touch_sync, false);
			sched_clock_tick();
		}

		/* Clear the guest paused flag on watchdog reset */
		kvm_check_and_clear_guest_paused();
		__touch_watchdog();
		return HRTIMER_RESTART;
	}

	/* check for a softlockup
	 * This is done by making sure a high priority task is
	 * being scheduled.  The task touches the watchdog to
	 * indicate it is getting cpu time.  If it hasn't then
	 * this is a good indication some task is hogging the cpu
	 */
	duration = is_softlockup(touch_ts);
	if (unlikely(duration)) {
		/*
		 * If a virtual machine is stopped by the host it can look to
		 * the watchdog like a soft lockup, check to see if the host
		 * stopped the vm before we issue the warning
		 */
		if (kvm_check_and_clear_guest_paused())
			return HRTIMER_RESTART;

		/* only warn once */
		if (__this_cpu_read(soft_watchdog_warn) == true) {
			/*
			 * When multiple processes are causing softlockups the
			 * softlockup detector only warns on the first one
			 * because the code relies on a full quiet cycle to
			 * re-arm.  The second process prevents the quiet cycle
			 * and never gets reported.  Use task pointers to detect
			 * this.
			 */
			if (__this_cpu_read(softlockup_task_ptr_saved) !=
			    current) {
				__this_cpu_write(soft_watchdog_warn, false);
				__touch_watchdog();
			}
			return HRTIMER_RESTART;
		}

		if (softlockup_all_cpu_backtrace) {
			/* Prevent multiple soft-lockup reports if one cpu is already
			 * engaged in dumping cpu back traces
			 */
			if (test_and_set_bit(0, &soft_lockup_nmi_warn)) {
				/* Someone else will report us. Let's give up */
				__this_cpu_write(soft_watchdog_warn, true);
				return HRTIMER_RESTART;
			}
		}

		pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
			smp_processor_id(), duration,
			current->comm, task_pid_nr(current));
		__this_cpu_write(softlockup_task_ptr_saved, current);
		print_modules();
		print_irqtrace_events(current);
		if (regs)
			show_regs(regs);
		else
			dump_stack();

		if (softlockup_all_cpu_backtrace) {
			/* Avoid generating two back traces for current
			 * given that one is already made above
			 */
			trigger_allbutself_cpu_backtrace();

			clear_bit(0, &soft_lockup_nmi_warn);
			/* Barrier to sync with other cpus */
			smp_mb__after_atomic();
		}

		add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
		if (softlockup_panic)
			panic("softlockup: hung tasks");
		__this_cpu_write(soft_watchdog_warn, true);
	} else
		__this_cpu_write(soft_watchdog_warn, false);

	return HRTIMER_RESTART;
}