| 
									
										
										
										
											2010-05-28 23:09:12 -04:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright 2010 Tilera Corporation. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  *   modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  *   as published by the Free Software Foundation, version 2. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   This program is distributed in the hope that it will be useful, but | 
					
						
							|  |  |  |  *   WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | 
					
						
							|  |  |  |  *   NON INFRINGEMENT.  See the GNU General Public License for | 
					
						
							|  |  |  |  *   more details. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _ASM_TILE_STACK_H
 | 
					
						
							|  |  |  | #define _ASM_TILE_STACK_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/types.h>
 | 
					
						
							|  |  |  | #include <linux/sched.h>
 | 
					
						
							|  |  |  | #include <asm/backtrace.h>
 | 
					
						
							| 
									
										
										
										
											2011-02-28 16:37:34 -05:00
										 |  |  | #include <asm/page.h>
 | 
					
						
							| 
									
										
										
										
											2010-05-28 23:09:12 -04:00
										 |  |  | #include <hv/hypervisor.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Everything we need to keep track of a backtrace iteration */ | 
					
						
							|  |  |  | struct KBacktraceIterator { | 
					
						
							|  |  |  | 	BacktraceIterator it; | 
					
						
							|  |  |  | 	struct task_struct *task;     /* task we are backtracing */ | 
					
						
							|  |  |  | 	int end;		      /* iteration complete. */ | 
					
						
							|  |  |  | 	int new_context;              /* new context is starting */ | 
					
						
							|  |  |  | 	int profile;                  /* profiling, so stop on async intrpt */ | 
					
						
							|  |  |  | 	int verbose;		      /* printk extra info (don't want to
 | 
					
						
							|  |  |  | 				       * do this for profiling) */ | 
					
						
							|  |  |  | 	int is_current;               /* backtracing current task */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Iteration methods for kernel backtraces */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Initialize a KBacktraceIterator from a task_struct, and optionally from | 
					
						
							|  |  |  |  * a set of registers.  If the registers are omitted, the process is | 
					
						
							|  |  |  |  * assumed to be descheduled, and registers are read from the process's | 
					
						
							|  |  |  |  * thread_struct and stack.  "verbose" means to printk some additional | 
					
						
							|  |  |  |  * information about fault handlers as we pass them on the stack. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | extern void KBacktraceIterator_init(struct KBacktraceIterator *kbt, | 
					
						
							|  |  |  | 				    struct task_struct *, struct pt_regs *); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Initialize iterator based on current stack. */ | 
					
						
							|  |  |  | extern void KBacktraceIterator_init_current(struct KBacktraceIterator *kbt); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-25 17:04:17 -04:00
										 |  |  | /* Helper method for above. */ | 
					
						
							|  |  |  | extern void _KBacktraceIterator_init_current(struct KBacktraceIterator *kbt, | 
					
						
							|  |  |  | 				ulong pc, ulong lr, ulong sp, ulong r52); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-28 23:09:12 -04:00
										 |  |  | /* No more frames? */ | 
					
						
							|  |  |  | extern int KBacktraceIterator_end(struct KBacktraceIterator *kbt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Advance to the next frame. */ | 
					
						
							|  |  |  | extern void KBacktraceIterator_next(struct KBacktraceIterator *kbt); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												tile: improve stack backtrace
This commit fixes a number of issues with the tile backtrace code.
- Don't try to identify userspace shared object or executable paths
  if we are doing a backtrace from an interrupt; it's not legal,
  and also unlikely to be interesting.  Likewise, don't try to do
  it for other address spaces, since d_path() assumes it is being
  called in "current" context.
- Move "in_backtrace" from thread_struct to thread_info.
  This way we can access it even if our stack thread_info has been
  clobbered, which makes backtracing more robust.
- Avoid using "current" directly when testing for is_sigreturn().
  Since "current" may be corrupt, we're better off using kbt->task
  explicitly to look up the vdso_base for the current task.
  Conveniently, this simplifies the internal APIs (we only need
  one is_sigreturn() function now).
- Avoid bogus "Odd fault" warning when pc/sp/ex1 are all zero,
  as is true for kernel threads above the last frame.
- Hook into Tejun Heo's dump_stack() framework in lib/dump_stack.c.
- Write last entry in save_stack_trace() as ULONG_MAX, not zero,
  since ftrace (at least) relies on finding that marker.
- Implement save_stack_trace_regs() and save_strack_trace_user(),
  and set CONFIG_USER_STACKTRACE_SUPPORT.
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
											
										 
											2015-05-08 10:27:35 -04:00
										 |  |  | /* Dump just the contents of the pt_regs structure. */ | 
					
						
							|  |  |  | extern void tile_show_regs(struct pt_regs *); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-28 23:09:12 -04:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Dump stack given complete register info. Use only from the | 
					
						
							|  |  |  |  * architecture-specific code; show_stack() | 
					
						
							| 
									
										
											  
											
												tile: improve stack backtrace
This commit fixes a number of issues with the tile backtrace code.
- Don't try to identify userspace shared object or executable paths
  if we are doing a backtrace from an interrupt; it's not legal,
  and also unlikely to be interesting.  Likewise, don't try to do
  it for other address spaces, since d_path() assumes it is being
  called in "current" context.
- Move "in_backtrace" from thread_struct to thread_info.
  This way we can access it even if our stack thread_info has been
  clobbered, which makes backtracing more robust.
- Avoid using "current" directly when testing for is_sigreturn().
  Since "current" may be corrupt, we're better off using kbt->task
  explicitly to look up the vdso_base for the current task.
  Conveniently, this simplifies the internal APIs (we only need
  one is_sigreturn() function now).
- Avoid bogus "Odd fault" warning when pc/sp/ex1 are all zero,
  as is true for kernel threads above the last frame.
- Hook into Tejun Heo's dump_stack() framework in lib/dump_stack.c.
- Write last entry in save_stack_trace() as ULONG_MAX, not zero,
  since ftrace (at least) relies on finding that marker.
- Implement save_stack_trace_regs() and save_strack_trace_user(),
  and set CONFIG_USER_STACKTRACE_SUPPORT.
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
											
										 
											2015-05-08 10:27:35 -04:00
										 |  |  |  * and dump_stack() are architecture-independent entry points. | 
					
						
							| 
									
										
										
										
											2010-05-28 23:09:12 -04:00
										 |  |  |  */ | 
					
						
							| 
									
										
											  
											
												tile: improve stack backtrace
This commit fixes a number of issues with the tile backtrace code.
- Don't try to identify userspace shared object or executable paths
  if we are doing a backtrace from an interrupt; it's not legal,
  and also unlikely to be interesting.  Likewise, don't try to do
  it for other address spaces, since d_path() assumes it is being
  called in "current" context.
- Move "in_backtrace" from thread_struct to thread_info.
  This way we can access it even if our stack thread_info has been
  clobbered, which makes backtracing more robust.
- Avoid using "current" directly when testing for is_sigreturn().
  Since "current" may be corrupt, we're better off using kbt->task
  explicitly to look up the vdso_base for the current task.
  Conveniently, this simplifies the internal APIs (we only need
  one is_sigreturn() function now).
- Avoid bogus "Odd fault" warning when pc/sp/ex1 are all zero,
  as is true for kernel threads above the last frame.
- Hook into Tejun Heo's dump_stack() framework in lib/dump_stack.c.
- Write last entry in save_stack_trace() as ULONG_MAX, not zero,
  since ftrace (at least) relies on finding that marker.
- Implement save_stack_trace_regs() and save_strack_trace_user(),
  and set CONFIG_USER_STACKTRACE_SUPPORT.
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
											
										 
											2015-05-08 10:27:35 -04:00
										 |  |  | extern void tile_show_stack(struct KBacktraceIterator *); | 
					
						
							| 
									
										
										
										
											2010-05-28 23:09:12 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif /* _ASM_TILE_STACK_H */
 |