|  | @@ -130,3 +130,142 @@ dik_show_trace(unsigned long *sp)
 | 
	
		
			
				|  |  |  		sp++;
 | 
	
		
			
				|  |  |  		if (tmp < (unsigned long) &_stext)
 | 
	
		
			
				|  |  |  			continue;
 | 
	
		
			
				|  |  | +		if (tmp >= (unsigned long) &_etext)
 | 
	
		
			
				|  |  | +			continue;
 | 
	
		
			
				|  |  | +		printk("[<%lx>]", tmp);
 | 
	
		
			
				|  |  | +		print_symbol(" %s", tmp);
 | 
	
		
			
				|  |  | +		printk("\n");
 | 
	
		
			
				|  |  | +		if (i > 40) {
 | 
	
		
			
				|  |  | +			printk(" ...");
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	printk("\n");
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +static int kstack_depth_to_print = 24;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +void show_stack(struct task_struct *task, unsigned long *sp)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	unsigned long *stack;
 | 
	
		
			
				|  |  | +	int i;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/*
 | 
	
		
			
				|  |  | +	 * debugging aid: "show_stack(NULL);" prints the
 | 
	
		
			
				|  |  | +	 * back trace for this cpu.
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	if(sp==NULL)
 | 
	
		
			
				|  |  | +		sp=(unsigned long*)&sp;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	stack = sp;
 | 
	
		
			
				|  |  | +	for(i=0; i < kstack_depth_to_print; i++) {
 | 
	
		
			
				|  |  | +		if (((long) stack & (THREAD_SIZE-1)) == 0)
 | 
	
		
			
				|  |  | +			break;
 | 
	
		
			
				|  |  | +		if (i && ((i % 4) == 0))
 | 
	
		
			
				|  |  | +			printk("\n       ");
 | 
	
		
			
				|  |  | +		printk("%016lx ", *stack++);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	printk("\n");
 | 
	
		
			
				|  |  | +	dik_show_trace(sp);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +void dump_stack(void)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	show_stack(NULL, NULL);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +EXPORT_SYMBOL(dump_stack);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +void
 | 
	
		
			
				|  |  | +die_if_kernel(char * str, struct pt_regs *regs, long err, unsigned long *r9_15)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	if (regs->ps & 8)
 | 
	
		
			
				|  |  | +		return;
 | 
	
		
			
				|  |  | +#ifdef CONFIG_SMP
 | 
	
		
			
				|  |  | +	printk("CPU %d ", hard_smp_processor_id());
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +	printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
 | 
	
		
			
				|  |  | +	dik_show_regs(regs, r9_15);
 | 
	
		
			
				|  |  | +	add_taint(TAINT_DIE);
 | 
	
		
			
				|  |  | +	dik_show_trace((unsigned long *)(regs+1));
 | 
	
		
			
				|  |  | +	dik_show_code((unsigned int *)regs->pc);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
 | 
	
		
			
				|  |  | +		printk("die_if_kernel recursion detected.\n");
 | 
	
		
			
				|  |  | +		local_irq_enable();
 | 
	
		
			
				|  |  | +		while (1);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	do_exit(SIGSEGV);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#ifndef CONFIG_MATHEMU
 | 
	
		
			
				|  |  | +static long dummy_emul(void) { return 0; }
 | 
	
		
			
				|  |  | +long (*alpha_fp_emul_imprecise)(struct pt_regs *regs, unsigned long writemask)
 | 
	
		
			
				|  |  | +  = (void *)dummy_emul;
 | 
	
		
			
				|  |  | +long (*alpha_fp_emul) (unsigned long pc)
 | 
	
		
			
				|  |  | +  = (void *)dummy_emul;
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +long alpha_fp_emul_imprecise(struct pt_regs *regs, unsigned long writemask);
 | 
	
		
			
				|  |  | +long alpha_fp_emul (unsigned long pc);
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +asmlinkage void
 | 
	
		
			
				|  |  | +do_entArith(unsigned long summary, unsigned long write_mask,
 | 
	
		
			
				|  |  | +	    struct pt_regs *regs)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	long si_code = FPE_FLTINV;
 | 
	
		
			
				|  |  | +	siginfo_t info;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if (summary & 1) {
 | 
	
		
			
				|  |  | +		/* Software-completion summary bit is set, so try to
 | 
	
		
			
				|  |  | +		   emulate the instruction.  If the processor supports
 | 
	
		
			
				|  |  | +		   precise exceptions, we don't have to search.  */
 | 
	
		
			
				|  |  | +		if (!amask(AMASK_PRECISE_TRAP))
 | 
	
		
			
				|  |  | +			si_code = alpha_fp_emul(regs->pc - 4);
 | 
	
		
			
				|  |  | +		else
 | 
	
		
			
				|  |  | +			si_code = alpha_fp_emul_imprecise(regs, write_mask);
 | 
	
		
			
				|  |  | +		if (si_code == 0)
 | 
	
		
			
				|  |  | +			return;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	die_if_kernel("Arithmetic fault", regs, 0, NULL);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	info.si_signo = SIGFPE;
 | 
	
		
			
				|  |  | +	info.si_errno = 0;
 | 
	
		
			
				|  |  | +	info.si_code = si_code;
 | 
	
		
			
				|  |  | +	info.si_addr = (void __user *) regs->pc;
 | 
	
		
			
				|  |  | +	send_sig_info(SIGFPE, &info, current);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +asmlinkage void
 | 
	
		
			
				|  |  | +do_entIF(unsigned long type, struct pt_regs *regs)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	siginfo_t info;
 | 
	
		
			
				|  |  | +	int signo, code;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	if ((regs->ps & ~IPL_MAX) == 0) {
 | 
	
		
			
				|  |  | +		if (type == 1) {
 | 
	
		
			
				|  |  | +			const unsigned int *data
 | 
	
		
			
				|  |  | +			  = (const unsigned int *) regs->pc;
 | 
	
		
			
				|  |  | +			printk("Kernel bug at %s:%d\n",
 | 
	
		
			
				|  |  | +			       (const char *)(data[1] | (long)data[2] << 32), 
 | 
	
		
			
				|  |  | +			       data[0]);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		die_if_kernel((type == 1 ? "Kernel Bug" : "Instruction fault"),
 | 
	
		
			
				|  |  | +			      regs, type, NULL);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	switch (type) {
 | 
	
		
			
				|  |  | +	      case 0: /* breakpoint */
 | 
	
		
			
				|  |  | +		info.si_signo = SIGTRAP;
 | 
	
		
			
				|  |  | +		info.si_errno = 0;
 | 
	
		
			
				|  |  | +		info.si_code = TRAP_BRKPT;
 | 
	
		
			
				|  |  | +		info.si_trapno = 0;
 | 
	
		
			
				|  |  | +		info.si_addr = (void __user *) regs->pc;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (ptrace_cancel_bpt(current)) {
 | 
	
		
			
				|  |  | +			regs->pc -= 4;	/* make pc point to former bpt */
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		send_sig_info(SIGTRAP, &info, current);
 | 
	
		
			
				|  |  | +		return;
 | 
	
		
			
				|  |  | +
 |