ia64/xen-unstable

changeset 12915:4da585fb62f9

[XEN][POWERPC] Clean up debug/traceback/trapping logic
This patch tries to sort out all the debugging mechanisms we have
available to us.
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Thu Nov 30 15:26:55 2006 -0600 (2006-11-30)
parents 7f3ae39112cd
children 2a10ce87327c
files xen/arch/powerpc/backtrace.c xen/arch/powerpc/exceptions.c xen/arch/powerpc/mm.c xen/arch/powerpc/powerpc64/ppc970.c xen/arch/powerpc/powerpc64/scom.h xen/arch/powerpc/powerpc64/traps.c xen/arch/powerpc/setup.c xen/arch/powerpc/smp.c xen/arch/powerpc/time.c xen/arch/powerpc/usercopy.c xen/include/asm-powerpc/debugger.h xen/include/asm-powerpc/flushtlb.h xen/include/asm-powerpc/misc.h xen/include/asm-powerpc/mm.h xen/include/asm-powerpc/page.h xen/include/asm-powerpc/processor.h
line diff
     1.1 --- a/xen/arch/powerpc/backtrace.c	Fri Sep 22 11:02:47 2006 -0400
     1.2 +++ b/xen/arch/powerpc/backtrace.c	Thu Nov 30 15:26:55 2006 -0600
     1.3 @@ -14,6 +14,7 @@
     1.4  #include <xen/console.h>
     1.5  #include <xen/sched.h>
     1.6  #include <xen/symbols.h>
     1.7 +#include <asm/debugger.h>
     1.8  
     1.9  static char namebuf[KSYM_NAME_LEN+1];
    1.10  
    1.11 @@ -192,6 +193,19 @@ void show_backtrace(ulong sp, ulong lr, 
    1.12      console_end_sync();
    1.13  }
    1.14  
    1.15 +void show_backtrace_regs(struct cpu_user_regs *regs)
    1.16 +{
    1.17 +    console_start_sync();
    1.18 +    
    1.19 +    show_registers(regs);
    1.20 +    printk("dar 0x%016lx, dsisr 0x%08x\n", mfdar(), mfdsisr());
    1.21 +    printk("hid4 0x%016lx\n", regs->hid4);
    1.22 +    printk("---[ backtrace ]---\n");
    1.23 +    show_backtrace(regs->gprs[1], regs->lr, regs->pc);
    1.24 +
    1.25 +    console_end_sync();
    1.26 +}
    1.27 +
    1.28  void __warn(char *file, int line)
    1.29  {
    1.30      ulong sp;
    1.31 @@ -202,9 +216,7 @@ void __warn(char *file, int line)
    1.32  
    1.33      sp = (ulong)__builtin_frame_address(0);
    1.34      lr = (ulong)__builtin_return_address(0);
    1.35 +    backtrace(sp, lr, lr);
    1.36  
    1.37 -    backtrace(sp, lr, lr);
    1.38      console_end_sync();
    1.39  }
    1.40 -
    1.41 -    
     2.1 --- a/xen/arch/powerpc/exceptions.c	Fri Sep 22 11:02:47 2006 -0400
     2.2 +++ b/xen/arch/powerpc/exceptions.c	Thu Nov 30 15:26:55 2006 -0600
     2.3 @@ -25,8 +25,10 @@
     2.4  #include <xen/serial.h>
     2.5  #include <xen/gdbstub.h>
     2.6  #include <xen/console.h>
     2.7 +#include <xen/shutdown.h>
     2.8  #include <asm/time.h>
     2.9  #include <asm/processor.h>
    2.10 +#include <asm/debugger.h>
    2.11  
    2.12  #undef DEBUG
    2.13  
    2.14 @@ -56,25 +58,19 @@ void do_dec(struct cpu_user_regs *regs)
    2.15  
    2.16  void program_exception(struct cpu_user_regs *regs, unsigned long cookie)
    2.17  {
    2.18 -#ifdef CRASH_DEBUG
    2.19 -    __trap_to_gdb(regs, cookie);
    2.20 -#else /* CRASH_DEBUG */
    2.21 -    int recover = 0;
    2.22 -
    2.23 -    console_start_sync();
    2.24 +    if (cookie == 0x200) {
    2.25 +        if (cpu_machinecheck(regs))
    2.26 +            return;
    2.27  
    2.28 -    show_registers(regs);
    2.29 -    printk("dar 0x%016lx, dsisr 0x%08x\n", mfdar(), mfdsisr());
    2.30 -    printk("hid4 0x%016lx\n", regs->hid4);
    2.31 -    printk("---[ backtrace ]---\n");
    2.32 -    show_backtrace(regs->gprs[1], regs->lr, regs->pc);
    2.33 +        printk("%s: machine check\n", __func__);
    2.34 +    } else {
    2.35 +#ifdef CRASH_DEBUG
    2.36 +        if (__trap_to_gdb(regs, cookie) == 0)
    2.37 +            return;
    2.38 +#endif /* CRASH_DEBUG */
    2.39  
    2.40 -    if (cookie == 0x200)
    2.41 -        recover = cpu_machinecheck(regs);
    2.42 -
    2.43 -    if (!recover)
    2.44 -        panic("%s: 0x%lx\n", __func__, cookie);
    2.45 -
    2.46 -    console_end_sync();
    2.47 -#endif /* CRASH_DEBUG */
    2.48 +        printk("%s: type: 0x%lx\n", __func__, cookie);
    2.49 +        show_backtrace_regs(regs);
    2.50 +    }
    2.51 +    machine_halt();
    2.52  }
     3.1 --- a/xen/arch/powerpc/mm.c	Fri Sep 22 11:02:47 2006 -0400
     3.2 +++ b/xen/arch/powerpc/mm.c	Thu Nov 30 15:26:55 2006 -0600
     3.3 @@ -25,7 +25,6 @@
     3.4  #include <xen/kernel.h>
     3.5  #include <xen/sched.h>
     3.6  #include <xen/perfc.h>
     3.7 -#include <asm/misc.h>
     3.8  #include <asm/init.h>
     3.9  #include <asm/page.h>
    3.10  
     4.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Fri Sep 22 11:02:47 2006 -0400
     4.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Thu Nov 30 15:26:55 2006 -0600
     4.3 @@ -30,6 +30,7 @@
     4.4  #include <asm/powerpc64/procarea.h>
     4.5  #include <asm/powerpc64/processor.h>
     4.6  #include <asm/powerpc64/ppc970-hid.h>
     4.7 +#include "scom.h"
     4.8  
     4.9  #undef DEBUG
    4.10  #undef SERIALIZE
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xen/arch/powerpc/powerpc64/scom.h	Thu Nov 30 15:26:55 2006 -0600
     5.3 @@ -0,0 +1,39 @@
     5.4 +/*
     5.5 + * This program is free software; you can redistribute it and/or modify
     5.6 + * it under the terms of the GNU General Public License as published by
     5.7 + * the Free Software Foundation; either version 2 of the License, or
     5.8 + * (at your option) any later version.
     5.9 + *
    5.10 + * This program is distributed in the hope that it will be useful,
    5.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.13 + * GNU General Public License for more details.
    5.14 + *
    5.15 + * You should have received a copy of the GNU General Public License
    5.16 + * along with this program; if not, write to the Free Software
    5.17 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    5.18 + *
    5.19 + * Copyright (C) IBM Corp. 2006
    5.20 + *
    5.21 + * Authors: Jimi Xenidis <jimix@watson.ibm.com>
    5.22 + */
    5.23 +
    5.24 +#ifndef _ARCH_POWERPC_POWERPC64_SCOM_H_
    5.25 +#define _ARCH_POWERPC_POWERPC64_SCOM_H_
    5.26 +
    5.27 +extern void cpu_scom_init(void);
    5.28 +int cpu_scom_read(unsigned int addr, unsigned long *d);
    5.29 +int cpu_scom_write(unsigned int addr, unsigned long d);
    5.30 +void cpu_scom_AMCR(void);
    5.31 +
    5.32 +/* SCOMC addresses are 16bit but we are given 24 bits in the
    5.33 + * books. The low oerder 8 bits are some kinda parity thin and should
    5.34 + * be ignored */
    5.35 +#define SCOM_AMC_REG       0x022601
    5.36 +#define SCOM_AMC_AND_MASK  0x022700
    5.37 +#define SCOM_AMC_OR_MASK   0x022800
    5.38 +#define SCOM_CMCE          0x030901
    5.39 +#define SCOM_PMCR          0x400801
    5.40 +#define SCOM_PTSR          0x408001
    5.41 +
    5.42 +#endif
     6.1 --- a/xen/arch/powerpc/powerpc64/traps.c	Fri Sep 22 11:02:47 2006 -0400
     6.2 +++ b/xen/arch/powerpc/powerpc64/traps.c	Thu Nov 30 15:26:55 2006 -0600
     6.3 @@ -48,7 +48,3 @@ void show_registers(struct cpu_user_regs
     6.4      console_end_sync();
     6.5  }
     6.6  
     6.7 -void show_execution_state(struct cpu_user_regs *regs)
     6.8 -{
     6.9 -    show_registers(regs);
    6.10 -}
     7.1 --- a/xen/arch/powerpc/setup.c	Fri Sep 22 11:02:47 2006 -0400
     7.2 +++ b/xen/arch/powerpc/setup.c	Thu Nov 30 15:26:55 2006 -0600
     7.3 @@ -414,7 +414,7 @@ void __init __start_xen_ppc(
     7.4  
     7.5      } else {
     7.6          /* booted by someone else that hopefully has a trap handler */
     7.7 -        trap();
     7.8 +        __builtin_trap();
     7.9      }
    7.10  
    7.11      __start_xen(mbi);
     8.1 --- a/xen/arch/powerpc/smp.c	Fri Sep 22 11:02:47 2006 -0400
     8.2 +++ b/xen/arch/powerpc/smp.c	Thu Nov 30 15:26:55 2006 -0600
     8.3 @@ -18,10 +18,10 @@
     8.4   * Authors: Hollis Blanchard <hollisb@us.ibm.com>
     8.5   */
     8.6  
     8.7 -#include <asm/misc.h>
     8.8  #include <xen/cpumask.h>
     8.9  #include <xen/smp.h>
    8.10  #include <asm/flushtlb.h>
    8.11 +#include <asm/debugger.h>
    8.12  
    8.13  int smp_num_siblings = 1;
    8.14  int smp_num_cpus = 1;
     9.1 --- a/xen/arch/powerpc/time.c	Fri Sep 22 11:02:47 2006 -0400
     9.2 +++ b/xen/arch/powerpc/time.c	Thu Nov 30 15:26:55 2006 -0600
     9.3 @@ -25,7 +25,7 @@
     9.4  #include <xen/sched.h>
     9.5  #include <asm/processor.h>
     9.6  #include <asm/current.h>
     9.7 -#include <asm/misc.h>
     9.8 +#include <asm/debugger.h>
     9.9  
    9.10  #define Dprintk(x...) printk(x)
    9.11  
    10.1 --- a/xen/arch/powerpc/usercopy.c	Fri Sep 22 11:02:47 2006 -0400
    10.2 +++ b/xen/arch/powerpc/usercopy.c	Thu Nov 30 15:26:55 2006 -0600
    10.3 @@ -23,6 +23,7 @@
    10.4  #include <xen/sched.h>
    10.5  #include <asm/current.h>
    10.6  #include <asm/uaccess.h>
    10.7 +#include <asm/debugger.h>
    10.8  #include <public/xen.h>
    10.9  #include <public/xencomm.h>
   10.10  
    11.1 --- a/xen/include/asm-powerpc/debugger.h	Fri Sep 22 11:02:47 2006 -0400
    11.2 +++ b/xen/include/asm-powerpc/debugger.h	Thu Nov 30 15:26:55 2006 -0600
    11.3 @@ -21,6 +21,38 @@
    11.4  #ifndef _ASM_DEBUGGER_H_
    11.5  #define _ASM_DEBUGGER_H_
    11.6  
    11.7 +extern void show_backtrace_regs(struct cpu_user_regs *);
    11.8 +extern void show_backtrace(ulong sp, ulong lr, ulong pc);
    11.9 +
   11.10 +static inline void dump_execution_state(void)
   11.11 +{
   11.12 +    ulong sp;
   11.13 +    ulong lr;
   11.14 +
   11.15 +    sp = (ulong)__builtin_frame_address(0);
   11.16 +    lr = (ulong)__builtin_return_address(0);
   11.17 +
   11.18 +    show_backtrace(sp, lr, lr);
   11.19 +}
   11.20 +
   11.21 +static inline void debugger_trap_immediate(void)
   11.22 +{
   11.23 +    dump_execution_state();
   11.24 +    __builtin_trap();
   11.25 +}
   11.26 +
   11.27 +static inline void show_execution_state(struct cpu_user_regs *regs)
   11.28 +{
   11.29 +    show_registers(regs);
   11.30 +}
   11.31 +
   11.32 +extern void __warn(char *file, int line);
   11.33 +#define WARN() __warn(__FILE__, __LINE__)
   11.34 +#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
   11.35 +#define unimplemented() WARN()
   11.36 +
   11.37 +#define FORCE_CRASH() debugger_trap_immediate()
   11.38 +
   11.39  #ifdef CRASH_DEBUG
   11.40  
   11.41  #include <xen/gdbstub.h>
   11.42 @@ -32,8 +64,6 @@ static inline int debugger_trap_fatal(
   11.43      return vector;
   11.44  }
   11.45  
   11.46 -#define debugger_trap_immediate() __asm__ __volatile__ ("trap");
   11.47 -
   11.48  #else /* CRASH_DEBUG */
   11.49  
   11.50  static inline int debugger_trap_fatal(
   11.51 @@ -43,17 +73,6 @@ static inline int debugger_trap_fatal(
   11.52      return vector;
   11.53  }
   11.54  
   11.55 -static inline void debugger_trap_immediate(void)
   11.56 -{
   11.57 -    ulong sp;
   11.58 -    ulong lr;
   11.59 -
   11.60 -    sp = (ulong)__builtin_frame_address(0);
   11.61 -    lr = (ulong)__builtin_return_address(0);
   11.62 -
   11.63 -    show_backtrace(sp, lr, lr);
   11.64 -}
   11.65 -
   11.66  #endif /* CRASH_DEBUG */
   11.67  
   11.68  #endif
    12.1 --- a/xen/include/asm-powerpc/flushtlb.h	Fri Sep 22 11:02:47 2006 -0400
    12.2 +++ b/xen/include/asm-powerpc/flushtlb.h	Thu Nov 30 15:26:55 2006 -0600
    12.3 @@ -24,7 +24,6 @@
    12.4  #include <xen/config.h>
    12.5  #include <xen/percpu.h>
    12.6  #include <xen/types.h>
    12.7 -#include <asm/misc.h>
    12.8  
    12.9  /* The current time as shown by the virtual TLB clock. */
   12.10  extern u32 tlbflush_clock;
    13.1 --- a/xen/include/asm-powerpc/misc.h	Fri Sep 22 11:02:47 2006 -0400
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,33 +0,0 @@
    13.4 -/*
    13.5 - * This program is free software; you can redistribute it and/or modify
    13.6 - * it under the terms of the GNU General Public License as published by
    13.7 - * the Free Software Foundation; either version 2 of the License, or
    13.8 - * (at your option) any later version.
    13.9 - *
   13.10 - * This program is distributed in the hope that it will be useful,
   13.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.13 - * GNU General Public License for more details.
   13.14 - *
   13.15 - * You should have received a copy of the GNU General Public License
   13.16 - * along with this program; if not, write to the Free Software
   13.17 - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
   13.18 - *
   13.19 - * Copyright (C) IBM Corp. 2005
   13.20 - *
   13.21 - * Authors: Hollis Blanchard <hollisb@us.ibm.com>
   13.22 - */
   13.23 -
   13.24 -#ifndef _ASM_MISC_H_
   13.25 -#define _ASM_MISC_H_
   13.26 -
   13.27 -static inline void unimplemented(void)
   13.28 -{
   13.29 -}
   13.30 -
   13.31 -static inline void trap(void)
   13.32 -{
   13.33 -    asm volatile("trap");
   13.34 -}
   13.35 -
   13.36 -#endif
    14.1 --- a/xen/include/asm-powerpc/mm.h	Fri Sep 22 11:02:47 2006 -0400
    14.2 +++ b/xen/include/asm-powerpc/mm.h	Thu Nov 30 15:26:55 2006 -0600
    14.3 @@ -25,7 +25,6 @@
    14.4  #include <xen/list.h>
    14.5  #include <xen/types.h>
    14.6  #include <xen/mm.h>
    14.7 -#include <asm/misc.h>
    14.8  #include <asm/system.h>
    14.9  #include <asm/flushtlb.h>
   14.10  #include <asm/uaccess.h>
    15.1 --- a/xen/include/asm-powerpc/page.h	Fri Sep 22 11:02:47 2006 -0400
    15.2 +++ b/xen/include/asm-powerpc/page.h	Thu Nov 30 15:26:55 2006 -0600
    15.3 @@ -28,7 +28,6 @@
    15.4  #ifndef __ASSEMBLY__
    15.5  
    15.6  #include <xen/config.h>
    15.7 -#include <asm/misc.h>
    15.8  #include <asm/cache.h>
    15.9  
   15.10  #define PFN_DOWN(x)   ((x) >> PAGE_SHIFT)
    16.1 --- a/xen/include/asm-powerpc/processor.h	Fri Sep 22 11:02:47 2006 -0400
    16.2 +++ b/xen/include/asm-powerpc/processor.h	Thu Nov 30 15:26:55 2006 -0600
    16.3 @@ -38,10 +38,7 @@ struct domain;
    16.4  struct vcpu;
    16.5  struct cpu_user_regs;
    16.6  extern int cpu_machinecheck(struct cpu_user_regs *);
    16.7 -extern void cpu_scom_init(void);
    16.8  extern void show_registers(struct cpu_user_regs *);
    16.9 -extern void show_execution_state(struct cpu_user_regs *);
   16.10 -extern void show_backtrace(ulong sp, ulong lr, ulong pc);
   16.11  extern unsigned int cpu_extent_order(void);
   16.12  extern unsigned int cpu_default_rma_order_pages(void);
   16.13  extern int cpu_rma_valid(unsigned int log);
   16.14 @@ -54,13 +51,6 @@ extern void load_cpu_sprs(struct vcpu *)
   16.15  extern void flush_segments(void);
   16.16  extern void dump_segments(int valid);
   16.17  
   16.18 -/* XXX this could also land us in GDB */
   16.19 -#define dump_execution_state() BUG()
   16.20 -
   16.21 -extern void __warn(char *file, int line);
   16.22 -#define WARN() __warn(__FILE__, __LINE__)
   16.23 -#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 )
   16.24 -
   16.25  #define ARCH_HAS_PREFETCH
   16.26  static inline void prefetch(const void *x) {;}
   16.27