[PATCH] kdb dmesg output broken after log_buf changes

Olaf Hering olh at suse.de
Fri Jan 30 21:33:26 EST 2004


 On Fri, Jan 30, Anton Blanchard wrote:

>
> > Like this? Or update to 4.3? Oh yes. :)
>
> Cool. Considering my lack of kdb knowledge I'll leave it to someone else
> (Will?) to merge that patch.

I sent it in (too large for the list), like the dis-asm.h


adding linuxppc64-dev at lists.linuxppc.org back to Cc:

> I cleaned up the xmon hooks to make them somewhat generic. The hope here
> is that we can switch debuggers at run time. It will also allow us to
> step through problems (at the moment if you get a DSI, hit xmon and fix
> the instruction up, you still end up panicing. Ive wanted a number of
> times to be able to fix it and continue on).
>
> Patch is attached below.
>
> My question is, how does kdb work? I cant see any hooks in arch/ppc64 to
> handle dodgy page faults etc. Does kdb work without requiring any arch
> hooks?
>
> Anton
>
> ===== arch/ppc64/Kconfig 1.39 vs edited =====
> --- 1.39/arch/ppc64/Kconfig	Sat Jan 24 13:39:39 2004
> +++ edited/arch/ppc64/Kconfig	Tue Jan 27 00:07:51 2004
> @@ -378,16 +378,15 @@
>  	  keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
>  	  unless you really know what this hack does.
>
> -choice
> -	optional
> -	depends on DEBUG_KERNEL
> -	prompt "Kernel Debugger"
> -
>  config XMON
>  	bool "XMON"
>  	help
>  	  Include in-kernel hooks for the xmon kernel monitor/debugger.
>  	  Unless you are intending to debug the kernel, say N here.
> +
> +config XMON_DEFAULT
> +	bool "Enable xmon by default"
> +	depends on XMON
>
>  config KDB
>  	bool "KDB"
> @@ -395,17 +394,10 @@
>  	  Include in-kernel hooks for the kdb kernel monitor/debugger.
>  	  Unless you are intending to debug the kernel, say N here.
>
> -endchoice
> -
> -
> -config XMON_DEFAULT
> -	bool "Enable xmon by default"
> -	depends on XMON
> -
> +# XXX FIXME
>  config KDB_OFF
>  	bool "Turn KDB off as default."
>  	depends on KDB
> -
>  	help
>   	   KDB will remain built into the kernel, but will be turned off.
>  	   "cat 1 > /proc/sys/kernel/kdb" to turn it on.
> ===== arch/ppc64/kernel/open_pic.c 1.25 vs edited =====
> --- 1.25/arch/ppc64/kernel/open_pic.c	Tue Jan 20 14:56:57 2004
> +++ edited/arch/ppc64/kernel/open_pic.c	Tue Jan 27 00:07:52 2004
> @@ -591,9 +591,9 @@
>  	request_irq(openpic_vec_ipi+1, openpic_ipi_action, SA_INTERRUPT,
>  		   "IPI1 (reschedule)", 0);
>  	request_irq(openpic_vec_ipi+2, openpic_ipi_action, SA_INTERRUPT,
> -		   "IPI2 (invalidate tlb)", 0);
> +		   "IPI2 (unused)", 0);
>  	request_irq(openpic_vec_ipi+3, openpic_ipi_action, SA_INTERRUPT,
> -		   "IPI3 (xmon break)", 0);
> +		   "IPI3 (debugger break)", 0);
>
>  	for ( i = 0; i < OPENPIC_NUM_IPI ; i++ )
>  		openpic_enable_ipi(openpic_vec_ipi+i);
> ===== arch/ppc64/kernel/ppc_ksyms.c 1.35 vs edited =====
> --- 1.35/arch/ppc64/kernel/ppc_ksyms.c	Sun Jan 25 00:55:49 2004
> +++ edited/arch/ppc64/kernel/ppc_ksyms.c	Tue Jan 27 00:35:17 2004
> @@ -203,24 +203,21 @@
>  EXPORT_SYMBOL(timer_interrupt);
>  EXPORT_SYMBOL(get_wchan);
>  EXPORT_SYMBOL(console_drivers);
> -#ifdef CONFIG_XMON
> -EXPORT_SYMBOL(xmon);
> -#endif
>
>  #ifdef CONFIG_DEBUG_KERNEL
> -extern void (*debugger)(struct pt_regs *regs);
> -extern int (*debugger_bpt)(struct pt_regs *regs);
> -extern int (*debugger_sstep)(struct pt_regs *regs);
> -extern int (*debugger_iabr_match)(struct pt_regs *regs);
> -extern int (*debugger_dabr_match)(struct pt_regs *regs);
> -extern void (*debugger_fault_handler)(struct pt_regs *regs);
> +extern int (*__debugger)(struct pt_regs *regs);
> +extern int (*__debugger_bpt)(struct pt_regs *regs);
> +extern int (*__debugger_sstep)(struct pt_regs *regs);
> +extern int (*__debugger_iabr_match)(struct pt_regs *regs);
> +extern int (*__debugger_dabr_match)(struct pt_regs *regs);
> +extern int (*__debugger_fault_handler)(struct pt_regs *regs);
>
> -EXPORT_SYMBOL(debugger);
> -EXPORT_SYMBOL(debugger_bpt);
> -EXPORT_SYMBOL(debugger_sstep);
> -EXPORT_SYMBOL(debugger_iabr_match);
> -EXPORT_SYMBOL(debugger_dabr_match);
> -EXPORT_SYMBOL(debugger_fault_handler);
> +EXPORT_SYMBOL(__debugger);
> +EXPORT_SYMBOL(__debugger_bpt);
> +EXPORT_SYMBOL(__debugger_sstep);
> +EXPORT_SYMBOL(__debugger_iabr_match);
> +EXPORT_SYMBOL(__debugger_dabr_match);
> +EXPORT_SYMBOL(__debugger_fault_handler);
>  #endif
>
>  EXPORT_SYMBOL(tb_ticks_per_usec);
> ===== arch/ppc64/kernel/setup.c 1.49 vs edited =====
> --- 1.49/arch/ppc64/kernel/setup.c	Wed Jan 28 11:25:51 2004
> +++ edited/arch/ppc64/kernel/setup.c	Wed Jan 28 16:31:19 2004
> @@ -68,10 +68,6 @@
>  unsigned long decr_overclock_set = 0;
>  unsigned long decr_overclock_proc0_set = 0;
>
> -#ifdef CONFIG_XMON
> -extern void xmon_map_scc(void);
> -#endif
> -
>  char saved_command_line[256];
>  unsigned char aux_device_present;
>
> @@ -148,15 +144,14 @@
>  		  unsigned long r6, unsigned long r7)
>  {
>  #ifdef CONFIG_PPC_PSERIES
> -        unsigned int ret, i;
> +	unsigned int ret, i;
>  #endif
>
>  #ifdef CONFIG_XMON_DEFAULT
> -	debugger = xmon;
> -	debugger_bpt = xmon_bpt;
> -	debugger_sstep = xmon_sstep;
> -	debugger_iabr_match = xmon_iabr_match;
> -	debugger_dabr_match = xmon_dabr_match;
> +	xmon_init();
> +#endif
> +#ifdef CONFIG_KDB_DEFAULT
> +	/* XXX FIXME */
>  #endif
>
>  #ifdef CONFIG_PPC_ISERIES
> @@ -555,12 +550,14 @@
>  	calibrate_delay = ppc64_calibrate_delay;
>
>  	ppc64_boot_msg(0x12, "Setup Arch");
> +
>  #ifdef CONFIG_XMON
> -	xmon_map_scc();
> -	if (strstr(cmd_line, "xmon"))
> -		xmon(0);
> +	if (strstr(cmd_line, "xmon")) {
> +		/* ensure xmon is enabled */
> +		xmon_init();
> +		debugger(0);
> +	}
>  #endif /* CONFIG_XMON */
> -
>
>  	/*
>  	 * Set cache line size based on type of cpu as a default.
> ===== arch/ppc64/kernel/smp.c 1.56 vs edited =====
> --- 1.56/arch/ppc64/kernel/smp.c	Thu Jan 22 14:44:04 2004
> +++ edited/arch/ppc64/kernel/smp.c	Tue Jan 27 00:30:12 2004
> @@ -414,7 +414,7 @@
>
>  void smp_message_recv(int msg, struct pt_regs *regs)
>  {
> -	switch( msg ) {
> +	switch(msg) {
>  	case PPC_MSG_CALL_FUNCTION:
>  #ifdef CONFIG_KDB
>  	        kdb_smp_regs[smp_processor_id()]=regs;
> @@ -430,11 +430,11 @@
>  		/* spare */
>  		break;
>  #endif
> -#ifdef CONFIG_XMON
> -	case PPC_MSG_XMON_BREAK:
> -		xmon(regs);
> +#ifdef CONFIG_DEBUG_KERNEL
> +	case PPC_MSG_DEBUGGER_BREAK:
> +		debugger(regs);
>  		break;
> -#endif /* CONFIG_XMON */
> +#endif
>  	default:
>  		printk("SMP %d: smp_message_recv(): unknown msg %d\n",
>  		       smp_processor_id(), msg);
> @@ -447,12 +447,12 @@
>  	smp_message_pass(cpu, PPC_MSG_RESCHEDULE, 0, 0);
>  }
>
> -#ifdef CONFIG_XMON
> -void smp_send_xmon_break(int cpu)
> +#ifdef CONFIG_DEBUG_KERNEL
> +void smp_send_debugger_break(int cpu)
>  {
> -	smp_message_pass(cpu, PPC_MSG_XMON_BREAK, 0, 0);
> +	smp_message_pass(cpu, PPC_MSG_DEBUGGER_BREAK, 0, 0);
>  }
> -#endif /* CONFIG_XMON */
> +#endif
>
>  static void stop_this_cpu(void *dummy)
>  {
> @@ -530,10 +530,7 @@
>  			printk("smp_call_function on cpu %d: other cpus not "
>  			       "responding (%d)\n", smp_processor_id(),
>  			       atomic_read(&data.started));
> -#ifdef CONFIG_DEBUG_KERNEL
> -			if (debugger)
> -				debugger(0);
> -#endif
> +			debugger(0);
>  			goto out;
>  		}
>  	}
> @@ -548,10 +545,7 @@
>  				       smp_processor_id(),
>  				       atomic_read(&data.finished),
>  				       atomic_read(&data.started));
> -#ifdef CONFIG_DEBUG_KERNEL
> -				if (debugger)
> -					debugger(0);
> -#endif
> +				debugger(0);
>  				goto out;
>  			}
>  		}
> ===== arch/ppc64/kernel/traps.c 1.25 vs edited =====
> --- 1.25/arch/ppc64/kernel/traps.c	Tue Jan 20 13:07:09 2004
> +++ edited/arch/ppc64/kernel/traps.c	Tue Jan 27 00:33:00 2004
> @@ -46,12 +46,12 @@
>  #endif
>
>  #ifdef CONFIG_DEBUG_KERNEL
> -void (*debugger)(struct pt_regs *regs);
> -int (*debugger_bpt)(struct pt_regs *regs);
> -int (*debugger_sstep)(struct pt_regs *regs);
> -int (*debugger_iabr_match)(struct pt_regs *regs);
> -int (*debugger_dabr_match)(struct pt_regs *regs);
> -void (*debugger_fault_handler)(struct pt_regs *regs);
> +int (*__debugger)(struct pt_regs *regs);
> +int (*__debugger_bpt)(struct pt_regs *regs);
> +int (*__debugger_sstep)(struct pt_regs *regs);
> +int (*__debugger_iabr_match)(struct pt_regs *regs);
> +int (*__debugger_dabr_match)(struct pt_regs *regs);
> +int (*__debugger_fault_handler)(struct pt_regs *regs);
>  #endif
>
>  /*
> @@ -88,11 +88,8 @@
>  _exception(int signr, siginfo_t *info, struct pt_regs *regs)
>  {
>  	if (!user_mode(regs)) {
> -#ifdef CONFIG_DEBUG_KERNEL
> -		if (debugger)
> -			debugger(regs);
> -#endif
> -		die("Exception in kernel mode\n", regs, signr);
> +		if (!debugger(regs))
> +			die("Exception in kernel mode\n", regs, signr);
>  	}
>
>  	force_sig_info(signr, info, current);
> @@ -146,11 +143,7 @@
>  	}
>  #endif
>
> -#ifdef CONFIG_DEBUG_KERNEL
> -	if (debugger)
> -		debugger(regs);
> -	else
> -#endif
> +	if (!debugger(regs))
>  		panic("System Reset");
>
>  	/* Must die if the interrupt is not recoverable */
> @@ -228,14 +221,11 @@
>  	}
>  #endif
>
> -#ifdef CONFIG_DEBUG_KERNEL
> -	if (debugger_fault_handler) {
> -		debugger_fault_handler(regs);
> +	if (debugger_fault_handler(regs))
>  		return;
> -	}
> -	if (debugger)
> -		debugger(regs);
> -#endif
> +	if (debugger(regs))
> +		return;
> +
>  	console_verbose();
>  	spin_lock_irq(&die_lock);
>  	bust_spinlocks(1);
> @@ -267,10 +257,8 @@
>  {
>  	siginfo_t info;
>
> -#ifdef CONFIG_DEBUG_KERNEL
> -	if (debugger_iabr_match && debugger_iabr_match(regs))
> +	if (debugger_iabr_match(regs))
>  		return;
> -#endif
>  	info.si_signo = SIGTRAP;
>  	info.si_errno = 0;
>  	info.si_code = TRAP_BRKPT;
> @@ -387,10 +375,9 @@
>  	} else if (regs->msr & 0x20000) {
>  		/* trap exception */
>
> -#ifdef CONFIG_DEBUG_KERNEL
> -		if (debugger_bpt && debugger_bpt(regs))
> +		if (debugger_bpt(regs))
>  			return;
> -#endif
> +
>  		if (check_bug_trap(regs)) {
>  			regs->nip += 4;
>  			return;
> @@ -434,10 +421,9 @@
>
>  	regs->msr &= ~MSR_SE;  /* Turn off 'trace' bit */
>
> -#ifdef CONFIG_DEBUG_KERNEL
> -	if (debugger_sstep && debugger_sstep(regs))
> +	if (debugger_sstep(regs))
>  		return;
> -#endif
> +
>  	info.si_signo = SIGTRAP;
>  	info.si_errno = 0;
>  	info.si_code = TRAP_TRACE;
> ===== arch/ppc64/kernel/xics.c 1.39 vs edited =====
> --- 1.39/arch/ppc64/kernel/xics.c	Thu Jan 22 14:44:05 2004
> +++ edited/arch/ppc64/kernel/xics.c	Tue Jan 27 00:20:34 2004
> @@ -375,11 +375,11 @@
>  			smp_message_recv(PPC_MSG_MIGRATE_TASK, regs);
>  		}
>  #endif
> -#ifdef CONFIG_XMON
> -		if (test_and_clear_bit(PPC_MSG_XMON_BREAK,
> +#ifdef CONFIG_DEBUG_KERNEL
> +		if (test_and_clear_bit(PPC_MSG_DEBUGGER_BREAK,
>  				       &xics_ipi_message[cpu].value)) {
>  			mb();
> -			smp_message_recv(PPC_MSG_XMON_BREAK, regs);
> +			smp_message_recv(PPC_MSG_DEBUGGER_BREAK, regs);
>  		}
>  #endif
>  	}
> ===== arch/ppc64/mm/fault.c 1.14 vs edited =====
> --- 1.14/arch/ppc64/mm/fault.c	Fri Sep 12 21:01:40 2003
> +++ edited/arch/ppc64/mm/fault.c	Tue Jan 27 00:31:32 2004
> @@ -37,12 +37,6 @@
>  #include <asm/system.h>
>  #include <asm/uaccess.h>
>
> -#include <asm/ppcdebug.h>
> -
> -#ifdef CONFIG_DEBUG_KERNEL
> -int debugger_kernel_faults = 1;
> -#endif
> -
>  void bad_page_fault(struct pt_regs *, unsigned long, int);
>
>  /*
> @@ -60,13 +54,10 @@
>  	unsigned long code = SEGV_MAPERR;
>  	unsigned long is_write = error_code & 0x02000000;
>
> -#ifdef CONFIG_DEBUG_KERNEL
> -	if (debugger_fault_handler && (regs->trap == 0x300 ||
> -				       regs->trap == 0x380)) {
> -		debugger_fault_handler(regs);
> -		return;
> +	if (regs->trap == 0x300 || regs->trap == 0x380) {
> +		if (debugger_fault_handler(regs))
> +			return;
>  	}
> -#endif
>
>  	/* On a kernel SLB miss we can only check for a valid exception entry */
>  	if (!user_mode(regs) && (regs->trap == 0x380)) {
> @@ -74,13 +65,10 @@
>  		return;
>  	}
>
> -#ifdef CONFIG_DEBUG_KERNEL
>  	if (error_code & 0x00400000) {
> -		/* DABR match */
>  		if (debugger_dabr_match(regs))
>  			return;
>  	}
> -#endif
>
>  	if (in_atomic() || mm == NULL) {
>  		bad_page_fault(regs, address, SIGSEGV);
> @@ -149,11 +137,6 @@
>  		info.si_errno = 0;
>  		info.si_code = code;
>  		info.si_addr = (void *) address;
> -#ifdef CONFIG_XMON
> -		ifppcdebug(PPCDBG_SIGNALXMON)
> -			PPCDBG_ENTER_DEBUGGER_REGS(regs);
> -#endif
> -
>  		force_sig_info(SIGSEGV, &info, current);
>  		return;
>  	}
> @@ -207,9 +190,7 @@
>  	}
>
>  	/* kernel has accessed a bad area */
> -#ifdef CONFIG_DEBUG_KERNEL
> -	if (debugger_kernel_faults)
> -		debugger(regs);
> -#endif
> +	if (debugger(regs))
> +		return;
>  	die("Kernel access of bad area", regs, sig);
>  }
> ===== arch/ppc64/mm/init.c 1.55 vs edited =====
> --- 1.55/arch/ppc64/mm/init.c	Tue Jan 20 13:07:09 2004
> +++ edited/arch/ppc64/mm/init.c	Tue Jan 27 00:31:39 2004
> @@ -59,6 +59,7 @@
>  #include <asm/cputable.h>
>  #include <asm/ppcdebug.h>
>  #include <asm/sections.h>
> +#include <asm/system.h>
>
>  #ifdef CONFIG_PPC_ISERIES
>  #include <asm/iSeries/iSeries_dma.h>
> @@ -694,7 +695,7 @@
>  	if (start == 0) {
>  		udbg_printf("do_init_bootmem: failed to allocate a bitmap.\n");
>  		udbg_printf("\tbootmap_pages = 0x%lx.\n", bootmap_pages);
> -		PPCDBG_ENTER_DEBUGGER();
> +		debugger(0);
>  	}
>
>  	boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages);
> ===== arch/ppc64/xmon/start.c 1.8 vs edited =====
> --- 1.8/arch/ppc64/xmon/start.c	Thu Jan 22 17:11:59 2004
> +++ edited/arch/ppc64/xmon/start.c	Tue Jan 27 00:38:33 2004
> @@ -11,6 +11,7 @@
>  #include <linux/kernel.h>
>  #include <linux/errno.h>
>  #include <linux/sysrq.h>
> +#include <linux/init.h>
>  #include <asm/machdep.h>
>  #include <asm/io.h>
>  #include <asm/page.h>
> @@ -31,30 +32,30 @@
>  }
>
>  #ifdef CONFIG_MAGIC_SYSRQ
> +extern int xmon(struct pt_regs *pt_regs);
>
>  static void sysrq_handle_xmon(int key, struct pt_regs *pt_regs,
>  			      struct tty_struct *tty)
>  {
> +	/* ensure xmon is enabled */
> +	xmon_init();
>  	xmon(pt_regs);
>  }
>
>  static struct sysrq_key_op sysrq_xmon_op =
>  {
>  	.handler =	sysrq_handle_xmon,
> -	.help_msg =	"xmon",
> +	.help_msg =	"Xmon",
>  	.action_msg =	"Entering xmon\n",
>  };
>
> -#endif /* CONFIG_MAGIC_SYSRQ */
> -
> -void
> -xmon_map_scc(void)
> +static int __init setup_xmon_sysrq(void)
>  {
> -#ifdef CONFIG_MAGIC_SYSRQ
> -	/* This maybe isn't the best place to register sysrq 'x' */
>  	__sysrq_put_key_op('x', &sysrq_xmon_op);
> -#endif /* CONFIG_MAGIC_SYSRQ */
> +	return 0;
>  }
> +__initcall(setup_xmon_sysrq);
> +#endif /* CONFIG_MAGIC_SYSRQ */
>
>  int
>  xmon_write(void *handle, void *ptr, int nb)
> @@ -79,11 +80,6 @@
>  void *xmon_stdin;
>  void *xmon_stdout;
>  void *xmon_stderr;
> -
> -void
> -xmon_init(void)
> -{
> -}
>
>  int
>  xmon_putc(int c, void *f)
> ===== arch/ppc64/xmon/xmon.c 1.32 vs edited =====
> --- 1.32/arch/ppc64/xmon/xmon.c	Tue Jan 20 13:07:09 2004
> +++ edited/arch/ppc64/xmon/xmon.c	Tue Jan 27 00:37:43 2004
> @@ -72,11 +72,10 @@
>  static unsigned bpinstr = 0x7fe00008;	/* trap */
>
>  /* Prototypes */
> -extern void (*debugger_fault_handler)(struct pt_regs *);
>  static int cmds(struct pt_regs *);
>  static int mread(unsigned long, void *, int);
>  static int mwrite(unsigned long, void *, int);
> -static void handle_fault(struct pt_regs *);
> +static int handle_fault(struct pt_regs *);
>  static void byterev(unsigned char *, int);
>  static void memex(void);
>  static int bsesc(void);
> @@ -114,10 +113,6 @@
>  #endif /* CONFIG_SMP */
>  static void csum(void);
>  static void bootcmds(void);
> -static void mem_translate(void);
> -static void mem_check(void);
> -static void mem_find_real(void);
> -static void mem_find_vsid(void);
>
>  static void debug_trace(void);
>
> @@ -223,7 +218,7 @@
>  #endif
>  }
>
> -void
> +int
>  xmon(struct pt_regs *excp)
>  {
>  	struct pt_regs regs;
> @@ -328,17 +323,9 @@
>  	clear_bit(smp_processor_id(), &cpus_in_xmon);
>  #endif /* CONFIG_SMP */
>  	set_msrd(msr);		/* restore interrupt enable */
> -}
>
> -void
> -xmon_irq(int irq, void *d, struct pt_regs *regs)
> -{
> -	unsigned long flags;
> -	local_save_flags(flags);
> -	local_irq_disable();
> -	printf("Keyboard interrupt\n");
> -	xmon(regs);
> -	local_irq_restore(flags);
> +	/* XXX return 1 to try and recover */
> +	return 0;
>  }
>
>  int
> @@ -522,18 +509,6 @@
>  			case 'z':
>  				memzcan();
>  				break;
> -			case 'x':
> -				mem_translate();
> -				break;
> -			case 'c':
> -				mem_check();
> -				break;
> -			case 'f':
> -				mem_find_real();
> -				break;
> -			case 'e':
> -				mem_find_vsid();
> -				break;
>  			case 'i':
>  				show_mem();
>  				break;
> @@ -630,7 +605,7 @@
>  		printf("stopping all cpus\n");
>  		/* interrupt other cpu(s) */
>  		cpu = MSG_ALL_BUT_SELF;
> -		smp_send_xmon_break(cpu);
> +		smp_send_debugger_break(cpu);
>  		return;
>  	}
>  	termch = cmd;
> @@ -1180,7 +1155,7 @@
>
>  	n = 0;
>  	if (setjmp(bus_error_jmp) == 0) {
> -		debugger_fault_handler = handle_fault;
> +		__debugger_fault_handler = handle_fault;
>  		sync();
>  		p = (char *)adrs;
>  		q = (char *)buf;
> @@ -1205,7 +1180,7 @@
>  		__delay(200);
>  		n = size;
>  	}
> -	debugger_fault_handler = 0;
> +	__debugger_fault_handler = 0;
>  	return n;
>  }
>
> @@ -1217,7 +1192,7 @@
>
>  	n = 0;
>  	if (setjmp(bus_error_jmp) == 0) {
> -		debugger_fault_handler = handle_fault;
> +		__debugger_fault_handler = handle_fault;
>  		sync();
>  		p = (char *) adrs;
>  		q = (char *) buf;
> @@ -1244,14 +1219,14 @@
>  	} else {
>  		printf("*** Error writing address %x\n", adrs + n);
>  	}
> -	debugger_fault_handler = 0;
> +	__debugger_fault_handler = 0;
>  	return n;
>  }
>
>  static int fault_type;
>  static char *fault_chars[] = { "--", "**", "##" };
>
> -static void
> +static int
>  handle_fault(struct pt_regs *regs)
>  {
>  	switch (regs->trap) {
> @@ -1267,6 +1242,8 @@
>  	}
>
>  	longjmp(bus_error_jmp, 1);
> +
> +	return 0;
>  }
>
>  #define SWAP(a, b, t)	((t) = (a), (a) = (b), (b) = (t))
> @@ -1880,7 +1857,7 @@
>  	char namebuf[128];
>
>  	if (setjmp(bus_error_jmp) == 0) {
> -		debugger_fault_handler = handle_fault;
> +		__debugger_fault_handler = handle_fault;
>  		sync();
>  		name = kallsyms_lookup(address, &size, &offset, &modname,
>  				       namebuf);
> @@ -1891,7 +1868,7 @@
>  		name = "symbol lookup failed";
>  	}
>
> -	debugger_fault_handler = 0;
> +	__debugger_fault_handler = 0;
>
>  	if (!name) {
>  		char addrstr[sizeof("0x%lx") + (BITS_PER_LONG*3/10)];
> @@ -1919,240 +1896,8 @@
>  	}
>  }
>
> -void
> -mem_translate()
> +static void debug_trace(void)
>  {
> -	int c;
> -	unsigned long ea, va, vsid, vpn, page, hpteg_slot_primary, hpteg_slot_secondary, primary_hash, i, *steg, esid, stabl;
> -	HPTE *  hpte;
> -	struct mm_struct * mm;
> -	pte_t  *ptep = NULL;
> -	void * pgdir;
> -
> -	c = inchar();
> -	if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n')
> -		termch = c;
> -	scanhex((void *)&ea);
> -
> -	if ((ea >= KRANGE_START) && (ea <= (KRANGE_START + (1UL<<60)))) {
> -		ptep = 0;
> -		vsid = get_kernel_vsid(ea);
> -		va = ( vsid << 28 ) | ( ea & 0x0fffffff );
> -	} else {
> -		// if in vmalloc range, use the vmalloc page directory
> -		if ( ( ea >= VMALLOC_START ) && ( ea <= VMALLOC_END ) ) {
> -			mm = &init_mm;
> -			vsid = get_kernel_vsid( ea );
> -		}
> -		// if in ioremap range, use the ioremap page directory
> -		else if ( ( ea >= IMALLOC_START ) && ( ea <= IMALLOC_END ) ) {
> -			mm = &ioremap_mm;
> -			vsid = get_kernel_vsid( ea );
> -		}
> -		// if in user range, use the current task's page directory
> -		else if ( ( ea >= USER_START ) && ( ea <= USER_END ) ) {
> -			mm = current->mm;
> -			vsid = get_vsid(mm->context, ea );
> -		}
> -		pgdir = mm->pgd;
> -		va = ( vsid << 28 ) | ( ea & 0x0fffffff );
> -		ptep = find_linux_pte( pgdir, ea );
> -	}
> -
> -	vpn = ((vsid << 28) | (((ea) & 0xFFFF000))) >> 12;
> -	page = vpn & 0xffff;
> -	esid = (ea >> 28)  & 0xFFFFFFFFF;
> -
> -  // Search the primary group for an available slot
> -	primary_hash = ( vsid & 0x7fffffffff ) ^ page;
> -	hpteg_slot_primary = ( primary_hash & htab_data.htab_hash_mask ) * HPTES_PER_GROUP;
> -	hpteg_slot_secondary = ( ~primary_hash & htab_data.htab_hash_mask ) * HPTES_PER_GROUP;
> -
> -	printf("ea             : %.16lx\n", ea);
> -	printf("esid           : %.16lx\n", esid);
> -	printf("vsid           : %.16lx\n", vsid);
> -
> -	printf("\nSoftware Page Table\n-------------------\n");
> -	printf("ptep           : %.16lx\n", ((unsigned long *)ptep));
> -	if(ptep) {
> -		printf("*ptep          : %.16lx\n", *((unsigned long *)ptep));
> -	}
> -
> -	hpte  = htab_data.htab  + hpteg_slot_primary;
> -	printf("\nHardware Page Table\n-------------------\n");
> -	printf("htab base      : %.16lx\n", htab_data.htab);
> -	printf("slot primary   : %.16lx\n", hpteg_slot_primary);
> -	printf("slot secondary : %.16lx\n", hpteg_slot_secondary);
> -	printf("\nPrimary Group\n");
> -	for (i=0; i<8; ++i) {
> -		if ( hpte->dw0.dw0.v != 0 ) {
> -			printf("%d: (hpte)%.16lx %.16lx\n", i, hpte->dw0.dword0, hpte->dw1.dword1);
> -			printf("          vsid: %.13lx   api: %.2lx  hash: %.1lx\n",
> -			       (hpte->dw0.dw0.avpn)>>5,
> -			       (hpte->dw0.dw0.avpn) & 0x1f,
> -			       (hpte->dw0.dw0.h));
> -			printf("          rpn: %.13lx \n", (hpte->dw1.dw1.rpn));
> -			printf("           pp: %.1lx \n",
> -			       ((hpte->dw1.dw1.pp0)<<2)|(hpte->dw1.dw1.pp));
> -			printf("        wimgn: %.2lx  reference: %.1lx  change: %.1lx\n",
> -			       ((hpte->dw1.dw1.w)<<4)|
> -			       ((hpte->dw1.dw1.i)<<3)|
> -			       ((hpte->dw1.dw1.m)<<2)|
> -			       ((hpte->dw1.dw1.g)<<1)|
> -			       ((hpte->dw1.dw1.n)<<0),
> -			       hpte->dw1.dw1.r, hpte->dw1.dw1.c);
> -		}
> -		hpte++;
> -	}
> -
> -	printf("\nSecondary Group\n");
> -	// Search the secondary group
> -	hpte  = htab_data.htab  + hpteg_slot_secondary;
> -	for (i=0; i<8; ++i) {
> -		if(hpte->dw0.dw0.v) {
> -			printf("%d: (hpte)%.16lx %.16lx\n", i, hpte->dw0.dword0, hpte->dw1.dword1);
> -			printf("          vsid: %.13lx   api: %.2lx  hash: %.1lx\n",
> -			       (hpte->dw0.dw0.avpn)>>5,
> -			       (hpte->dw0.dw0.avpn) & 0x1f,
> -			       (hpte->dw0.dw0.h));
> -			printf("          rpn: %.13lx \n", (hpte->dw1.dw1.rpn));
> -			printf("           pp: %.1lx \n",
> -			       ((hpte->dw1.dw1.pp0)<<2)|(hpte->dw1.dw1.pp));
> -			printf("        wimgn: %.2lx  reference: %.1lx  change: %.1lx\n",
> -			       ((hpte->dw1.dw1.w)<<4)|
> -			       ((hpte->dw1.dw1.i)<<3)|
> -			       ((hpte->dw1.dw1.m)<<2)|
> -			       ((hpte->dw1.dw1.g)<<1)|
> -			       ((hpte->dw1.dw1.n)<<0),
> -			       hpte->dw1.dw1.r, hpte->dw1.dw1.c);
> -		}
> -		hpte++;
> -	}
> -
> -	printf("\nHardware Segment Table\n-----------------------\n");
> -	stabl = (unsigned long)(KERNELBASE+(_ASR&0xFFFFFFFFFFFFFFFE));
> -	steg = (unsigned long *)((stabl) | ((esid & 0x1f) << 7));
> -
> -	printf("stab base      : %.16lx\n", stabl);
> -	printf("slot           : %.16lx\n", steg);
> -
> -	for (i=0; i<8; ++i) {
> -		printf("%d: (ste) %.16lx %.16lx\n", i,
> -		       *((unsigned long *)(steg+i*2)),*((unsigned long *)(steg+i*2+1)) );
> -	}
> -}
> -
> -void mem_check()
> -{
> -	unsigned long htab_size_bytes;
> -	unsigned long htab_end;
> -	unsigned long last_rpn;
> -	HPTE *hpte1, *hpte2;
> -
> -	htab_size_bytes = htab_data.htab_num_ptegs * 128; // 128B / PTEG
> -	htab_end = (unsigned long)htab_data.htab + htab_size_bytes;
> -	// last_rpn = (naca->physicalMemorySize-1) >> PAGE_SHIFT;
> -	last_rpn = 0xfffff;
> -
> -	printf("\nHardware Page Table Check\n-------------------\n");
> -	printf("htab base      : %.16lx\n", htab_data.htab);
> -	printf("htab size      : %.16lx\n", htab_size_bytes);
> -
> -#if 1
> -	for(hpte1 = htab_data.htab; hpte1 < (HPTE *)htab_end; hpte1++) {
> -		if ( hpte1->dw0.dw0.v != 0 ) {
> -			if ( hpte1->dw1.dw1.rpn <= last_rpn ) {
> -				for(hpte2 = hpte1+1; hpte2 < (HPTE *)htab_end; hpte2++) {
> -					if ( hpte2->dw0.dw0.v != 0 ) {
> -						if(hpte1->dw1.dw1.rpn == hpte2->dw1.dw1.rpn) {
> -							printf(" Duplicate rpn: %.13lx \n", (hpte1->dw1.dw1.rpn));
> -							printf("   hpte1: %16.16lx  *hpte1: %16.16lx %16.16lx\n",
> -							       hpte1, hpte1->dw0.dword0, hpte1->dw1.dword1);
> -							printf("   hpte2: %16.16lx  *hpte2: %16.16lx %16.16lx\n",
> -							       hpte2, hpte2->dw0.dword0, hpte2->dw1.dword1);
> -						}
> -					}
> -				}
> -			} else {
> -				printf(" Bogus rpn: %.13lx \n", (hpte1->dw1.dw1.rpn));
> -				printf("   hpte: %16.16lx  *hpte: %16.16lx %16.16lx\n",
> -				       hpte1, hpte1->dw0.dword0, hpte1->dw1.dword1);
> -			}
> -		}
> -	}
> -#endif
> -	printf("\nDone -------------------\n");
> -}
> -
> -void mem_find_real()
> -{
> -	unsigned long htab_size_bytes;
> -	unsigned long htab_end;
> -	unsigned long last_rpn;
> -	HPTE *hpte1;
> -	unsigned long pa, rpn;
> -	int c;
> -
> -	c = inchar();
> -	if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n')
> -		termch = c;
> -	scanhex((void *)&pa);
> -	rpn = pa >> 12;
> -
> -	htab_size_bytes = htab_data.htab_num_ptegs * 128; // 128B / PTEG
> -	htab_end = (unsigned long)htab_data.htab + htab_size_bytes;
> -	// last_rpn = (naca->physicalMemorySize-1) >> PAGE_SHIFT;
> -	last_rpn = 0xfffff;
> -
> -	printf("\nMem Find RPN\n-------------------\n");
> -	printf("htab base      : %.16lx\n", htab_data.htab);
> -	printf("htab size      : %.16lx\n", htab_size_bytes);
> -
> -	for(hpte1 = htab_data.htab; hpte1 < (HPTE *)htab_end; hpte1++) {
> -		if ( hpte1->dw0.dw0.v != 0 ) {
> -			if ( hpte1->dw1.dw1.rpn == rpn ) {
> -				printf(" Found rpn: %.13lx \n", (hpte1->dw1.dw1.rpn));
> -				printf("      hpte: %16.16lx  *hpte1: %16.16lx %16.16lx\n",
> -				       hpte1, hpte1->dw0.dword0, hpte1->dw1.dword1);
> -			}
> -		}
> -	}
> -	printf("\nDone -------------------\n");
> -}
> -
> -void mem_find_vsid()
> -{
> -	unsigned long htab_size_bytes;
> -	unsigned long htab_end;
> -	HPTE *hpte1;
> -	unsigned long vsid;
> -	int c;
> -
> -	c = inchar();
> -	if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n')
> -		termch = c;
> -	scanhex((void *)&vsid);
> -
> -	htab_size_bytes = htab_data.htab_num_ptegs * 128; // 128B / PTEG
> -	htab_end = (unsigned long)htab_data.htab + htab_size_bytes;
> -
> -	printf("\nMem Find VSID\n-------------------\n");
> -	printf("htab base      : %.16lx\n", htab_data.htab);
> -	printf("htab size      : %.16lx\n", htab_size_bytes);
> -
> -	for(hpte1 = htab_data.htab; hpte1 < (HPTE *)htab_end; hpte1++) {
> -		if ( hpte1->dw0.dw0.v != 0 ) {
> -			if ( ((hpte1->dw0.dw0.avpn)>>5) == vsid ) {
> -				printf(" Found vsid: %.16lx \n", ((hpte1->dw0.dw0.avpn) >> 5));
> -				printf("       hpte: %16.16lx  *hpte1: %16.16lx %16.16lx\n",
> -				       hpte1, hpte1->dw0.dword0, hpte1->dw1.dword1);
> -			}
> -		}
> -	}
> -	printf("\nDone -------------------\n");
> -}
> -
> -static void debug_trace(void) {
>          unsigned long val, cmd, on;
>
>  	cmd = skipbl();
> @@ -2198,4 +1943,13 @@
>  		}
>  		cmd = skipbl();
>  	}
> +}
> +
> +void xmon_init(void)
> +{
> +	__debugger = xmon;
> +	__debugger_bpt = xmon_bpt;
> +	__debugger_sstep = xmon_sstep;
> +	__debugger_iabr_match = xmon_iabr_match;
> +	__debugger_dabr_match = xmon_dabr_match;
>  }
> ===== include/asm-ppc64/ppcdebug.h 1.4 vs edited =====
> --- 1.4/include/asm-ppc64/ppcdebug.h	Fri Sep 13 21:19:46 2002
> +++ edited/include/asm-ppc64/ppcdebug.h	Tue Jan 27 00:07:54 2004
> @@ -95,24 +95,11 @@
>  #define ppcdebugset(FLAGS) (udbg_ifdebug(FLAGS))
>  #define PPCDBG_BINFMT (test_thread_flag(TIF_32BIT) ? PPCDBG_BINFMT32 : PPCDBG_BINFMT64)
>
> -#ifdef CONFIG_XMON
> -#define PPCDBG_ENTER_DEBUGGER() xmon(0)
> -#define PPCDBG_ENTER_DEBUGGER_REGS(X) xmon(X)
> -#endif
> -
>  #else
>  #define PPCDBG(...) do {;} while (0)
>  #define PPCDBGCALL(FLAGS,FUNCTION) do {;} while (0)
>  #define ifppcdebug(...) if (0)
>  #define ppcdebugset(FLAGS) (0)
>  #endif /* CONFIG_PPCDBG */
> -
> -#ifndef PPCDBG_ENTER_DEBUGGER
> -#define PPCDBG_ENTER_DEBUGGER() do {;} while(0)
> -#endif
> -
> -#ifndef PPCDBG_ENTER_DEBUGGER_REGS
> -#define PPCDBG_ENTER_DEBUGGER_REGS(A) do {;} while(0)
> -#endif
>
>  #endif /*__PPCDEBUG_H */
> ===== include/asm-ppc64/smp.h 1.17 vs edited =====
> --- 1.17/include/asm-ppc64/smp.h	Tue Jan 20 13:08:24 2004
> +++ edited/include/asm-ppc64/smp.h	Tue Jan 27 00:24:40 2004
> @@ -29,8 +29,7 @@
>  #ifdef CONFIG_SMP
>
>  extern void smp_message_pass(int target, int msg, unsigned long data, int wait);
> -extern void smp_send_tlb_invalidate(int);
> -extern void smp_send_xmon_break(int cpu);
> +extern void smp_send_debugger_break(int cpu);
>  struct pt_regs;
>  extern void smp_message_recv(int, struct pt_regs *);
>
> @@ -63,17 +62,22 @@
>   * in /proc/interrupts will be wrong!!! --Troy */
>  #define PPC_MSG_CALL_FUNCTION   0
>  #define PPC_MSG_RESCHEDULE      1
> +/* This is unused now */
> +#if 0
>  #define PPC_MSG_MIGRATE_TASK    2
> -#define PPC_MSG_XMON_BREAK      3
> +#endif
> +#define PPC_MSG_DEBUGGER_BREAK  3
>
>  void smp_init_iSeries(void);
>  void smp_init_pSeries(void);
>
>  #endif /* !(CONFIG_SMP) */
> -#endif /* __ASSEMBLY__ */
>
>  #define get_hard_smp_processor_id(CPU) (paca[(CPU)].xHwProcNum)
> -#define set_hard_smp_processor_id(CPU, VAL) do { (paca[(CPU)].xHwProcNum = VAL); } while (0)
> +#define set_hard_smp_processor_id(CPU, VAL) \
> +	do { (paca[(CPU)].xHwProcNum = VAL); } while (0)
> +
> +#endif /* __ASSEMBLY__ */
>
>  #endif /* !(_PPC64_SMP_H) */
>  #endif /* __KERNEL__ */
> ===== include/asm-ppc64/system.h 1.25 vs edited =====
> --- 1.25/include/asm-ppc64/system.h	Thu Jan 22 16:29:20 2004
> +++ edited/include/asm-ppc64/system.h	Tue Jan 27 00:28:18 2004
> @@ -9,6 +9,7 @@
>   */
>
>  #include <linux/config.h>
> +#include <linux/compiler.h>
>  #include <asm/page.h>
>  #include <asm/processor.h>
>  #include <asm/hw_irq.h>
> @@ -53,30 +54,40 @@
>  #endif /* CONFIG_SMP */
>
>  #ifdef CONFIG_DEBUG_KERNEL
> -extern void (*debugger)(struct pt_regs *regs);
> -extern int (*debugger_bpt)(struct pt_regs *regs);
> -extern int (*debugger_sstep)(struct pt_regs *regs);
> -extern int (*debugger_iabr_match)(struct pt_regs *regs);
> -extern int (*debugger_dabr_match)(struct pt_regs *regs);
> -extern void (*debugger_fault_handler)(struct pt_regs *regs);
> -#else
> -#define debugger(regs)			do { } while (0)
> -#define debugger_bpt(regs)		0
> -#define debugger_sstep(regs)		0
> -#define debugger_iabr_match(regs)	0
> -#define debugger_dabr_match(regs)	0
> -#define debugger_fault_handler		((void (*)(struct pt_regs *))0)
> -#endif
> +
> +extern int (*__debugger)(struct pt_regs *regs);
> +extern int (*__debugger_bpt)(struct pt_regs *regs);
> +extern int (*__debugger_sstep)(struct pt_regs *regs);
> +extern int (*__debugger_iabr_match)(struct pt_regs *regs);
> +extern int (*__debugger_dabr_match)(struct pt_regs *regs);
> +extern int (*__debugger_fault_handler)(struct pt_regs *regs);
> +
> +#define DEBUGGER_BOILERPLATE(__NAME) \
> +static inline int __NAME(struct pt_regs *regs) \
> +{ \
> +	if (unlikely(__ ## __NAME)) \
> +		return __ ## __NAME(regs); \
> +	return 0; \
> +}
> +
> +DEBUGGER_BOILERPLATE(debugger)
> +DEBUGGER_BOILERPLATE(debugger_bpt)
> +DEBUGGER_BOILERPLATE(debugger_sstep)
> +DEBUGGER_BOILERPLATE(debugger_iabr_match)
> +DEBUGGER_BOILERPLATE(debugger_dabr_match)
> +DEBUGGER_BOILERPLATE(debugger_fault_handler)
>
>  #ifdef CONFIG_XMON
> -extern void xmon_irq(int, void *, struct pt_regs *);
> +extern void xmon_init(void);
> +#endif
>
> -extern void xmon(struct pt_regs *regs);
> -extern int xmon_bpt(struct pt_regs *regs);
> -extern int xmon_sstep(struct pt_regs *regs);
> -extern int xmon_iabr_match(struct pt_regs *regs);
> -extern int xmon_dabr_match(struct pt_regs *regs);
> -extern void (*xmon_fault_handler)(struct pt_regs *regs);
> +#else
> +#define DEBUGGER(regs)			0
> +#define DEBUGGER_BPT(regs)		0
> +#define DEBUGGER_SSTEP(regs)		0
> +#define DEBUGGER_IABR_MATCH(regs)	0
> +#define DEBUGGER_DABR_MATCH(regs)	0
> +#define DEBUGGER_FAULT_HANDLER(regs)	0
>  #endif
>
>  extern void show_regs(struct pt_regs * regs);
>

--
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list