mrdump_arm64.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <linux/bug.h>
  2. #include <linux/kallsyms.h>
  3. #include <linux/ptrace.h>
  4. #include <asm/stacktrace.h>
  5. #include <asm/system_misc.h>
  6. #include <asm/traps.h>
  7. #include "mrdump_private.h"
  8. static void mrdump_dump_backtrace(struct pt_regs *regs)
  9. {
  10. struct stackframe frame;
  11. int count = 0;
  12. if (regs == NULL)
  13. return;
  14. frame.fp = regs->regs[29];
  15. frame.sp = regs->sp;
  16. frame.pc = regs->pc;
  17. pr_notice("Call trace:\n");
  18. while (count++ < 32) {
  19. unsigned long where = frame.pc;
  20. int ret;
  21. ret = unwind_frame(&frame);
  22. if (ret < 0)
  23. break;
  24. print_ip_sym(where);
  25. #if 0
  26. if (in_exception_text(where))
  27. dump_mem("", "Exception stack", frame.sp,
  28. frame.sp + sizeof(struct pt_regs));
  29. #endif
  30. }
  31. }
  32. void mrdump_save_current_backtrace(struct pt_regs *regs)
  33. {
  34. asm volatile ("stp x0, x1, [%0]\n\t"
  35. "stp x2, x3, [%0, #16]\n\t"
  36. "stp x4, x5, [%0, #32]\n\t"
  37. "stp x6, x7, [%0, #48]\n\t"
  38. "stp x8, x9, [%0, #64]\n\t"
  39. "stp x10, x11, [%0, #80]\n\t"
  40. "stp x12, x13, [%0, #96]\n\t"
  41. "stp x14, x15, [%0, #112]\n\t"
  42. "stp x16, x17, [%0, #128]\n\t"
  43. "stp x18, x19, [%0, #144]\n\t"
  44. "stp x20, x21, [%0, #160]\n\t"
  45. "stp x22, x23, [%0, #176]\n\t"
  46. "stp x24, x25, [%0, #192]\n\t"
  47. "stp x26, x27, [%0, #208]\n\t"
  48. "stp x28, x29, [%0, #224]\n\t"
  49. "str x30, [%0, #240]\n\t" : : "r" (&regs->user_regs) : "memory");
  50. asm volatile ("mov x8, sp\n\t"
  51. "str x8, [%0]\n\t"
  52. "1:\n\t"
  53. "adr x8, 1b\n\t"
  54. "str x8, [%1]\n\t" : : "r" (&regs->user_regs.sp), "r"(&regs->user_regs.pc) : "x8", "memory");
  55. }
  56. void mrdump_print_crash(struct pt_regs *regs)
  57. {
  58. __show_regs(regs);
  59. mrdump_dump_backtrace(regs);
  60. }