~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/avr32/oprofile/backtrace.c

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * AVR32 specific backtracing code for oprofile
  3  *
  4  * Copyright 2008 Weinmann GmbH
  5  *
  6  * Author: Nikolaus Voss <n.voss@weinmann.de>
  7  *
  8  * Based on i386 oprofile backtrace code by John Levon and David Smith
  9  *
 10  * This program is free software; you can redistribute it and/or modify
 11  * it under the terms of the GNU General Public License version 2 as
 12  * published by the Free Software Foundation.
 13  *
 14  */
 15 
 16 #include <linux/oprofile.h>
 17 #include <linux/sched.h>
 18 #include <linux/uaccess.h>
 19 
 20 /* The first two words of each frame on the stack look like this if we have
 21  * frame pointers */
 22 struct frame_head {
 23         unsigned long lr;
 24         struct frame_head *fp;
 25 };
 26 
 27 /* copied from arch/avr32/kernel/process.c */
 28 static inline int valid_stack_ptr(struct thread_info *tinfo, unsigned long p)
 29 {
 30         return (p > (unsigned long)tinfo)
 31                 && (p < (unsigned long)tinfo + THREAD_SIZE - 3);
 32 }
 33 
 34 /* copied from arch/x86/oprofile/backtrace.c */
 35 static struct frame_head *dump_user_backtrace(struct frame_head *head)
 36 {
 37         struct frame_head bufhead[2];
 38 
 39         /* Also check accessibility of one struct frame_head beyond */
 40         if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
 41                 return NULL;
 42         if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
 43                 return NULL;
 44 
 45         oprofile_add_trace(bufhead[0].lr);
 46 
 47         /* frame pointers should strictly progress back up the stack
 48          * (towards higher addresses) */
 49         if (bufhead[0].fp <= head)
 50                 return NULL;
 51 
 52         return bufhead[0].fp;
 53 }
 54 
 55 void avr32_backtrace(struct pt_regs * const regs, unsigned int depth)
 56 {
 57         /* Get first frame pointer */
 58         struct frame_head *head = (struct frame_head *)(regs->r7);
 59 
 60         if (!user_mode(regs)) {
 61 #ifdef CONFIG_FRAME_POINTER
 62                 /*
 63                  * Traverse the kernel stack from frame to frame up to
 64                  * "depth" steps.
 65                  */
 66                 while (depth-- && valid_stack_ptr(task_thread_info(current),
 67                                                   (unsigned long)head)) {
 68                         oprofile_add_trace(head->lr);
 69                         if (head->fp <= head)
 70                                 break;
 71                         head = head->fp;
 72                 }
 73 #endif
 74         } else {
 75                 /* Assume we have frame pointers in user mode process */
 76                 while (depth-- && head)
 77                         head = dump_user_backtrace(head);
 78         }
 79 }
 80 
 81 
 82 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp