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

TOMOYO Linux Cross Reference
Linux/arch/um/kernel/stacktrace.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4  * Copyright (C) 2013 Richard Weinberger <richard@nod.at>
  5  * Copyright (C) 2014 Google Inc., Author: Daniel Walter <dwalter@google.com>
  6  */
  7 
  8 #include <linux/kallsyms.h>
  9 #include <linux/kernel.h>
 10 #include <linux/sched.h>
 11 #include <linux/stacktrace.h>
 12 #include <linux/module.h>
 13 #include <linux/uaccess.h>
 14 #include <asm/stacktrace.h>
 15 
 16 void dump_trace(struct task_struct *tsk,
 17                 const struct stacktrace_ops *ops,
 18                 void *data)
 19 {
 20         int reliable = 0;
 21         unsigned long *sp, bp, addr;
 22         struct pt_regs *segv_regs = tsk->thread.segv_regs;
 23         struct stack_frame *frame;
 24 
 25         bp = get_frame_pointer(tsk, segv_regs);
 26         sp = get_stack_pointer(tsk, segv_regs);
 27 
 28         frame = (struct stack_frame *)bp;
 29         while (((long) sp & (THREAD_SIZE-1)) != 0) {
 30                 addr = READ_ONCE_NOCHECK(*sp);
 31                 if (__kernel_text_address(addr)) {
 32                         reliable = 0;
 33                         if ((unsigned long) sp == bp + sizeof(long)) {
 34                                 frame = frame ? frame->next_frame : NULL;
 35                                 bp = (unsigned long)frame;
 36                                 reliable = 1;
 37                         }
 38                         ops->address(data, addr, reliable);
 39                 }
 40                 sp++;
 41         }
 42 }
 43 
 44 static void save_addr(void *data, unsigned long address, int reliable)
 45 {
 46         struct stack_trace *trace = data;
 47 
 48         if (!reliable)
 49                 return;
 50         if (trace->nr_entries >= trace->max_entries)
 51                 return;
 52 
 53         trace->entries[trace->nr_entries++] = address;
 54 }
 55 
 56 static const struct stacktrace_ops dump_ops = {
 57         .address = save_addr
 58 };
 59 
 60 static void __save_stack_trace(struct task_struct *tsk, struct stack_trace *trace)
 61 {
 62         dump_trace(tsk, &dump_ops, trace);
 63 }
 64 
 65 void save_stack_trace(struct stack_trace *trace)
 66 {
 67         __save_stack_trace(current, trace);
 68 }
 69 EXPORT_SYMBOL_GPL(save_stack_trace);
 70 
 71 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 72 {
 73         __save_stack_trace(tsk, trace);
 74 }
 75 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
 76 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php